Package org.jivesoftware.smackx.packet

Examples of org.jivesoftware.smackx.packet.DiscoverItems


        discoShell.open();
    }
   
    private void displayEntityTree( TreeItem parent, String entityID, String node ) {
        try {
            DiscoverItems items;
            if( node == null )
                items = manager.discoverItems( entityID );
            else
                items = manager.discoverItems( entityID, node );
            //System.out.println("displaying " + entityID + "... ");
           // if ( items.getItems().hasNext() )
              //  System.out.println(entityID + " has children :)\n" );
           
            for( Iterator i = items.getItems(); i.hasNext(); ) {
               
                DiscoverItems.Item item = (DiscoverItems.Item) i.next();
                TreeItem treeItem = new TreeItem( parent, SWT.NONE );
                parent.setExpanded( true );
                String text[] = { item.getEntityID(), item.getName(), item.getNode(), item.getAction() };
View Full Code Here


        LOGGER.debug("Service listing");

        ServiceDiscoveryManager disco = ServiceDiscoveryManager
                .getInstanceFor(connection);
        try {
            DiscoverItems items = disco.discoverItems(connection.getServiceName());

            Iterator<DiscoverItems.Item> iter = items.getItems();
            while (iter.hasNext()) {
                DiscoverItems.Item item = iter.next();
                DiscoverInfo info = disco.discoverInfo(item.getEntityID());

                Iterator<DiscoverInfo.Identity> iter2 = info.getIdentities();
View Full Code Here

                    };
                }
            });
           
            AdHocCommandManager manager2 = AdHocCommandManager.getAddHocCommandsManager(getConnection(1));
            DiscoverItems items = manager2.discoverCommands(getFullJID(0));

            assertTrue("Disco for command test failed", items.getItems().next().getNode().equals("test"));

            RemoteCommand command = manager2.getRemoteCommand(getFullJID(0), "test2");
            command.execute();
            assertEquals("Disco for command test failed", command.getForm().getField("test2").getValues().next(), "it worked");
        }
View Full Code Here

    LeafNode myNode = getRandomPubnode(getManager(), true, false);
    myNode.send(new Item());
    myNode.send(new Item());
    myNode.send(new Item());
    myNode.send(new Item());
    DiscoverItems items = myNode.discoverItems();
   
    int count = 0;
   
    for(Iterator<DiscoverItems.Item> it = items.getItems(); it.hasNext(); it.next(),count++);
   
    assertEquals(4, count);
  }
View Full Code Here

        // Listen for disco#items requests and answer with an empty result       
        PacketFilter packetFilter = new PacketTypeFilter(DiscoverItems.class);
        PacketListener packetListener = new PacketListener() {
            public void processPacket(Packet packet) {
                DiscoverItems discoverItems = (DiscoverItems) packet;
                // Send back the items defined in the client if the request is of type GET
                if (discoverItems != null && discoverItems.getType() == IQ.Type.GET) {
                    DiscoverItems response = new DiscoverItems();
                    response.setType(IQ.Type.RESULT);
                    response.setTo(discoverItems.getFrom());
                    response.setPacketID(discoverItems.getPacketID());
                    response.setNode(discoverItems.getNode());

                    // Add the defined items related to the requested node. Look for
                    // the NodeInformationProvider associated with the requested node. 
                    NodeInformationProvider nodeInformationProvider =
                            getNodeInformationProvider(discoverItems.getNode());
                    if (nodeInformationProvider != null) {
                        // Specified node was found, add node items
                        response.addItems(nodeInformationProvider.getNodeItems());
                        // Add packet extensions
                        response.addExtensions(nodeInformationProvider.getNodePacketExtensions());
                    } else if(discoverItems.getNode() != null) {
                        // Return <item-not-found/> error since client doesn't contain
                        // the specified node
                        response.setType(IQ.Type.ERROR);
                        response.setError(new XMPPError(XMPPError.Condition.item_not_found));
                    }
                    connection.sendPacket(response);
                }
            }
        };
        connection.addPacketListener(packetListener, packetFilter);

        // Listen for disco#info requests and answer the client's supported features
        // To add a new feature as supported use the #addFeature message       
        packetFilter = new PacketTypeFilter(DiscoverInfo.class);
        packetListener = new PacketListener() {
            public void processPacket(Packet packet) {
                DiscoverInfo discoverInfo = (DiscoverInfo) packet;
                // Answer the client's supported features if the request is of the GET type
                if (discoverInfo != null && discoverInfo.getType() == IQ.Type.GET) {
                    DiscoverInfo response = new DiscoverInfo();
                    response.setType(IQ.Type.RESULT);
                    response.setTo(discoverInfo.getFrom());
                    response.setPacketID(discoverInfo.getPacketID());
                    response.setNode(discoverInfo.getNode());
                    // Add the client's identity and features only if "node" is null
                    // and if the request was not send to a node. If Entity Caps are
                    // enabled the client's identity and features are may also added
                    // if the right node is chosen
                    if (discoverInfo.getNode() == null) {
                        addDiscoverInfoTo(response);
                    }
                    else {
                        // Disco#info was sent to a node. Check if we have information of the
                        // specified node
                        NodeInformationProvider nodeInformationProvider =
                                getNodeInformationProvider(discoverInfo.getNode());
                        if (nodeInformationProvider != null) {
                            // Node was found. Add node features
                            response.addFeatures(nodeInformationProvider.getNodeFeatures());
                            // Add node identities
                            response.addIdentities(nodeInformationProvider.getNodeIdentities());
                            // Add packet extensions
                            response.addExtensions(nodeInformationProvider.getNodePacketExtensions());
                        }
                        else {
                            // Return <item-not-found/> error since specified node was not found
                            response.setType(IQ.Type.ERROR);
                            response.setError(new XMPPError(XMPPError.Condition.item_not_found));
                        }
                    }
                    connection.sendPacket(response);
                }
            }
View Full Code Here

     * @return the discovered items.
     * @throws XMPPException if the operation failed for some reason.
     */
    public DiscoverItems discoverItems(String entityID, String node) throws XMPPException {
        // Discover the entity's items
        DiscoverItems disco = new DiscoverItems();
        disco.setType(IQ.Type.GET);
        disco.setTo(entityID);
        disco.setNode(node);

        // Create a packet collector to listen for a response.
        PacketCollector collector =
            connection.createPacketCollector(new PacketIDFilter(disco.getPacketID()));

        connection.sendPacket(disco);

        // Wait up to 5 seconds for a result.
        IQ result = (IQ) collector.nextResult(SmackConfiguration.getPacketReplyTimeout());
View Full Code Here

                        if (info.containsFeature("http://jabber.org/protocol/address")) {
                            serviceAddress = serviceName;
                        }
                        else {
                            // Get the disco items and send the disco packet to each server item
                            DiscoverItems items = ServiceDiscoveryManager.getInstanceFor(connection)
                                    .discoverItems(serviceName);
                            for (Iterator<DiscoverItems.Item> it = items.getItems(); it.hasNext();) {
                                DiscoverItems.Item item = it.next();
                                info = ServiceDiscoveryManager.getInstanceFor(connection)
                                        .discoverInfo(item.getEntityID(), item.getNode());
                                if (info.containsFeature("http://jabber.org/protocol/address")) {
                                    serviceAddress = serviceName;
View Full Code Here

   * @throws XMPPException
   */
  protected boolean checkRoom(String conference, String room) throws XMPPException {
    final XMPPConnection conn = ecfConnection.getXMPPConnection();
    final ServiceDiscoveryManager serviceDiscoveryManager = new ServiceDiscoveryManager(conn);
    final DiscoverItems result = serviceDiscoveryManager.discoverItems(conference);

    for (final Iterator items = result.getItems(); items.hasNext();) {
      final DiscoverItems.Item item = ((DiscoverItems.Item) items.next());
      if (room.equals(item.getEntityID())) {
        return true;
      }
    }
View Full Code Here

        ServiceDiscoveryManager serviceDiscoveryManager = ServiceDiscoveryManager.getInstanceFor(this.connection);

        List<String> proxies = new ArrayList<String>();

        // get all items form XMPP server
        DiscoverItems discoverItems = serviceDiscoveryManager.discoverItems(this.connection.getServiceName());
        Iterator<Item> itemIterator = discoverItems.getItems();

        // query all items if they are SOCKS5 proxies
        while (itemIterator.hasNext()) {
            Item item = itemIterator.next();
View Full Code Here

     * @throws XMPPException thrown if a server error has occurred.
     */
    public Collection<String> getSearchServices() throws XMPPException {
        final List<String> searchServices = new ArrayList<String>();
        ServiceDiscoveryManager discoManager = ServiceDiscoveryManager.getInstanceFor(con);
        DiscoverItems items = discoManager.discoverItems(con.getServiceName());
        Iterator<DiscoverItems.Item> iter = items.getItems();
        while (iter.hasNext()) {
            DiscoverItems.Item item = iter.next();
            try {
                DiscoverInfo info;
                try {
View Full Code Here

TOP

Related Classes of org.jivesoftware.smackx.packet.DiscoverItems

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.