|
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 fetches contacts from the logged in user's facebook account |
|
17 * |
|
18 */ |
|
19 |
|
20 #ifndef _FBCONTACTFETCHERPLUGIN_H |
|
21 #define _FBCONTACTFETCHERPLUGIN_H |
|
22 |
|
23 // Include files |
|
24 #include <smfcontactfetcherplugin.h> |
|
25 #include <smfpluginutil.h> |
|
26 |
|
27 // Forward declarations |
|
28 class FBContactProviderBase; |
|
29 class QVariant; |
|
30 class QNetworkReply; |
|
31 |
|
32 /** |
|
33 * The Plugin class that fetches contacts from the logged in user's |
|
34 * facebook account |
|
35 */ |
|
36 class FBContactFetcherPlugin : public QObject, public SmfContactFetcherPlugin |
|
37 { |
|
38 Q_OBJECT |
|
39 Q_INTERFACES( SmfContactFetcherPlugin SmfPluginBase ) |
|
40 |
|
41 public: |
|
42 /** |
|
43 * Destructor |
|
44 */ |
|
45 virtual ~FBContactFetcherPlugin( ); |
|
46 |
|
47 public: // From SmfContactFetcherPlugin interface |
|
48 |
|
49 /** |
|
50 * Method to get the list of friends |
|
51 * @param aRequest [out] The request data to be sent to network |
|
52 * @param aPageNum The page to be extracted |
|
53 * @param aItemsPerPage Number of items per page |
|
54 * @return SmfPluginError Plugin error if any, else SmfPluginErrNone |
|
55 */ |
|
56 SmfPluginError friends( SmfPluginRequestData &aRequest, |
|
57 const int aPageNum = SMF_FIRST_PAGE, |
|
58 const int aItemsPerPage = SMF_ITEMS_PER_PAGE ); |
|
59 |
|
60 /** |
|
61 * Method to get the list of followers |
|
62 * @param aRequest [out] The request data to be sent to network |
|
63 * @param aPageNum The page to be extracted |
|
64 * @param aItemsPerPage Number of items per page |
|
65 * @return SmfPluginError Plugin error if any, else SmfPluginErrNone |
|
66 */ |
|
67 SmfPluginError followers( SmfPluginRequestData &aRequest, |
|
68 const int aPageNum = SMF_FIRST_PAGE, |
|
69 const int aItemsPerPage = SMF_ITEMS_PER_PAGE ); |
|
70 |
|
71 /** |
|
72 * Method to search for a contact |
|
73 * @param aRequest [out] The request data to be sent to network |
|
74 * @param aContact contact to be searched |
|
75 * @param aPageNum The page to be extracted |
|
76 * @param aItemsPerPage Number of items per page |
|
77 * @return SmfPluginError Plugin error if any, else SmfPluginErrNone |
|
78 */ |
|
79 SmfPluginError search( SmfPluginRequestData &aRequest, |
|
80 const SmfContact &aContact, |
|
81 const int aPageNum = SMF_FIRST_PAGE, |
|
82 const int aItemsPerPage = SMF_ITEMS_PER_PAGE ); |
|
83 |
|
84 /** |
|
85 * Method to search for contacts (friends) who are near the user. |
|
86 * Proximity defines accuracy level |
|
87 * @param aRequest [out] The request data to be sent to network |
|
88 * @param aLocation The location search criteria |
|
89 * @param aProximity location search boundary |
|
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 searchNear( SmfPluginRequestData &aRequest, |
|
95 const SmfLocation &aLocation, |
|
96 const SmfLocationSearchBoundary &aProximity, |
|
97 const int aPageNum = SMF_FIRST_PAGE, |
|
98 const int aItemsPerPage = SMF_ITEMS_PER_PAGE ); |
|
99 |
|
100 /** |
|
101 * Method to get the list of groups |
|
102 * @param aRequest [out] The request data to be sent to network |
|
103 * @param aPageNum The page to be extracted |
|
104 * @param aItemsPerPage Number of items per page |
|
105 * @return SmfPluginError Plugin error if any, else SmfPluginErrNone |
|
106 */ |
|
107 SmfPluginError groups( SmfPluginRequestData &aRequest, |
|
108 const int aPageNum = SMF_FIRST_PAGE, |
|
109 const int aItemsPerPage = SMF_ITEMS_PER_PAGE ); |
|
110 |
|
111 /** |
|
112 * Method to search for a contact in a group |
|
113 * @param aRequest [out] The request data to be sent to network |
|
114 * @param aGroup the group in which to search |
|
115 * @param aPageNum The page to be extracted |
|
116 * @param aItemsPerPage Number of items per page |
|
117 * @return SmfPluginError Plugin error if any, else SmfPluginErrNone |
|
118 */ |
|
119 SmfPluginError searchInGroup( SmfPluginRequestData &aRequest, |
|
120 const SmfGroup &aGroup, |
|
121 const int aPageNum = SMF_FIRST_PAGE, |
|
122 const int aItemsPerPage = SMF_ITEMS_PER_PAGE ); |
|
123 |
|
124 /** |
|
125 * Customised method for SmfContactFetcherPlugin interface |
|
126 * @param aRequest [out] The request data to be sent to network |
|
127 * @param aOperation The operation type (should be known between |
|
128 * the client interface and the plugin) |
|
129 * @param aData The data required to form the request (The type |
|
130 * of data should be known between client and the plugin) |
|
131 * @return SmfPluginError Plugin error if any, else SmfPluginErrNone |
|
132 */ |
|
133 SmfPluginError customRequest( SmfPluginRequestData &aRequest, |
|
134 const int &aOperation, QByteArray *aData ); |
|
135 |
|
136 public: // From SmfPluginBase interface |
|
137 /** |
|
138 * The first method to be called in the plugin that implements this interface. |
|
139 * If this method is not called, plugin may not behave as expected. |
|
140 * Plugins are expected to save the aUtil handle and use and when required. |
|
141 * @param aUtil The instance of SmfPluginUtil |
|
142 */ |
|
143 void initialize( SmfPluginUtil *aUtil ); |
|
144 |
|
145 /** |
|
146 * Method to get the provider information |
|
147 * @return Instance of SmfProviderBase |
|
148 */ |
|
149 SmfProviderBase* getProviderInfo( ); |
|
150 |
|
151 /** |
|
152 * Method to get the result for a network request. |
|
153 * @param aOperation The type of operation to be requested |
|
154 * @param aTransportResult The result of transport operation |
|
155 * @param aResponse The QByteArray instance containing the network response. |
|
156 * The plugins should delete this instance once they have read the |
|
157 * data from it. |
|
158 * @param aResult [out] An output parameter to the plugin manager.If the |
|
159 * return value is SmfSendRequestAgain, QVariant will be of type |
|
160 * SmfPluginRequestData. |
|
161 * For SmfGalleryPlugin: If last operation was pictures(), aResult will |
|
162 * be of type QList<SmfPicture>. If last operation was description(), |
|
163 * aResult will be of type QString. If last operation was upload() or |
|
164 * postComment(), aResult will be of type bool. |
|
165 * @param aRetType [out] SmfPluginRetType |
|
166 * @param aPageResult [out] The SmfResultPage structure variable |
|
167 */ |
|
168 SmfPluginError responseAvailable( |
|
169 const SmfRequestTypeID aOperation, |
|
170 const SmfTransportResult &aTransportResult, |
|
171 QByteArray *aResponse, |
|
172 QVariant* aResult, |
|
173 SmfPluginRetType &aRetType, |
|
174 SmfResultPage &aPageResult ); |
|
175 |
|
176 private: |
|
177 /** |
|
178 * Method called by plugins to generate a signature string from a base string |
|
179 * @param aBaseString The base string |
|
180 * @return The md5 hash of the base string |
|
181 */ |
|
182 QString generateSignature(const QString aBaseString); |
|
183 |
|
184 /** |
|
185 * Method to get Facebook specific UIDs of the user's friends |
|
186 * @param aRequest [out] The request data to be sent to network |
|
187 * @param aPageNum The page to be extracted |
|
188 * @param aItemsPerPage Number of items per page |
|
189 * @return SmfPluginError Plugin error if any, else SmfPluginErrNone |
|
190 */ |
|
191 SmfPluginError getFriendsUids( SmfPluginRequestData &aRequest, |
|
192 const int aPageNum, |
|
193 const int aItemsPerPage ); |
|
194 |
|
195 /** |
|
196 * Method to get the details of users friends from facebook |
|
197 * @param aRequest [out] The request data to be sent to network |
|
198 * @param aPageNum The page to be extracted |
|
199 * @param aItemsPerPage Number of items per page |
|
200 * @return SmfPluginError Plugin error if any, else SmfPluginErrNone |
|
201 */ |
|
202 SmfPluginError getFriendsDetails( SmfPluginRequestData &aRequest, |
|
203 const int aPageNum, |
|
204 const int aItemsPerPage ); |
|
205 |
|
206 private: |
|
207 FBContactProviderBase *m_provider; |
|
208 SmfPluginUtil *m_util; |
|
209 }; |
|
210 |
|
211 |
|
212 |
|
213 /** |
|
214 * The Plugin class that implements SmfProviderBase for this facebook plugin |
|
215 */ |
|
216 class FBContactProviderBase : public QObject, public SmfProviderBase |
|
217 { |
|
218 Q_OBJECT |
|
219 Q_INTERFACES( SmfProviderBase ) |
|
220 |
|
221 public: |
|
222 /** |
|
223 * Destructor |
|
224 */ |
|
225 virtual ~FBContactProviderBase( ); |
|
226 |
|
227 /** |
|
228 * Method to get the Localisable name of the service. |
|
229 * @return The Localisable name of the service. |
|
230 */ |
|
231 QString serviceName( ) const; |
|
232 |
|
233 /** |
|
234 * Method to get the Logo of the service |
|
235 * @return The Logo of the service |
|
236 */ |
|
237 QImage serviceIcon( ) const; |
|
238 |
|
239 /** |
|
240 * Method to get the Readable service description |
|
241 * @return The Readable service description |
|
242 */ |
|
243 QString description( ) const; |
|
244 |
|
245 /** |
|
246 * Method to get the Website of the service |
|
247 * @return The Website of the service |
|
248 */ |
|
249 QUrl serviceUrl( ) const; |
|
250 |
|
251 /** |
|
252 * Method to get the URL of the Application providing this service |
|
253 * @return The URL of the Application providing this service |
|
254 */ |
|
255 QUrl applicationUrl( ) const; |
|
256 |
|
257 /** |
|
258 * Method to get the Icon of the application |
|
259 * @return The Icon of the application |
|
260 */ |
|
261 QImage applicationIcon( ) const; |
|
262 |
|
263 /** |
|
264 * Method to get the list of interfaces that this provider support |
|
265 * @return List of supported Interafces |
|
266 */ |
|
267 QList<QString> supportedInterfaces( ) const; |
|
268 |
|
269 /** |
|
270 * Method to get the list of languages supported by this service provider |
|
271 * @return a QStringList of languages supported by this service |
|
272 * provider in 2 letter ISO 639-1 format. |
|
273 */ |
|
274 QStringList supportedLanguages( ) const; |
|
275 |
|
276 /** |
|
277 * Method to get the Plugin specific ID |
|
278 * @return The Plugin specific ID |
|
279 */ |
|
280 QString pluginId( ) const; |
|
281 |
|
282 /** |
|
283 * Method to get the ID of the authentication application |
|
284 * for this service |
|
285 * @param aProgram The authentication application name |
|
286 * @param aArguments List of arguments required for authentication app |
|
287 * @param aMode Strting mode for authentication application |
|
288 * @return The ID of the authentication application |
|
289 */ |
|
290 QString authenticationApp( QString &aProgram, QStringList & aArguments, |
|
291 QIODevice::OpenModeFlag aMode = QIODevice::ReadWrite ) const; |
|
292 |
|
293 /** |
|
294 * Method to get the unique registration ID provided by the |
|
295 * Smf for authorised plugins |
|
296 * @return The unique registration ID/token provided by the Smf for |
|
297 * authorised plugins |
|
298 */ |
|
299 QString smfRegistrationId( ) const; |
|
300 |
|
301 private: |
|
302 /** |
|
303 * Method that initializes this class. This method should be called |
|
304 * from the initialize() method of the FBContactFetcherPlugin class |
|
305 */ |
|
306 void initialize(); |
|
307 |
|
308 private: |
|
309 friend class FBContactFetcherPlugin; |
|
310 QString m_serviceName; |
|
311 QImage m_serviceIcon; |
|
312 QString m_description; |
|
313 QUrl m_serviceUrl; |
|
314 QUrl m_applicationUrl; |
|
315 QImage m_applicationIcon; |
|
316 QString m_pluginId; |
|
317 QString m_authAppId; |
|
318 QString m_smfRegToken; |
|
319 QList<QString> m_supportedInterfaces; |
|
320 QStringList m_supportedLangs; |
|
321 }; |
|
322 |
|
323 #endif /*_FBCONTACTFETCHERPLUGIN_H*/ |