mirror of
https://codeberg.org/Mercury-IM/Smack
synced 2024-11-22 06:12:05 +01:00
Check that service is MUC service in getHostedRooms()
and otherwhise throw a NotAMucServiceException.
This commit is contained in:
parent
2e03f0f3f3
commit
19ebcb814b
2 changed files with 13 additions and 2 deletions
|
@ -17,6 +17,7 @@
|
|||
package org.jivesoftware.smackx.muc;
|
||||
|
||||
import org.jivesoftware.smack.SmackException;
|
||||
import org.jxmpp.jid.DomainBareJid;
|
||||
|
||||
public abstract class MultiUserChatException extends SmackException {
|
||||
|
||||
|
@ -96,7 +97,12 @@ public abstract class MultiUserChatException extends SmackException {
|
|||
*/
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
public NotAMucServiceException(MultiUserChat multiUserChat) {
|
||||
NotAMucServiceException(DomainBareJid service) {
|
||||
super("Can't perform operation because " + service
|
||||
+ " does not provide a MUC (XEP-45) service.");
|
||||
}
|
||||
|
||||
NotAMucServiceException(MultiUserChat multiUserChat) {
|
||||
super("Can not join '" + multiUserChat.getRoom() + "', because '"
|
||||
+ multiUserChat.getRoom().asDomainBareJid()
|
||||
+ "' does not provide a MUC (XEP-45) service.");
|
||||
|
|
|
@ -48,6 +48,7 @@ import org.jivesoftware.smackx.disco.AbstractNodeInformationProvider;
|
|||
import org.jivesoftware.smackx.disco.ServiceDiscoveryManager;
|
||||
import org.jivesoftware.smackx.disco.packet.DiscoverInfo;
|
||||
import org.jivesoftware.smackx.disco.packet.DiscoverItems;
|
||||
import org.jivesoftware.smackx.muc.MultiUserChatException.NotAMucServiceException;
|
||||
import org.jivesoftware.smackx.muc.packet.MUCInitialPresence;
|
||||
import org.jivesoftware.smackx.muc.packet.MUCUser;
|
||||
import org.jxmpp.jid.EntityBareJid;
|
||||
|
@ -290,9 +291,13 @@ public final class MultiUserChatManager extends Manager {
|
|||
* @throws NoResponseException
|
||||
* @throws NotConnectedException
|
||||
* @throws InterruptedException
|
||||
* @throws NotAMucServiceException
|
||||
*/
|
||||
public List<HostedRoom> getHostedRooms(DomainBareJid serviceName) throws NoResponseException, XMPPErrorException,
|
||||
NotConnectedException, InterruptedException {
|
||||
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();
|
||||
|
|
Loading…
Reference in a new issue