Java 类org.jivesoftware.smack.provider.ProviderManager 实例源码

项目:java-for-playwrights    文件:XMPPWithIQProtocol.java   
public XMPPWithIQProtocol(String ipAddress, int port, String user,
        String password) throws XMPPException {

    // Connect:
    config = new ConnectionConfiguration(ipAddress, port);
    config.setSASLAuthenticationEnabled(false);
       config.setSecurityMode(SecurityMode.disabled);

       connection = new XMPPConnection(config);
       connection.connect();

       // Login:
       connection.login(user, password, "root");

       // Add IQ provider:
       ProviderManager.getInstance().addIQProvider("query", "iq:myOwn", new MyIQProvider());
}
项目:communote-server    文件:XMPPConnector.java   
/**
 * The constructor for the XMPP bot.
 *
 * @param host
 *            The server the bot should login.
 * @param port
 *            The hosts port.
 * @param login
 *            The bots login name.
 * @param password
 *            The bots login password.
 * @param resource
 *            The bots resource (i.e. Work or Home). Can be null.
 * @throws IllegalArgumentException
 *             Throws an {@link IllegalArgumentException} if some of the parameters are in an
 *             invalid format.
 */
public XMPPConnector(String host, String port, String login, String password, String resource)
        throws IllegalArgumentException {
    checkParameters(host, port, login, password, resource);
    int numericalPort = port == null ? DEFAULT_XMPP_PORT : Integer.parseInt(port);
    this.sender = login + "@" + host + "/" + resource;
    SmackConfiguration.DEBUG_ENABLED = Boolean.parseBoolean(ApplicationPropertyXmpp.DEBUG
            .getValue());
    ProviderManager.addExtensionProvider(AliasPacketExtension.ALIAS_ELEMENT_NAME,
            AliasPacketExtension.ALIAS_NAMESPACE, AliasPacketExtension.class);
    ConnectionConfiguration config = new ConnectionConfiguration(host, numericalPort);
    connection = new XMPPTCPConnection(config);
    connect(login, password, resource);
    sendPriorityPresence();
    if (connection.isConnected()) {
        LOG.info(ResourceBundleManager.instance().getText("xmpp.connection.started",
                Locale.ENGLISH));
        connection.addConnectionListener(new XMPPConnectionStatusLogger());
    } else {
        LOG.info("The XMPP connection wasn't established.");
    }
}
项目:AyoSunny    文件:XmppConnectionManager.java   
public XMPPConnection init() {
    Connection.DEBUG_ENABLED = false;
    ProviderManager pm = ProviderManager.getInstance();
    configure(pm);
    ConnectionConfiguration connectionConfig = new ConnectionConfiguration(Const.XMPP_HOST, Const.XMPP_PORT);
    // connectionConfig.setSASLAuthenticationEnabled(false);//
    // 不使用SASL验证,设置为false
    // connectionConfig
    // .setSecurityMode(ConnectionConfiguration.SecurityMode.enabled);
    // 允许自动连接
    connectionConfig.setReconnectionAllowed(true);
    // 允许登陆成功后更新在线状态
    connectionConfig.setSendPresence(true);

    // 收到好友邀请后manual表示需要经过同意,accept_all表示不经同意自动为好友
    Roster.setDefaultSubscriptionMode(Roster.SubscriptionMode.accept_all);
    XMPPConnection connection = new XMPPConnection(connectionConfig);
    return connection;
}
项目:androidsummary    文件:XmppConnectionManager.java   
/**
 * 初始化连接
 * @param loginConfig
 * @return
 */
public XMPPConnection init(IMConfig loginConfig) {
    Connection.DEBUG_ENABLED = false;
    ProviderManager pm = ProviderManager.getInstance();
    configure(pm);

    connectionConfig = new ConnectionConfiguration(
            loginConfig.getXmppHost(), loginConfig.getXmppPort(),
            loginConfig.getXmppServiceName());
    //connectionConfig.setSASLAuthenticationEnabled(false);// 不使用SASL验证,设置为false
    connectionConfig
            .setSecurityMode(ConnectionConfiguration.SecurityMode.enabled);
    // 允许自动连接
    connectionConfig.setReconnectionAllowed(false);
    // 允许登陆成功后更新在线状态
    connectionConfig.setSendPresence(true);
    // 收到好友邀请后manual表示需要经过同意,accept_all表示不经同意自动为好友
    Roster.setDefaultSubscriptionMode(Roster.SubscriptionMode.manual);
    connection = new XMPPConnection(connectionConfig);
    return connection;
}
项目:androidclient    文件:SmackInitializer.java   
public static void initialize(Context context) {
    if (!sInitialized) {
        disableSmackDefault();

        InputStream is = context.getResources().openRawResource(R.raw.service);
        ProviderManager.addLoader(new ProviderFileLoader(is));
        try {
            is.close();
        }
        catch (IOException ignored) {
        }

        // FIXME these got to be fixed somehow (VCard4 is not even used anymore)
        ProviderManager.addIQProvider(VCard4.ELEMENT_NAME, VCard4.NAMESPACE, new VCard4.Provider());
        ProviderManager.addIQProvider(ServerlistCommand.ELEMENT_NAME, ServerlistCommand.NAMESPACE, new ServerlistCommand.ResultProvider());

        // do not append Smack version
        VersionManager.setAutoAppendSmackVersion(false);

        // we want to manually handle roster stuff
        Roster.setDefaultSubscriptionMode(Roster.SubscriptionMode.manual);

        sInitialized = true;
    }
}
项目:aceim    文件:XMPPService.java   
@Override
public void configure(ProviderManager pm) throws RemoteException {
    super.configure(pm);

    String pgpKey = getCoreService().requestPreference(ResourceUtils.KEY_PRIVATEKEY_FILE);
    String pgpKeyPassword = getCoreService().requestPreference(ResourceUtils.KEY_PRIVATEKEY_PASSWORD);

    EncryptedDataProvider edProvider;
    if (pgpKey != null && pgpKeyPassword != null){
        edProvider = new EncryptedDataProvider();
        edProvider.setMyKey(pgpKey);
        edProvider.setMyKeyPw(pgpKeyPassword);
        pm.addExtensionProvider("x", "jabber:x:signed", edProvider);
        pm.addExtensionProvider("x", "jabber:x:encrypted", edProvider);     

        Security.addProvider(edProvider.getProvider());         
    } else {
        edProvider = null;
        pm.removeExtensionProvider("x", "jabber:x:signed");
        pm.removeExtensionProvider("x", "jabber:x:encrypted");
    }

    ((XMPPCryptoEntityAdapter)getEntityAdapter()).setEdProvider(edProvider);
}
项目:java-bells    文件:JingleManager.java   
public static synchronized final void enableJingle() {
    if( enabled )
        return;
    enabled = true;
       ProviderManager providerManager = ProviderManager.getInstance();
       providerManager.addIQProvider( JingleIQ.ELEMENT_NAME,
               JingleIQ.NAMESPACE,
               new JingleIQProvider());

       Connection.addConnectionCreationListener(new ConnectionCreationListener() {
           public synchronized void connectionCreated(Connection connection) {
            if( ! ServiceDiscoveryManager.getInstanceFor(connection).includesFeature(JingleIQ.NAMESPACE) )
                ServiceDiscoveryManager.getInstanceFor(connection).addFeature(JingleIQ.NAMESPACE);
           }
       });
}
项目:openxface-android    文件:XConnectionManager.java   
/**
 * 通过主机名和端口号去对服务器进行连接和一些初始化
 */
private void initConnect() {
    if (!isConnected()) {
        String connectionHost = mNotificationService.getHost();
        int connectionPort = Integer.parseInt(mNotificationService
                .getPort());
        ConnectionConfiguration connConfig = new ConnectionConfiguration(
                connectionHost, connectionPort);
        connConfig.setSecurityMode(SecurityMode.required);
        connConfig.setSASLAuthenticationEnabled(false);
        connConfig.setCompressionEnabled(false);
        mConnection = new XMPPConnection(connConfig);
        try {
            mConnection.connect();
            ProviderManager.getInstance().addIQProvider(ELEMENT_NAME,
                    NAME_SPACE, new NotificationIQProvider());
        } catch (XMPPException e) {
            startReconnection();
        }
    }
}
项目:spark-svn-mirror    文件:SessionManager.java   
/**
 * Initializes session.
 *
 * @param connection the XMPPConnection used in this session.
 * @param username   the agents username.
 * @param password   the agents password.
 */
public void initializeSession(XMPPConnection connection, String username, String password) {
    this.connection = connection;
    this.username = username;
    this.password = password;
    this.userBareAddress = StringUtils.parseBareAddress(connection.getUser());

    // create workgroup session
    personalDataManager = new PrivateDataManager(getConnection());

    // Discover items
    discoverItems();


    ProviderManager.getInstance().addExtensionProvider("event", "http://jabber.org/protocol/disco#info", new Features.Provider());
}
项目:spark-svn-mirror    文件:ReversiPlugin.java   
public void shutdown() {
        // Remove Reversi button from chat toolbar.
        removeToolbarButton();
        // Remove IQ listener
        SparkManager.getConnection().removePacketListener(gameOfferListener);
//
//        // See if there are any pending offers or invitations. If so, cancel
//        // them.
//        for (Iterator<String> i = gameOffers.keySet().iterator(); i.hasNext();i.next()) {
//          System.out.println("gameoffer");
//
//        }
//        System.out.println(gameInvitations.size());
//        for (Iterator<String> i = gameInvitations.keySet().iterator(); i.hasNext(); i.next()) {
//          
//        }
        gameOffers.clear();
        gameInvitations.clear();

        // Remove Smack providers.
        ProviderManager.getInstance().removeIQProvider(GameOffer.ELEMENT_NAME, GameOffer.NAMESPACE);
        ProviderManager.getInstance().removeExtensionProvider(GameMove.ELEMENT_NAME, GameMove.NAMESPACE);
        ProviderManager.getInstance().removeExtensionProvider(GameForfeit.ELEMENT_NAME, GameForfeit.NAMESPACE);
    }
项目:BizareChat    文件:QuickbloxGroupXmppConnection.java   
public void connect() throws IOException, XMPPException, SmackException {
    ProviderManager.addExtensionProvider(ReadReceipt.ELEMENT, ReadReceipt.NAMESPACE, new ReadReceipt.Provider());
    receiptReceivedListener = (fromJid, toJid, receiptId, receipt) -> {
        // TODO Handle read event
    };
    ReadReceiptManager.getInstanceFor(groupChatConnection).addReadReceivedListener(receiptReceivedListener);
    initGroupConnection();
    groupChatConnection.connect();
    groupChatConnection.login();
}
项目:BizareChat    文件:QuickbloxPrivateXmppConnection.java   
private void initPrivateConnection() {
    long currentUserId = CurrentUser.getInstance().getCurrentUserId();
    String currentUserPassword = CurrentUser.getInstance().getCurrentPassword();
    String userName = currentUserId + "-" + ApiConstants.APP_ID;
    XMPPTCPConnectionConfiguration.Builder configBuilder = XMPPTCPConnectionConfiguration.builder();
    configBuilder.setUsernameAndPassword(userName, currentUserPassword);
    configBuilder.setSecurityMode(ConnectionConfiguration.SecurityMode.disabled);
    configBuilder.setServiceName(ApiConstants.CHAT_END_POINT);
    configBuilder.setHost(ApiConstants.CHAT_END_POINT);
    configBuilder.setDebuggerEnabled(true);

    privateChatConnection = new XMPPTCPConnection(configBuilder.build());
    privateChatConnection.addConnectionListener(this);

    ReconnectionManager manager = ReconnectionManager.getInstanceFor(privateChatConnection);
    manager.enableAutomaticReconnection();
    manager.setReconnectionPolicy(ReconnectionManager.ReconnectionPolicy.FIXED_DELAY);
    manager.setFixedDelay(15);

    ProviderManager.addExtensionProvider(Displayed.ELEMENT, Displayed.NAMESPACE, new Displayed.Provider());
    DisplayedManager.getInstanceFor(privateChatConnection).addDisplayedListener(
            (fromJid, toJid, receiptId, receipt) -> {
                messageService.get().processDisplayed(fromJid, toJid, receiptId, receipt);
            });

    ProviderManager.addExtensionProvider(Received.ELEMENT, Received.NAMESPACE, new Received.Provider());
    ReceivedManager.getInstanceFor(privateChatConnection).addReceivedListener(
            (fromJid, toJid, receiptId, receipt) -> {
                messageService.get().processReceived(fromJid, toJid, receiptId, receipt);
            });
}
项目:fcmxmppserverv2    文件:CcsClient.java   
private CcsClient() {
    // Add FCMPacketExtension
    ProviderManager.addExtensionProvider(Util.FCM_ELEMENT_NAME, Util.FCM_NAMESPACE,
            new ExtensionElementProvider<FcmPacketExtension>() {
                @Override
                public FcmPacketExtension parse(XmlPullParser parser, int initialDepth) 
                        throws XmlPullParserException, IOException, SmackException {
                    final String json = parser.nextText();
                    return new FcmPacketExtension(json);
                }
            });
}
项目:androidpn-client    文件:XmppManager.java   
public void run() {
    Log.i(LOGTAG, "ConnectTask.run()...");
    boolean connected = false;
    if (!xmppManager.isConnected()) {
        // Create the configuration for this new connection
        ConnectionConfiguration connConfig = new ConnectionConfiguration(
                xmppHost, xmppPort);
        // connConfig.setSecurityMode(SecurityMode.disabled);
        connConfig.setSecurityMode(SecurityMode.required);
        connConfig.setSASLAuthenticationEnabled(false);
        connConfig.setCompressionEnabled(false);

        XMPPConnection connection = new XMPPConnection(connConfig);
        xmppManager.setConnection(connection);

        try {
            // Connect to the server
            connection.connect();
            Log.i(LOGTAG, "XMPP connected successfully");

            // packet provider
            ProviderManager.getInstance().addIQProvider("notification",
                    "androidpn:iq:notification",
                    new NotificationIQProvider());
            connected = true;

        } catch (XMPPException e) {
            Log.e(LOGTAG, "XMPP connection failed", e);
        }

        if (connected) {
            xmppManager.runTask();
        }

    } else {
        Log.i(LOGTAG, "XMPP connected already");
        xmppManager.runTask();
    }
}
项目:fcmxmppserver    文件:CcsClient.java   
private CcsClient() {
    // Add FcmPacketExtension
    ProviderManager.getInstance().addExtensionProvider(Util.FCM_ELEMENT_NAME, Util.FCM_NAMESPACE,
            new PacketExtensionProvider() {

                @Override
                public PacketExtension parseExtension(XmlPullParser parser) throws Exception {
                    String json = parser.nextText();
                    FcmPacketExtension packet = new FcmPacketExtension(json);
                    return packet;
                }
            });
}
项目:Smack    文件:PacketParserUtils.java   
/**
 * Parses an extension element.
 *
 * @param elementName the XML element name of the extension element.
 * @param namespace the XML namespace of the stanza(/packet) extension.
 * @param parser the XML parser, positioned at the starting element of the extension.
 * @return an extension element.
 */
public static ExtensionElement parseExtensionElement(String elementName, String namespace,
                XmlPullParser parser) throws XmlPullParserException,
                IOException, SmackException {
    ParserUtils.assertAtStartTag(parser);
    // See if a provider is registered to handle the extension.
    ExtensionElementProvider<ExtensionElement> provider = ProviderManager.getExtensionProvider(elementName, namespace);
    if (provider != null) {
            return provider.parse(parser);
    }

    final int initialDepth = parser.getDepth();
    // No providers registered, so use a default extension.
    DefaultExtensionElement extension = new DefaultExtensionElement(elementName, namespace);
    outerloop: while (true) {
        int eventType = parser.next();
        switch (eventType) {
        case XmlPullParser.START_TAG:
            String name = parser.getName();
            // If an empty element, set the value with the empty string.
            if (parser.isEmptyElementTag()) {
                extension.setValue(name,"");
            }
            // Otherwise, get the the element text.
            else {
                eventType = parser.next();
                if (eventType == XmlPullParser.TEXT) {
                    String value = parser.getText();
                    extension.setValue(name, value);
                }
            }
            break;
        case XmlPullParser.END_TAG:
            if (parser.getDepth() == initialDepth) {
                break outerloop;
            }
        }
    }
    return extension;
}
项目:Smack    文件:ItemProvider.java   
@Override
public Item parse(XmlPullParser parser, int initialDepth)
                throws XmlPullParserException, IOException, SmackException {
    String id = parser.getAttributeValue(null, "id");
    String node = parser.getAttributeValue(null, "node");

    int tag = parser.next();

    if (tag == XmlPullParser.END_TAG) 
    {
        return new Item(id, node);
    }
    else 
    {
        String payloadElemName = parser.getName();
        String payloadNS = parser.getNamespace();

        final ExtensionElementProvider<ExtensionElement> extensionProvider = ProviderManager.getExtensionProvider(payloadElemName, payloadNS);
        if (extensionProvider == null)
        {
            CharSequence payloadText = PacketParserUtils.parseElement(parser, true);
            return new PayloadItem<SimplePayload>(id, node, new SimplePayload(payloadElemName, payloadNS, payloadText));
        }
        else 
        {
            return new PayloadItem<ExtensionElement>(id, node, extensionProvider.parse(parser));
        }
    }
}
项目:Smack    文件:JingleManager.java   
/**
 * 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() {
        public void connectionCreated(XMPPConnection connection) {
            JingleManager.setServiceEnabled(connection, true);
        }
    });
}
项目:EIM    文件:ItemProvider.java   
public PacketExtension parseExtension(XmlPullParser parser) throws Exception
{
    String id = parser.getAttributeValue(null, "id");
    String elem = parser.getName();

    int tag = parser.next();

    if (tag == XmlPullParser.END_TAG)
    {
        return new Item(id);        
    }
    else
    {
        String payloadElemName = parser.getName();
        String payloadNS = parser.getNamespace();

        if (ProviderManager.getInstance().getExtensionProvider(payloadElemName, payloadNS) == null)
        {
            boolean done = false;
            StringBuilder payloadText = new StringBuilder();

            while (!done)
            {
                if (tag == XmlPullParser.END_TAG && parser.getName().equals(elem))
                    done = true;
                else if (!((tag == XmlPullParser.START_TAG) && parser.isEmptyElementTag()))
                    payloadText.append(parser.getText());

                if (!done)
                    tag = parser.next();
            }
            return new PayloadItem<SimplePayload>(id, new SimplePayload(payloadElemName, payloadNS, payloadText.toString()));
        }
        else
        {
            return new PayloadItem<PacketExtension>(id, PacketParserUtils.parsePacketExtension(payloadElemName, payloadNS, parser));
        }
    }
}
项目:EIM    文件:XmppConnectionManager.java   
public XMPPConnection init(LoginConfig loginConfig) {

        Connection.DEBUG_ENABLED = false;
        ProviderManager pm = ProviderManager.getInstance();
        configure(pm);
        connectionConfig = new ConnectionConfiguration(
                loginConfig.getXmppHost(), loginConfig.getXmppPort(),
                loginConfig.getXmppServiceName());
         try {
            Class.forName("org.jivesoftware.smackx.ServiceDiscoveryManager", true, XmppConnectionManager.class.getClassLoader());
        } catch (ClassNotFoundException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
    /// ServiceDiscoveryManager discoManager = new ServiceDiscoveryManager(connection);
        connectionConfig.setSASLAuthenticationEnabled(false);// ��ʹ��SASL��֤������Ϊfalse
        connectionConfig
                .setSecurityMode(ConnectionConfiguration.SecurityMode.enabled);
        // �����Զ�����
        connectionConfig.setReconnectionAllowed(false);
        // �����½�ɹ����������״̬
        connectionConfig.setSendPresence(true);
        // connectionConfig.setSendPresence(false);
        // �յ����������manual��ʾ��Ҫ����ͬ��,accept_all��ʾ����ͬ���Զ�Ϊ����
        Roster.setDefaultSubscriptionMode(Roster.SubscriptionMode.manual);
        connection = new XMPPConnection(connectionConfig);
        return connection;
    }
项目:MessagePushClient    文件:XmppManager.java   
public void run() {
    Log.i(LOGTAG, "ConnectTask.run()...");

    if (!xmppManager.isConnected()) {
        // Create the configuration for this new connection
        ConnectionConfiguration connConfig = new ConnectionConfiguration(
                xmppHost, xmppPort);
        // connConfig.setSecurityMode(SecurityMode.disabled);
        connConfig.setSecurityMode(SecurityMode.required);
        connConfig.setSASLAuthenticationEnabled(false);
        connConfig.setCompressionEnabled(false);

        XMPPConnection connection = new XMPPConnection(connConfig);
        xmppManager.setConnection(connection);

        try {
            // Connect to the server
            connection.connect();
            Log.i(LOGTAG, "XMPP connected successfully");

            // packet provider
            ProviderManager.getInstance().addIQProvider("notification",
                    "androidpn:iq:notification",
                    new NotificationIQProvider());

        } catch (XMPPException e) {
            Log.e(LOGTAG, "XMPP connection failed", e);
        }

        xmppManager.runTask();

    } else {
        Log.i(LOGTAG, "XMPP connected already");
        xmppManager.runTask();
    }
}
项目:androidpn_enhanced_client    文件:XmppManager.java   
public void run() {
    Log.i(LOGTAG, "ConnectTask.run()...");

    if (!xmppManager.isConnected()) {
        // Create the configuration for this new connection
        ConnectionConfiguration connConfig = new ConnectionConfiguration(
                xmppHost, xmppPort);
        // connConfig.setSecurityMode(SecurityMode.disabled);
        connConfig.setSecurityMode(SecurityMode.required);
        connConfig.setSASLAuthenticationEnabled(false);
        connConfig.setCompressionEnabled(false);

        XMPPConnection connection = new XMPPConnection(connConfig);
        xmppManager.setConnection(connection);

        try {
            // Connect to the server
            connection.connect();
            Log.i(LOGTAG, "XMPP connected successfully");

            // packet provider
            ProviderManager.getInstance().addIQProvider("notification",
                    "androidpn:iq:notification",
                    new NotificationIQProvider());
            xmppManager.runTask();
        } catch (XMPPException e) {
            Log.e(LOGTAG, "XMPP connection failed", e);
            xmppManager.dropTask(2);
            xmppManager.startReconnectionThread();
            xmppManager.runTask();
        }
    } else {
        Log.i(LOGTAG, "XMPP connected already");
        xmppManager.runTask();
    }
}
项目:ShoppingMall    文件:XmppManager.java   
public void run() {

            if (!xmppManager.isConnected()) {
                // Create the configuration for this new connection
                ConnectionConfiguration connConfig = new ConnectionConfiguration(xmppHost, xmppPort);
                // connConfig.setSecurityMode(SecurityMode.disabled);
                // connConfig.setSecurityMode(SecurityMode.required);
                connConfig.setSASLAuthenticationEnabled(false);
                connConfig.setCompressionEnabled(false);
                connConfig.setSecurityMode(SecurityMode.disabled);

                XMPPConnection connection = new XMPPConnection(connConfig);
                xmppManager.setConnection(connection);

                try {
                    // Connect to the server
                    connection.connect();

                    // packet provider
                    ProviderManager.getInstance().addIQProvider("notification", "androidpn:iq:notification", new NotificationIQProvider());
                    reconnection.waiting = 0;
                    reconnection.needWork.set(false);
                } catch (XMPPException e) {
                    e.printStackTrace();
                }

                xmppManager.runTask();

            } else {
                xmppManager.runTask();
            }
        }
项目:FastOmiai    文件:XmppManager.java   
public void run() {
    Log.i(LOGTAG, "ConnectTask.run()...");

    if (!xmppManager.isConnected()) {
        // Create the configuration for this new connection
        ConnectionConfiguration connConfig = new ConnectionConfiguration(
                xmppHost, xmppPort);
        // connConfig.setSecurityMode(SecurityMode.disabled);
        connConfig.setSecurityMode(SecurityMode.required);
        connConfig.setSASLAuthenticationEnabled(false);
        connConfig.setCompressionEnabled(false);

        XMPPConnection connection = new XMPPConnection(connConfig);
        xmppManager.setConnection(connection);

        try {
            // Connect to the server
            connection.connect();
            Log.i(LOGTAG, "XMPP connected successfully");

            // packet provider
            ProviderManager.getInstance().addIQProvider("notification",
                    "androidpn:iq:notification",
                    new NotificationIQProvider());

        } catch (XMPPException e) {
            Log.e(LOGTAG, "XMPP connection failed", e);
        }

        xmppManager.runTask();

    } else {
        Log.i(LOGTAG, "XMPP connected already");
        xmppManager.runTask();
    }
}
项目:XmppTest    文件:SmackImpl.java   
static void registerSmackProviders() {
    ProviderManager pm = ProviderManager.getInstance();
    // add IQ handling
    pm.addIQProvider("query", "http://jabber.org/protocol/disco#info",
            new DiscoverInfoProvider());
    // add delayed delivery notifications
    pm.addExtensionProvider("delay", "urn:xmpp:delay",
            new DelayInfoProvider());
    pm.addExtensionProvider("x", "jabber:x:delay", new DelayInfoProvider());
    // add carbons and forwarding
    pm.addExtensionProvider("forwarded", Forwarded.NAMESPACE,
            new Forwarded.Provider());
    pm.addExtensionProvider("sent", Carbon.NAMESPACE, new Carbon.Provider());
    pm.addExtensionProvider("received", Carbon.NAMESPACE,
            new Carbon.Provider());
    // add delivery receipts
    pm.addExtensionProvider(DeliveryReceipt.ELEMENT,
            DeliveryReceipt.NAMESPACE, new DeliveryReceipt.Provider());
    pm.addExtensionProvider(DeliveryReceiptRequest.ELEMENT,
            DeliveryReceipt.NAMESPACE,
            new DeliveryReceiptRequest.Provider());
    // add XMPP Ping (XEP-0199)
    pm.addIQProvider("ping", "urn:xmpp:ping", new PingProvider());

    ServiceDiscoveryManager.setIdentityName(XMPP_IDENTITY_NAME);
    ServiceDiscoveryManager.setIdentityType(XMPP_IDENTITY_TYPE);
}
项目:Zom-Android    文件:XmppStreamHandler.java   
private static void addSimplePacketExtension(final String name, final String namespace) {
    ProviderManager.addExtensionProvider(name, namespace,
            new DataPacketProvider.PacketExtensionProvider() {
                public Stanza parseExtension(XmlPullParser parser) throws Exception {
                    StreamHandlingPacket packet = new StreamHandlingPacket(name, namespace);
                    int attributeCount = parser.getAttributeCount();
                    for (int i = 0; i < attributeCount; i++) {
                        packet.addAttribute(parser.getAttributeName(i),
                                parser.getAttributeValue(i));
                    }
                    return packet;
                }
            });
}
项目:olat    文件:RemoteGroupCreationOverXMPP.java   
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());
    }
项目:olat    文件:RemoteAccountCreationOverXMPP.java   
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());

}
项目:olat    文件:RemoteGroupCreationOverXMPP.java   
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());
    }
项目:olat    文件:RemoteAccountCreationOverXMPP.java   
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());

}
项目:androidclient    文件:SmackInitializer.java   
/**
 * Initializes Smack for registration.
 */
public static void initializeRegistration() {
    disableSmackDefault();
    // not moving these into configuration since they are not loaded often
    ProviderManager.addIQProvider("query", "jabber:iq:register", new RegistrationProvider());
    ProviderManager.addExtensionProvider("x", "jabber:x:data", new DataFormProvider());
    ProviderManager.addExtensionProvider(Account.ELEMENT_NAME, Account.NAMESPACE, new Account.Provider());
}
项目:android_chat    文件:ThreadHelper.java   
/**
 * XMPP
 * @throws XMPPException 
 */
public void xmppConnect() throws XMPPException {
    if (!(ThreadHelper.xmppConnection == null) &&
            ThreadHelper.xmppConnection.isConnected()) return;
    // Set configuration parameter
    Roster.setDefaultSubscriptionMode(Roster.SubscriptionMode.manual);
    ConnectionConfiguration config = new ConnectionConfiguration(HOST, PORT);
    config.setSASLAuthenticationEnabled(false);
    configure(ProviderManager.getInstance());
    ThreadHelper.xmppConnection = new XMPPConnection(config);
    ThreadHelper.xmppConnection.connect();
}
项目:msf-spaces-sdk-android    文件:ProviderInitializer.java   
/**
 * Adds all IQProvider to the ProviderManager so receiving datapackages will be parsed correctly.
 */
public static void initializeProviderManager(){
       /* These rows creates the provider manager that handles different extensions for XMPP
        * basically this tells smack how to handle different XML objects.
        */
       ProviderManager pm = ProviderManager.getInstance();
    pm.addIQProvider("spaces", NamespaceConfig.SPACES_SERVICE, new SpacesProvider());
       pm.addIQProvider("pubsub", NamespaceConfig.XMPP_PUBSUB, new PubSubProvider());
       pm.addIQProvider("pubsub", NamespaceConfig.XMPP_PUBSUB + "#owner", new PubSubProvider());
       pm.addExtensionProvider("subscription", NamespaceConfig.XMPP_PUBSUB, new SubscriptionProvider());
       pm.addExtensionProvider("subscriptions", NamespaceConfig.XMPP_PUBSUB, new SubscriptionsProvider());
       pm.addExtensionProvider("subscriptions", NamespaceConfig.XMPP_PUBSUB + "#owner", new SubscriptionsProvider());
       pm.addExtensionProvider("affiliations", NamespaceConfig.XMPP_PUBSUB, new AffiliationsProvider());
       pm.addExtensionProvider("affiliation", NamespaceConfig.XMPP_PUBSUB, new AffiliationProvider());
       pm.addExtensionProvider("options", NamespaceConfig.XMPP_PUBSUB, new FormNodeProvider());
       pm.addExtensionProvider("options", NamespaceConfig.XMPP_PUBSUB + "#event", new FormNodeProvider());
       pm.addExtensionProvider("configure", NamespaceConfig.XMPP_PUBSUB + "#owner", new FormNodeProvider());
       pm.addExtensionProvider("default", NamespaceConfig.XMPP_PUBSUB + "#owner", new FormNodeProvider());
       pm.addExtensionProvider("event", NamespaceConfig.XMPP_PUBSUB + "#event", new EventProvider());
       pm.addExtensionProvider("configuration", NamespaceConfig.XMPP_PUBSUB + "#event", new ConfigEventProvider());
       pm.addExtensionProvider("delete", NamespaceConfig.XMPP_PUBSUB + "#event", new SimpleNodeProvider());
       pm.addExtensionProvider("create", NamespaceConfig.XMPP_PUBSUB, new SimpleNodeProvider());
       pm.addExtensionProvider("retract", NamespaceConfig.XMPP_PUBSUB + "#event", new RetractEventProvider());
       pm.addExtensionProvider("purge", NamespaceConfig.XMPP_PUBSUB + "#event", new SimpleNodeProvider());
       pm.addExtensionProvider("items", NamespaceConfig.XMPP_PUBSUB, new ItemsProvider());
       pm.addExtensionProvider("items", NamespaceConfig.XMPP_PUBSUB + "#event", new ItemsProvider());
       pm.addExtensionProvider("item", NamespaceConfig.XMPP_PUBSUB, new ItemProvider());
       pm.addExtensionProvider("item", NamespaceConfig.XMPP_PUBSUB + "#event", new ItemProvider());
       pm.addExtensionProvider("item", "", new ItemProvider());

       pm.addExtensionProvider("headers", "http://jabber.org/protocol/shim", new HeadersProvider());
       pm.addExtensionProvider("header", "http://jabber.org/protocol/shim", new HeaderProvider());

       pm.addExtensionProvider("x", "jabber:x:data", new DataFormProvider());

       pm.addIQProvider("query", "http://jabber.org/protocol/disco#items", new DiscoverItemsProvider());
       pm.addIQProvider("query", "http://jabber.org/protocol/disco#info", new DiscoverInfoProvider());
       pm.addIQProvider("query", NamespaceConfig.PERSISTENCE_SERVICE, new PersistenceServiceQueryProvider());
       pm.addIQProvider("delete", NamespaceConfig.PERSISTENCE_SERVICE, new PersistenceServiceDeleteProvider());
}
项目:Androidpn    文件:XmppManager.java   
public void run() {
    Log.i(LOGTAG, "ConnectTask.run()...");

    if (!xmppManager.isConnected()) {
        // Create the configuration for this new connection
        ConnectionConfiguration connConfig = new ConnectionConfiguration(
                xmppHost, xmppPort);
        // connConfig.setSecurityMode(SecurityMode.disabled);
        connConfig.setSecurityMode(SecurityMode.required);
        connConfig.setSASLAuthenticationEnabled(false);
        connConfig.setCompressionEnabled(false);

        XMPPConnection connection = new XMPPConnection(connConfig);
        xmppManager.setConnection(connection);

        try {
            // Connect to the server
            connection.connect();
            Log.i(LOGTAG, "XMPP connected successfully");

            // packet provider
            ProviderManager.getInstance().addIQProvider("notification",
                    "androidpn:iq:notification",
                    new NotificationIQProvider());

        } catch (XMPPException e) {
            Log.e(LOGTAG, "XMPP connection failed", e);
        }

        xmppManager.runTask();

    } else {
        Log.i(LOGTAG, "XMPP connected already");
        xmppManager.runTask();
    }
}
项目:Androidpn    文件:XmppManager.java   
public void run() {
    Log.i(LOGTAG, "ConnectTask.run()...");

    if (!XmppManager.isConnected(xmppManager)) {

        // Create the configuration for this new connection
        ConnectionConfiguration connConfig = new ConnectionConfiguration(
                xmppHost, xmppPort);
        connConfig.setSecurityMode(SecurityMode.disabled);
        connConfig.setSASLAuthenticationEnabled(false);
        connConfig.setCompressionEnabled(false);

        XMPPConnection connection = new XMPPConnection(connConfig);
        XmppManager.setXMPPConnection(xmppManager, connection);

        try {
            // Connect to the server
            connection.connect();
            Log.i(LOGTAG, "XMPP connected successfully");

            // packet provider
            ProviderManager.getInstance().addIQProvider("notification",
                    "androidpn:iq:notification",
                    new NotificationProvider());

        } catch (XMPPException e) {
            Log.e(LOGTAG, "XMPP connection failed", e);
        }

        XmppManager.runTask(xmppManager);

    } else {
        Log.i(LOGTAG, "XMPP connected already");
        XmppManager.runTask(xmppManager);
    }

}
项目:Androidpn    文件:XmppManager.java   
public void run() {
    Log.i(LOGTAG, "ConnectTask.run()...");

    if (!xmppManager.isConnected()) {
        // Create the configuration for this new connection
        ConnectionConfiguration connConfig = new ConnectionConfiguration(
                xmppHost, xmppPort);
        connConfig.setSecurityMode(SecurityMode.disabled);
        connConfig.setSASLAuthenticationEnabled(false);
        connConfig.setCompressionEnabled(false);

        XMPPConnection connection = new XMPPConnection(connConfig);
        xmppManager.setConnection(connection);

        try {
            // Connect to the server
            connection.connect();
            Log.i(LOGTAG, "XMPP connected successfully");

            // packet provider
            ProviderManager.getInstance().addIQProvider("notification",
                    "androidpn:iq:notification",
                    new NotificationIQProvider());

        } catch (XMPPException e) {
            Log.e(LOGTAG, "XMPP connection failed", e);
        }

        xmppManager.runTask();

    } else {
        Log.i(LOGTAG, "XMPP connected already");
        xmppManager.runTask();
    }
}
项目:Androidpn    文件:XmppManager.java   
public void run() {
    Log.i(LOGTAG, "ConnectTask.run()...");

    if (!XmppManager.isConnected(xmppManager)) {

        // Create the configuration for this new connection
        ConnectionConfiguration connConfig = new ConnectionConfiguration(
                xmppHost, xmppPort);
        connConfig.setSecurityMode(SecurityMode.disabled);
        connConfig.setSASLAuthenticationEnabled(false);
        connConfig.setCompressionEnabled(false);

        XMPPConnection connection = new XMPPConnection(connConfig);
        XmppManager.setXMPPConnection(xmppManager, connection);

        try {
            // Connect to the server
            connection.connect();
            Log.i(LOGTAG, "XMPP connected successfully");

            // packet provider
            ProviderManager.getInstance().addIQProvider("notification",
                    "androidpn:iq:notification",
                    new NotificationProvider());

        } catch (XMPPException e) {
            Log.e(LOGTAG, "XMPP connection failed", e);
        }

        XmppManager.runTask(xmppManager);

    } else {
        Log.i(LOGTAG, "XMPP connected already");
        XmppManager.runTask(xmppManager);
    }

}
项目:Androidpn    文件:XmppManager.java   
public void run() {
    Log.i(LOGTAG, "ConnectTask.run()...");

    if (!XmppManager.isConnected(xmppManager)) {

        // Create the configuration for this new connection
        ConnectionConfiguration connConfig = new ConnectionConfiguration(
                xmppHost, xmppPort);
        connConfig.setSecurityMode(SecurityMode.disabled);
        connConfig.setSASLAuthenticationEnabled(false);
        connConfig.setCompressionEnabled(false);

        XMPPConnection connection = new XMPPConnection(connConfig);
        XmppManager.setXMPPConnection(xmppManager, connection);

        try {
            // Connect to the server
            connection.connect();
            Log.i(LOGTAG, "XMPP connected successfully");

            // packet provider
            ProviderManager.getInstance().addIQProvider("notification",
                    "androidpn:iq:notification",
                    new NotificationIQProvider());

        } catch (XMPPException e) {
            Log.e(LOGTAG, "XMPP connection failed", e);
        }

        XmppManager.runTask(xmppManager);

    } else {
        Log.i(LOGTAG, "XMPP connected already");
        XmppManager.runTask(xmppManager);
    }

}
项目:Androidpn    文件:XmppManager.java   
public void run() {
    Log.i(LOGTAG, "ConnectTask.run()...");

    if (!XmppManager.isConnected(xmppManager)) {

        // Create the configuration for this new connection
        ConnectionConfiguration connConfig = new ConnectionConfiguration(
                xmppHost, xmppPort);
        connConfig.setSecurityMode(SecurityMode.disabled);
        connConfig.setSASLAuthenticationEnabled(false);
        connConfig.setCompressionEnabled(false);

        XMPPConnection connection = new XMPPConnection(connConfig);
        XmppManager.setXMPPConnection(xmppManager, connection);

        try {
            // Connect to the server
            connection.connect();
            Log.i(LOGTAG, "XMPP connected successfully");

            // packet provider
            ProviderManager.getInstance().addIQProvider("notification",
                    "androidpn:iq:notification",
                    new NotificationProvider());

        } catch (XMPPException e) {
            Log.e(LOGTAG, "XMPP connection failed", e);
        }

        XmppManager.runTask(xmppManager);

    } else {
        Log.i(LOGTAG, "XMPP connected already");
        XmppManager.runTask(xmppManager);
    }

}
项目:Androidpn    文件:XmppManager.java   
public void run() {

            Log.i(LOGTAG, "ConnectTask.run()...");

            if (!XmppManager.isConnected(xmppManager)) {

                // Create the configuration for this new connection
                ConnectionConfiguration config = new ConnectionConfiguration(
                        xmppHost, xmppPort, "AndroidpnXmppClient");
                // config.setCompressionEnabled(true);
                // config.setSASLAuthenticationEnabled(true);

                XMPPConnection connection = new XMPPConnection(config);
                XmppManager.setXMPPConnection(xmppManager, connection);

                try {
                    // Connect to the server
                    connection.connect();
                    Log.i(LOGTAG, "XMPP connected successfully");

                    // packet provider
                    ProviderManager.getInstance().addIQProvider("registration",
                            "androidpn:iq:registration",
                            new RegistrationProvider());
                    ProviderManager.getInstance().addIQProvider("notification",
                            "androidpn:iq:notification",
                            new RegistrationProvider());

                } catch (XMPPException e) {
                    Log.e(LOGTAG, "XMPP connection failed", e);
                }

                XmppManager.runTask(xmppManager);

            } else {
                Log.i(LOGTAG, "XMPP connected already");
                XmppManager.runTask(xmppManager);
            }

        }