Examples of ServiceDiscoveryManager


Examples of org.jivesoftware.smackx.ServiceDiscoveryManager

        // mock nextResult method
        when(collector.nextResult(anyInt())).thenAnswer(answer);
        when(collector.nextResult()).thenAnswer(answer);

        // initialize service discovery manager for this connection
        new ServiceDiscoveryManager(connection);

        return connection;
    }
View Full Code Here

Examples of org.jivesoftware.smackx.ServiceDiscoveryManager

        // mock connection
        connection = mock(Connection.class);

        // create service discovery manager for mocked connection
        new ServiceDiscoveryManager(connection);

        // initialize Socks5ByteStreamManager to get the InitiationListener
        byteStreamManager = Socks5BytestreamManager.getBytestreamManager(connection);

        // get the InitiationListener from Socks5ByteStreamManager
View Full Code Here

Examples of org.jivesoftware.smackx.ServiceDiscoveryManager

        if (managers.size() == 0) {
            Socks5Proxy.getSocks5Proxy().stop();
        }

        // remove feature from service discovery
        ServiceDiscoveryManager serviceDiscoveryManager = ServiceDiscoveryManager.getInstanceFor(this.connection);

        // check if service discovery is not already disposed by connection shutdown
        if (serviceDiscoveryManager != null) {
            serviceDiscoveryManager.removeFeature(NAMESPACE);
        }

    }
View Full Code Here

Examples of org.jivesoftware.smackx.ServiceDiscoveryManager

     * @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);
    }
View Full Code Here

Examples of org.jivesoftware.smackx.ServiceDiscoveryManager

     *
     * @return list of JIDs of SOCKS5 proxies
     * @throws XMPPException if there was an error querying the XMPP server for SOCKS5 proxies
     */
    private List<String> determineProxies() throws XMPPException {
        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();

            // skip blacklisted servers
            if (this.proxyBlacklist.contains(item.getEntityID())) {
                continue;
            }

            try {
                DiscoverInfo proxyInfo;
                proxyInfo = serviceDiscoveryManager.discoverInfo(item.getEntityID());
                Iterator<Identity> identities = proxyInfo.getIdentities();

                // item must have category "proxy" and type "bytestream"
                while (identities.hasNext()) {
                    Identity identity = identities.next();
View Full Code Here

Examples of org.jivesoftware.smackx.ServiceDiscoveryManager

    /**
     * Adds the SOCKS5 Bytestream feature to the service discovery.
     */
    private void enableService() {
        ServiceDiscoveryManager manager = ServiceDiscoveryManager.getInstanceFor(this.connection);
        if (!manager.includesFeature(NAMESPACE)) {
            manager.addFeature(NAMESPACE);
        }
    }
View Full Code Here

Examples of org.jivesoftware.smackx.ServiceDiscoveryManager

     * to see if the email service has been configured and is available.
     *
     * @return true if the email service is available, otherwise return false.
     */
    public boolean isEmailAvailable() {
        ServiceDiscoveryManager discoManager = ServiceDiscoveryManager.getInstanceFor(connection);

        try {
            String workgroupService = StringUtils.parseServer(workgroupJID);
            DiscoverInfo infoResult = discoManager.discoverInfo(workgroupService);
            return infoResult.containsFeature("jive:email:provider");
        }
        catch (XMPPException e) {
            return false;
        }
View Full Code Here

Examples of org.jivesoftware.smackx.ServiceDiscoveryManager

     * @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) {
View Full Code Here

Examples of org.jivesoftware.smackx.ServiceDiscoveryManager

     * @throws XMPPException if an error occured while trying to discover the information.
     */
    public static Collection<HostedRoom> getHostedRooms(Connection connection, String serviceName)
            throws XMPPException {
        List<HostedRoom> answer = new ArrayList<HostedRoom>();
        ServiceDiscoveryManager discoManager = ServiceDiscoveryManager.getInstanceFor(connection);
        DiscoverItems items = discoManager.discoverItems(serviceName);
        for (Iterator<DiscoverItems.Item> it = items.getItems(); it.hasNext();) {
            answer.add(new HostedRoom(it.next()));
        }
        return answer;
    }
View Full Code Here

Examples of org.jivesoftware.smackx.ServiceDiscoveryManager

   * @throws XMPPException
   */
  public DiscoverInfo getSupportedFeatures()
    throws XMPPException
  {
    ServiceDiscoveryManager mgr = ServiceDiscoveryManager.getInstanceFor(con);
    return mgr.discoverInfo(to);
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.