/**
     * The method is called by a ProtocolProvider implementation whenever a change in the
     * registration state of the corresponding provider had occurred.
     *
     * @param evt ProviderStatusChangeEvent the event describing the status change.
     */
    public void registrationStateChanged(RegistrationStateChangeEvent evt) {
      if (logger.isDebugEnabled())
        logger.debug(
            "The provider changed state from: " + evt.getOldState() + " to: " + evt.getNewState());

      if (evt.getNewState() == RegistrationState.REGISTERED) {
        opSetPersPresence =
            (OperationSetPresenceSipImpl)
                sipProvider.getOperationSet(OperationSetPersistentPresence.class);
      }
    }
    /**
     * The method would simply register all received events so that they could be available for
     * later inspection by the unit tests. In the case where a registration event notifying us of a
     * completed registration is seen, the method would call notifyAll().
     *
     * @param evt ProviderStatusChangeEvent the event describing the status change.
     */
    public void registrationStateChanged(RegistrationStateChangeEvent evt) {
      logger.debug("Received a RegistrationStateChangeEvent: " + evt);

      collectedNewStates.add(evt.getNewState());

      if (evt.getNewState().equals(RegistrationState.REGISTERED)) {
        logger.debug("We're registered and will notify those who wait");
        synchronized (this) {
          notifyAll();
        }
      }
    }
    /**
     * The method is called by a ProtocolProvider implementation whenever a change in the
     * registration state of the corresponding provider had occurred.
     *
     * @param evt ProviderStatusChangeEvent the event describing the status change.
     */
    public void registrationStateChanged(RegistrationStateChangeEvent evt) {
      if (logger.isDebugEnabled())
        logger.debug(
            "The provider changed state from: " + evt.getOldState() + " to: " + evt.getNewState());

      if (evt.getNewState() == RegistrationState.REGISTERED) {
        AimConnection aimConnection = icqProvider.getAimConnection();
        aimConnection
            .getIcbmService()
            .getRvConnectionManager()
            .addConnectionManagerListener(OperationSetFileTransferIcqImpl.this);
      }
    }
Exemple #4
0
    /**
     * The method is called by a ProtocolProvider implementation whenever a change in the
     * registration state of the corresponding provider had occurred. The method is particularly
     * interested in events stating that the SIP provider has unregistered so that it would fire
     * status change events for all contacts in our buddy list.
     *
     * @param evt ProviderStatusChangeEvent the event describing the status change.
     */
    public void registrationStateChanged(RegistrationStateChangeEvent evt) {
      if (evt.getNewState() == RegistrationState.UNREGISTERING
          || evt.getNewState() == RegistrationState.UNREGISTERED
          || evt.getNewState() == RegistrationState.AUTHENTICATION_FAILED
          || evt.getNewState() == RegistrationState.CONNECTION_FAILED) {
        // stop any task associated with the timer
        if (keepAliveTimer != null) {
          keepAliveTimer.cancel();
          keepAliveTimer = null;
        }
      } else if (evt.getNewState().equals(RegistrationState.REGISTERED)) {
        String keepAliveMethod =
            provider
                .getAccountID()
                .getAccountPropertyString(ProtocolProviderFactory.KEEP_ALIVE_METHOD);

        if (logger.isTraceEnabled()) logger.trace("Keep alive method " + keepAliveMethod);
        // options is default keep-alive, if property is missing
        // then options is used
        if (keepAliveMethod != null
            && !(keepAliveMethod.equalsIgnoreCase("options")
                || keepAliveMethod.equalsIgnoreCase("crlf"))) return;

        int keepAliveInterval =
            provider
                .getAccountID()
                .getAccountPropertyInt(ProtocolProviderFactory.KEEP_ALIVE_INTERVAL, -1);

        if (logger.isTraceEnabled()) logger.trace("Keep alive interval is " + keepAliveInterval);
        if (keepAliveInterval > 0 && !provider.getRegistrarConnection().isRegistrarless()) {
          if (keepAliveTimer == null) keepAliveTimer = new Timer();

          TimerTask keepAliveTask;
          // CRLF is used by default on Android
          if ((OSUtils.IS_ANDROID && keepAliveMethod == null)
              || "crlf".equalsIgnoreCase(keepAliveMethod)) {
            keepAliveTask = new CRLfKeepAliveTask();
          } else {
            // OPTIONS
            keepAliveTask = new OptionsKeepAliveTask();
          }

          if (logger.isDebugEnabled()) logger.debug("Scheduling keep alives: " + keepAliveTask);

          keepAliveTimer.schedule(keepAliveTask, 0, keepAliveInterval * 1000);
        }
      }
    }
 /**
  * Notified when registration state changed for a provider.
  *
  * @param evt
  */
 public void registrationStateChanged(RegistrationStateChangeEvent evt) {
   if (evt.getNewState() == RegistrationState.UNREGISTERING) {
     new Timer().schedule(this, TIME_FOR_PP_TO_UNREGISTER);
   } else {
     protocolProvider.removeRegistrationStateChangeListener(this);
     resetListeningPointsTimers.remove(protocolProvider.getRegistrarConnection().getTransport());
   }
 }
    /**
     * The method is called by a ProtocolProvider implementation whenever a change in the
     * registration state of the corresponding provider had occurred.
     *
     * @param evt ProviderStatusChangeEvent the event describing the status change.
     */
    public void registrationStateChanged(RegistrationStateChangeEvent evt) {
      if (logger.isDebugEnabled())
        logger.debug(
            "The provider changed state from: " + evt.getOldState() + " to: " + evt.getNewState());

      if (evt.getNewState() == RegistrationState.REGISTERED) {
        opSetPersPresence =
            (OperationSetPersistentPresenceJabberImpl)
                jabberProvider.getOperationSet(OperationSetPersistentPresence.class);

        // Create the Jabber FileTransferManager.
        manager = new FileTransferManager(jabberProvider.getConnection());

        fileTransferRequestListener = new FileTransferRequestListener();

        ProviderManager.getInstance()
            .addIQProvider(FileElement.ELEMENT_NAME, FileElement.NAMESPACE, new FileElement());

        ProviderManager.getInstance()
            .addIQProvider(ThumbnailIQ.ELEMENT_NAME, ThumbnailIQ.NAMESPACE, new ThumbnailIQ());

        jabberProvider
            .getConnection()
            .addPacketListener(
                fileTransferRequestListener,
                new AndFilter(
                    new PacketTypeFilter(StreamInitiation.class), new IQTypeFilter(IQ.Type.SET)));
      } else if (evt.getNewState() == RegistrationState.UNREGISTERED) {
        if (fileTransferRequestListener != null && jabberProvider.getConnection() != null) {
          jabberProvider.getConnection().removePacketListener(fileTransferRequestListener);
        }

        ProviderManager providerManager = ProviderManager.getInstance();
        if (providerManager != null) {
          ProviderManager.getInstance()
              .removeIQProvider(FileElement.ELEMENT_NAME, FileElement.NAMESPACE);

          ProviderManager.getInstance()
              .removeIQProvider(ThumbnailIQ.ELEMENT_NAME, ThumbnailIQ.NAMESPACE);
        }

        fileTransferRequestListener = null;
        manager = null;
      }
    }
Exemple #7
0
 @Override
 public void registrationStateChanged(RegistrationStateChangeEvent evt) {
   RegistrationState registrationState = evt.getNewState();
   logger.info("XMPP provider reg state: " + registrationState);
   if (RegistrationState.REGISTERED.equals(registrationState)) {
     // Do initializations which require valid connection
     meetExtensionsHandler.init();
   }
 }
    /**
     * The method is called by a ProtocolProvider implementation whenever a change in the
     * registration state of the corresponding provider had occurred.
     *
     * @param evt ProviderStatusChangeEvent the event describing the status change.
     */
    public void registrationStateChanged(RegistrationStateChangeEvent evt) {
      if (logger.isDebugEnabled())
        logger.debug(
            "The provider changed state from: " + evt.getOldState() + " to: " + evt.getNewState());

      if (evt.getNewState() == RegistrationState.REGISTERING) {
        opSetPersPresence =
            (OperationSetPersistentPresenceJabberImpl)
                jabberProvider.getOperationSet(OperationSetPersistentPresence.class);

        if (smackMessageListener == null) {
          smackMessageListener = new SmackMessageListener();
        } else {
          // make sure this listener is not already installed in this
          // connection
          jabberProvider.getConnection().removePacketListener(smackMessageListener);
        }

        jabberProvider
            .getConnection()
            .addPacketListener(
                smackMessageListener,
                new AndFilter(packetFilters.toArray(new PacketFilter[packetFilters.size()])));
      } else if (evt.getNewState() == RegistrationState.REGISTERED) {
        new Thread(
                new Runnable() {
                  @Override
                  public void run() {
                    initAdditionalServices();
                  }
                })
            .start();
      } else if (evt.getNewState() == RegistrationState.UNREGISTERED
          || evt.getNewState() == RegistrationState.CONNECTION_FAILED
          || evt.getNewState() == RegistrationState.AUTHENTICATION_FAILED) {
        if (jabberProvider.getConnection() != null) {
          if (smackMessageListener != null)
            jabberProvider.getConnection().removePacketListener(smackMessageListener);
        }

        smackMessageListener = null;
      }
    }
  /**
   * {@inheritDoc}
   *
   * <p>Implements {@link RegistrationStateChangeListener}. Notifies this instance that there has
   * been a change in the <tt>RegistrationState</tt> of {@link #protocolProvider}. Subscribes this
   * instance to {@link ColibriConferenceIQ}s as soon as <tt>protocolProvider</tt> is registered and
   * unsubscribes it as soon as <tt>protocolProvider</tt> is unregistered.
   */
  public void registrationStateChanged(RegistrationStateChangeEvent ev) {
    RegistrationState registrationState = ev.getNewState();

    if (RegistrationState.REGISTERED.equals(registrationState)) {
      protocolProvider.getConnection().addPacketListener(this, this);
    } else if (RegistrationState.UNREGISTERED.equals(registrationState)) {
      XMPPConnection connection = protocolProvider.getConnection();

      if (connection != null) connection.removePacketListener(this);
    }
  }