summaryrefslogtreecommitdiff
path: root/NET/worlds/network/IPhone.java
diff options
context:
space:
mode:
authorFuwn <[email protected]>2026-02-12 22:33:32 -0800
committerFuwn <[email protected]>2026-02-12 22:33:32 -0800
commitc7a9d4a6bd53ed7d61731770f2f10e8b9fd435f9 (patch)
treedf9f48bf128a6c0186a8e91857d6ff30fe0e9f18 /NET/worlds/network/IPhone.java
downloadworldsplayer-c7a9d4a6bd53ed7d61731770f2f10e8b9fd435f9.tar.xz
worldsplayer-c7a9d4a6bd53ed7d61731770f2f10e8b9fd435f9.zip
Initial commit
Diffstat (limited to 'NET/worlds/network/IPhone.java')
-rw-r--r--NET/worlds/network/IPhone.java121
1 files changed, 121 insertions, 0 deletions
diff --git a/NET/worlds/network/IPhone.java b/NET/worlds/network/IPhone.java
new file mode 100644
index 0000000..56c12c0
--- /dev/null
+++ b/NET/worlds/network/IPhone.java
@@ -0,0 +1,121 @@
+package NET.worlds.network;
+
+import NET.worlds.console.ConfirmDialog;
+import NET.worlds.console.Console;
+import NET.worlds.console.DialogReceiver;
+import NET.worlds.core.RegKey;
+import NET.worlds.core.RegKeyNotFoundException;
+import java.io.IOException;
+import java.net.InetAddress;
+import java.net.UnknownHostException;
+import java.text.MessageFormat;
+
+public class IPhone implements DialogReceiver {
+ private static String _IPhoneProgPath = null;
+ private static ConfirmDialog _dlg = null;
+ private String _name;
+ private String _ip;
+
+ private IPhone(String name, String ip) {
+ this._name = name;
+ this._ip = ip;
+ }
+
+ public static synchronized boolean placeCall(String name, String text) {
+ if (_dlg != null) {
+ return false;
+ } else {
+ String s = text.trim();
+ if (s.startsWith("[TALK:") && s.endsWith("]")) {
+ s = s.substring(6, s.length() - 1);
+ IPhone fone = new IPhone(name, s);
+ _dlg = new ConfirmDialog(
+ Console.getFrame(), fone, "Internet Phone Request", name + " has requested an Internet Phone call. " + "Do you want to call them?"
+ );
+ return true;
+ } else {
+ return false;
+ }
+ }
+ }
+
+ public static boolean isCall(String text) {
+ String s = text.trim().toUpperCase();
+ return s.startsWith("[TALK") && s.endsWith("]");
+ }
+
+ public static String initiateCall(String text) {
+ if (_IPhoneProgPath == null) {
+ getRegEntry();
+ }
+
+ if (_IPhoneProgPath.equals("")) {
+ return "Can't initiate call -- no Internet Telephone Application found.";
+ } else {
+ String ret = "[BAD REMOTE HOST ADDRESS]";
+
+ try {
+ String s = InetAddress.getLocalHost().toString();
+ s = s.substring(s.indexOf(47) + 1);
+ ret = "[TALK:" + s + "]";
+ Runtime.getRuntime().exec(_IPhoneProgPath);
+ } catch (SecurityException var3) {
+ ret = "Can't initiate call -- couldn't start Internet Telephone Application.";
+ } catch (UnknownHostException var4) {
+ var4.printStackTrace();
+ } catch (IOException var5) {
+ var5.printStackTrace();
+ }
+
+ return ret;
+ }
+ }
+
+ private static void getRegEntry() {
+ try {
+ RegKey root = RegKey.getRootKey(2);
+ RegKey key = new RegKey(root, "SOFTWARE\\Classes\\InternetPhoneUser\\shell\\open\\command", 0);
+ _IPhoneProgPath = key.getStringValue("");
+ key.close();
+ int idx = _IPhoneProgPath.indexOf(34);
+ if (idx == 0) {
+ _IPhoneProgPath = _IPhoneProgPath.substring(1, _IPhoneProgPath.indexOf(34, 1));
+ } else {
+ _IPhoneProgPath = _IPhoneProgPath.substring(0, idx);
+ }
+ } catch (RegKeyNotFoundException var3) {
+ _IPhoneProgPath = "";
+ }
+ }
+
+ private void talkToPhoneService() {
+ DDEMLClass ddeml = new DDEMLClass("InternetPhone", "CallIP");
+ ddeml.Request("," + this._ip);
+ ddeml.destroy();
+ ddeml = new DDEMLClass("InternetPhone", "Show");
+ ddeml.Request("2");
+ ddeml.destroy();
+ }
+
+ @Override
+ public void dialogDone(Object who, boolean confirmed) {
+ if (confirmed) {
+ Object[] arguments = new Object[]{new String(this._name), new String(this._ip)};
+ Console.println(MessageFormat.format(Console.message("Calling-IP"), arguments));
+ if (_IPhoneProgPath == null) {
+ getRegEntry();
+ }
+
+ try {
+ Runtime.getRuntime().exec(_IPhoneProgPath);
+ this.talkToPhoneService();
+ } catch (SecurityException var5) {
+ Console.println(Console.message("Call-failed"));
+ } catch (Exception var6) {
+ var6.printStackTrace();
+ }
+ }
+
+ _dlg = null;
+ }
+}