File indexing completed on 2024-11-24 04:44:17
0001 /* 0002 SPDX-FileCopyrightText: 2014 Christian Mollekopf <mollekopf@kolabsys.com> 0003 0004 SPDX-License-Identifier: LGPL-2.0-or-later 0005 */ 0006 0007 #include "kolabmessagehelper.h" 0008 0009 #include <Akonadi/CollectionAnnotationsAttribute> 0010 0011 #include "kolabhelpers.h" 0012 #include "kolabresource_debug.h" 0013 0014 KolabMessageHelper::KolabMessageHelper(const Akonadi::Collection &col) 0015 : mCollection(col) 0016 { 0017 } 0018 0019 KolabMessageHelper::~KolabMessageHelper() = default; 0020 0021 Akonadi::Item KolabMessageHelper::createItemFromMessage(const KMime::Message::Ptr &message, 0022 const qint64 uid, 0023 const qint64 size, 0024 const QMap<QByteArray, QVariant> &attrs, 0025 const QList<QByteArray> &flags, 0026 const KIMAP::FetchJob::FetchScope &scope, 0027 bool &ok) const 0028 { 0029 const Akonadi::Item item = MessageHelper::createItemFromMessage(message, uid, size, attrs, flags, scope, ok); 0030 if (!ok) { 0031 qCWarning(KOLABRESOURCE_LOG) << "Failed to read imap message"; 0032 return item; 0033 } 0034 Kolab::FolderType folderType = Kolab::MailType; 0035 if (mCollection.hasAttribute<Akonadi::CollectionAnnotationsAttribute>()) { 0036 const QByteArray folderTypeString = 0037 KolabHelpers::getFolderTypeAnnotation(mCollection.attribute<Akonadi::CollectionAnnotationsAttribute>()->annotations()); 0038 folderType = KolabHelpers::folderTypeFromString(folderTypeString); 0039 } 0040 return KolabHelpers::translateFromImap(folderType, item, ok); 0041 }