本文整理匯總了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.");
}
}
示例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());
}
示例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;
}
示例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;
}
示例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;
}
}
示例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);
}
示例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);
}
});
}
示例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();
}
}
}
示例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());
}
示例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);
}
示例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();
}
示例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);
});
}
示例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);
}
});
}
示例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();
}
}
示例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;
}
});
}