/** * 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; } }
/** * 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); } }