Java 类org.jivesoftware.smackx.packet.DiscoverItems 实例源码

项目:VASSAL-src    文件:JabberClient.java   
public void process(Packet packet) {
  if (roomResponseFilter.accept(packet)) {
    final DiscoverItems result = (DiscoverItems) packet;
    final JabberPlayer player = playerMgr.getPlayer(packet.getFrom());
    // Collect the entityID for each returned item
    for (Iterator<DiscoverItems.Item> items = result.getItems(); items.hasNext();) {
      final String roomJID = items.next().getEntityID();
      final JabberRoom room = roomMgr.getRoomByJID(JabberClient.this, roomJID);
      try {
       room.setInfo(MultiUserChat.getRoomInfo(JabberClient.this
            .getConnection(), roomJID));
      }
      catch (XMPPException e) {
        // Ignore Error
      }
      if (!roomJID.equals(monitorRoom.getRoom())) {
        player.join(roomMgr.getRoomByJID(JabberClient.this, roomJID));
      }
    }
    fireRoomsUpdated();
  }
  else if (newPlayerFilter.accept(packet)) {
    sendRoomQuery(getAbsolutePlayerJID(packet.getFrom()));
  }
}
项目:EIM    文件:AdHocCommandManager.java   
/**
 * Publish the commands to an specific JID.
 *
 * @param jid the full JID to publish the commands to.
 * @throws XMPPException if the operation failed for some reason.
 */
public void publishCommands(String jid) throws XMPPException {
    ServiceDiscoveryManager serviceDiscoveryManager = ServiceDiscoveryManager
            .getInstanceFor(connection);

    // Collects the commands to publish as items
    DiscoverItems discoverItems = new DiscoverItems();
    Collection<AdHocCommandInfo> xCommandsList = getRegisteredCommands();

    for (AdHocCommandInfo info : xCommandsList) {
        DiscoverItems.Item item = new DiscoverItems.Item(info.getOwnerJID());
        item.setName(info.getName());
        item.setNode(info.getNode());
        discoverItems.addItem(item);
    }

    serviceDiscoveryManager.publishItems(jid, discoNode, discoverItems);
}
项目:EIM    文件:MultiUserChat.java   
/**
 * Returns a collection with the XMPP addresses of the Multi-User Chat services.
 *
 * @param connection the XMPP connection to use for discovering Multi-User Chat services.
 * @return a collection with the XMPP addresses of the Multi-User Chat services.
 * @throws XMPPException if an error occured while trying to discover MUC services.
 */
public static Collection<String> getServiceNames(Connection connection) throws XMPPException {
    final List<String> answer = new ArrayList<String>();
    ServiceDiscoveryManager discoManager = ServiceDiscoveryManager.getInstanceFor(connection);
    DiscoverItems items = discoManager.discoverItems(connection.getServiceName());
    for (Iterator<DiscoverItems.Item> it = items.getItems(); it.hasNext();) {
        DiscoverItems.Item item = it.next();
        try {
            DiscoverInfo info = discoManager.discoverInfo(item.getEntityID());
            if (info.containsFeature("http://jabber.org/protocol/muc")) {
                answer.add(item.getEntityID());
            }
        }
        catch (XMPPException e) {
            // Trouble finding info in some cases. This is a workaround for
            // discovering info on remote servers.
        }
    }
    return answer;
}
项目:EIM    文件:ServiceDiscoveryManager.java   
/**
 * Returns the discovered items of a given XMPP entity addressed by its JID and
 * note attribute. Use this message only when trying to query information which is not 
 * directly addressable.
 * 
 * @param entityID the address of the XMPP entity.
 * @param node the attribute that supplements the 'jid' attribute.
 * @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());
    // Stop queuing results
    collector.cancel();
    if (result == null) {
        throw new XMPPException("No response from the server.");
    }
    if (result.getType() == IQ.Type.ERROR) {
        throw new XMPPException(result.getError());
    }
    return (DiscoverItems) result;
}
项目:EIM    文件:ServiceDiscoveryManager.java   
/**
 * Publishes new items to a parent entity and node. The item elements to publish MUST have at 
 * least a 'jid' attribute specifying the Entity ID of the item, and an action attribute which 
 * specifies the action being taken for that item. Possible action values are: "update" and 
 * "remove".
 * 
 * @param entityID the address of the XMPP entity.
 * @param node the attribute that supplements the 'jid' attribute.
 * @param discoverItems the DiscoveryItems to publish.
 * @throws XMPPException if the operation failed for some reason.
 */
public void publishItems(String entityID, String node, DiscoverItems discoverItems)
        throws XMPPException {
    discoverItems.setType(IQ.Type.SET);
    discoverItems.setTo(entityID);
    discoverItems.setNode(node);

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

    connection.sendPacket(discoverItems);

    // Wait up to 5 seconds for a result.
    IQ result = (IQ) collector.nextResult(SmackConfiguration.getPacketReplyTimeout());
    // Stop queuing results
    collector.cancel();
    if (result == null) {
        throw new XMPPException("No response from the server.");
    }
    if (result.getType() == IQ.Type.ERROR) {
        throw new XMPPException(result.getError());
    }
}
项目:androidPN-client.    文件:MultiUserChat.java   
/**
 * Returns a collection with the XMPP addresses of the Multi-User Chat services.
 *
 * @param connection the XMPP connection to use for discovering Multi-User Chat services.
 * @return a collection with the XMPP addresses of the Multi-User Chat services.
 * @throws XMPPException if an error occured while trying to discover MUC services.
 */
public static Collection<String> getServiceNames(Connection connection) throws XMPPException {
    final List<String> answer = new ArrayList<String>();
    ServiceDiscoveryManager discoManager = ServiceDiscoveryManager.getInstanceFor(connection);
    DiscoverItems items = discoManager.discoverItems(connection.getServiceName());
    for (Iterator<DiscoverItems.Item> it = items.getItems(); it.hasNext();) {
        DiscoverItems.Item item = it.next();
        try {
            DiscoverInfo info = discoManager.discoverInfo(item.getEntityID());
            if (info.containsFeature("http://jabber.org/protocol/muc")) {
                answer.add(item.getEntityID());
            }
        }
        catch (XMPPException e) {
            // Trouble finding info in some cases. This is a workaround for
            // discovering info on remote servers.
        }
    }
    return answer;
}
项目:vassal    文件:JabberClient.java   
public void process(Packet packet) {
  if (roomResponseFilter.accept(packet)) {
    final DiscoverItems result = (DiscoverItems) packet;
    final JabberPlayer player = playerMgr.getPlayer(packet.getFrom());
    // Collect the entityID for each returned item
    for (Iterator<DiscoverItems.Item> items = result.getItems(); items.hasNext();) {
      final String roomJID = items.next().getEntityID();
      final JabberRoom room = roomMgr.getRoomByJID(JabberClient.this, roomJID);
      try {
       room.setInfo(MultiUserChat.getRoomInfo(JabberClient.this
            .getConnection(), roomJID));
      }
      catch (XMPPException e) {
        // Ignore Error
      }
      if (!roomJID.equals(monitorRoom.getRoom())) {
        player.join(roomMgr.getRoomByJID(JabberClient.this, roomJID));
      }
    }
    fireRoomsUpdated();
  }
  else if (newPlayerFilter.accept(packet)) {
    sendRoomQuery(getAbsolutePlayerJID(packet.getFrom()));
  }
}
项目:xmppsupport_v2    文件:AdHocCommandManager.java   
/**
 * Publish the commands to an specific JID.
 * 
 * @param jid
 *            the full JID to publish the commands to.
 * @throws XMPPException
 *             if the operation failed for some reason.
 */
public void publishCommands(String jid) throws XMPPException {
    ServiceDiscoveryManager serviceDiscoveryManager = ServiceDiscoveryManager
            .getInstanceFor(connection);

    // Collects the commands to publish as items
    DiscoverItems discoverItems = new DiscoverItems();
    Collection<AdHocCommandInfo> xCommandsList = getRegisteredCommands();

    for (AdHocCommandInfo info : xCommandsList) {
        DiscoverItems.Item item = new DiscoverItems.Item(info.getOwnerJID());
        item.setName(info.getName());
        item.setNode(info.getNode());
        discoverItems.addItem(item);
    }

    serviceDiscoveryManager.publishItems(jid, discoNode, discoverItems);
}
项目:xmppsupport_v2    文件:MultiUserChat.java   
/**
 * Returns a collection with the XMPP addresses of the Multi-User Chat
 * services.
 * 
 * @param connection
 *            the XMPP connection to use for discovering Multi-User Chat
 *            services.
 * @return a collection with the XMPP addresses of the Multi-User Chat
 *         services.
 * @throws XMPPException
 *             if an error occured while trying to discover MUC services.
 */
public static Collection<String> getServiceNames(Connection connection)
        throws XMPPException {
    final List<String> answer = new ArrayList<String>();
    ServiceDiscoveryManager discoManager = ServiceDiscoveryManager
            .getInstanceFor(connection);
    DiscoverItems items = discoManager.discoverItems(connection
            .getServiceName());
    for (Iterator<DiscoverItems.Item> it = items.getItems(); it.hasNext();) {
        DiscoverItems.Item item = it.next();
        try {
            DiscoverInfo info = discoManager.discoverInfo(item
                    .getEntityID());
            if (info.containsFeature("http://jabber.org/protocol/muc")) {
                answer.add(item.getEntityID());
            }
        } catch (XMPPException e) {
            // Trouble finding info in some cases. This is a workaround for
            // discovering info on remote servers.
        }
    }
    return answer;
}
项目:xmppsupport_v2    文件:ServiceDiscoveryManager.java   
/**
 * Publishes new items to a parent entity and node. The item elements to
 * publish MUST have at least a 'jid' attribute specifying the Entity ID of
 * the item, and an action attribute which specifies the action being taken
 * for that item. Possible action values are: "update" and "remove".
 * 
 * @param entityID
 *            the address of the XMPP entity.
 * @param node
 *            the attribute that supplements the 'jid' attribute.
 * @param discoverItems
 *            the DiscoveryItems to publish.
 * @throws XMPPException
 *             if the operation failed for some reason.
 */
public void publishItems(String entityID, String node,
        DiscoverItems discoverItems) throws XMPPException {
    discoverItems.setType(IQ.Type.SET);
    discoverItems.setTo(entityID);
    discoverItems.setNode(node);

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

    connection.sendPacket(discoverItems);

    // Wait up to 5 seconds for a result.
    IQ result = (IQ) collector.nextResult(SmackConfiguration
            .getPacketReplyTimeout());
    // Stop queuing results
    collector.cancel();
    if (result == null) {
        throw new XMPPException("No response from the server.");
    }
    if (result.getType() == IQ.Type.ERROR) {
        throw new XMPPException(result.getError());
    }
}
项目:java-bells    文件:AdHocCommandManager.java   
/**
 * Publish the commands to an specific JID.
 *
 * @param jid the full JID to publish the commands to.
 * @throws XMPPException if the operation failed for some reason.
 */
public void publishCommands(String jid) throws XMPPException {
    ServiceDiscoveryManager serviceDiscoveryManager = ServiceDiscoveryManager
            .getInstanceFor(connection);

    // Collects the commands to publish as items
    DiscoverItems discoverItems = new DiscoverItems();
    Collection<AdHocCommandInfo> xCommandsList = getRegisteredCommands();

    for (AdHocCommandInfo info : xCommandsList) {
        DiscoverItems.Item item = new DiscoverItems.Item(info.getOwnerJID());
        item.setName(info.getName());
        item.setNode(info.getNode());
        discoverItems.addItem(item);
    }

    serviceDiscoveryManager.publishItems(jid, discoNode, discoverItems);
}
项目:java-bells    文件:MultiUserChat.java   
/**
 * Returns a collection with the XMPP addresses of the Multi-User Chat services.
 *
 * @param connection the XMPP connection to use for discovering Multi-User Chat services.
 * @return a collection with the XMPP addresses of the Multi-User Chat services.
 * @throws XMPPException if an error occured while trying to discover MUC services.
 */
public static Collection<String> getServiceNames(Connection connection) throws XMPPException {
    final List<String> answer = new ArrayList<String>();
    ServiceDiscoveryManager discoManager = ServiceDiscoveryManager.getInstanceFor(connection);
    DiscoverItems items = discoManager.discoverItems(connection.getServiceName());
    for (Iterator<DiscoverItems.Item> it = items.getItems(); it.hasNext();) {
        DiscoverItems.Item item = it.next();
        try {
            DiscoverInfo info = discoManager.discoverInfo(item.getEntityID());
            if (info.containsFeature("http://jabber.org/protocol/muc")) {
                answer.add(item.getEntityID());
            }
        }
        catch (XMPPException e) {
            // Trouble finding info in some cases. This is a workaround for
            // discovering info on remote servers.
        }
    }
    return answer;
}
项目:java-bells    文件:ServiceDiscoveryManager.java   
/**
 * Returns the discovered items of a given XMPP entity addressed by its JID and
 * note attribute. Use this message only when trying to query information which is not 
 * directly addressable.
 * 
 * @param entityID the address of the XMPP entity.
 * @param node the optional attribute that supplements the 'jid' attribute.
 * @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());
    // Stop queuing results
    collector.cancel();
    if (result == null) {
        throw new XMPPException("No response from the server.");
    }
    if (result.getType() == IQ.Type.ERROR) {
        throw new XMPPException(result.getError());
    }
    return (DiscoverItems) result;
}
项目:java-bells    文件:ServiceDiscoveryManager.java   
/**
 * Publishes new items to a parent entity and node. The item elements to publish MUST have at 
 * least a 'jid' attribute specifying the Entity ID of the item, and an action attribute which 
 * specifies the action being taken for that item. Possible action values are: "update" and 
 * "remove".
 * 
 * @param entityID the address of the XMPP entity.
 * @param node the attribute that supplements the 'jid' attribute.
 * @param discoverItems the DiscoveryItems to publish.
 * @throws XMPPException if the operation failed for some reason.
 */
public void publishItems(String entityID, String node, DiscoverItems discoverItems)
        throws XMPPException {
    discoverItems.setType(IQ.Type.SET);
    discoverItems.setTo(entityID);
    discoverItems.setNode(node);

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

    connection.sendPacket(discoverItems);

    // Wait up to 5 seconds for a result.
    IQ result = (IQ) collector.nextResult(SmackConfiguration.getPacketReplyTimeout());
    // Stop queuing results
    collector.cancel();
    if (result == null) {
        throw new XMPPException("No response from the server.");
    }
    if (result.getType() == IQ.Type.ERROR) {
        throw new XMPPException(result.getError());
    }
}
项目:telegraph    文件:AdHocCommandManager.java   
/**
 * Publish the commands to an specific JID.
 *
 * @param jid the full JID to publish the commands to.
 * @throws XMPPException if the operation failed for some reason.
 */
public void publishCommands(String jid) throws XMPPException {
    ServiceDiscoveryManager serviceDiscoveryManager = ServiceDiscoveryManager
            .getInstanceFor(connection);

    // Collects the commands to publish as items
    DiscoverItems discoverItems = new DiscoverItems();
    Collection<AdHocCommandInfo> xCommandsList = getRegisteredCommands();

    for (AdHocCommandInfo info : xCommandsList) {
        DiscoverItems.Item item = new DiscoverItems.Item(info.getOwnerJID());
        item.setName(info.getName());
        item.setNode(info.getNode());
        discoverItems.addItem(item);
    }

    serviceDiscoveryManager.publishItems(jid, discoNode, discoverItems);
}
项目:telegraph    文件:MultiUserChat.java   
/**
 * Returns a collection with the XMPP addresses of the Multi-User Chat services.
 *
 * @param connection the XMPP connection to use for discovering Multi-User Chat services.
 * @return a collection with the XMPP addresses of the Multi-User Chat services.
 * @throws XMPPException if an error occured while trying to discover MUC services.
 */
public static Collection<String> getServiceNames(Connection connection) throws XMPPException {
    final List<String> answer = new ArrayList<String>();
    ServiceDiscoveryManager discoManager = ServiceDiscoveryManager.getInstanceFor(connection);
    DiscoverItems items = discoManager.discoverItems(connection.getServiceName());
    for (Iterator<DiscoverItems.Item> it = items.getItems(); it.hasNext();) {
        DiscoverItems.Item item = it.next();
        try {
            DiscoverInfo info = discoManager.discoverInfo(item.getEntityID());
            if (info.containsFeature("http://jabber.org/protocol/muc")) {
                answer.add(item.getEntityID());
            }
        }
        catch (XMPPException e) {
            // Trouble finding info in some cases. This is a workaround for
            // discovering info on remote servers.
        }
    }
    return answer;
}
项目:telegraph    文件:ServiceDiscoveryManager.java   
/**
 * Returns the discovered items of a given XMPP entity addressed by its JID and
 * note attribute. Use this message only when trying to query information which is not 
 * directly addressable.
 * 
 * @param entityID the address of the XMPP entity.
 * @param node the attribute that supplements the 'jid' attribute.
 * @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());
    // Stop queuing results
    collector.cancel();
    if (result == null) {
        throw new XMPPException("No response from the server.");
    }
    if (result.getType() == IQ.Type.ERROR) {
        throw new XMPPException(result.getError());
    }
    return (DiscoverItems) result;
}
项目:telegraph    文件:ServiceDiscoveryManager.java   
/**
 * Publishes new items to a parent entity and node. The item elements to publish MUST have at 
 * least a 'jid' attribute specifying the Entity ID of the item, and an action attribute which 
 * specifies the action being taken for that item. Possible action values are: "update" and 
 * "remove".
 * 
 * @param entityID the address of the XMPP entity.
 * @param node the attribute that supplements the 'jid' attribute.
 * @param discoverItems the DiscoveryItems to publish.
 * @throws XMPPException if the operation failed for some reason.
 */
public void publishItems(String entityID, String node, DiscoverItems discoverItems)
        throws XMPPException {
    discoverItems.setType(IQ.Type.SET);
    discoverItems.setTo(entityID);
    discoverItems.setNode(node);

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

    connection.sendPacket(discoverItems);

    // Wait up to 5 seconds for a result.
    IQ result = (IQ) collector.nextResult(SmackConfiguration.getPacketReplyTimeout());
    // Stop queuing results
    collector.cancel();
    if (result == null) {
        throw new XMPPException("No response from the server.");
    }
    if (result.getType() == IQ.Type.ERROR) {
        throw new XMPPException(result.getError());
    }
}
项目:NewCommunication-Android    文件:AdHocCommandManager.java   
/**
 * Publish the commands to an specific JID.
 *
 * @param jid the full JID to publish the commands to.
 * @throws XMPPException if the operation failed for some reason.
 */
public void publishCommands(String jid) throws XMPPException {
    ServiceDiscoveryManager serviceDiscoveryManager = ServiceDiscoveryManager
            .getInstanceFor(connection);

    // Collects the commands to publish as items
    DiscoverItems discoverItems = new DiscoverItems();
    Collection<AdHocCommandInfo> xCommandsList = getRegisteredCommands();

    for (AdHocCommandInfo info : xCommandsList) {
        DiscoverItems.Item item = new DiscoverItems.Item(info.getOwnerJID());
        item.setName(info.getName());
        item.setNode(info.getNode());
        discoverItems.addItem(item);
    }

    serviceDiscoveryManager.publishItems(jid, discoNode, discoverItems);
}
项目:NewCommunication-Android    文件:MultiUserChat.java   
/**
 * Returns a collection with the XMPP addresses of the Multi-User Chat services.
 *
 * @param connection the XMPP connection to use for discovering Multi-User Chat services.
 * @return a collection with the XMPP addresses of the Multi-User Chat services.
 * @throws XMPPException if an error occured while trying to discover MUC services.
 */
public static Collection<String> getServiceNames(Connection connection) throws XMPPException {
    final List<String> answer = new ArrayList<String>();
    ServiceDiscoveryManager discoManager = ServiceDiscoveryManager.getInstanceFor(connection);
    DiscoverItems items = discoManager.discoverItems(connection.getServiceName());
    for (Iterator<DiscoverItems.Item> it = items.getItems(); it.hasNext();) {
        DiscoverItems.Item item = it.next();
        try {
            DiscoverInfo info = discoManager.discoverInfo(item.getEntityID());
            if (info.containsFeature("http://jabber.org/protocol/muc")) {
                answer.add(item.getEntityID());
            }
        }
        catch (XMPPException e) {
            // Trouble finding info in some cases. This is a workaround for
            // discovering info on remote servers.
        }
    }
    return answer;
}
项目:NewCommunication-Android    文件:Socks5TransferNegotiatorManager.java   
/**
 * Checks the service discovery item returned from a server component to verify if it is
 * a File Transfer proxy or not.
 *
 * @param manager the service discovery manager which will be used to query the component
 * @param item    the discovered item on the server relating
 * @return returns the JID of the proxy if it is a proxy or null if the item is not a proxy.
 */
private String checkIsProxy(ServiceDiscoveryManager manager, DiscoverItems.Item item) {
    DiscoverInfo info;
    try {
        info = manager.discoverInfo(item.getEntityID());
    }
    catch (XMPPException e) {
        return null;
    }
    Iterator<DiscoverInfo.Identity> itx = info.getIdentities();
    while (itx.hasNext()) {
        DiscoverInfo.Identity identity = itx.next();
        if ("proxy".equalsIgnoreCase(identity.getCategory())
                && "bytestreams".equalsIgnoreCase(
                identity.getType())) {
            return info.getFrom();
        }
    }
    return null;
}
项目:NewCommunication-Android    文件:Socks5TransferNegotiatorManager.java   
private void initProxies() {
    proxies = new ArrayList<String>();
    ServiceDiscoveryManager manager = ServiceDiscoveryManager
            .getInstanceFor(connection);
    try {
        DiscoverItems discoItems = manager.discoverItems(connection.getServiceName());
        Iterator<DiscoverItems.Item> it = discoItems.getItems();
        while (it.hasNext()) {
            DiscoverItems.Item item = it.next();
            String proxy = checkIsProxy(manager, item);
            if (proxy != null) {
                proxies.add(proxy);
            }
        }
    }
    catch (XMPPException e) {
        return;
    }
    if (proxies.size() > 0) {
        initStreamHosts();
    }
}
项目:NewCommunication-Android    文件:ServiceDiscoveryManager.java   
/**
 * Returns the discovered items of a given XMPP entity addressed by its JID and
 * note attribute. Use this message only when trying to query information which is not 
 * directly addressable.
 * 
 * @param entityID the address of the XMPP entity.
 * @param node the attribute that supplements the 'jid' attribute.
 * @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());
    // Stop queuing results
    collector.cancel();
    if (result == null) {
        throw new XMPPException("No response from the server.");
    }
    if (result.getType() == IQ.Type.ERROR) {
        throw new XMPPException(result.getError());
    }
    return (DiscoverItems) result;
}
项目:NewCommunication-Android    文件:ServiceDiscoveryManager.java   
/**
 * Publishes new items to a parent entity and node. The item elements to publish MUST have at 
 * least a 'jid' attribute specifying the Entity ID of the item, and an action attribute which 
 * specifies the action being taken for that item. Possible action values are: "update" and 
 * "remove".
 * 
 * @param entityID the address of the XMPP entity.
 * @param node the attribute that supplements the 'jid' attribute.
 * @param discoverItems the DiscoveryItems to publish.
 * @throws XMPPException if the operation failed for some reason.
 */
public void publishItems(String entityID, String node, DiscoverItems discoverItems)
        throws XMPPException {
    discoverItems.setType(IQ.Type.SET);
    discoverItems.setTo(entityID);
    discoverItems.setNode(node);

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

    connection.sendPacket(discoverItems);

    // Wait up to 5 seconds for a result.
    IQ result = (IQ) collector.nextResult(SmackConfiguration.getPacketReplyTimeout());
    // Stop queuing results
    collector.cancel();
    if (result == null) {
        throw new XMPPException("No response from the server.");
    }
    if (result.getType() == IQ.Type.ERROR) {
        throw new XMPPException(result.getError());
    }
}
项目:asmack-mini    文件:ServiceDiscoveryManager.java   
/**
 * Returns the discovered items of a given XMPP entity addressed by its JID and
 * note attribute. Use this message only when trying to query information which is not 
 * directly addressable.
 * 
 * @param entityID the address of the XMPP entity.
 * @param node the optional attribute that supplements the 'jid' attribute.
 * @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());
    // Stop queuing results
    collector.cancel();
    if (result == null) {
        throw new XMPPException("No response from the server.");
    }
    if (result.getType() == IQ.Type.ERROR) {
        throw new XMPPException(result.getError());
    }
    return (DiscoverItems) result;
}
项目:asmack-mini    文件:ServiceDiscoveryManager.java   
/**
 * Publishes new items to a parent entity and node. The item elements to publish MUST have at 
 * least a 'jid' attribute specifying the Entity ID of the item, and an action attribute which 
 * specifies the action being taken for that item. Possible action values are: "update" and 
 * "remove".
 * 
 * @param entityID the address of the XMPP entity.
 * @param node the attribute that supplements the 'jid' attribute.
 * @param discoverItems the DiscoveryItems to publish.
 * @throws XMPPException if the operation failed for some reason.
 */
public void publishItems(String entityID, String node, DiscoverItems discoverItems)
        throws XMPPException {
    discoverItems.setType(IQ.Type.SET);
    discoverItems.setTo(entityID);
    discoverItems.setNode(node);

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

    connection.sendPacket(discoverItems);

    // Wait up to 5 seconds for a result.
    IQ result = (IQ) collector.nextResult(SmackConfiguration.getPacketReplyTimeout());
    // Stop queuing results
    collector.cancel();
    if (result == null) {
        throw new XMPPException("No response from the server.");
    }
    if (result.getType() == IQ.Type.ERROR) {
        throw new XMPPException(result.getError());
    }
}
项目:spark-svn-mirror    文件:ConferenceServiceBrowser.java   
public Collection<String> getConferenceServices(String server) throws Exception {
    List<String> answer = new ArrayList<String>();
    ServiceDiscoveryManager discoManager = ServiceDiscoveryManager.getInstanceFor(SparkManager.getConnection());
    DiscoverItems items = discoManager.discoverItems(server);
    for (Iterator<Item> it = items.getItems(); it.hasNext();) {
        Item item = it.next();
        if (item.getEntityID().startsWith("conference") || item.getEntityID().startsWith("private")) {
            answer.add(item.getEntityID());
        }
        else {
            try {
                DiscoverInfo info = discoManager.discoverInfo(item.getEntityID());
                if (info.containsFeature("http://jabber.org/protocol/muc")) {
                    answer.add(item.getEntityID());
                }
            }
            catch (XMPPException e) {
                // Nothing to do
            }
        }
    }
    return answer;
}
项目:spark-svn-mirror    文件:BookmarksUI.java   
private Collection<String> getConferenceServices(String server) throws Exception {
    List<String> answer = new ArrayList<String>();
    ServiceDiscoveryManager discoManager = ServiceDiscoveryManager.getInstanceFor(SparkManager.getConnection());
    DiscoverItems items = discoManager.discoverItems(server);
    for (Iterator<DiscoverItems.Item> it = items.getItems(); it.hasNext();) {
        DiscoverItems.Item item = (DiscoverItems.Item)it.next();
        if (item.getEntityID().startsWith("conference") || item.getEntityID().startsWith("private")) {
            answer.add(item.getEntityID());
        }
        else {
            try {
                DiscoverInfo info = discoManager.discoverInfo(item.getEntityID());
                if (info.containsFeature("http://jabber.org/protocol/muc")) {
                    answer.add(item.getEntityID());
                }
            }
            catch (XMPPException e) {
                Log.error("Problem when loading conference service.", e);
            }
        }
    }
    return answer;
}
项目:spark-svn-mirror    文件:RoomBrowser.java   
public void displayRoomInformation(final String roomJID) {
    SwingWorker worker = new SwingWorker() {
        RoomInfo roomInfo = null;
        DiscoverItems items = null;

        public Object construct() {
            try {
                roomInfo = MultiUserChat.getRoomInfo(SparkManager.getConnection(), roomJID);


                ServiceDiscoveryManager manager = ServiceDiscoveryManager.getInstanceFor(SparkManager.getConnection());
                items = manager.discoverItems(roomJID);
            }
            catch (XMPPException e) {
                Log.error(e);
            }
            return "ok";
        }

        public void finished() {
            setupRoomInformationUI(roomJID, roomInfo, items);
        }
    };

    worker.start();
}
项目:spark-svn-mirror    文件:Enterprise.java   
private void populateFeatureSet() {
    final ServiceDiscoveryManager disco = ServiceDiscoveryManager.getInstanceFor(SparkManager.getConnection());
    final DiscoverItems items = SparkManager.getSessionManager().getDiscoveredItems();
    Iterator<DiscoverItems.Item> iter = items.getItems();
    while (iter.hasNext()) {
        DiscoverItems.Item item = iter.next();
        String entity = item.getEntityID();
        if (entity != null) {
            if (entity.startsWith("manager.")) {
                sparkManagerInstalled = true;

                // Populate with feature sets.
                try {
                    featureInfo = disco.discoverInfo(item.getEntityID());
                }
                catch (XMPPException e) {
                    Log.error("Error while retrieving feature list for SparkManager.", e);
                }

            }
        }
    }
}
项目:spark-svn-mirror    文件:CheckUpdates.java   
/**
 * Does a service discvery on the server to see if a Spark Manager
 * is enabled.
 *
 * @param con the XMPPConnection to use.
 * @return true if Spark Manager is available.
 */
public static boolean isSparkPluginInstalled(XMPPConnection con) {
    if (!con.isConnected()) {
        return false;
    }


    try {
        DiscoverItems items = SparkManager.getSessionManager().getDiscoveredItems();
        Iterator<DiscoverItems.Item> iter = items.getItems();
        while (iter.hasNext()) {
            DiscoverItems.Item item = (DiscoverItems.Item)iter.next();
            if ("Spark Updater".equals(item.getName())) {
                return true;
            }
        }
    }
    catch (Exception e) {
        Log.error(e);
    }

    return false;

}
项目:spark-svn-mirror    文件:SipAccountPacket.java   
/**
 * Does a service discovery on the server to see if a SIPpark Manager is
 * enabled.
 *
 * @param con the XMPPConnection to use.
 * @return true if SIPpark Manager is available.
 */
public static boolean isSoftPhonePluginInstalled(XMPPConnection con) {
    if (!con.isConnected()) {
        return false;
    }

    ServiceDiscoveryManager disco = ServiceDiscoveryManager
            .getInstanceFor(con);
    try {
        DiscoverItems items = disco.discoverItems(con.getServiceName());
        Iterator<DiscoverItems.Item> iter = items.getItems();
        while (iter.hasNext()) {
            DiscoverItems.Item item = iter.next();
            if ("SIP Controller".equals(item.getName())) {
                Log.debug("SIP Controller Found");
                return true;
            }
        }
    }
    catch (XMPPException e) {
        Log.error("isSparkPluginInstalled", e);
    }

    return false;

}
项目:VASSAL-src    文件:JabberClient.java   
private void sendRoomQuery(String jid) {
  DiscoverItems disco = new DiscoverItems();
  disco.setType(IQ.Type.GET);
  disco.setTo(jid);
  disco.setNode(QUERY_ROOMS);
  conn.sendPacket(disco);
}
项目:VASSAL-src    文件:JabberClient.java   
public boolean acceptPacket(Packet packet) {
  boolean accept = false;
  if (roomResponseFilter.accept(packet)) {
    accept = QUERY_ROOMS.equals(((DiscoverItems) packet).getNode());
  }
  else if (newPlayerFilter.accept(packet)) {
    accept = ((Presence) packet).isAvailable();
  }
  return accept;
}