1
0
Fork 0
mirror of https://codeberg.org/Mercury-IM/Smack synced 2024-11-22 14:22:05 +01:00

Add MultiUserChatManager.getMucServiceDomains()

and deprecate getXMPPServiceDomains().
This commit is contained in:
Florian Schmaus 2018-04-18 09:11:04 +02:00
parent 5fbf2ce75a
commit 4fb34a6952
3 changed files with 23 additions and 7 deletions

View file

@ -1,6 +1,6 @@
/** /**
* *
* Copyright © 2014-2017 Florian Schmaus * Copyright © 2014-2018 Florian Schmaus
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -338,11 +338,27 @@ public final class MultiUserChatManager extends Manager {
* @throws NotConnectedException * @throws NotConnectedException
* @throws InterruptedException * @throws InterruptedException
*/ */
public List<DomainBareJid> getXMPPServiceDomains() throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException { public List<DomainBareJid> getMucServiceDomains() throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException {
ServiceDiscoveryManager sdm = ServiceDiscoveryManager.getInstanceFor(connection()); ServiceDiscoveryManager sdm = ServiceDiscoveryManager.getInstanceFor(connection());
return sdm.findServices(MUCInitialPresence.NAMESPACE, false, false); return sdm.findServices(MUCInitialPresence.NAMESPACE, false, false);
} }
/**
* Returns a collection with the XMPP addresses of the Multi-User Chat services.
*
* @return a collection with the XMPP addresses of the Multi-User Chat services.
* @throws XMPPErrorException
* @throws NoResponseException
* @throws NotConnectedException
* @throws InterruptedException
* @deprecated use {@link #getMucServiceDomains()} instead.
*/
// TODO: Remove in Smack 4.5
@Deprecated
public List<DomainBareJid> getXMPPServiceDomains() throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException {
return getMucServiceDomains();
}
/** /**
* Check if the provided domain bare JID provides a MUC service. * Check if the provided domain bare JID provides a MUC service.
* *

View file

@ -1,6 +1,6 @@
/** /**
* *
* Copyright 2015 Florian Schmaus * Copyright 2015-2018 Florian Schmaus
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -52,7 +52,7 @@ public class MultiUserChatIntegrationTest extends AbstractSmackIntegrationTest {
mucManagerOne = MultiUserChatManager.getInstanceFor(conOne); mucManagerOne = MultiUserChatManager.getInstanceFor(conOne);
mucManagerTwo = MultiUserChatManager.getInstanceFor(conTwo); mucManagerTwo = MultiUserChatManager.getInstanceFor(conTwo);
List<DomainBareJid> services = mucManagerOne.getXMPPServiceDomains(); List<DomainBareJid> services = mucManagerOne.getMucServiceDomains();
if (services.isEmpty()) { if (services.isEmpty()) {
throw new TestNotPossibleException("No MUC (XEP-45) service found"); throw new TestNotPossibleException("No MUC (XEP-45) service found");
} }

View file

@ -1,6 +1,6 @@
/** /**
* *
* Copyright 2015 Florian Schmaus * Copyright 2015-2018 Florian Schmaus
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -45,7 +45,7 @@ public class MultiUserChatLowLevelIntegrationTest extends AbstractSmackLowLevelI
performCheck(new ConnectionCallback() { performCheck(new ConnectionCallback() {
@Override @Override
public void connectionCallback(XMPPTCPConnection connection) throws Exception { public void connectionCallback(XMPPTCPConnection connection) throws Exception {
if (MultiUserChatManager.getInstanceFor(connection).getXMPPServiceDomains().isEmpty()) { if (MultiUserChatManager.getInstanceFor(connection).getMucServiceDomains().isEmpty()) {
throw new TestNotPossibleException("MUC component not offered by service"); throw new TestNotPossibleException("MUC component not offered by service");
} }
} }
@ -62,7 +62,7 @@ public class MultiUserChatLowLevelIntegrationTest extends AbstractSmackLowLevelI
final MultiUserChatManager multiUserChatManager = MultiUserChatManager.getInstanceFor(connection); final MultiUserChatManager multiUserChatManager = MultiUserChatManager.getInstanceFor(connection);
final Resourcepart mucNickname = Resourcepart.from("Nick-" + StringUtils.randomString(6)); final Resourcepart mucNickname = Resourcepart.from("Nick-" + StringUtils.randomString(6));
final String randomMucName = StringUtils.randomString(6); final String randomMucName = StringUtils.randomString(6);
final DomainBareJid mucComponent = multiUserChatManager.getXMPPServiceDomains().get(0); final DomainBareJid mucComponent = multiUserChatManager.getMucServiceDomains().get(0);
final MultiUserChat muc = multiUserChatManager.getMultiUserChat(JidCreate.entityBareFrom( final MultiUserChat muc = multiUserChatManager.getMultiUserChat(JidCreate.entityBareFrom(
Localpart.from(randomMucName), mucComponent)); Localpart.from(randomMucName), mucComponent));