1 /* 2 SPDX-FileCopyrightText: 2013 Sérgio Martins <iamsergio@gmail.com> 3 4 SPDX-License-Identifier: LGPL-2.0-or-later 5 */ 6 7 #include "helper.h" 8 9 #include <Akonadi/CollectionFetchJob> 10 #include <Akonadi/CollectionFetchScope> 11 #include <Akonadi/ItemFetchJob> 12 13 #include <QStringList> 14 15 using namespace Akonadi; 16 confirmExists(const Akonadi::Item & item)17bool Helper::confirmExists(const Akonadi::Item &item) 18 { 19 auto job = new ItemFetchJob(item); 20 return job->exec() != 0; 21 } 22 confirmDoesntExist(const Akonadi::Item & item)23bool Helper::confirmDoesntExist(const Akonadi::Item &item) 24 { 25 auto job = new ItemFetchJob(item); 26 return job->exec() == 0; 27 } 28 fetchCollection()29Akonadi::Collection Helper::fetchCollection() 30 { 31 auto job = new CollectionFetchJob(Collection::root(), CollectionFetchJob::Recursive); 32 // Get list of collections 33 job->fetchScope().setContentMimeTypes(QStringList() << QStringLiteral("application/x-vnd.akonadi.calendar.event")); 34 const bool ret = job->exec(); 35 Q_ASSERT(ret); 36 Q_UNUSED(ret) 37 38 // Find our collection 39 const Collection::List collections = job->collections(); 40 Q_ASSERT(!collections.isEmpty()); 41 Collection collection = collections.first(); 42 43 Q_ASSERT(collection.isValid()); 44 45 return collection; 46 } 47