Message JabberChatService::handleNormalReceivedMessage(const QXmppMessage &xmppMessage) { auto jid = Jid::parse(xmppMessage.from()); auto contact = ContactManager::instance()->byId(account(), jid.bare(), ActionCreateAndAdd); auto chat = ChatTypeContact::findChat(contact, ActionCreateAndAdd); contact.addProperty("jabber:chat-resource", jid.resource(), CustomProperties::NonStorable); auto message = Message::create(); message.setMessageChat(chat); message.setMessageSender(contact); return message; }
void FacebookChatService::unreadMessageReceived(const QFacebookDownloadUnreadMessageResult &result) { if (m_receivedMessages.find(result.messageId) != std::end(m_receivedMessages)) return; m_receivedMessages.insert(std::make_pair(result.messageId, QDateTime::currentDateTime())); auto contact = m_contactManager->byId(account(), QString::number(result.senderUid), ActionCreateAndAdd); auto chat = ChatTypeContact::findChat(m_chatManager, m_chatStorage, contact, ActionCreateAndAdd); auto message = m_messageStorage->create(); message.setMessageChat(chat); message.setType(MessageType::MessageTypeReceived); message.setMessageSender(contact); message.setSendDate(result.timestamp); message.setReceiveDate(QDateTime::currentDateTime()); message.setContent(normalizeHtml(plainToHtml(result.text))); emit messageReceived(message); }
Message JabberRoomChatService::handleReceivedMessage(const QXmppMessage &xmppMessage) const { auto jid = Jid::parse(xmppMessage.from()); auto roomChat = getRoomChat(jid.bare()); if (!roomChat) return Message::null; if (jid.resource() == roomChat->nick()) // message from myself return Message::null; auto contact = m_contactManager->byId(account(), jid.full(), ActionCreateAndAdd); auto buddy = m_buddyManager->byContact(contact, ActionCreateAndAdd); buddy.setDisplay(jid.resource()); buddy.setTemporary(true); auto result = m_messageStorage->create(); result.setMessageChat(roomChat->chat()); result.setMessageSender(contact); return result; }