File indexing completed on 2024-11-10 04:40:40

0001 /*
0002     SPDX-FileCopyrightText: 2013 Christian Mollekopf <mollekopf@kolabsys.com>
0003 
0004     SPDX-License-Identifier: LGPL-2.0-or-later
0005 */
0006 #include "gidextractor_p.h"
0007 #include "gidextractorinterface.h"
0008 
0009 #include "item.h"
0010 #include "typepluginloader_p.h"
0011 
0012 using namespace Akonadi;
0013 
0014 QString GidExtractor::extractGid(const Item &item)
0015 {
0016     const QObject *object = TypePluginLoader::objectForMimeTypeAndClass(item.mimeType(), item.availablePayloadMetaTypeIds());
0017     if (object) {
0018         const GidExtractorInterface *extractor = qobject_cast<const GidExtractorInterface *>(object);
0019         if (extractor) {
0020             return extractor->extractGid(item);
0021         }
0022     }
0023     return QString();
0024 }
0025 
0026 QString GidExtractor::getGid(const Item &item)
0027 {
0028     const QString gid = item.gid();
0029     if (!gid.isNull()) {
0030         return gid;
0031     }
0032     if (item.loadedPayloadParts().isEmpty()) {
0033         return QString();
0034     }
0035     return extractGid(item);
0036 }