inline bool qCompare(const Akonadi::Tag &left, const Akonadi::Tag &right, const char *actual, const char *expected, const char *file, int line) { return zCompareHelper((left == right) && (left.name() == right.name()), left, right, actual, expected, file, line); }
void Serializer::updateTagFromAkonadiTag(Domain::Tag::Ptr tag, Akonadi::Tag akonadiTag) { if (!isAkonadiTag(akonadiTag)) return; tag->setProperty("tagId", akonadiTag.id()); tag->setName(akonadiTag.name()); }
void Serializer::updateContextFromTag(Domain::Context::Ptr context, Akonadi::Tag tag) { if (!isContext(tag)) return; context->setProperty("tagId", tag.id()); context->setName(tag.name()); }
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); }
void TagChangeHelper::start(const Akonadi::Tag &tag, const KMime::Message::Ptr &message, KIMAP::Session *session) { Q_ASSERT(tag.isValid()); const QString mailBox = mTask->mailBoxForCollection(mTask->relationCollection()); const qint64 oldUid = tag.remoteId().toLongLong(); qCDebug(KOLABRESOURCE_LOG) << mailBox << oldUid; const qint64 uidNext = -1; UpdateMessageJob *append = new UpdateMessageJob(message, session, tag.gid(), QSharedPointer<TagMerger>(new TagMerger), mailBox, uidNext, oldUid, this); connect(append, &KJob::result, this, &TagChangeHelper::onReplaceDone); append->setProperty("tag", QVariant::fromValue(tag)); append->start(); }
QByteArray EwsTagStore::serializeTag(const Akonadi::Tag &tag) const { QByteArray tagData; QDataStream stream(&tagData, QIODevice::WriteOnly); stream.setVersion(TagDataVer1StreamVer); stream << TagDataVer1; stream << tag.name() << tag.gid(); Attribute::List attrs = tag.attributes(); stream << (int)attrs.size(); Q_FOREACH(const Attribute *attr, attrs) { stream << attr->type(); stream << attr->serialized(); }
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()); } }
bool Serializer::isContextTag(const Domain::Context::Ptr &context, const Akonadi::Tag &tag) const { return (context->property("tagId").value<Akonadi::Tag::Id>() == tag.id()); }
bool Serializer::isContext(const Akonadi::Tag &tag) const { return (tag.type() == Akonadi::SerializerInterface::contextTagType()); }