File indexing completed on 2024-11-24 04:44:00
0001 /* 0002 SPDX-FileCopyrightText: 2010 Klarälvdalens Datakonsult AB, a KDAB Group company <info@kdab.com> 0003 SPDX-FileContributor: Kevin Ottens <kevin@kdab.com> 0004 0005 SPDX-License-Identifier: LGPL-2.0-or-later 0006 */ 0007 0008 #include "dummyresourcestate.h" 0009 Q_DECLARE_METATYPE(QList<qint64>) 0010 Q_DECLARE_METATYPE(QString) 0011 Q_DECLARE_METATYPE(TagListAndMembers) 0012 0013 DummyResourceState::DummyResourceState() 0014 : m_automaticExpunge(true) 0015 , m_subscriptionEnabled(true) 0016 , m_disconnectedMode(true) 0017 , m_intervalCheckTime(-1) 0018 , m_mergeMode(Akonadi::ItemSync::RIDMerge) 0019 { 0020 qRegisterMetaType<QList<qint64>>(); 0021 qRegisterMetaType<QList<qint64>>(); 0022 qRegisterMetaType<TagListAndMembers>(); 0023 } 0024 0025 DummyResourceState::~DummyResourceState() = default; 0026 0027 void DummyResourceState::setUserName(const QString &name) 0028 { 0029 m_userName = name; 0030 } 0031 0032 QString DummyResourceState::userName() const 0033 { 0034 return m_userName; 0035 } 0036 0037 void DummyResourceState::setResourceName(const QString &name) 0038 { 0039 m_resourceName = name; 0040 } 0041 0042 QString DummyResourceState::resourceName() const 0043 { 0044 return m_resourceName; 0045 } 0046 0047 void DummyResourceState::setResourceIdentifier(const QString &identifier) 0048 { 0049 m_resourceIdentifier = identifier; 0050 } 0051 0052 QString DummyResourceState::resourceIdentifier() const 0053 { 0054 return m_resourceIdentifier; 0055 } 0056 0057 void DummyResourceState::setServerCapabilities(const QStringList &capabilities) 0058 { 0059 m_capabilities = capabilities; 0060 } 0061 0062 QStringList DummyResourceState::serverCapabilities() const 0063 { 0064 return m_capabilities; 0065 } 0066 0067 void DummyResourceState::setServerNamespaces(const QList<KIMAP::MailBoxDescriptor> &namespaces) 0068 { 0069 m_namespaces = namespaces; 0070 } 0071 0072 QList<KIMAP::MailBoxDescriptor> DummyResourceState::serverNamespaces() const 0073 { 0074 return m_namespaces; 0075 } 0076 0077 QList<KIMAP::MailBoxDescriptor> DummyResourceState::personalNamespaces() const 0078 { 0079 return {}; 0080 } 0081 0082 QList<KIMAP::MailBoxDescriptor> DummyResourceState::userNamespaces() const 0083 { 0084 return {}; 0085 } 0086 0087 QList<KIMAP::MailBoxDescriptor> DummyResourceState::sharedNamespaces() const 0088 { 0089 return {}; 0090 } 0091 0092 void DummyResourceState::setAutomaticExpungeEnagled(bool enabled) 0093 { 0094 m_automaticExpunge = enabled; 0095 } 0096 0097 bool DummyResourceState::isAutomaticExpungeEnabled() const 0098 { 0099 return m_automaticExpunge; 0100 } 0101 0102 void DummyResourceState::setSubscriptionEnabled(bool enabled) 0103 { 0104 m_subscriptionEnabled = enabled; 0105 } 0106 0107 bool DummyResourceState::isSubscriptionEnabled() const 0108 { 0109 return m_subscriptionEnabled; 0110 } 0111 0112 void DummyResourceState::setDisconnectedModeEnabled(bool enabled) 0113 { 0114 m_disconnectedMode = enabled; 0115 } 0116 0117 bool DummyResourceState::isDisconnectedModeEnabled() const 0118 { 0119 return m_disconnectedMode; 0120 } 0121 0122 void DummyResourceState::setIntervalCheckTime(int interval) 0123 { 0124 m_intervalCheckTime = interval; 0125 } 0126 0127 int DummyResourceState::intervalCheckTime() const 0128 { 0129 return m_intervalCheckTime; 0130 } 0131 0132 void DummyResourceState::setCollection(const Akonadi::Collection &collection) 0133 { 0134 m_collection = collection; 0135 } 0136 0137 Akonadi::Collection DummyResourceState::collection() const 0138 { 0139 return m_collection; 0140 } 0141 0142 void DummyResourceState::setItem(const Akonadi::Item &item) 0143 { 0144 m_items.clear(); 0145 m_items << item; 0146 } 0147 0148 Akonadi::Item DummyResourceState::item() const 0149 { 0150 return m_items.first(); 0151 } 0152 0153 Akonadi::Item::List DummyResourceState::items() const 0154 { 0155 return m_items; 0156 } 0157 0158 void DummyResourceState::setParentCollection(const Akonadi::Collection &collection) 0159 { 0160 m_parentCollection = collection; 0161 } 0162 0163 Akonadi::Collection DummyResourceState::parentCollection() const 0164 { 0165 return m_parentCollection; 0166 } 0167 0168 void DummyResourceState::setSourceCollection(const Akonadi::Collection &collection) 0169 { 0170 m_sourceCollection = collection; 0171 } 0172 0173 Akonadi::Collection DummyResourceState::sourceCollection() const 0174 { 0175 return m_sourceCollection; 0176 } 0177 0178 void DummyResourceState::setTargetCollection(const Akonadi::Collection &collection) 0179 { 0180 m_targetCollection = collection; 0181 } 0182 0183 Akonadi::Collection DummyResourceState::targetCollection() const 0184 { 0185 return m_targetCollection; 0186 } 0187 0188 void DummyResourceState::setParts(const QSet<QByteArray> &parts) 0189 { 0190 m_parts = parts; 0191 } 0192 0193 QSet<QByteArray> DummyResourceState::parts() const 0194 { 0195 return m_parts; 0196 } 0197 0198 void DummyResourceState::setTag(const Akonadi::Tag &tag) 0199 { 0200 m_tag = tag; 0201 } 0202 0203 Akonadi::Tag DummyResourceState::tag() const 0204 { 0205 return m_tag; 0206 } 0207 0208 void DummyResourceState::setAddedTags(const QSet<Akonadi::Tag> &addedTags) 0209 { 0210 m_addedTags = addedTags; 0211 } 0212 0213 QSet<Akonadi::Tag> DummyResourceState::addedTags() const 0214 { 0215 return m_addedTags; 0216 } 0217 0218 void DummyResourceState::setRemovedTags(const QSet<Akonadi::Tag> &removedTags) 0219 { 0220 m_removedTags = removedTags; 0221 } 0222 0223 QSet<Akonadi::Tag> DummyResourceState::removedTags() const 0224 { 0225 return m_removedTags; 0226 } 0227 0228 Akonadi::Relation::List DummyResourceState::addedRelations() const 0229 { 0230 return {}; 0231 } 0232 0233 Akonadi::Relation::List DummyResourceState::removedRelations() const 0234 { 0235 return {}; 0236 } 0237 0238 QString DummyResourceState::rootRemoteId() const 0239 { 0240 return QStringLiteral("root-id"); 0241 } 0242 0243 void DummyResourceState::setIdleCollection(const Akonadi::Collection &collection) 0244 { 0245 recordCall("setIdleCollection", QVariant::fromValue(collection)); 0246 } 0247 0248 void DummyResourceState::applyCollectionChanges(const Akonadi::Collection &collection) 0249 { 0250 recordCall("applyCollectionChanges", QVariant::fromValue(collection)); 0251 } 0252 0253 void DummyResourceState::collectionAttributesRetrieved(const Akonadi::Collection &collection) 0254 { 0255 recordCall("collectionAttributesRetrieved", QVariant::fromValue(collection)); 0256 } 0257 0258 void DummyResourceState::itemRetrieved(const Akonadi::Item &item) 0259 { 0260 recordCall("itemRetrieved", QVariant::fromValue(item)); 0261 } 0262 0263 void DummyResourceState::itemsRetrieved(const Akonadi::Item::List &items) 0264 { 0265 recordCall("itemsRetrieved", QVariant::fromValue(items)); 0266 } 0267 0268 void DummyResourceState::itemsRetrievedIncremental(const Akonadi::Item::List &changed, const Akonadi::Item::List &removed) 0269 { 0270 Q_UNUSED(removed) 0271 0272 recordCall("itemsRetrievedIncremental", QVariant::fromValue(changed)); 0273 } 0274 0275 void DummyResourceState::itemsRetrievalDone() 0276 { 0277 recordCall("itemsRetrievalDone"); 0278 } 0279 0280 void DummyResourceState::setTotalItems(int) 0281 { 0282 } 0283 0284 QSet<QByteArray> DummyResourceState::addedFlags() const 0285 { 0286 return {}; 0287 } 0288 0289 QSet<QByteArray> DummyResourceState::removedFlags() const 0290 { 0291 return {}; 0292 } 0293 0294 void DummyResourceState::itemChangeCommitted(const Akonadi::Item &item) 0295 { 0296 recordCall("itemChangeCommitted", QVariant::fromValue(item)); 0297 } 0298 0299 void DummyResourceState::itemsChangesCommitted(const Akonadi::Item::List &items) 0300 { 0301 recordCall("itemsChangesCommitted", QVariant::fromValue(items)); 0302 } 0303 0304 void DummyResourceState::collectionsRetrieved(const Akonadi::Collection::List &collections) 0305 { 0306 recordCall("collectionsRetrieved", QVariant::fromValue(collections)); 0307 } 0308 0309 void DummyResourceState::collectionChangeCommitted(const Akonadi::Collection &collection) 0310 { 0311 recordCall("collectionChangeCommitted", QVariant::fromValue(collection)); 0312 } 0313 0314 void DummyResourceState::tagsRetrieved(const Akonadi::Tag::List &tags, const QHash<QString, Akonadi::Item::List> &items) 0315 { 0316 recordCall("tagsRetrieved", QVariant::fromValue(qMakePair(tags, items))); 0317 } 0318 0319 void DummyResourceState::relationsRetrieved(const Akonadi::Relation::List &relations) 0320 { 0321 recordCall("relationsRetrieved", QVariant::fromValue(relations)); 0322 } 0323 0324 void DummyResourceState::tagChangeCommitted(const Akonadi::Tag &tag) 0325 { 0326 recordCall("tagChangeCommitted", QVariant::fromValue(tag)); 0327 } 0328 0329 void DummyResourceState::changeProcessed() 0330 { 0331 recordCall("changeProcessed"); 0332 } 0333 0334 void DummyResourceState::searchFinished(const QList<qint64> &result, bool isRid) 0335 { 0336 Q_UNUSED(isRid) 0337 recordCall("searchFinished", QVariant::fromValue(result)); 0338 } 0339 0340 void DummyResourceState::cancelTask(const QString &errorString) 0341 { 0342 recordCall("cancelTask", QVariant::fromValue(errorString)); 0343 } 0344 0345 void DummyResourceState::deferTask() 0346 { 0347 recordCall("deferTask"); 0348 } 0349 0350 void DummyResourceState::restartItemRetrieval(Akonadi::Collection::Id col) 0351 { 0352 recordCall("restartItemRetrieval", QVariant::fromValue(col)); 0353 } 0354 0355 void DummyResourceState::taskDone() 0356 { 0357 recordCall("taskDone"); 0358 } 0359 0360 void DummyResourceState::emitError(const QString &message) 0361 { 0362 recordCall("emitError", QVariant::fromValue(message)); 0363 } 0364 0365 void DummyResourceState::emitWarning(const QString &message) 0366 { 0367 recordCall("emitWarning", QVariant::fromValue(message)); 0368 } 0369 0370 void DummyResourceState::emitPercent(int percent) 0371 { 0372 Q_UNUSED(percent) 0373 // FIXME: Many tests need to be updated for this to be uncommented out. 0374 // recordCall( "emitPercent", QVariant::fromValue(percent) ); 0375 } 0376 0377 void DummyResourceState::synchronizeCollectionTree() 0378 { 0379 recordCall("synchronizeCollectionTree"); 0380 } 0381 0382 void DummyResourceState::scheduleConnectionAttempt() 0383 { 0384 recordCall("scheduleConnectionAttempt"); 0385 } 0386 0387 void DummyResourceState::showInformationDialog(const QString &message, const QString &, const QString &) 0388 { 0389 recordCall("showInformationDialog", QVariant::fromValue(message)); 0390 } 0391 0392 QList<QPair<QByteArray, QVariant>> DummyResourceState::calls() const 0393 { 0394 return m_calls; 0395 } 0396 0397 QChar DummyResourceState::separatorCharacter() const 0398 { 0399 return m_separator; 0400 } 0401 0402 void DummyResourceState::setSeparatorCharacter(QChar separator) 0403 { 0404 m_separator = separator; 0405 } 0406 0407 void DummyResourceState::recordCall(const QByteArray &callName, const QVariant ¶meter) 0408 { 0409 m_calls << QPair<QByteArray, QVariant>(callName, parameter); 0410 } 0411 0412 int DummyResourceState::batchSize() const 0413 { 0414 return 10; 0415 } 0416 0417 void DummyResourceState::setItemMergingMode(Akonadi::ItemSync::MergeMode mergeMode) 0418 { 0419 m_mergeMode = mergeMode; 0420 } 0421 0422 MessageHelper::Ptr DummyResourceState::messageHelper() const 0423 { 0424 return MessageHelper::Ptr(new MessageHelper()); 0425 }