File indexing completed on 2024-06-16 04:50:18
0001 /* 0002 SPDX-FileCopyrightText: 2007 Till Adam <adam@kde.org> 0003 SPDX-FileCopyrightText: 2007 Volker Krause <vkrause@kde.org> 0004 0005 SPDX-License-Identifier: LGPL-2.0-or-later 0006 */ 0007 0008 #pragma once 0009 0010 #include "akonadicore_export.h" 0011 #include <qglobal.h> 0012 0013 class QObject; 0014 class QString; 0015 template<typename T> 0016 class QList; 0017 0018 namespace Akonadi 0019 { 0020 class ItemSerializerPlugin; 0021 0022 /** 0023 * @internal 0024 * 0025 * With KDE 4.6 we are on the way to change the ItemSerializer plugins into general TypePlugins 0026 * which provide several type specific actions, namely: 0027 * @li Serializing/Deserializing of payload 0028 * @li Comparing two payloads and reporting the differences 0029 * 0030 * To share the code of loading the plugins and finding the right plugin for a given mime type 0031 * the old code from ItemSerializer has been extracted into the pluginForMimeType() method 0032 * inside the TypePluginLoader namespace. 0033 */ 0034 namespace TypePluginLoader 0035 { 0036 enum Option { 0037 NoOptions, 0038 NoDefault = 1, 0039 0040 _LastOption, 0041 OptionMask = 2 * _LastOption - 1 0042 }; 0043 Q_DECLARE_FLAGS(Options, Option) 0044 0045 /** 0046 * Returns the default item serializer plugin that matches the given @p mimetype. 0047 */ 0048 AKONADICORE_EXPORT ItemSerializerPlugin *defaultPluginForMimeType(const QString &mimetype); 0049 0050 /** 0051 * Returns the item serializer plugin that matches the given 0052 * @p mimetype, and any of the classes described by @p metaTypeIds. 0053 */ 0054 AKONADICORE_EXPORT ItemSerializerPlugin *pluginForMimeTypeAndClass(const QString &mimetype, const QList<int> &metaTypeIds, Options options = NoOptions); 0055 0056 /** 0057 * Returns the default type plugin object that matches the given @p mimetype. 0058 */ 0059 AKONADICORE_EXPORT QObject *defaultObjectForMimeType(const QString &mimetype); 0060 0061 /** 0062 * Returns the type plugin object that matches the given @p mimetype, 0063 * and any of the classes described by @p metaTypeIds. 0064 */ 0065 AKONADICORE_EXPORT QObject *objectForMimeTypeAndClass(const QString &mimetype, const QList<int> &metaTypeIds, Options options = NoOptions); 0066 0067 /** 0068 * Override the plugin-lookup with @p plugin. 0069 * 0070 * After calling this each lookup will always return @p plugin. 0071 * This is useful to inject a special plugin for testing purposes. 0072 * To reset the plugin, set to 0. 0073 * 0074 * @since 4.12 0075 */ 0076 AKONADICORE_EXPORT void overridePluginLookup(QObject *plugin); 0077 0078 } 0079 0080 } 0081 0082 Q_DECLARE_OPERATORS_FOR_FLAGS(Akonadi::TypePluginLoader::Options)