forked from TBSniller/piccap
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
26 changed files
with
1,951 additions
and
351 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
|
||
<head> | ||
<meta charset="UTF-8"> | ||
<title>PicCap - Hyperion Sender App</title> | ||
<script src="./webOSTVjs-1.2.4/webOSTV.js" charset="utf-8"></script> | ||
<script src="./webOSTVjs-1.2.4/webOSTV-dev.js" charset="utf-8"></script> | ||
<meta name="viewport" content="width=device-width, initial-scale=1" /> | ||
<link rel="stylesheet" href="./css/basicui.css" media="screen"> | ||
<link rel="stylesheet" href="./css/blueui.css" media="screen"> | ||
<link rel="stylesheet" href="./css/darkui.css" media="screen"> | ||
<link rel="stylesheet" href="./css/blackui.css" media="screen"> | ||
</head> | ||
|
||
<body> | ||
<noscript>You need to enable JavaScript to run this app.</noscript> | ||
<div id="root"></div> | ||
|
||
<script type="module" src="./src/index.jsx"></script> | ||
</body> | ||
|
||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
let checkRootStatusIntervalID = null; | ||
const onHBExec = (result, logStore) => { | ||
if (result.returnValue) { | ||
logStore.setPiccapLog(`HBChannel exec returned. stdout: ${result.stdoutString} stderr: ${result.stderrString}`); | ||
} else { | ||
logStore.setPiccapLog(`HBChannel exec failed! Code: ${result.errorCode}`); | ||
} | ||
}; | ||
|
||
const makeServiceRoot = (logStore) => { | ||
logStore.setPiccapLog('Rooting..'); | ||
logStore.setInfoState('Rooting app and service..'); | ||
logStore.setPiccapLog('Calling HBChannel exec to elevate app and service'); | ||
/* eslint-disable no-undef */ | ||
webOS.service.request( | ||
'luna://org.webosbrew.hbchannel.service', | ||
{ | ||
method: 'exec', | ||
parameters: { | ||
command: '/media/developer/apps/usr/palm/services/org.webosbrew.hbchannel.service/elevate-service org.webosbrew.piccap; /media/developer/apps/usr/palm/services/org.webosbrew.hbchannel.service/elevate-service org.webosbrew.piccap.service', | ||
}, | ||
onSuccess: (result) => { | ||
onHBExec(result, logStore); | ||
|
||
logStore.setPiccapLog('Elevation completed - killing service process..'); | ||
logStore.setInfoState('Killing service..'); | ||
killHyperion(); | ||
}, | ||
onFailure: (result) => onHBExec(result, logStore), | ||
}, | ||
); | ||
/* eslint-enable no-undef */ | ||
|
||
logStore.setInfoState('Finished making root processing'); | ||
}; | ||
|
||
const onCheckRootStatus = (result, logStore, rootStore) => { | ||
if (result.returnValue === true) { | ||
if (result.elevated) { | ||
logStore.setPiccapLog('PicCap-Service returned rooted!'); | ||
document.getElementById('txtInfoState').innerHTML = 'Running as root'; | ||
rootStore.setRoot(true); | ||
clearInterval(checkRootStatusIntervalID); | ||
rootStore.setRootingInProgress(false); | ||
} else { | ||
if (!rootStore.rootingInProgress) { | ||
logStore.setPiccapLog('Rooting not in progress yet.'); | ||
makeServiceRoot(); | ||
rootStore.setRootingInProgress(true); | ||
} | ||
logStore.setPiccapLog('PicCap-Service returned not rooted yet! Will check again soon.'); | ||
document.getElementById('txtInfoState').innerHTML = 'Not running as root. Service elevation in progress..'; | ||
} | ||
} else { | ||
logStore.setPiccapLog(`Getting root-status from PicCap-Service failed! Will try again. Code: ${result.errorCode}`); | ||
document.getElementById('txtInfoState').innerHTML = 'PicCap-Service status failed!'; | ||
} | ||
}; | ||
|
||
const checkRoot = (logStore, rootStore) => { | ||
logStore.setStatus('Processing root check'); | ||
logStore.setPiccapLog('Starting loop for PicCap-Service to get root-status'); | ||
|
||
let firstInterval = true; | ||
checkRootStatusIntervalID = window.setInterval(() => { | ||
logStore.setPiccapLog('Calling PicCap-Service to get root-status'); | ||
document.getElementById('txtInfoState').innerHTML = 'Checking root status'; | ||
/* eslint-disable no-undef */ | ||
webOS.service.request( | ||
'luna://org.webosbrew.piccap.service', | ||
{ | ||
method: 'status', | ||
parameters: {}, | ||
onSuccess: (result) => onCheckRootStatus(result, logStore, rootStore), | ||
onFailure: (result) => onCheckRootStatus(result, logStore, rootStore), | ||
}, | ||
); | ||
/* eslint-enable no-undef */ | ||
|
||
if (!rootStore.rootingInProgress && !rootStore.root && !firstInterval) { | ||
logStore.setPiccapLog('Not rooted and rooting not in progress yet.'); | ||
makeServiceRoot(logStore); | ||
rootStore.setRootingInProgress(true); | ||
} | ||
firstInterval = false; | ||
}, 3000); | ||
}; | ||
|
||
export { | ||
checkRoot, | ||
onHBExec, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
import { getSettings } from './settings'; | ||
|
||
const onServiceCallback = (result, logStore) => { | ||
if (result.returnValue) { | ||
logStore.setPiccapLog('Servicecall returned successfully.'); | ||
logStore.setInfoState('Servicecall success!'); | ||
} else { | ||
logStore.setPiccapLog(`Servicecall failed! Code: ${result.errorCode}`); | ||
logStore.setInfoState('Servicecall failed!'); | ||
} | ||
}; | ||
|
||
const serviceStart = (logStore) => { | ||
logStore.setPiccapLog('Start clicked'); | ||
try { | ||
logStore.setStatus('Starting service...'); | ||
logStore.setInfoState('Sending start command'); | ||
/* eslint-disable no-undef */ | ||
webOS.service.request( | ||
'luna://org.webosbrew.piccap.service', | ||
{ | ||
method: 'start', | ||
parameters: {}, | ||
onSuccess: (result) => onServiceCallback(result, logStore), | ||
onFailure: (result) => onServiceCallback(result, logStore), | ||
}, | ||
); | ||
/* eslint-enable no-undef */ | ||
} catch (err) { | ||
logStore.setStatus(`Failed: ${JSON.stringify(err)}`); | ||
} | ||
|
||
logStore.setInfoState('Start command send'); | ||
}; | ||
|
||
const serviceStop = (logStore) => { | ||
logStore.setPiccapLog('Stop clicked'); | ||
try { | ||
logStore.setStatus('Stopping service...'); | ||
logStore.setInfoState('Sending stop command'); | ||
/* eslint-disable no-undef */ | ||
webOS.service.request( | ||
'luna://org.webosbrew.piccap.service', | ||
{ | ||
method: 'stop', | ||
parameters: {}, | ||
onSuccess: (result) => onServiceCallback(result, logStore), | ||
onFailure: (result) => onServiceCallback(result, logStore), | ||
}, | ||
); | ||
/* eslint-enable no-undef */ | ||
} catch (err) { | ||
logStore.setStatus(`Failed: ${JSON.stringify(err)}`); | ||
} | ||
logStore.setInfoState('Stop command send'); | ||
}; | ||
|
||
const serviceReload = (logStore) => { | ||
logStore.setPiccapLog('Reload clicked'); | ||
getSettings(logStore); | ||
}; | ||
|
||
export { | ||
serviceStart, | ||
serviceStop, | ||
serviceReload, | ||
}; |
Oops, something went wrong.