aboutsummaryrefslogtreecommitdiffstats
path: root/src/eu/siacs/conversations/generator/IqGenerator.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/eu/siacs/conversations/generator/IqGenerator.java')
-rw-r--r--src/eu/siacs/conversations/generator/IqGenerator.java50
1 files changed, 26 insertions, 24 deletions
diff --git a/src/eu/siacs/conversations/generator/IqGenerator.java b/src/eu/siacs/conversations/generator/IqGenerator.java
index 259538c2..b5ecafb5 100644
--- a/src/eu/siacs/conversations/generator/IqGenerator.java
+++ b/src/eu/siacs/conversations/generator/IqGenerator.java
@@ -10,67 +10,69 @@ import eu.siacs.conversations.xmpp.stanzas.IqPacket;
public class IqGenerator extends AbstractGenerator {
-
-
public IqPacket discoResponse(IqPacket request) {
IqPacket packet = new IqPacket(IqPacket.TYPE_RESULT);
packet.setId(request.getId());
packet.setTo(request.getFrom());
- Element query = packet.addChild("query","http://jabber.org/protocol/disco#info");
+ Element query = packet.addChild("query",
+ "http://jabber.org/protocol/disco#info");
query.setAttribute("node", request.query().getAttribute("node"));
Element identity = query.addChild("identity");
- identity.setAttribute("category","client");
+ identity.setAttribute("category", "client");
identity.setAttribute("type", this.IDENTITY_TYPE);
identity.setAttribute("name", IDENTITY_NAME);
List<String> features = Arrays.asList(FEATURES);
Collections.sort(features);
- for(String feature : features) {
- query.addChild("feature").setAttribute("var",feature);
+ for (String feature : features) {
+ query.addChild("feature").setAttribute("var", feature);
}
return packet;
}
-
+
protected IqPacket publish(String node, Element item) {
IqPacket packet = new IqPacket(IqPacket.TYPE_SET);
- Element pubsub = packet.addChild("pubsub", "http://jabber.org/protocol/pubsub");
+ Element pubsub = packet.addChild("pubsub",
+ "http://jabber.org/protocol/pubsub");
Element publish = pubsub.addChild("publish");
publish.setAttribute("node", node);
publish.addChild(item);
return packet;
}
-
+
protected IqPacket retrieve(String node, Element item) {
IqPacket packet = new IqPacket(IqPacket.TYPE_GET);
- Element pubsub = packet.addChild("pubsub", "http://jabber.org/protocol/pubsub");
- Element items = pubsub.addChild("items");
- items.setAttribute("node", node);
- if (item!=null) {
+ Element pubsub = packet.addChild("pubsub",
+ "http://jabber.org/protocol/pubsub");
+ Element items = pubsub.addChild("items");
+ items.setAttribute("node", node);
+ if (item != null) {
items.addChild(item);
}
return packet;
}
-
+
public IqPacket publishAvatar(Avatar avatar) {
Element item = new Element("item");
item.setAttribute("id", avatar.sha1sum);
- Element data = item.addChild("data","urn:xmpp:avatar:data");
+ Element data = item.addChild("data", "urn:xmpp:avatar:data");
data.setContent(avatar.image);
return publish("urn:xmpp:avatar:data", item);
}
-
+
public IqPacket publishAvatarMetadata(Avatar avatar) {
Element item = new Element("item");
item.setAttribute("id", avatar.sha1sum);
- Element metadata = item.addChild("metadata","urn:xmpp:avatar:metadata");
+ Element metadata = item
+ .addChild("metadata", "urn:xmpp:avatar:metadata");
Element info = metadata.addChild("info");
- info.setAttribute("bytes",avatar.size);
- info.setAttribute("id",avatar.sha1sum);
- info.setAttribute("height",avatar.height);
- info.setAttribute("width",avatar.height);
+ info.setAttribute("bytes", avatar.size);
+ info.setAttribute("id", avatar.sha1sum);
+ info.setAttribute("height", avatar.height);
+ info.setAttribute("width", avatar.height);
info.setAttribute("type", avatar.type);
- return publish("urn:xmpp:avatar:metadata",item);
+ return publish("urn:xmpp:avatar:metadata", item);
}
-
+
public IqPacket retrieveAvatar(Avatar avatar) {
Element item = new Element("item");
item.setAttribute("id", avatar.sha1sum);
@@ -81,7 +83,7 @@ public class IqGenerator extends AbstractGenerator {
public IqPacket retrieveAvatarMetaData(String to) {
IqPacket packet = retrieve("urn:xmpp:avatar:metadata", null);
- if (to!=null) {
+ if (to != null) {
packet.setTo(to);
}
return packet;