|
1 /* |
|
2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: FTU wizard provider. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include "ftuwizardprovider.h" |
|
20 #include "ftumanifestparser.h" |
|
21 |
|
22 #include <ftuwizardfactory.h> |
|
23 |
|
24 #include <QDebug> |
|
25 #include <QPluginLoader> |
|
26 #ifdef Q_OS_SYMBIAN |
|
27 #include <QLibraryInfo> |
|
28 #else |
|
29 #include <QCoreApplication> |
|
30 #endif |
|
31 #include <QDir> |
|
32 |
|
33 //#define _USE_SERVICEFW |
|
34 |
|
35 #ifdef _USE_SERVICEFW |
|
36 #include "ftuwizardproviderinternalcrkeys.h" |
|
37 |
|
38 #include <qservicemanager.h> |
|
39 #include <qserviceinterfacedescriptor.h> |
|
40 #include <XQSettingsManager> // for reading cenrep keys |
|
41 |
|
42 #endif |
|
43 |
|
44 |
|
45 #ifndef FTUWIZARDPROVIDER_TEST |
|
46 const char wizardManifestDir [] = "/fturesources/plugins/wizardproviders"; |
|
47 #else |
|
48 const char wizardManifestDir [] = "/fturesources/testresources/plugins/wizardproviders"; |
|
49 #endif |
|
50 |
|
51 // --------------------------------------------------------------------------- |
|
52 // FtuWizardProvider::FtuWizardProvider |
|
53 // --------------------------------------------------------------------------- |
|
54 // |
|
55 FtuWizardProvider::FtuWizardProvider(QObject* parent): |
|
56 QObject(parent), mWizardManifestDir(wizardManifestDir) |
|
57 { |
|
58 |
|
59 } |
|
60 |
|
61 // --------------------------------------------------------------------------- |
|
62 // FtuWizardProvider::~FtuWizardProvider |
|
63 // --------------------------------------------------------------------------- |
|
64 // |
|
65 FtuWizardProvider::~FtuWizardProvider() |
|
66 { |
|
67 } |
|
68 |
|
69 // --------------------------------------------------------------------------- |
|
70 // FtuWizardProvider::loadFTUPlugins |
|
71 // --------------------------------------------------------------------------- |
|
72 // |
|
73 void FtuWizardProvider::loadFTUPlugins(QList<FtuWizardFactory*>& plugins) |
|
74 { |
|
75 #ifdef Q_OS_SYMBIAN |
|
76 QDir pluginsDir = QLibraryInfo::location(QLibraryInfo::PluginsPath) |
|
77 + "/FTU"; |
|
78 #else |
|
79 QDir pluginsDir = QCoreApplication::applicationDirPath() |
|
80 + "/resource/qt/plugins/FTU"; |
|
81 #endif |
|
82 |
|
83 QStringList pluginList; |
|
84 |
|
85 FtuManifestParser parser; |
|
86 #ifdef Q_OS_SYMBIAN |
|
87 pluginList = parser.parsePluginList(mWizardManifestDir); |
|
88 #else |
|
89 QString manifestDir = QCoreApplication::applicationDirPath() |
|
90 + mWizardManifestDir; |
|
91 // Remove c:/ |
|
92 manifestDir.remove(0,3); |
|
93 pluginList = parser.parsePluginList(manifestDir); |
|
94 #endif |
|
95 |
|
96 #ifdef _USE_SERVICEFW |
|
97 |
|
98 XQSettingsManager settingsManager; |
|
99 |
|
100 XQSettingsKey numberOfPluginsKey(XQSettingsKey::TargetCentralRepository, |
|
101 KCrUidFtuWizardProvider, |
|
102 KFtuNumberOfWizardPlugins); |
|
103 |
|
104 bool ok; |
|
105 int numberOfPlugins = settingsManager.readItemValue( |
|
106 numberOfPluginsKey).toInt(&ok); |
|
107 |
|
108 QServiceManager* serviceManager = new QServiceManager(); |
|
109 |
|
110 if(ok) |
|
111 { |
|
112 qDebug() << "Ftu:reading config for " << numberOfPlugins |
|
113 << " plugins"; |
|
114 |
|
115 |
|
116 for(int i=1; i <= numberOfPlugins ; ++i) |
|
117 { |
|
118 XQSettingsKey fileKey(XQSettingsKey::TargetCentralRepository, |
|
119 KCrUidFtuWizardProvider, |
|
120 KFtuNumberOfWizardPlugins + i); |
|
121 |
|
122 QString interface = settingsManager.readItemValue(fileKey, |
|
123 XQSettingsManager::TypeString).toString(); |
|
124 qDebug() << "Ftu:Reading interface name from conf :" << interface; |
|
125 QObject* obj = serviceManager->loadInterface(interface); |
|
126 if(obj) |
|
127 { |
|
128 FtuWizardFactory* factory = qobject_cast<FtuWizardFactory*> |
|
129 (obj); |
|
130 if(factory) |
|
131 { |
|
132 plugins.append(factory); |
|
133 } |
|
134 } |
|
135 |
|
136 } |
|
137 } |
|
138 delete serviceManager; |
|
139 |
|
140 #else |
|
141 foreach (QString filename, pluginList) |
|
142 { |
|
143 qDebug () << "Ftu: Loading instance from : "<< filename; |
|
144 QPluginLoader loader(pluginsDir.absoluteFilePath(filename)); |
|
145 QObject* instance = loader.instance(); |
|
146 if(instance) |
|
147 { |
|
148 qDebug() << "ftu: instance loaded"; |
|
149 FtuWizardFactory* factory = qobject_cast<FtuWizardFactory*> |
|
150 (instance); |
|
151 if(factory) |
|
152 { |
|
153 qDebug() << "ftu: appending factory to list"; |
|
154 plugins.append(factory); |
|
155 } |
|
156 } |
|
157 } |
|
158 #endif |
|
159 } |