void ChatSession::OnMessageReceived(const Tp::ReceivedMessage &message)
{
    QList<Tp::ReceivedMessage> messages;
    messages.append(message);
    tp_text_channel_->acknowledge(messages);

    ChatSessionParticipant* from = GetParticipant(message.sender());
    ChatMessage* m = new ChatMessage(from, message.received(), message.text());
    message_history_.push_back(m);
    emit( MessageReceived(*m) );
}
Message::Message(const Tp::ReceivedMessage &original, const KTp::MessageContext &context) :
    d(new Private)
{
    Q_UNUSED(context)

    d->sentTime = original.sent();
    if (d->sentTime.isNull()) {
        d->sentTime = original.received();
    }

    d->token = original.messageToken();
    d->messageType = original.messageType();
    d->isHistory = original.isScrollback();
    d->direction = KTp::Message::RemoteToLocal;

    setMainMessagePart(original.text());

    if (!original.sender().isNull()) {
        d->sender = KTp::ContactPtr::qObjectCast(original.sender());
    } else {
        d->senderAlias = original.senderNickname();
    }
}