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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
|
package NET.worlds.scape;
import NET.worlds.console.Console;
import NET.worlds.console.InternetExplorer;
import NET.worlds.console.Main;
import NET.worlds.console.MainCallback;
import NET.worlds.console.OkCancelDialog;
import NET.worlds.console.PolledDialog;
import NET.worlds.console.WebBrowser;
import NET.worlds.console.WebControlImp;
import NET.worlds.core.IniFile;
import NET.worlds.network.RemoteFileConst;
import NET.worlds.network.URL;
import java.io.IOException;
import java.text.MessageFormat;
import java.util.Hashtable;
public class SendURLAction extends DialogAction implements MainCallback, RemoteFileConst {
URL destination;
URL destinationOverride;
String worldOverride;
String description;
String postData = null;
protected boolean getUser;
InternetExplorer bogusBrowser;
private static String notAvailablePrefix = "http://www.worldsstore.com/superstore/en/product/";
private static Hashtable notAvailable = new Hashtable();
private String trigger;
private int tries = 0;
private Persister curSeq = null;
private static Object classCookie = new Object();
static {
Object o = new Object();
notAvailable.put("pa101", o);
notAvailable.put("pa102", o);
notAvailable.put("pg102", o);
notAvailable.put("pg105", o);
notAvailable.put("ph108", o);
notAvailable.put("ph502", o);
}
public SendURLAction() {
this("http://www.worlds.net");
}
public SendURLAction(URL dest) {
this.destination = dest;
this.getUser = false;
}
public SendURLAction(String dest) {
this(dest == null ? null : URL.make(dest));
}
public SendURLAction(String dest, boolean get) {
this(dest == null ? null : URL.make(dest), get);
}
public SendURLAction(URL dest, boolean get) {
this.destination = dest;
this.getUser = get;
}
public void setDestination(URL d) {
this.destination = d;
}
public void setTrigger(String t) {
this.trigger = t;
}
public void startBrowser() {
if (Main.isMainThread()) {
this.tryLaunch();
} else {
Main.register(this);
}
}
@Override
public void mainCallback() {
Main.unregister(this);
this.tryLaunch();
}
private URL getDestination() {
if (this.worldOverride != null) {
IniFile ini = new IniFile("InstalledWorlds");
String first = ini.getIniString("InstalledWorld0", "");
if (this.worldOverride.equalsIgnoreCase(first)) {
return this.destinationOverride;
}
}
return this.destination;
}
private void tryLaunch() {
URL destURL = this.getDestination();
if (destURL != null) {
String dest = destURL.unalias();
String newDest = WebControlImp.processURL(dest);
if (newDest != null) {
dest = newDest;
}
if (this.postData != null) {
this.postData = WebControlImp.processURL(this.postData);
}
String info = null;
Console console = Console.getActive();
if (console != null && console.getGalaxy().getChatname() != null && !console.getGalaxy().getChatname().equals("")) {
info = "Username=" + console.getGalaxy().getUsernameU();
}
if (this.getUser && info != null) {
dest = dest + "?" + info;
}
String midDest = dest.substring(dest.indexOf(":") + 1);
if (dest.startsWith("sound:")) {
dest = URL.make(midDest).unalias();
WavSoundPlayer.pauseSystem();
CDAudio.get().setEnabled(false);
try {
WebBrowser.forceMinimized(true);
WebBrowser.reuseOrMake(dest, this.postData, WebBrowser.getAdPartPlacement(), "sound:");
WebBrowser.forceMinimized(false);
return;
} catch (IOException var14) {
}
} else if (dest.startsWith("videoMap:") || dest.startsWith("overmap:")) {
dest = URL.make(midDest).unalias();
WavSoundPlayer.pauseSystem();
CDAudio.get().setEnabled(false);
try {
WebBrowser.dontUseToolbar();
WebBrowser.dontUseWindowFrame();
WebBrowser.reuseOrMake(dest, this.postData, WebBrowser.getMapPartPlacement(), "videoMap:");
WebBrowser.useToolbar();
return;
} catch (IOException var15) {
}
} else if (dest.startsWith("videoAd:")) {
dest = URL.make(midDest).unalias();
WavSoundPlayer.pauseSystem();
CDAudio.get().setEnabled(false);
try {
WebBrowser.dontUseToolbar();
WebBrowser.dontUseWindowFrame();
WebBrowser.reuseOrMake(dest, this.postData, WebBrowser.getAdPartPlacement(), "videoAd:");
WebBrowser.useToolbar();
return;
} catch (IOException var13) {
}
} else if (dest.startsWith("zoom:")) {
dest = URL.make(midDest).unalias();
WavSoundPlayer.pauseSystem();
CDAudio.get().setEnabled(false);
try {
WebBrowser.dontUseToolbar();
WebBrowser.dontUseWindowFrame();
WebBrowser.reuseOrMake(dest, this.postData, WebBrowser.getRenderPartPlacement(), "zoom:");
WebBrowser.useToolbar();
return;
} catch (IOException var12) {
}
} else if (dest.startsWith("zoomLeft:")) {
dest = URL.make(midDest).unalias();
WavSoundPlayer.pauseSystem();
CDAudio.get().setEnabled(false);
try {
WebBrowser.dontUseToolbar();
WebBrowser.dontUseWindowFrame();
WebBrowser.reuseOrMake(dest, this.postData, WebBrowser.getLeftRenderPartPlacement(), "zoomLeft:");
WebBrowser.useToolbar();
return;
} catch (IOException var11) {
}
} else if (dest.startsWith("outside:")) {
dest = URL.make(midDest).unalias();
WavSoundPlayer.pauseSystem();
CDAudio.get().setEnabled(false);
try {
WebBrowser.dontUseToolbar();
WebBrowser.reuseOrMake(dest, this.postData, WebBrowser.getOutsidePlacement(), "outside:");
WebBrowser.useToolbar();
return;
} catch (IOException var10) {
}
} else if (dest.startsWith("http:")) {
try {
WebBrowser.reuseOrMake(dest, this.postData);
return;
} catch (IOException var9) {
}
}
if (this.bogusBrowser == null) {
try {
this.bogusBrowser = new InternetExplorer(null);
} catch (IOException var8) {
}
}
if (!launchViaRegistry(dest)) {
Console.println(dest + Console.message("Unable-to-launch"));
}
}
}
@Override
public void doIt() {
this.startBrowser();
}
@Override
public PolledDialog getDialog() {
URL tmpURL = this.getDestination();
if (tmpURL == null) {
return new ItemNotAvailableDialog(Console.getFrame(), this);
} else {
String tmp = tmpURL.unalias().toLowerCase();
if (tmp.startsWith(notAvailablePrefix) && notAvailable.containsKey(tmp.substring(notAvailablePrefix.length()))) {
return new ItemNotAvailableDialog(Console.getFrame(), this);
} else {
return (PolledDialog)(this.description != null && !this.description.equals("Would you like more information?")
? new OkCancelDialog(
Console.getFrame(), this, Console.message("BrowseQ"), Console.message("Cancel"), Console.message("OK"), this.description, false, 1
)
: new MoreInfoDialog(Console.getFrame(), this));
}
}
}
private static native boolean launchViaRegistry(String var0);
@Override
public Object properties(int index, int offset, int mode, Object value) throws NoSuchPropertyException {
Object ret = null;
switch (index - offset) {
case 0:
if (mode == 0) {
ret = URLPropertyEditor.make(new Property(this, index, "Destination").allowSetNull(), null);
} else if (mode == 1) {
ret = this.destination;
} else if (mode == 2) {
this.destination = (URL)value;
}
break;
case 1:
if (mode == 0) {
ret = StringPropertyEditor.make(new Property(this, index, "Description"));
} else if (mode == 1) {
ret = this.description;
} else if (mode == 2) {
this.description = ((String)value).trim();
}
break;
case 2:
if (mode == 0) {
ret = URLPropertyEditor.make(new Property(this, index, "Destination Override").allowSetNull(), null);
} else if (mode == 1) {
ret = this.destinationOverride;
} else if (mode == 2) {
this.destinationOverride = (URL)value;
}
break;
case 3:
if (mode == 0) {
ret = StringPropertyEditor.make(new Property(this, index, "Override World").allowSetNull());
} else if (mode == 1) {
ret = this.worldOverride;
} else if (mode == 2) {
if (value == null) {
this.worldOverride = null;
} else {
this.worldOverride = ((String)value).trim();
if (this.worldOverride.length() == 0) {
this.worldOverride = null;
}
}
}
break;
case 4:
if (mode == 0) {
ret = BooleanPropertyEditor.make(new Property(this, index, "Send User Info (auto-login)"), "No", "Yes");
} else if (mode == 1) {
ret = new Boolean(this.getUser);
} else if (mode == 2) {
if ((Boolean)value) {
this.getUser = true;
} else {
this.getUser = false;
}
}
break;
case 5:
if (mode == 0) {
ret = StringPropertyEditor.make(new Property(this, index, "POST data"));
} else if (mode == 1) {
ret = this.postData;
} else if (mode == 2) {
this.postData = ((String)value).trim();
}
break;
default:
ret = super.properties(index, offset + 6, mode, value);
}
return ret;
}
@Override
public void saveState(Saver s) throws IOException {
s.saveVersion(9, classCookie);
super.saveState(s);
s.saveString(this.description);
URL.save(s, this.destination);
URL.save(s, this.destinationOverride);
s.saveString(this.worldOverride);
s.saveBoolean(this.getUser);
s.saveString(this.postData);
}
@Override
public void restoreState(Restorer r) throws IOException, TooNewException {
String destStr = null;
switch (r.restoreVersion(classCookie)) {
case 1:
r.setOldFlag();
r.restoreBoolean();
destStr = r.restoreString();
r.restoreString();
break;
case 2:
r.setOldFlag();
r.restoreBoolean();
destStr = r.restoreString();
break;
case 3:
this.dialogActionSkipRestore(r);
r.restoreBoolean();
destStr = r.restoreString();
break;
case 4:
this.dialogActionSkipRestore(r);
destStr = r.restoreString();
break;
case 5:
this.dialogActionSkipRestore(r);
destStr = r.restoreString();
this.getUser = r.restoreBoolean();
r.restoreBoolean();
break;
case 6:
super.restoreState(r);
this.description = r.restoreString();
destStr = r.restoreString();
this.getUser = r.restoreBoolean();
r.restoreBoolean();
break;
case 7:
super.restoreState(r);
this.description = r.restoreString();
destStr = r.restoreString();
String destOverrideStr = r.restoreString();
if (destOverrideStr != null) {
this.destinationOverride = URL.make(destOverrideStr);
}
this.worldOverride = r.restoreString();
this.getUser = r.restoreBoolean();
r.restoreBoolean();
break;
case 8:
super.restoreState(r);
this.description = r.restoreString();
this.destination = URL.restore(r, null);
this.destinationOverride = URL.restore(r, null);
this.worldOverride = r.restoreString();
this.getUser = r.restoreBoolean();
r.restoreBoolean();
break;
case 9:
super.restoreState(r);
this.description = r.restoreString();
this.destination = URL.restore(r, null);
this.destinationOverride = URL.restore(r, null);
this.worldOverride = r.restoreString();
this.getUser = r.restoreBoolean();
this.postData = r.restoreString();
break;
default:
throw new TooNewException();
}
if (destStr != null) {
this.destination = URL.make(destStr);
}
}
@Override
public void postRestore(int version) {
super.postRestore(version);
if (this.trigger != null) {
SuperRoot owner = this.getOwner();
while (owner != null && !(owner instanceof WObject)) {
owner = owner.getOwner();
}
if (owner == null) {
Object[] arguments = new Object[]{new String(this.getName())};
Console.println(MessageFormat.format(Console.message("Cannot-sensor"), arguments));
} else if (this.trigger.equals("click")) {
((WObject)owner).addHandler(new ClickSensor(this));
} else if (this.trigger.equals("bump")) {
((WObject)owner).addHandler(new BumpSensor(this));
} else {
Room r = ((WObject)owner).getRoom();
if (r != null) {
Object[] arguments = new Object[]{new String(this.trigger), new String(this.getName()), new String(r.getName())};
Console.println(MessageFormat.format(Console.message("Trigger-value-in"), arguments));
} else {
Object[] arguments = new Object[]{new String(this.trigger), new String(this.getName())};
Console.println(MessageFormat.format(Console.message("Trigger-value"), arguments));
}
}
this.trigger = null;
}
}
}
|