1package eu.siacs.conversations.parser;
2
3import android.util.Log;
4import android.util.Pair;
5
6import eu.siacs.conversations.crypto.PgpDecryptionService;
7import net.java.otr4j.session.Session;
8import net.java.otr4j.session.SessionStatus;
9
10import java.util.ArrayList;
11import java.util.Set;
12import java.util.UUID;
13
14import eu.siacs.conversations.Config;
15import eu.siacs.conversations.crypto.axolotl.AxolotlService;
16import eu.siacs.conversations.crypto.axolotl.XmppAxolotlMessage;
17import eu.siacs.conversations.entities.Account;
18import eu.siacs.conversations.entities.Bookmark;
19import eu.siacs.conversations.entities.Contact;
20import eu.siacs.conversations.entities.Conversation;
21import eu.siacs.conversations.entities.Message;
22import eu.siacs.conversations.entities.MucOptions;
23import eu.siacs.conversations.http.HttpConnectionManager;
24import eu.siacs.conversations.services.MessageArchiveService;
25import eu.siacs.conversations.services.XmppConnectionService;
26import eu.siacs.conversations.utils.CryptoHelper;
27import eu.siacs.conversations.xml.Element;
28import eu.siacs.conversations.xmpp.OnMessagePacketReceived;
29import eu.siacs.conversations.xmpp.chatstate.ChatState;
30import eu.siacs.conversations.xmpp.jid.Jid;
31import eu.siacs.conversations.xmpp.pep.Avatar;
32import eu.siacs.conversations.xmpp.stanzas.MessagePacket;
33
34public class MessageParser extends AbstractParser implements
35 OnMessagePacketReceived {
36 public MessageParser(XmppConnectionService service) {
37 super(service);
38 }
39
40 private boolean extractChatState(Conversation conversation, final MessagePacket packet) {
41 ChatState state = ChatState.parse(packet);
42 if (state != null && conversation != null) {
43 final Account account = conversation.getAccount();
44 Jid from = packet.getFrom();
45 if (from.toBareJid().equals(account.getJid().toBareJid())) {
46 conversation.setOutgoingChatState(state);
47 if (state == ChatState.ACTIVE || state == ChatState.COMPOSING) {
48 mXmppConnectionService.markRead(conversation);
49 account.activateGracePeriod();
50 }
51 return false;
52 } else {
53 return conversation.setIncomingChatState(state);
54 }
55 }
56 return false;
57 }
58
59 private Message parseOtrChat(String body, Jid from, String id, Conversation conversation) {
60 String presence;
61 if (from.isBareJid()) {
62 presence = "";
63 } else {
64 presence = from.getResourcepart();
65 }
66 if (body.matches("^\\?OTRv\\d{1,2}\\?.*")) {
67 conversation.endOtrIfNeeded();
68 }
69 if (!conversation.hasValidOtrSession()) {
70 conversation.startOtrSession(presence,false);
71 } else {
72 String foreignPresence = conversation.getOtrSession().getSessionID().getUserID();
73 if (!foreignPresence.equals(presence)) {
74 conversation.endOtrIfNeeded();
75 conversation.startOtrSession(presence, false);
76 }
77 }
78 try {
79 conversation.setLastReceivedOtrMessageId(id);
80 Session otrSession = conversation.getOtrSession();
81 body = otrSession.transformReceiving(body);
82 SessionStatus status = otrSession.getSessionStatus();
83 if (body == null && status == SessionStatus.ENCRYPTED) {
84 mXmppConnectionService.onOtrSessionEstablished(conversation);
85 return null;
86 } else if (body == null && status == SessionStatus.FINISHED) {
87 conversation.resetOtrSession();
88 mXmppConnectionService.updateConversationUi();
89 return null;
90 } else if (body == null || (body.isEmpty())) {
91 return null;
92 }
93 if (body.startsWith(CryptoHelper.FILETRANSFER)) {
94 String key = body.substring(CryptoHelper.FILETRANSFER.length());
95 conversation.setSymmetricKey(CryptoHelper.hexToBytes(key));
96 return null;
97 }
98 Message finishedMessage = new Message(conversation, body, Message.ENCRYPTION_OTR, Message.STATUS_RECEIVED);
99 conversation.setLastReceivedOtrMessageId(null);
100 return finishedMessage;
101 } catch (Exception e) {
102 conversation.resetOtrSession();
103 return null;
104 }
105 }
106
107 private Message parseAxolotlChat(Element axolotlMessage, Jid from, String id, Conversation conversation, int status) {
108 Message finishedMessage = null;
109 AxolotlService service = conversation.getAccount().getAxolotlService();
110 XmppAxolotlMessage xmppAxolotlMessage = XmppAxolotlMessage.fromElement(axolotlMessage, from.toBareJid());
111 XmppAxolotlMessage.XmppAxolotlPlaintextMessage plaintextMessage = service.processReceivingPayloadMessage(xmppAxolotlMessage);
112 if(plaintextMessage != null) {
113 finishedMessage = new Message(conversation, plaintextMessage.getPlaintext(), Message.ENCRYPTION_AXOLOTL, status);
114 finishedMessage.setAxolotlFingerprint(plaintextMessage.getFingerprint());
115 Log.d(Config.LOGTAG, AxolotlService.getLogprefix(finishedMessage.getConversation().getAccount())+" Received Message with session fingerprint: "+plaintextMessage.getFingerprint());
116 }
117
118 return finishedMessage;
119 }
120
121 private class Invite {
122 Jid jid;
123 String password;
124 Invite(Jid jid, String password) {
125 this.jid = jid;
126 this.password = password;
127 }
128
129 public boolean execute(Account account) {
130 if (jid != null) {
131 Conversation conversation = mXmppConnectionService.findOrCreateConversation(account, jid, true);
132 if (!conversation.getMucOptions().online()) {
133 conversation.getMucOptions().setPassword(password);
134 mXmppConnectionService.databaseBackend.updateConversation(conversation);
135 mXmppConnectionService.joinMuc(conversation);
136 mXmppConnectionService.updateConversationUi();
137 }
138 return true;
139 }
140 return false;
141 }
142 }
143
144 private Invite extractInvite(Element message) {
145 Element x = message.findChild("x", "http://jabber.org/protocol/muc#user");
146 if (x != null) {
147 Element invite = x.findChild("invite");
148 if (invite != null) {
149 Element pw = x.findChild("password");
150 return new Invite(message.getAttributeAsJid("from"), pw != null ? pw.getContent(): null);
151 }
152 } else {
153 x = message.findChild("x","jabber:x:conference");
154 if (x != null) {
155 return new Invite(x.getAttributeAsJid("jid"),x.getAttribute("password"));
156 }
157 }
158 return null;
159 }
160
161 private static String extractStanzaId(Element packet, Jid by) {
162 for(Element child : packet.getChildren()) {
163 if (child.getName().equals("stanza-id")
164 && "urn:xmpp:sid:0".equals(child.getNamespace())
165 && by.equals(child.getAttributeAsJid("by"))) {
166 return child.getAttribute("id");
167 }
168 }
169 return null;
170 }
171
172 private void parseEvent(final Element event, final Jid from, final Account account) {
173 Element items = event.findChild("items");
174 String node = items == null ? null : items.getAttribute("node");
175 if ("urn:xmpp:avatar:metadata".equals(node)) {
176 Avatar avatar = Avatar.parseMetadata(items);
177 if (avatar != null) {
178 avatar.owner = from.toBareJid();
179 if (mXmppConnectionService.getFileBackend().isAvatarCached(avatar)) {
180 if (account.getJid().toBareJid().equals(from)) {
181 if (account.setAvatar(avatar.getFilename())) {
182 mXmppConnectionService.databaseBackend.updateAccount(account);
183 }
184 mXmppConnectionService.getAvatarService().clear(account);
185 mXmppConnectionService.updateConversationUi();
186 mXmppConnectionService.updateAccountUi();
187 } else {
188 Contact contact = account.getRoster().getContact(from);
189 contact.setAvatar(avatar);
190 mXmppConnectionService.getAvatarService().clear(contact);
191 mXmppConnectionService.updateConversationUi();
192 mXmppConnectionService.updateRosterUi();
193 }
194 } else {
195 mXmppConnectionService.fetchAvatar(account, avatar);
196 }
197 }
198 } else if ("http://jabber.org/protocol/nick".equals(node)) {
199 Element i = items.findChild("item");
200 Element nick = i == null ? null : i.findChild("nick", "http://jabber.org/protocol/nick");
201 if (nick != null && nick.getContent() != null) {
202 Contact contact = account.getRoster().getContact(from);
203 contact.setPresenceName(nick.getContent());
204 mXmppConnectionService.getAvatarService().clear(account);
205 mXmppConnectionService.updateConversationUi();
206 mXmppConnectionService.updateAccountUi();
207 }
208 } else if (AxolotlService.PEP_DEVICE_LIST.equals(node)) {
209 Log.d(Config.LOGTAG, AxolotlService.getLogprefix(account)+"Received PEP device list update from "+ from + ", processing...");
210 Element item = items.findChild("item");
211 Set<Integer> deviceIds = mXmppConnectionService.getIqParser().deviceIds(item);
212 AxolotlService axolotlService = account.getAxolotlService();
213 axolotlService.registerDevices(from, deviceIds);
214 mXmppConnectionService.updateAccountUi();
215 }
216 }
217
218 private boolean handleErrorMessage(Account account, MessagePacket packet) {
219 if (packet.getType() == MessagePacket.TYPE_ERROR) {
220 Jid from = packet.getFrom();
221 if (from != null) {
222 Element error = packet.findChild("error");
223 String text = error == null ? null : error.findChildContent("text");
224 if (text != null) {
225 Log.d(Config.LOGTAG, account.getJid().toBareJid() + ": sending message to "+ from+ " failed - " + text);
226 } else if (error != null) {
227 Log.d(Config.LOGTAG, account.getJid().toBareJid() + ": sending message to "+ from+ " failed - " + error);
228 }
229 Message message = mXmppConnectionService.markMessage(account,
230 from.toBareJid(),
231 packet.getId(),
232 Message.STATUS_SEND_FAILED);
233 if (message != null && message.getEncryption() == Message.ENCRYPTION_OTR) {
234 message.getConversation().endOtrIfNeeded();
235 }
236 }
237 return true;
238 }
239 return false;
240 }
241
242 @Override
243 public void onMessagePacketReceived(Account account, MessagePacket original) {
244 if (handleErrorMessage(account, original)) {
245 return;
246 }
247 final MessagePacket packet;
248 Long timestamp = null;
249 final boolean isForwarded;
250 boolean isCarbon = false;
251 String serverMsgId = null;
252 final Element fin = original.findChild("fin", "urn:xmpp:mam:0");
253 if (fin != null) {
254 mXmppConnectionService.getMessageArchiveService().processFin(fin,original.getFrom());
255 return;
256 }
257 final Element result = original.findChild("result","urn:xmpp:mam:0");
258 final MessageArchiveService.Query query = result == null ? null : mXmppConnectionService.getMessageArchiveService().findQuery(result.getAttribute("queryid"));
259 if (query != null && query.validFrom(original.getFrom())) {
260 Pair<MessagePacket, Long> f = original.getForwardedMessagePacket("result", "urn:xmpp:mam:0");
261 if (f == null) {
262 return;
263 }
264 timestamp = f.second;
265 packet = f.first;
266 isForwarded = true;
267 serverMsgId = result.getAttribute("id");
268 query.incrementMessageCount();
269 } else if (query != null) {
270 Log.d(Config.LOGTAG,account.getJid().toBareJid()+": received mam result from invalid sender");
271 return;
272 } else if (original.fromServer(account)) {
273 Pair<MessagePacket, Long> f;
274 f = original.getForwardedMessagePacket("received", "urn:xmpp:carbons:2");
275 f = f == null ? original.getForwardedMessagePacket("sent", "urn:xmpp:carbons:2") : f;
276 packet = f != null ? f.first : original;
277 if (handleErrorMessage(account, packet)) {
278 return;
279 }
280 timestamp = f != null ? f.second : null;
281 isCarbon = f != null;
282 isForwarded = isCarbon;
283 } else {
284 packet = original;
285 isForwarded = false;
286 }
287
288 if (timestamp == null) {
289 timestamp = AbstractParser.getTimestamp(packet, System.currentTimeMillis());
290 }
291 final String body = packet.getBody();
292 final Element mucUserElement = packet.findChild("x", "http://jabber.org/protocol/muc#user");
293 final String pgpEncrypted = packet.findChildContent("x", "jabber:x:encrypted");
294 final Element replaceElement = packet.findChild("replace","urn:xmpp:message-correct:0");
295 final String replacementId = replaceElement == null ? null : replaceElement.getAttribute("id");
296 final Element axolotlEncrypted = packet.findChild(XmppAxolotlMessage.CONTAINERTAG, AxolotlService.PEP_PREFIX);
297 int status;
298 final Jid counterpart;
299 final Jid to = packet.getTo();
300 final Jid from = packet.getFrom();
301 final String remoteMsgId = packet.getId();
302
303 if (from == null) {
304 Log.d(Config.LOGTAG,"no from in: "+packet.toString());
305 return;
306 }
307
308 boolean isTypeGroupChat = packet.getType() == MessagePacket.TYPE_GROUPCHAT;
309 boolean isProperlyAddressed = (to != null ) && (!to.isBareJid() || account.countPresences() <= 1);
310 boolean isMucStatusMessage = from.isBareJid() && mucUserElement != null && mucUserElement.hasChild("status");
311 if (packet.fromAccount(account)) {
312 status = Message.STATUS_SEND;
313 counterpart = to != null ? to : account.getJid();
314 } else {
315 status = Message.STATUS_RECEIVED;
316 counterpart = from;
317 }
318
319 Invite invite = extractInvite(packet);
320 if (invite != null && invite.execute(account)) {
321 return;
322 }
323
324 if (extractChatState(mXmppConnectionService.find(account, counterpart.toBareJid()), packet)) {
325 mXmppConnectionService.updateConversationUi();
326 }
327
328 if ((body != null || pgpEncrypted != null || axolotlEncrypted != null) && !isMucStatusMessage) {
329 Conversation conversation = mXmppConnectionService.findOrCreateConversation(account, counterpart.toBareJid(), isTypeGroupChat, query);
330 if (isTypeGroupChat) {
331 if (counterpart.getResourcepart().equals(conversation.getMucOptions().getActualNick())) {
332 status = Message.STATUS_SEND_RECEIVED;
333 isCarbon = true; //not really carbon but received from another resource
334 if (mXmppConnectionService.markMessage(conversation, remoteMsgId, status)) {
335 return;
336 } else if (remoteMsgId == null || Config.IGNORE_ID_REWRITE_IN_MUC) {
337 Message message = conversation.findSentMessageWithBody(packet.getBody());
338 if (message != null) {
339 mXmppConnectionService.markMessage(message, status);
340 return;
341 }
342 }
343 } else {
344 status = Message.STATUS_RECEIVED;
345 }
346 }
347 Message message;
348 if (body != null && body.startsWith("?OTR")) {
349 if (!isForwarded && !isTypeGroupChat && isProperlyAddressed) {
350 message = parseOtrChat(body, from, remoteMsgId, conversation);
351 if (message == null) {
352 return;
353 }
354 } else {
355 Log.d(Config.LOGTAG,account.getJid().toBareJid()+": ignoring OTR message from "+from+" isForwarded="+Boolean.toString(isForwarded)+", isProperlyAddressed="+Boolean.valueOf(isProperlyAddressed));
356 message = new Message(conversation, body, Message.ENCRYPTION_NONE, status);
357 }
358 } else if (pgpEncrypted != null) {
359 message = new Message(conversation, pgpEncrypted, Message.ENCRYPTION_PGP, status);
360 } else if (axolotlEncrypted != null) {
361 message = parseAxolotlChat(axolotlEncrypted, from, remoteMsgId, conversation, status);
362 if (message == null) {
363 return;
364 }
365 } else {
366 message = new Message(conversation, body, Message.ENCRYPTION_NONE, status);
367 }
368
369 if (serverMsgId == null) {
370 serverMsgId = extractStanzaId(packet, isTypeGroupChat ? conversation.getJid().toBareJid() : account.getServer());
371 }
372
373 message.setCounterpart(counterpart);
374 message.setRemoteMsgId(remoteMsgId);
375 message.setServerMsgId(serverMsgId);
376 message.setCarbon(isCarbon);
377 message.setTime(timestamp);
378 message.markable = packet.hasChild("markable", "urn:xmpp:chat-markers:0");
379 if (conversation.getMode() == Conversation.MODE_MULTI) {
380 Jid trueCounterpart = conversation.getMucOptions().getTrueCounterpart(counterpart.getResourcepart());
381 message.setTrueCounterpart(trueCounterpart);
382 if (trueCounterpart != null) {
383 updateLastseen(timestamp, account, trueCounterpart, false);
384 }
385 if (!isTypeGroupChat) {
386 message.setType(Message.TYPE_PRIVATE);
387 }
388 } else {
389 updateLastseen(timestamp, account, packet.getFrom(), true);
390 }
391
392 if (replacementId != null && mXmppConnectionService.allowMessageCorrection()) {
393 Message replacedMessage = conversation.findMessageWithRemoteIdAndCounterpart(replacementId,
394 counterpart,
395 message.getStatus() == Message.STATUS_RECEIVED,
396 message.isCarbon());
397 if (replacedMessage != null) {
398 final boolean fingerprintsMatch = replacedMessage.getAxolotlFingerprint() == null
399 || replacedMessage.getAxolotlFingerprint().equals(message.getAxolotlFingerprint());
400 final boolean trueCountersMatch = replacedMessage.getTrueCounterpart() != null
401 && replacedMessage.getTrueCounterpart().equals(message.getTrueCounterpart());
402 if (fingerprintsMatch && (trueCountersMatch || conversation.getMode() == Conversation.MODE_SINGLE)) {
403 Log.d(Config.LOGTAG, "replaced message '" + replacedMessage.getBody() + "' with '" + message.getBody() + "'");
404 final String uuid = replacedMessage.getUuid();
405 replacedMessage.setUuid(UUID.randomUUID().toString());
406 replacedMessage.setBody(message.getBody());
407 replacedMessage.setEdited(replacedMessage.getRemoteMsgId());
408 replacedMessage.setRemoteMsgId(remoteMsgId);
409 replacedMessage.setEncryption(message.getEncryption());
410 if (replacedMessage.getStatus() == Message.STATUS_RECEIVED) {
411 replacedMessage.markUnread();
412 }
413 mXmppConnectionService.updateMessage(replacedMessage, uuid);
414 if (mXmppConnectionService.confirmMessages() && remoteMsgId != null && !isForwarded && !isTypeGroupChat) {
415 sendMessageReceipts(account, packet);
416 }
417 if (replacedMessage.getEncryption() == Message.ENCRYPTION_PGP) {
418 conversation.getAccount().getPgpDecryptionService().add(replacedMessage);
419 }
420 return;
421 } else {
422 Log.d(Config.LOGTAG,account.getJid().toBareJid()+": received message correction but verification didn't check out");
423 }
424 }
425 }
426
427 boolean checkForDuplicates = query != null
428 || (isTypeGroupChat && packet.hasChild("delay","urn:xmpp:delay"))
429 || message.getType() == Message.TYPE_PRIVATE;
430 if (checkForDuplicates && conversation.hasDuplicateMessage(message)) {
431 Log.d(Config.LOGTAG,"skipping duplicate message from "+message.getCounterpart().toString()+" "+message.getBody());
432 return;
433 }
434
435 if (query != null && query.getPagingOrder() == MessageArchiveService.PagingOrder.REVERSE) {
436 conversation.prepend(message);
437 } else {
438 conversation.add(message);
439 }
440
441 if (message.getEncryption() == Message.ENCRYPTION_PGP) {
442 conversation.getAccount().getPgpDecryptionService().add(message);
443 }
444
445 if (query == null || query.getWith() == null) { //either no mam or catchup
446 if (status == Message.STATUS_SEND || status == Message.STATUS_SEND_RECEIVED) {
447 mXmppConnectionService.markRead(conversation);
448 if (query == null) {
449 account.activateGracePeriod();
450 }
451 } else {
452 message.markUnread();
453 }
454 }
455
456 if (query == null) {
457 mXmppConnectionService.updateConversationUi();
458 }
459
460 if (mXmppConnectionService.confirmMessages() && remoteMsgId != null && !isForwarded && !isTypeGroupChat) {
461 sendMessageReceipts(account, packet);
462 }
463
464 if (message.getStatus() == Message.STATUS_RECEIVED
465 && conversation.getOtrSession() != null
466 && !conversation.getOtrSession().getSessionID().getUserID()
467 .equals(message.getCounterpart().getResourcepart())) {
468 conversation.endOtrIfNeeded();
469 }
470
471 if (message.getEncryption() == Message.ENCRYPTION_NONE || mXmppConnectionService.saveEncryptedMessages()) {
472 mXmppConnectionService.databaseBackend.createMessage(message);
473 }
474 final HttpConnectionManager manager = this.mXmppConnectionService.getHttpConnectionManager();
475 if (message.trusted() && message.treatAsDownloadable() != Message.Decision.NEVER && manager.getAutoAcceptFileSize() > 0) {
476 manager.createNewDownloadConnection(message);
477 } else if (!message.isRead()) {
478 if (query == null) {
479 mXmppConnectionService.getNotificationService().push(message);
480 } else if (query.getWith() == null) { // mam catchup
481 mXmppConnectionService.getNotificationService().pushFromBacklog(message);
482 }
483 }
484 } else if (!packet.hasChild("body")){ //no body
485 if (isTypeGroupChat) {
486 Conversation conversation = mXmppConnectionService.find(account, from.toBareJid());
487 if (packet.hasChild("subject")) {
488 if (conversation != null && conversation.getMode() == Conversation.MODE_MULTI) {
489 conversation.setHasMessagesLeftOnServer(conversation.countMessages() > 0);
490 String subject = packet.findChildContent("subject");
491 conversation.getMucOptions().setSubject(subject);
492 final Bookmark bookmark = conversation.getBookmark();
493 if (bookmark != null && bookmark.getBookmarkName() == null) {
494 if (bookmark.setBookmarkName(subject)) {
495 mXmppConnectionService.pushBookmarks(account);
496 }
497 }
498 mXmppConnectionService.updateConversationUi();
499 return;
500 }
501 }
502
503 if (conversation != null && isMucStatusMessage) {
504 for (Element child : mucUserElement.getChildren()) {
505 if (child.getName().equals("status")
506 && MucOptions.STATUS_CODE_ROOM_CONFIG_CHANGED.equals(child.getAttribute("code"))) {
507 mXmppConnectionService.fetchConferenceConfiguration(conversation);
508 }
509 }
510 }
511 }
512 }
513
514 Element received = packet.findChild("received", "urn:xmpp:chat-markers:0");
515 if (received == null) {
516 received = packet.findChild("received", "urn:xmpp:receipts");
517 }
518 if (received != null && !packet.fromAccount(account)) {
519 mXmppConnectionService.markMessage(account, from.toBareJid(), received.getAttribute("id"), Message.STATUS_SEND_RECEIVED);
520 }
521 Element displayed = packet.findChild("displayed", "urn:xmpp:chat-markers:0");
522 if (displayed != null) {
523 if (packet.fromAccount(account)) {
524 Conversation conversation = mXmppConnectionService.find(account,counterpart.toBareJid());
525 if (conversation != null) {
526 mXmppConnectionService.markRead(conversation);
527 }
528 } else {
529 updateLastseen(timestamp, account, packet.getFrom(), true);
530 final Message displayedMessage = mXmppConnectionService.markMessage(account, from.toBareJid(), displayed.getAttribute("id"), Message.STATUS_SEND_DISPLAYED);
531 Message message = displayedMessage == null ? null : displayedMessage.prev();
532 while (message != null
533 && message.getStatus() == Message.STATUS_SEND_RECEIVED
534 && message.getTimeSent() < displayedMessage.getTimeSent()) {
535 mXmppConnectionService.markMessage(message, Message.STATUS_SEND_DISPLAYED);
536 message = message.prev();
537 }
538 }
539 }
540
541 Element event = packet.findChild("event", "http://jabber.org/protocol/pubsub#event");
542 if (event != null) {
543 parseEvent(event, from, account);
544 }
545
546 String nick = packet.findChildContent("nick", "http://jabber.org/protocol/nick");
547 if (nick != null) {
548 Contact contact = account.getRoster().getContact(from);
549 contact.setPresenceName(nick);
550 }
551 }
552
553 private void sendMessageReceipts(Account account, MessagePacket packet) {
554 ArrayList<String> receiptsNamespaces = new ArrayList<>();
555 if (packet.hasChild("markable", "urn:xmpp:chat-markers:0")) {
556 receiptsNamespaces.add("urn:xmpp:chat-markers:0");
557 }
558 if (packet.hasChild("request", "urn:xmpp:receipts")) {
559 receiptsNamespaces.add("urn:xmpp:receipts");
560 }
561 if (receiptsNamespaces.size() > 0) {
562 MessagePacket receipt = mXmppConnectionService.getMessageGenerator().received(account,
563 packet,
564 receiptsNamespaces,
565 packet.getType());
566 mXmppConnectionService.sendMessagePacket(account, receipt);
567 }
568 }
569}