/**
   * Creates an instance of this operation set.
   *
   * @param provider a reference to the <tt>ProtocolProviderServiceImpl</tt> that created us and
   *     that we'll use for retrieving the underlying aim connection.
   */
  OperationSetBasicInstantMessagingJabberImpl(ProtocolProviderServiceJabberImpl provider) {
    this.jabberProvider = provider;

    packetFilters.add(new GroupMessagePacketFilter());
    packetFilters.add(new PacketTypeFilter(org.jivesoftware.smack.packet.Message.class));

    provider.addRegistrationStateChangeListener(new RegistrationStateListener());

    ProviderManager man = ProviderManager.getInstance();
    MessageCorrectionExtensionProvider extProvider = new MessageCorrectionExtensionProvider();
    man.addExtensionProvider(
        MessageCorrectionExtension.ELEMENT_NAME, MessageCorrectionExtension.NAMESPACE, extProvider);
  }
  /**
   * Subscribes this provider as interested in receiving notifications for new mail messages from
   * Google mail services such as Gmail or Google Apps.
   */
  private void subscribeForGmailNotifications() {
    // first check support for the notification service
    String accountIDService = jabberProvider.getAccountID().getService();
    boolean notificationsAreSupported =
        jabberProvider.isFeatureSupported(accountIDService, NewMailNotificationIQ.NAMESPACE);

    if (!notificationsAreSupported) {
      if (logger.isDebugEnabled())
        logger.debug(
            accountIDService
                + " does not seem to provide a Gmail notification "
                + " service so we won't be trying to subscribe for it");
      return;
    }

    if (logger.isDebugEnabled())
      logger.debug(
          accountIDService
              + " seems to provide a Gmail notification "
              + " service so we will try to subscribe for it");

    ProviderManager providerManager = ProviderManager.getInstance();

    providerManager.addIQProvider(
        MailboxIQ.ELEMENT_NAME, MailboxIQ.NAMESPACE, new MailboxIQProvider());
    providerManager.addIQProvider(
        NewMailNotificationIQ.ELEMENT_NAME,
        NewMailNotificationIQ.NAMESPACE,
        new NewMailNotificationProvider());

    Connection connection = jabberProvider.getConnection();

    connection.addPacketListener(new MailboxIQListener(), new PacketTypeFilter(MailboxIQ.class));
    connection.addPacketListener(
        new NewMailNotificationListener(), new PacketTypeFilter(NewMailNotificationIQ.class));

    if (opSetPersPresence.getCurrentStatusMessage().equals(JabberStatusEnum.OFFLINE)) return;

    // create a query with -1 values for newer-than-tid and
    // newer-than-time attributes
    MailboxQueryIQ mailboxQuery = new MailboxQueryIQ();

    if (logger.isTraceEnabled())
      logger.trace(
          "sending mailNotification for acc: "
              + jabberProvider.getAccountID().getAccountUniqueID());
    jabberProvider.getConnection().sendPacket(mailboxQuery);
  }
    /**
     * 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 #4
0
  /** Starts this manager for given <tt>hostName</tt>. */
  public void start() {
    expireThread.start();

    ConfigurationService config = FocusBundleActivator.getConfigService();

    String hostName = config.getString(HOSTNAME_PNAME);

    String xmppDomain = config.getString(XMPP_DOMAIN_PNAME);

    focusUserDomain = config.getString(FOCUS_USER_DOMAIN_PNAME);

    focusUserName = config.getString(FOCUS_USER_NAME_PNAME);

    String focusUserPassword = config.getString(FOCUS_USER_PASSWORD_PNAME);

    protocolProviderHandler.start(hostName, focusUserDomain, focusUserPassword, focusUserName);

    jitsiMeetServices =
        new JitsiMeetServices(
            protocolProviderHandler.getOperationSet(OperationSetSubscription.class));

    componentsDiscovery = new ComponentsDiscovery(jitsiMeetServices);

    componentsDiscovery.start(xmppDomain, protocolProviderHandler);

    meetExtensionsHandler = new MeetExtensionsHandler(this);

    ProviderManager.getInstance()
        .addExtensionProvider(
            LogPacketExtension.LOG_ELEM_NAME,
            LogPacketExtension.NAMESPACE,
            new LogExtensionProvider());

    FocusBundleActivator.bundleContext.registerService(
        JitsiMeetServices.class, jitsiMeetServices, null);

    protocolProviderHandler.addRegistrationListener(this);

    protocolProviderHandler.register();
  }