|
1 /* |
|
2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * |
|
5 * This program is free software: you can redistribute it and/or modify |
|
6 * it under the terms of the GNU Lesser General Public License as published by |
|
7 * the Free Software Foundation, version 2.1 of the License. |
|
8 * |
|
9 * This program is distributed in the hope that it will be useful, |
|
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
12 * GNU Lesser General Public License for more details. |
|
13 * |
|
14 * You should have received a copy of the GNU Lesser General Public License |
|
15 * along with this program. If not, |
|
16 * see "http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html/". |
|
17 * |
|
18 * Description: Class implement extended wrapper for ECom framework |
|
19 * |
|
20 */ |
|
21 |
|
22 #ifndef XQPLUGINLOADER_H |
|
23 #define XQPLUGINLOADER_H |
|
24 |
|
25 //Incudes |
|
26 #include <QtGlobal> |
|
27 #include <QObject> |
|
28 #include <QList> |
|
29 #include <QString> |
|
30 //Forward class declarations |
|
31 class XQPluginInfo; |
|
32 class XQPluginLoaderPrivate; |
|
33 |
|
34 #ifdef BUILD_XQPLUGINS_DLL |
|
35 #define DLL_EXPORT Q_DECL_EXPORT |
|
36 #else |
|
37 #define DLL_EXPORT Q_DECL_IMPORT |
|
38 #endif |
|
39 |
|
40 |
|
41 //Class declaration |
|
42 class DLL_EXPORT XQPluginLoader : public QObject |
|
43 { |
|
44 public: |
|
45 /** |
|
46 * Constructor |
|
47 * @param parent - address of class instance parent |
|
48 */ |
|
49 XQPluginLoader(QObject* parent = 0); |
|
50 |
|
51 /** |
|
52 * Constructor |
|
53 * @param uid - UID of plugin that should be loaded |
|
54 * @param parent - address of class instance parent |
|
55 */ |
|
56 XQPluginLoader(int uid, QObject* parent = 0); |
|
57 |
|
58 /** |
|
59 * Destructor |
|
60 */ |
|
61 virtual ~XQPluginLoader(); |
|
62 |
|
63 /** |
|
64 * List available plugins which implement requested interface. |
|
65 * Function resolve plugins using interface name |
|
66 * @param interfaceName - requested interface name |
|
67 * @param impls - destination list where resolved plugins info will be stored |
|
68 * @return true on success, false on any error |
|
69 */ |
|
70 static bool listImplementations(const QString &interfaceName, |
|
71 QList<XQPluginInfo > &impls); |
|
72 |
|
73 |
|
74 /** |
|
75 * Function return UID of requested plugin |
|
76 */ |
|
77 int uid()const; |
|
78 |
|
79 |
|
80 /** |
|
81 * Function return pointer to plugin root-component instance |
|
82 * @return instance address on success, 0 otherwise |
|
83 */ |
|
84 QObject* instance(); |
|
85 |
|
86 /** |
|
87 * Function return information if plugin have been loaded |
|
88 * @return true if plugin have been loaded, false otherwise |
|
89 */ |
|
90 bool isLoaded() const; |
|
91 |
|
92 /** |
|
93 * Function load requested plugin |
|
94 * @return true on success, false otherwise |
|
95 */ |
|
96 bool load(); |
|
97 |
|
98 |
|
99 /** |
|
100 * Function unload plugin |
|
101 * @return true on success, false otherwise |
|
102 */ |
|
103 bool unload(); |
|
104 |
|
105 /** |
|
106 * |
|
107 */ |
|
108 void setUid ( int uid ); |
|
109 |
|
110 /** |
|
111 * |
|
112 */ |
|
113 QString errorString () const; |
|
114 |
|
115 private: |
|
116 /** |
|
117 * Private extended plugin loader implementation. |
|
118 * Own |
|
119 */ |
|
120 XQPluginLoaderPrivate* d; |
|
121 |
|
122 /** |
|
123 * Flag that inform about loading state |
|
124 */ |
|
125 bool did_load; |
|
126 |
|
127 Q_DISABLE_COPY(XQPluginLoader) |
|
128 }; |
|
129 |
|
130 #endif |