Changeset View
Changeset View
Standalone View
Standalone View
agents/unifiedmailboxagent/unifiedmailboxmanager.cpp
Show First 20 Lines • Show All 91 Lines • ▼ Show 20 Line(s) | 89 | connect(&mMonitor, &Akonadi::Monitor::itemAdded, | |||
---|---|---|---|---|---|
92 | 92 | | |||
93 | qCDebug(UNIFIEDMAILBOXAGENT_LOG) << "Item" << item.id() << "added to collection" << collection.id(); | 93 | qCDebug(UNIFIEDMAILBOXAGENT_LOG) << "Item" << item.id() << "added to collection" << collection.id(); | ||
94 | const auto box = unifiedMailboxForSource(collection.id()); | 94 | const auto box = unifiedMailboxForSource(collection.id()); | ||
95 | if (!box) { | 95 | if (!box) { | ||
96 | qCWarning(UNIFIEDMAILBOXAGENT_LOG) << "Failed to find unified mailbox for source collection " << collection.id(); | 96 | qCWarning(UNIFIEDMAILBOXAGENT_LOG) << "Failed to find unified mailbox for source collection " << collection.id(); | ||
97 | return; | 97 | return; | ||
98 | } | 98 | } | ||
99 | 99 | | |||
100 | if (!box->collectionId()) { | 100 | if (box->collectionId() <= -1) { | ||
101 | qCWarning(UNIFIEDMAILBOXAGENT_LOG) << "Missing box->collection mapping for unified mailbox" << box->id(); | 101 | qCWarning(UNIFIEDMAILBOXAGENT_LOG) << "Missing box->collection mapping for unified mailbox" << box->id(); | ||
102 | return; | 102 | return; | ||
103 | } | 103 | } | ||
104 | 104 | | |||
105 | new Akonadi::LinkJob(Akonadi::Collection{box->collectionId().value()}, {item}, this); | 105 | new Akonadi::LinkJob(Akonadi::Collection{box->collectionId()}, {item}, this); | ||
106 | }); | 106 | }); | ||
107 | connect(&mMonitor, &Akonadi::Monitor::itemsRemoved, | 107 | connect(&mMonitor, &Akonadi::Monitor::itemsRemoved, | ||
108 | this, [this](const Akonadi::Item::List &items) { | 108 | this, [this](const Akonadi::Item::List &items) { | ||
109 | ReplayNextOnExit replayNext(mMonitor); | 109 | ReplayNextOnExit replayNext(mMonitor); | ||
110 | 110 | | |||
111 | // Monitor did the heavy lifting for us and already figured out that | 111 | // Monitor did the heavy lifting for us and already figured out that | ||
112 | // we only monitor the source collection of the Items and translated | 112 | // we only monitor the source collection of the Items and translated | ||
113 | // it into REMOVE change. | 113 | // it into REMOVE change. | ||
114 | 114 | | |||
115 | // This relies on Akonadi never mixing Items from different sources or | 115 | // This relies on Akonadi never mixing Items from different sources or | ||
116 | // destination during batch-moves. | 116 | // destination during batch-moves. | ||
117 | const auto parentId = items.first().parentCollection().id(); | 117 | const auto parentId = items.first().parentCollection().id(); | ||
118 | const auto box = unifiedMailboxForSource(parentId); | 118 | const auto box = unifiedMailboxForSource(parentId); | ||
119 | if (!box) { | 119 | if (!box) { | ||
120 | qCWarning(UNIFIEDMAILBOXAGENT_LOG) << "Received Remove notification for Items belonging to" << parentId << "which we don't monitor"; | 120 | qCWarning(UNIFIEDMAILBOXAGENT_LOG) << "Received Remove notification for Items belonging to" << parentId << "which we don't monitor"; | ||
121 | return; | 121 | return; | ||
122 | } | 122 | } | ||
123 | if (!box->collectionId()) { | 123 | if (box->collectionId() <= -1) { | ||
124 | qCWarning(UNIFIEDMAILBOXAGENT_LOG) << "Missing box->collection mapping for unified mailbox" << box->id(); | 124 | qCWarning(UNIFIEDMAILBOXAGENT_LOG) << "Missing box->collection mapping for unified mailbox" << box->id(); | ||
125 | return; | 125 | return; | ||
126 | } | 126 | } | ||
127 | 127 | | |||
128 | new Akonadi::UnlinkJob(Akonadi::Collection{box->collectionId().value()}, items, this); | 128 | new Akonadi::UnlinkJob(Akonadi::Collection{box->collectionId()}, items, this); | ||
129 | }); | 129 | }); | ||
130 | connect(&mMonitor, &Akonadi::Monitor::itemsMoved, | 130 | connect(&mMonitor, &Akonadi::Monitor::itemsMoved, | ||
131 | this, [this](const Akonadi::Item::List &items, const Akonadi::Collection &srcCollection, | 131 | this, [this](const Akonadi::Item::List &items, const Akonadi::Collection &srcCollection, | ||
132 | const Akonadi::Collection &dstCollection) { | 132 | const Akonadi::Collection &dstCollection) { | ||
133 | ReplayNextOnExit replayNext(mMonitor); | 133 | ReplayNextOnExit replayNext(mMonitor); | ||
134 | 134 | | |||
135 | if (const auto srcBox = unifiedMailboxForSource(srcCollection.id())) { | 135 | if (const auto srcBox = unifiedMailboxForSource(srcCollection.id())) { | ||
136 | // Move source collection was our source, unlink the Item from a box | 136 | // Move source collection was our source, unlink the Item from a box | ||
137 | new Akonadi::UnlinkJob(Akonadi::Collection{srcBox->collectionId().value()}, items, this); | 137 | new Akonadi::UnlinkJob(Akonadi::Collection{srcBox->collectionId()}, items, this); | ||
138 | } | 138 | } | ||
139 | if (const auto dstBox = unifiedMailboxForSource(dstCollection.id())) { | 139 | if (const auto dstBox = unifiedMailboxForSource(dstCollection.id())) { | ||
140 | // Move destination collection is our source, link the Item into a box | 140 | // Move destination collection is our source, link the Item into a box | ||
141 | new Akonadi::LinkJob(Akonadi::Collection{dstBox->collectionId().value()}, items, this); | 141 | new Akonadi::LinkJob(Akonadi::Collection{dstBox->collectionId()}, items, this); | ||
142 | } | 142 | } | ||
143 | }); | 143 | }); | ||
144 | 144 | | |||
145 | connect(&mMonitor, &Akonadi::Monitor::collectionRemoved, | 145 | connect(&mMonitor, &Akonadi::Monitor::collectionRemoved, | ||
146 | this, [this](const Akonadi::Collection &col) { | 146 | this, [this](const Akonadi::Collection &col) { | ||
147 | ReplayNextOnExit replayNext(mMonitor); | 147 | ReplayNextOnExit replayNext(mMonitor); | ||
148 | 148 | | |||
149 | if (auto box = unifiedMailboxForSource(col.id())) { | 149 | if (auto box = unifiedMailboxForSource(col.id())) { | ||
▲ Show 20 Lines • Show All 292 Lines • Show Last 20 Lines |