summaryrefslogtreecommitdiff
path: root/NET/worlds/scape/SendURLAction.java
diff options
context:
space:
mode:
authorFuwn <[email protected]>2026-02-12 22:33:32 -0800
committerFuwn <[email protected]>2026-02-12 22:33:32 -0800
commitc7a9d4a6bd53ed7d61731770f2f10e8b9fd435f9 (patch)
treedf9f48bf128a6c0186a8e91857d6ff30fe0e9f18 /NET/worlds/scape/SendURLAction.java
downloadworldsplayer-c7a9d4a6bd53ed7d61731770f2f10e8b9fd435f9.tar.xz
worldsplayer-c7a9d4a6bd53ed7d61731770f2f10e8b9fd435f9.zip
Initial commit
Diffstat (limited to 'NET/worlds/scape/SendURLAction.java')
-rw-r--r--NET/worlds/scape/SendURLAction.java442
1 files changed, 442 insertions, 0 deletions
diff --git a/NET/worlds/scape/SendURLAction.java b/NET/worlds/scape/SendURLAction.java
new file mode 100644
index 0000000..83da5e1
--- /dev/null
+++ b/NET/worlds/scape/SendURLAction.java
@@ -0,0 +1,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;
+ }
+ }
+}