/**
     * 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 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);
      }
    }
Ejemplo n.º 3
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);
        }
      }
    }
Ejemplo n.º 4
0
 /**
  * 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;
      }
    }