Namespace: Add constant for 'jabberdata' & Make use of Namespace.DATA constant

This commit is contained in:
Christian Schneppe 2018-02-19 20:58:23 +01:00
parent 26ae6626b8
commit 2e29525bd7
6 changed files with 11 additions and 8 deletions

View file

@ -16,6 +16,7 @@ import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import de.pixart.messenger.utils.Namespace;
import de.pixart.messenger.xml.Element;
import de.pixart.messenger.xmpp.forms.Data;
import de.pixart.messenger.xmpp.forms.Field;
@ -133,7 +134,7 @@ public class ServiceDiscoveryResult {
if (element.getAttribute("var") != null) {
features.add(element.getAttribute("var"));
}
} else if (element.getName().equals("x") && "jabber:x:data".equals(element.getAttribute("xmlns"))) {
} else if (element.getName().equals("x") && element.getAttribute("xmlns").equals(Namespace.DATA)) {
forms.add(Data.parse(element));
}
}

View file

@ -2777,7 +2777,7 @@ public class XmppConnectionService extends Service {
}
}
}
Element form = query.findChild("x", "jabber:x:data");
Element form = query.findChild("x", Namespace.DATA);
if (form != null) {
conversation.getMucOptions().updateFormData(Data.parse(form));
}
@ -2807,7 +2807,7 @@ public class XmppConnectionService extends Service {
if (packet.getType() == IqPacket.TYPE.RESULT) {
Element pubsub = packet.findChild("pubsub", "http://jabber.org/protocol/pubsub#owner");
Element configuration = pubsub == null ? null : pubsub.findChild("configure");
Element x = configuration == null ? null : configuration.findChild("x", "jabber:x:data");
Element x = configuration == null ? null : configuration.findChild("x", Namespace.DATA);
if (x != null) {
Data data = Data.parse(x);
data.submit(options);
@ -2839,7 +2839,7 @@ public class XmppConnectionService extends Service {
@Override
public void onIqPacketReceived(Account account, IqPacket packet) {
if (packet.getType() == IqPacket.TYPE.RESULT) {
Data data = Data.parse(packet.query().findChild("x", "jabber:x:data"));
Data data = Data.parse(packet.query().findChild("x", Namespace.DATA));
data.submit(options);
IqPacket set = new IqPacket(IqPacket.TYPE.SET);
set.setTo(conversation.getJid().toBareJid());

View file

@ -10,6 +10,7 @@ public final class Namespace {
public static final String MAM = "urn:xmpp:mam:2";
public static final String MAM_LEGACY = "urn:xmpp:mam:0";
public static final String IDLE = "urn:xmpp:idle:1";
public static final String DATA = "jabber:x:data";
public static final String OOB = "jabber:x:oob";
public static final String SASL = "urn:ietf:params:xml:ns:xmpp-sasl";
public static final String TLS = "urn:ietf:params:xml:ns:xmpp-tls";

View file

@ -1007,8 +1007,8 @@ public class XmppConnection implements Runnable {
register.query().addChild(password);
register.setFrom(account.getJid().toBareJid());
sendUnmodifiedIqPacket(register, registrationResponseListener);
} else if (query.hasChild("x", "jabber:x:data")) {
final Data data = Data.parse(query.findChild("x", "jabber:x:data"));
} else if (query.hasChild("x", Namespace.DATA)) {
final Data data = Data.parse(query.findChild("x", Namespace.DATA));
final Element blob = query.findChild("data", "urn:xmpp:bob");
final String id = packet.getId();
InputStream is;

View file

@ -7,6 +7,7 @@ import java.util.Collection;
import java.util.Iterator;
import java.util.List;
import de.pixart.messenger.utils.Namespace;
import de.pixart.messenger.xml.Element;
public class Data extends Element {
@ -15,7 +16,7 @@ public class Data extends Element {
public Data() {
super("x");
this.setAttribute("xmlns", "jabber:x:data");
this.setAttribute("xmlns", Namespace.DATA);
}
public List<Field> getFields() {

View file

@ -43,7 +43,7 @@ public class PushManagementService {
public void onIqPacketReceived(Account account, IqPacket packet) {
Element command = packet.findChild("command", "http://jabber.org/protocol/commands");
if (packet.getType() == IqPacket.TYPE.RESULT && command != null) {
Element x = command.findChild("x", "jabber:x:data");
Element x = command.findChild("x", Namespace.DATA);
if (x != null) {
Data data = Data.parse(x);
try {