|
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 * Nalina Hariharan |
|
14 * |
|
15 * Description: |
|
16 * The Plugin that does music services related functionalities from last.fm site |
|
17 * |
|
18 */ |
|
19 |
|
20 #ifndef _LASTFMMUSICSERVICEPLUGIN_H |
|
21 #define _LASTFMMUSICSERVICEPLUGIN_H |
|
22 |
|
23 // Include files |
|
24 #include <smfmusicserviceplugin.h> |
|
25 |
|
26 // Class declaration |
|
27 class LastFmMusicServiceProviderBase; |
|
28 class QVariant; |
|
29 |
|
30 /** |
|
31 * The Plugin does music services related functionalities from last.fm site |
|
32 */ |
|
33 class LastFmMusicServicePlugin : public QObject, public SmfMusicServicePlugin |
|
34 { |
|
35 Q_OBJECT |
|
36 Q_INTERFACES( SmfMusicServicePlugin SmfPluginBase ) |
|
37 |
|
38 public: |
|
39 /** |
|
40 * Destructor |
|
41 */ |
|
42 virtual ~LastFmMusicServicePlugin ( ); |
|
43 |
|
44 public: // From SmfMusicServicePlugin interface |
|
45 /** |
|
46 * Method to get self profile information |
|
47 * @param aRequest [out] The request data to be sent to network |
|
48 * @return Appropriate value of the enum SmfPluginError. |
|
49 * Plugin error if any, else SmfPluginErrNone for success |
|
50 */ |
|
51 SmfPluginError userMusicInfo( SmfPluginRequestData &aRequest ); |
|
52 |
|
53 /** |
|
54 * Method to search information about artists. All information |
|
55 * in SmfArtists is not required, however more available the better |
|
56 * @param aRequest [out] The request data to be sent to network |
|
57 * @param aArtist The artist which is the search criteria |
|
58 * @param aPageNum The page to be extracted |
|
59 * @param aItemsPerPage Number of items per page |
|
60 * @return Appropriate value of the enum SmfPluginError. |
|
61 * Plugin error if any, else SmfPluginErrNone for success |
|
62 */ |
|
63 SmfPluginError searchArtist( SmfPluginRequestData &aRequest, |
|
64 const SmfArtists &aArtist, |
|
65 const int aPageNum = SMF_FIRST_PAGE, |
|
66 const int aItemsPerPage = SMF_ITEMS_PER_PAGE ); |
|
67 |
|
68 /** |
|
69 * Method to search information about album. All information |
|
70 * in SmfAlbum is not required, however more available the better |
|
71 * @param aRequest [out] The request data to be sent to network |
|
72 * @param aAlbum [in] The album which is the search criteria |
|
73 * @param aPageNum [in] The page to be extracted |
|
74 * @param aItemsPerPage [in] Number of items per page |
|
75 * @return Appropriate value of the enum SmfPluginError. |
|
76 * Plugin error if any, else SmfPluginErrNone for success |
|
77 */ |
|
78 SmfPluginError searchAlbum( SmfPluginRequestData &aRequest, |
|
79 const SmfAlbum &aAlbum, |
|
80 const int aPageNum = SMF_FIRST_PAGE, |
|
81 const int aItemsPerPage = SMF_ITEMS_PER_PAGE ); |
|
82 |
|
83 /** |
|
84 * Method to search information about events. All information |
|
85 * in SmfEvent is not required, however more available the better |
|
86 * @param aRequest [out] The request data to be sent to network |
|
87 * @param aEvent [in] The event which is the search criteria |
|
88 * @param aPageNum [in] The page to be extracted |
|
89 * @param aItemsPerPage [in] Number of items per page |
|
90 * @return Appropriate value of the enum SmfPluginError. |
|
91 * Plugin error if any, else SmfPluginErrNone for success |
|
92 */ |
|
93 SmfPluginError searchEvents( SmfPluginRequestData &aRequest, |
|
94 const SmfEvent &aEvent, |
|
95 const int aPageNum = SMF_FIRST_PAGE, |
|
96 const int aItemsPerPage = SMF_ITEMS_PER_PAGE ); |
|
97 |
|
98 /** |
|
99 * Method to search information about venue. All information |
|
100 * in SmfLocation is not required, however more available the better |
|
101 * @param aRequest [out] The request data to be sent to network |
|
102 * @param aVenue [in] The venue which is the search criteria |
|
103 * @param aPageNum [in] The page to be extracted |
|
104 * @param aItemsPerPage [in] Number of items per page |
|
105 * @return Appropriate value of the enum SmfPluginError. |
|
106 * Plugin error if any, else SmfPluginErrNone for success |
|
107 */ |
|
108 SmfPluginError searchVenue( SmfPluginRequestData &aRequest, |
|
109 const SmfLocation &aVenue, |
|
110 const int aPageNum = SMF_FIRST_PAGE, |
|
111 const int aItemsPerPage = SMF_ITEMS_PER_PAGE ); |
|
112 |
|
113 /** |
|
114 * Method to search information about other service users for a |
|
115 * particular place |
|
116 * @param aRequest [out] The request data to be sent to network |
|
117 * @param aPlace [in] The place which is the search criteria |
|
118 * @param aPageNum [in] The page to be extracted |
|
119 * @param aItemsPerPage [in] Number of items per page |
|
120 * @return Appropriate value of the enum SmfPluginError. |
|
121 * Plugin error if any, else SmfPluginErrNone for success |
|
122 */ |
|
123 SmfPluginError searchUser( SmfPluginRequestData &aRequest, |
|
124 const SmfLocation &aPlace, |
|
125 const int aPageNum = SMF_FIRST_PAGE, |
|
126 const int aItemsPerPage = SMF_ITEMS_PER_PAGE ); |
|
127 |
|
128 /** |
|
129 * Method to post the currently playing track |
|
130 * @param aRequest [out] The request data to be sent to network |
|
131 * @param aTrack [in] The current playing track, that should be posted |
|
132 * @return Appropriate value of the enum SmfPluginError. |
|
133 * Plugin error if any, else SmfPluginErrNone for success |
|
134 */ |
|
135 SmfPluginError postCurrentPlaying( |
|
136 SmfPluginRequestData &aRequest, |
|
137 const SmfTrackInfo &aTrack ); |
|
138 |
|
139 /** |
|
140 * Method to post the rating on a track |
|
141 * @param aRequest [out] The request data to be sent to network |
|
142 * @param aTrack [in] The track on which rating should be posted |
|
143 * @param aRating [in] The rating values |
|
144 * @return Appropriate value of the enum SmfPluginError. |
|
145 * Plugin error if any, else SmfPluginErrNone for success |
|
146 */ |
|
147 SmfPluginError postRating( |
|
148 SmfPluginRequestData &aRequest, |
|
149 const SmfTrackInfo &aTrack, |
|
150 const SmfMusicRating &aRating ); |
|
151 |
|
152 /** |
|
153 * Method to post comment on a track |
|
154 * @param aRequest [out] The request data to be sent to network |
|
155 * @param aTrack [in] The track on which comment should be posted |
|
156 * @param aComment [in] The comment content |
|
157 * @return Appropriate value of the enum SmfPluginError. |
|
158 * Plugin error if any, else SmfPluginErrNone for success |
|
159 */ |
|
160 SmfPluginError postComments( |
|
161 SmfPluginRequestData &aRequest, |
|
162 const SmfTrackInfo &aTrack, |
|
163 const SmfComment &aComment ); |
|
164 |
|
165 /** |
|
166 * Customised method for SmfMusicServicePlugin interface |
|
167 * @param aRequest [out] The request data to be sent to network |
|
168 * @param aOperation [in] The operation type (should be known between |
|
169 * the client interface and the plugin) |
|
170 * @param aData [in] The data required to form the request (The type |
|
171 * of data should be known between client and the plugin) |
|
172 * @return Appropriate value of the enum SmfPluginError. |
|
173 * Plugin error if any, else SmfPluginErrNone for success |
|
174 */ |
|
175 SmfPluginError customRequest( SmfPluginRequestData &aRequest, |
|
176 const int &aOperation, QByteArray *aData ); |
|
177 |
|
178 |
|
179 public: // From SmfPluginBase interface |
|
180 /** |
|
181 * The first method to be called in the plugin that implements this interface. |
|
182 * If this method is not called, plugin may not behave as expected. |
|
183 */ |
|
184 void initialize( ); |
|
185 |
|
186 /** |
|
187 * Method to get the provider information |
|
188 * @return Instance of SmfProviderBase |
|
189 */ |
|
190 SmfProviderBase* getProviderInfo( ); |
|
191 |
|
192 /** |
|
193 * Method to get the result for a network request. |
|
194 * @param aOperation The type of operation to be requested |
|
195 * @param aTransportResult The result of transport operation |
|
196 * @param aResponse The QByteArray instance containing the network response. |
|
197 * The plugins should delete this instance once they have read the |
|
198 * data from it. |
|
199 * @param aResult [out] An output parameter to the plugin manager.If the |
|
200 * return value is SmfSendRequestAgain, QVariant will be of type |
|
201 * SmfPluginRequestData. |
|
202 * For SmfMusicServicePlugin: If last operation was userMusicInfo(), aResult |
|
203 * will be of type SmfMusicProfile. If last operation was searchArtist(), |
|
204 * aResult will be of type QList<SmfArtists>. If last operation was searchAlbum(), |
|
205 * aResult will be of type QList<SmfAlbum>. If last operation was searchEvents(), |
|
206 * aResult will be of type QList<SmfEvent>. If last operation was searchVenue(), |
|
207 * aResult will be of type QList<Smfocation>. If last operation was searchUser(), |
|
208 * aResult will be of type QList<SmfMusicProfile>. If last operation was |
|
209 * postCurrentPlaying() or postRating() or postComments(), aResult will be of |
|
210 * type bool. |
|
211 * @param aRetType [out] SmfPluginRetType |
|
212 * @param aPageResult [out] The SmfResultPage structure variable |
|
213 */ |
|
214 SmfPluginError responseAvailable( |
|
215 const SmfRequestTypeID aOperation, |
|
216 const SmfTransportResult &aTransportResult, |
|
217 QByteArray *aResponse, |
|
218 QVariant* aResult, |
|
219 SmfPluginRetType &aRetType, |
|
220 SmfResultPage &aPageResult ); |
|
221 |
|
222 private: |
|
223 /** |
|
224 * Method called by plugins to generate a signature string from a base string |
|
225 * @param aBaseString The base string |
|
226 * @return The md5 hash of the base string |
|
227 */ |
|
228 QString generateSignature(const QString aBaseString); |
|
229 |
|
230 /** |
|
231 * Method to interpret the key sets obtained from credential manager |
|
232 * @param aApiKey [out] The api key |
|
233 * @param aApiSecret [out] The api secret |
|
234 * @param aSessionKey [out] The session key |
|
235 * @param aToken [out] The session token |
|
236 * @param aName [out] The user name |
|
237 */ |
|
238 void fetchKeys( QString &aApiKey, |
|
239 QString &aApiSecret, |
|
240 QString &aToken, |
|
241 QString &aName ); |
|
242 |
|
243 private: // Data |
|
244 LastFmMusicServiceProviderBase *m_provider; |
|
245 }; |
|
246 |
|
247 |
|
248 |
|
249 /** |
|
250 * The Plugin class that implements SmfProviderBase for this last.fm plugin |
|
251 */ |
|
252 class LastFmMusicServiceProviderBase : public QObject, public SmfProviderBase |
|
253 { |
|
254 Q_OBJECT |
|
255 Q_INTERFACES( SmfProviderBase ) |
|
256 |
|
257 public: |
|
258 /** |
|
259 * Destructor |
|
260 */ |
|
261 virtual ~LastFmMusicServiceProviderBase( ); |
|
262 |
|
263 /** |
|
264 * Method to get the Localisable name of the service. |
|
265 * @return The Localisable name of the service. |
|
266 */ |
|
267 QString serviceName( ) const; |
|
268 |
|
269 /** |
|
270 * Method to get the Logo of the service |
|
271 * @return The Logo of the service |
|
272 */ |
|
273 QImage serviceIcon( ) const; |
|
274 |
|
275 /** |
|
276 * Method to get the Readable service description |
|
277 * @return The Readable service description |
|
278 */ |
|
279 QString description( ) const; |
|
280 |
|
281 /** |
|
282 * Method to get the Website of the service |
|
283 * @return The Website of the service |
|
284 */ |
|
285 QUrl serviceUrl( ) const; |
|
286 |
|
287 /** |
|
288 * Method to get the URL of the Application providing this service |
|
289 * @return The URL of the Application providing this service |
|
290 */ |
|
291 QUrl applicationUrl( ) const; |
|
292 |
|
293 /** |
|
294 * Method to get the Icon of the application |
|
295 * @return The Icon of the application |
|
296 */ |
|
297 QImage applicationIcon( ) const; |
|
298 |
|
299 /** |
|
300 * Method to get the list of interfaces that this provider support |
|
301 * @return List of supported Interafces |
|
302 */ |
|
303 QList<QString> supportedInterfaces( ) const; |
|
304 |
|
305 /** |
|
306 * Method to get the list of languages supported by this service provider |
|
307 * @return a QStringList of languages supported by this service |
|
308 * provider in 2 letter ISO 639-1 format. |
|
309 */ |
|
310 QStringList supportedLanguages( ) const; |
|
311 |
|
312 /** |
|
313 * Method to get the Plugin specific ID |
|
314 * @return The Plugin specific ID |
|
315 */ |
|
316 QString pluginId( ) const; |
|
317 |
|
318 /** |
|
319 * Method to get the ID of the authentication application |
|
320 * for this service |
|
321 * @param aProgram The authentication application name |
|
322 * @param aArguments List of arguments required for authentication app |
|
323 * @param aMode Strting mode for authentication application |
|
324 * @return The ID of the authentication application |
|
325 */ |
|
326 QString authenticationApp( QString &aProgram, QStringList & aArguments, |
|
327 QIODevice::OpenModeFlag aMode = QIODevice::ReadWrite ) const; |
|
328 |
|
329 /** |
|
330 * Method to get the unique registration ID provided by the |
|
331 * Smf for authorised plugins |
|
332 * @return The unique registration ID/token provided by the Smf for |
|
333 * authorised plugins |
|
334 */ |
|
335 QString smfRegistrationId( ) const; |
|
336 |
|
337 private: |
|
338 /** |
|
339 * Method that initializes this class. This method should be called |
|
340 * from the initialize() method of the LastFmMusicServicePlugin class |
|
341 */ |
|
342 void initialize(); |
|
343 |
|
344 private: |
|
345 friend class LastFmMusicServicePlugin; |
|
346 QString m_serviceName; |
|
347 QImage m_serviceIcon; |
|
348 QString m_description; |
|
349 QUrl m_serviceUrl; |
|
350 QUrl m_applicationUrl; |
|
351 QImage m_applicationIcon; |
|
352 QString m_pluginId; |
|
353 QString m_authAppId; |
|
354 QString m_smfRegToken; |
|
355 QList<QString> m_supportedInterfaces; |
|
356 QStringList m_supportedLangs; |
|
357 QDateTime m_validity; |
|
358 }; |
|
359 |
|
360 #endif //_LASTFMMUSICSERVICEPLUGIN_H |