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.Namespace;
33import eu.siacs.conversations.xml.Element;
34import eu.siacs.conversations.xmpp.forms.Data;
35import eu.siacs.conversations.xmpp.pep.Avatar;
36import eu.siacs.conversations.xmpp.stanzas.IqPacket;
37import rocks.xmpp.addr.Jid;
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.addChild("nick", Namespace.NICK).setContent(nick);
135 return publish(Namespace.NICK, item);
136 }
137
138 public IqPacket deleteNode(String node) {
139 IqPacket packet = new IqPacket(IqPacket.TYPE.SET);
140 final Element pubsub = packet.addChild("pubsub", Namespace.PUBSUB_OWNER);
141 pubsub.addChild("delete").setAttribute("node", node);
142 return packet;
143 }
144
145 public IqPacket deleteItem(final String node, final String id) {
146 IqPacket packet = new IqPacket(IqPacket.TYPE.SET);
147 final Element pubsub = packet.addChild("pubsub", Namespace.PUBSUB);
148 final Element retract = pubsub.addChild("retract");
149 retract.setAttribute("node", node);
150 retract.setAttribute("notify","true");
151 retract.addChild("item").setAttribute("id", id);
152 return packet;
153 }
154
155 public IqPacket publishAvatar(Avatar avatar, Bundle options) {
156 final Element item = new Element("item");
157 item.setAttribute("id", avatar.sha1sum);
158 final Element data = item.addChild("data", "urn:xmpp:avatar:data");
159 data.setContent(avatar.image);
160 return publish("urn:xmpp:avatar:data", item, options);
161 }
162
163 public IqPacket publishElement(final String namespace, final Element element, final Bundle options) {
164 return publishElement(namespace, element, "curent", options);
165 }
166
167 public IqPacket publishElement(final String namespace, final Element element, String id, final Bundle options) {
168 final Element item = new Element("item");
169 item.setAttribute("id", id);
170 item.addChild(element);
171 return publish(namespace, item, options);
172 }
173
174 public IqPacket publishAvatarMetadata(final Avatar avatar, final Bundle options) {
175 final Element item = new Element("item");
176 item.setAttribute("id", avatar.sha1sum);
177 final Element metadata = item
178 .addChild("metadata", "urn:xmpp:avatar:metadata");
179 final Element info = metadata.addChild("info");
180 info.setAttribute("bytes", avatar.size);
181 info.setAttribute("id", avatar.sha1sum);
182 info.setAttribute("height", avatar.height);
183 info.setAttribute("width", avatar.height);
184 info.setAttribute("type", avatar.type);
185 return publish("urn:xmpp:avatar:metadata", item, options);
186 }
187
188 public IqPacket retrievePepAvatar(final Avatar avatar) {
189 final Element item = new Element("item");
190 item.setAttribute("id", avatar.sha1sum);
191 final IqPacket packet = retrieve("urn:xmpp:avatar:data", item);
192 packet.setTo(avatar.owner);
193 return packet;
194 }
195
196 public IqPacket retrieveVcardAvatar(final Avatar avatar) {
197 final IqPacket packet = new IqPacket(IqPacket.TYPE.GET);
198 packet.setTo(avatar.owner);
199 packet.addChild("vCard", "vcard-temp");
200 return packet;
201 }
202
203 public IqPacket retrieveAvatarMetaData(final Jid to) {
204 final IqPacket packet = retrieve("urn:xmpp:avatar:metadata", null);
205 if (to != null) {
206 packet.setTo(to);
207 }
208 return packet;
209 }
210
211 public IqPacket retrieveDeviceIds(final Jid to) {
212 final IqPacket packet = retrieve(AxolotlService.PEP_DEVICE_LIST, null);
213 if (to != null) {
214 packet.setTo(to);
215 }
216 return packet;
217 }
218
219 public IqPacket retrieveBundlesForDevice(final Jid to, final int deviceid) {
220 final IqPacket packet = retrieve(AxolotlService.PEP_BUNDLES + ":" + deviceid, null);
221 packet.setTo(to);
222 return packet;
223 }
224
225 public IqPacket retrieveVerificationForDevice(final Jid to, final int deviceid) {
226 final IqPacket packet = retrieve(AxolotlService.PEP_VERIFICATION + ":" + deviceid, null);
227 packet.setTo(to);
228 return packet;
229 }
230
231 public IqPacket publishDeviceIds(final Set<Integer> ids, final Bundle publishOptions) {
232 final Element item = new Element("item");
233 item.setAttribute("id", "current");
234 final Element list = item.addChild("list", AxolotlService.PEP_PREFIX);
235 for (Integer id : ids) {
236 final Element device = new Element("device");
237 device.setAttribute("id", id);
238 list.addChild(device);
239 }
240 return publish(AxolotlService.PEP_DEVICE_LIST, item, publishOptions);
241 }
242
243 public Element publishBookmarkItem(final Bookmark bookmark) {
244 final String name = bookmark.getBookmarkName();
245 final String nick = bookmark.getNick();
246 final boolean autojoin = bookmark.autojoin();
247 final Element conference = new Element("conference", Namespace.BOOKMARKS2);
248 if (name != null) {
249 conference.setAttribute("name", name);
250 }
251 if (nick != null) {
252 conference.addChild("nick").setContent(nick);
253 }
254 conference.setAttribute("autojoin",String.valueOf(autojoin));
255 return conference;
256 }
257
258 public IqPacket publishBundles(final SignedPreKeyRecord signedPreKeyRecord, final IdentityKey identityKey,
259 final Set<PreKeyRecord> preKeyRecords, final int deviceId, Bundle publishOptions) {
260 final Element item = new Element("item");
261 item.setAttribute("id", "current");
262 final Element bundle = item.addChild("bundle", AxolotlService.PEP_PREFIX);
263 final Element signedPreKeyPublic = bundle.addChild("signedPreKeyPublic");
264 signedPreKeyPublic.setAttribute("signedPreKeyId", signedPreKeyRecord.getId());
265 ECPublicKey publicKey = signedPreKeyRecord.getKeyPair().getPublicKey();
266 signedPreKeyPublic.setContent(Base64.encodeToString(publicKey.serialize(), Base64.DEFAULT));
267 final Element signedPreKeySignature = bundle.addChild("signedPreKeySignature");
268 signedPreKeySignature.setContent(Base64.encodeToString(signedPreKeyRecord.getSignature(), Base64.DEFAULT));
269 final Element identityKeyElement = bundle.addChild("identityKey");
270 identityKeyElement.setContent(Base64.encodeToString(identityKey.serialize(), Base64.DEFAULT));
271
272 final Element prekeys = bundle.addChild("prekeys", AxolotlService.PEP_PREFIX);
273 for (PreKeyRecord preKeyRecord : preKeyRecords) {
274 final Element prekey = prekeys.addChild("preKeyPublic");
275 prekey.setAttribute("preKeyId", preKeyRecord.getId());
276 prekey.setContent(Base64.encodeToString(preKeyRecord.getKeyPair().getPublicKey().serialize(), Base64.DEFAULT));
277 }
278
279 return publish(AxolotlService.PEP_BUNDLES + ":" + deviceId, item, publishOptions);
280 }
281
282 public IqPacket publishVerification(byte[] signature, X509Certificate[] certificates, final int deviceId) {
283 final Element item = new Element("item");
284 item.setAttribute("id", "current");
285 final Element verification = item.addChild("verification", AxolotlService.PEP_PREFIX);
286 final Element chain = verification.addChild("chain");
287 for (int i = 0; i < certificates.length; ++i) {
288 try {
289 Element certificate = chain.addChild("certificate");
290 certificate.setContent(Base64.encodeToString(certificates[i].getEncoded(), Base64.DEFAULT));
291 certificate.setAttribute("index", i);
292 } catch (CertificateEncodingException e) {
293 Log.d(Config.LOGTAG, "could not encode certificate");
294 }
295 }
296 verification.addChild("signature").setContent(Base64.encodeToString(signature, Base64.DEFAULT));
297 return publish(AxolotlService.PEP_VERIFICATION + ":" + deviceId, item);
298 }
299
300 public IqPacket queryMessageArchiveManagement(final MessageArchiveService.Query mam) {
301 final IqPacket packet = new IqPacket(IqPacket.TYPE.SET);
302 final Element query = packet.query(mam.version.namespace);
303 query.setAttribute("queryid", mam.getQueryId());
304 final Data data = new Data();
305 data.setFormType(mam.version.namespace);
306 if (mam.muc()) {
307 packet.setTo(mam.getWith());
308 } else if (mam.getWith() != null) {
309 data.put("with", mam.getWith().toString());
310 }
311 final long start = mam.getStart();
312 final long end = mam.getEnd();
313 if (start != 0) {
314 data.put("start", getTimestamp(start));
315 }
316 if (end != 0) {
317 data.put("end", getTimestamp(end));
318 }
319 data.submit();
320 query.addChild(data);
321 Element set = query.addChild("set", "http://jabber.org/protocol/rsm");
322 if (mam.getPagingOrder() == MessageArchiveService.PagingOrder.REVERSE) {
323 set.addChild("before").setContent(mam.getReference());
324 } else if (mam.getReference() != null) {
325 set.addChild("after").setContent(mam.getReference());
326 }
327 set.addChild("max").setContent(String.valueOf(Config.PAGE_SIZE));
328 return packet;
329 }
330
331 public IqPacket generateGetBlockList() {
332 final IqPacket iq = new IqPacket(IqPacket.TYPE.GET);
333 iq.addChild("blocklist", Namespace.BLOCKING);
334
335 return iq;
336 }
337
338 public IqPacket generateSetBlockRequest(final Jid jid, boolean reportSpam) {
339 final IqPacket iq = new IqPacket(IqPacket.TYPE.SET);
340 final Element block = iq.addChild("block", Namespace.BLOCKING);
341 final Element item = block.addChild("item").setAttribute("jid", jid.toEscapedString());
342 if (reportSpam) {
343 item.addChild("report", "urn:xmpp:reporting:0").addChild("spam");
344 }
345 Log.d(Config.LOGTAG, iq.toString());
346 return iq;
347 }
348
349 public IqPacket generateSetUnblockRequest(final Jid jid) {
350 final IqPacket iq = new IqPacket(IqPacket.TYPE.SET);
351 final Element block = iq.addChild("unblock", Namespace.BLOCKING);
352 block.addChild("item").setAttribute("jid", jid.toEscapedString());
353 return iq;
354 }
355
356 public IqPacket generateSetPassword(final Account account, final String newPassword) {
357 final IqPacket packet = new IqPacket(IqPacket.TYPE.SET);
358 packet.setTo(Jid.of(account.getServer()));
359 final Element query = packet.addChild("query", Namespace.REGISTER);
360 final Jid jid = account.getJid();
361 query.addChild("username").setContent(jid.getLocal());
362 query.addChild("password").setContent(newPassword);
363 return packet;
364 }
365
366 public IqPacket changeAffiliation(Conversation conference, Jid jid, String affiliation) {
367 List<Jid> jids = new ArrayList<>();
368 jids.add(jid);
369 return changeAffiliation(conference, jids, affiliation);
370 }
371
372 public IqPacket changeAffiliation(Conversation conference, List<Jid> jids, String affiliation) {
373 IqPacket packet = new IqPacket(IqPacket.TYPE.SET);
374 packet.setTo(conference.getJid().asBareJid());
375 packet.setFrom(conference.getAccount().getJid());
376 Element query = packet.query("http://jabber.org/protocol/muc#admin");
377 for (Jid jid : jids) {
378 Element item = query.addChild("item");
379 item.setAttribute("jid", jid.toEscapedString());
380 item.setAttribute("affiliation", affiliation);
381 }
382 return packet;
383 }
384
385 public IqPacket changeRole(Conversation conference, String nick, String role) {
386 IqPacket packet = new IqPacket(IqPacket.TYPE.SET);
387 packet.setTo(conference.getJid().asBareJid());
388 packet.setFrom(conference.getAccount().getJid());
389 Element item = packet.query("http://jabber.org/protocol/muc#admin").addChild("item");
390 item.setAttribute("nick", nick);
391 item.setAttribute("role", role);
392 return packet;
393 }
394
395 public IqPacket requestHttpUploadSlot(Jid host, DownloadableFile file, String mime) {
396 IqPacket packet = new IqPacket(IqPacket.TYPE.GET);
397 packet.setTo(host);
398 Element request = packet.addChild("request", Namespace.HTTP_UPLOAD);
399 request.setAttribute("filename", convertFilename(file.getName()));
400 request.setAttribute("size", file.getExpectedSize());
401 request.setAttribute("content-type", mime);
402 return packet;
403 }
404
405 public IqPacket requestHttpUploadLegacySlot(Jid host, DownloadableFile file, String mime) {
406 IqPacket packet = new IqPacket(IqPacket.TYPE.GET);
407 packet.setTo(host);
408 Element request = packet.addChild("request", Namespace.HTTP_UPLOAD_LEGACY);
409 request.addChild("filename").setContent(convertFilename(file.getName()));
410 request.addChild("size").setContent(String.valueOf(file.getExpectedSize()));
411 request.addChild("content-type").setContent(mime);
412 return packet;
413 }
414
415 public IqPacket requestP1S3Slot(Jid host, String md5) {
416 IqPacket packet = new IqPacket(IqPacket.TYPE.SET);
417 packet.setTo(host);
418 packet.query(Namespace.P1_S3_FILE_TRANSFER).setAttribute("md5", md5);
419 return packet;
420 }
421
422 public IqPacket requestP1S3Url(Jid host, String fileId) {
423 IqPacket packet = new IqPacket(IqPacket.TYPE.GET);
424 packet.setTo(host);
425 packet.query(Namespace.P1_S3_FILE_TRANSFER).setAttribute("fileid", fileId);
426 return packet;
427 }
428
429 private static String convertFilename(String name) {
430 int pos = name.indexOf('.');
431 if (pos != -1) {
432 try {
433 UUID uuid = UUID.fromString(name.substring(0, pos));
434 ByteBuffer bb = ByteBuffer.wrap(new byte[16]);
435 bb.putLong(uuid.getMostSignificantBits());
436 bb.putLong(uuid.getLeastSignificantBits());
437 return Base64.encodeToString(bb.array(), Base64.URL_SAFE | Base64.NO_PADDING | Base64.NO_WRAP) + name.substring(pos, name.length());
438 } catch (Exception e) {
439 return name;
440 }
441 } else {
442 return name;
443 }
444 }
445
446 public IqPacket generateCreateAccountWithCaptcha(Account account, String id, Data data) {
447 final IqPacket register = new IqPacket(IqPacket.TYPE.SET);
448 register.setFrom(account.getJid().asBareJid());
449 register.setTo(Jid.of(account.getServer()));
450 register.setId(id);
451 Element query = register.query(Namespace.REGISTER);
452 if (data != null) {
453 query.addChild(data);
454 }
455 return register;
456 }
457
458 public IqPacket pushTokenToAppServer(Jid appServer, String token, String deviceId) {
459 return pushTokenToAppServer(appServer, token, deviceId, null);
460 }
461
462 public IqPacket pushTokenToAppServer(Jid appServer, String token, String deviceId, Jid muc) {
463 final IqPacket packet = new IqPacket(IqPacket.TYPE.SET);
464 packet.setTo(appServer);
465 final Element command = packet.addChild("command", Namespace.COMMANDS);
466 command.setAttribute("node", "register-push-fcm");
467 command.setAttribute("action", "execute");
468 final Data data = new Data();
469 data.put("token", token);
470 data.put("android-id", deviceId);
471 if (muc != null) {
472 data.put("muc", muc.toEscapedString());
473 }
474 data.submit();
475 command.addChild(data);
476 return packet;
477 }
478
479 public IqPacket unregisterChannelOnAppServer(Jid appServer, String deviceId, String channel) {
480 final IqPacket packet = new IqPacket(IqPacket.TYPE.SET);
481 packet.setTo(appServer);
482 final Element command = packet.addChild("command", Namespace.COMMANDS);
483 command.setAttribute("node", "unregister-push-fcm");
484 command.setAttribute("action", "execute");
485 final Data data = new Data();
486 data.put("channel", channel);
487 data.put("android-id", deviceId);
488 data.submit();
489 command.addChild(data);
490 return packet;
491 }
492
493 public IqPacket enablePush(final Jid jid, final String node, final String secret) {
494 IqPacket packet = new IqPacket(IqPacket.TYPE.SET);
495 Element enable = packet.addChild("enable", Namespace.PUSH);
496 enable.setAttribute("jid", jid.toString());
497 enable.setAttribute("node", node);
498 if (secret != null) {
499 Data data = new Data();
500 data.setFormType(Namespace.PUBSUB_PUBLISH_OPTIONS);
501 data.put("secret", secret);
502 data.submit();
503 enable.addChild(data);
504 }
505 return packet;
506 }
507
508 public IqPacket disablePush(final Jid jid, final String node) {
509 IqPacket packet = new IqPacket(IqPacket.TYPE.SET);
510 Element disable = packet.addChild("disable", Namespace.PUSH);
511 disable.setAttribute("jid", jid.toEscapedString());
512 disable.setAttribute("node", node);
513 return packet;
514 }
515
516 public IqPacket queryAffiliation(Conversation conversation, String affiliation) {
517 IqPacket packet = new IqPacket(IqPacket.TYPE.GET);
518 packet.setTo(conversation.getJid().asBareJid());
519 packet.query("http://jabber.org/protocol/muc#admin").addChild("item").setAttribute("affiliation", affiliation);
520 return packet;
521 }
522
523 public static Bundle defaultGroupChatConfiguration() {
524 Bundle options = new Bundle();
525 options.putString("muc#roomconfig_persistentroom", "1");
526 options.putString("muc#roomconfig_membersonly", "1");
527 options.putString("muc#roomconfig_publicroom", "0");
528 options.putString("muc#roomconfig_whois", "anyone");
529 options.putString("muc#roomconfig_changesubject", "0");
530 options.putString("muc#roomconfig_allowinvites", "0");
531 options.putString("muc#roomconfig_enablearchiving", "1"); //prosody
532 options.putString("mam", "1"); //ejabberd community
533 options.putString("muc#roomconfig_mam", "1"); //ejabberd saas
534 return options;
535 }
536
537 public static Bundle defaultChannelConfiguration() {
538 Bundle options = new Bundle();
539 options.putString("muc#roomconfig_persistentroom", "1");
540 options.putString("muc#roomconfig_membersonly", "0");
541 options.putString("muc#roomconfig_publicroom", "1");
542 options.putString("muc#roomconfig_whois", "moderators");
543 options.putString("muc#roomconfig_changesubject", "0");
544 options.putString("muc#roomconfig_enablearchiving", "1"); //prosody
545 options.putString("mam", "1"); //ejabberd community
546 options.putString("muc#roomconfig_mam", "1"); //ejabberd saas
547 return options;
548 }
549
550 public IqPacket requestPubsubConfiguration(Jid jid, String node) {
551 return pubsubConfiguration(jid, node, null);
552 }
553
554 public IqPacket publishPubsubConfiguration(Jid jid, String node, Data data) {
555 return pubsubConfiguration(jid, node, data);
556 }
557
558 private IqPacket pubsubConfiguration(Jid jid, String node, Data data) {
559 IqPacket packet = new IqPacket(data == null ? IqPacket.TYPE.GET : IqPacket.TYPE.SET);
560 packet.setTo(jid);
561 Element pubsub = packet.addChild("pubsub", "http://jabber.org/protocol/pubsub#owner");
562 Element configure = pubsub.addChild("configure").setAttribute("node", node);
563 if (data != null) {
564 configure.addChild(data);
565 }
566 return packet;
567 }
568
569 public IqPacket queryDiscoItems(Jid jid) {
570 IqPacket packet = new IqPacket(IqPacket.TYPE.GET);
571 packet.setTo(jid);
572 packet.addChild("query",Namespace.DISCO_ITEMS);
573 return packet;
574 }
575
576 public IqPacket queryDiscoInfo(Jid jid) {
577 IqPacket packet = new IqPacket(IqPacket.TYPE.GET);
578 packet.setTo(jid);
579 packet.addChild("query",Namespace.DISCO_INFO);
580 return packet;
581 }
582}