|
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 * Sangeetha Prasad, Nalina Hariharan |
|
14 * |
|
15 * Description: |
|
16 * The Plugin that fetches gallery related items from the logged in user's flickr account |
|
17 * |
|
18 */ |
|
19 |
|
20 #ifndef FLICKRGALLERYPLUGIN_H_ |
|
21 #define FLICKRGALLERYPLUGIN_H_ |
|
22 |
|
23 // Include files |
|
24 #include <QDateTime> |
|
25 #include <smfgalleryplugin.h> |
|
26 #include <smfcontact.h> |
|
27 |
|
28 // Forward declarations |
|
29 class FlickrProviderBase; |
|
30 class QVariant; |
|
31 |
|
32 |
|
33 /** |
|
34 * The Plugin that fetches gallery related items from the logged |
|
35 * in user's flickr account |
|
36 */ |
|
37 class FlickrGalleryPlugin : public QObject, public SmfGalleryPlugin |
|
38 { |
|
39 Q_OBJECT |
|
40 Q_INTERFACES( SmfGalleryPlugin SmfPluginBase ) |
|
41 |
|
42 public: |
|
43 /** |
|
44 * Destructor |
|
45 */ |
|
46 virtual ~FlickrGalleryPlugin(); |
|
47 |
|
48 public: // From FlickrGalleryPlugin |
|
49 |
|
50 /** |
|
51 * Method to get a list of albums |
|
52 * @param aRequest [out] The request data to be sent to network |
|
53 * @param aNames The subject or any keywords to be used to filter albums with that name |
|
54 * @param aUser The user whose albums are requested |
|
55 * @param aPageNum The page to be extracted |
|
56 * @param aItemsPerPage Number of items per page |
|
57 * @return SmfPluginError Plugin error if any, else SmfPluginErrNone |
|
58 */ |
|
59 SmfPluginError albums( SmfPluginRequestData &aRequest, |
|
60 const QStringList &aNames, |
|
61 const SmfContact *aUser, |
|
62 const int aPageNum = SMF_FIRST_PAGE, |
|
63 const int aItemsPerPage = SMF_ITEMS_PER_PAGE ); |
|
64 |
|
65 /** |
|
66 * Method to get a list of pictures |
|
67 * @param aRequest [out] The request data to be sent to network |
|
68 * @param aAlbums The album(s) whose pictures are being requested |
|
69 * @param aPageNum The page to be extracted |
|
70 * @param aItemsPerPage Number of items per page |
|
71 * @return SmfPluginError Plugin error if any, else SmfPluginErrNone |
|
72 */ |
|
73 SmfPluginError pictures( SmfPluginRequestData &aRequest, |
|
74 const SmfPictureAlbumList &aAlbums, |
|
75 const int aPageNum = SMF_FIRST_PAGE, |
|
76 const int aItemsPerPage = SMF_ITEMS_PER_PAGE ); |
|
77 |
|
78 /** |
|
79 * Method to get a description |
|
80 * @param aRequest [out] The request data to be sent to network |
|
81 * @param aImage The image abot which the description is required |
|
82 * @return SmfPluginError Plugin error if any, else SmfPluginErrNone |
|
83 */ |
|
84 SmfPluginError description( SmfPluginRequestData &aRequest, |
|
85 const SmfPicture &aImage ); |
|
86 |
|
87 /** |
|
88 * Method to upload a picture |
|
89 * @param aRequest [out] The request data to be sent to network |
|
90 * @param aImage The image to be uploaded |
|
91 * @param aAlbum the optional destination album name |
|
92 * @return SmfPluginError Plugin error if any, else SmfPluginErrNone |
|
93 */ |
|
94 SmfPluginError upload( SmfPluginRequestData &aRequest, |
|
95 const SmfPicture &aImage, |
|
96 const SmfPictureAlbum* aAlbum = NULL ); |
|
97 |
|
98 |
|
99 /** |
|
100 * Method to upload a list of pictures |
|
101 * @param aRequest [out] The request data to be sent to network |
|
102 * @param aImages The list of images to be uploaded |
|
103 * @param aAlbum the optional destination album name |
|
104 * @return SmfPluginError Plugin error if any, else SmfPluginErrNone |
|
105 */ |
|
106 SmfPluginError upload( SmfPluginRequestData &aRequest, |
|
107 const QList<SmfPicture> &aImages, |
|
108 const SmfPictureAlbum* aAlbum = NULL ); |
|
109 |
|
110 /** |
|
111 * Method to post comment on a picture is available |
|
112 * @param aRequest [out] The request data to be sent to network |
|
113 * @param aImage The image on which comment is to be posted |
|
114 * @param aComment The comment to be posted |
|
115 * @return SmfPluginError Plugin error if any, else SmfPluginErrNone |
|
116 */ |
|
117 SmfPluginError postComment( SmfPluginRequestData &aRequest, |
|
118 const SmfPicture &aImage, |
|
119 const SmfComment &aComment ); |
|
120 |
|
121 |
|
122 /** |
|
123 * Customised method for SMFGalleryPlugin interface |
|
124 * @param aRequest [out] The request data to be sent to network |
|
125 * @param aOperation The operation type (should be known between |
|
126 * the client interface and the plugin) |
|
127 * @param aData The data required to form the request (The type |
|
128 * of data should be known between client and the plugin) |
|
129 * @return SmfPluginError Plugin error if any, else SmfPluginErrNone |
|
130 */ |
|
131 SmfPluginError customRequest( SmfPluginRequestData &aRequest, |
|
132 const int &aOperation, |
|
133 QByteArray *aData ); |
|
134 |
|
135 public: // From SmfPluginBase |
|
136 /** |
|
137 * The first method to be called in the plugin that implements this interface. |
|
138 * If this method is not called, plugin may not behave as expected. |
|
139 */ |
|
140 void initialize( ); |
|
141 |
|
142 /** |
|
143 * Method to get the provider information |
|
144 * @return Instance of SmfProviderBase |
|
145 */ |
|
146 SmfProviderBase* getProviderInfo( ); |
|
147 |
|
148 /** |
|
149 * Method to get the result for a network request. |
|
150 * @param aOperation The type of operation to be requested |
|
151 * @param aTransportResult The result of transport operation |
|
152 * @param aResponse The QByteArray instance containing the network response. |
|
153 * The plugins should delete this instance once they have read the |
|
154 * data from it. |
|
155 * @param aResult [out] An output parameter to the plugin manager.If the |
|
156 * return value is SmfSendRequestAgain, QVariant will be of type |
|
157 * SmfPluginRequestData. |
|
158 * For SmfGalleryPlugin: If last operation was albums, aResult will be of |
|
159 * type QList<SmfPictureAlbum>. If the last operation was pictures(), aResult |
|
160 * will be of type QList<SmfPicture>. If last operation was description(), |
|
161 * aResult will be of type QString. If last operation was upload() or |
|
162 * postComment(), aResult will be of type bool. |
|
163 * @param aRetType [out] SmfPluginRetType |
|
164 * @param aPageResult [out] The SmfResultPage structure variable |
|
165 */ |
|
166 SmfPluginError responseAvailable( |
|
167 const SmfRequestTypeID aOperation, |
|
168 const SmfTransportResult &aTransportResult, |
|
169 QByteArray *aResponse, |
|
170 QVariant* aResult, |
|
171 SmfPluginRetType &aRetType, |
|
172 SmfResultPage &aPageResult ); |
|
173 |
|
174 /** |
|
175 * Method to construct individual fields for photo upload |
|
176 * @param aName The name argument |
|
177 * @param aContent The content of this field |
|
178 * @param aBoundary The boundary string (need to be unique in the payload data) |
|
179 * @param aFilename The filename if for photo field |
|
180 * @return The field data constructed by this method |
|
181 */ |
|
182 QByteArray constructField( const QString &aName, |
|
183 const QString &aContent, |
|
184 const QByteArray &aBoundary, |
|
185 const QString &aFilename = QString() ); |
|
186 |
|
187 private: |
|
188 /** |
|
189 * Method called by plugins to generate a signature string from a base string |
|
190 * @param aBaseString The base string |
|
191 * @return The md5 hash of the base string |
|
192 */ |
|
193 QString generateSignature( const QString aBaseString ); |
|
194 |
|
195 /** |
|
196 * Method to interpret the key sets obtained from credential manager |
|
197 * @param aApiKey [out] The api key |
|
198 * @param aApiSecret [out] The api secret |
|
199 * @param aAuthToken [out] The auth token provided by Flickr |
|
200 */ |
|
201 void fetchKeys( QString &aApiKey, |
|
202 QString &aApiSecret, |
|
203 QString &aAuthToken ); |
|
204 |
|
205 private: |
|
206 FlickrProviderBase *m_provider; |
|
207 |
|
208 }; |
|
209 |
|
210 /** |
|
211 * The Plugin class that implements SmfProviderBase for this flickr plugin |
|
212 */ |
|
213 class FlickrProviderBase : public QObject, public SmfProviderBase |
|
214 { |
|
215 Q_OBJECT |
|
216 Q_INTERFACES( SmfProviderBase ) |
|
217 |
|
218 public: |
|
219 virtual ~FlickrProviderBase( ); |
|
220 |
|
221 /** |
|
222 * Method to get the Localisable name of the service. |
|
223 * @return The Localisable name of the service. |
|
224 */ |
|
225 QString serviceName( ) const; |
|
226 |
|
227 /** |
|
228 * Method to get the Logo of the service |
|
229 * @return The Logo of the service |
|
230 */ |
|
231 QImage serviceIcon( ) const; |
|
232 |
|
233 /** |
|
234 * Method to get the Readable service description |
|
235 * @return The Readable service description |
|
236 */ |
|
237 QString description( ) const; |
|
238 |
|
239 /** |
|
240 * Method to get the Website of the service |
|
241 * @return The Website of the service |
|
242 */ |
|
243 QUrl serviceUrl( ) const; |
|
244 |
|
245 /** |
|
246 * Method to get the URL of the Application providing this service |
|
247 * @return The URL of the Application providing this service |
|
248 */ |
|
249 QUrl applicationUrl( ) const; |
|
250 |
|
251 /** |
|
252 * Method to get the Icon of the application |
|
253 * @return The Icon of the application |
|
254 */ |
|
255 QImage applicationIcon( ) const; |
|
256 |
|
257 /** |
|
258 * Method to get the list of interfaces that this provider support |
|
259 * @return List of supported Interafces |
|
260 */ |
|
261 QList<QString> supportedInterfaces( ) const; |
|
262 |
|
263 /** |
|
264 * Method to get the list of languages supported by this service provider |
|
265 * @return a QStringList of languages supported by this service |
|
266 * provider in 2 letter ISO 639-1 format. |
|
267 */ |
|
268 QStringList supportedLanguages( ) const; |
|
269 |
|
270 /** |
|
271 * Method to get the Plugin specific ID |
|
272 * @return The Plugin specific ID |
|
273 */ |
|
274 QString pluginId( ) const; |
|
275 |
|
276 /** |
|
277 * Method to get the ID of the authentication application |
|
278 * for this service |
|
279 * @param aProgram The authentication application name |
|
280 * @param aArguments List of arguments required for authentication app |
|
281 * @param aMode Strting mode for authentication application |
|
282 * @return The ID of the authentication application |
|
283 */ |
|
284 QString authenticationApp( QString &aProgram, QStringList & aArguments, |
|
285 QIODevice::OpenModeFlag aMode = QIODevice::ReadWrite ) const; |
|
286 |
|
287 /** |
|
288 * Method to get the unique registration ID provided by the |
|
289 * Smf for authorised plugins |
|
290 * @return The unique registration ID/token provided by the Smf for |
|
291 * authorised plugins |
|
292 */ |
|
293 QString smfRegistrationId( ) const; |
|
294 |
|
295 private: |
|
296 friend class FlickrGalleryPlugin; |
|
297 void initialize(); |
|
298 QString m_serviceName; |
|
299 QImage m_serviceIcon; |
|
300 QString m_description; |
|
301 QUrl m_serviceUrl; |
|
302 QUrl m_applicationUrl; |
|
303 QImage m_applicationIcon; |
|
304 QString m_pluginId; |
|
305 QString m_authAppId; |
|
306 QString m_smfRegToken; |
|
307 QList<QString> m_supportedInterfaces; |
|
308 QStringList m_supportedLangs; |
|
309 QDateTime m_validity; |
|
310 }; |
|
311 |
|
312 |
|
313 #endif /* FLICKRGALLERYPLUGIN_H_ */ |