1 | /* |
2 | Copyright (c) 2007 Till Adam <adam@kde.org> |
3 | Copyright (c) 2007 Volker Krause <vkrause@kde.org> |
4 | |
5 | This library is free software; you can redistribute it and/or modify it |
6 | under the terms of the GNU Library General Public License as published by |
7 | the Free Software Foundation; either version 2 of the License, or (at your |
8 | option) any later version. |
9 | |
10 | This library is distributed in the hope that it will be useful, but WITHOUT |
11 | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
12 | FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public |
13 | License for more details. |
14 | |
15 | You should have received a copy of the GNU Library General Public License |
16 | along with this library; see the file COPYING.LIB. If not, write to the |
17 | Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA |
18 | 02110-1301, USA. |
19 | */ |
20 | |
21 | #ifndef AKONADI_TYPEPLUGINLOADER_P_H |
22 | #define AKONADI_TYPEPLUGINLOADER_P_H |
23 | |
24 | #include <QtCore/qglobal.h> |
25 | |
26 | class QObject; |
27 | class QString; |
28 | template <typename T> |
29 | class QVector; |
30 | |
31 | namespace Akonadi { |
32 | class ItemSerializerPlugin; |
33 | |
34 | /** |
35 | * @internal |
36 | * |
37 | * With KDE 4.6 we are on the way to change the ItemSerializer plugins into general TypePlugins |
38 | * which provide several type specific actions, namely: |
39 | * @li Serializing/Deserializing of payload |
40 | * @li Comparing two payloads and reporting the differences |
41 | * |
42 | * To share the code of loading the plugins and finding the right plugin for a given mime type |
43 | * the old code from ItemSerializer has been extracted into the pluginForMimeType() method |
44 | * inside the TypePluginLoader namespace. |
45 | */ |
46 | namespace TypePluginLoader { |
47 | |
48 | enum Option { |
49 | NoOptions, |
50 | NoDefault = 1, |
51 | |
52 | _LastOption, |
53 | OptionMask = 2 * _LastOption - 1 |
54 | }; |
55 | Q_DECLARE_FLAGS(Options, Option) |
56 | |
57 | #if 0 |
58 | /** |
59 | * Returns the legacy (pre-KDE-4.6) item serializer plugin that matches the given @p mimetype. |
60 | */ |
61 | ItemSerializerPlugin *legacyPluginForMimeType(const QString &mimetype); |
62 | #endif |
63 | |
64 | /** |
65 | * Returns the default item serializer plugin that matches the given @p mimetype. |
66 | */ |
67 | ItemSerializerPlugin *defaultPluginForMimeType(const QString &mimetype); |
68 | |
69 | /** |
70 | * Returns the item serializer plugin that matches the given |
71 | * @p mimetype, and any of the classes described by @p metaTypeIds. |
72 | */ |
73 | ItemSerializerPlugin *pluginForMimeTypeAndClass(const QString &mimetype, const QVector<int> &metaTypeIds, Options options = NoOptions); |
74 | |
75 | #if 0 |
76 | /** |
77 | * Returns the legacy (pre-KDE-4.6) type plugin object that matches the given @p mimetype. |
78 | */ |
79 | QObject *legacyObjectForMimeType(const QString &mimetype); |
80 | #endif |
81 | |
82 | /** |
83 | * Returns the default type plugin object that matches the given @p mimetype. |
84 | */ |
85 | QObject *defaultObjectForMimeType(const QString &mimetype); |
86 | |
87 | /** |
88 | * Returns the type plugin object that matches the given @p mimetype, |
89 | * and any of the classes described by @p metaTypeIds. |
90 | */ |
91 | QObject *objectForMimeTypeAndClass(const QString &mimetype, const QVector<int> &metaTypeIds, Options options = NoOptions); |
92 | |
93 | /** |
94 | * Override the plugin-lookup with @p plugin. |
95 | * |
96 | * After calling this each lookup will always return @p plugin. |
97 | * This is useful to inject a special plugin for testing purposes. |
98 | * To reset the plugin, set to 0. |
99 | * |
100 | * @since 4.12 |
101 | */ |
102 | void overridePluginLookup(QObject *plugin); |
103 | |
104 | } |
105 | |
106 | } |
107 | |
108 | Q_DECLARE_OPERATORS_FOR_FLAGS(Akonadi::TypePluginLoader::Options) |
109 | |
110 | #endif |
111 | |