|
1 /** |
|
2 * Copyright (c) 2010 Sasken Communication Technologies Ltd. |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of the "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 * Chandradeep Gandhi, Sasken Communication Technologies Ltd - Initial contribution |
|
11 * |
|
12 * Contributors: |
|
13 * Manasij Roy, Nalina Hariharan |
|
14 * |
|
15 * Description: |
|
16 * The Plugin Manager util class performs all plugin functional |
|
17 * specific functionalities |
|
18 * |
|
19 */ |
|
20 |
|
21 // plugin interfaces |
|
22 #include <smfcontactfetcherplugin.h> |
|
23 #include <smfpostproviderplugin.h> |
|
24 #include <smflyricsserviceplugin.h> |
|
25 #include <smfmusiceventsplugin.h> |
|
26 #include <smfmusicsearchplugin.h> |
|
27 #include <smfmusicserviceplugin.h> |
|
28 #include <smfplaylistserviceplugin.h> |
|
29 #include <smfgalleryplugin.h> |
|
30 #include <smfprovider.h> |
|
31 |
|
32 #include "smfpluginmanagerutil.h" |
|
33 #include "smfpluginmanager.h" |
|
34 |
|
35 // Static data initialisation |
|
36 SmfPluginManagerUtil* SmfPluginManagerUtil::m_myInstance = NULL; |
|
37 |
|
38 |
|
39 /** |
|
40 * Method to get the instance of SmfPluginManagerUtil class |
|
41 * @param aParent The parent object |
|
42 * @return The instance of SmfPluginManagerUtil class |
|
43 */ |
|
44 SmfPluginManagerUtil* SmfPluginManagerUtil::getInstance ( QObject *aParent ) |
|
45 { |
|
46 if(NULL == m_myInstance) |
|
47 m_myInstance = new SmfPluginManagerUtil( aParent ); |
|
48 return m_myInstance; |
|
49 } |
|
50 |
|
51 |
|
52 /** |
|
53 * Constructor with default argument |
|
54 * @param aParent The parent object |
|
55 */ |
|
56 SmfPluginManagerUtil::SmfPluginManagerUtil ( QObject */*aParent*/ ) |
|
57 { |
|
58 } |
|
59 |
|
60 |
|
61 /** |
|
62 * Destructor |
|
63 */ |
|
64 SmfPluginManagerUtil::~SmfPluginManagerUtil ( ) |
|
65 { |
|
66 if(m_myInstance) |
|
67 delete m_myInstance; |
|
68 } |
|
69 |
|
70 |
|
71 /** |
|
72 * Method called by Plugin Manager to create a web query. |
|
73 * This method calls the respective plugin methods for creation of |
|
74 * web queries using the aOperation and aInputData parameters. |
|
75 * @param aInstance Instance of the loaded plugin that perform this operation |
|
76 * @param aOperation The type of operation to be performed |
|
77 * @param aInputData The data required to create the web query |
|
78 * @param aReqData [out] The request data created by the plugin |
|
79 * @param aResult [out] SmfPluginManagerResult, The result of the operation |
|
80 * @see smfglobal.h |
|
81 */ |
|
82 void SmfPluginManagerUtil::createRequest ( QObject* aInstance, |
|
83 const SmfRequestTypeID &aOperation, |
|
84 QByteArray &aInputData, |
|
85 SmfPluginRequestData &aReqData, |
|
86 SmfPluginManagerResult &aResult ) |
|
87 { |
|
88 SmfPluginManager::getInstance()->server()->writeLog("SmfPluginManagerUtil::createRequest"); |
|
89 SmfPluginError pluginErrorVal; |
|
90 |
|
91 // Find the type of service required |
|
92 switch(aOperation) |
|
93 { |
|
94 case SmfContactGetFriends: |
|
95 case SmfContactGetFollowers: |
|
96 case SmfContactSearch: |
|
97 case SmfContactSearchNear: |
|
98 case SmfContactGetGroups: |
|
99 case SmfContactSearchInGroup: |
|
100 // Authorise the plugin and call create request methods |
|
101 pluginErrorVal = createContactFetcherRequest(aInstance, aOperation, |
|
102 aInputData, aReqData, aResult); |
|
103 break; |
|
104 |
|
105 case SmfContactRetrievePosts: |
|
106 case SmfContactPost: |
|
107 case SmfContactUpdatePost: |
|
108 case SmfContactPostDirected: |
|
109 case SmfContactCommentOnAPost: |
|
110 case SmfContactPostAppearence: |
|
111 case SmfContactSharePost: |
|
112 // Authorise the plugin and call create request methods |
|
113 pluginErrorVal = createContactPostRequest(aInstance, aOperation, |
|
114 aInputData, aReqData, aResult); |
|
115 break; |
|
116 |
|
117 case SmfMusicGetLyrics: |
|
118 case SmfMusicGetSubtitle: |
|
119 // Authorise the plugin and call create request methods |
|
120 pluginErrorVal = createMusicLyricsRequest(aInstance, aOperation, |
|
121 aInputData, aReqData, aResult); |
|
122 break; |
|
123 |
|
124 case SmfMusicGetEventsOnLoc: |
|
125 case SmfMusicGetVenueOnLoc: |
|
126 case SmfMusicGetEventsOnVenue: |
|
127 case SmfMusicPostEvents: |
|
128 // Authorise the plugin and call create request methods |
|
129 pluginErrorVal = createMusicEventsRequest(aInstance, aOperation, |
|
130 aInputData, aReqData, aResult); |
|
131 break; |
|
132 |
|
133 case SmfMusicGetRecommendations: |
|
134 case SmfMusicGetTracks: |
|
135 case SmfMusicGetTrackInfo: |
|
136 case SmfMusicGetStores: |
|
137 case SmfMusicPostCurrentPlaying: |
|
138 // Authorise the plugin and call create request methods |
|
139 pluginErrorVal = createMusicSearchRequest(aInstance, aOperation, |
|
140 aInputData, aReqData, aResult); |
|
141 break; |
|
142 |
|
143 case SmfMusicGetUserInfo: |
|
144 case SmfMusicSearchUser: |
|
145 // Authorise the plugin and call create request methods |
|
146 pluginErrorVal = createMusicServiceRequest(aInstance, aOperation, |
|
147 aInputData, aReqData, aResult); |
|
148 break; |
|
149 |
|
150 case SmfMusicGetPlaylists: |
|
151 case SmfMusicGetPlaylistsOfUser: |
|
152 case SmfMusicAddToPlaylist: |
|
153 case SmfMusicPostCurrentPlayingPlaylist: |
|
154 // Authorise the plugin and call create request methods |
|
155 pluginErrorVal = createMusicPlaylistRequest(aInstance, aOperation, |
|
156 aInputData, aReqData, aResult); |
|
157 break; |
|
158 |
|
159 case SmfPictureGetPictures: |
|
160 case SmfPictureDescription: |
|
161 case SmfPictureUpload: |
|
162 case SmfPictureMultiUpload: |
|
163 case SmfPicturePostComment: |
|
164 // Authorise the plugin and call create request methods |
|
165 pluginErrorVal = createGalleryRequest(aInstance, aOperation, |
|
166 aInputData, aReqData, aResult); |
|
167 break; |
|
168 |
|
169 default: |
|
170 SmfPluginManager::getInstance()->server()->writeLog("Unknown service type!!!"); |
|
171 aResult = SmfPluginUnknownService; |
|
172 } |
|
173 if(SmfPluginErrNone == pluginErrorVal) |
|
174 aResult = SmfPluginRequestCreated; |
|
175 else |
|
176 aResult = SmfPluginRequestCreationFailed; |
|
177 } |
|
178 |
|
179 |
|
180 /** |
|
181 * Method to create a web query to fetch contact details. |
|
182 * @param aPlugin The instance of the loaded plugin that performs the |
|
183 * contact fetch operation. |
|
184 * @param aOperation The type of operation to be performed |
|
185 * @param aInputData The data required to create the web query |
|
186 * @param aReqData [out] The request data created by the plugin |
|
187 * @param aResult [out] SmfPluginManagerResult, The result of the operation |
|
188 * @return SmfPluginError |
|
189 * @see smfglobal.h |
|
190 */ |
|
191 SmfPluginError SmfPluginManagerUtil::createContactFetcherRequest ( QObject *aPlugin, |
|
192 const SmfRequestTypeID &aOperation, |
|
193 QByteArray &aInputData, |
|
194 SmfPluginRequestData &aReqData, |
|
195 SmfPluginManagerResult &aResult ) |
|
196 { |
|
197 SmfPluginManager::getInstance()->server()->writeLog("SmfPluginManagerUtil::createContactFetcherRequest"); |
|
198 |
|
199 // typecast instance to the contact - fetcher type, here SmfContactFetcherPlugin |
|
200 SmfContactFetcherPlugin *plugin = qobject_cast<SmfContactFetcherPlugin *>(aPlugin); |
|
201 SmfPluginError pluginErrorVal; |
|
202 |
|
203 if(plugin) |
|
204 { |
|
205 QDataStream stream(aInputData); |
|
206 int pageNum, itemPerPage; |
|
207 |
|
208 switch(aOperation) |
|
209 { |
|
210 case SmfContactGetFriends: |
|
211 stream>>pageNum; |
|
212 stream>>itemPerPage; |
|
213 pluginErrorVal = plugin->friends(aReqData, pageNum, itemPerPage); |
|
214 break; |
|
215 |
|
216 case SmfContactGetFollowers: |
|
217 stream>>pageNum; |
|
218 stream>>itemPerPage; |
|
219 pluginErrorVal = plugin->followers(aReqData, pageNum, itemPerPage); |
|
220 break; |
|
221 |
|
222 case SmfContactSearch: |
|
223 { |
|
224 SmfContact searchContact; |
|
225 stream>>searchContact; |
|
226 stream>>pageNum; |
|
227 stream>>itemPerPage; |
|
228 pluginErrorVal = plugin->search(aReqData, searchContact, pageNum, itemPerPage); |
|
229 break; |
|
230 } |
|
231 |
|
232 case SmfContactSearchNear: |
|
233 { |
|
234 SmfLocation location; |
|
235 int i; |
|
236 stream>>i; |
|
237 SmfLocationSearchBoundary proximity = (SmfLocationSearchBoundary)i; |
|
238 stream>>pageNum; |
|
239 stream>>itemPerPage; |
|
240 pluginErrorVal = plugin->searchNear(aReqData, location, proximity, pageNum, itemPerPage); |
|
241 break; |
|
242 } |
|
243 |
|
244 case SmfContactGetGroups: |
|
245 stream>>pageNum; |
|
246 stream>>itemPerPage; |
|
247 pluginErrorVal = plugin->groups(aReqData, pageNum, itemPerPage); |
|
248 break; |
|
249 |
|
250 case SmfContactSearchInGroup: |
|
251 { |
|
252 SmfGroup group; |
|
253 stream>>group; |
|
254 stream>>pageNum; |
|
255 stream>>itemPerPage; |
|
256 pluginErrorVal = plugin->searchInGroup(aReqData, group, pageNum, itemPerPage); |
|
257 break; |
|
258 } |
|
259 |
|
260 default: |
|
261 // do nothing, unknown service |
|
262 aResult = SmfPluginUnknownService; |
|
263 SmfPluginManager::getInstance()->server()->writeLog("No API found for this operation type!!!"); |
|
264 return SmfPluginErrInvalidRequest; |
|
265 } |
|
266 |
|
267 if(SmfPluginErrNone == pluginErrorVal) |
|
268 aResult = SmfPluginRequestCreated; |
|
269 else |
|
270 aResult = SmfPluginServiceError; |
|
271 } |
|
272 else |
|
273 aResult = SmfPluginLoadError; |
|
274 |
|
275 return pluginErrorVal; |
|
276 } |
|
277 |
|
278 |
|
279 /** |
|
280 * Method to create a web query to do post operation on contacts |
|
281 * (like scraps or messages) |
|
282 * @param aPlugin The instance of the loaded plugin that performs the |
|
283 * contact fetch operation. |
|
284 * @param aOperation The type of operation to be performed |
|
285 * @param aInputData The data required to create the web query |
|
286 * @param aReqData [out] The request data created by the plugin |
|
287 * @param aResult [out] SmfPluginManagerResult, The result of the operation |
|
288 * @return SmfPluginError |
|
289 * @see smfglobal.h |
|
290 */ |
|
291 SmfPluginError SmfPluginManagerUtil::createContactPostRequest ( QObject *aPlugin, |
|
292 const SmfRequestTypeID &aOperation, |
|
293 QByteArray &aInputData, |
|
294 SmfPluginRequestData &aReqData, |
|
295 SmfPluginManagerResult &aResult ) |
|
296 { |
|
297 SmfPluginManager::getInstance()->server()->writeLog("SmfPluginManagerUtil::createContactPostRequest"); |
|
298 |
|
299 // typecast instance to SmfPostProviderPlugin |
|
300 SmfPostProviderPlugin *plugin = qobject_cast<SmfPostProviderPlugin *>(aPlugin); |
|
301 SmfPluginError pluginErrorVal; |
|
302 |
|
303 if(plugin) |
|
304 { |
|
305 QDataStream stream(aInputData); |
|
306 SmfContact contact; |
|
307 SmfPost post; |
|
308 SmfLocation location; |
|
309 int pageNum, itemPerPage; |
|
310 |
|
311 switch(aOperation) |
|
312 { |
|
313 case SmfContactRetrievePosts: |
|
314 stream>>contact; |
|
315 stream>>pageNum; |
|
316 stream>>itemPerPage; |
|
317 pluginErrorVal = plugin->retrieve(aReqData, &contact, pageNum, itemPerPage); |
|
318 break; |
|
319 |
|
320 case SmfContactPost: |
|
321 stream>>post; |
|
322 stream>>location; |
|
323 pluginErrorVal = plugin->post(aReqData, post, location); |
|
324 break; |
|
325 |
|
326 case SmfContactUpdatePost: |
|
327 stream>>post; |
|
328 pluginErrorVal = plugin->updatePost(aReqData, post); |
|
329 break; |
|
330 |
|
331 case SmfContactPostDirected: |
|
332 stream>>post; |
|
333 stream>>contact; |
|
334 stream>>location; |
|
335 pluginErrorVal = plugin->postDirected(aReqData, post, contact, &location); |
|
336 break; |
|
337 |
|
338 case SmfContactCommentOnAPost: |
|
339 { |
|
340 SmfPost post2; |
|
341 stream>>post; |
|
342 stream>>post2; |
|
343 stream>>location; |
|
344 pluginErrorVal = plugin->commentOnAPost(aReqData, post, post2, &location); |
|
345 break; |
|
346 } |
|
347 |
|
348 case SmfContactPostAppearence: |
|
349 { |
|
350 QString status; |
|
351 int i; |
|
352 stream>>i; |
|
353 SmfPresenceInfo presence = (SmfPresenceInfo)i; |
|
354 stream>>status; |
|
355 pluginErrorVal = plugin->postAppearence(aReqData, presence, status); |
|
356 break; |
|
357 } |
|
358 |
|
359 case SmfContactSharePost: |
|
360 { |
|
361 bool edited; |
|
362 stream>>post; |
|
363 stream>>contact; |
|
364 stream>>edited; |
|
365 pluginErrorVal = plugin->sharePost(aReqData, post, contact, edited); |
|
366 break; |
|
367 } |
|
368 |
|
369 default: |
|
370 // do nothing, unknown service |
|
371 aResult = SmfPluginUnknownService; |
|
372 SmfPluginManager::getInstance()->server()->writeLog("No API found for this operation type!!!"); |
|
373 return SmfPluginErrInvalidRequest; |
|
374 } |
|
375 |
|
376 if(SmfPluginErrNone == pluginErrorVal) |
|
377 aResult = SmfPluginRequestCreated; |
|
378 else |
|
379 aResult = SmfPluginServiceError; |
|
380 } |
|
381 else |
|
382 aResult = SmfPluginLoadError; |
|
383 |
|
384 return pluginErrorVal; |
|
385 } |
|
386 |
|
387 |
|
388 |
|
389 /** |
|
390 * Method to create a web query to do music lyrics or subtitle search |
|
391 * @param aPlugin The instance of the loaded plugin that performs the |
|
392 * contact fetch operation. |
|
393 * @param aOperation The type of operation to be performed |
|
394 * @param aInputData The data required to create the web query |
|
395 * @param aReqData [out] The request data created by the plugin |
|
396 * @param aResult [out] SmfPluginManagerResult, The result of the operation |
|
397 * @return SmfPluginError |
|
398 * @see smfglobal.h |
|
399 */ |
|
400 SmfPluginError SmfPluginManagerUtil::createMusicLyricsRequest ( QObject *aPlugin, |
|
401 const SmfRequestTypeID &aOperation, |
|
402 QByteArray &aInputData, |
|
403 SmfPluginRequestData &aReqData, |
|
404 SmfPluginManagerResult &aResult ) |
|
405 { |
|
406 SmfPluginManager::getInstance()->server()->writeLog("SmfPluginManagerUtil::createMusicLyricsRequest"); |
|
407 |
|
408 // typecast instance to SmfLyricsServicePlugin |
|
409 SmfLyricsServicePlugin *plugin = qobject_cast<SmfLyricsServicePlugin *>(aPlugin); |
|
410 SmfPluginError pluginErrorVal; |
|
411 |
|
412 if(plugin) |
|
413 { |
|
414 QDataStream stream(aInputData); |
|
415 SmfTrackInfo trackInfo; |
|
416 int pageNum, itemPerPage; |
|
417 |
|
418 switch(aOperation) |
|
419 { |
|
420 case SmfMusicGetLyrics: |
|
421 stream>>trackInfo; |
|
422 stream>>pageNum; |
|
423 stream>>itemPerPage; |
|
424 pluginErrorVal = plugin->lyrics(aReqData, trackInfo, pageNum, itemPerPage); |
|
425 break; |
|
426 |
|
427 case SmfMusicGetSubtitle: |
|
428 { |
|
429 stream>>trackInfo; |
|
430 int i; |
|
431 stream>>i; |
|
432 SmfSubtitleSearchFilter filter = (SmfSubtitleSearchFilter)i; |
|
433 stream>>pageNum; |
|
434 stream>>itemPerPage; |
|
435 pluginErrorVal = plugin->subtitles(aReqData, trackInfo, filter, pageNum, itemPerPage); |
|
436 break; |
|
437 } |
|
438 |
|
439 default: |
|
440 // do nothing, unknown service |
|
441 aResult = SmfPluginUnknownService; |
|
442 SmfPluginManager::getInstance()->server()->writeLog("No API found for this operation type!!!"); |
|
443 return SmfPluginErrInvalidRequest; |
|
444 } |
|
445 |
|
446 if(SmfPluginErrNone == pluginErrorVal) |
|
447 aResult = SmfPluginRequestCreated; |
|
448 else |
|
449 aResult = SmfPluginServiceError; |
|
450 } |
|
451 else |
|
452 aResult = SmfPluginLoadError; |
|
453 |
|
454 return pluginErrorVal; |
|
455 } |
|
456 |
|
457 |
|
458 /** |
|
459 * Method to create a web query to do music event search or event post operation |
|
460 * @param aPlugin The instance of the loaded plugin that performs the |
|
461 * contact fetch operation. |
|
462 * @param aOperation The type of operation to be performed |
|
463 * @param aInputData The data required to create the web query |
|
464 * @param aReqData [out] The request data created by the plugin |
|
465 * @param aResult [out] SmfPluginManagerResult, The result of the operation |
|
466 * @return SmfPluginError |
|
467 * @see smfglobal.h |
|
468 */ |
|
469 SmfPluginError SmfPluginManagerUtil::createMusicEventsRequest ( QObject *aPlugin, |
|
470 const SmfRequestTypeID &aOperation, |
|
471 QByteArray &aInputData, |
|
472 SmfPluginRequestData &aReqData, |
|
473 SmfPluginManagerResult &aResult ) |
|
474 { |
|
475 SmfPluginManager::getInstance()->server()->writeLog("SmfPluginManagerUtil::createMusicEventsRequest"); |
|
476 |
|
477 // typecast instance to SmfMusicEventsPlugin |
|
478 SmfMusicEventsPlugin *plugin = qobject_cast<SmfMusicEventsPlugin *>(aPlugin); |
|
479 SmfPluginError pluginErrorVal; |
|
480 |
|
481 if(plugin) |
|
482 { |
|
483 QDataStream stream(aInputData); |
|
484 int pageNum, itemPerPage; |
|
485 QtMobility::QGeoPositionInfo location; |
|
486 |
|
487 switch(aOperation) |
|
488 { |
|
489 case SmfMusicGetEventsOnLoc: |
|
490 stream>>location; |
|
491 stream>>pageNum; |
|
492 stream>>itemPerPage; |
|
493 pluginErrorVal = plugin->events(aReqData, location, pageNum, itemPerPage); |
|
494 break; |
|
495 |
|
496 case SmfMusicGetVenueOnLoc: |
|
497 stream>>location; |
|
498 stream>>pageNum; |
|
499 stream>>itemPerPage; |
|
500 pluginErrorVal = plugin->venues(aReqData, location, pageNum, itemPerPage); |
|
501 break; |
|
502 |
|
503 case SmfMusicGetEventsOnVenue: |
|
504 { |
|
505 SmfLocation venue; |
|
506 stream>>venue; |
|
507 stream>>pageNum; |
|
508 stream>>itemPerPage; |
|
509 pluginErrorVal = plugin->events(aReqData, venue, pageNum, itemPerPage); |
|
510 break; |
|
511 } |
|
512 |
|
513 case SmfMusicPostEvents: |
|
514 { |
|
515 QList<SmfEvent> list; |
|
516 stream>>list; |
|
517 pluginErrorVal = plugin->postEvents(aReqData, list); |
|
518 break; |
|
519 } |
|
520 |
|
521 default: |
|
522 // do nothing, unknown service |
|
523 aResult = SmfPluginUnknownService; |
|
524 SmfPluginManager::getInstance()->server()->writeLog("No API found for this operation type!!!"); |
|
525 return SmfPluginErrInvalidRequest; |
|
526 } |
|
527 |
|
528 if(SmfPluginErrNone == pluginErrorVal) |
|
529 aResult = SmfPluginRequestCreated; |
|
530 else |
|
531 aResult = SmfPluginServiceError; |
|
532 } |
|
533 else |
|
534 aResult = SmfPluginLoadError; |
|
535 |
|
536 return pluginErrorVal; |
|
537 } |
|
538 |
|
539 |
|
540 |
|
541 /** |
|
542 * Method to create a web query to do music search operation |
|
543 * @param aPlugin The instance of the loaded plugin that performs the |
|
544 * contact fetch operation. |
|
545 * @param aOperation The type of operation to be performed |
|
546 * @param aInputData The data required to create the web query |
|
547 * @param aReqData [out] The request data created by the plugin |
|
548 * @param aResult [out] SmfPluginManagerResult, The result of the operation |
|
549 * @return SmfPluginError |
|
550 * @see smfglobal.h |
|
551 */ |
|
552 SmfPluginError SmfPluginManagerUtil::createMusicSearchRequest ( QObject *aPlugin, |
|
553 const SmfRequestTypeID &aOperation, |
|
554 QByteArray &aInputData, |
|
555 SmfPluginRequestData &aReqData, |
|
556 SmfPluginManagerResult &aResult ) |
|
557 { |
|
558 SmfPluginManager::getInstance()->server()->writeLog("SmfPluginManagerUtil::createMusicSearchRequest"); |
|
559 |
|
560 // typecast instance to SmfMusicSearchPlugin |
|
561 SmfMusicSearchPlugin *plugin = qobject_cast<SmfMusicSearchPlugin *>(aPlugin); |
|
562 SmfPluginError pluginErrorVal; |
|
563 |
|
564 if(plugin) |
|
565 { |
|
566 QDataStream stream(aInputData); |
|
567 int pageNum, itemPerPage; |
|
568 SmfTrackInfo trackInfo; |
|
569 |
|
570 switch(aOperation) |
|
571 { |
|
572 case SmfMusicGetRecommendations: |
|
573 stream>>trackInfo; |
|
574 stream>>pageNum; |
|
575 stream>>itemPerPage; |
|
576 pluginErrorVal = plugin->recommendations(aReqData, trackInfo, pageNum, itemPerPage); |
|
577 break; |
|
578 |
|
579 case SmfMusicGetTracks: |
|
580 stream>>trackInfo; |
|
581 stream>>pageNum; |
|
582 stream>>itemPerPage; |
|
583 pluginErrorVal = plugin->tracks(aReqData, trackInfo, pageNum, itemPerPage); |
|
584 break; |
|
585 |
|
586 case SmfMusicGetTrackInfo: |
|
587 { |
|
588 SmfMusicFingerPrint fp; |
|
589 stream>>fp; |
|
590 stream>>pageNum; |
|
591 stream>>itemPerPage; |
|
592 pluginErrorVal = plugin->trackInfo(aReqData, fp, pageNum, itemPerPage); |
|
593 break; |
|
594 } |
|
595 |
|
596 case SmfMusicGetStores: |
|
597 stream>>trackInfo; |
|
598 stream>>pageNum; |
|
599 stream>>itemPerPage; |
|
600 pluginErrorVal = plugin->stores(aReqData, trackInfo, pageNum, itemPerPage); |
|
601 break; |
|
602 |
|
603 case SmfMusicPostCurrentPlaying: |
|
604 stream>>trackInfo; |
|
605 pluginErrorVal = plugin->postCurrentPlaying(aReqData, trackInfo); |
|
606 break; |
|
607 |
|
608 default: |
|
609 // do nothing, unknown service |
|
610 aResult = SmfPluginUnknownService; |
|
611 SmfPluginManager::getInstance()->server()->writeLog("No API found for this operation type!!!"); |
|
612 return SmfPluginErrInvalidRequest; |
|
613 } |
|
614 |
|
615 if(SmfPluginErrNone == pluginErrorVal) |
|
616 aResult = SmfPluginRequestCreated; |
|
617 else |
|
618 aResult = SmfPluginServiceError; |
|
619 } |
|
620 else |
|
621 aResult = SmfPluginLoadError; |
|
622 |
|
623 return pluginErrorVal; |
|
624 } |
|
625 |
|
626 |
|
627 /** |
|
628 * Method to create a web query to do music service request operation |
|
629 * like getting self profile or search profiles of other users |
|
630 * @param aPlugin The instance of the loaded plugin that performs the |
|
631 * contact fetch operation. |
|
632 * @param aOperation The type of operation to be performed |
|
633 * @param aInputData The data required to create the web query |
|
634 * @param aReqData [out] The request data created by the plugin |
|
635 * @param aResult [out] SmfPluginManagerResult, The result of the operation |
|
636 * @return SmfPluginError |
|
637 * @see smfglobal.h |
|
638 */ |
|
639 SmfPluginError SmfPluginManagerUtil::createMusicServiceRequest ( QObject *aPlugin, |
|
640 const SmfRequestTypeID &aOperation, |
|
641 QByteArray &aInputData, |
|
642 SmfPluginRequestData &aReqData, |
|
643 SmfPluginManagerResult &aResult ) |
|
644 { |
|
645 SmfPluginManager::getInstance()->server()->writeLog("SmfPluginManagerUtil::createMusicServiceRequest"); |
|
646 |
|
647 // typecast instance to SmfMusicServicePlugin |
|
648 SmfMusicServicePlugin *plugin = qobject_cast<SmfMusicServicePlugin *>(aPlugin); |
|
649 SmfPluginError pluginErrorVal; |
|
650 |
|
651 if(plugin) |
|
652 { |
|
653 QDataStream stream(aInputData); |
|
654 int pageNum, itemPerPage; |
|
655 |
|
656 switch(aOperation) |
|
657 { |
|
658 case SmfMusicGetUserInfo: |
|
659 pluginErrorVal = plugin->userInfo(aReqData); |
|
660 break; |
|
661 |
|
662 case SmfMusicSearchUser: |
|
663 { |
|
664 SmfLocation place; |
|
665 stream>>place; |
|
666 stream>>pageNum; |
|
667 stream>>itemPerPage; |
|
668 pluginErrorVal = plugin->searchUser(aReqData, place, pageNum, itemPerPage); |
|
669 break; |
|
670 } |
|
671 |
|
672 default: |
|
673 // do nothing, unknown service |
|
674 aResult = SmfPluginUnknownService; |
|
675 SmfPluginManager::getInstance()->server()->writeLog("No API found for this operation type!!!"); |
|
676 return SmfPluginErrInvalidRequest; |
|
677 } |
|
678 |
|
679 if(SmfPluginErrNone == pluginErrorVal) |
|
680 aResult = SmfPluginRequestCreated; |
|
681 else |
|
682 aResult = SmfPluginServiceError; |
|
683 } |
|
684 else |
|
685 aResult = SmfPluginLoadError; |
|
686 |
|
687 return pluginErrorVal; |
|
688 } |
|
689 |
|
690 |
|
691 |
|
692 /** |
|
693 * Method to create a web query to do music playlist related operation |
|
694 * @param aPlugin The instance of the loaded plugin that performs the |
|
695 * contact fetch operation. |
|
696 * @param aOperation The type of operation to be performed |
|
697 * @param aInputData The data required to create the web query |
|
698 * @param aReqData [out] The request data created by the plugin |
|
699 * @param aResult [out] SmfPluginManagerResult, The result of the operation |
|
700 * @return SmfPluginError |
|
701 * @see smfglobal.h |
|
702 */ |
|
703 SmfPluginError SmfPluginManagerUtil::createMusicPlaylistRequest ( QObject *aPlugin, |
|
704 const SmfRequestTypeID &aOperation, |
|
705 QByteArray &aInputData, |
|
706 SmfPluginRequestData &aReqData, |
|
707 SmfPluginManagerResult &aResult ) |
|
708 { |
|
709 SmfPluginManager::getInstance()->server()->writeLog("SmfPluginManagerUtil::createMusicPlaylistRequest"); |
|
710 |
|
711 // typecast instance to SmfPlaylistServicePlugin |
|
712 SmfPlaylistServicePlugin *plugin = qobject_cast<SmfPlaylistServicePlugin *>(aPlugin); |
|
713 SmfPluginError pluginErrorVal; |
|
714 |
|
715 if(plugin) |
|
716 { |
|
717 QDataStream stream(aInputData); |
|
718 int pageNum, itemPerPage; |
|
719 SmfPlaylist playlist; |
|
720 |
|
721 switch(aOperation) |
|
722 { |
|
723 case SmfMusicGetPlaylists: |
|
724 stream>>pageNum; |
|
725 stream>>itemPerPage; |
|
726 pluginErrorVal = plugin->playlists(aReqData, pageNum, itemPerPage); |
|
727 break; |
|
728 |
|
729 case SmfMusicGetPlaylistsOfUser: |
|
730 { |
|
731 SmfMusicProfile user; |
|
732 stream>>user; |
|
733 stream>>pageNum; |
|
734 stream>>itemPerPage; |
|
735 pluginErrorVal = plugin->playlistsOf(aReqData, user, pageNum, itemPerPage); |
|
736 break; |
|
737 } |
|
738 |
|
739 case SmfMusicAddToPlaylist: |
|
740 { |
|
741 QList<SmfTrackInfo> list; |
|
742 stream>>playlist; |
|
743 stream>>list; |
|
744 pluginErrorVal = plugin->addToPlaylist(aReqData, playlist, list); |
|
745 break; |
|
746 } |
|
747 |
|
748 case SmfMusicPostCurrentPlayingPlaylist: |
|
749 stream>>playlist; |
|
750 pluginErrorVal = plugin->postCurrentPlayingPlaylist(aReqData, playlist); |
|
751 break; |
|
752 |
|
753 default: |
|
754 // do nothing, unknown service |
|
755 aResult = SmfPluginUnknownService; |
|
756 SmfPluginManager::getInstance()->server()->writeLog("No API found for this operation type!!!"); |
|
757 return SmfPluginErrInvalidRequest; |
|
758 } |
|
759 |
|
760 if(SmfPluginErrNone == pluginErrorVal) |
|
761 aResult = SmfPluginRequestCreated; |
|
762 else |
|
763 aResult = SmfPluginServiceError; |
|
764 } |
|
765 else |
|
766 aResult = SmfPluginLoadError; |
|
767 |
|
768 return pluginErrorVal; |
|
769 } |
|
770 |
|
771 |
|
772 /** |
|
773 * Method to create a web query to do gallery related operation |
|
774 * @param aPlugin The instance of the loaded plugin that performs the |
|
775 * contact fetch operation. |
|
776 * @param aOperation The type of operation to be performed |
|
777 * @param aInputData The data required to create the web query |
|
778 * @param aReqData [out] The request data created by the plugin |
|
779 * @param aResult [out] SmfPluginManagerResult, The result of the operation |
|
780 * @return SmfPluginError |
|
781 * @see smfglobal.h |
|
782 */ |
|
783 SmfPluginError SmfPluginManagerUtil::createGalleryRequest ( QObject *aPlugin, |
|
784 const SmfRequestTypeID &aOperation, |
|
785 QByteArray &aInputData, |
|
786 SmfPluginRequestData &aReqData, |
|
787 SmfPluginManagerResult &aResult ) |
|
788 { |
|
789 SmfPluginManager::getInstance()->server()->writeLog("SmfPluginManagerUtil::createGalleryRequest"); |
|
790 |
|
791 // typecast instance to SmfGalleryPlugin |
|
792 SmfGalleryPlugin *plugin = qobject_cast<SmfGalleryPlugin *>(aPlugin); |
|
793 SmfPluginError pluginErrorVal; |
|
794 |
|
795 if(plugin) |
|
796 { |
|
797 QDataStream stream(aInputData); |
|
798 SmfPicture picture; |
|
799 |
|
800 switch(aOperation) |
|
801 { |
|
802 case SmfPictureGetPictures: |
|
803 { |
|
804 int pageNum, itemPerPage; |
|
805 stream>>pageNum; |
|
806 stream>>itemPerPage; |
|
807 pluginErrorVal = plugin->pictures(aReqData, pageNum, itemPerPage); |
|
808 break; |
|
809 } |
|
810 |
|
811 case SmfPictureDescription: |
|
812 stream>>picture; |
|
813 pluginErrorVal = plugin->description(aReqData, picture); |
|
814 break; |
|
815 |
|
816 case SmfPictureUpload: |
|
817 stream>>picture; |
|
818 pluginErrorVal = plugin->upload(aReqData, picture); |
|
819 break; |
|
820 |
|
821 case SmfPictureMultiUpload: |
|
822 { |
|
823 QList<SmfPicture> list; |
|
824 stream>>list; |
|
825 pluginErrorVal = plugin->upload(aReqData, list); |
|
826 break; |
|
827 } |
|
828 |
|
829 case SmfPicturePostComment: |
|
830 { |
|
831 SmfComment comment; |
|
832 stream>>picture; |
|
833 stream>>comment; |
|
834 pluginErrorVal = plugin->postComment(aReqData, picture, comment); |
|
835 break; |
|
836 } |
|
837 |
|
838 default: |
|
839 // do nothing, unknown service |
|
840 aResult = SmfPluginUnknownService; |
|
841 SmfPluginManager::getInstance()->server()->writeLog("No API found for this operation type!!!"); |
|
842 return SmfPluginErrInvalidRequest; |
|
843 } |
|
844 |
|
845 if(SmfPluginErrNone == pluginErrorVal) |
|
846 aResult = SmfPluginRequestCreated; |
|
847 else |
|
848 aResult = SmfPluginServiceError; |
|
849 } |
|
850 else |
|
851 aResult = SmfPluginLoadError; |
|
852 |
|
853 return pluginErrorVal; |
|
854 } |
|
855 |
|
856 |
|
857 /** |
|
858 * Method called by Plugin Manager when network response is available |
|
859 * @param aInstance The instance of the loaded plugin that requested |
|
860 * the network operation. |
|
861 * @param aOperation The type of operation to be performed |
|
862 * @param aTransportResult The result of Transport Operation |
|
863 * @param aResponse The network response data |
|
864 * @param aResult [out] An output parameter to the plugin manager |
|
865 * containing the data parsed by the plugins |
|
866 * @param aRetType [out] The Plugin return value |
|
867 * @param aPageResult [out] The page information filled by the plugins |
|
868 * @return SmfPluginManagerResult, The result of the operation |
|
869 * @see smfglobal.h |
|
870 */ |
|
871 SmfPluginManagerResult SmfPluginManagerUtil::responseAvailable ( |
|
872 SmfPluginBase *aInstance, |
|
873 const SmfRequestTypeID &aOperation, |
|
874 const SmfTransportResult &aTransportResult, |
|
875 QByteArray *aResponse, |
|
876 QVariant *aResult, |
|
877 SmfPluginRetType &aRetType, |
|
878 SmfResultPage &aPageResult ) |
|
879 { |
|
880 SmfPluginManager::getInstance()->server()->writeLog("SmfPluginManagerUtil::responseAvailable"); |
|
881 |
|
882 SmfPluginError pluginRet; |
|
883 SmfPluginManagerResult result = SmfPluginUnknownError; |
|
884 |
|
885 switch(aOperation) |
|
886 { |
|
887 case SmfContactGetFriends: |
|
888 case SmfContactGetFollowers: |
|
889 case SmfContactSearch: |
|
890 case SmfContactSearchNear: |
|
891 case SmfContactGetGroups: |
|
892 case SmfContactSearchInGroup: |
|
893 case SmfContactRetrievePosts: |
|
894 case SmfContactPost: |
|
895 case SmfContactUpdatePost: |
|
896 case SmfContactPostDirected: |
|
897 case SmfContactCommentOnAPost: |
|
898 case SmfContactPostAppearence: |
|
899 case SmfContactSharePost: |
|
900 case SmfMusicGetLyrics: |
|
901 case SmfMusicGetSubtitle: |
|
902 case SmfMusicGetEventsOnLoc: |
|
903 case SmfMusicGetVenueOnLoc: |
|
904 case SmfMusicGetEventsOnVenue: |
|
905 case SmfMusicPostEvents: |
|
906 case SmfMusicGetRecommendations: |
|
907 case SmfMusicGetTracks: |
|
908 case SmfMusicGetTrackInfo: |
|
909 case SmfMusicGetStores: |
|
910 case SmfMusicPostCurrentPlaying: |
|
911 case SmfMusicGetUserInfo: |
|
912 case SmfMusicSearchUser: |
|
913 case SmfMusicGetPlaylists: |
|
914 case SmfMusicGetPlaylistsOfUser: |
|
915 case SmfMusicAddToPlaylist: |
|
916 case SmfMusicPostCurrentPlayingPlaylist: |
|
917 case SmfPictureGetPictures: |
|
918 case SmfPictureDescription: |
|
919 case SmfPictureUpload: |
|
920 case SmfPictureMultiUpload: |
|
921 case SmfPicturePostComment: |
|
922 { |
|
923 pluginRet = aInstance->responseAvailable(aTransportResult, aResponse, |
|
924 aResult, aRetType, aPageResult ); |
|
925 |
|
926 // When plugin returns no error |
|
927 if( SmfPluginErrNone == pluginRet ) |
|
928 { |
|
929 // Request is complete, parsed data available with aResult |
|
930 if( SmfRequestComplete == aRetType ) |
|
931 result = SmfPluginResponseParsed; |
|
932 |
|
933 // Send the request again |
|
934 else if(SmfSendRequestAgain == aRetType ) |
|
935 result = SmfPluginSendRequestAgain; |
|
936 else |
|
937 result = SmfPluginResponseParseFailure; |
|
938 } |
|
939 // Parsing failed |
|
940 else |
|
941 result = SmfPluginResponseParseFailure; |
|
942 |
|
943 break; |
|
944 } |
|
945 |
|
946 default: |
|
947 // Unknown service, saved data in Plugin manager is corrupted |
|
948 SmfPluginManager::getInstance()->server()->writeLog("No operation type found!!!"); |
|
949 } |
|
950 |
|
951 return result; |
|
952 } |
|
953 |
|
954 |
|
955 /** |
|
956 * Method to serialize the result of parsing (which is done by the |
|
957 * plugins) to QByteArray to be sent to Smf server. |
|
958 * @param aOperation The type of operation to be performed |
|
959 * @param aResult The data to be serialized |
|
960 * @param aDataStream Stream to be written |
|
961 */ |
|
962 void SmfPluginManagerUtil::serializeResult ( |
|
963 const SmfRequestTypeID &aOperation, |
|
964 QVariant* aResult, |
|
965 QDataStream &aDataStream ) |
|
966 { |
|
967 SmfPluginManager::getInstance()->server()->writeLog("SmfPluginManagerUtil::serializeResult"); |
|
968 switch(aOperation) |
|
969 { |
|
970 // FOR CONTACT - FETCHER |
|
971 case SmfContactGetFriends: |
|
972 case SmfContactGetFollowers: |
|
973 case SmfContactSearch: |
|
974 case SmfContactSearchNear: |
|
975 case SmfContactSearchInGroup: |
|
976 { |
|
977 QList<SmfContact> contactList; |
|
978 if( aResult->canConvert<SmfContactList>() ) |
|
979 contactList = aResult->value<SmfContactList>(); |
|
980 aDataStream<<contactList; |
|
981 break; |
|
982 } |
|
983 |
|
984 case SmfContactGetGroups: |
|
985 { |
|
986 QList<SmfGroup> groupList; |
|
987 if( aResult->canConvert<SmfGroupList>() ) |
|
988 groupList = aResult->value<SmfGroupList>(); |
|
989 aDataStream<<groupList; |
|
990 |
|
991 break; |
|
992 } |
|
993 |
|
994 // FOR CONTACT - POSTS |
|
995 case SmfContactRetrievePosts: |
|
996 { |
|
997 SmfPluginManager::getInstance()->server()->writeLog("Serialize - retrieveposts() result"); |
|
998 |
|
999 QList<SmfPost> postList; |
|
1000 if( aResult->canConvert<SmfPostList>() ) |
|
1001 postList = aResult->value<SmfPostList>(); |
|
1002 aDataStream<<postList; |
|
1003 break; |
|
1004 } |
|
1005 |
|
1006 case SmfContactPost: |
|
1007 case SmfContactUpdatePost: |
|
1008 case SmfContactPostDirected: |
|
1009 case SmfContactCommentOnAPost: |
|
1010 case SmfContactPostAppearence: |
|
1011 case SmfContactSharePost: |
|
1012 { |
|
1013 bool value; |
|
1014 if( QVariant::Bool == aResult->type() ) |
|
1015 value = aResult->toBool(); |
|
1016 aDataStream<<value; |
|
1017 break; |
|
1018 } |
|
1019 |
|
1020 // FOR MUSIC - LYRICS SERVICE |
|
1021 case SmfMusicGetLyrics: |
|
1022 { |
|
1023 QList<SmfLyrics> lyricsList; |
|
1024 if( aResult->canConvert<SmfLyricsList>() ) |
|
1025 lyricsList = aResult->value<SmfLyricsList>(); |
|
1026 aDataStream<<lyricsList; |
|
1027 |
|
1028 break; |
|
1029 } |
|
1030 |
|
1031 case SmfMusicGetSubtitle: |
|
1032 { |
|
1033 QList<SmfSubtitle> subtitleList; |
|
1034 if( aResult->canConvert<SmfSubtitleList>() ) |
|
1035 subtitleList = aResult->value<SmfSubtitleList>(); |
|
1036 aDataStream<<subtitleList; |
|
1037 |
|
1038 break; |
|
1039 } |
|
1040 |
|
1041 // FOR MUSIC - EVENTS |
|
1042 case SmfMusicGetEventsOnLoc: |
|
1043 case SmfMusicGetEventsOnVenue: |
|
1044 { |
|
1045 QList<SmfEvent> eventList; |
|
1046 if( aResult->canConvert<SmfEventList>() ) |
|
1047 eventList = aResult->value<SmfEventList>(); |
|
1048 aDataStream<<eventList; |
|
1049 |
|
1050 break; |
|
1051 } |
|
1052 |
|
1053 case SmfMusicGetVenueOnLoc: |
|
1054 { |
|
1055 QList<SmfLocation> venueList; |
|
1056 if( aResult->canConvert<SmfLocationList>() ) |
|
1057 venueList = aResult->value<SmfLocationList>(); |
|
1058 aDataStream<<venueList; |
|
1059 break; |
|
1060 } |
|
1061 |
|
1062 case SmfMusicPostEvents: |
|
1063 { |
|
1064 bool value; |
|
1065 if( QVariant::Bool == aResult->type() ) |
|
1066 value = aResult->toBool(); |
|
1067 aDataStream<<value; |
|
1068 break; |
|
1069 } |
|
1070 |
|
1071 // FOR MUSIC - SEARCH |
|
1072 case SmfMusicGetRecommendations: |
|
1073 case SmfMusicGetTracks: |
|
1074 case SmfMusicGetTrackInfo: |
|
1075 { |
|
1076 QList<SmfTrackInfo> trackList; |
|
1077 if( aResult->canConvert<SmfTrackInfoList>() ) |
|
1078 trackList = aResult->value<SmfTrackInfoList>(); |
|
1079 aDataStream<<trackList; |
|
1080 |
|
1081 break; |
|
1082 } |
|
1083 |
|
1084 case SmfMusicGetStores: |
|
1085 { |
|
1086 QList<SmfProvider> storeList; |
|
1087 if( aResult->canConvert<SmfProviderList>() ) |
|
1088 storeList = aResult->value<SmfProviderList>(); |
|
1089 aDataStream<<storeList; |
|
1090 break; |
|
1091 } |
|
1092 |
|
1093 case SmfMusicPostCurrentPlaying: |
|
1094 { |
|
1095 bool value; |
|
1096 if( QVariant::Bool == aResult->type() ) |
|
1097 value = aResult->toBool(); |
|
1098 aDataStream<<value; |
|
1099 break; |
|
1100 } |
|
1101 |
|
1102 |
|
1103 // FOR MUSIC - SERVICE |
|
1104 case SmfMusicGetUserInfo: |
|
1105 { |
|
1106 SmfMusicProfile user; |
|
1107 if(aResult->canConvert<SmfMusicProfile>()) |
|
1108 user = aResult->value<SmfMusicProfile>(); |
|
1109 aDataStream<<user; |
|
1110 break; |
|
1111 } |
|
1112 |
|
1113 case SmfMusicSearchUser: |
|
1114 { |
|
1115 QList<SmfMusicProfile> userList; |
|
1116 if( aResult->canConvert<SmfMusicProfileList>() ) |
|
1117 userList = aResult->value<SmfMusicProfileList>(); |
|
1118 aDataStream<<userList; |
|
1119 break; |
|
1120 } |
|
1121 |
|
1122 // FOR MUSIC - PLAYLIST SERVICE |
|
1123 case SmfMusicGetPlaylists: |
|
1124 case SmfMusicGetPlaylistsOfUser: |
|
1125 { |
|
1126 QList<SmfPlaylist> playlists; |
|
1127 if( aResult->canConvert<SmfPlaylistList>() ) |
|
1128 playlists = aResult->value<SmfPlaylistList>(); |
|
1129 aDataStream<<playlists; |
|
1130 break; |
|
1131 } |
|
1132 |
|
1133 case SmfMusicAddToPlaylist: |
|
1134 case SmfMusicPostCurrentPlayingPlaylist: |
|
1135 { |
|
1136 bool value; |
|
1137 if( QVariant::Bool == aResult->type() ) |
|
1138 value = aResult->toBool(); |
|
1139 aDataStream<<value; |
|
1140 break; |
|
1141 } |
|
1142 |
|
1143 // FOR PICTURES - GALLERY SERVICES |
|
1144 case SmfPictureGetPictures: |
|
1145 { |
|
1146 QList<SmfPicture> picList; |
|
1147 if( aResult->canConvert<SmfPictureList>() ) |
|
1148 picList = aResult->value<SmfPictureList>(); |
|
1149 aDataStream<<picList; |
|
1150 break; |
|
1151 } |
|
1152 |
|
1153 case SmfPictureDescription: |
|
1154 { |
|
1155 QString str; |
|
1156 if( QVariant::String == aResult->type() ) |
|
1157 str = aResult->toString(); |
|
1158 aDataStream<<str; |
|
1159 break; |
|
1160 } |
|
1161 |
|
1162 case SmfPictureUpload: |
|
1163 case SmfPictureMultiUpload: |
|
1164 case SmfPicturePostComment: |
|
1165 { |
|
1166 bool value; |
|
1167 if( QVariant::Bool == aResult->type() ) |
|
1168 value = aResult->toBool(); |
|
1169 aDataStream<<value; |
|
1170 break; |
|
1171 } |
|
1172 |
|
1173 default: |
|
1174 // Unknown service, saved data in Plugin manager is corrupted |
|
1175 SmfPluginManager::getInstance()->server()->writeLog("No operation type found!!!"); |
|
1176 } |
|
1177 } |
|
1178 |