当前位置: 首页>>代码示例>>Java>>正文


Java ProviderManager类代码示例

本文整理汇总了Java中org.jivesoftware.smack.provider.ProviderManager的典型用法代码示例。如果您正苦于以下问题:Java ProviderManager类的具体用法?Java ProviderManager怎么用?Java ProviderManager使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


ProviderManager类属于org.jivesoftware.smack.provider包,在下文中一共展示了ProviderManager类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: XMPPConnector

import org.jivesoftware.smack.provider.ProviderManager; //导入依赖的package包/类
/**
 * 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.");
    }
}
 
开发者ID:Communote,项目名称:communote-server,代码行数:39,代码来源:XMPPConnector.java

示例2: XMPPWithIQProtocol

import org.jivesoftware.smack.provider.ProviderManager; //导入依赖的package包/类
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());
}
 
开发者ID:tokahuke,项目名称:java-for-playwrights,代码行数:18,代码来源:XMPPWithIQProtocol.java

示例3: init

import org.jivesoftware.smack.provider.ProviderManager; //导入依赖的package包/类
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;
}
 
开发者ID:cowthan,项目名称:AyoSunny,代码行数:20,代码来源:XmppConnectionManager.java

示例4: init

import org.jivesoftware.smack.provider.ProviderManager; //导入依赖的package包/类
/**
 * 初始化连接
 * @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;
}
 
开发者ID:jingshauizh,项目名称:androidsummary,代码行数:26,代码来源:XmppConnectionManager.java

示例5: initialize

import org.jivesoftware.smack.provider.ProviderManager; //导入依赖的package包/类
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;
    }
}
 
开发者ID:kontalk,项目名称:androidclient,代码行数:26,代码来源:SmackInitializer.java

示例6: configure

import org.jivesoftware.smack.provider.ProviderManager; //导入依赖的package包/类
@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);
}
 
开发者ID:snuk182,项目名称:aceim,代码行数:25,代码来源:XMPPService.java

示例7: enableJingle

import org.jivesoftware.smack.provider.ProviderManager; //导入依赖的package包/类
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);
           }
       });
}
 
开发者ID:bejayoharen,项目名称:java-bells,代码行数:17,代码来源:JingleManager.java

示例8: initConnect

import org.jivesoftware.smack.provider.ProviderManager; //导入依赖的package包/类
/**
 * 通过主机名和端口号去对服务器进行连接和一些初始化
 */
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();
        }
    }
}
 
开发者ID:polyvi,项目名称:openxface-android,代码行数:24,代码来源:XConnectionManager.java

示例9: initializeSession

import org.jivesoftware.smack.provider.ProviderManager; //导入依赖的package包/类
/**
 * 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());
}
 
开发者ID:visit,项目名称:spark-svn-mirror,代码行数:23,代码来源:SessionManager.java

示例10: shutdown

import org.jivesoftware.smack.provider.ProviderManager; //导入依赖的package包/类
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);
    }
 
开发者ID:visit,项目名称:spark-svn-mirror,代码行数:25,代码来源:ReversiPlugin.java

示例11: connect

import org.jivesoftware.smack.provider.ProviderManager; //导入依赖的package包/类
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();
}
 
开发者ID:ukevgen,项目名称:BizareChat,代码行数:11,代码来源:QuickbloxGroupXmppConnection.java

示例12: initPrivateConnection

import org.jivesoftware.smack.provider.ProviderManager; //导入依赖的package包/类
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);
            });
}
 
开发者ID:ukevgen,项目名称:BizareChat,代码行数:32,代码来源:QuickbloxPrivateXmppConnection.java

示例13: CcsClient

import org.jivesoftware.smack.provider.ProviderManager; //导入依赖的package包/类
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);
				}
			});
}
 
开发者ID:carlosCharz,项目名称:fcmxmppserverv2,代码行数:13,代码来源:CcsClient.java

示例14: run

import org.jivesoftware.smack.provider.ProviderManager; //导入依赖的package包/类
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();
    }
}
 
开发者ID:daktak,项目名称:androidpn-client,代码行数:40,代码来源:XmppManager.java

示例15: CcsClient

import org.jivesoftware.smack.provider.ProviderManager; //导入依赖的package包/类
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;
				}
			});
}
 
开发者ID:carlosCharz,项目名称:fcmxmppserver,代码行数:14,代码来源:CcsClient.java


注:本文中的org.jivesoftware.smack.provider.ProviderManager类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。