use of eu.siacs.conversations.xmpp.forms.Data in project Conversations by siacs.
the class ServiceDiscoveryResult method createFormFromJSONObject.
private static Data createFormFromJSONObject(JSONObject o) {
Data data = new Data();
JSONArray names = o.names();
for (int i = 0; i < names.length(); ++i) {
try {
String name = names.getString(i);
JSONArray jsonValues = o.getJSONArray(name);
ArrayList<String> values = new ArrayList<>(jsonValues.length());
for (int j = 0; j < jsonValues.length(); ++j) {
values.add(jsonValues.getString(j));
}
data.put(name, values);
} catch (Exception e) {
e.printStackTrace();
}
}
return data;
}
use of eu.siacs.conversations.xmpp.forms.Data in project Conversations by siacs.
the class ServiceDiscoveryResult method toJSON.
public JSONObject toJSON() {
try {
JSONObject o = new JSONObject();
JSONArray ids = new JSONArray();
for (Identity id : this.getIdentities()) {
ids.put(id.toJSON());
}
o.put("identities", ids);
o.put("features", new JSONArray(this.getFeatures()));
JSONArray forms = new JSONArray();
for (Data data : this.forms) {
forms.put(createJSONFromForm(data));
}
o.put("forms", forms);
return o;
} catch (JSONException e) {
return null;
}
}
use of eu.siacs.conversations.xmpp.forms.Data in project Conversations by siacs.
the class IqGenerator method pushTokenToAppServer.
public IqPacket pushTokenToAppServer(Jid appServer, String token, String deviceId) {
IqPacket packet = new IqPacket(IqPacket.TYPE.SET);
packet.setTo(appServer);
Element command = packet.addChild("command", "http://jabber.org/protocol/commands");
command.setAttribute("node", "register-push-gcm");
command.setAttribute("action", "execute");
Data data = new Data();
data.put("token", token);
data.put("device-id", deviceId);
data.submit();
command.addChild(data);
return packet;
}
use of eu.siacs.conversations.xmpp.forms.Data in project Conversations by siacs.
the class IqGenerator method enablePush.
public IqPacket enablePush(Jid jid, String node, String secret) {
IqPacket packet = new IqPacket(IqPacket.TYPE.SET);
Element enable = packet.addChild("enable", "urn:xmpp:push:0");
enable.setAttribute("jid", jid.toString());
enable.setAttribute("node", node);
Data data = new Data();
data.setFormType("http://jabber.org/protocol/pubsub#publish-options");
data.put("secret", secret);
data.submit();
enable.addChild(data);
return packet;
}
Aggregations