diff --git a/src/core/BaseModel.coffee b/src/core/BaseModel.coffee index b2bfd21..2c32936 100644 --- a/src/core/BaseModel.coffee +++ b/src/core/BaseModel.coffee @@ -32,10 +32,10 @@ class BaseModel render: (p) -> _GUI.loadScheme p, @, @host - quit: () -> + quit: (force) -> evt = new _GUI.BaseEvent("exit") - @onexit(evt) - if not evt.prevent + @onexit(evt) if not force + if force or not evt.prevent delete @.observable @dialog.quit() if @dialog _PM.kill @ diff --git a/src/core/api.coffee b/src/core/api.coffee index 6d779cd..3d6c93e 100644 --- a/src/core/api.coffee +++ b/src/core/api.coffee @@ -42,6 +42,46 @@ class FormatedString args = arguments @values[i] = args[i] for i in [0..args.length - 1] +class Version + constructor:(@string) -> + arr = @string.split "-" + br = + "r": 3, + "b": 2, + "a": 1 + @branch = 3 + @branch = br[arr[1]] if arr.length is 2 and br[arr[1]] + mt = arr[0].match /\d+/g + throw new Error __("Version string is in invalid format: {0}", @string) if not mt + @major = 0 + @minor = 0 + @patch = 0 + @major = Number mt[0] if mt.length >= 1 + @minor = Number mt[1] if mt.length >= 2 + @patch = Number mt[2] if mt.length >= 3 + + # this function return + # 0 if the version is unchanged + # 1 if the current version is newer + # -1 if the current version is older + compare: (o) -> + other = o.__v() + return 1 if @branch > other.branch + return -1 if @branch < other.branch + return 0 if @major is other.major and @minor is other.minor and @patch is other.patch + return 1 if @major > other.major + return -1 if @major < other.major + return 1 if @minor > other.minor + return -1 if @minor < other.minor + return 1 if @patch > other.patch + return -1 + nt: (o) -> + return (@compare o) is 1 + ot: (o) -> + return (@compare o) is -1 + __v: () -> @ + toString: () -> @string + Object.defineProperty Object.prototype, '__', value: () -> return @toString() @@ -53,7 +93,8 @@ String.prototype.hash = () -> i = this.length hash = (hash * 33) ^ this.charCodeAt(--i) while i hash >>> 0 - +String.prototype.__v = () -> + return new Version @ String.prototype.asBase64 = () -> tmp = encodeURIComponent this return btoa ( tmp.replace /%([0-9A-F]{2})/g, (match, p1) -> diff --git a/src/core/core.coffee b/src/core/core.coffee index f8214e8..4e52b20 100644 --- a/src/core/core.coffee +++ b/src/core/core.coffee @@ -103,11 +103,11 @@ self.OS or= delete _PM.processes[app.name][i] _PM.processes[app.name].splice i, 1 - killAll: (app) -> + killAll: (app, force) -> return unless _PM.processes[app] tmp = [] tmp.push a for a in _PM.processes[app] - a.quit() for a in tmp + a.quit(force) for a in tmp cleanup: -> console.log "Clean up system" diff --git a/src/core/gui.coffee b/src/core/gui.coffee index f6f4fcf..a066c50 100644 --- a/src/core/gui.coffee +++ b/src/core/gui.coffee @@ -133,11 +133,14 @@ self.OS.GUI = forceLaunch: (app, args) -> console.log "This method is used for developing only, please use the launch method instead" - _PM.killAll app - ($ _OS.APP[app].style).remove() if _OS.APP[app] and _OS.APP[app].style - _OS.APP[app] = undefined + _GUI.unloadApp app _GUI.launch app, args + unloadApp: (app) -> + _PM.killAll app, true + ($ _OS.APP[app].style).remove() if _OS.APP[app] and _OS.APP[app].style + _OS.APP[app] = undefined + loadApp: (app, ok, err) -> path = "os://packages/#{app}" path = _OS.setting.system.packages[app].path if _OS.setting.system.packages[app].path diff --git a/src/packages/ActivityMonitor/main.coffee b/src/packages/ActivityMonitor/main.coffee index 5dc66ea..8028b5a 100644 --- a/src/packages/ActivityMonitor/main.coffee +++ b/src/packages/ActivityMonitor/main.coffee @@ -29,7 +29,7 @@ class ActivityMonitor extends this.OS.GUI.BaseApplication item = me.grid.get "selected" return unless item app = _PM.appByPid item[0].value - app.quit() if app + app.quit(true) if app header = [{width:50,value: "__(Pid)"},{value:"__(Name)"}, {value:"__(Type)", width:80},{width:75,value: "__(Alive (ms))"}] @gdata = diff --git a/src/packages/ActivityMonitor/package.json b/src/packages/ActivityMonitor/package.json index e6d5b27..2ad54c7 100644 --- a/src/packages/ActivityMonitor/package.json +++ b/src/packages/ActivityMonitor/package.json @@ -6,7 +6,7 @@ "author": "Xuan Sang LE", "email": "xsang.le@gmail.com" }, - "version":"0.1a", + "version":"0.0.1-a", "category":"System", "iconclass":"fa fa-heartbeat", "mimes":["none"] diff --git a/src/packages/AntOSDK/package.json b/src/packages/AntOSDK/package.json index bf3667d..f37eca7 100644 --- a/src/packages/AntOSDK/package.json +++ b/src/packages/AntOSDK/package.json @@ -6,7 +6,7 @@ "author": "Xuan Sang LE", "email": "xsang.le@gmail.com" }, - "version":"0.1a", + "version":"0.0.1-a", "category":"System", "iconclass":"fa fa-cubes", "mimes":[ diff --git a/src/packages/Blogger/package.json b/src/packages/Blogger/package.json index b459947..d9e682b 100644 --- a/src/packages/Blogger/package.json +++ b/src/packages/Blogger/package.json @@ -6,7 +6,7 @@ "author": "Xuan Sang LE", "email": "xsang.le@gmail.com" }, - "version":"0.1a", + "version":"0.0.1-a", "category":"Internet", "iconclass":"fa fa-book", "mimes":["none"] diff --git a/src/packages/CodeBlock/package.json b/src/packages/CodeBlock/package.json index ee04189..d005d95 100644 --- a/src/packages/CodeBlock/package.json +++ b/src/packages/CodeBlock/package.json @@ -6,7 +6,7 @@ "author": "Xuan Sang LE", "email": "xsang.le@gmail.com" }, - "version":"0.1a", + "version":"0.0.1-a", "category":"Programming", "iconclass":"fa fa-puzzle-piece", "mimes":["none"] diff --git a/src/packages/CoreServices/package.json b/src/packages/CoreServices/package.json index 5b71523..eb7f9a7 100644 --- a/src/packages/CoreServices/package.json +++ b/src/packages/CoreServices/package.json @@ -9,7 +9,7 @@ "credit": "dedicated to some one here", "licences": "GPLv3" }, - "version":"0.1a", + "version":"0.0.1-a", "category":"System", "mimes":["*"] } \ No newline at end of file diff --git a/src/packages/DummyApp/package.json b/src/packages/DummyApp/package.json index 655ca4b..2f01e8c 100644 --- a/src/packages/DummyApp/package.json +++ b/src/packages/DummyApp/package.json @@ -8,7 +8,7 @@ "credit": "dedicated to some one here", "licences": "GPLv3" }, - "version":"0.1a", + "version":"0.0.2-a", "category":"System", "icon": "icon.png", "mimes":["none"] diff --git a/src/packages/Files/package.json b/src/packages/Files/package.json index 0f6511f..a3bb1a5 100644 --- a/src/packages/Files/package.json +++ b/src/packages/Files/package.json @@ -6,7 +6,7 @@ "author": "Xuan Sang LE", "email": "xsang.le@gmail.com" }, - "version":"0.1a", + "version":"0.0.1-a", "category":"System", "iconclass":"fa fa-hdd-o", "mimes":["dir"] diff --git a/src/packages/GraphEditor/package.json b/src/packages/GraphEditor/package.json index 4b38cbe..3d06ddd 100644 --- a/src/packages/GraphEditor/package.json +++ b/src/packages/GraphEditor/package.json @@ -7,7 +7,7 @@ "email": "xsang.le@gmail.com", "licences": "GPLv3" }, - "version":"0.1a", + "version":"0.0.1-a", "category":"Office", "iconclass": "fa fa-sitemap", "mimes":["text/.*graphviz"] diff --git a/src/packages/MarkOn/package.json b/src/packages/MarkOn/package.json index 18cf73a..51ce51d 100644 --- a/src/packages/MarkOn/package.json +++ b/src/packages/MarkOn/package.json @@ -6,7 +6,7 @@ "author": "Xuan Sang LE", "email": "xsang.le@gmail.com" }, - "version":"0.1a", + "version":"0.0.1-a", "category":"Utils", "iconclass":"fa fa-leanpub", "mimes":["text/.*"] diff --git a/src/packages/MarketPlace/main.coffee b/src/packages/MarketPlace/main.coffee index 2e457d2..de03c63 100644 --- a/src/packages/MarketPlace/main.coffee +++ b/src/packages/MarketPlace/main.coffee @@ -48,9 +48,10 @@ class MarketPlace extends this.OS.GUI.BaseApplication return unless app me._gui.launch app.className if app.className @btinstall.set "onbtclick", (e) -> - me.install e + return me.update() if me.btinstall.get "dirty" + me.install() @btremove.set "onbtclick", (e) -> - me.uninstall e + me.uninstall() @bindKey "CTRL-R", () -> me.openDialog new RepositoryDialog() fetchApps: (url) -> @@ -67,15 +68,28 @@ class MarketPlace extends this.OS.GUI.BaseApplication me = @ ($ @container).css "visibility", "visible" ( $ @appname ).html d.name + (@find "vstat").set "text", "" if d.description d.description.asFileHandler().read (text) -> converter = new showdown.Converter() ($ me.appdesc).html converter.makeHtml text else ($ me.appdesc).empty() - - if @systemsetting.system.packages[d.className] + pkgcache = @systemsetting.system.packages + @btinstall.set "text", "__(Install)" + @btinstall.set "dirty", false + if pkgcache[d.className] + vs = pkgcache[d.className].version + ovs = d.version ($ @btinstall).hide() + if vs and ovs + vs = vs.__v() + ovs = ovs.__v() + if ovs.nt vs + @btinstall.set "dirty", true + @btinstall.set "text", "__(Update)" + ($ @btinstall).show() + (@find "vstat").set "text", __("Your application version is older ({0} < {1})", vs, ovs) ($ @btremove).show() ($ @btexec).show() else @@ -97,7 +111,7 @@ class MarketPlace extends this.OS.GUI.BaseApplication } ] - install: (e) -> + install: (f) -> me = @ app = @applist.get "selected" return unless app @@ -134,7 +148,7 @@ class MarketPlace extends this.OS.GUI.BaseApplication , (err, s) -> return me.error __("Cannot down load the app {0}", err) if err - uninstall: (e) -> + uninstall: (f) -> me = @ sel = @applist.get "selected" name = sel.className @@ -148,12 +162,21 @@ class MarketPlace extends this.OS.GUI.BaseApplication return me.error __("Cannot uninstall package: {0}", r.error) if r.error me.notify __("Package uninstalled") delete me.systemsetting.system.packages[name] - window.OS.PM.killAll name - delete window.OS.APP[name] + me._gui.unloadApp name me._gui.refreshSystemMenu() me.appDetail sel + f() if f , __("Uninstall") , - { text: __("Uninstall : {0}?", app.name) } + { text: __("Uninstall: {0}?", app.name) } + + update: () -> + me = @ + new Promise (r, e) -> + me.uninstall () -> + r() + .then () -> + me.install() + mkdirs: (n, list, f) -> me = @ if list.length is 0 diff --git a/src/packages/MarketPlace/main.css b/src/packages/MarketPlace/main.css index 3406718..9267cb1 100644 --- a/src/packages/MarketPlace/main.css +++ b/src/packages/MarketPlace/main.css @@ -61,6 +61,15 @@ afx-app-window[data-id="marketplace-win"] ul[data-id='app-detail'] span{ afx-app-window[data-id="marketplace-win"] span.info-header{ font-weight: bold; } +afx-app-window[data-id="marketplace-win"] afx-label[data-id="vstat"] { + font-size: 11px; + color: chocolate; +} +afx-app-window[data-id="marketplace-win"] p.stat { + margin: 0; + padding:0; + margin-bottom: 10px; +} afx-app-window[data-id = "repository-dialog-win"] afx-list-view[data-id="repo-list"] ul.complex-content > li{ font-size: 11px; font-style: italic; diff --git a/src/packages/MarketPlace/package.json b/src/packages/MarketPlace/package.json index 7954bf5..bc79268 100644 --- a/src/packages/MarketPlace/package.json +++ b/src/packages/MarketPlace/package.json @@ -6,7 +6,7 @@ "author": "Xuan Sang LE", "email": "xsang.le@gmail.com" }, - "version":"0.1a", + "version":"0.0.1-a", "category":"System", "iconclass":"fa fa-adn", "mimes":["none"] diff --git a/src/packages/MarketPlace/scheme.html b/src/packages/MarketPlace/scheme.html index 8e067e8..bad486a 100644 --- a/src/packages/MarketPlace/scheme.html +++ b/src/packages/MarketPlace/scheme.html @@ -7,14 +7,15 @@
- +
+

-
+

    diff --git a/src/packages/NotePad/package.json b/src/packages/NotePad/package.json index 633fb69..9192249 100644 --- a/src/packages/NotePad/package.json +++ b/src/packages/NotePad/package.json @@ -6,7 +6,7 @@ "author": "Xuan Sang LE", "email": "xsang.le@gmail.com" }, - "version":"0.1a", + "version":"0.0.1-a", "category":"System", "iconclass":"fa fa-pencil-square-o", "mimes":[ diff --git a/src/packages/Preview/package.json b/src/packages/Preview/package.json index 7c7a88d..1759a43 100644 --- a/src/packages/Preview/package.json +++ b/src/packages/Preview/package.json @@ -6,7 +6,7 @@ "author": "Xuan Sang LE", "email": "xsang.le@gmail.com" }, - "version":"0.1a", + "version":"0.0.1-a", "category":"Utils", "iconclass":"fa fa-eye", "mimes":["[^\/]*/.*pdf", "image/.*"] diff --git a/src/packages/Setting/package.json b/src/packages/Setting/package.json index ecdeeac..e50bc7a 100644 --- a/src/packages/Setting/package.json +++ b/src/packages/Setting/package.json @@ -6,7 +6,7 @@ "author": "Xuan Sang LE", "email": "xsang.le@gmail.com" }, - "version":"0.1a", + "version":"0.0.1-a", "category":"System", "iconclass":"fa fa-wrench", "mimes":["none"] diff --git a/src/packages/wTerm/package.json b/src/packages/wTerm/package.json index 08d86cc..a5f44eb 100644 --- a/src/packages/wTerm/package.json +++ b/src/packages/wTerm/package.json @@ -6,7 +6,7 @@ "author": "Xuan Sang LE", "email": "xsang.le@gmail.com" }, - "version":"0.1a", + "version":"0.0.1-a", "category":"System", "iconclass":"fa fa-terminal", "mimes":["none"]