powered by Jive Software

Smack 4.4.0-alpha2: XmlStringBuilder.attribute(String name, Enum<?> value) method is not working in android

In aTalk Jingle class, in the override method:
IQChildElementXmlStringBuilder getIQChildElementBuilder(IQChildElementXmlStringBuilder xml)

When the statement below
xml.attribute(ACTION_ATTR_NAME, getAction());

call with getAction() as Enum to method

XmlStringBuilder#attribute(String name, Enum<?> value)

aTalk media call will failed. instead has to force to use:

xml.attribute(ACTION_ATTR_NAME, getAction().toString()); // must use toString()

Both aTalk and smack JingleAction class does not implement method name()?

That post is missing one important piece of information: A description how the “aTalk media call … failed” actually failed. You usually want to include

  • what did happen
  • what you expect to happen instead

in any of your reports.

Every Enum implements name():
https://docs.oracle.com/javase/8/docs/api/java/lang/Enum.html#name()

There is a slight difference in aTalk and smack JingleAction enum implementation:

Each aTalk enum element is specified as e.g.:
SESSION_INITIATE("session-initiate"),

whereas smack enum is specified as:
session_initiate,

The return value of enum.name() is
“SESSION_INITIATE” and “session_initiate” for aTalk and smack respectively

However the value of enum.toString() for both gives
“session-initiate”

which will only produce the correct action attribute in the jingle stanza.

<jingle xmlns='urn:xmpp:jingle:1' initiator='swordfish@atalk.org/atalk' action='session-initiate' sid='29p13n0spj735'>

When method enum.name() is used, the following stanza is being generated, and therefore cannot be understood by the recipient.

<jingle xmlns='urn:xmpp:jingle:1' initiator='swordfish@atalk.org/atalk' action='SESSION_INITIATE' sid='3qv5a1rfv8nof'>

Thanks, now I understood what you are talking about :slight_smile:

Should be fixed with: