public MessagePacket generateChatState(Conversation conversation) {
   final Account account = conversation.getAccount();
   MessagePacket packet = new MessagePacket();
   packet.setTo(conversation.getJid().toBareJid());
   packet.setFrom(account.getJid());
   packet.addChild(ChatState.toElement(conversation.getOutgoingChatState()));
   return packet;
 }
 protected void filterContacts(final String needle) {
   getListItems().clear();
   for (final Account account : xmppConnectionService.getAccounts()) {
     if (account.getStatus() != Account.State.DISABLED) {
       for (final Contact contact : account.getRoster().getContacts()) {
         if (contact.showInRoster()
             && !filterContacts.contains(contact.getJid().toBareJid().toString())
             && contact.match(needle)) {
           getListItems().add(contact);
         }
       }
     }
   }
   Collections.sort(getListItems());
   getListItemAdapter().notifyDataSetChanged();
 }
 private MessagePacket preparePacket(Message message, boolean addDelay) {
   Conversation conversation = message.getConversation();
   Account account = conversation.getAccount();
   MessagePacket packet = new MessagePacket();
   packet.setTo(message.getCounterpart());
   packet.setType(MessagePacket.TYPE_CHAT);
   packet.addChild("markable", "urn:xmpp:chat-markers:0");
   if (this.mXmppConnectionService.indicateReceived()) {
     packet.addChild("request", "urn:xmpp:receipts");
   }
   packet.setFrom(account.getJid());
   packet.setId(message.getUuid());
   if (addDelay) {
     addDelay(packet, message.getTimeSent());
   }
   return packet;
 }
 public MessagePacket received(Account account, MessagePacket originalMessage, String namespace) {
   MessagePacket receivedPacket = new MessagePacket();
   receivedPacket.setType(MessagePacket.TYPE_NORMAL);
   receivedPacket.setTo(originalMessage.getFrom());
   receivedPacket.setFrom(account.getJid());
   Element received = receivedPacket.addChild("received", namespace);
   received.setAttribute("id", originalMessage.getId());
   return receivedPacket;
 }
 public MessagePacket confirm(final Account account, final Jid to, final String id) {
   MessagePacket packet = new MessagePacket();
   packet.setType(MessagePacket.TYPE_NORMAL);
   packet.setTo(to);
   packet.setFrom(account.getJid());
   Element received = packet.addChild("displayed", "urn:xmpp:chat-markers:0");
   received.setAttribute("id", id);
   return packet;
 }