/** * Enable the Jabber services related to file transfer on the particular * connection. * * @param connection The connection on which to enable or disable the services. * @param isEnabled True to enable, false to disable. */ public static void setServiceEnabled(final XMPPConnection connection, final boolean isEnabled) { ServiceDiscoveryManager manager = ServiceDiscoveryManager .getInstanceFor(connection); for (int i = 0; i < NAMESPACE.length; i++) { if (isEnabled) { manager.addFeature(NAMESPACE[i]); } else { manager.removeFeature(NAMESPACE[i]); } } }
/** * Gets the supported features of the servers pubsub implementation * as a standard {@link DiscoverInfo} instance. * * @return The supported features * * @throws XMPPException */ public DiscoverInfo getSupportedFeatures() throws XMPPException { ServiceDiscoveryManager mgr = ServiceDiscoveryManager.getInstanceFor(con); return mgr.discoverInfo(to); }
/** * Discover the commands of an specific JID. The <code>jid</code> is a * full JID. * * @param jid the full JID to retrieve the commands for. * @return the discovered items. * @throws XMPPException if the operation failed for some reason. */ public DiscoverItems discoverCommands(String jid) throws XMPPException { ServiceDiscoveryManager serviceDiscoveryManager = ServiceDiscoveryManager .getInstanceFor(connection); return serviceDiscoveryManager.discoverItems(jid, discoNode); }
/** * Returns true if the XHTML support is enabled for the given connection. * * @param connection the connection to look for XHTML support * @return a boolean indicating if the XHTML support is enabled for the given connection */ public static boolean isServiceEnabled(Connection connection) { return ServiceDiscoveryManager.getInstanceFor(connection).includesFeature(namespace); }
/** * 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); } }
/** * Enable the Jabber services related to file transfer on the particular * connection. * * @param connection The connection on which to enable or disable the services. * @param isEnabled True to enable, false to disable. */ public static void setServiceEnabled(final Connection connection, final boolean isEnabled) { ServiceDiscoveryManager manager = ServiceDiscoveryManager .getInstanceFor(connection); List<String> namespaces = new ArrayList<String>(); namespaces.addAll(Arrays.asList(NAMESPACE)); namespaces.add(InBandBytestreamManager.NAMESPACE); if (!IBB_ONLY) { namespaces.add(Socks5BytestreamManager.NAMESPACE); } for (String namespace : namespaces) { if (isEnabled) { if (!manager.includesFeature(namespace)) { manager.addFeature(namespace); } } else { manager.removeFeature(namespace); } } }
synchronized(packetReader) { ServiceDiscoveryManager discoManager = ServiceDiscoveryManager.getInstanceFor(this); discoManager.setIdentityName("smack component"); discoManager.setIdentityType("smack"); discoManager.setIdentityCategory("component"); discoManager.removeFeature("http://jabber.org/protocol/xhtml-im"); discoManager.removeFeature("http://jabber.org/protocol/muc");
/** * 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; }
private CarbonManager(Connection connection) { ServiceDiscoveryManager sdm = ServiceDiscoveryManager.getInstanceFor(connection); sdm.addFeature(Carbon.NAMESPACE); this.connection = connection; instances.put(connection, this); }
public void connectionEstablished(final XMPPConnection connection) { // Set on every established connection that this client supports the Multi-User // Chat protocol. This information will be used when another client tries to // discover whether this client supports MUC or not. ServiceDiscoveryManager.getInstanceFor(connection).addFeature(discoNamespace); // Set the NodeInformationProvider that will provide information about the // joined rooms whenever a disco request is received ServiceDiscoveryManager.getInstanceFor(connection).setNodeInformationProvider( discoNode, new NodeInformationProvider() { public Iterator getNodeItems() { ArrayList answer = new ArrayList(); Iterator rooms=MultiUserChat.getJoinedRooms(connection); while (rooms.hasNext()) { answer.add(new DiscoverItems.Item((String)rooms.next())); } return answer.iterator(); } }); } });
ServiceDiscoveryManager serviceDiscoveryManager = ServiceDiscoveryManager.getInstanceFor(this.connection); serviceDiscoveryManager.removeFeature(NAMESPACE);
/** * 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); }
getIdentityName()); identity.setType(getIdentityType()); response.addIdentity(identity); for (Iterator<String> it = getFeatures(); it.hasNext();) { response.addFeature(it.next());
/** * Returns the discovered information of a given XMPP entity addressed by its JID. * * @param entityID the address of the XMPP entity. * @return the discovered information. * @throws XMPPException if the operation failed for some reason. */ public DiscoverInfo discoverInfo(String entityID) throws XMPPException { return discoverInfo(entityID, null); }
DiscoverInfo.Identity identity = new DiscoverInfo.Identity(getIdentityCategory(), getIdentityName()); identity.setType(getIdentityType()); response.addIdentity(identity); for (Iterator it = getFeatures(); it.hasNext();) { response.addFeature((String) it.next());
/** * Returns the discovered items of a given XMPP entity addressed by its JID. * * @param entityID the address of the XMPP entity. * @return the discovered information. * @throws XMPPException if the operation failed for some reason. */ public DiscoverItems discoverItems(String entityID) throws XMPPException { return discoverItems(entityID, null); }
/** * Returns true if the server supports publishing of items. A client may wish to publish items * to the server so that the server can provide items associated to the client. These items will * be returned by the server whenever the server receives a disco request targeted to the bare * address of the client (i.e. user@host.com). * * @param entityID the address of the XMPP entity. * @return true if the server supports publishing of items. * @throws XMPPException if the operation failed for some reason. */ public boolean canPublishItems(String entityID) throws XMPPException { DiscoverInfo info = discoverInfo(entityID); return canPublishItems(info); }
/** * Creates a new ServiceDiscoveryManager for a given XMPPConnection. This means that the * service manager will respond to any service discovery request that the connection may * receive. * * @param connection the connection to which a ServiceDiscoveryManager is going to be created. */ public ServiceDiscoveryManager(XMPPConnection connection) { this.connection = connection; init(); }
public void connectionCreated(Connection connection) { new ServiceDiscoveryManager(connection); } });
/** * Publishes new items to a parent entity. 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 discoverItems the DiscoveryItems to publish. * @throws XMPPException if the operation failed for some reason. */ public void publishItems(String entityID, DiscoverItems discoverItems) throws XMPPException { publishItems(entityID, null, discoverItems); }