IqGenerator.java

  1package eu.siacs.conversations.generator;
  2
  3
  4import android.os.Bundle;
  5import android.util.Base64;
  6import android.util.Log;
  7
  8import org.whispersystems.libsignal.IdentityKey;
  9import org.whispersystems.libsignal.ecc.ECPublicKey;
 10import org.whispersystems.libsignal.state.PreKeyRecord;
 11import org.whispersystems.libsignal.state.SignedPreKeyRecord;
 12
 13import java.nio.ByteBuffer;
 14import java.security.cert.CertificateEncodingException;
 15import java.security.cert.X509Certificate;
 16import java.util.ArrayList;
 17import java.util.List;
 18import java.util.Locale;
 19import java.util.Set;
 20import java.util.TimeZone;
 21import java.util.UUID;
 22
 23import eu.siacs.conversations.Config;
 24import eu.siacs.conversations.R;
 25import eu.siacs.conversations.crypto.axolotl.AxolotlService;
 26import eu.siacs.conversations.entities.Account;
 27import eu.siacs.conversations.entities.Bookmark;
 28import eu.siacs.conversations.entities.Conversation;
 29import eu.siacs.conversations.entities.DownloadableFile;
 30import eu.siacs.conversations.services.MessageArchiveService;
 31import eu.siacs.conversations.services.XmppConnectionService;
 32import eu.siacs.conversations.xml.Element;
 33import eu.siacs.conversations.xml.Namespace;
 34import eu.siacs.conversations.xmpp.Jid;
 35import eu.siacs.conversations.xmpp.forms.Data;
 36import eu.siacs.conversations.xmpp.pep.Avatar;
 37import eu.siacs.conversations.xmpp.stanzas.IqPacket;
 38
 39public class IqGenerator extends AbstractGenerator {
 40
 41    public IqGenerator(final XmppConnectionService service) {
 42        super(service);
 43    }
 44
 45    public IqPacket discoResponse(final Account account, final IqPacket request) {
 46        final IqPacket packet = new IqPacket(IqPacket.TYPE.RESULT);
 47        packet.setId(request.getId());
 48        packet.setTo(request.getFrom());
 49        final Element query = packet.addChild("query", "http://jabber.org/protocol/disco#info");
 50        query.setAttribute("node", request.query().getAttribute("node"));
 51        final Element identity = query.addChild("identity");
 52        identity.setAttribute("category", "client");
 53        identity.setAttribute("type", getIdentityType());
 54        identity.setAttribute("name", getIdentityName());
 55        for (final String feature : getFeatures(account)) {
 56            query.addChild("feature").setAttribute("var", feature);
 57        }
 58        return packet;
 59    }
 60
 61    public IqPacket versionResponse(final IqPacket request) {
 62        final IqPacket packet = request.generateResponse(IqPacket.TYPE.RESULT);
 63        Element query = packet.query("jabber:iq:version");
 64        query.addChild("name").setContent(mXmppConnectionService.getString(R.string.app_name));
 65        query.addChild("version").setContent(getIdentityVersion());
 66        if ("chromium".equals(android.os.Build.BRAND)) {
 67            query.addChild("os").setContent("Chrome OS");
 68        } else {
 69            query.addChild("os").setContent("Android");
 70        }
 71        return packet;
 72    }
 73
 74    public IqPacket entityTimeResponse(IqPacket request) {
 75        final IqPacket packet = request.generateResponse(IqPacket.TYPE.RESULT);
 76        Element time = packet.addChild("time", "urn:xmpp:time");
 77        final long now = System.currentTimeMillis();
 78        time.addChild("utc").setContent(getTimestamp(now));
 79        TimeZone ourTimezone = TimeZone.getDefault();
 80        long offsetSeconds = ourTimezone.getOffset(now) / 1000;
 81        long offsetMinutes = Math.abs((offsetSeconds % 3600) / 60);
 82        long offsetHours = offsetSeconds / 3600;
 83        String hours;
 84        if (offsetHours < 0) {
 85            hours = String.format(Locale.US, "%03d", offsetHours);
 86        } else {
 87            hours = String.format(Locale.US, "%02d", offsetHours);
 88        }
 89        String minutes = String.format(Locale.US, "%02d", offsetMinutes);
 90        time.addChild("tzo").setContent(hours + ":" + minutes);
 91        return packet;
 92    }
 93
 94    public IqPacket purgeOfflineMessages() {
 95        final IqPacket packet = new IqPacket(IqPacket.TYPE.SET);
 96        packet.addChild("offline", Namespace.FLEXIBLE_OFFLINE_MESSAGE_RETRIEVAL).addChild("purge");
 97        return packet;
 98    }
 99
100    protected IqPacket publish(final String node, final Element item, final Bundle options) {
101        final IqPacket packet = new IqPacket(IqPacket.TYPE.SET);
102        final Element pubsub = packet.addChild("pubsub", Namespace.PUBSUB);
103        final Element publish = pubsub.addChild("publish");
104        publish.setAttribute("node", node);
105        publish.addChild(item);
106        if (options != null) {
107            final Element publishOptions = pubsub.addChild("publish-options");
108            publishOptions.addChild(Data.create(Namespace.PUBSUB_PUBLISH_OPTIONS, options));
109        }
110        return packet;
111    }
112
113    protected IqPacket publish(final String node, final Element item) {
114        return publish(node, item, null);
115    }
116
117    private IqPacket retrieve(String node, Element item) {
118        final IqPacket packet = new IqPacket(IqPacket.TYPE.GET);
119        final Element pubsub = packet.addChild("pubsub", Namespace.PUBSUB);
120        final Element items = pubsub.addChild("items");
121        items.setAttribute("node", node);
122        if (item != null) {
123            items.addChild(item);
124        }
125        return packet;
126    }
127
128    public IqPacket retrieveBookmarks() {
129        return retrieve(Namespace.BOOKMARKS2, null);
130    }
131
132    public IqPacket publishNick(String nick) {
133        final Element item = new Element("item");
134        item.setAttribute("id", "current");
135        item.addChild("nick", Namespace.NICK).setContent(nick);
136        return publish(Namespace.NICK, item);
137    }
138
139    public IqPacket deleteNode(final String node) {
140        final IqPacket packet = new IqPacket(IqPacket.TYPE.SET);
141        final Element pubsub = packet.addChild("pubsub", Namespace.PUBSUB_OWNER);
142        pubsub.addChild("delete").setAttribute("node", node);
143        return packet;
144    }
145
146    public IqPacket deleteItem(final String node, final String id) {
147        IqPacket packet = new IqPacket(IqPacket.TYPE.SET);
148        final Element pubsub = packet.addChild("pubsub", Namespace.PUBSUB);
149        final Element retract = pubsub.addChild("retract");
150        retract.setAttribute("node", node);
151        retract.setAttribute("notify","true");
152        retract.addChild("item").setAttribute("id", id);
153        return packet;
154    }
155
156    public IqPacket publishAvatar(Avatar avatar, Bundle options) {
157        final Element item = new Element("item");
158        item.setAttribute("id", avatar.sha1sum);
159        final Element data = item.addChild("data", Namespace.AVATAR_DATA);
160        data.setContent(avatar.image);
161        return publish(Namespace.AVATAR_DATA, item, options);
162    }
163
164    public IqPacket publishElement(final String namespace, final Element element, String id, final Bundle options) {
165        final Element item = new Element("item");
166        item.setAttribute("id", id);
167        item.addChild(element);
168        return publish(namespace, item, options);
169    }
170
171    public IqPacket publishAvatarMetadata(final Avatar avatar, final Bundle options) {
172        final Element item = new Element("item");
173        item.setAttribute("id", avatar.sha1sum);
174        final Element metadata = item
175                .addChild("metadata", Namespace.AVATAR_METADATA);
176        final Element info = metadata.addChild("info");
177        info.setAttribute("bytes", avatar.size);
178        info.setAttribute("id", avatar.sha1sum);
179        info.setAttribute("height", avatar.height);
180        info.setAttribute("width", avatar.height);
181        info.setAttribute("type", avatar.type);
182        return publish(Namespace.AVATAR_METADATA, item, options);
183    }
184
185    public IqPacket retrievePepAvatar(final Avatar avatar) {
186        final Element item = new Element("item");
187        item.setAttribute("id", avatar.sha1sum);
188        final IqPacket packet = retrieve(Namespace.AVATAR_DATA, item);
189        packet.setTo(avatar.owner);
190        return packet;
191    }
192
193    public IqPacket retrieveVcardAvatar(final Avatar avatar) {
194        final IqPacket packet = new IqPacket(IqPacket.TYPE.GET);
195        packet.setTo(avatar.owner);
196        packet.addChild("vCard", "vcard-temp");
197        return packet;
198    }
199
200    public IqPacket retrieveVcardAvatar(final Jid to) {
201        final IqPacket packet = new IqPacket(IqPacket.TYPE.GET);
202        packet.setTo(to);
203        packet.addChild("vCard", "vcard-temp");
204        return packet;
205    }
206
207    public IqPacket retrieveAvatarMetaData(final Jid to) {
208        final IqPacket packet = retrieve("urn:xmpp:avatar:metadata", null);
209        if (to != null) {
210            packet.setTo(to);
211        }
212        return packet;
213    }
214
215    public IqPacket retrieveDeviceIds(final Jid to) {
216        final IqPacket packet = retrieve(AxolotlService.PEP_DEVICE_LIST, null);
217        if (to != null) {
218            packet.setTo(to);
219        }
220        return packet;
221    }
222
223    public IqPacket retrieveBundlesForDevice(final Jid to, final int deviceid) {
224        final IqPacket packet = retrieve(AxolotlService.PEP_BUNDLES + ":" + deviceid, null);
225        packet.setTo(to);
226        return packet;
227    }
228
229    public IqPacket retrieveVerificationForDevice(final Jid to, final int deviceid) {
230        final IqPacket packet = retrieve(AxolotlService.PEP_VERIFICATION + ":" + deviceid, null);
231        packet.setTo(to);
232        return packet;
233    }
234
235    public IqPacket publishDeviceIds(final Set<Integer> ids, final Bundle publishOptions) {
236        final Element item = new Element("item");
237        item.setAttribute("id", "current");
238        final Element list = item.addChild("list", AxolotlService.PEP_PREFIX);
239        for (Integer id : ids) {
240            final Element device = new Element("device");
241            device.setAttribute("id", id);
242            list.addChild(device);
243        }
244        return publish(AxolotlService.PEP_DEVICE_LIST, item, publishOptions);
245    }
246
247    public Element publishBookmarkItem(final Bookmark bookmark) {
248        final String name = bookmark.getBookmarkName();
249        final String nick = bookmark.getNick();
250        final String password = bookmark.getPassword();
251        final boolean autojoin = bookmark.autojoin();
252        final Element conference = new Element("conference", Namespace.BOOKMARKS2);
253        if (name != null) {
254            conference.setAttribute("name", name);
255        }
256        if (nick != null) {
257            conference.addChild("nick").setContent(nick);
258        }
259        if (password != null) {
260            conference.addChild("password").setContent(password);
261        }
262        conference.setAttribute("autojoin",String.valueOf(autojoin));
263        conference.addChild(bookmark.getExtensions());
264        return conference;
265    }
266
267    public IqPacket publishBundles(final SignedPreKeyRecord signedPreKeyRecord, final IdentityKey identityKey,
268                                   final Set<PreKeyRecord> preKeyRecords, final int deviceId, Bundle publishOptions) {
269        final Element item = new Element("item");
270        item.setAttribute("id", "current");
271        final Element bundle = item.addChild("bundle", AxolotlService.PEP_PREFIX);
272        final Element signedPreKeyPublic = bundle.addChild("signedPreKeyPublic");
273        signedPreKeyPublic.setAttribute("signedPreKeyId", signedPreKeyRecord.getId());
274        ECPublicKey publicKey = signedPreKeyRecord.getKeyPair().getPublicKey();
275        signedPreKeyPublic.setContent(Base64.encodeToString(publicKey.serialize(), Base64.NO_WRAP));
276        final Element signedPreKeySignature = bundle.addChild("signedPreKeySignature");
277        signedPreKeySignature.setContent(Base64.encodeToString(signedPreKeyRecord.getSignature(), Base64.NO_WRAP));
278        final Element identityKeyElement = bundle.addChild("identityKey");
279        identityKeyElement.setContent(Base64.encodeToString(identityKey.serialize(), Base64.NO_WRAP));
280
281        final Element prekeys = bundle.addChild("prekeys", AxolotlService.PEP_PREFIX);
282        for (PreKeyRecord preKeyRecord : preKeyRecords) {
283            final Element prekey = prekeys.addChild("preKeyPublic");
284            prekey.setAttribute("preKeyId", preKeyRecord.getId());
285            prekey.setContent(Base64.encodeToString(preKeyRecord.getKeyPair().getPublicKey().serialize(), Base64.NO_WRAP));
286        }
287
288        return publish(AxolotlService.PEP_BUNDLES + ":" + deviceId, item, publishOptions);
289    }
290
291    public IqPacket publishVerification(byte[] signature, X509Certificate[] certificates, final int deviceId) {
292        final Element item = new Element("item");
293        item.setAttribute("id", "current");
294        final Element verification = item.addChild("verification", AxolotlService.PEP_PREFIX);
295        final Element chain = verification.addChild("chain");
296        for (int i = 0; i < certificates.length; ++i) {
297            try {
298                Element certificate = chain.addChild("certificate");
299                certificate.setContent(Base64.encodeToString(certificates[i].getEncoded(), Base64.NO_WRAP));
300                certificate.setAttribute("index", i);
301            } catch (CertificateEncodingException e) {
302                Log.d(Config.LOGTAG, "could not encode certificate");
303            }
304        }
305        verification.addChild("signature").setContent(Base64.encodeToString(signature, Base64.NO_WRAP));
306        return publish(AxolotlService.PEP_VERIFICATION + ":" + deviceId, item);
307    }
308
309    public IqPacket queryMessageArchiveManagement(final MessageArchiveService.Query mam) {
310        final IqPacket packet = new IqPacket(IqPacket.TYPE.SET);
311        final Element query = packet.query(mam.version.namespace);
312        query.setAttribute("queryid", mam.getQueryId());
313        final Data data = new Data();
314        data.setFormType(mam.version.namespace);
315        if (mam.muc()) {
316            packet.setTo(mam.getWith());
317        } else if (mam.getWith() != null) {
318            data.put("with", mam.getWith().toEscapedString());
319        }
320        final long start = mam.getStart();
321        final long end = mam.getEnd();
322        if (start != 0) {
323            data.put("start", getTimestamp(start));
324        }
325        if (end != 0) {
326            data.put("end", getTimestamp(end));
327        }
328        data.submit();
329        query.addChild(data);
330        Element set = query.addChild("set", "http://jabber.org/protocol/rsm");
331        if (mam.getPagingOrder() == MessageArchiveService.PagingOrder.REVERSE) {
332            set.addChild("before").setContent(mam.getReference());
333        } else if (mam.getReference() != null) {
334            set.addChild("after").setContent(mam.getReference());
335        }
336        set.addChild("max").setContent(String.valueOf(Config.PAGE_SIZE));
337        return packet;
338    }
339
340    public IqPacket generateGetBlockList() {
341        final IqPacket iq = new IqPacket(IqPacket.TYPE.GET);
342        iq.addChild("blocklist", Namespace.BLOCKING);
343
344        return iq;
345    }
346
347    public IqPacket generateSetBlockRequest(final Jid jid, final boolean reportSpam, final String serverMsgId) {
348        final IqPacket iq = new IqPacket(IqPacket.TYPE.SET);
349        final Element block = iq.addChild("block", Namespace.BLOCKING);
350        final Element item = block.addChild("item").setAttribute("jid", jid);
351        if (reportSpam) {
352            final Element report = item.addChild("report", Namespace.REPORTING);
353            report.setAttribute("reason", Namespace.REPORTING_REASON_SPAM);
354            if (serverMsgId != null) {
355                final Element stanzaId = report.addChild("stanza-id", Namespace.STANZA_IDS);
356                stanzaId.setAttribute("by", jid);
357                stanzaId.setAttribute("id", serverMsgId);
358            }
359        }
360        Log.d(Config.LOGTAG, iq.toString());
361        return iq;
362    }
363
364    public IqPacket generateSetUnblockRequest(final Jid jid) {
365        final IqPacket iq = new IqPacket(IqPacket.TYPE.SET);
366        final Element block = iq.addChild("unblock", Namespace.BLOCKING);
367        block.addChild("item").setAttribute("jid", jid);
368        return iq;
369    }
370
371    public IqPacket generateSetPassword(final Account account, final String newPassword) {
372        final IqPacket packet = new IqPacket(IqPacket.TYPE.SET);
373        packet.setTo(account.getDomain());
374        final Element query = packet.addChild("query", Namespace.REGISTER);
375        final Jid jid = account.getJid();
376        query.addChild("username").setContent(jid.getLocal());
377        query.addChild("password").setContent(newPassword);
378        return packet;
379    }
380
381    public IqPacket changeAffiliation(Conversation conference, Jid jid, String affiliation) {
382        List<Jid> jids = new ArrayList<>();
383        jids.add(jid);
384        return changeAffiliation(conference, jids, affiliation);
385    }
386
387    public IqPacket changeAffiliation(Conversation conference, List<Jid> jids, String affiliation) {
388        IqPacket packet = new IqPacket(IqPacket.TYPE.SET);
389        packet.setTo(conference.getJid().asBareJid());
390        packet.setFrom(conference.getAccount().getJid());
391        Element query = packet.query("http://jabber.org/protocol/muc#admin");
392        for (Jid jid : jids) {
393            Element item = query.addChild("item");
394            item.setAttribute("jid", jid);
395            item.setAttribute("affiliation", affiliation);
396        }
397        return packet;
398    }
399
400    public IqPacket changeRole(Conversation conference, String nick, String role) {
401        IqPacket packet = new IqPacket(IqPacket.TYPE.SET);
402        packet.setTo(conference.getJid().asBareJid());
403        packet.setFrom(conference.getAccount().getJid());
404        Element item = packet.query("http://jabber.org/protocol/muc#admin").addChild("item");
405        item.setAttribute("nick", nick);
406        item.setAttribute("role", role);
407        return packet;
408    }
409
410    public IqPacket requestHttpUploadSlot(Jid host, DownloadableFile file, String mime) {
411        IqPacket packet = new IqPacket(IqPacket.TYPE.GET);
412        packet.setTo(host);
413        Element request = packet.addChild("request", Namespace.HTTP_UPLOAD);
414        request.setAttribute("filename", convertFilename(file.getName()));
415        request.setAttribute("size", file.getExpectedSize());
416        request.setAttribute("content-type", mime);
417        return packet;
418    }
419
420    public IqPacket requestHttpUploadLegacySlot(Jid host, DownloadableFile file, String mime) {
421        IqPacket packet = new IqPacket(IqPacket.TYPE.GET);
422        packet.setTo(host);
423        Element request = packet.addChild("request", Namespace.HTTP_UPLOAD_LEGACY);
424        request.addChild("filename").setContent(convertFilename(file.getName()));
425        request.addChild("size").setContent(String.valueOf(file.getExpectedSize()));
426        request.addChild("content-type").setContent(mime);
427        return packet;
428    }
429
430    private static String convertFilename(String name) {
431        int pos = name.indexOf('.');
432        if (pos != -1) {
433            try {
434                UUID uuid = UUID.fromString(name.substring(0, pos));
435                ByteBuffer bb = ByteBuffer.wrap(new byte[16]);
436                bb.putLong(uuid.getMostSignificantBits());
437                bb.putLong(uuid.getLeastSignificantBits());
438                return Base64.encodeToString(bb.array(), Base64.URL_SAFE | Base64.NO_PADDING | Base64.NO_WRAP) + name.substring(pos);
439            } catch (Exception e) {
440                return name;
441            }
442        } else {
443            return name;
444        }
445    }
446
447    public IqPacket generateCreateAccountWithCaptcha(Account account, String id, Data data) {
448        final IqPacket register = new IqPacket(IqPacket.TYPE.SET);
449        register.setFrom(account.getJid().asBareJid());
450        register.setTo(account.getDomain());
451        register.setId(id);
452        Element query = register.query(Namespace.REGISTER);
453        if (data != null) {
454            query.addChild(data);
455        }
456        return register;
457    }
458
459    public IqPacket pushTokenToAppServer(Jid appServer, String token, String deviceId) {
460        return pushTokenToAppServer(appServer, token, deviceId, null);
461    }
462
463    public IqPacket pushTokenToAppServer(Jid appServer, String token, String deviceId, Jid muc) {
464        final IqPacket packet = new IqPacket(IqPacket.TYPE.SET);
465        packet.setTo(appServer);
466        final Element command = packet.addChild("command", Namespace.COMMANDS);
467        command.setAttribute("node", "register-push-fcm");
468        command.setAttribute("action", "execute");
469        final Data data = new Data();
470        data.put("token", token);
471        data.put("android-id", deviceId);
472        if (muc != null) {
473            data.put("muc", muc.toEscapedString());
474        }
475        data.submit();
476        command.addChild(data);
477        return packet;
478    }
479
480    public IqPacket unregisterChannelOnAppServer(Jid appServer, String deviceId, String channel) {
481        final IqPacket packet = new IqPacket(IqPacket.TYPE.SET);
482        packet.setTo(appServer);
483        final Element command = packet.addChild("command", Namespace.COMMANDS);
484        command.setAttribute("node", "unregister-push-fcm");
485        command.setAttribute("action", "execute");
486        final Data data = new Data();
487        data.put("channel", channel);
488        data.put("android-id", deviceId);
489        data.submit();
490        command.addChild(data);
491        return packet;
492    }
493
494    public IqPacket enablePush(final Jid jid, final String node, final String secret) {
495        IqPacket packet = new IqPacket(IqPacket.TYPE.SET);
496        Element enable = packet.addChild("enable", Namespace.PUSH);
497        enable.setAttribute("jid", jid);
498        enable.setAttribute("node", node);
499        if (secret != null) {
500            Data data = new Data();
501            data.setFormType(Namespace.PUBSUB_PUBLISH_OPTIONS);
502            data.put("secret", secret);
503            data.submit();
504            enable.addChild(data);
505        }
506        return packet;
507    }
508
509    public IqPacket disablePush(final Jid jid, final String node) {
510        IqPacket packet = new IqPacket(IqPacket.TYPE.SET);
511        Element disable = packet.addChild("disable", Namespace.PUSH);
512        disable.setAttribute("jid", jid);
513        disable.setAttribute("node", node);
514        return packet;
515    }
516
517    public IqPacket queryAffiliation(Conversation conversation, String affiliation) {
518        IqPacket packet = new IqPacket(IqPacket.TYPE.GET);
519        packet.setTo(conversation.getJid().asBareJid());
520        packet.query("http://jabber.org/protocol/muc#admin").addChild("item").setAttribute("affiliation", affiliation);
521        return packet;
522    }
523
524    public static Bundle defaultGroupChatConfiguration() {
525        Bundle options = new Bundle();
526        options.putString("muc#roomconfig_persistentroom", "1");
527        options.putString("muc#roomconfig_membersonly", "1");
528        options.putString("muc#roomconfig_publicroom", "0");
529        options.putString("muc#roomconfig_whois", "anyone");
530        options.putString("muc#roomconfig_changesubject", "0");
531        options.putString("muc#roomconfig_allowinvites", "0");
532        options.putString("muc#roomconfig_enablearchiving", "1"); //prosody
533        options.putString("mam", "1"); //ejabberd community
534        options.putString("muc#roomconfig_mam", "1"); //ejabberd saas
535        return options;
536    }
537
538    public static Bundle defaultChannelConfiguration() {
539        Bundle options = new Bundle();
540        options.putString("muc#roomconfig_persistentroom", "1");
541        options.putString("muc#roomconfig_membersonly", "0");
542        options.putString("muc#roomconfig_publicroom", "1");
543        options.putString("muc#roomconfig_whois", "moderators");
544        options.putString("muc#roomconfig_changesubject", "0");
545        options.putString("muc#roomconfig_enablearchiving", "1"); //prosody
546        options.putString("mam", "1"); //ejabberd community
547        options.putString("muc#roomconfig_mam", "1"); //ejabberd saas
548        return options;
549    }
550
551    public IqPacket requestPubsubConfiguration(Jid jid, String node) {
552        return pubsubConfiguration(jid, node, null);
553    }
554
555    public IqPacket publishPubsubConfiguration(Jid jid, String node, Data data) {
556        return pubsubConfiguration(jid, node, data);
557    }
558
559    private IqPacket pubsubConfiguration(Jid jid, String node, Data data) {
560        IqPacket packet = new IqPacket(data == null ? IqPacket.TYPE.GET : IqPacket.TYPE.SET);
561        packet.setTo(jid);
562        Element pubsub = packet.addChild("pubsub", "http://jabber.org/protocol/pubsub#owner");
563        Element configure = pubsub.addChild("configure").setAttribute("node", node);
564        if (data != null) {
565            configure.addChild(data);
566        }
567        return packet;
568    }
569
570    public IqPacket queryDiscoItems(Jid jid) {
571        IqPacket packet = new IqPacket(IqPacket.TYPE.GET);
572        packet.setTo(jid);
573        packet.addChild("query",Namespace.DISCO_ITEMS);
574        return packet;
575    }
576
577    public IqPacket queryDiscoInfo(Jid jid) {
578        IqPacket packet = new IqPacket(IqPacket.TYPE.GET);
579        packet.setTo(jid);
580        packet.addChild("query",Namespace.DISCO_INFO);
581        return packet;
582    }
583}