24 #include <QPluginLoader> |
24 #include <QPluginLoader> |
25 #include <QList> |
25 #include <QList> |
26 #include <smfpluginbase.h> |
26 #include <smfpluginbase.h> |
27 #include <smfpluginutil.h> |
27 #include <smfpluginutil.h> |
28 #include <smfprovider.h> |
28 #include <smfprovider.h> |
|
29 #include <smfcredmgrclient.h> |
29 |
30 |
30 #include "smfpluginmanager.h" |
31 #include "smfpluginmanager.h" |
31 #include "smfpluginmanagerutil.h" |
32 #include "smfpluginmanagerutil.h" |
32 #include "smftransportmanagerutil.h" |
33 #include "smftransportmanagerutil.h" |
33 |
34 |
153 { |
154 { |
154 SmfPluginBase* instance = qobject_cast<SmfPluginBase *>(plugin); |
155 SmfPluginBase* instance = qobject_cast<SmfPluginBase *>(plugin); |
155 |
156 |
156 if(instance) |
157 if(instance) |
157 { |
158 { |
158 // Get the registration token of the plugin |
|
159 QString regToken = instance->getProviderInfo()->smfRegistrationId(); |
|
160 QList<QUrl> urlList; |
159 QList<QUrl> urlList; |
161 SmfPluginRequestData reqData; |
160 SmfPluginRequestData reqData; |
162 |
161 |
163 // check if the plugin is authorised (with CSM) |
162 // check if the plugin is authorised (with CSM) |
164 if( authorisePlugin(regToken, urlList )) |
163 if( authorisePlugin(aPluginID, urlList )) |
165 { |
164 { |
166 qDebug()<<"Plugin authorised"; |
165 qDebug()<<"Plugin authorised"; |
167 |
166 |
168 // call the utility method to create plugin specific request |
167 // call the utility method to create plugin specific request |
169 result = SmfUnknownError; |
168 result = SmfUnknownError; |
170 m_util->createRequest(plugin, aOperation, aInputData, reqData, result); |
169 QByteArray notused; |
|
170 m_util->createRequest(plugin, aOperation, aInputData, reqData, result, notused); |
171 |
171 |
172 // If the request is created successfully, call the TM method to send the request |
172 // If the request is created successfully, call the TM method to send the request |
173 if( SmfNoError == result ) |
173 if( SmfNoError == result ) |
174 { |
174 { |
175 qDebug()<<"Plugin request creation successful"; |
175 qDebug()<<"Plugin request creation successful"; |
210 qDebug()<<"Plugin not loaded!!!"; |
210 qDebug()<<"Plugin not loaded!!!"; |
211 } |
211 } |
212 |
212 |
213 return result; |
213 return result; |
214 } |
214 } |
|
215 |
|
216 |
|
217 /** |
|
218 * Method called by Smf server to create a synchronous plugin request. |
|
219 * @param aPluginID The plugin ID that need to perform this operation |
|
220 * @param aOperation The type of operation to be performed |
|
221 * @param aInputData The data required by the plugins |
|
222 * @param aOutputData [out] The output data to be filled by the plugins |
|
223 * @return SmfError The result of the operation. It can be :- |
|
224 * SmfPluginNoError (if the request is success) or |
|
225 * SmfPluginLoadError (if plugin could not be loaded) or |
|
226 * SmfPluginNotAuthorised (if the plugin is not authorised) or |
|
227 * SmfPluginUnknownPluginService (if the requested service is not known or unsupported) |
|
228 */ |
|
229 SmfError SmfPluginManager::createSyncRequest ( const QString& aPluginID, |
|
230 const SmfRequestTypeID& aOperation, |
|
231 QByteArray& aInputData, |
|
232 QByteArray& aOutputData ) |
|
233 { |
|
234 qDebug()<<"Inside SmfPluginManager::createSyncRequest()"; |
|
235 |
|
236 SmfError result = SmfUnknownError; |
|
237 |
|
238 // Load the plugin |
|
239 QObject *plugin = load(aPluginID, result); |
|
240 |
|
241 // Check if plugin is loaded |
|
242 if(plugin && (SmfNoError == result)) |
|
243 { |
|
244 SmfPluginBase* instance = qobject_cast<SmfPluginBase *>(plugin); |
|
245 |
|
246 if(instance) |
|
247 { |
|
248 QList<QUrl> urlList; |
|
249 SmfPluginRequestData reqData; |
|
250 |
|
251 // check if the plugin is authorised (with CSM) |
|
252 if( authorisePlugin(aPluginID, urlList )) |
|
253 { |
|
254 qDebug()<<"Plugin authorised"; |
|
255 |
|
256 // call the utility method to create plugin specific request |
|
257 result = SmfUnknownError; |
|
258 m_util->createRequest(plugin, aOperation, aInputData, reqData, result, aOutputData ); |
|
259 |
|
260 // If the request is created successfully, call the TM method to send the request |
|
261 if( SmfNoError == result ) |
|
262 qDebug()<<"Plugin request creation successful"; |
|
263 else |
|
264 qDebug()<<"Plugin request creation failed!!!, error = "<<result; |
|
265 } |
|
266 |
|
267 else |
|
268 { |
|
269 // plugin not authorised, so unload |
|
270 qDebug()<<"Plugin not authorised!!!"; |
|
271 unload(instance); |
|
272 result = SmfPMPluginNotAuthorised; |
|
273 } |
|
274 } |
|
275 else |
|
276 { |
|
277 // plugin instance cannot be casted, so unload |
|
278 qDebug()<<"Plugin instance cannot be casted to SmfPluginBase*!!!"; |
|
279 unload(instance); |
|
280 result = SmfPMPluginLoadError; |
|
281 } |
|
282 } |
|
283 |
|
284 else |
|
285 { |
|
286 // plugin not loaded |
|
287 qDebug()<<"Plugin not loaded!!!"; |
|
288 } |
|
289 |
|
290 return result; |
|
291 } |
|
292 |
215 |
293 |
216 |
294 |
217 /** |
295 /** |
218 * Method called by Transport Manager when network response is available |
296 * Method called by Transport Manager when network response is available |
219 * @param aTransportResult The result of Transport Operation |
297 * @param aTransportResult The result of Transport Operation |
434 qDebug()<<"instance found"; |
512 qDebug()<<"instance found"; |
435 SmfPluginBase* plugin = qobject_cast<SmfPluginBase *>(instance); |
513 SmfPluginBase* plugin = qobject_cast<SmfPluginBase *>(instance); |
436 if (plugin) |
514 if (plugin) |
437 { |
515 { |
438 qDebug()<<"SmfPluginBase found"; |
516 qDebug()<<"SmfPluginBase found"; |
439 plugin->initialize(SmfPluginUtil::getInstance()); |
517 plugin->initialize(); |
440 |
518 |
441 // get the plugin id |
519 // get the plugin id |
442 QString id = plugin->getProviderInfo()->pluginId(); |
520 QString id = plugin->getProviderInfo()->pluginId(); |
443 |
521 |
444 // get the interface implemented by the plugin |
522 // get the interface implemented by the plugin |
549 |
627 |
550 // If the plugin is loaded |
628 // If the plugin is loaded |
551 if( pluginLoader->isLoaded() && plugin ) |
629 if( pluginLoader->isLoaded() && plugin ) |
552 { |
630 { |
553 // Initialize the plugin |
631 // Initialize the plugin |
554 plugin->initialize(SmfPluginUtil::getInstance()); |
632 plugin->initialize(); |
555 |
633 |
556 // update the plugin loader and the loaded plugin lists |
634 // update the plugin loader and the loaded plugin lists |
557 m_pluginLoaderHash.insertMulti(plugin, pluginLoader); |
635 m_pluginLoaderHash.insertMulti(plugin, pluginLoader); |
558 aLoadResult = SmfNoError; |
636 aLoadResult = SmfNoError; |
559 qDebug()<<"Plugin loaded"; |
637 qDebug()<<"Plugin loaded"; |
744 /** |
822 /** |
745 * Method that checks if a plugin is authorised to make a request. |
823 * Method that checks if a plugin is authorised to make a request. |
746 * This method communicates with Credential and Settings Manager |
824 * This method communicates with Credential and Settings Manager |
747 * through Smf server, giving the registration token and getting |
825 * through Smf server, giving the registration token and getting |
748 * the valid url list if available for this plugin. |
826 * the valid url list if available for this plugin. |
749 * @param aRegToken The registration token given by the plugin |
827 * @param aPluginId The ID of the plugin |
750 * @param aUrlList [out] The list of Urls that the plugin can send |
828 * @param aUrlList [out] The list of Urls that the plugin can send |
751 * request to (to be filled by CSM). This list will be empty if |
829 * request to (to be filled by CSM). This list will be empty if |
752 * aRegToken is empty |
830 * aPluginId is not valid or not authorised. |
753 * @return Returns true if plugin is authorised, else returns false. |
831 * @return Returns true if plugin is authorised, else returns false. |
754 * Also returns false if aRegToken is empty. |
832 * Also returns false if aRegToken is empty. |
755 */ |
833 */ |
756 bool SmfPluginManager::authorisePlugin( const QString &aRegToken, |
834 bool SmfPluginManager::authorisePlugin( const QString &aPluginId, |
757 QList<QUrl> &aUrlList ) |
835 QList<QUrl> &aUrlList ) |
758 { |
836 { |
759 Q_UNUSED(aRegToken) |
|
760 qDebug()<<"Inside SmfPluginManager::authorisePlugin()"; |
837 qDebug()<<"Inside SmfPluginManager::authorisePlugin()"; |
761 |
838 |
762 #ifdef CSM_INTEGRATED |
839 bool authorised = false; |
763 aUrlList.clear(); |
840 SmfCredMgrClient csmClient; |
764 |
841 |
765 // Get the valid URL list from CSM, giving the reg token |
842 aUrlList = csmClient.URLList(aPluginId); |
766 if(aRegToken.size()) |
843 if(aUrlList.count()) |
767 return m_server->authorisePlugin(aRegToken, aUrlList); |
844 authorised = true; |
768 else |
845 |
769 return false; |
846 return authorised; |
770 #else |
|
771 |
|
772 // CSM STUBBING - start |
|
773 QUrl url1 ("http://www.example.com"); |
|
774 QUrl url2 ("http://api.facebook.com"); |
|
775 QUrl url3 ("http://api.flickr.com"); |
|
776 |
|
777 aUrlList.append(url1); |
|
778 aUrlList.append(url2); |
|
779 aUrlList.append(url3); |
|
780 |
|
781 return true; |
|
782 // CSM STUBBING - end |
|
783 #endif |
|
784 |
|
785 } |
847 } |
786 |
848 |
787 |
849 |
788 /** |
850 /** |
789 * Method to serialize the result of parsing (which is done by the |
851 * Method to serialize the result of parsing (which is done by the |
880 SmfError result; |
942 SmfError result; |
881 SmfPluginBase* instance = qobject_cast<SmfPluginBase *>(load(pluginId, result)); |
943 SmfPluginBase* instance = qobject_cast<SmfPluginBase *>(load(pluginId, result)); |
882 |
944 |
883 if(instance && (SmfNoError == result)) |
945 if(instance && (SmfNoError == result)) |
884 { |
946 { |
885 instance->initialize(SmfPluginUtil::getInstance()); |
947 instance->initialize(); |
886 serviceProv = instance->getProviderInfo()->serviceName(); |
948 serviceProv = instance->getProviderInfo()->serviceName(); |
887 interfaceName = dir.dirName(); |
949 interfaceName = dir.dirName(); |
888 } |
950 } |
889 |
951 |
890 unload(instance); |
952 unload(instance); |
924 SmfError result; |
986 SmfError result; |
925 SmfPluginBase* instance = qobject_cast<SmfPluginBase *>(load(pluginId, result)); |
987 SmfPluginBase* instance = qobject_cast<SmfPluginBase *>(load(pluginId, result)); |
926 |
988 |
927 if(instance && (SmfNoError == result)) |
989 if(instance && (SmfNoError == result)) |
928 { |
990 { |
929 instance->initialize(SmfPluginUtil::getInstance()); |
991 instance->initialize(); |
930 serviceProv = instance->getProviderInfo()->serviceName(); |
992 serviceProv = instance->getProviderInfo()->serviceName(); |
931 interfaceName = dir.dirName(); |
993 interfaceName = dir.dirName(); |
932 interfaceName.prepend("org.symbian.smf.plugin."); |
994 interfaceName.prepend("org.symbian.smf.plugin."); |
933 QString prgm; |
995 QString prgm; |
934 QStringList list; |
996 QStringList list; |
991 SmfError result; |
1053 SmfError result; |
992 SmfPluginBase* instance = qobject_cast<SmfPluginBase *>(load(pluginId, result)); |
1054 SmfPluginBase* instance = qobject_cast<SmfPluginBase *>(load(pluginId, result)); |
993 |
1055 |
994 if(instance && (SmfNoError == result)) |
1056 if(instance && (SmfNoError == result)) |
995 { |
1057 { |
996 instance->initialize(SmfPluginUtil::getInstance()); |
1058 instance->initialize(); |
997 serviceProv = instance->getProviderInfo()->serviceName(); |
1059 serviceProv = instance->getProviderInfo()->serviceName(); |
998 interfaceName = dir.dirName(); |
1060 interfaceName = dir.dirName(); |
999 } |
1061 } |
1000 |
1062 |
1001 unload(instance); |
1063 unload(instance); |