From ecd9a66d4198c993bfe7a451aa312fe62047c3a2 Mon Sep 17 00:00:00 2001 From: Boris Grozev Date: Thu, 28 Feb 2013 12:26:45 +0000 Subject: [PATCH] Checks for inband registration support via disco#info, instead of using the smack AccountManager.supportsAccountCreation() method. --- .../OperationSetChangePasswordJabberImpl.java | 34 ++++++++++++++----- .../ProtocolProviderServiceJabberImpl.java | 5 +++ 2 files changed, 31 insertions(+), 8 deletions(-) diff --git a/src/net/java/sip/communicator/impl/protocol/jabber/OperationSetChangePasswordJabberImpl.java b/src/net/java/sip/communicator/impl/protocol/jabber/OperationSetChangePasswordJabberImpl.java index b187c0e9b..ace9bf677 100644 --- a/src/net/java/sip/communicator/impl/protocol/jabber/OperationSetChangePasswordJabberImpl.java +++ b/src/net/java/sip/communicator/impl/protocol/jabber/OperationSetChangePasswordJabberImpl.java @@ -8,6 +8,7 @@ import net.java.sip.communicator.service.protocol.*; import net.java.sip.communicator.util.*; import org.jivesoftware.smack.*; +import org.jivesoftware.smackx.packet.*; /** * A jabber implementation of the password change operation set. @@ -72,17 +73,34 @@ public void changePassword(String newPass) } /** - * Returns true if the server supports password changes. This uses smack's - * AccountManager#supportsAccountCreation method, which checks for - * XEP-0077 (inband registrations) support. + * Returns true if the server supports password changes. Checks for + * XEP-0077 (inband registrations) support via disco#info. + * * @return True if the server supports password changes, false otherwise. */ public boolean supportsPasswordChange() { - org.jivesoftware.smack.AccountManager accountManager - = new org.jivesoftware.smack.AccountManager( - protocolProvider.getConnection()); - - return accountManager.supportsAccountCreation(); + try + { + DiscoverInfo discoverInfo + = protocolProvider.getDiscoveryManager() + .discoverInfo( + protocolProvider.getAccountID().getService()); + return discoverInfo.containsFeature( + ProtocolProviderServiceJabberImpl.URN_REGISTER); + } + catch(Exception e) + { + if(logger.isInfoEnabled()) + logger.info("Exception occurred while trying to find out if" + + " inband registrations are supported. Returning true" + + "anyway."); + /* It makes sense to return true if something goes wrong, because + failing later on is not fatal, and registrations are very + likely to be supported. + */ + return true; + } + } } diff --git a/src/net/java/sip/communicator/impl/protocol/jabber/ProtocolProviderServiceJabberImpl.java b/src/net/java/sip/communicator/impl/protocol/jabber/ProtocolProviderServiceJabberImpl.java index 06078dd83..d9ea9ac93 100644 --- a/src/net/java/sip/communicator/impl/protocol/jabber/ProtocolProviderServiceJabberImpl.java +++ b/src/net/java/sip/communicator/impl/protocol/jabber/ProtocolProviderServiceJabberImpl.java @@ -171,6 +171,11 @@ public class ProtocolProviderServiceJabberImpl public static final String URN_GOOGLE_VIDEO = "http://www.google.com/xmpp/protocol/video/v1"; + /** + * URN for XEP-0077 inband registration + */ + public static final String URN_REGISTER = "jabber:iq:register"; + /** * The name of the property under which the user may specify if the desktop * streaming or sharing should be disabled.