mirror of
https://codeberg.org/Mercury-IM/Smack
synced 2024-11-22 06:12:05 +01:00
Merge pull request #301 from adiaholic/JIRA836
Saving an instance of ServiceDiscoveryManager in MultiUserChatManager.
This commit is contained in:
commit
0cd3318b12
1 changed files with 9 additions and 8 deletions
|
@ -152,8 +152,11 @@ public final class MultiUserChatManager extends Manager {
|
||||||
|
|
||||||
private AutoJoinFailedCallback autoJoinFailedCallback;
|
private AutoJoinFailedCallback autoJoinFailedCallback;
|
||||||
|
|
||||||
|
private final ServiceDiscoveryManager serviceDiscoveryManager;
|
||||||
|
|
||||||
private MultiUserChatManager(XMPPConnection connection) {
|
private MultiUserChatManager(XMPPConnection connection) {
|
||||||
super(connection);
|
super(connection);
|
||||||
|
serviceDiscoveryManager = ServiceDiscoveryManager.getInstanceFor(connection);
|
||||||
// Listens for all messages that include a MUCUser extension and fire the invitation
|
// Listens for all messages that include a MUCUser extension and fire the invitation
|
||||||
// listeners if the message includes an invitation.
|
// listeners if the message includes an invitation.
|
||||||
StanzaListener invitationPacketListener = new StanzaListener() {
|
StanzaListener invitationPacketListener = new StanzaListener() {
|
||||||
|
@ -277,7 +280,7 @@ public final class MultiUserChatManager extends Manager {
|
||||||
* @throws InterruptedException
|
* @throws InterruptedException
|
||||||
*/
|
*/
|
||||||
public boolean isServiceEnabled(Jid user) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException {
|
public boolean isServiceEnabled(Jid user) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException {
|
||||||
return ServiceDiscoveryManager.getInstanceFor(connection()).supportsFeature(user, MUCInitialPresence.NAMESPACE);
|
return serviceDiscoveryManager.supportsFeature(user, MUCInitialPresence.NAMESPACE);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -304,7 +307,7 @@ public final class MultiUserChatManager extends Manager {
|
||||||
public List<EntityBareJid> getJoinedRooms(EntityJid user) throws NoResponseException, XMPPErrorException,
|
public List<EntityBareJid> getJoinedRooms(EntityJid user) throws NoResponseException, XMPPErrorException,
|
||||||
NotConnectedException, InterruptedException {
|
NotConnectedException, InterruptedException {
|
||||||
// Send the disco packet to the user
|
// Send the disco packet to the user
|
||||||
DiscoverItems result = ServiceDiscoveryManager.getInstanceFor(connection()).discoverItems(user, DISCO_NODE);
|
DiscoverItems result = serviceDiscoveryManager.discoverItems(user, DISCO_NODE);
|
||||||
List<DiscoverItems.Item> items = result.getItems();
|
List<DiscoverItems.Item> items = result.getItems();
|
||||||
List<EntityBareJid> answer = new ArrayList<>(items.size());
|
List<EntityBareJid> answer = new ArrayList<>(items.size());
|
||||||
// Collect the entityID for each returned item
|
// Collect the entityID for each returned item
|
||||||
|
@ -331,7 +334,7 @@ public final class MultiUserChatManager extends Manager {
|
||||||
* @throws InterruptedException
|
* @throws InterruptedException
|
||||||
*/
|
*/
|
||||||
public RoomInfo getRoomInfo(EntityBareJid room) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException {
|
public RoomInfo getRoomInfo(EntityBareJid room) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException {
|
||||||
DiscoverInfo info = ServiceDiscoveryManager.getInstanceFor(connection()).discoverInfo(room);
|
DiscoverInfo info = serviceDiscoveryManager.discoverInfo(room);
|
||||||
return new RoomInfo(info);
|
return new RoomInfo(info);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -345,8 +348,7 @@ public final class MultiUserChatManager extends Manager {
|
||||||
* @throws InterruptedException
|
* @throws InterruptedException
|
||||||
*/
|
*/
|
||||||
public List<DomainBareJid> getMucServiceDomains() throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException {
|
public List<DomainBareJid> getMucServiceDomains() throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException {
|
||||||
ServiceDiscoveryManager sdm = ServiceDiscoveryManager.getInstanceFor(connection());
|
return serviceDiscoveryManager.findServices(MUCInitialPresence.NAMESPACE, false, false);
|
||||||
return sdm.findServices(MUCInitialPresence.NAMESPACE, false, false);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -379,7 +381,7 @@ public final class MultiUserChatManager extends Manager {
|
||||||
*/
|
*/
|
||||||
public boolean providesMucService(DomainBareJid domainBareJid) throws NoResponseException,
|
public boolean providesMucService(DomainBareJid domainBareJid) throws NoResponseException,
|
||||||
XMPPErrorException, NotConnectedException, InterruptedException {
|
XMPPErrorException, NotConnectedException, InterruptedException {
|
||||||
return ServiceDiscoveryManager.getInstanceFor(connection()).supportsFeature(domainBareJid,
|
return serviceDiscoveryManager.supportsFeature(domainBareJid,
|
||||||
MUCInitialPresence.NAMESPACE);
|
MUCInitialPresence.NAMESPACE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -402,8 +404,7 @@ public final class MultiUserChatManager extends Manager {
|
||||||
if (!providesMucService(serviceName)) {
|
if (!providesMucService(serviceName)) {
|
||||||
throw new NotAMucServiceException(serviceName);
|
throw new NotAMucServiceException(serviceName);
|
||||||
}
|
}
|
||||||
ServiceDiscoveryManager discoManager = ServiceDiscoveryManager.getInstanceFor(connection());
|
DiscoverItems discoverItems = serviceDiscoveryManager.discoverItems(serviceName);
|
||||||
DiscoverItems discoverItems = discoManager.discoverItems(serviceName);
|
|
||||||
List<DiscoverItems.Item> items = discoverItems.getItems();
|
List<DiscoverItems.Item> items = discoverItems.getItems();
|
||||||
|
|
||||||
Map<EntityBareJid, HostedRoom> answer = new HashMap<>(items.size());
|
Map<EntityBareJid, HostedRoom> answer = new HashMap<>(items.size());
|
||||||
|
|
Loading…
Reference in a new issue