Make use of Namespace.DATA constant

This commit is contained in:
Marc Schink 2018-02-16 15:57:02 +01:00
parent 9af7b7ae1e
commit 17c6d8827c
5 changed files with 11 additions and 8 deletions

View file

@ -11,11 +11,13 @@ import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;
import java.util.Comparator; import java.util.Comparator;
import java.util.List; import java.util.List;
import org.json.JSONArray; import org.json.JSONArray;
import org.json.JSONException; import org.json.JSONException;
import org.json.JSONObject; import org.json.JSONObject;
import eu.siacs.conversations.xml.Element; import eu.siacs.conversations.xml.Element;
import eu.siacs.conversations.xml.Namespace;
import eu.siacs.conversations.xmpp.forms.Data; import eu.siacs.conversations.xmpp.forms.Data;
import eu.siacs.conversations.xmpp.forms.Field; import eu.siacs.conversations.xmpp.forms.Field;
import eu.siacs.conversations.xmpp.stanzas.IqPacket; import eu.siacs.conversations.xmpp.stanzas.IqPacket;
@ -132,7 +134,7 @@ public class ServiceDiscoveryResult {
if (element.getAttribute("var") != null) { if (element.getAttribute("var") != null) {
features.add(element.getAttribute("var")); 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)); forms.add(Data.parse(element));
} }
} }

View file

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

View file

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

View file

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

View file

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