Package com.aelitis.azureus.core.messenger

Examples of com.aelitis.azureus.core.messenger.ClientMessageContext$torrentURLHandler


            return false;
          }

          String value = (String) valueObj;

          ClientMessageContext context = PlatformMessenger.getClientMessageContext();
          if (context == null) {
            return false;
          }
         
          // AZMSG;x;listener-id;op-id;params
          String[] splitVal = value.split(";", 5);
          if (splitVal.length != 5) {
            return false;
          }
          String lId = splitVal[2];
          String opId = splitVal[3];
          Map decodedMap = JSONUtils.decodeJSON(splitVal[4]);
          if (decodedMap == null) {
            decodedMap = Collections.EMPTY_MAP;
          }

          if (opId.equals(DisplayListener.OP_OPEN_URL)) {
            String url = MapUtils.getMapString(decodedMap, "url", null);
            if (!decodedMap.containsKey("target")) {
              context.debug("no target for url: " + url);
            } else if (UrlFilter.getInstance().urlIsBlocked(url)) {
              context.debug("url blocked: " + url);
            } else if (!UrlFilter.getInstance().urlCanRPC(url)) {
              context.debug("url not in whitelistL " + url);
            } else {
              // implicit bring to front
              final UIFunctions functions = UIFunctionsManager.getUIFunctions();
              if (functions != null) {
                functions.bringToFront();
              }

              // 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 {
View Full Code Here


   *
   *
   * @since 3.0.5.3
   */
  private void initializePlatformClientMessageContext() {
    ClientMessageContext clientMsgContext = PlatformMessenger.getClientMessageContext();
    if (clientMsgContext != null) {
      clientMsgContext.setMessageDispatcher(new MessageDispatcherSWT(clientMsgContext));
      clientMsgContext.addMessageListener(new TorrentListener());
      clientMsgContext.addMessageListener(new VuzeListener());
      clientMsgContext.addMessageListener(new DisplayListener(null));
      clientMsgContext.addMessageListener(new ConfigListener(null));
    }
    PluginInitializer.getDefaultInterface().addEventListener(new PluginEventListener() {
      public void handleEvent(PluginEvent ev) {
        try {
          int type = ev.getType();
View Full Code Here

          authURL, 560, 390, false, true);
 
      final Boolean[] b = new Boolean[1];
      b[0] = Boolean.FALSE;
 
      ClientMessageContext context = browserWindow.getContext();
      context.addMessageListener(new AbstractBrowserMessageListener(
          "contentnetwork") {
        public void handleMessage(BrowserMessage message) {
          String opid = message.getOperationId();
 
          if ("authorize".equals(opid)) {
View Full Code Here

TOP

Related Classes of com.aelitis.azureus.core.messenger.ClientMessageContext$torrentURLHandler

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.