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