1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
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;
}
}
|