Package rocks.xmpp.extensions.disco

Examples of rocks.xmpp.extensions.disco.ServiceDiscoveryManager


    public void testServiceDiscoveryEntry() {
        TestXmppSession xmppSession1 = new TestXmppSession();
        LastActivityManager lastActivityManager = xmppSession1.getExtensionManager(LastActivityManager.class);
        // By default, the manager should be enabled.
        Assert.assertTrue(lastActivityManager.isEnabled());
        ServiceDiscoveryManager serviceDiscoveryManager = xmppSession1.getExtensionManager(ServiceDiscoveryManager.class);
        Feature feature = new Feature("jabber:iq:last");
        Assert.assertTrue(serviceDiscoveryManager.getFeatures().contains(feature));
        lastActivityManager.setEnabled(false);
        Assert.assertFalse(lastActivityManager.isEnabled());
        Assert.assertFalse(serviceDiscoveryManager.getFeatures().contains(feature));
    }
View Full Code Here


    public void testServiceDiscoveryEntry() {
        TestXmppSession connection1 = new TestXmppSession();
        EntityTimeManager entityTimeManager = connection1.getExtensionManager(EntityTimeManager.class);
        // By default, the manager should be enabled.
        Assert.assertTrue(entityTimeManager.isEnabled());
        ServiceDiscoveryManager serviceDiscoveryManager = connection1.getExtensionManager(ServiceDiscoveryManager.class);
        Feature feature = new Feature("urn:xmpp:time");
        Assert.assertTrue(serviceDiscoveryManager.getFeatures().contains(feature));
        entityTimeManager.setEnabled(false);
        Assert.assertFalse(entityTimeManager.isEnabled());
        Assert.assertFalse(serviceDiscoveryManager.getFeatures().contains(feature));
    }
View Full Code Here

    @Test
    public void testServiceDiscoveryEntry() {
        TestXmppSession xmppSession = new TestXmppSession();
        HashManager hashManager = xmppSession.getExtensionManager(HashManager.class);
        Assert.assertTrue(hashManager.isEnabled());
        ServiceDiscoveryManager serviceDiscoveryManager = xmppSession.getExtensionManager(ServiceDiscoveryManager.class);
        Feature feature = new Feature("urn:xmpp:hashes:1");
        Feature featureSha256 = new Feature("urn:xmpp:hash-function-text-names:sha-256");
        Assert.assertTrue(serviceDiscoveryManager.getFeatures().contains(feature));
        Assert.assertTrue(serviceDiscoveryManager.getFeatures().contains(featureSha256));
        hashManager.setEnabled(false);
        Assert.assertFalse(hashManager.isEnabled());
        Assert.assertFalse(serviceDiscoveryManager.getFeatures().contains(feature));
        Assert.assertFalse(serviceDiscoveryManager.getFeatures().contains(featureSha256));
    }
View Full Code Here

    public void testServiceDiscoveryEntry() {
        TestXmppSession connection1 = new TestXmppSession();
        PingManager pingManager = connection1.getExtensionManager(PingManager.class);
        // By default, the manager should be enabled.
        Assert.assertTrue(pingManager.isEnabled());
        ServiceDiscoveryManager serviceDiscoveryManager = connection1.getExtensionManager(ServiceDiscoveryManager.class);
        Feature feature = new Feature("urn:xmpp:ping");
        Assert.assertTrue(serviceDiscoveryManager.getFeatures().contains(feature));
        pingManager.setEnabled(false);
        Assert.assertFalse(pingManager.isEnabled());
        Assert.assertFalse(serviceDiscoveryManager.getFeatures().contains(feature));
    }
View Full Code Here

     * @return The reserved nickname or null, if you don't have a reserved nickname.
     * @throws rocks.xmpp.core.stanza.model.StanzaException If the entity returned a stanza error.
     * @throws rocks.xmpp.core.session.NoResponseException  If the entity did not respond.
     */
    public String getReservedNickname() throws XmppException {
        ServiceDiscoveryManager serviceDiscoveryManager = xmppSession.getExtensionManager(ServiceDiscoveryManager.class);
        InfoNode infoNode = serviceDiscoveryManager.discoverInformation(roomJid, "x-roomuser-item");
        if (infoNode != null) {
            for (Identity identity : infoNode.getIdentities()) {
                if ("conference".equals(identity.getCategory()) && "text".equals(identity.getType())) {
                    return identity.getName();
                }
View Full Code Here

                            });
                            MenuItem serviceDiscoveryMenuItem = new MenuItem("Discover Info");
                            serviceDiscoveryMenuItem.setOnAction(new EventHandler<ActionEvent>() {
                                @Override
                                public void handle(ActionEvent actionEvent) {
                                    ServiceDiscoveryManager serviceDiscoveryManager = xmppSession.getExtensionManager(ServiceDiscoveryManager.class);
                                    try {
                                        Jid jid = new Jid(item.contact.get().getJid().getLocal(), item.contact.get().getJid().getDomain());
                                        InfoNode infoNode = serviceDiscoveryManager.discoverInformation(null);
                                        int i = 0;
                                    } catch (XmppException e) {
                                        e.printStackTrace();
                                    }

                                }
                            });
                            MenuItem vCardItem = new MenuItem("Get VCard");
                            vCardItem.setOnAction(new EventHandler<ActionEvent>() {
                                @Override
                                public void handle(ActionEvent actionEvent) {
                                    VCardManager vCardManager = xmppSession.getExtensionManager(VCardManager.class);
                                    try {
                                        Jid jid = new Jid(item.contact.get().getJid().getLocal(), item.contact.get().getJid().getDomain());
                                        VCard vCard = vCardManager.getVCard(jid);
                                        int i = 0;
                                    } catch (XmppException e) {
                                        e.printStackTrace();
                                    }

                                }
                            });
                            MenuItem storeAnnotationsItems = new MenuItem("Store annotations");
                            storeAnnotationsItems.setOnAction(new EventHandler<ActionEvent>() {
                                @Override
                                public void handle(ActionEvent actionEvent) {
                                    PrivateDataManager privateDataManager = xmppSession.getExtensionManager(PrivateDataManager.class);
                                    try {
                                        List<Annotation.Note> notes = new ArrayList<>();
                                        notes.add(new Annotation.Note("Hallo", item.contact.get().getJid()));
                                        privateDataManager.storeData(new Annotation(notes));
                                    } catch (XmppException e) {
                                        e.printStackTrace();
                                    }

                                }
                            });
                            MenuItem getAnnotationsItems = new MenuItem("Get annotations");
                            getAnnotationsItems.setOnAction(new EventHandler<ActionEvent>() {
                                @Override
                                public void handle(ActionEvent actionEvent) {
                                    PrivateDataManager privateDataManager = xmppSession.getExtensionManager(PrivateDataManager.class);
                                    try {
                                        Annotation annotations = privateDataManager.getData(Annotation.class);
                                        int i = 0;
                                    } catch (XmppException e) {
                                        e.printStackTrace();
                                    }
                                }
                            });
                            MenuItem pubSubItem = new MenuItem("PubSub");
                            pubSubItem.setOnAction(new EventHandler<ActionEvent>() {
                                @Override
                                public void handle(ActionEvent actionEvent) {
                                    PubSubManager pubSubManager = xmppSession.getExtensionManager(PubSubManager.class);
                                    ServiceDiscoveryManager serviceDiscoveryManager = xmppSession.getExtensionManager(ServiceDiscoveryManager.class);
                                    try {
                                        ItemNode infoNode = serviceDiscoveryManager.discoverItems(null);
                                        int i = 0;
                                    } catch (XmppException e) {
                                        e.printStackTrace();
                                    }
                                }
View Full Code Here

     * @return True, if the server supports flexible offline message retrieval; otherwise false.
     * @throws rocks.xmpp.core.stanza.model.StanzaException If the server returned a stanza error.
     * @throws rocks.xmpp.core.session.NoResponseException  If the server did not respond.
     */
    public boolean isSupported() throws XmppException {
        ServiceDiscoveryManager serviceDiscoveryManager = xmppSession.getExtensionManager(ServiceDiscoveryManager.class);
        InfoNode infoNode = serviceDiscoveryManager.discoverInformation(null);
        return infoNode.getFeatures().contains(new Feature(OfflineMessage.NAMESPACE));
    }
View Full Code Here

     * @throws rocks.xmpp.core.stanza.model.StanzaException If the server returned a stanza error.
     * @throws rocks.xmpp.core.session.NoResponseException  If the server did not respond.
     * @see <a href="http://xmpp.org/extensions/xep-0013.html#request-number">2.2 Requesting Number of Messages</a>
     */
    public int requestNumberOfMessages() throws XmppException {
        ServiceDiscoveryManager serviceDiscoveryManager = xmppSession.getExtensionManager(ServiceDiscoveryManager.class);
        InfoNode infoDiscovery = serviceDiscoveryManager.discoverInformation(null, OfflineMessage.NAMESPACE);
        if (!infoDiscovery.getExtensions().isEmpty()) {
            DataForm dataForm = infoDiscovery.getExtensions().get(0);
            if (dataForm != null) {
                for (DataForm.Field field : dataForm.getFields()) {
                    if ("number_of_messages".equals(field.getVar())) {
View Full Code Here

     * @throws rocks.xmpp.core.session.NoResponseException  If the server did not respond.
     * @see <a href="http://xmpp.org/extensions/xep-0013.html#request-headers">2.3 Requesting Message Headers</a>
     */
    public List<OfflineMessageHeader> requestMessageHeaders() throws XmppException {
        List<OfflineMessageHeader> result = new ArrayList<>();
        ServiceDiscoveryManager serviceDiscoveryManager = xmppSession.getExtensionManager(ServiceDiscoveryManager.class);
        ItemNode itemNode = serviceDiscoveryManager.discoverItems(null, OfflineMessage.NAMESPACE);
        for (Item item : itemNode.getItems()) {
            result.add(new OfflineMessageHeader(Jid.valueOf(item.getName()), item.getNode()));
        }
        return result;
    }
View Full Code Here

        // server returns a stream header to the client and MAY announce support for in-band registration by including the relevant stream feature.
        boolean isSupported = xmppSession.getStreamFeaturesManager().getFeatures().containsKey(RegisterFeature.class);

        // Since the stream feature is only optional, discover the server features, too.
        if (!isSupported) {
            ServiceDiscoveryManager serviceDiscoveryManager = xmppSession.getExtensionManager(ServiceDiscoveryManager.class);
            InfoNode infoNode = serviceDiscoveryManager.discoverInformation(null);
            isSupported = infoNode.getFeatures().contains(new Feature("jabber:iq:register"));
        }
        return isSupported;
    }
View Full Code Here

TOP

Related Classes of rocks.xmpp.extensions.disco.ServiceDiscoveryManager

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.