1 #ifndef _FLICKRCONTACTFETCHERPLUGIN_H |
|
2 #define _FLICKRCONTACTFETCHERPLUGIN_H |
|
3 |
|
4 // Include files |
|
5 #include <smfcontactfetcherplugin.h> |
|
6 #include <smfpluginutil.h> |
|
7 |
|
8 // Forward declarations |
|
9 class FlickrProviderBase; |
|
10 class QVariant; |
|
11 class QNetworkReply; |
|
12 |
|
13 // Class declaration |
|
14 class FlickrContactFetcherPlugin : public QObject, public SmfContactFetcherPlugin |
|
15 { |
|
16 Q_OBJECT |
|
17 Q_INTERFACES( SmfContactFetcherPlugin SmfPluginBase ) |
|
18 |
|
19 public: |
|
20 virtual ~FlickrContactFetcherPlugin( ); |
|
21 |
|
22 public: // From SmfContactFetcherPlugin |
|
23 |
|
24 /** |
|
25 * Method to get the list of friends |
|
26 * @param aRequest [out] The request data to be sent to network |
|
27 * @param aPageNum The page to be extracted |
|
28 * @param aItemsPerPage Number of items per page |
|
29 * @return SmfPluginError Plugin error if any, else SmfPluginErrNone |
|
30 */ |
|
31 SmfPluginError friends( SmfPluginRequestData &aRequest, |
|
32 const int aPageNum = SMF_FIRST_PAGE, |
|
33 const int aItemsPerPage = SMF_ITEMS_PER_PAGE ); |
|
34 |
|
35 /** |
|
36 * Method to get the list of followers |
|
37 * @param aRequest [out] The request data to be sent to network |
|
38 * @param aPageNum The page to be extracted |
|
39 * @param aItemsPerPage Number of items per page |
|
40 * @return SmfPluginError Plugin error if any, else SmfPluginErrNone |
|
41 */ |
|
42 SmfPluginError followers( SmfPluginRequestData &aRequest, |
|
43 const int aPageNum = SMF_FIRST_PAGE, |
|
44 const int aItemsPerPage = SMF_ITEMS_PER_PAGE ); |
|
45 |
|
46 /** |
|
47 * Method to search for a contact |
|
48 * @param aRequest [out] The request data to be sent to network |
|
49 * @param aContact contact to be searched |
|
50 * @param aPageNum The page to be extracted |
|
51 * @param aItemsPerPage Number of items per page |
|
52 * @return SmfPluginError Plugin error if any, else SmfPluginErrNone |
|
53 */ |
|
54 SmfPluginError search( SmfPluginRequestData &aRequest, |
|
55 const SmfContact &aContact, |
|
56 const int aPageNum = SMF_FIRST_PAGE, |
|
57 const int aItemsPerPage = SMF_ITEMS_PER_PAGE ); |
|
58 |
|
59 /** |
|
60 * Method to search for contacts (friends) who are near the user. |
|
61 * Proximity defines accuracy level |
|
62 * @param aRequest [out] The request data to be sent to network |
|
63 * @param aLocation The location search criteria |
|
64 * @param aProximity location search boundary |
|
65 * @param aPageNum The page to be extracted |
|
66 * @param aItemsPerPage Number of items per page |
|
67 * @return SmfPluginError Plugin error if any, else SmfPluginErrNone |
|
68 */ |
|
69 SmfPluginError searchNear( SmfPluginRequestData &aRequest, |
|
70 const SmfLocation &aLocation, |
|
71 const SmfLocationSearchBoundary &aProximity, |
|
72 const int aPageNum = SMF_FIRST_PAGE, |
|
73 const int aItemsPerPage = SMF_ITEMS_PER_PAGE ); |
|
74 |
|
75 /** |
|
76 * Method to get the list of groups |
|
77 * @param aRequest [out] The request data to be sent to network |
|
78 * @param aPageNum The page to be extracted |
|
79 * @param aItemsPerPage Number of items per page |
|
80 * @return SmfPluginError Plugin error if any, else SmfPluginErrNone |
|
81 */ |
|
82 SmfPluginError groups( SmfPluginRequestData &aRequest, |
|
83 const int aPageNum = SMF_FIRST_PAGE, |
|
84 const int aItemsPerPage = SMF_ITEMS_PER_PAGE ); |
|
85 |
|
86 /** |
|
87 * Method to search for a contact in a group |
|
88 * @param aRequest [out] The request data to be sent to network |
|
89 * @param aGroup the group in which to search |
|
90 * @param aPageNum The page to be extracted |
|
91 * @param aItemsPerPage Number of items per page |
|
92 * @return SmfPluginError Plugin error if any, else SmfPluginErrNone |
|
93 */ |
|
94 SmfPluginError searchInGroup( SmfPluginRequestData &aRequest, |
|
95 const SmfGroup &aGroup, |
|
96 const int aPageNum = SMF_FIRST_PAGE, |
|
97 const int aItemsPerPage = SMF_ITEMS_PER_PAGE ); |
|
98 |
|
99 /** |
|
100 * Customised method for SmfContactFetcherPlugin interface |
|
101 * @param aRequest [out] The request data to be sent to network |
|
102 * @param aOperation The operation type (should be known between |
|
103 * the client interface and the plugin) |
|
104 * @param aData The data required to form the request (The type |
|
105 * of data should be known between client and the plugin) |
|
106 * @return SmfPluginError Plugin error if any, else SmfPluginErrNone |
|
107 */ |
|
108 SmfPluginError customRequest( SmfPluginRequestData &aRequest, |
|
109 const int &aOperation, QByteArray *aData ); |
|
110 |
|
111 public: // From SmfPluginBase |
|
112 /** |
|
113 * The first method to be called in the plugin that implements this interface. |
|
114 * If this method is not called, plugin may not behave as expected. |
|
115 * Plugins are expected to save the aUtil handle and use and when required. |
|
116 * @param aUtil The instance of SmfPluginUtil |
|
117 */ |
|
118 void initialize( SmfPluginUtil *aUtil ); |
|
119 |
|
120 /** |
|
121 * Method to get the provider information |
|
122 * @return Instance of SmfProviderBase |
|
123 */ |
|
124 SmfProviderBase* getProviderInfo( ); |
|
125 |
|
126 /** |
|
127 * Method to get the result for a network request. |
|
128 * @param aTransportResult The result of transport operation |
|
129 * @param aResponse The QByteArray instance containing the network response. |
|
130 * The plugins should delete this instance once they have read the |
|
131 * data from it. |
|
132 * @param aResult [out] An output parameter to the plugin manager.If the |
|
133 * return value is SmfSendRequestAgain, QVariant will be of type |
|
134 * SmfPluginRequestData. |
|
135 * For SmfGalleryPlugin: If last operation was pictures(), aResult will |
|
136 * be of type QList<SmfPicture>. If last operation was description(), |
|
137 * aResult will be of type QString. If last operation was upload() or |
|
138 * postComment(), aResult will be of type bool. |
|
139 * @param aRetType [out] SmfPluginRetType |
|
140 * @param aPageResult [out] The SmfResultPage structure variable |
|
141 */ |
|
142 SmfPluginError responseAvailable( |
|
143 const SmfTransportResult &aTransportResult, |
|
144 QByteArray *aResponse, |
|
145 QVariant* aResult, |
|
146 SmfPluginRetType &aRetType, |
|
147 SmfResultPage &aPageResult ); |
|
148 |
|
149 private: |
|
150 /** |
|
151 * Method called by plugins to generate a signature string from a base string |
|
152 * @param aBaseString The base string |
|
153 * @return The md5 hash of the base string |
|
154 */ |
|
155 QString generateSignature(const QString aBaseString); |
|
156 |
|
157 /** |
|
158 * Method called by plugins for logging |
|
159 * @param log string to be logged |
|
160 */ |
|
161 void writeLog(QString log) const; |
|
162 |
|
163 private: |
|
164 /** |
|
165 * Method called by plugins to generate a request data |
|
166 * @param aRequest [out] The request data to be sent to network |
|
167 * @param aOperation The type of http operation |
|
168 * @param aSignatureMethod The signature method to be used |
|
169 * @param aParams A map of parameters to its values |
|
170 * @param aMode The mode of creation of the request |
|
171 * @param aPostData The data to be posted (for HTTP POST |
|
172 * only, else it will be NULL) |
|
173 * @return SmfPluginError Plugin error if any, else SmfPluginErrNone |
|
174 */ |
|
175 SmfPluginError createRequest( SmfPluginRequestData &aRequest, |
|
176 const QNetworkAccessManager::Operation aOperation, |
|
177 const SmfSignatureMethod aSignatureMethod, |
|
178 QMultiMap<QByteArray, QByteArray> &aParams, |
|
179 const SmfParsingMode aMode, |
|
180 QBuffer *aPostData ); |
|
181 |
|
182 private: |
|
183 FlickrProviderBase *m_provider; |
|
184 SmfPluginUtil *m_util; |
|
185 |
|
186 }; |
|
187 |
|
188 |
|
189 // Class declaration |
|
190 class FlickrProviderBase : public QObject, public SmfProviderBase |
|
191 { |
|
192 Q_OBJECT |
|
193 Q_INTERFACES( SmfProviderBase ) |
|
194 |
|
195 public: |
|
196 virtual ~FlickrProviderBase( ); |
|
197 |
|
198 /** |
|
199 * Method to get the Localisable name of the service. |
|
200 * @return The Localisable name of the service. |
|
201 */ |
|
202 QString serviceName( ) const; |
|
203 |
|
204 /** |
|
205 * Method to get the Logo of the service |
|
206 * @return The Logo of the service |
|
207 */ |
|
208 QImage serviceIcon( ) const; |
|
209 |
|
210 /** |
|
211 * Method to get the Readable service description |
|
212 * @return The Readable service description |
|
213 */ |
|
214 QString description( ) const; |
|
215 |
|
216 /** |
|
217 * Method to get the Website of the service |
|
218 * @return The Website of the service |
|
219 */ |
|
220 QUrl serviceUrl( ) const; |
|
221 |
|
222 /** |
|
223 * Method to get the URL of the Application providing this service |
|
224 * @return The URL of the Application providing this service |
|
225 */ |
|
226 QUrl applicationUrl( ) const; |
|
227 |
|
228 /** |
|
229 * Method to get the Icon of the application |
|
230 * @return The Icon of the application |
|
231 */ |
|
232 QImage applicationIcon( ) const; |
|
233 |
|
234 /** |
|
235 * Method to get the Plugin specific ID |
|
236 * @return The Plugin specific ID |
|
237 */ |
|
238 QString pluginId( ) const; |
|
239 |
|
240 /** |
|
241 * Method to get the ID of the authentication application |
|
242 * for this service |
|
243 * @param aProgram The authentication application name |
|
244 * @param aArguments List of arguments required for authentication app |
|
245 * @param aMode Strting mode for authentication application |
|
246 * @return The ID of the authentication application |
|
247 */ |
|
248 QString authenticationApp( QString &aProgram, QStringList & aArguments, |
|
249 QIODevice::OpenModeFlag aMode = QIODevice::ReadWrite ) const; |
|
250 |
|
251 /** |
|
252 * Method to get the unique registration ID provided by the |
|
253 * Smf for authorised plugins |
|
254 * @return The unique registration ID/token provided by the Smf for |
|
255 * authorised plugins |
|
256 */ |
|
257 QString smfRegistrationId( ) const; |
|
258 |
|
259 private: |
|
260 friend class FlickrContactFetcherPlugin; |
|
261 void initialize(); |
|
262 QString m_serviceName; |
|
263 QImage m_serviceIcon; |
|
264 QString m_description; |
|
265 QUrl m_serviceUrl; |
|
266 QUrl m_applicationUrl; |
|
267 QImage m_applicationIcon; |
|
268 QString m_pluginId; |
|
269 QString m_authAppId; |
|
270 QString m_smfRegToken; |
|
271 }; |
|
272 |
|
273 #endif /*_FLICKRCONTACTFETCHERPLUGIN_H*/ |
|