1 #ifndef _FBPOSTPROVIDERPLUGIN_H |
|
2 #define _FBPOSTPROVIDERPLUGIN_H |
|
3 |
|
4 // Include files |
|
5 #include <smfpostproviderplugin.h> |
|
6 #include <smfpluginutil.h> |
|
7 |
|
8 // Forward declarations |
|
9 class FBProviderBase; |
|
10 class QVariant; |
|
11 class QNetworkReply; |
|
12 |
|
13 // Class declaration |
|
14 class FBPostProviderPlugin : public QObject, public SmfPostProviderPlugin |
|
15 { |
|
16 Q_OBJECT |
|
17 Q_INTERFACES( SmfPostProviderPlugin SmfPluginBase ) |
|
18 |
|
19 public: |
|
20 virtual ~FBPostProviderPlugin( ); |
|
21 |
|
22 public: // From SmfPostProviderPlugin |
|
23 |
|
24 /** |
|
25 * Method that returns maximum no of chars (unicode) that service |
|
26 * provider can post without truncation. Negative value means |
|
27 * no limit |
|
28 * @return Max characters that can be posted without truncation |
|
29 */ |
|
30 qint32 maxCharsInPost( ) const; |
|
31 |
|
32 /** |
|
33 * Method that returns maximum no of items that can be returned |
|
34 * in a single query to getPosts. Negative value means feature |
|
35 * not supported. |
|
36 * @return Max items that can be returned in a single query |
|
37 */ |
|
38 qint32 maxItems( ) const; |
|
39 |
|
40 /** |
|
41 * <Method that returns all the formatting of posts that this |
|
42 * service provider supports. May return 0 items to mean |
|
43 * only QString is supported. |
|
44 * @return Supported formats of posts |
|
45 */ |
|
46 QVector<QTextFormat> supportedFormats ( ) const; |
|
47 |
|
48 /** |
|
49 * Method that returns whether this SP supports Appearence |
|
50 * @return Returns true if Appearance is supported, else false. |
|
51 * @see SmfAppearenceInfo |
|
52 */ |
|
53 bool supportsAppearence ( ) const; |
|
54 |
|
55 /** |
|
56 * Method to get the latest posts |
|
57 * @param aRequest [out] The request data to be sent to network |
|
58 * @param aUser The user's contact in this SP, omit for self contact |
|
59 * @param aPageNum The page to be extracted |
|
60 * @param aItemsPerPage Number of items per page |
|
61 * @return SmfPluginError Plugin error if any, else SmfPluginErrNone |
|
62 */ |
|
63 SmfPluginError retrieve( SmfPluginRequestData &aRequest, |
|
64 const SmfContact *aUser=0, |
|
65 const int aPageNum = SMF_FIRST_PAGE, |
|
66 const int aItemsPerPage = SMF_ITEMS_PER_PAGE ); |
|
67 |
|
68 |
|
69 /** |
|
70 * Method to update a post to own area. |
|
71 * @param aRequest [out] The request data to be sent to network |
|
72 * @param aPostData The post data to be posted |
|
73 * @param aLocation The location |
|
74 * @return SmfPluginError Plugin error if any, else SmfPluginErrNone |
|
75 */ |
|
76 SmfPluginError post( SmfPluginRequestData &aRequest, |
|
77 const SmfPost &aPostData, |
|
78 const SmfLocation &aLocation ); |
|
79 |
|
80 /** |
|
81 * Method to update the last post to own area with new data |
|
82 * @param aRequest [out] The request data to be sent to network |
|
83 * @param aPostData The edited/new data to be posted |
|
84 * @return SmfPluginError Plugin error if any, else SmfPluginErrNone |
|
85 */ |
|
86 SmfPluginError updatePost( SmfPluginRequestData &aRequest, |
|
87 const SmfPost &aPostData ); |
|
88 |
|
89 /** |
|
90 * Method to update a post to a particular contact |
|
91 * @param aRequest [out] The request data to be sent to network |
|
92 * @param aPostData The post data to be posted |
|
93 * @param aContact The contact where the data has to be posted |
|
94 * @param aLocation The location |
|
95 * @return SmfPluginError Plugin error if any, else SmfPluginErrNone |
|
96 */ |
|
97 SmfPluginError postDirected( SmfPluginRequestData &aRequest, |
|
98 const SmfPost &aPostData, |
|
99 const SmfContact &aContact, |
|
100 const SmfLocation *aLocation = NULL ); |
|
101 |
|
102 |
|
103 /** |
|
104 * Method to post a comment on a post. |
|
105 * @param aRequest [out] The request data to be sent to network |
|
106 * @param aTarget Post on which comment has to be posted |
|
107 * @param aComment comment to be posted |
|
108 * @param aLocation location data |
|
109 */ |
|
110 SmfPluginError commentOnAPost(SmfPluginRequestData &aRequest, |
|
111 const SmfPost &aTarget, |
|
112 const SmfPost &aComment, |
|
113 const SmfLocation *aLocation = NULL); |
|
114 |
|
115 /** |
|
116 * Method to update the presence information of the user |
|
117 * @param aRequest [out] The request data to be sent to network |
|
118 * @param aAppearence The appearence information |
|
119 * @param aStatus The status string |
|
120 * @return SmfPluginError Plugin error if any, else SmfPluginErrNone |
|
121 */ |
|
122 SmfPluginError postAppearence( SmfPluginRequestData &aRequest, |
|
123 const SmfPresenceInfo &aAppearence, |
|
124 const QString &aStatus ); |
|
125 |
|
126 /** |
|
127 * Share /a contact's post to user's friends and followers |
|
128 * (e.g. retweet in twitter, share on facebook) |
|
129 * @param aRequest [out] The request data to be sent to network |
|
130 * @param aPostData data to be posted |
|
131 * @param aContact contact to which the post belonged |
|
132 * @param aEdited whether user changed items within the post |
|
133 * @return SmfPluginError Plugin error if any, else SmfPluginErrNone |
|
134 */ |
|
135 SmfPluginError sharePost( SmfPluginRequestData &aRequest, |
|
136 const SmfPost &aPostData, |
|
137 const SmfContact &aContact, |
|
138 const bool &aEdited); |
|
139 |
|
140 /** |
|
141 * Customised method for SmfPostProviderPlugin interface |
|
142 * @param aRequest [out] The request data to be sent to network |
|
143 * @param aOperation The operation type (should be known between |
|
144 * the client interface and the plugin) |
|
145 * @param aData The data required to form the request (The type |
|
146 * of data should be known between client and the plugin) |
|
147 * @return SmfPluginError Plugin error if any, else SmfPluginErrNone |
|
148 */ |
|
149 SmfPluginError customRequest( SmfPluginRequestData &aRequest, |
|
150 const int &aOperation, QByteArray *aData ); |
|
151 |
|
152 public: // From SmfPluginBase |
|
153 /** |
|
154 * The first method to be called in the plugin that implements this interface. |
|
155 * If this method is not called, plugin may not behave as expected. |
|
156 * Plugins are expected to save the aUtil handle and use and when required. |
|
157 * @param aUtil The instance of SmfPluginUtil |
|
158 */ |
|
159 void initialize( SmfPluginUtil *aUtil ); |
|
160 |
|
161 /** |
|
162 * Method to get the provider information |
|
163 * @return Instance of SmfProviderBase |
|
164 */ |
|
165 SmfProviderBase* getProviderInfo( ); |
|
166 |
|
167 /** |
|
168 * Method to get the result for a network request. |
|
169 * @param aTransportResult The result of transport operation |
|
170 * @param aResponse The QByteArray instance containing the network response. |
|
171 * The plugins should delete this instance once they have read the |
|
172 * data from it. |
|
173 * @param aResult [out] An output parameter to the plugin manager.If the |
|
174 * return value is SmfSendRequestAgain, QVariant will be of type |
|
175 * SmfPluginRequestData. |
|
176 * For SmfPostProviderPlugin: If last operation was retrieve(), aResult will be |
|
177 * of type QList<SmfPost>. If last operation was post() or updatePost() or |
|
178 * postDirected() or commentOnAPost() or postAppearence() or sharePost(), |
|
179 * aResult will be of type bool |
|
180 * @param aRetType [out] SmfPluginRetType |
|
181 * @param aPageResult [out] The SmfResultPage structure variable |
|
182 */ |
|
183 SmfPluginError responseAvailable( |
|
184 const SmfTransportResult &aTransportResult, |
|
185 QByteArray *aResponse, |
|
186 QVariant* aResult, |
|
187 SmfPluginRetType &aRetType, |
|
188 SmfResultPage &aPageResult ); |
|
189 |
|
190 private: |
|
191 /** |
|
192 * Method called by plugins to generate a signature string from a base string |
|
193 * @param aBaseString The base string |
|
194 * @return The md5 hash of the base string |
|
195 */ |
|
196 QString generateSignature(const QString aBaseString); |
|
197 |
|
198 /** |
|
199 * Method called by plugins for logging |
|
200 * @param log string to be logged |
|
201 */ |
|
202 void writeLog(QString log) const; |
|
203 |
|
204 private: |
|
205 FBProviderBase *m_provider; |
|
206 SmfPluginUtil *m_util; |
|
207 }; |
|
208 |
|
209 // Class declaration |
|
210 class FBProviderBase : public QObject, public SmfProviderBase |
|
211 { |
|
212 Q_OBJECT |
|
213 Q_INTERFACES( SmfProviderBase ) |
|
214 |
|
215 public: |
|
216 virtual ~FBProviderBase( ); |
|
217 |
|
218 /** |
|
219 * Method to get the Localisable name of the service. |
|
220 * @return The Localisable name of the service. |
|
221 */ |
|
222 QString serviceName( ) const; |
|
223 |
|
224 /** |
|
225 * Method to get the Logo of the service |
|
226 * @return The Logo of the service |
|
227 */ |
|
228 QImage serviceIcon( ) const; |
|
229 |
|
230 /** |
|
231 * Method to get the Readable service description |
|
232 * @return The Readable service description |
|
233 */ |
|
234 QString description( ) const; |
|
235 |
|
236 /** |
|
237 * Method to get the Website of the service |
|
238 * @return The Website of the service |
|
239 */ |
|
240 QUrl serviceUrl( ) const; |
|
241 |
|
242 /** |
|
243 * Method to get the URL of the Application providing this service |
|
244 * @return The URL of the Application providing this service |
|
245 */ |
|
246 QUrl applicationUrl( ) const; |
|
247 |
|
248 /** |
|
249 * Method to get the Icon of the application |
|
250 * @return The Icon of the application |
|
251 */ |
|
252 QImage applicationIcon( ) const; |
|
253 |
|
254 /** |
|
255 * Method to get the Plugin specific ID |
|
256 * @return The Plugin specific ID |
|
257 */ |
|
258 QString pluginId( ) const; |
|
259 |
|
260 /** |
|
261 * Method to get the ID of the authentication application |
|
262 * for this service |
|
263 * @param aProgram The authentication application name |
|
264 * @param aArguments List of arguments required for authentication app |
|
265 * @param aMode Strting mode for authentication application |
|
266 * @return The ID of the authentication application |
|
267 */ |
|
268 QString authenticationApp( QString &aProgram, QStringList & aArguments, |
|
269 QIODevice::OpenModeFlag aMode = QIODevice::ReadWrite ) const; |
|
270 |
|
271 /** |
|
272 * Method to get the unique registration ID provided by the |
|
273 * Smf for authorised plugins |
|
274 * @return The unique registration ID/token provided by the Smf for |
|
275 * authorised plugins |
|
276 */ |
|
277 QString smfRegistrationId( ) const; |
|
278 |
|
279 private: |
|
280 friend class FBPostProviderPlugin; |
|
281 void initialize(); |
|
282 QString m_serviceName; |
|
283 QImage m_serviceIcon; |
|
284 QString m_description; |
|
285 QUrl m_serviceUrl; |
|
286 QUrl m_applicationUrl; |
|
287 QImage m_applicationIcon; |
|
288 QString m_pluginId; |
|
289 QString m_authAppId; |
|
290 QString m_smfRegToken; |
|
291 }; |
|
292 |
|
293 #endif /*_FBPOSTPROVIDERPLUGIN_H*/ |
|