Skip to content

Commit

Permalink
feat: WIP add websocket for remote connections
Browse files Browse the repository at this point in the history
this currently uses the websocket for all connections.
  • Loading branch information
lart2150 committed Dec 31, 2023
1 parent 06613aa commit d745d69
Show file tree
Hide file tree
Showing 7 changed files with 447 additions and 190 deletions.
10 changes: 10 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
/rc_images
/dist
/release
/bin
/.gradle
/.settings
/config.ini
/css
/cdata.*
/*.jar
Binary file added lib/Java-WebSocket-1.5.5.jar
Binary file not shown.
100 changes: 50 additions & 50 deletions src/com/tivo/kmttg/gui/remote/info.java
Original file line number Diff line number Diff line change
Expand Up @@ -240,61 +240,61 @@ private void RC_infoCB(final String tivoName) {
info += String.format("%-30s %s\n", fields[i], json.get(fields[i]));
}

if (! r.awayMode() ) {
// More detailed info
JSONObject j = new JSONObject();
j.put("bodyId", r.bodyId_get());
JSONObject response = r.Command("systemInformationGet", j);
if (response != null) {
String integers[] = {
"remoteAddress", "recordingCapacityHdHours",
"recordingCapacitySdHours", "freeDiskSpaceSdHours",
"freeDiskSpaceHdHours"
};
String strings[] = {
"internalTemperature",
"zipCode", "remoteBatteryLevel", "activeVideoOutputFormat",
"platform", "netflixEsn",
"hdcpVersionInfo", "collabSliceVersion",
"programInfoTo", "gcCompletionTime", "indexCompletionTime",
"dialInCode", "serviceState", "serviceLevel", "serviceMapInfo",
};
String jsons[] = { "serviceConnectionInfo", "vcmConnectionInfo" };
for (int i=0; i<strings.length; ++i) {
if (response.has(strings[i]))
info += String.format(
"%-30s %s\n", strings[i], response.getString(strings[i])
);
}
for (int i=0; i<jsons.length; ++i) {
if (response.has(jsons[i])) {
response.getJSONObject(jsons[i]).remove("type");
info += String.format(
"%s:\n%s\n", jsons[i], response.getJSONObject(jsons[i]).toString(3)
);
}
}
for (int i=0; i<integers.length; ++i) {
if (response.has(integers[i]))
info += String.format(
"%-30s %d\n", integers[i], response.getInt(integers[i])
);
// More detailed info
JSONObject j = new JSONObject();
j.put("bodyId", r.bodyId_get());
JSONObject response = r.Command("systemInformationGet", j);
if (response != null) {
String integers[] = {
"remoteAddress", "recordingCapacityHdHours",
"recordingCapacitySdHours", "freeDiskSpaceSdHours",
"freeDiskSpaceHdHours"
};
String strings[] = {
"internalTemperature",
"zipCode", "remoteBatteryLevel", "activeVideoOutputFormat",
"platform", "netflixEsn",
"hdcpVersionInfo", "collabSliceVersion",
"programInfoTo", "gcCompletionTime", "indexCompletionTime",
"dialInCode", "serviceState", "serviceLevel", "serviceMapInfo",
};
String jsons[] = { "serviceConnectionInfo", "vcmConnectionInfo" };
for (int i=0; i<strings.length; ++i) {
if (response.has(strings[i]))
info += String.format(
"%-30s %s\n", strings[i], response.getString(strings[i])
);
}
for (int i=0; i<jsons.length; ++i) {
if (response.has(jsons[i])) {
response.getJSONObject(jsons[i]).remove("type");
info += String.format(
"%s:\n%s\n", jsons[i], response.getJSONObject(jsons[i]).toString(3)
);
}
}
for (int i=0; i<integers.length; ++i) {
if (response.has(integers[i]))
info += String.format(
"%-30s %d\n", integers[i], response.getInt(integers[i])
);
}

// What's On info
String [] whatson = getWhatsOn(tivoName);
if (whatson != null) {
info += String.format("%-30s ", "What's On");
for (int i=0; i<whatson.length; ++i) {
if (i>0)
info += "; ";
info += whatson[i];
}
info += "\n";
}

// What's On info
String [] whatson = getWhatsOn(tivoName);
if (whatson != null) {
info += String.format("%-30s ", "What's On");
for (int i=0; i<whatson.length; ++i) {
if (i>0)
info += "; ";
info += whatson[i];
}
info += "\n";
}
info += "\n";

if (! r.awayMode() ) {
// Tuner info
reply = r.Command("TunerInfo", new JSONObject());
if (reply != null && reply.has("state")) {
Expand Down
7 changes: 3 additions & 4 deletions src/com/tivo/kmttg/main/config.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
import java.util.Stack;

import com.tivo.kmttg.rpc.Remote;
import com.tivo.kmttg.rpc.TiVoRPCWS;
import com.tivo.kmttg.util.*;
import com.tivo.kmttg.gui.gui;
import com.tivo.kmttg.httpserver.kmttgServer;
Expand Down Expand Up @@ -631,11 +632,9 @@ public static void twpDeleteEnabledSet(Boolean state) {

public static Remote initRemote(String tivoName) {
if (rpcEnabled(tivoName)) {
Remote r = new Remote(tivoName);
return(r);
return new Remote(tivoName);
} else {
Remote r = new Remote(tivoName, true);
return(r);
return new Remote(tivoName, true);
}
}

Expand Down
Loading

0 comments on commit d745d69

Please sign in to comment.