powered by Jive Software

PacketReader.java change request

I would like to request that the current parseRegistration method in org.jivesoftware.smack.PacketReader.java be changed to something like this:

private Registration parseRegistration(XmlPullParser parser) throws Exception {
        Registration registration = new Registration();
        Map fields = null;
        boolean done = false;
        while (!done) {
            int eventType = parser.next();
            if (eventType == XmlPullParser.START_TAG) {
                if (parser.getName().equals("username")) {
                else if (parser.getName().equals("password")) {
                // Else if any other element that''s in the jabber:iq:register namespace,
                // attempt to parse it if it''s in the form <name>value</name>.
                else if (parser.getNamespace().equals("jabber:iq:register")) {
                    String name = parser.getName();                          // add the key whether or not the value contains anything
                         // for creating registration forms
                         String value = "";                     if (parser.next() == XmlPullParser.TEXT) {
                        value = parser.getText();
                         }                          // Ignore instructions, but anything else should be added to the map.
                         if (!name.equals("instructions")) {
                              if (fields == null) {
                                   fields = new HashMap();
                              fields.put(name, value);
                         else {
                // Otherwise, it must be a packet extension.
                else {
            else if (eventType == XmlPullParser.END_TAG) {
                if (parser.getName().equals("query")) {
                    done = true;
        return registration;

The reason I ask this is I can use the Registration packet for registering to services other than a Jabber server… but I need the keys to be added to the attributes even if they don’'t contain a value. Could this also be used for collecting Registration information from a jabber server?


Adam Olsen

If this change isn’‘t in smack’'s best interest, is there a way I can add my own provider for jabber:iq:register without effecting the built in one?



Sorry for the late reply. Your proposition is in our pending list. FYI, from my first impression it seems to be a safe modification so it’'s possible that we will include it.


– Gato

I can’‘t think of any major reasons that this change would be a problem to put in Smack core. I also agree that registration should be more configurable – this will likely be handled by Smack 2.0. In any case, I’'ll file a bug so that this change goes in for the next release.



Heh. I guess I was in the posting process when Gato got to the message first.


Very cool, thanks guys.

Good to see you on, Matt… it’‘s been a month or so since I’'ve seen a post from you

Very cool, thanks guys.

Good to see you on, Matt… it’'s been a month or so

since I’'ve seen a post from you

Has it been that long? I’‘ve been reading everything in the forums to be sure. Also, I’'ve been busy recently with an upcoming Smack extension for a new JEP that we (Jive) have submitted. The JEP is at: