Java Code Examples for org.jivesoftware.smack.provider.ProviderManager#addIQProvider()

The following examples show how to use org.jivesoftware.smack.provider.ProviderManager#addIQProvider() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: PhonePlugin.java    From Spark with Apache License 2.0 5 votes vote down vote up
public void initialize() {
    ProviderManager.addExtensionProvider("phone-event", "http://jivesoftware.com/xmlns/phone", new PhoneEventPacketExtensionProvider());
    ProviderManager.addIQProvider("phone-action", "http://jivesoftware.com/xmlns/phone", new PhoneActionIQProvider());

    final XMPPConnection con = SparkManager.getConnection();


    SwingWorker worker = new SwingWorker() {
        public Object construct() {
            try {
                phoneClient = new PhoneClient(con);

                // Add BaseListener
                phoneClient.addEventListener(new PhoneListener());
            }
            catch (Exception e) {
                // Ignore because the user does not have support.
                //Log.debug(e);
            }
            return phoneClient;
        }

        public void finished() {
            if (phoneClient != null) {
                setupPhoneSystem();
            }
        }
    };

    worker.start();
}
 
Example 2
Source File: RemoteGroupCreationOverXMPP.java    From olat with Apache License 2.0 5 votes vote down vote up
protected RemoteGroupCreationOverXMPP() {

        final ProviderManager providerMgr = ProviderManager.getInstance();
        // register iq handler
        providerMgr.addIQProvider("query", GroupCreate.NAMESPACE, new GroupCreate.Provider());
        providerMgr.addIQProvider("query", GroupDelete.NAMESPACE, new GroupDelete.Provider());

        providerMgr.addIQProvider("query", AddUserToGroup.NAMESPACE, new AddUserToGroup.Provider());
        providerMgr.addIQProvider("query", RemoveUserFromGroup.NAMESPACE, new RemoveUserFromGroup.Provider());
    }
 
Example 3
Source File: RemoteAccountCreationOverXMPP.java    From olat with Apache License 2.0 5 votes vote down vote up
protected RemoteAccountCreationOverXMPP() {
    final ProviderManager providerMgr = ProviderManager.getInstance();
    // register iq handlers
    providerMgr.addIQProvider("query", UserCreate.NAMESPACE, new UserCreate.Provider());
    providerMgr.addIQProvider("query", UserDelete.NAMESPACE, new UserDelete.Provider());
    providerMgr.addIQProvider("query", UserCheck.NAMESPACE, new UserCheck.Provider());

}
 
Example 4
Source File: SparkFileUploadPlugin.java    From Spark with Apache License 2.0 5 votes vote down vote up
public void initialize()
{
    ProviderManager.addIQProvider("slot", UploadRequest.NAMESPACE, new UploadRequest.Provider());

    chatManager = SparkManager.getChatManager();
    chatManager.addChatRoomListener(this);
    chatManager.addGlobalMessageListener(this);
}
 
Example 5
Source File: ReversiPlugin.java    From Spark with Apache License 2.0 5 votes vote down vote up
public void initialize() {
    // Offers and invitations hold all pending game offers we've sent to
    // other users or incoming
    // invitations. The map key is always the opponent's JID. The map value
    // is a transcript alert
    // UI component.
    gameOffers = new ConcurrentHashMap<String, JPanel>();
    gameInvitations = new ConcurrentHashMap<>();

    // Add Reversi item to chat toolbar.
    addToolbarButton();

    // Add Smack providers. The plugin uses custom XMPP extensions to
    // communicate game offers
    // and current game state. Adding the Smack providers lets us use the
    // custom protocol.
    ProviderManager.addIQProvider(GameOffer.ELEMENT_NAME, GameOffer.NAMESPACE, new GameOffer.Provider());
    ProviderManager.addExtensionProvider(GameMove.ELEMENT_NAME, GameMove.NAMESPACE, new GameMove.Provider());
    ProviderManager.addExtensionProvider(GameForfeit.ELEMENT_NAME, GameForfeit.NAMESPACE, new GameForfeit.Provider());

    // Add IQ listener to listen for incoming game invitations.
    gameOfferListener = new StanzaListener() {
        @Override
        public void processStanza(Stanza stanza) {
            GameOffer invitation = (GameOffer) stanza;
            if (invitation.getType() == IQ.Type.get) {
                showInvitationAlert(invitation);
            } else if (invitation.getType() == IQ.Type.error) {
                handleErrorIQ(invitation);
            }
        }
    };
    SparkManager.getConnection().addAsyncStanzaListener(gameOfferListener, new StanzaTypeFilter(GameOffer.class));
}
 
Example 6
Source File: RemoteGroupCreationOverXMPP.java    From olat with Apache License 2.0 5 votes vote down vote up
protected RemoteGroupCreationOverXMPP() {

        final ProviderManager providerMgr = ProviderManager.getInstance();
        // register iq handler
        providerMgr.addIQProvider("query", GroupCreate.NAMESPACE, new GroupCreate.Provider());
        providerMgr.addIQProvider("query", GroupDelete.NAMESPACE, new GroupDelete.Provider());

        providerMgr.addIQProvider("query", AddUserToGroup.NAMESPACE, new AddUserToGroup.Provider());
        providerMgr.addIQProvider("query", RemoveUserFromGroup.NAMESPACE, new RemoveUserFromGroup.Provider());
    }
 
Example 7
Source File: RemoteAccountCreationOverXMPP.java    From olat with Apache License 2.0 5 votes vote down vote up
protected RemoteAccountCreationOverXMPP() {
    final ProviderManager providerMgr = ProviderManager.getInstance();
    // register iq handlers
    providerMgr.addIQProvider("query", UserCreate.NAMESPACE, new UserCreate.Provider());
    providerMgr.addIQProvider("query", UserDelete.NAMESPACE, new UserDelete.Provider());
    providerMgr.addIQProvider("query", UserCheck.NAMESPACE, new UserCheck.Provider());

}
 
Example 8
Source File: CheckUpdates.java    From Spark with Apache License 2.0 5 votes vote down vote up
public CheckUpdates() {
    // Set the Jabber IQ Provider for Jabber:iq:spark
    ProviderManager.addIQProvider("query", "jabber:iq:spark", new SparkVersion.Provider());

    // For simplicity, use an alias for the root xml tag
    xstream.alias("Version", SparkVersion.class);

    // Specify the main update url for JiveSoftware
    this.mainUpdateURL = "http://www.igniterealtime.org/updater/updater";

    sparkPluginInstalled = isSparkPluginInstalled(SparkManager.getConnection());
}
 
Example 9
Source File: ProviderRegister.java    From xyTalk-pc with GNU Affero General Public License v3.0 5 votes vote down vote up
public static void register(){
	//ProviderManager.addExtensionProvider("request", "urn:xmpp:receipts", new ReceiptProvider());
       ProviderManager.addExtensionProvider("event", "http://jabber.org/protocol/disco#info", new Features.Provider());
       ProviderManager.addExtensionProvider("x", MucInvitation.NAMESPACE, new MucInvitation.Provider());
       ProviderManager.addExtensionProvider("x", MucKick.NAMESPACE, new MucKick.Provider());
       ProviderManager.addExtensionProvider("x", MucUpdateMembers.NAMESPACE, new MucUpdateMembers.Provider());
       ProviderManager.addExtensionProvider("x", OfflineFile.NAMESPACE, new OfflineFile.Provider());
       ProviderManager.addExtensionProvider("x", OfflineFileReceipt.NAMESPACE, new OfflineFileReceipt.Provider());        
       ProviderManager.addExtensionProvider("x", OfflineFileRobot.NAMESPACE, new OfflineFileRobot.Provider());     
       ProviderManager.addIQProvider("query", "http://jabber.org/protocol/muc#owner",  
               new MUCOwnerProvider());
       ProviderManager.addIQProvider("query","http://jabber.org/protocol/muc#admin", new MUCAdminProvider());
}
 
Example 10
Source File: JingleManager.java    From Smack with Apache License 2.0 5 votes vote down vote up
/**
 * Setup the jingle system to let the remote clients know we support Jingle.
 * (This used to be a static part of construction.  The problem is a remote client might
 * attempt a Jingle connection to us after we've created an XMPPConnection, but before we've
 * setup an instance of a JingleManager.  We will appear to not support Jingle.  With the new
 * method you just call it once and all new connections will report Jingle support.)
 */
public static void setJingleServiceEnabled() {
    ProviderManager.addIQProvider("jingle", "urn:xmpp:tmp:jingle", new JingleProvider());

    // Enable the Jingle support on every established connection
    // The ServiceDiscoveryManager class should have been already
    // initialized
    XMPPConnectionRegistry.addConnectionCreationListener(new ConnectionCreationListener() {
        @Override
        public void connectionCreated(XMPPConnection connection) {
            JingleManager.setServiceEnabled(connection, true);
        }
    });
}
 
Example 11
Source File: XStreamExtensionProvider.java    From saros with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Create a new XStreamExtensionProvider using the given element name as the XML root element with
 * the given namespace. The Provider is able to understand the given classes, which should be
 * annotated using XStream annotations.
 *
 * <p><b>Important</b>: use valid XML element names and namespaces or the receiving side will be
 * unable to decode the extension !
 */
public XStreamExtensionProvider(String namespace, String elementName, Class<?>... classes) {

  if (namespace == null) throw new NullPointerException("namespace is null");

  ClassLoader classLoader = currentClassloader;

  this.elementName = elementName;
  this.namespace = namespace;

  xstream = XStreamFactory.getSecureXStream();

  if (classLoader != null) xstream.setClassLoader(classLoader);
  else xstream.setClassLoader(getClass().getClassLoader());

  xstream.registerConverter(BooleanConverter.BINARY);
  xstream.registerConverter(new UrlEncodingStringConverter());
  xstream.processAnnotations(XStreamPacketExtension.class);
  xstream.processAnnotations(classes);
  xstream.alias(elementName, XStreamPacketExtension.class);

  ProviderManager providerManager = ProviderManager.getInstance();
  providerManager.addExtensionProvider(getElementName(), getNamespace(), this);
  providerManager.addIQProvider(getElementName(), getNamespace(), this);

  // TODO Validate that elementName is a valid XML identifier

  replaceables = new HashMap<Class<? extends Converter>, ReplaceableConverter>();
  replaceableSingles =
      new HashMap<Class<? extends SingleValueConverter>, ReplaceableSingleValueConverter>();
}
 
Example 12
Source File: RemotePluginVersionOverXMPP.java    From olat with Apache License 2.0 4 votes vote down vote up
RemotePluginVersionOverXMPP() {
    // register IQ handler
    final ProviderManager providerMgr = ProviderManager.getInstance();
    providerMgr.addIQProvider("query", PluginVersion.NAMESPACE, new PluginVersion.Provider());

}
 
Example 13
Source File: SoftPhoneManager.java    From Spark with Apache License 2.0 4 votes vote down vote up
/**
 * Setup the Preferences according to remote server
 *
 * @param con XMPPConnection connection
 */
private void setupRemotePreferences(XMPPConnection con) {

    try {
        ProviderManager.addIQProvider(SipAccountPacket.ELEMENT_NAME, SipAccountPacket.NAMESPACE, new SipAccountPacket.Provider());

        ProviderManager.addIQProvider(LogPacket.ELEMENT_NAME, LogPacket.NAMESPACE, new LogPacket.Provider());

        SipAccountPacket sp = SipAccountPacket.getSipSettings(con);

        if (sp != null) {

            SipAccount sipAccount = sp.getSipAccount();

            if (sipAccount != null) {
                this.saccount = sipAccount;
                preference = new SipPreference();
                preference.setShowGUI(false);
                preference.setCommitSettings(false);

                preferences = new SipPreferences();

                preferences.setUserName(sipAccount.getSipUsername());
                preferences.setAuthUserName(sipAccount.getAuthUsername());
                preferences.setServer(sipAccount.getServer());
                preferences.setPassword(sipAccount.getPassword());
                preferences.setRegisterAtStart(true);

                preferences.setStunServer(sipAccount.getStunServer());
                preferences.setStunPort(sipAccount.getStunPort());
                preferences.setUseStun(sipAccount.isUseStun());
                preferences.setVoicemail(sipAccount.getVoiceMailNumber());
                preferences.setOutboundproxy(sipAccount.getOutboundproxy());
                preferences.setPromptCredentials(sipAccount.isPromptCredentials());

                SIPConfig.setUseStun(preferences.isUseStun());
                SIPConfig.setStunServer(preferences.getStunServer());
                SIPConfig.setStunPort(preferences.getStunPort());
                SIPConfig.setOutboundProxy(preferences.getOutboundproxy());

                preference.setData(preferences);
                SIPConfig.setPreferredNetworkAddress(NetworkAddressManager.getLocalHost(false).getHostAddress());

                if (preferences.isRegisterAtStart()) {
                    register();
                }

                if (preferences.isPromptCredentials()) {
                    loadLocalPreferences();
                }

            } else {

            }
        }

    }
    catch (Exception e) {
        Log.error("setupRemotePreferences", e);
    }

}
 
Example 14
Source File: GatewayPlugin.java    From Spark with Apache License 2.0 4 votes vote down vote up
@Override
public void initialize() {
ProviderManager.addIQProvider(Gateway.ELEMENT_NAME, Gateway.NAMESPACE, new Gateway.Provider());
LocalPreferences localPref = SettingsManager.getLocalPreferences();
useTab = localPref.getShowTransportTab();
transferTab.setBackground((Color)UIManager.get("ContactItem.background"));
       SwingWorker thread = new SwingWorker() {
           @Override
		public Object construct() {
               try {
                   // Let's try and avoid any timing issues with the gateway presence.
                   Thread.sleep(5000);
                   populateTransports();
               }
               catch (Exception e) {
                   Log.error(e);
                   return false;
               }

               return true;
           }

           @Override
		public void finished() {
       	
       	transferTab.setLayout(new VerticalFlowLayout(0,0,0,true,false));
       	Boolean transportExists = (Boolean)get();
               if (!transportExists) {
                   return;
               } 
               
               
               
               if (TransportUtils.getTransports().size() > 0  && useTab) {
                  SparkManager.getWorkspace().getWorkspacePane().addTab(Res.getString("title.transports"), SparkRes.getImageIcon(SparkRes.TRANSPORT_ICON), transferTab); 
               }

               for (final Transport transport : TransportUtils.getTransports()) {
                   addTransport(transport);
               }

               // Register presences.
               registerPresenceListener();
           }
       };

       thread.start();
   }
 
Example 15
Source File: RemoteSessionsOnIMServerOverXMPP.java    From olat with Apache License 2.0 4 votes vote down vote up
protected RemoteSessionsOnIMServerOverXMPP(final ImPrefsManager imPrefsManager) {
    this.imPrefsManager = imPrefsManager;
    final ProviderManager providerMgr = ProviderManager.getInstance();
    // register iq handler
    providerMgr.addIQProvider("query", SessionItems.NAMESPACE, new SessionItems.Provider());
}
 
Example 16
Source File: RemoteSessionCountOverXMPP.java    From olat with Apache License 2.0 4 votes vote down vote up
RemoteSessionCountOverXMPP() {
    // register IQ handler
    final ProviderManager providerMgr = ProviderManager.getInstance();
    providerMgr.addIQProvider("query", SessionCount.NAMESPACE, new SessionCount.Provider());

}
 
Example 17
Source File: RemotePluginVersionOverXMPP.java    From olat with Apache License 2.0 4 votes vote down vote up
RemotePluginVersionOverXMPP() {
    // register IQ handler
    final ProviderManager providerMgr = ProviderManager.getInstance();
    providerMgr.addIQProvider("query", PluginVersion.NAMESPACE, new PluginVersion.Provider());

}
 
Example 18
Source File: RemoteSessionsOnIMServerOverXMPP.java    From olat with Apache License 2.0 4 votes vote down vote up
protected RemoteSessionsOnIMServerOverXMPP(final ImPrefsManager imPrefsManager) {
    this.imPrefsManager = imPrefsManager;
    final ProviderManager providerMgr = ProviderManager.getInstance();
    // register iq handler
    providerMgr.addIQProvider("query", SessionItems.NAMESPACE, new SessionItems.Provider());
}
 
Example 19
Source File: RemoteSessionCountOverXMPP.java    From olat with Apache License 2.0 4 votes vote down vote up
RemoteSessionCountOverXMPP() {
    // register IQ handler
    final ProviderManager providerMgr = ProviderManager.getInstance();
    providerMgr.addIQProvider("query", SessionCount.NAMESPACE, new SessionCount.Provider());

}
 
Example 20
Source File: BattleshipPlugin.java    From Spark with Apache License 2.0 3 votes vote down vote up
@Override
   public void initialize() {

ProviderManager.addIQProvider(GameOfferPacket.ELEMENT_NAME, GameOfferPacket.NAMESPACE, GameOfferPacket.class);
ProviderManager.addExtensionProvider(MovePacket.ELEMENT_NAME, MovePacket.NAMESPACE, MovePacket.class);
ProviderManager.addExtensionProvider(MoveAnswerPacket.ELEMENT_NAME, MoveAnswerPacket.NAMESPACE, MoveAnswerPacket.class);


_gameofferListener = new StanzaListener() {
    
    @Override
    public void processPacket(Stanza stanza) {
	GameOfferPacket invitation = (GameOfferPacket) stanza;
	if (invitation.getType() == IQ.Type.get) {
	    showInvitationInChat(invitation);
	}
    }
};

SparkManager.getConnection().addAsyncStanzaListener(_gameofferListener,
	new StanzaTypeFilter(GameOfferPacket.class));

_chatRoomListener = new ChatRoomOpeningListener();

SparkManager.getChatManager().addChatRoomListener(_chatRoomListener);


   
   }