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
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
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
*/
|