Пример #1
0
void Serializer::updateTagFromAkonadiTag(Domain::Tag::Ptr tag, Akonadi::Tag akonadiTag)
{
    if (!isAkonadiTag(akonadiTag))
        return;

    tag->setProperty("tagId", akonadiTag.id());
    tag->setName(akonadiTag.name());
}
Пример #2
0
void Serializer::updateContextFromTag(Domain::Context::Ptr context, Akonadi::Tag tag)
{
    if (!isContext(tag))
        return;

    context->setProperty("tagId", tag.id());
    context->setName(tag.name());
}
Пример #3
0
void TagTest::testMonitor()
{
    Akonadi::Monitor monitor;
    monitor.setTypeMonitored(Akonadi::Monitor::Tags);
    monitor.tagFetchScope().fetchAttribute<Akonadi::TagAttribute>();

    Akonadi::Tag createdTag;
    {
        QSignalSpy addedSpy(&monitor, SIGNAL(tagAdded(Akonadi::Tag)));
        QVERIFY(addedSpy.isValid());
        Tag tag;
        tag.setGid("gid2");
        tag.setName(QStringLiteral("name2"));
        tag.setType("type2");
        TagCreateJob *createjob = new TagCreateJob(tag, this);
        AKVERIFYEXEC(createjob);
        createdTag = createjob->tag();
        //We usually pick up signals from the previous tests as well (due to server-side notification caching)
        QTRY_VERIFY(addedSpy.count() >= 1);
        QTRY_COMPARE(addedSpy.last().first().value<Akonadi::Tag>().id(), createdTag.id());
        QVERIFY(addedSpy.last().first().value<Akonadi::Tag>().hasAttribute<Akonadi::TagAttribute>());
    }

    {
        QSignalSpy modifedSpy(&monitor, SIGNAL(tagChanged(Akonadi::Tag)));
        QVERIFY(modifedSpy.isValid());
        createdTag.setName(QStringLiteral("name3"));

        TagModifyJob *modJob = new TagModifyJob(createdTag, this);
        AKVERIFYEXEC(modJob);
        //We usually pick up signals from the previous tests as well (due to server-side notification caching)
        QTRY_VERIFY(modifedSpy.count() >= 1);
        QTRY_COMPARE(modifedSpy.last().first().value<Akonadi::Tag>().id(), createdTag.id());
        QVERIFY(modifedSpy.last().first().value<Akonadi::Tag>().hasAttribute<Akonadi::TagAttribute>());
    }

    {
        QSignalSpy removedSpy(&monitor, SIGNAL(tagRemoved(Akonadi::Tag)));
        QVERIFY(removedSpy.isValid());
        TagDeleteJob *deletejob = new TagDeleteJob(createdTag, this);
        AKVERIFYEXEC(deletejob);
        QTRY_VERIFY(removedSpy.count() >= 1);
        QTRY_COMPARE(removedSpy.last().first().value<Akonadi::Tag>().id(), createdTag.id());
    }
}
Пример #4
0
void TagChangeHelper::recordNewUid(qint64 newUid, Akonadi::Tag tag)
{
    Q_ASSERT(newUid > 0);
    Q_ASSERT(tag.isValid());

    const QByteArray remoteId =  QByteArray::number(newUid);
    qCDebug(KOLABRESOURCE_LOG) << "Setting remote ID to " << remoteId << " on tag with local id: " << tag.id();
    //Make sure we only update the id and send nothing else
    Akonadi::Tag updateTag;
    updateTag.setId(tag.id());
    updateTag.setRemoteId(remoteId);
    Akonadi::TagModifyJob *modJob = new Akonadi::TagModifyJob(updateTag);
    connect(modJob, &KJob::result, this, &TagChangeHelper::onModifyDone);
}
Пример #5
0
bool Serializer::isContextTag(const Domain::Context::Ptr &context, const Akonadi::Tag &tag) const
{
    return (context->property("tagId").value<Akonadi::Tag::Id>() == tag.id());
}