summaryrefslogtreecommitdiff
path: root/NET/worlds/network/IPhone.java
diff options
context:
space:
mode:
Diffstat (limited to 'NET/worlds/network/IPhone.java')
-rw-r--r--NET/worlds/network/IPhone.java190
1 files changed, 190 insertions, 0 deletions
diff --git a/NET/worlds/network/IPhone.java b/NET/worlds/network/IPhone.java
new file mode 100644
index 0000000..d6f91da
--- /dev/null
+++ b/NET/worlds/network/IPhone.java
@@ -0,0 +1,190 @@
+/* */ 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
+/* */ {
+/* 22 */ private static String _IPhoneProgPath = null;
+/* 23 */ private static ConfirmDialog _dlg = null;
+/* */ private String _name;
+/* */ private String _ip;
+/* */
+/* */ private IPhone(String name, String ip)
+/* */ {
+/* 29 */ this._name = name;
+/* 30 */ this._ip = ip;
+/* */ }
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */ public static synchronized boolean placeCall(String name, String text)
+/* */ {
+/* 45 */ if (_dlg != null) {
+/* 46 */ return false;
+/* */ }
+/* 48 */ String s = text.trim();
+/* 49 */ if ((s.startsWith("[TALK:")) && (s.endsWith("]"))) {
+/* 50 */ s = s.substring(6, s.length() - 1);
+/* */
+/* 52 */ IPhone fone = new IPhone(name, s);
+/* */
+/* 54 */ _dlg = new ConfirmDialog(Console.getFrame(), fone,
+/* 55 */ "Internet Phone Request", name +
+/* 56 */ " has requested an Internet Phone call. " +
+/* 57 */ "Do you want to call them?");
+/* */
+/* 59 */ return true;
+/* */ }
+/* 61 */ return false;
+/* */ }
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */ public static boolean isCall(String text)
+/* */ {
+/* 71 */ String s = text.trim().toUpperCase();
+/* 72 */ return (s.startsWith("[TALK")) && (s.endsWith("]"));
+/* */ }
+/* */
+/* */ public static String initiateCall(String text) {
+/* 76 */ if (_IPhoneProgPath == null) {
+/* 77 */ getRegEntry();
+/* */ }
+/* 79 */ if (_IPhoneProgPath.equals("")) {
+/* 80 */ return "Can't initiate call -- no Internet Telephone Application found.";
+/* */ }
+/* 82 */ String ret = "[BAD REMOTE HOST ADDRESS]";
+/* */ try {
+/* 84 */ String s = InetAddress.getLocalHost().toString();
+/* 85 */ s = s.substring(s.indexOf('/') + 1);
+/* 86 */ ret = "[TALK:" + s + "]";
+/* */
+/* */
+/* 89 */ Runtime.getRuntime().exec(_IPhoneProgPath);
+/* */ }
+/* */ catch (SecurityException e) {
+/* 92 */ ret = "Can't initiate call -- couldn't start Internet Telephone Application.";
+/* */ }
+/* */ catch (UnknownHostException e) {
+/* 95 */ e.printStackTrace();
+/* */ } catch (IOException e) {
+/* 97 */ e.printStackTrace();
+/* */ }
+/* */
+/* 100 */ return ret;
+/* */ }
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */ private static void getRegEntry()
+/* */ {
+/* */ try
+/* */ {
+/* 113 */ RegKey root = RegKey.getRootKey(2);
+/* 114 */ RegKey key = new RegKey(
+/* 115 */ root,
+/* 116 */ "SOFTWARE\\Classes\\InternetPhoneUser\\shell\\open\\command",
+/* 117 */ 0);
+/* 118 */ _IPhoneProgPath = key.getStringValue("");
+/* 119 */ key.close();
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* 127 */ int idx = _IPhoneProgPath.indexOf('"');
+/* 128 */ if (idx == 0) {
+/* 129 */ _IPhoneProgPath = _IPhoneProgPath.substring(1,
+/* 130 */ _IPhoneProgPath.indexOf('"', 1));
+/* */ } else {
+/* 132 */ _IPhoneProgPath = _IPhoneProgPath.substring(0, idx);
+/* */ }
+/* */ }
+/* */ catch (RegKeyNotFoundException e) {
+/* 136 */ _IPhoneProgPath = "";
+/* */ }
+/* */ }
+/* */
+/* */ private void talkToPhoneService() {
+/* 141 */ DDEMLClass ddeml = new DDEMLClass("InternetPhone", "CallIP");
+/* 142 */ ddeml.Request("," + this._ip);
+/* 143 */ ddeml.destroy();
+/* */
+/* 145 */ ddeml = new DDEMLClass("InternetPhone", "Show");
+/* 146 */ ddeml.Request("2");
+/* 147 */ ddeml.destroy();
+/* */ }
+/* */
+/* */ public void dialogDone(Object who, boolean confirmed)
+/* */ {
+/* 152 */ if (confirmed) {
+/* 153 */ Object[] arguments = { new String(this._name), new String(this._ip) };
+/* 154 */ Console.println(MessageFormat.format(Console.message("Calling-IP"),
+/* 155 */ arguments));
+/* */
+/* 157 */ if (_IPhoneProgPath == null) {
+/* 158 */ getRegEntry();
+/* */ }
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */ try
+/* */ {
+/* 172 */ Runtime.getRuntime().exec(_IPhoneProgPath);
+/* 173 */ talkToPhoneService();
+/* */ }
+/* */ catch (SecurityException e) {
+/* 176 */ Console.println(Console.message("Call-failed"));
+/* */ } catch (Exception e) {
+/* 178 */ e.printStackTrace();
+/* */ }
+/* */ }
+/* */
+/* 182 */ _dlg = null;
+/* */ }
+/* */ }
+
+
+/* Location: C:\Program Files (x86)\Worlds Inc\WorldsPlayer - Win7\lib\worlds.jar!\NET\worlds\network\IPhone.class
+ * Java compiler version: 6 (50.0)
+ * JD-Core Version: 0.7.1
+ */ \ No newline at end of file