void TpSessionChannel::onMessageReceived(const Tp::ReceivedMessage &msg)
{
    QDEBUG_FUNCTION_BEGIN
    qDebug() << "TpSessionChannel::onMessageReceived " << msg.text();
    emit messageReceived(msg, this);
    QDEBUG_FUNCTION_END
};
Esempio n. 2
0
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) );
}
Esempio n. 3
0
void ChannelWatcher::onMessageReceived(const Tp::ReceivedMessage &message)
{
    if (!message.isDeliveryReport()) {
        StorageMessage msg;
        msg.messageDateTime = message.received();
        msg.accountObjectPathId = m_accountDbId;
        msg.targetContactId = m_contactDbId;
        msg.message = message.text();
        msg.messageToken = message.messageToken();
        msg.isIncoming = true;
        msg.isDelivered = true;
        msg.type = 1;

        if (msg.messageToken.isEmpty()) {
            msg.messageToken = QCryptographicHash::hash(QString(msg.messageDateTime.toString() + msg.message).toUtf8(),
                                                        QCryptographicHash::Md5);
        }

        storeMessage(msg);
    } else {
        qDebug() << "Received a delivery report for message" << message.deliveryDetails().originalToken();

        //TODO
        //     QSqlQuery updateQuery;
        //     updateQuery.prepare("UPDATE data SET deliveredDateTime = :deliveredDateTime, isDelivered = :isDelivered WHERE id = :id");
        //     updateQuery.bindValue(":deliveredDateTime", message.deliveredDateTime);
        //     updateQuery.bindValue(":isDelivered", message.isDelivered);
        //     updateQuery.bindValue(":id", message.id);
        //
        //     bool transactionBegin = d->db.transaction();
        //     qDebug() << "Update transaction begins" << transactionBegin;
        //     bool queryResult = updateQuery.exec();
        //     qDebug() << "Update query gut" << queryResult;
        //     if (queryResult) {
        //         d->db.commit();
        //     } else {
        //         qWarning() << updateQuery.lastError().text();
        //         d->db.rollback();
        //     }

    }
}
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();
    }
}