Message::Message(const Tp::Message &original, const KTp::MessageContext &context) :
    d(new Private)
{
    d->sentTime = original.sent();
    d->token = original.messageToken();
    d->messageType = original.messageType();
    d->isHistory = false;
    d->direction = KTp::Message::LocalToRemote;

    setMainMessagePart(original.text());

    if (context.account()->connection()) {
        d->sender = KTp::ContactPtr::qObjectCast(context.account()->connection()->selfContact());
    } else {
        d->senderAlias = context.account()->nickname();
        d->senderId = context.account()->uniqueIdentifier();
    }
}
Esempio n. 2
0
void HighlightFilter::filterMessage(KTp::Message &message,
                                    const KTp::MessageContext &context)
{
    QString msg = message.mainMessagePart();

    if (msg.contains(context.account()->nickname(), Qt::CaseInsensitive)) {
        message.setProperty("highlight", true);
    }

    if (msg.contains(d->user.loginName(), Qt::CaseInsensitive)) {
        message.setProperty("highlight", true);
    }
}