diff options
Diffstat (limited to 'NET/worlds/scape/SendURLAction.java')
| -rw-r--r-- | NET/worlds/scape/SendURLAction.java | 637 |
1 files changed, 637 insertions, 0 deletions
diff --git a/NET/worlds/scape/SendURLAction.java b/NET/worlds/scape/SendURLAction.java new file mode 100644 index 0000000..0cd5c26 --- /dev/null +++ b/NET/worlds/scape/SendURLAction.java @@ -0,0 +1,637 @@ +/* */ 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.Galaxy; +/* */ 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; +/* 85 */ String postData = null; +/* */ +/* */ +/* */ +/* */ protected boolean getUser; +/* */ +/* */ +/* */ InternetExplorer bogusBrowser; +/* */ +/* */ +/* 95 */ private static String notAvailablePrefix = "http://www.worldsstore.com/superstore/en/product/"; +/* 96 */ private static Hashtable<String, Object> notAvailable = new Hashtable(); +/* 97 */ static { Object o = new Object(); +/* 98 */ notAvailable.put("pa101", o); +/* 99 */ notAvailable.put("pa102", o); +/* 100 */ notAvailable.put("pg102", o); +/* 101 */ notAvailable.put("pg105", o); +/* 102 */ notAvailable.put("ph108", o); +/* 103 */ notAvailable.put("ph502", o); +/* */ } +/* */ +/* */ +/* */ +/* */ +/* */ public SendURLAction() +/* */ { +/* 111 */ this("http://www.worlds.net"); +/* */ } +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ public SendURLAction(URL dest) +/* */ { +/* 121 */ this.destination = dest; +/* 122 */ this.getUser = false; +/* */ } +/* */ +/* */ public SendURLAction(String dest) { +/* 126 */ this(dest == null ? null : URL.make(dest)); +/* */ } +/* */ +/* */ public SendURLAction(String dest, boolean get) { +/* 130 */ this(dest == null ? null : URL.make(dest), get); +/* */ } +/* */ +/* */ +/* */ +/* */ +/* */ private String trigger; +/* */ +/* */ +/* */ +/* */ public SendURLAction(URL dest, boolean get) +/* */ { +/* 142 */ this.destination = dest; +/* 143 */ this.getUser = get; +/* */ } +/* */ +/* */ public void setDestination(URL d) { +/* 147 */ this.destination = d; +/* */ } +/* */ +/* */ +/* */ +/* */ public void setTrigger(String t) +/* */ { +/* 154 */ this.trigger = t; +/* */ } +/* */ +/* */ public void startBrowser() { +/* 158 */ if (Main.isMainThread()) { +/* 159 */ tryLaunch(); +/* */ } else +/* 161 */ Main.register(this); +/* */ } +/* */ +/* */ public void mainCallback() { +/* 165 */ Main.unregister(this); +/* 166 */ tryLaunch(); +/* */ } +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ private URL getDestination() +/* */ { +/* 175 */ if (this.worldOverride != null) { +/* 176 */ IniFile ini = new IniFile("InstalledWorlds"); +/* 177 */ String first = ini.getIniString("InstalledWorld0", ""); +/* 178 */ if (this.worldOverride.equalsIgnoreCase(first)) +/* 179 */ return this.destinationOverride; +/* */ } +/* 181 */ return this.destination; +/* */ } +/* */ +/* */ private void tryLaunch() +/* */ { +/* 186 */ URL destURL = getDestination(); +/* 187 */ if (destURL == null) { +/* 188 */ return; +/* */ } +/* 190 */ String dest = destURL.unalias(); +/* */ +/* */ +/* 193 */ String newDest = WebControlImp.processURL(dest); +/* */ +/* 195 */ if (newDest != null) { +/* 196 */ dest = newDest; +/* */ } +/* 198 */ if (this.postData != null) { +/* 199 */ this.postData = WebControlImp.processURL(this.postData); +/* */ } +/* 201 */ String info = null; +/* */ +/* */ +/* 204 */ Console console = Console.getActive(); +/* 205 */ if ((console != null) && (console.getGalaxy().getChatname() != null) && +/* 206 */ (!console.getGalaxy().getChatname().equals(""))) { +/* 207 */ info = "Username=" + console.getGalaxy().getUsernameU(); +/* */ } +/* */ +/* */ +/* 211 */ if ((this.getUser) && (info != null)) { +/* 212 */ dest = dest + "?" + info; +/* */ } +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* 231 */ String midDest = dest.substring(dest.indexOf(":") + 1); +/* */ +/* 233 */ if (dest.startsWith("sound:")) { +/* 234 */ dest = URL.make(midDest).unalias(); +/* */ +/* 236 */ WavSoundPlayer.pauseSystem(); +/* 237 */ CDAudio.get().setEnabled(false); +/* */ try +/* */ { +/* 240 */ WebBrowser.forceMinimized(true); +/* 241 */ WebBrowser.reuseOrMake(dest, this.postData, +/* 242 */ WebBrowser.getAdPartPlacement(), +/* 243 */ "sound:"); +/* 244 */ WebBrowser.forceMinimized(false); +/* 245 */ return; +/* */ +/* */ +/* */ } +/* */ catch (IOException localIOException) {} +/* */ +/* */ } +/* 252 */ else if ((dest.startsWith("videoMap:")) || +/* 253 */ (dest.startsWith("overmap:"))) { +/* 254 */ dest = URL.make(midDest).unalias(); +/* */ +/* 256 */ WavSoundPlayer.pauseSystem(); +/* 257 */ CDAudio.get().setEnabled(false); +/* */ try +/* */ { +/* 260 */ WebBrowser.dontUseToolbar(); +/* 261 */ WebBrowser.dontUseWindowFrame(); +/* 262 */ WebBrowser.reuseOrMake(dest, this.postData, +/* */ +/* 264 */ WebBrowser.getMapPartPlacement(), +/* 265 */ "videoMap:"); +/* 266 */ WebBrowser.useToolbar(); +/* 267 */ return; +/* */ +/* */ +/* */ } +/* */ catch (IOException localIOException1) {} +/* */ +/* */ } +/* 274 */ else if (dest.startsWith("videoAd:")) { +/* 275 */ dest = URL.make(midDest).unalias(); +/* */ +/* 277 */ WavSoundPlayer.pauseSystem(); +/* 278 */ CDAudio.get().setEnabled(false); +/* */ try +/* */ { +/* 281 */ WebBrowser.dontUseToolbar(); +/* 282 */ WebBrowser.dontUseWindowFrame(); +/* 283 */ WebBrowser.reuseOrMake(dest, this.postData, +/* 284 */ WebBrowser.getAdPartPlacement(), +/* 285 */ "videoAd:"); +/* 286 */ WebBrowser.useToolbar(); +/* 287 */ return; +/* */ +/* */ +/* */ } +/* */ catch (IOException localIOException2) {} +/* */ +/* */ } +/* 294 */ else if (dest.startsWith("zoom:")) { +/* 295 */ dest = URL.make(midDest).unalias(); +/* */ +/* 297 */ WavSoundPlayer.pauseSystem(); +/* 298 */ CDAudio.get().setEnabled(false); +/* */ try +/* */ { +/* 301 */ WebBrowser.dontUseToolbar(); +/* 302 */ WebBrowser.dontUseWindowFrame(); +/* 303 */ WebBrowser.reuseOrMake(dest, this.postData, +/* 304 */ WebBrowser.getRenderPartPlacement(), +/* 305 */ "zoom:"); +/* 306 */ WebBrowser.useToolbar(); +/* 307 */ return; +/* */ +/* */ +/* */ } +/* */ catch (IOException localIOException3) {} +/* */ +/* */ } +/* 314 */ else if (dest.startsWith("zoomLeft:")) { +/* 315 */ dest = URL.make(midDest).unalias(); +/* */ +/* 317 */ WavSoundPlayer.pauseSystem(); +/* 318 */ CDAudio.get().setEnabled(false); +/* */ try +/* */ { +/* 321 */ WebBrowser.dontUseToolbar(); +/* 322 */ WebBrowser.dontUseWindowFrame(); +/* 323 */ WebBrowser.reuseOrMake(dest, this.postData, +/* 324 */ WebBrowser.getLeftRenderPartPlacement(), +/* 325 */ "zoomLeft:"); +/* 326 */ WebBrowser.useToolbar(); +/* 327 */ return; +/* */ +/* */ +/* */ } +/* */ catch (IOException localIOException4) {} +/* */ +/* */ } +/* 334 */ else if (dest.startsWith("outside:")) { +/* 335 */ dest = URL.make(midDest).unalias(); +/* */ +/* 337 */ WavSoundPlayer.pauseSystem(); +/* 338 */ CDAudio.get().setEnabled(false); +/* */ try +/* */ { +/* 341 */ WebBrowser.dontUseToolbar(); +/* 342 */ WebBrowser.reuseOrMake(dest, this.postData, +/* 343 */ WebBrowser.getOutsidePlacement(), +/* 344 */ "outside:"); +/* 345 */ WebBrowser.useToolbar(); +/* 346 */ return; +/* */ +/* */ } +/* */ catch (IOException localIOException5) {} +/* */ +/* */ } +/* 352 */ else if (dest.startsWith("http:")) { +/* */ try { +/* 354 */ WebBrowser.reuseOrMake(dest, this.postData); +/* 355 */ return; +/* */ } +/* */ catch (IOException localIOException6) {} +/* */ } +/* */ +/* */ +/* 361 */ if (this.bogusBrowser == null) +/* */ { +/* */ try +/* */ { +/* */ +/* 366 */ this.bogusBrowser = new InternetExplorer(null); +/* */ } +/* */ catch (IOException localIOException7) {} +/* */ } +/* */ +/* */ +/* 372 */ if (!launchViaRegistry(dest)) +/* 373 */ Console.println(dest + Console.message("Unable-to-launch")); +/* */ } +/* */ +/* 376 */ private int tries = 0; +/* 377 */ private Persister curSeq = null; +/* */ +/* */ public void doIt() { +/* 380 */ startBrowser(); +/* */ } +/* */ +/* */ public PolledDialog getDialog() +/* */ { +/* 385 */ URL tmpURL = getDestination(); +/* 386 */ if (tmpURL == null) { +/* 387 */ return new ItemNotAvailableDialog(Console.getFrame(), this); +/* */ } +/* 389 */ String tmp = tmpURL.unalias().toLowerCase(); +/* 390 */ if (tmp.startsWith(notAvailablePrefix)) +/* */ { +/* 392 */ if (notAvailable.containsKey(tmp.substring(notAvailablePrefix.length()))) { +/* 393 */ return new ItemNotAvailableDialog(Console.getFrame(), this); +/* */ } +/* */ } +/* 396 */ if ((this.description == null) || +/* 397 */ (this.description.equals("Would you like more information?"))) { +/* 398 */ return new MoreInfoDialog(Console.getFrame(), this); +/* */ } +/* 400 */ return new OkCancelDialog(Console.getFrame(), this, +/* 401 */ Console.message("BrowseQ"), Console.message("Cancel"), +/* 402 */ Console.message("OK"), this.description, false, 1); +/* */ } +/* */ +/* */ +/* */ +/* */ +/* */ private static native boolean launchViaRegistry(String paramString); +/* */ +/* */ +/* */ +/* */ public Object properties(int index, int offset, int mode, Object value) +/* */ throws NoSuchPropertyException +/* */ { +/* 415 */ Object ret = null; +/* 416 */ switch (index - offset) { +/* */ case 0: +/* 418 */ if (mode == 0) { +/* 419 */ ret = URLPropertyEditor.make(new Property(this, +/* 420 */ index, +/* 421 */ "Destination") +/* 422 */ .allowSetNull(), null); +/* 423 */ } else if (mode == 1) { +/* 424 */ ret = this.destination; +/* 425 */ } else if (mode == 2) +/* 426 */ this.destination = ((URL)value); +/* 427 */ break; +/* */ case 1: +/* 429 */ if (mode == 0) { +/* 430 */ ret = StringPropertyEditor.make(new Property(this, +/* 431 */ index, +/* 432 */ "Description")); +/* 433 */ } else if (mode == 1) { +/* 434 */ ret = this.description; +/* 435 */ } else if (mode == 2) +/* 436 */ this.description = ((String)value).trim(); +/* 437 */ break; +/* */ case 2: +/* 439 */ if (mode == 0) { +/* 440 */ ret = URLPropertyEditor.make(new Property(this, +/* 441 */ index, +/* 442 */ "Destination Override") +/* 443 */ .allowSetNull(), null); +/* 444 */ } else if (mode == 1) { +/* 445 */ ret = this.destinationOverride; +/* 446 */ } else if (mode == 2) +/* 447 */ this.destinationOverride = ((URL)value); +/* 448 */ break; +/* */ case 3: +/* 450 */ if (mode == 0) { +/* 451 */ ret = StringPropertyEditor.make(new Property(this, +/* 452 */ index, +/* 453 */ "Override World") +/* 454 */ .allowSetNull()); +/* 455 */ } else if (mode == 1) { +/* 456 */ ret = this.worldOverride; +/* 457 */ } else if (mode == 2) { +/* 458 */ if (value == null) { +/* 459 */ this.worldOverride = null; +/* */ } else { +/* 461 */ this.worldOverride = ((String)value).trim(); +/* 462 */ if (this.worldOverride.length() == 0) +/* 463 */ this.worldOverride = null; +/* */ } +/* */ } +/* 466 */ break; +/* */ case 4: +/* 468 */ if (mode == 0) { +/* 469 */ ret = BooleanPropertyEditor.make(new Property(this, +/* 470 */ index, "Send User Info (auto-login)"), "No", "Yes"); +/* 471 */ } else if (mode == 1) { +/* 472 */ ret = new Boolean(this.getUser); +/* 473 */ } else if (mode == 2) { +/* 474 */ if (((Boolean)value).booleanValue()) { +/* 475 */ this.getUser = true; +/* */ } else { +/* 477 */ this.getUser = false; +/* */ } +/* */ } +/* 480 */ break; +/* */ +/* */ case 5: +/* 483 */ if (mode == 0) { +/* 484 */ ret = StringPropertyEditor.make(new Property(this, +/* 485 */ index, +/* 486 */ "POST data")); +/* 487 */ } else if (mode == 1) { +/* 488 */ ret = this.postData; +/* 489 */ } else if (mode == 2) +/* 490 */ this.postData = ((String)value).trim(); +/* 491 */ break; +/* */ +/* */ +/* */ default: +/* 495 */ ret = super.properties(index, offset + 6, mode, value); +/* */ } +/* */ +/* 498 */ return ret; +/* */ } +/* */ +/* 501 */ private static Object classCookie = new Object(); +/* */ +/* */ public void saveState(Saver s) throws IOException +/* */ { +/* 505 */ s.saveVersion(9, classCookie); +/* 506 */ super.saveState(s); +/* 507 */ s.saveString(this.description); +/* 508 */ URL.save(s, this.destination); +/* 509 */ URL.save(s, this.destinationOverride); +/* 510 */ s.saveString(this.worldOverride); +/* 511 */ s.saveBoolean(this.getUser); +/* 512 */ s.saveString(this.postData); +/* */ } +/* */ +/* */ public void restoreState(Restorer r) throws IOException, TooNewException +/* */ { +/* 517 */ String destStr = null; +/* */ +/* 519 */ switch (r.restoreVersion(classCookie)) { +/* */ case 1: +/* 521 */ r.setOldFlag(); +/* 522 */ r.restoreBoolean(); +/* 523 */ destStr = r.restoreString(); +/* 524 */ r.restoreString(); +/* 525 */ break; +/* */ case 2: +/* 527 */ r.setOldFlag(); +/* 528 */ r.restoreBoolean(); +/* 529 */ destStr = r.restoreString(); +/* 530 */ break; +/* */ case 3: +/* 532 */ dialogActionSkipRestore(r); +/* 533 */ r.restoreBoolean(); +/* 534 */ destStr = r.restoreString(); +/* 535 */ break; +/* */ case 4: +/* 537 */ dialogActionSkipRestore(r); +/* 538 */ destStr = r.restoreString(); +/* 539 */ break; +/* */ case 5: +/* 541 */ dialogActionSkipRestore(r); +/* 542 */ destStr = r.restoreString(); +/* 543 */ this.getUser = r.restoreBoolean(); +/* 544 */ r.restoreBoolean(); +/* 545 */ break; +/* */ case 6: +/* 547 */ super.restoreState(r); +/* 548 */ this.description = r.restoreString(); +/* 549 */ destStr = r.restoreString(); +/* 550 */ this.getUser = r.restoreBoolean(); +/* 551 */ r.restoreBoolean(); +/* 552 */ break; +/* */ case 7: +/* 554 */ super.restoreState(r); +/* 555 */ this.description = r.restoreString(); +/* 556 */ destStr = r.restoreString(); +/* */ +/* 558 */ String destOverrideStr = r.restoreString(); +/* 559 */ if (destOverrideStr != null) { +/* 560 */ this.destinationOverride = URL.make(destOverrideStr); +/* */ } +/* 562 */ this.worldOverride = r.restoreString(); +/* 563 */ this.getUser = r.restoreBoolean(); +/* 564 */ r.restoreBoolean(); +/* 565 */ break; +/* */ case 8: +/* 567 */ super.restoreState(r); +/* 568 */ this.description = r.restoreString(); +/* 569 */ this.destination = URL.restore(r, null); +/* 570 */ this.destinationOverride = URL.restore(r, null); +/* 571 */ this.worldOverride = r.restoreString(); +/* 572 */ this.getUser = r.restoreBoolean(); +/* 573 */ r.restoreBoolean(); +/* 574 */ break; +/* */ case 9: +/* 576 */ super.restoreState(r); +/* 577 */ this.description = r.restoreString(); +/* 578 */ this.destination = URL.restore(r, null); +/* 579 */ this.destinationOverride = URL.restore(r, null); +/* 580 */ this.worldOverride = r.restoreString(); +/* 581 */ this.getUser = r.restoreBoolean(); +/* 582 */ this.postData = r.restoreString(); +/* 583 */ break; +/* */ +/* */ default: +/* 586 */ throw new TooNewException(); +/* */ } +/* 588 */ if (destStr != null) { +/* 589 */ this.destination = URL.make(destStr); +/* */ } +/* */ } +/* */ +/* */ public void postRestore(int version) { +/* 594 */ super.postRestore(version); +/* 595 */ if (this.trigger != null) +/* */ { +/* */ +/* 598 */ SuperRoot owner = getOwner(); +/* */ +/* 600 */ while ((owner != null) && (!(owner instanceof WObject))) { +/* 601 */ owner = owner.getOwner(); +/* */ } +/* 603 */ if (owner == null) { +/* 604 */ Object[] arguments = { new String(getName()) }; +/* 605 */ Console.println(MessageFormat.format( +/* 606 */ Console.message("Cannot-sensor"), arguments)); +/* 607 */ } else if (this.trigger.equals("click")) { +/* 608 */ ((WObject)owner).addHandler(new ClickSensor(this)); +/* 609 */ } else if (this.trigger.equals("bump")) { +/* 610 */ ((WObject)owner).addHandler(new BumpSensor(this)); +/* */ } else { +/* 612 */ Room r = ((WObject)owner).getRoom(); +/* 613 */ if (r != null) +/* */ { +/* 615 */ Object[] arguments = { new String(this.trigger), +/* 616 */ new String(getName()), new String(r.getName()) }; +/* 617 */ Console.println(MessageFormat.format( +/* 618 */ Console.message("Trigger-value-in"), arguments)); +/* */ } +/* */ else +/* */ { +/* 622 */ Object[] arguments = { new String(this.trigger), +/* 623 */ new String(getName()) }; +/* 624 */ Console.println(MessageFormat.format( +/* 625 */ Console.message("Trigger-value"), arguments)); +/* */ } +/* */ } +/* 628 */ this.trigger = null; +/* */ } +/* */ } +/* */ } + + +/* Location: C:\Program Files (x86)\Worlds Inc\WorldsPlayer - Win7\lib\worlds.jar!\NET\worlds\scape\SendURLAction.class + * Java compiler version: 6 (50.0) + * JD-Core Version: 0.7.1 + */
\ No newline at end of file |