Skip to content

Commit

Permalink
Fixed somes others service bugs in earlier webOS version.
Browse files Browse the repository at this point in the history
Fixed voice text input bug.
  • Loading branch information
Cathwyler committed Mar 29, 2024
1 parent 0e593ae commit 3268218
Show file tree
Hide file tree
Showing 3 changed files with 75 additions and 49 deletions.
4 changes: 2 additions & 2 deletions MagicRemoteService/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,5 @@
// Vous pouvez spécifier toutes les valeurs ou indiquer les numéros de build et de révision par défaut
// en utilisant '*', comme indiqué ci-dessous :
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.2.4.6")]
[assembly: AssemblyFileVersion("1.2.4.6")]
[assembly: AssemblyVersion("1.2.4.7")]
[assembly: AssemblyFileVersion("1.2.4.7")]
8 changes: 5 additions & 3 deletions MagicRemoteService/Resources/TV/MagicRemoteService/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -611,9 +611,11 @@ function SubscriptionDomEvent() {
});

deKeyboard.addEventListener("input", function(inEvent) {
SendUnicode({
usC: deKeyboard.value.charCodeAt()
});
for(var i = 0; i < deKeyboard.value.length; i++){
SendUnicode({
usC: deKeyboard.value.charCodeAt(i)
});
}
deKeyboard.value = "";
});

Expand Down
112 changes: 68 additions & 44 deletions MagicRemoteService/Resources/TV/Service/service.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ var strAppId = "com.cathwyler.magicremoteservice";

var serService = new Service(strAppId + ".service");

/*function SendLogIfDebug() {};
function LogIfDebug() {};
if(bDebug){
var arrLog = [];
var dLog = {};
Expand All @@ -17,14 +17,25 @@ if(bDebug){
try {
if (mMessage.isSubscription) {
dLog[mMessage.uniqueToken] = mMessage;
mMessage.respond({
subscribed: true,
returnValue: true
});
} else if (!(arrLog.length > 0)) {
mMessage.respond({
returnValue: true
});
}
while (arrLog.length > 0) {
mMessage.respond({
log: arrLog.shift(),
returnValue: true
});
}
mMessage.respond({
subscribed: true,
returnValue: true
});
} catch(eError) {
mMessage.respond({
eError: eError.message,
errorCode: "1",
errorText: eError.message,
returnValue: false
});
}
Expand All @@ -50,15 +61,15 @@ if(bDebug){
}
});
};
SendLogIfDebug = function() {
LogIfDebug = function() {
try {
arrLog.push(Array.prototype.slice.call(arguments).map(function(x) {
return x.toString();
}).join(""));
if(Object.keys(dLog).length > 0){
while (arrLog.length > 0) {
var strLog = arrLog.shift();
for(var uniqueToken in dLog) {
for(var uniqueToken in dLog) {
dLog[uniqueToken].respond({
log: strLog,
returnValue: true
Expand All @@ -69,13 +80,14 @@ if(bDebug){
} catch(eError) {
for(var uniqueToken in dLog) {
dLog[uniqueToken].respond({
eError: eError.message,
errorCode: "1",
errorText: eError.message,
returnValue: false
});
}
}
}
}*/
}

var socClient = Dgram.createSocket("udp4");
socClient.on("listening", function () {
Expand All @@ -87,7 +99,9 @@ bufWol.fill(0xFF, 0, 6);
var metWol = serService.register("wol");
metWol.on("request", function(mMessage) {
try {
bufWol.fill(new Buffer(mMessage.payload.mMac.arrMac), 6);
for (var iWol = 6, iMac = 0; iWol < bufWol.length; iWol++, iMac++) {
bufWol[iWol] = mMessage.payload.mMac.arrMac[iMac % mMessage.payload.mMac.arrMac.length];
}
socClient.send(bufWol, 0, bufWol.length, 9, mMessage.payload.strBroadcast);

mMessage.respond({
Expand All @@ -106,10 +120,7 @@ metWol.on("request", function(mMessage) {
if(bOverlay){
var strInputAppId = "com.webos.app.hdmi";

var aKeepAlive;
serService.activityManager.create("aKeepAlive", function(a) {
aKeepAlive = a;
});
serService.activityManager.create("MagicRemoteServiceKeepAlive");

var dClose = {};
var metClose = serService.register("close");
Expand All @@ -122,6 +133,7 @@ if(bOverlay){
returnValue: true
});
} else {
LogIfDebug("Subscribe auto launch callback");
mMessage.respond({
returnValue: true
});
Expand All @@ -140,11 +152,12 @@ if(bOverlay){

var subAutoLaunch = serService.subscribe("luna://com.palm.activitymanager/create", {
activity: {
name: "MagicRemoteService auto launch",
name: "MagicRemoteServiceAutoLaunch",
description: "MagicRemoteService auto launch",
type: {
foreground: true,
persist: true
persist: true,
explicit: true
}, schedule: {
precise: true,
interval: "00d00h00m05s"
Expand All @@ -159,21 +172,27 @@ if(bOverlay){
});
subAutoLaunch.on("response", function(mMessage) {
try {
switch(mMessage.payload.event) {
case undefined:
break;
case "update":
break;
case "start":
serService.call("luna://com.palm.activitymanager/complete", {
activityId: mMessage.payload.activityId,
restart: true
});
break;
default:
break;
if(mMessage.payload.returnValue) {
switch(mMessage.payload.event) {
case undefined:
LogIfDebug("Subscribe auto launch");
break;
case "start":
LogIfDebug("Subscribe auto launch start");
serService.call("luna://com.palm.activitymanager/complete", {
activityId: mMessage.payload.activityId,
restart: true
});
break;
default:
LogIfDebug("Subscribe auto launch ", mMessage.payload.event);
break;
}
} else {
LogIfDebug("Subscribe auto launch response error [", mMessage.payload.errorText, "]");
}
} catch(eError) {
LogIfDebug("Subscribe auto launch response error [", eError, "]");
}
});
subAutoLaunch.on("cancel", function(mMessage) {
Expand All @@ -185,24 +204,29 @@ if(bOverlay){
});
subInputStatus.on("response", function(mMessage) {
try {
if(mMessage.payload.video[0].connected === true && mMessage.payload.video[0].appId === strInputAppId) {
if(!bApp){
bApp = true;
serService.call("luna://com.webos.applicationManager/launch", {
id: strAppId
});
}
} else {
if(bApp){
bApp = false;
for(var uniqueToken in dClose) {
dClose[uniqueToken].respond({
returnValue: true
if(mMessage.payload.returnValue){
if(mMessage.payload.video[0].connected === true && mMessage.payload.video[0].appId === strInputAppId) {
if(!bApp){
bApp = true;
serService.call("luna://com.webos.applicationManager/launch", {
id: strAppId
});
}
}
} else {
if(bApp){
bApp = false;
for(var uniqueToken in dClose) {
dClose[uniqueToken].respond({
returnValue: true
});
}
}
}
} else {
LogIfDebug("Subscribe input status response error [", mMessage.payload.errorText, "]");
}
} catch(eError) {
LogIfDebug("Subscribe input status response error [", eError, "]");
}
});
subInputStatus.on("cancel", function(mMessage) {
Expand Down

0 comments on commit 3268218

Please sign in to comment.