Client does not parse packet extensions properly

Hi,

I am using the DefaultPacketExtension class to get Jabber events from messages. The XML messages arrive at my client in proper form:

chat_1

chat_1


However, after parsing, the “map” member variable of the DefaultPacketExtension instance is NULL, and does not contain any of the inner properties of the extension. Therefore, I cannot determine if the packet extension indicates a “composing” event, nor can I get the ID from the packet extension. The parsed packet extension DOES contain the element name and the namespace, but that’'s it.

Creating a packet extension with these properties and sending it embedded in a message packet works fine.

Any ideas?

Thanks,

Aman

Aman,

I’‘ll try to take a look at this issue tonight to figure out what’'s up.

Thanks,

matt

Looks like it doesn’'t map an empty tag and a missing assignment is preventing tag text from getting saved.

Here’'s a fix for parsePacketExtention that just add the check for empty tag and add the missing eventType assignment:

// No providers registered, so use a default extension.
        DefaultPacketExtension extension = new DefaultPacketExtension(elementName, namespace);
        boolean done = false;
        while (!done) {
            int eventType = parser.next();
            if (eventType == XmlPullParser.START_TAG) {
                String name = parser.getName();
                if (parser.isEmptyElementTag()) {
                    extension.setValue(name,"");
                }                 else {
                    eventType = parser.next();
                    if (eventType == XmlPullParser.TEXT) {
                        String value = parser.getText();
                     extension.setValue(name, value);
                    }
                }
            }
            else if (eventType == XmlPullParser.END_TAG) {
                if (parser.getName().equals(elementName)) {
                    done = true;
                }
            }
        }

Take care,

John

John,

Thanks for the patch! I’'ll get this applied to the code base tonight. Your name will most definitely appear in the next changelog.

-Matt

…that way they know who to blame eh?

The change is now in CVS so it will appear in tomorrow’'s daily build. Let me know how it works!

-Matt