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")) {
registration.setUsername(parser.nextText());
}
else if (parser.getName().equals("password")) {
registration.setPassword(parser.nextText());
}
// 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 {
registration.setInstructions(value);
}
}
// Otherwise, it must be a packet extension.
else {
registration.addExtension(
PacketParserUtils.parsePacketExtension(
parser.getName(),
parser.getNamespace(),
parser));
}
}
else if (eventType == XmlPullParser.END_TAG) {
if (parser.getName().equals("query")) {
done = true;
}
}
}
registration.setAttributes(fields);
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?
Thanks,
Adam Olsen