Search in sources :

Example 11 with DiscoverInfo

use of org.jivesoftware.smackx.packet.DiscoverInfo in project Smack by igniterealtime.

the class MultiUserChatTest method testPrivateIQ.

/**
 * Tests that IQ packets can be sent to/from room occupants. This case will try to discover
 * information about other room occupants.
 */
public void testPrivateIQ() {
    try {
        // User2 joins the new room
        MultiUserChat muc2 = new MultiUserChat(getConnection(1), room);
        muc2.join("testbot2");
        // User2 discovers information about User1
        DiscoverInfo info = ServiceDiscoveryManager.getInstanceFor(getConnection(1)).discoverInfo(room + "/testbot", null);
        assertNotNull("No info was discovered from room occupant", info);
        assertEquals("Wrong IQ type", IQ.Type.result, info.getType());
        assertEquals("Wrong IQ sender", room + "/testbot", info.getFrom());
        // User2 leaves the room
        muc2.leave();
    } catch (Exception e) {
        e.printStackTrace();
        fail(e.getMessage());
    }
}
Also used : DiscoverInfo(org.jivesoftware.smackx.packet.DiscoverInfo) XMPPException(org.jivesoftware.smack.XMPPException)

Example 12 with DiscoverInfo

use of org.jivesoftware.smackx.packet.DiscoverInfo in project Smack by igniterealtime.

the class EntityUseCases method testDiscoverPubsubInfo.

public void testDiscoverPubsubInfo() throws Exception {
    DiscoverInfo supportedFeatures = getManager().getSupportedFeatures();
    assertNotNull(supportedFeatures);
}
Also used : DiscoverInfo(org.jivesoftware.smackx.packet.DiscoverInfo)

Example 13 with DiscoverInfo

use of org.jivesoftware.smackx.packet.DiscoverInfo in project Smack by igniterealtime.

the class EntityUseCases method testDiscoverNodeInfo.

public void testDiscoverNodeInfo() throws Exception {
    LeafNode myNode = getManager().createNode("DiscoNode" + System.currentTimeMillis());
    DiscoverInfo info = myNode.discoverInfo();
    assertTrue(info.getIdentities().hasNext());
    Identity ident = info.getIdentities().next();
    assertEquals("leaf", ident.getType());
}
Also used : DiscoverInfo(org.jivesoftware.smackx.packet.DiscoverInfo) Identity(org.jivesoftware.smackx.packet.DiscoverInfo.Identity)

Example 14 with DiscoverInfo

use of org.jivesoftware.smackx.packet.DiscoverInfo in project ecf by eclipse.

the class MultiUserChat method getServiceNames.

/**
 * 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;
}
Also used : DiscoverInfo(org.jivesoftware.smackx.packet.DiscoverInfo) ArrayList(java.util.ArrayList) DiscoverItems(org.jivesoftware.smackx.packet.DiscoverItems) XMPPException(org.jivesoftware.smack.XMPPException) ServiceDiscoveryManager(org.jivesoftware.smackx.ServiceDiscoveryManager)

Example 15 with DiscoverInfo

use of org.jivesoftware.smackx.packet.DiscoverInfo in project ecf by eclipse.

the class Socks5BytestreamManager method supportsSocks5.

/**
 * Returns <code>true</code> if the given target JID supports feature SOCKS5 Bytestream.
 *
 * @param targetJID the target JID
 * @return <code>true</code> if the given target JID supports feature SOCKS5 Bytestream
 *         otherwise <code>false</code>
 * @throws XMPPException if there was an error querying target for supported features
 */
private boolean supportsSocks5(String targetJID) throws XMPPException {
    ServiceDiscoveryManager serviceDiscoveryManager = ServiceDiscoveryManager.getInstanceFor(this.connection);
    DiscoverInfo discoverInfo = serviceDiscoveryManager.discoverInfo(targetJID);
    return discoverInfo.containsFeature(NAMESPACE);
}
Also used : DiscoverInfo(org.jivesoftware.smackx.packet.DiscoverInfo) ServiceDiscoveryManager(org.jivesoftware.smackx.ServiceDiscoveryManager)

Aggregations

DiscoverInfo (org.jivesoftware.smackx.packet.DiscoverInfo)20 XMPPException (org.jivesoftware.smack.XMPPException)6 ServiceDiscoveryManager (org.jivesoftware.smackx.ServiceDiscoveryManager)5 Identity (org.jivesoftware.smackx.packet.DiscoverInfo.Identity)5 DiscoverItems (org.jivesoftware.smackx.packet.DiscoverItems)5 ArrayList (java.util.ArrayList)3 DataInputStream (java.io.DataInputStream)1 File (java.io.File)1 FileInputStream (java.io.FileInputStream)1 IOException (java.io.IOException)1 Reader (java.io.Reader)1 StringReader (java.io.StringReader)1 MessageDigest (java.security.MessageDigest)1 LinkedList (java.util.LinkedList)1 List (java.util.List)1 TreeSet (java.util.TreeSet)1 Connection (org.jivesoftware.smack.Connection)1 XMPPConnection (org.jivesoftware.smack.XMPPConnection)1 PacketFilter (org.jivesoftware.smack.filter.PacketFilter)1 PacketIDFilter (org.jivesoftware.smack.filter.PacketIDFilter)1