/
appStoreLauncher.js
83 lines (66 loc) · 2.47 KB
/
appStoreLauncher.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
// -*- mode: js; js-indent-level: 4; indent-tabs-mode: nil -*-
const Gdk = imports.gi.Gdk;
const Gio = imports.gi.Gio;
const Lang = imports.lang;
const Config = imports.config;
const Environment = imports.environment;
const APP_STORE_NAME = 'com.endlessm.AppStore';
const APP_STORE_PATH = '/com/endlessm/AppStore';
const APP_STORE_IFACE = 'com.endlessm.AppStore';
/* We launch the page remotely but we only need a subset of its DBus API */
const AppStoreIface = '<node><interface name="com.endlessm.AppStore">' +
'<method name="showPage">' +
'<arg type="u" direction="in" name="timestamp"/>' +
'<arg type="s" direction="in" name="page"/>' +
'</method>' +
'</interface></node>';
const AppStoreProxy = Gio.DBusProxy.makeProxyWrapper(AppStoreIface);
var AppStoreLauncher = new Lang.Class({
Name: 'AppStoreLauncher',
_init: function() {
this.proxy = new AppStoreProxy(Gio.DBus.session,
APP_STORE_NAME,
APP_STORE_PATH,
Lang.bind(this, this._onProxyConstructed));
},
_onProxyConstructed: function() {
log("Launching com.endlessm.AppStore service...");
}
});
function main() {
Environment.init();
let initialPage = 'apps';
let args = ARGV;
for (let i in args) {
let arg = args[i];
if (arg == '-w' || arg == '--web-links') {
initialPage = 'web';
args.splice(i, 1);
continue;
}
if (arg == '-v' || arg == '--version') {
log("eos-app-store Version: " + Config.PACKAGE_VERSION);
return 0;
}
if (arg == '-h' || arg == '--help') {
log("eos-app-store-launcher Version: " + Config.PACKAGE_VERSION + "\n" +
"\n" +
"Usage:\n" +
" eos-app-store [OPTION...]\n" +
"\n" +
"Help options:\n" +
" -h, --help Show help\n" +
"\n" +
"Application options:\n" +
" -w, --web-links Show the 'Web Links' page\n" +
" -v, --version Print version and exit");
return 0;
}
log("Unknown argument: '" + arg + "'\n" +
"Usage: eos-app-store-launcher [OPTION...]");
return -1;
}
let storeLauncher = new AppStoreLauncher();
storeLauncher.proxy.showPageRemote(Gdk.CURRENT_TIME, initialPage);
return 0;
}