Skip to content

Commit

Permalink
Revert "Trying the standalone stuff (oh boy)"
Browse files Browse the repository at this point in the history
This reverts commit 4d3960f.
  • Loading branch information
ThowZzy committed Mar 13, 2024
1 parent 726570a commit 68ec785
Show file tree
Hide file tree
Showing 22 changed files with 94 additions and 9,279 deletions.
8 changes: 0 additions & 8 deletions .github/workflows/build-wgt-apps.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,6 @@ jobs:

- name: Install Needed packages
run: sudo apt install expect

- name: Install modules and build service
working-directory: apps/Launcher/service
run: |
npm i
cd mods
npm i
npm run build

- name: Download Tizen-Studio
run: |
Expand Down
37 changes: 12 additions & 25 deletions apps/Launcher/config.xml
Original file line number Diff line number Diff line change
@@ -1,26 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>
<widget xmlns:tizen="http://tizen.org/ns/widgets" xmlns="http://www.w3.org/ns/widgets" id="https://tizentube.live"
version="1.0.2" viewmodes="maximized">
<access origin="*" subdomains="true" />
<tizen:application id="I80YHgsJe2.Launcher" package="I80YHgsJe2" required_version="2.3" />
<author href="https://tizentube.live">Reis Can</author>
<content src="index.html" />
<feature name="http://tizen.org/feature/screen.size.normal.1080.1920" />
<tizen:privilege name="http://tizen.org/privilege/internet" />
<tizen:privilege name="http://developer.samsung.com/privilege/network.public" />
<tizen:privilege name="http://tizen.org/privilege/tv.inputdevice" />
<feature name="http://tizen.org/feature/web.service" />
<icon src="icon.png" />
<tizen:metadata key="http://samsung.com/tv/metadata/prelaunch.support" value="true" />
<tizen:metadata key="http://tizen.org/metadata/app_ui_type/base_screen_resolution" value="extensive" />
<name>Launcher</name>
<tizen:privilege name="http://tizen.org/privilege/application.launch" />
<tizen:profile name="tv-samsung" />
<tizen:setting screen-orientation="landscape" context-menu="enable" background-support="enable" encryption="disable"
install-location="auto" hwkey-event="enable" />
<tizen:service id="I80YHgsJe2.LauncherService">
<tizen:content src="service/dist/index.js" />
<tizen:name>TizenTubeService</tizen:name>
<tizen:description>TizenTubeService</tizen:description>
</tizen:service>
</widget>
<widget xmlns="http://www.w3.org/ns/widgets" xmlns:tizen="http://tizen.org/ns/widgets" id="http://github.com/reisxd/TizenTube" version="1.0.0" viewmodes="maximized">
<tizen:application id="I80YHgsJe2.Launcher" package="I80YHgsJe2" required_version="2.3"/>
<content src="index.html"/>
<feature name="http://tizen.org/feature/screen.size.normal.1080.1920"/>
<icon src="icon.png"/>
<tizen:metadata key="http://samsung.com/tv/metadata/prelaunch.support" value="true"/>
<name>Launcher</name>
<tizen:privilege name="http://tizen.org/privilege/application.launch"/>
<tizen:privilege name="http://tizen.org/privilege/tv.inputdevice"/>
<tizen:profile name="tv-samsung"/>
<tizen:setting screen-orientation="landscape" context-menu="enable" background-support="disable" encryption="disable" install-location="auto" hwkey-event="enable"/>
</widget>
136 changes: 82 additions & 54 deletions apps/Launcher/script.js
Original file line number Diff line number Diff line change
@@ -1,62 +1,90 @@
function connect_to_server() {
const isTizen3 = navigator.userAgent.includes('Tizen 3.0');
var wsServer;
try {
wsServer = new WebSocket('ws://127.0.0.1:3000');
} catch (e) {
document.getElementById('text').innerText = 'Could not connect to server..';
return;
}
var got_ok = false;
wsServer.onmessage = function (message) {
const msg = JSON.parse(message.data);
if (msg.ok) { //Improve here: SDB connection can still fail here if TV Developer IP isn't right
//-> Catch this and ask user to change it (can also happen if an sdb conn already exists)
//tizen.application.getCurrentApplication().exit();
//return;
got_ok = true;
//Experimental code to address the issue
}
if (msg.exit) {
tizen.application.getCurrentApplication().exit();
}
//Store IP once hitting the key "finish"
document.onkeydown = e => {
if (e.keyCode == 65376) {
var input = document.getElementById("ip");
localStorage.setItem("ip", input.value);
alert("Set IP to " + input.value);
window.location.reload();
}
};

wsServer.onopen = function () {
wsServer.send(JSON.stringify({
e: 'launch',
version: isTizen3
}));
};
function prompt_for_ip(previous_IP = "192.168.1.10") {
document.getElementById("inputbox").innerHTML = `
<h2 class="text2">Set Server IP which is running the node server. (Press OK to open the keyboard)</h2>
<h2 class="text2">You can specify the port of the server but it is optionnal, by default it will use the port 3000. Examples : 192.168.1.10, 192.168.1.10:8080 ...</h2>
<label class="label">Server IP:</label>
<input type="text" class="input" placeholder="IP Address" id="ip">
`;
// Focus on input
const input = document.getElementById("ip");
input.blur();
input.focus();

setTimeout(function () {
if (got_ok) {
document.getElementById('text').innerText = "Connection with the server was successful but the ADB connection failed... You likely did not change the TV's developer IP to your server's. Or you still have an active connection to your TV with tizen device manager. Or you need to enable/disable the Tizen3 Compatibility.";
} else {
document.getElementById('text').innerText = 'Could not connect to server after 10 seconds.. Check if it is running and submit again its IP.';
}
return;
}, 10000);
//Pre-fill with the previous IP or the default one
input.value = previous_IP;

/*input.onblur = () => { //Not sure this is needed
// Set IP
localStorage.setItem("ip", input.value);
alert("Set IP to " + input.value);
// Reload page
window.location.reload();
}*/
}

function start_service(){
var testWS = new WebSocket(`ws://127.0.0.1:3000`);
testWS.onerror = () => {
var pkg_id = tizen.application.getCurrentApplication().appInfo.packageId;
var service_id = pkg_id + ".LauncherService";
tizen.application.launchAppControl(new tizen.ApplicationControl('http://tizen.org/appcontrol/operation/service'), service_id, function () {
document.getElementById('text').innerText = "Service started.";
connect_to_server();
}, function (e) {
alert('Launch Service failed: ' + e.message);
});
};
function connect_to_server() {
// Check if IP was set
if (localStorage.getItem("ip") == null) {
document.getElementById('text').innerText = 'Waiting for the IP of the server..';
// Set IP by prompt
prompt_for_ip();
return;
} else {
var IP = localStorage.getItem('ip');
var IP_split = IP.split(":");
var wsServer;
try {
if (IP_split.length > 1) {
wsServer = new WebSocket('ws://' + IP_split[0] + ":" + IP_split[1]);
} else {
wsServer = new WebSocket('ws://' + IP_split[0] + ':3000');
}
} catch (e) {
document.getElementById('text').innerText = 'Could not connect to server.. Check if it is running and submit again its IP.';
prompt_for_ip(IP);
return;
}
var got_ok = false;
wsServer.onmessage = function (message) {
const msg = JSON.parse(message.data);
if (msg.ok) { //Improve here: SDB connection can still fail here if TV Developer IP isn't right
//-> Catch this and ask user to change it (can also happen if an sdb conn already exists)
//tizen.application.getCurrentApplication().exit();
//return;
got_ok = true;
//Experimental code to address the issue
}
if(msg.exit){
tizen.application.getCurrentApplication().exit();
}
}

wsServer.onopen = function () {
wsServer.send(JSON.stringify({
e: 'launch'
}));
};

testWS.onopen = () => {
document.getElementById('text').innerText = "Service is already running.";
testWS.close();
connect_to_server();
};
setTimeout(function () {
if (got_ok) {
document.getElementById('text').innerText = "Connection with the server was successful but the ADB connection failed... You likely did not change the TV's developer IP to your server's. Or you still have an active connection to your TV with tizen device manager. Or you need to enable/disable the Tizen3 Compatibility.";
} else{
document.getElementById('text').innerText = 'Could not connect to server after 10 seconds.. Check if it is running and submit again its IP.';
}
prompt_for_ip(IP);
return;
}, 10000);
}
}

document.addEventListener("DOMContentLoaded", start_service);
document.addEventListener("DOMContentLoaded", connect_to_server);
6 changes: 0 additions & 6 deletions apps/Launcher/service/config.json

This file was deleted.

60 changes: 0 additions & 60 deletions apps/Launcher/service/debuggerController.js

This file was deleted.

37 changes: 0 additions & 37 deletions apps/Launcher/service/mods/adblock.js

This file was deleted.

41 changes: 0 additions & 41 deletions apps/Launcher/service/mods/config.js

This file was deleted.

Loading

0 comments on commit 68ec785

Please sign in to comment.