use of org.jivesoftware.smackx.iqregister.packet.Registration in project Smack by igniterealtime.
the class RegistrationProvider method parse.
@Override
public Registration parse(XmlPullParser parser, int initialDepth) throws Exception {
String instruction = null;
Map<String, String> fields = new HashMap<String, String>();
List<ExtensionElement> packetExtensions = new LinkedList<ExtensionElement>();
outerloop: while (true) {
int eventType = parser.next();
if (eventType == XmlPullParser.START_TAG) {
// attempt to parse it if it's in the form <name>value</name>.
if (parser.getNamespace().equals(Registration.NAMESPACE)) {
String name = parser.getName();
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")) {
fields.put(name, value);
} else {
instruction = value;
}
} else // Otherwise, it must be a packet extension.
{
PacketParserUtils.addExtensionElement(packetExtensions, parser);
}
} else if (eventType == XmlPullParser.END_TAG) {
if (parser.getName().equals(IQ.QUERY_ELEMENT)) {
break outerloop;
}
}
}
Registration registration = new Registration(instruction, fields);
registration.addExtensions(packetExtensions);
return registration;
}
use of org.jivesoftware.smackx.iqregister.packet.Registration in project Smack by igniterealtime.
the class AccountManager method deleteAccount.
/**
* Deletes the currently logged-in account from the server. This operation can only
* be performed after a successful login operation has been completed. Not all servers
* support deleting accounts; an XMPPException will be thrown when that is the case.
*
* @throws IllegalStateException if not currently logged-in to the server.
* @throws XMPPErrorException if an error occurs when deleting the account.
* @throws NoResponseException if there was no response from the server.
* @throws NotConnectedException
* @throws InterruptedException
*/
public void deleteAccount() throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException {
Map<String, String> attributes = new HashMap<String, String>();
// To delete an account, we add a single attribute, "remove", that is blank.
attributes.put("remove", "");
Registration reg = new Registration(attributes);
reg.setType(IQ.Type.set);
reg.setTo(connection().getXMPPServiceDomain());
createStanzaCollectorAndSend(reg).nextResultOrThrow();
}
Aggregations