use of org.jivesoftware.smackx.disco.ServiceDiscoveryManager in project Smack by igniterealtime.
the class PEPManager method isSupported.
public boolean isSupported() throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException {
XMPPConnection connection = connection();
ServiceDiscoveryManager serviceDiscoveryManager = ServiceDiscoveryManager.getInstanceFor(connection);
BareJid localBareJid = connection.getUser().asBareJid();
return serviceDiscoveryManager.supportsFeatures(localBareJid, REQUIRED_FEATURES);
}
use of org.jivesoftware.smackx.disco.ServiceDiscoveryManager in project Smack by igniterealtime.
the class MultiUserChatManager method getHostedRooms.
/**
* Returns a List of HostedRooms where each HostedRoom has the XMPP address of the room and the room's name.
* Once discovered the rooms hosted by a chat service it is possible to discover more detailed room information or
* join the room.
*
* @param serviceName the service that is hosting the rooms to discover.
* @return a collection of HostedRooms.
* @throws XMPPErrorException
* @throws NoResponseException
* @throws NotConnectedException
* @throws InterruptedException
* @throws NotAMucServiceException
*/
public List<HostedRoom> getHostedRooms(DomainBareJid serviceName) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException, NotAMucServiceException {
if (!providesMucService(serviceName)) {
throw new NotAMucServiceException(serviceName);
}
ServiceDiscoveryManager discoManager = ServiceDiscoveryManager.getInstanceFor(connection());
DiscoverItems discoverItems = discoManager.discoverItems(serviceName);
List<DiscoverItems.Item> items = discoverItems.getItems();
List<HostedRoom> answer = new ArrayList<HostedRoom>(items.size());
for (DiscoverItems.Item item : items) {
answer.add(new HostedRoom(item));
}
return answer;
}
use of org.jivesoftware.smackx.disco.ServiceDiscoveryManager in project xabber-android by redsolution.
the class HttpFileUploadManager method discoverSupport.
private void discoverSupport(XMPPConnection xmppConnection) throws SmackException.NotConnectedException, XMPPException.XMPPErrorException, SmackException.NoResponseException {
final String account = xmppConnection.getUser();
uploadServers.remove(account);
ServiceDiscoveryManager discoManager = ServiceDiscoveryManager.getInstanceFor(xmppConnection);
List<String> services = discoManager.findServices(Request.NAMESPACE, true, true);
if (!services.isEmpty()) {
final String uploadServerUrl = services.get(0);
if (!uploadServerUrl.isEmpty()) {
LogManager.i(this, "Http file upload server: " + uploadServerUrl);
uploadServers.put(account, uploadServerUrl);
}
}
}
use of org.jivesoftware.smackx.disco.ServiceDiscoveryManager in project Spark by igniterealtime.
the class RoomBrowser method displayRoomInformation.
public void displayRoomInformation(final String roomJID) {
SwingWorker worker = new SwingWorker() {
RoomInfo roomInfo = null;
DiscoverItems items = null;
public Object construct() {
try {
roomInfo = MultiUserChatManager.getInstanceFor(SparkManager.getConnection()).getRoomInfo(roomJID);
ServiceDiscoveryManager manager = ServiceDiscoveryManager.getInstanceFor(SparkManager.getConnection());
items = manager.discoverItems(roomJID);
} catch (XMPPException | SmackException e) {
Log.error(e);
}
return "ok";
}
public void finished() {
setupRoomInformationUI(roomJID, roomInfo, items);
}
};
worker.start();
}
use of org.jivesoftware.smackx.disco.ServiceDiscoveryManager in project Spark by igniterealtime.
the class BookmarksUI method getConferenceServices.
private Collection<String> getConferenceServices(String server) throws Exception {
List<String> answer = new ArrayList<>();
ServiceDiscoveryManager discoManager = ServiceDiscoveryManager.getInstanceFor(SparkManager.getConnection());
DiscoverItems items = discoManager.discoverItems(server);
for (DiscoverItems.Item item : items.getItems()) {
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 | SmackException e) {
Log.error("Problem when loading conference service.", e);
}
}
}
return answer;
}
Aggregations