initial service integration
This commit is contained in:
parent
06c6d4540d
commit
63249de99c
11
.enyoconfig
11
.enyoconfig
@ -8,7 +8,8 @@
|
||||
"spotlight",
|
||||
"layout",
|
||||
"svg",
|
||||
"enyo-ilib"
|
||||
"enyo-ilib",
|
||||
"enyo-webos"
|
||||
],
|
||||
"sources": {
|
||||
"enyo": "https://github.com/enyojs/enyo.git",
|
||||
@ -16,7 +17,8 @@
|
||||
"spotlight": "https://github.com/enyojs/spotlight.git",
|
||||
"layout": "https://github.com/enyojs/layout.git",
|
||||
"svg": "https://github.com/enyojs/svg.git",
|
||||
"enyo-ilib": "https://github.com/enyojs/enyo-ilib.git"
|
||||
"enyo-ilib": "https://github.com/enyojs/enyo-ilib.git",
|
||||
"enyo-webos": "https://github.com/enyojs/enyo-webos.git"
|
||||
},
|
||||
"targets": {
|
||||
"enyo": "2.7.0",
|
||||
@ -24,7 +26,8 @@
|
||||
"spotlight": "2.7.0",
|
||||
"layout": "2.7.0",
|
||||
"svg": "2.7.0",
|
||||
"enyo-ilib": "2.7.0"
|
||||
"enyo-ilib": "2.7.0",
|
||||
"enyo-webos": "2.7.0"
|
||||
},
|
||||
"production": false,
|
||||
"devMode": true,
|
||||
@ -66,4 +69,4 @@
|
||||
"promisePolyfill": false,
|
||||
"styleOnly": false,
|
||||
"lessVars": []
|
||||
}
|
||||
}
|
||||
|
3
.gitmodules
vendored
3
.gitmodules
vendored
@ -16,3 +16,6 @@
|
||||
[submodule "lib/enyo-ilib"]
|
||||
path = lib/enyo-ilib
|
||||
url = https://github.com/enyojs/enyo-ilib.git
|
||||
[submodule "lib/enyo-webos"]
|
||||
path = lib/enyo-webos
|
||||
url = https://github.com/enyojs/enyo-webos
|
||||
|
12
appinfo.json
Normal file
12
appinfo.json
Normal file
@ -0,0 +1,12 @@
|
||||
{
|
||||
"id": "org.webosbrew.hbchannel",
|
||||
"version": "0.0.1",
|
||||
"vendor": "webosbrew.org",
|
||||
"title": "Homebrew Channel",
|
||||
"icon": "assets/icon160.png",
|
||||
"main": "index.html",
|
||||
"iconColor": "white",
|
||||
"type": "web",
|
||||
"trustLevel": "trusted",
|
||||
"uiRevision": 2
|
||||
}
|
BIN
assets/icon160.png
Normal file
BIN
assets/icon160.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 12 KiB |
1
lib/enyo-webos
Submodule
1
lib/enyo-webos
Submodule
@ -0,0 +1 @@
|
||||
Subproject commit eff99a6f78eed8a0828988eb1bea59ea7efba9cc
|
3978
package-lock.json
generated
3978
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@ -5,18 +5,23 @@
|
||||
"main": "index.js",
|
||||
"moduleDir": "src",
|
||||
"scripts": {
|
||||
"pack": "enyo pack"
|
||||
"build": "enyo pack",
|
||||
"package": "ares-package dist/",
|
||||
"deploy": "ares-install org.webosbrew.hbchannel_0.0.1_all.ipk",
|
||||
"launch": "ares-launch org.webosbrew.hbchannel"
|
||||
},
|
||||
"assets": [
|
||||
"appinfo.json",
|
||||
"favicon.ico",
|
||||
"assets/**/*.*",
|
||||
"webosbrew-repository/**"
|
||||
"services/**"
|
||||
],
|
||||
"styles": [
|
||||
"css/*.less",
|
||||
"css/*.css"
|
||||
],
|
||||
"devDependencies": {
|
||||
"@webosose/ares-cli": "^2.1.0",
|
||||
"enyo-dev": "^1.0.0"
|
||||
}
|
||||
}
|
||||
|
11
services/package.json
Normal file
11
services/package.json
Normal file
@ -0,0 +1,11 @@
|
||||
{
|
||||
"name": "org.webosbrew.hbchannel.service",
|
||||
"version": "1.0.0",
|
||||
"description": "Homebrew Channel Service",
|
||||
"main": "service.js",
|
||||
"scripts": {
|
||||
"test": "echo \"Error: no test specified\" && exit 1"
|
||||
},
|
||||
"author": "David Buchanan",
|
||||
"license": "MIT"
|
||||
}
|
4
services/run-js-service
Executable file
4
services/run-js-service
Executable file
@ -0,0 +1,4 @@
|
||||
#! /bin/sh
|
||||
|
||||
# :^)
|
||||
eval "$(cat /usr/bin/run-js-service | sed 's/^thirdparty_jail=.*/thirdparty_jail=off/')"
|
67
services/service.js
Executable file
67
services/service.js
Executable file
@ -0,0 +1,67 @@
|
||||
var pkgInfo = require('./package.json');
|
||||
var Service = require('webos-service');
|
||||
var child_process = require('child_process')
|
||||
|
||||
// Register com.yourdomain.@DIR@.service, on both buses
|
||||
var service = new Service(pkgInfo.name);
|
||||
|
||||
service.register("checkRoot", function (message) {
|
||||
message.respond({
|
||||
returnValue: process.getuid() === 0,
|
||||
});
|
||||
});
|
||||
|
||||
service.register("exec", function (message) {
|
||||
child_process.exec(message.payload.command, {encoding: "buffer"}, function (error, stdout, stderr) {
|
||||
message.respond({
|
||||
returnValue: !error,
|
||||
error: error,
|
||||
stdoutString: stdout.toString(),
|
||||
stdoutBytes: stdout.toString("base64"),
|
||||
stderrString: stderr.toString(),
|
||||
stderrBytes: stderr.toString("base64")
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
service.register("spawn", function (message) {
|
||||
var proc = child_process.spawn("/bin/sh", ["-c", message.payload.command]);
|
||||
|
||||
proc.stdout.on('data', function (data) {
|
||||
message.respond({
|
||||
event: "stdoutData",
|
||||
stdoutString: data.toString(),
|
||||
stdoutBytes: data.toString("base64")
|
||||
});
|
||||
});
|
||||
proc.stderr.on('data', function (data) {
|
||||
message.respond({
|
||||
event: "stderrData",
|
||||
stderrString: data.toString(),
|
||||
stderrBytes: data.toString("base64")
|
||||
});
|
||||
});
|
||||
proc.on('close', function (code) {
|
||||
message.respond({
|
||||
event: "close",
|
||||
closeCode: code
|
||||
});
|
||||
});
|
||||
proc.on('exit', function (code) {
|
||||
message.respond({
|
||||
event: "exit",
|
||||
exitCode: code
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
// stub service that emulates luna://com.webos.service.sm/license/apps/getDrmStatus
|
||||
service.register("getDrmStatus", function (message) {
|
||||
message.respond({
|
||||
"appId": message.payload.appId,
|
||||
"drmType": "NCG DRM",
|
||||
"installBasePath": "/media/cryptofs",
|
||||
"returnValue": true,
|
||||
"isTimeLimited": false
|
||||
});
|
||||
});
|
9
services/services.json
Normal file
9
services/services.json
Normal file
@ -0,0 +1,9 @@
|
||||
{
|
||||
"id": "org.webosbrew.hbchannel.service",
|
||||
"description": "Homebrew Channel Service",
|
||||
"services": [
|
||||
{
|
||||
"name": "org.webosbrew.hbchannel.service"
|
||||
}
|
||||
]
|
||||
}
|
@ -15,7 +15,8 @@ var
|
||||
Item = require('moonstone/Item'),
|
||||
Popup = require('moonstone/Popup'),
|
||||
TooltipDecorator = require('moonstone/TooltipDecorator'),
|
||||
LabeledTextItem = require('moonstone/LabeledTextItem');
|
||||
LabeledTextItem = require('moonstone/LabeledTextItem'),
|
||||
LunaService = require('enyo-webos/LunaService');
|
||||
|
||||
var magic = {t: 0, n: 0};
|
||||
|
||||
@ -50,7 +51,8 @@ module.exports = kind({
|
||||
{
|
||||
kind: LabeledTextItem,
|
||||
label: 'Root status',
|
||||
text: 'working',
|
||||
text: 'unknown',
|
||||
name: 'rootStatus',
|
||||
disabled: true,
|
||||
},
|
||||
],
|
||||
@ -76,7 +78,25 @@ module.exports = kind({
|
||||
]
|
||||
},
|
||||
{kind: Popup, name: 'errorPopup', content: 'An error occured while downloading repository.', allowHtml: true, modal: true, allowBackKey: true},
|
||||
{kind: LunaService, name: 'checkroot', service: 'luna://org.webosbrew.hbchannel.service', method: 'checkRoot', onResponse: 'onCheckRoot', onError: 'onCheckRoot'},
|
||||
],
|
||||
|
||||
rootStatus: 'pending...',
|
||||
bindings: [
|
||||
{from: "rootStatus", to: '$.rootStatus.text'},
|
||||
],
|
||||
create: function () {
|
||||
this.inherited(arguments);
|
||||
this.$.checkroot.send({});
|
||||
},
|
||||
onCheckRoot: function (sender, response) {
|
||||
console.info(sender, response);
|
||||
if (response.errorText) {
|
||||
this.set('rootStatus', response.errorText);
|
||||
} else {
|
||||
this.set('rootStatus', response.returnValue ? 'ok' : 'unelevated');
|
||||
}
|
||||
},
|
||||
versionTap: function (sender, evt) {
|
||||
var t = new Date().getTime();
|
||||
if (t - magic.t > 5000) magic.n = 0;
|
||||
|
Loading…
x
Reference in New Issue
Block a user