AnsweredAssumed Answered

Smack 4.2.0-beta3 AbstractXMPPConnection#parseFeatures missing case for stream feature <register xmlns='http://jabber.org/features/iq-register'/>

Question asked by cmeng on Dec 31, 2016
Latest reply on Jan 1, 2017 by cmeng

For XMPP server that supports "iq-register", following <stream:features/> is send during initial connection:

 

01-01 07:13:53.675 11086-26982/org.atalk.android D/SMACK: RECV (5): <stream:features><c xmlns='http://jabber.org/protocol/caps' hash='sha-1' node='http://www.process-one.net/en/ejabberd/' ver='xPSMVlLIKeByCDbCp8QJ1d0gn9Q='/><register xmlns='http://jabber.org/features/iq-register'/><mechanisms xmlns='urn:ietf:params:xml:ns:xmpp-sasl'><mechanism>SCRAM-SHA-1</mechanism><mec hanism>PLAIN</mechanism><mechanism>X-OAUTH2</mechanism></mechanisms></stream:fea tures>

 

However Smack AbstractXMPPConnection#parseFeatures method does not include a case to capture the stream feature <register xmlns='http://jabber.org/features/iq-register'/> as attached below:

/** ======================================================

protected final void parseFeatures(XmlPullParser parser) throws Exception {
   streamFeatures.clear();
   final int initialDepth = parser.getDepth();
   while (true) {
   int eventType = parser.next();

   if (eventType == XmlPullParser.START_TAG && parser.getDepth() == initialDepth + 1) {
   ExtensionElement streamFeature = null;
   String name = parser.getName();
   String namespace = parser.getNamespace();
   switch (name) {
   case StartTls.ELEMENT:
   streamFeature = PacketParserUtils.parseStartTlsFeature(parser);
   break;
   case Mechanisms.ELEMENT:
   streamFeature = new Mechanisms(PacketParserUtils.parseMechanisms(parser));
   break;
   case Bind.ELEMENT:
   streamFeature = Bind.Feature.INSTANCE;
   break;
   case Session.ELEMENT:
   streamFeature = PacketParserUtils.parseSessionFeature(parser);
   break;
   case Compress.Feature.ELEMENT:
   streamFeature = PacketParserUtils.parseCompressionFeature(parser);
   break;
   default:
   ExtensionElementProvider<ExtensionElement> provider = ProviderManager.getStreamFeatureProvider(name, namespace);
   if (provider != null) {
   streamFeature = provider.parse(parser);
   }
   break;
   }
   if (streamFeature != null) {
  addStreamFeature(streamFeature);
   }
  }
   else if (eventType == XmlPullParser.END_TAG && parser.getDepth() == initialDepth) {
   break;
   }
  }

==================================================== **/

 

Also the AccountManager#isSupported is checking against this feature using

public static final String ELEMENT = "query";
public static final String NAMESPACE = "jabber:iq:register";

 

//====================================================================

public boolean isSupported()
   throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException {
   XMPPConnection connection = connection();

   ExtensionElement extensionElement = connection.getFeature(Registration.ELEMENT, Registration.NAMESPACE);
   if (extensionElement != null) {
   return true;
   }

   return ServiceDiscoveryManager.getInstanceFor(connection).serverSupportsFeature(Registration.NAMESPACE);
}

Outcomes