Package com.aelitis.azureus.core.messenger.browser

Examples of com.aelitis.azureus.core.messenger.browser.BrowserMessage


              // this is actually sync.. so we could add a completion listener
              // and return the boolean result if we wanted/needed
              BrowserMessageDispatcher dispatcher = context.getDispatcher();
              if (dispatcher != null) {
                dispatcher.dispatch(new BrowserMessage(lId, opId, decodedMap));
              } else {
                context.debug("No dispatcher for StimulusRPC" + opId);
              }

              return true;
            }

          } else if (opId.equals(TorrentListener.OP_LOAD_TORRENT)) {
            if (decodedMap.containsKey("b64")) {
              String b64 = MapUtils.getMapString(decodedMap, "b64", null);
              return TorrentListener.loadTorrentByB64(core, b64);
            } else if (decodedMap.containsKey("url")) {
              String url = MapUtils.getMapString(decodedMap, "url", null);

              boolean blocked = UrlFilter.getInstance().urlIsBlocked(url);
              // Security: Only allow torrents from whitelisted urls
              if (blocked) {
                Debug.out("stopped loading torrent URL because it's not in whitelist");
                return false;
              }

              boolean playNow = MapUtils.getMapBoolean(decodedMap, "play-now",
                  false);
              boolean playPrepare = MapUtils.getMapBoolean(decodedMap,
                  "play-prepare", false);
              boolean bringToFront = MapUtils.getMapBoolean(decodedMap,
                  "bring-to-front", true);
             
              // Content Network of context is invalid because it's the
              // internal one used for anythin. Get network id from params instead
              long contentNetworkID = MapUtils.getMapLong(decodedMap,
                  "content-network", ConstantsVuze.getDefaultContentNetwork().getID());
              ContentNetwork cn = ContentNetworkManagerFactory.getSingleton().getContentNetwork(contentNetworkID);
              if (cn == null) {
                cn = ConstantsVuze.getDefaultContentNetwork();
              }

              DownloadUrlInfo dlInfo = new DownloadUrlInfoContentNetwork(url,
                  cn);
              dlInfo.setReferer(MapUtils.getMapString(decodedMap, "referer",
                  null));

              TorrentUIUtilsV3.loadTorrent(dlInfo, playNow, playPrepare,
                  bringToFront);

              return true;
            }
          } else if (opId.equals("is-ready")) {
            // The platform needs to know when it can call open-url, and it
            // determines this by the is-ready function
            return mainWindow.isReady();
          } else if (opId.equals("is-version-ge")) {
            if (decodedMap.containsKey("version")) {
              String id = MapUtils.getMapString(decodedMap, "id", "client");
              String version = MapUtils.getMapString(decodedMap, "version", "");
              if (id.equals("client")) {
                return org.gudy.azureus2.core3.util.Constants.compareVersions(
                    org.gudy.azureus2.core3.util.Constants.AZUREUS_VERSION,
                    version) >= 0;
              }
            }
            return false;

          } else if (opId.equals("is-active-tab")) {
            if (decodedMap.containsKey("tab")) {
              String tabID = MapUtils.getMapString(decodedMap, "tab", "");
              if (tabID.length() > 0) {
                // 3.2 TODO: Should we be checking for partial matches?
                MultipleDocumentInterface mdi = UIFunctionsManager.getUIFunctions().getMDI();
                MdiEntry entry = mdi.getCurrentEntry();
                if (entry != null) {
                  return entry.getId().equals(tabID);
                }
              }
            }

            return false;

          } else if (ConfigListener.DEFAULT_LISTENER_ID.equals(lId)) {
            if (ConfigListener.OP_NEW_INSTALL.equals(opId)) {
              return COConfigurationManager.isNewInstall();
            } else if (ConfigListener.OP_CHECK_FOR_UPDATES.equals(opId)) {
              ConfigListener.checkForUpdates();
              return true;
            } else if (ConfigListener.OP_LOG_DIAGS.equals(opId)) {
              ConfigListener.logDiagnostics();
              return true;
            }
          } else if (DisplayListener.DEFAULT_LISTENER_ID.equals(lId)) {
            if (DisplayListener.OP_REFRESH_TAB.equals(opId)) {
              DisplayListener.refreshTab(MapUtils.getMapString(decodedMap, "browser-id", ""));
            } else if (DisplayListener.OP_SWITCH_TO_TAB.equals(opId)) {
              DisplayListener.switchToTab(MapUtils.getMapString(decodedMap,
                  "target", ""), MapUtils.getMapString(decodedMap,
                  "source-ref", null));
            }

          } else if (DisplayListener.OP_SHOW_DONATION_WINDOW.equals(lId)) {
            DonationWindow.open(true, MapUtils.getMapString(decodedMap,
                "source-ref", "SRPC"));
          }


          if (System.getProperty(
              "browser.route.all.external.stimuli.for.testing", "false").equalsIgnoreCase(
              "true")) {

            BrowserMessageDispatcher dispatcher = context.getDispatcher();
            if (dispatcher != null) {
              dispatcher.dispatch(new BrowserMessage(lId, opId, decodedMap));
            }
          } else {

            System.err.println("Unhandled external stimulus: " + value);
          }
View Full Code Here


  
            params = JSONUtils.decodeJSON((String)args[2]);
          }
         
 
          BrowserMessage message = new BrowserMessage((String) args[0], (String) args[1], params);
          message.setReferer(browser.getUrl());
          dispatch(message);
          return null;
        }
      };
    } catch (Throwable t) {
View Full Code Here

TOP

Related Classes of com.aelitis.azureus.core.messenger.browser.BrowserMessage

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.