org.jivesoftware.smack.provider.ProviderManager Java Examples
The following examples show how to use
org.jivesoftware.smack.provider.ProviderManager.
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: SparkFileUploadPlugin.java From Spark with Apache License 2.0 | 6 votes |
public void shutdown() { try { Log.debug("shutdown"); chatManager.removeChatRoomListener(this); chatManager.removeGlobalMessageListener(this); ProviderManager.removeIQProvider("slot", UploadRequest.NAMESPACE); } catch(Exception e) { Log.warning("shutdown ", e); } }
Example #2
Source File: ReversiPlugin.java From Spark with Apache License 2.0 | 6 votes |
public void shutdown() { // Remove Reversi button from chat toolbar. removeToolbarButton(); // Remove IQ listener SparkManager.getConnection().removeAsyncStanzaListener(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.removeIQProvider(GameOffer.ELEMENT_NAME, GameOffer.NAMESPACE); ProviderManager.removeExtensionProvider(GameMove.ELEMENT_NAME, GameMove.NAMESPACE); ProviderManager.removeExtensionProvider(GameForfeit.ELEMENT_NAME, GameForfeit.NAMESPACE); }
Example #3
Source File: SessionManager.java From Spark with Apache License 2.0 | 6 votes |
/** * Initializes session. * * @param connection the XMPPConnection used in this session. * @param username the agents username. * @param password the agents password. */ public void initializeSession( AbstractXMPPConnection connection, String username, String password) { this.connection = connection; this.username = username; this.password = password; this.userBareAddress = connection.getUser().asEntityBareJid(); // create workgroup session personalDataManager = PrivateDataManager.getInstanceFor( getConnection() ); // Discover items discoverItems(); ProviderManager.addExtensionProvider("event", "http://jabber.org/protocol/disco#info", new Features.Provider()); }
Example #4
Source File: PresenceListener.java From desktopclient-java with GNU General Public License v3.0 | 5 votes |
public PresenceListener(Roster roster, RosterHandler handler) { mRoster = roster; mHandler = handler; ProviderManager.addExtensionProvider( PublicKeyPresence.ELEMENT_NAME, PublicKeyPresence.NAMESPACE, new PublicKeyPresence.Provider()); ProviderManager.addExtensionProvider( PresenceSignature.ELEMENT_NAME, PresenceSignature.NAMESPACE, new PresenceSignature.Provider()); }
Example #5
Source File: ProviderRegister.java From xyTalk-pc with GNU Affero General Public License v3.0 | 5 votes |
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 #6
Source File: ReferenceProvider.java From Smack with Apache License 2.0 | 5 votes |
@Override public ReferenceElement parse(XmlPullParser parser, int initialDepth, XmlEnvironment xmlEnvironment) throws XmlPullParserException, IOException, SmackParsingException { Integer begin = ParserUtils.getIntegerAttribute(parser, ReferenceElement.ATTR_BEGIN); Integer end = ParserUtils.getIntegerAttribute(parser, ReferenceElement.ATTR_END); String typeString = parser.getAttributeValue(null, ReferenceElement.ATTR_TYPE); ReferenceElement.Type type = ReferenceElement.Type.valueOf(typeString); String anchor = parser.getAttributeValue(null, ReferenceElement.ATTR_ANCHOR); String uriString = parser.getAttributeValue(null, ReferenceElement.ATTR_URI); URI uri; try { uri = uriString != null ? new URI(uriString) : null; } catch (URISyntaxException e) { // TODO: Should be SmackParseException and probably be factored into ParserUtils. throw new IOException(e); } ExtensionElement child = null; outerloop: while (true) { XmlPullParser.Event eventType = parser.next(); if (eventType == XmlPullParser.Event.START_ELEMENT) { String elementName = parser.getName(); String namespace = parser.getNamespace(); ExtensionElementProvider<?> provider = ProviderManager.getExtensionProvider(elementName, namespace); if (provider != null) { child = provider.parse(parser); } } else if (eventType == XmlPullParser.Event.END_ELEMENT) { break outerloop; } } return new ReferenceElement(begin, end, type, anchor, uri, child); }
Example #7
Source File: AbstractXMPPConnection.java From Smack with Apache License 2.0 | 5 votes |
protected final void parseAndProcessNonza(XmlPullParser parser) throws IOException, XmlPullParserException, SmackParsingException { ParserUtils.assertAtStartTag(parser); final int initialDepth = parser.getDepth(); final String element = parser.getName(); final String namespace = parser.getNamespace(); final QName key = new QName(namespace, element); NonzaProvider<? extends Nonza> nonzaProvider = ProviderManager.getNonzaProvider(key); if (nonzaProvider == null) { LOGGER.severe("Unknown nonza: " + key); ParserUtils.forwardToEndTagOfDepth(parser, initialDepth); return; } List<NonzaCallback> nonzaCallbacks; synchronized (nonzaCallbacksMap) { nonzaCallbacks = nonzaCallbacksMap.getAll(key); nonzaCallbacks = CollectionUtil.newListWith(nonzaCallbacks); } if (nonzaCallbacks == null) { LOGGER.info("No nonza callback for " + key); ParserUtils.forwardToEndTagOfDepth(parser, initialDepth); return; } Nonza nonza = nonzaProvider.parse(parser, incomingStreamXmlEnvironment); for (NonzaCallback nonzaCallback : nonzaCallbacks) { nonzaCallback.onNonzaReceived(nonza); } }
Example #8
Source File: ItemProvider.java From Smack with Apache License 2.0 | 5 votes |
@Override public Item parse(XmlPullParser parser, int initialDepth, XmlEnvironment xmlEnvironment) throws XmlPullParserException, IOException, SmackParsingException { String id = parser.getAttributeValue(null, "id"); String node = parser.getAttributeValue(null, "node"); String xmlns = parser.getNamespace(); ItemNamespace itemNamespace = ItemNamespace.fromXmlns(xmlns); XmlPullParser.Event tag = parser.next(); if (tag == XmlPullParser.Event.END_ELEMENT) { return new Item(itemNamespace, id, node); } else { String payloadElemName = parser.getName(); String payloadNS = parser.getNamespace(); final ExtensionElementProvider<ExtensionElement> extensionProvider = ProviderManager.getExtensionProvider(payloadElemName, payloadNS); if (extensionProvider == null) { // TODO: Should we use StandardExtensionElement in this case? And probably remove SimplePayload all together. CharSequence payloadText = PacketParserUtils.parseElement(parser, true); return new PayloadItem<>(itemNamespace, id, node, new SimplePayload(payloadText.toString())); } else { return new PayloadItem<>(itemNamespace, id, node, extensionProvider.parse(parser)); } } }
Example #9
Source File: MoodConcretisationTest.java From Smack with Apache License 2.0 | 5 votes |
@Test public void concretisationTest() throws Exception { ProviderManager.addExtensionProvider( EcstaticMoodConcretisation.ELEMENT, EcstaticMoodConcretisation.NAMESPACE, EcstaticMoodConcretisationProvider.INSTANCE); String xml = "<mood xmlns='http://jabber.org/protocol/mood'>" + "<happy>" + "<ecstatic xmlns='https://example.org/'/>" + "</happy>" + "<text>Yay, the mood spec has been approved!</text>" + "</mood>"; MoodElement element = new MoodElement( new MoodElement.MoodSubjectElement( Mood.happy, new EcstaticMoodConcretisation()), "Yay, the mood spec has been approved!"); assertXmlSimilar(xml, element.toXML().toString()); XmlPullParser parser = TestUtils.getParser(xml); MoodElement parsed = MoodProvider.INSTANCE.parse(parser); assertXmlSimilar(xml, parsed.toXML().toString()); assertTrue(parsed.hasConcretisation()); assertTrue(parsed.hasText()); assertEquals(EcstaticMoodConcretisation.ELEMENT, parsed.getMoodConcretisation().getMood()); }
Example #10
Source File: JingleManager.java From Smack with Apache License 2.0 | 5 votes |
/** * 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: MessengerService.java From KlyphMessenger with MIT License | 5 votes |
@Override public void onCreate() { Log.d(TAG, "onCreate"); if (instance != null) Log.d(TAG, "instance is already defined !"); instance = this; notificationsEnabled = MessengerPreferences.areNotificationsEnabled(); ringtone = MessengerPreferences.getNotificationRingtone(); ringtoneUri = MessengerPreferences.getNotificationRingtoneUri(); vibrateEnabled = MessengerPreferences.isNotificationVibrationEnabled(); chats = new ArrayList<Chat>(); roster = new ArrayList<PRosterEntry>(); savedMessages = new ArrayList<org.jivesoftware.smack.packet.Message>(); pendingActions = new LinkedHashMap<String, Object>(); configure(ProviderManager.getInstance()); Connection.addConnectionCreationListener(new ConnectionCreationListener() { public void connectionCreated(Connection connection) { reconnectionManager = new ReconnectionManager(connection, ConnectionState.getInstance(MessengerService.this).isOnline()); connection.addConnectionListener(reconnectionManager); } }); registerReceiver(new BroadcastReceiver() { public void onReceive(Context context, Intent intent) { Log.i(TAG, "Connection status change to " + ConnectionState.getInstance(MessengerService.this).isOnline()); onConnectivityChange(); } }, new IntentFilter("android.net.conn.CONNECTIVITY_CHANGE")); connect(); }
Example #12
Source File: XStreamExtensionProvider.java From saros with GNU General Public License v2.0 | 5 votes |
/** * 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 #13
Source File: CheckUpdates.java From Spark with Apache License 2.0 | 5 votes |
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 #14
Source File: ReversiPlugin.java From Spark with Apache License 2.0 | 5 votes |
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 #15
Source File: SparkFileUploadPlugin.java From Spark with Apache License 2.0 | 5 votes |
public void initialize() { ProviderManager.addIQProvider("slot", UploadRequest.NAMESPACE, new UploadRequest.Provider()); chatManager = SparkManager.getChatManager(); chatManager.addChatRoomListener(this); chatManager.addGlobalMessageListener(this); }
Example #16
Source File: TicTacToePlugin.java From Spark with Apache License 2.0 | 5 votes |
@Override public void initialize() { ClassLoader cl = getClass().getClassLoader(); buttonimg = new ImageIcon(cl.getResource("ttt.button.png")); _currentInvitations = new HashSet<>(); ProviderManager.addIQProvider(GameOfferPacket.ELEMENT_NAME, GameOfferPacket.NAMESPACE, new GameOfferPacket.Provider() ); ProviderManager.addExtensionProvider(MovePacket.ELEMENT_NAME, MovePacket.NAMESPACE, new MovePacket.Provider() ); ProviderManager.addExtensionProvider(InvalidMove.ELEMENT_NAME, InvalidMove.NAMESPACE, new InvalidMove.Provider() ); // Add IQ listener to listen for incoming game invitations. _gameOfferListener = new StanzaListener() { @Override public void processStanza(Stanza stanza) { GameOfferPacket invitation = (GameOfferPacket) stanza; if (invitation.getType() == IQ.Type.get) { showInvitationAlert(invitation); } } }; SparkManager.getConnection().addAsyncStanzaListener(_gameOfferListener, new StanzaTypeFilter(GameOfferPacket.class)); addButtonToToolBar(); }
Example #17
Source File: PhonePlugin.java From Spark with Apache License 2.0 | 5 votes |
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 #18
Source File: SmackGcmSenderChannel.java From arcusplatform with Apache License 2.0 | 5 votes |
public SmackGcmSenderChannel(String googleApiKey, Long googleSenderId, int keepAliveInterval, UpstreamNotificationResponder errorResponder) { this.errorResponder = errorResponder; upstreamListener = new SmackGcmUpstreamMessageListener(errorResponder); try { ProviderManager.addExtensionProvider(GcmServiceConstants.GCM_ELEMENT_NAME, GcmServiceConstants.GCM_NAMESPACE, new SmackGcmPacketExtensionProvider()); connect(googleSenderId, googleApiKey, keepAliveInterval); } catch (XMPPException | IOException | SmackException e) { // Nothing we can do about these... throw new RuntimeException(e); } }
Example #19
Source File: XmppManager.java From androidpn-client with Apache License 2.0 | 5 votes |
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(); } }
Example #20
Source File: RemoteGroupCreationOverXMPP.java From olat with Apache License 2.0 | 5 votes |
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 #21
Source File: RemoteAccountCreationOverXMPP.java From olat with Apache License 2.0 | 5 votes |
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 #22
Source File: RemoteAccountCreationOverXMPP.java From olat with Apache License 2.0 | 5 votes |
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 #23
Source File: RemoteGroupCreationOverXMPP.java From olat with Apache License 2.0 | 5 votes |
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 #24
Source File: RemoteSessionCountOverXMPP.java From olat with Apache License 2.0 | 4 votes |
RemoteSessionCountOverXMPP() { // register IQ handler final ProviderManager providerMgr = ProviderManager.getInstance(); providerMgr.addIQProvider("query", SessionCount.NAMESPACE, new SessionCount.Provider()); }
Example #25
Source File: XMPPSession.java From mangosta-android with Apache License 2.0 | 4 votes |
private void addExtensions() { // Microblogging ProviderManager.addExtensionProvider(PostEntryExtension.ELEMENT, PostEntryExtension.NAMESPACE, new PostEntryProvider()); }
Example #26
Source File: SoftPhoneManager.java From Spark with Apache License 2.0 | 4 votes |
/** * 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 #27
Source File: XSCHelper.java From PracticeCode with Apache License 2.0 | 4 votes |
private XSCHelper() { //配置Provider,如不配置则无法解析数据 configureConnection(ProviderManager.getInstance()); }
Example #28
Source File: RemoteSessionCountOverXMPP.java From olat with Apache License 2.0 | 4 votes |
RemoteSessionCountOverXMPP() { // register IQ handler final ProviderManager providerMgr = ProviderManager.getInstance(); providerMgr.addIQProvider("query", SessionCount.NAMESPACE, new SessionCount.Provider()); }
Example #29
Source File: VCardManager.java From Spark with Apache License 2.0 | 4 votes |
/** * Initialize VCardManager. */ public VCardManager() { // Register providers ProviderManager.addExtensionProvider( JabberAvatarExtension.ELEMENT_NAME, JabberAvatarExtension.NAMESPACE, new JabberAvatarExtension.Provider() ); ProviderManager.addExtensionProvider( VCardUpdateExtension.ELEMENT_NAME, VCardUpdateExtension.NAMESPACE, new VCardUpdateExtension.Provider() ); // Initialize parser parser = new MXParser(); try { parser.setFeature(XmlPullParser.FEATURE_PROCESS_NAMESPACES, true); } catch (XmlPullParserException e) { Log.error(e); } imageFile = new File(SparkManager.getUserDirectory(), "personal.png"); // Initialize vCard. personalVCard = new VCard(); personalVCardAvatar = null; personalVCardHash = null; // Set VCard Storage vcardStorageDirectory = new File(SparkManager.getUserDirectory(), "vcards"); vcardStorageDirectory.mkdirs(); // Set the current user directory. contactsDir = new File(SparkManager.getUserDirectory(), "contacts"); contactsDir.mkdirs(); initializeUI(); // Intercept all presence packets being sent and append vcard information. StanzaFilter presenceFilter = new StanzaTypeFilter(Presence.class); SparkManager.getConnection().addPacketInterceptor( stanza -> { Presence newPresence = (Presence)stanza; VCardUpdateExtension update = new VCardUpdateExtension(); JabberAvatarExtension jax = new JabberAvatarExtension(); ExtensionElement updateExt = newPresence.getExtension(update.getElementName(), update.getNamespace()); ExtensionElement jabberExt = newPresence.getExtension(jax.getElementName(), jax.getNamespace()); if (updateExt != null) { newPresence.removeExtension(updateExt); } if (jabberExt != null) { newPresence.removeExtension(jabberExt); } if (personalVCard != null) { if ( personalVCardAvatar == null ) { personalVCardAvatar = personalVCard.getAvatar(); } if (personalVCardAvatar != null && personalVCardAvatar.length > 0) { if ( personalVCardHash == null ) { personalVCardHash = personalVCard.getAvatarHash(); } update.setPhotoHash(personalVCardHash); jax.setPhotoHash(personalVCardHash); newPresence.addExtension(update); newPresence.addExtension(jax); } } }, presenceFilter); editor = new VCardEditor(); // Start Listener startQueueListener(); }
Example #30
Source File: GatewayPlugin.java From Spark with Apache License 2.0 | 4 votes |
@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(); }