Java Code Examples for org.jivesoftware.smack.provider.ProviderManager#addExtensionProvider()
The following examples show how to use
org.jivesoftware.smack.provider.ProviderManager#addExtensionProvider() .
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: 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 2
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 3
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 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: 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 6
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 7
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 8
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 9
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 10
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 11
Source File: ParsingExceptionTest.java From Smack with Apache License 2.0 | 4 votes |
@Before public void init() { ProviderManager.addExtensionProvider(ThrowException.ELEMENT, ThrowException.NAMESPACE, new ThrowException()); }
Example 12
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 13
Source File: BattleshipPlugin.java From Spark with Apache License 2.0 | 3 votes |
@Override public void initialize() { ProviderManager.addIQProvider(GameOfferPacket.ELEMENT_NAME, GameOfferPacket.NAMESPACE, GameOfferPacket.class); ProviderManager.addExtensionProvider(MovePacket.ELEMENT_NAME, MovePacket.NAMESPACE, MovePacket.class); ProviderManager.addExtensionProvider(MoveAnswerPacket.ELEMENT_NAME, MoveAnswerPacket.NAMESPACE, MoveAnswerPacket.class); _gameofferListener = new StanzaListener() { @Override public void processPacket(Stanza stanza) { GameOfferPacket invitation = (GameOfferPacket) stanza; if (invitation.getType() == IQ.Type.get) { showInvitationInChat(invitation); } } }; SparkManager.getConnection().addAsyncStanzaListener(_gameofferListener, new StanzaTypeFilter(GameOfferPacket.class)); _chatRoomListener = new ChatRoomOpeningListener(); SparkManager.getChatManager().addChatRoomListener(_chatRoomListener); }