Package rocks.xmpp.extensions.disco.model.items

Examples of rocks.xmpp.extensions.disco.model.items.ItemNode


                "          name='Music from the time of Shakespeare'/>\n" +
                "  </query>\n" +
                "</iq>\n";

        IQ iq = unmarshal(xml, IQ.class);
        ItemNode itemNode = iq.getExtension(ItemDiscovery.class);
        Assert.assertNotNull(itemNode);
        Assert.assertEquals(itemNode.getItems().size(), 3);
        Assert.assertEquals(itemNode.getItems().get(0).getJid(), Jid.valueOf("catalog.shakespeare.lit"));
        Assert.assertEquals(itemNode.getItems().get(0).getNode(), "books");
        Assert.assertEquals(itemNode.getItems().get(0).getName(), "Books by and about Shakespeare");
        Assert.assertEquals(itemNode.getItems().get(1).getJid(), Jid.valueOf("catalog.shakespeare.lit"));
        Assert.assertEquals(itemNode.getItems().get(1).getNode(), "clothing");
        Assert.assertEquals(itemNode.getItems().get(1).getName(), "Wear your literary taste with pride");
        Assert.assertEquals(itemNode.getItems().get(2).getJid(), Jid.valueOf("catalog.shakespeare.lit"));
        Assert.assertEquals(itemNode.getItems().get(2).getNode(), "music");
        Assert.assertEquals(itemNode.getItems().get(2).getName(), "Music from the time of Shakespeare");
    }
View Full Code Here


                                IQ result = iq.createResult();
                                result.setExtension(new ItemDiscovery(items));
                                xmppSession.send(result);
                                e.consume();
                            } else {
                                ItemNode itemNode = itemNodeMap.get(itemDiscovery.getNode());
                                if (itemNode != null) {
                                    IQ result = iq.createResult();
                                    result.setExtension(new ItemDiscovery(itemNode.getNode(), items));
                                    xmppSession.send(result);
                                    e.consume();
                                } else {
                                    xmppSession.send(iq.createError(new StanzaError(new ItemNotFound())));
                                    e.consume();
View Full Code Here

     * @throws rocks.xmpp.core.session.NoResponseException  If the chat service did not respond.
     * @see <a href="http://xmpp.org/extensions/xep-0045.html#disco-roomitems">6.5 Querying for Room Items</a>
     * @see #getOccupants()
     */
    public List<String> discoverOccupants() throws XmppException {
        ItemNode itemNode = serviceDiscoveryManager.discoverItems(roomJid);
        List<String> occupants = new ArrayList<>();
        List<Item> items = itemNode.getItems();
        for (Item item : items) {
            if (item.getJid() != null) {
                String nickname = item.getJid().getResource();
                if (nickname != null) {
                    occupants.add(nickname);
View Full Code Here

                                @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

     * @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.
     * @see <a href="http://xmpp.org/extensions/xep-0060.html#entity-nodes">5.2 Discover Nodes</a>
     */
    public List<PubSubNode> getNodes() throws XmppException {
        ItemNode itemNode = serviceDiscoveryManager.discoverItems(service);
        List<PubSubNode> nodes = new ArrayList<>();
        for (Item item : itemNode.getItems()) {
            PubSubNode n = new PubSubNode(item.getNode(), item.getName(), service, xmppSession);
            nodes.add(n);
        }
        return nodes;
    }
View Full Code Here

     * @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

     * @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.
     * @see <a href="http://xmpp.org/extensions/xep-0065.html#disco">4. Discovering Proxies</a>
     */
    public List<StreamHost> discoverProxies() throws XmppException {
        ItemNode itemNode = serviceDiscoveryManager.discoverItems(null);
        for (Item item : itemNode.getItems()) {
            InfoNode infoNode = serviceDiscoveryManager.discoverInformation(item.getJid());
            if (infoNode.getFeatures().contains(new Feature(Socks5ByteStream.NAMESPACE))) {
                IQ result = xmppSession.query(new IQ(item.getJid(), IQ.Type.GET, new Socks5ByteStream()));
                Socks5ByteStream socks5ByteStream = result.getExtension(Socks5ByteStream.class);
                if (socks5ByteStream != null) {
View Full Code Here

     * @throws rocks.xmpp.core.stanza.model.StanzaException If the chat service returned a stanza error.
     * @throws rocks.xmpp.core.session.NoResponseException  If the chat service did not respond.
     */
    public List<ChatRoom> getPublicRooms() throws XmppException {
        List<ChatRoom> chatRooms = new ArrayList<>();
        ItemNode itemNode = serviceDiscoveryManager.discoverItems(serviceAddress);
        for (Item item : itemNode.getItems()) {
            chatRooms.add(new ChatRoom(item.getName(), item.getJid(), xmppSession));
        }
        return chatRooms;
    }
View Full Code Here

     * @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.
     * @see <a href="http://xmpp.org/extensions/xep-0045.html#disco-service">6.1 Discovering a MUC Service</a>
     */
    public Collection<ChatService> getChatServices() throws XmppException {
        ItemNode itemDiscovery = serviceDiscoveryManager.discoverItems(null);
        Collection<ChatService> chatServices = new ArrayList<>();

        for (Item item : itemDiscovery.getItems()) {
            InfoNode infoDiscovery = serviceDiscoveryManager.discoverInformation(item.getJid());
            if (infoDiscovery.getFeatures().contains(new Feature(Muc.NAMESPACE))) {
                chatServices.add(new ChatService(item.getJid(), xmppSession, serviceDiscoveryManager));
            }
        }
View Full Code Here

     * @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.
     * @see <a href="http://xmpp.org/extensions/xep-0060.html#entity-discoveritems">5.5 Discover Items for a Node</a>
     */
    public List<rocks.xmpp.extensions.pubsub.model.Item> discoverItems() throws XmppException {
        ItemNode itemNode = serviceDiscoveryManager.discoverItems(pubSubServiceAddress, nodeId);
        List<rocks.xmpp.extensions.pubsub.model.Item> result = new ArrayList<>();
        for (Item item : itemNode.getItems()) {
            // The 'name' attribute of each Service Discovery item MUST contain its ItemID
            result.add(new PubSub.ItemElement(item.getName()));
        }
        return result;
    }
View Full Code Here

TOP

Related Classes of rocks.xmpp.extensions.disco.model.items.ItemNode

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.