1 /** |
|
2 * @file smfproviderbase.h |
|
3 * @author Nalina Hariharan, Sasken Communication Technologies Ltd - Initial contribution |
|
4 * @version 1.0 |
|
5 * |
|
6 * @section LICENSE |
|
7 * |
|
8 * Copyright (c) 2010 Sasken Communication Technologies Ltd. |
|
9 * All rights reserved. |
|
10 * This component and the accompanying materials are made available |
|
11 * under the terms of the "{License}" |
|
12 * which accompanies this distribution, and is available |
|
13 * at the URL "{LicenseUrl}". |
|
14 * |
|
15 * @section DESCRIPTION |
|
16 * |
|
17 * The Provider Base class is the class that has to be contained as a member |
|
18 * in all Plug-in Interfaces. |
|
19 */ |
|
20 |
|
21 #ifndef SMFPROVIDERBASE_H_ |
|
22 #define SMFPROVIDERBASE_H_ |
|
23 |
|
24 #include <QImage> |
|
25 #include <QUrl> |
|
26 #include <QBuffer> |
|
27 #include <QNetworkAccessManager> |
|
28 |
|
29 |
|
30 /** |
|
31 * The enumeration used to track the plugin methods return type |
|
32 */ |
|
33 enum SmfPluginRetType |
|
34 { |
|
35 SmfSendRequestAgain = 0, |
|
36 SmfRequestComplete |
|
37 }; |
|
38 |
|
39 /** |
|
40 * The enumeration used to indicate result of transport to the plugins |
|
41 */ |
|
42 enum SmfTransportResult |
|
43 { |
|
44 SmfNoError = 0, |
|
45 SmfNetworkTimeOut, |
|
46 SmfIAPChanged, |
|
47 SmfUnknownError |
|
48 }; |
|
49 |
|
50 /** |
|
51 * The enumeration used to denote errors reported by plugin |
|
52 * Smf can't continue without handling these errors |
|
53 */ |
|
54 enum SmfPluginError |
|
55 { |
|
56 SmfPluginErrNone = 0, |
|
57 SmfPluginErrTooManyRequest, |
|
58 SmfPluginErrRequestQuotaExceeded, |
|
59 SmfPluginErrInvalidRequest, |
|
60 SmfPluginErrUserNotLoggedIn, |
|
61 SmfPluginErrAuthenticationExpired, |
|
62 SmfPluginErrPermissionDenied, |
|
63 SmfPluginErrInvalidApplication, |
|
64 SmfPluginErrServiceUnavailable, |
|
65 SmfPluginErrServiceTemporaryUnavailable, |
|
66 SmfPluginErrFormatNotSupported, |
|
67 SmfPluginErrDataSizeExceeded |
|
68 }; |
|
69 |
|
70 |
|
71 /** |
|
72 * The enumeration used to indicate the type of network operation done |
|
73 */ |
|
74 enum SmfRequestOperation |
|
75 { |
|
76 SmfContactGetFriends = 0, |
|
77 SmfContactGetFollowers, |
|
78 SmfContactSearch, |
|
79 SmfContactGerGroups, |
|
80 SmfContactSearchInGroup, |
|
81 SmfContactGetPosts, |
|
82 SmfContactUpdatePost, |
|
83 SmfContactUpdatePostDirected, |
|
84 SmfContactPostAppearence, |
|
85 SmfMusicGetLyrics, |
|
86 SmfMusicGetSubtitle, |
|
87 SmfMusicGetEventsOnLoc, |
|
88 SmfMusicGetVenueOnLoc, |
|
89 SmfMusicGetEventsOnVenue, |
|
90 SmfMusicPostEvents, |
|
91 SmfMusicGetRecommendations, |
|
92 SmfMusicGetTracks, |
|
93 SmfMusicGetTrackInfo, |
|
94 SmfMusicGetStores, |
|
95 SmfMusicPostCurrentPlaying, |
|
96 SmfMusicGetUserInfo, |
|
97 SmfMusicSearchUser, |
|
98 SmfMusicGetPlaylists, |
|
99 SmfMusicGetPlaylistsOfUser, |
|
100 SmfMusicAddToPlaylist, |
|
101 SmfMusicPostCurrentPlayingPlaylist, |
|
102 SmfPictureGetPictures, |
|
103 SmfPictureDescription, |
|
104 SmfPictureUpload, |
|
105 SmfPictureMultiUpload, |
|
106 SmfPicturePostComment |
|
107 |
|
108 }; |
|
109 |
|
110 |
|
111 /** |
|
112 * The structure used to track the data usage of each plugins |
|
113 */ |
|
114 struct SmfPluginDataUsage |
|
115 { |
|
116 /** |
|
117 * Application that called the plugin |
|
118 */ |
|
119 QString iAppName; |
|
120 |
|
121 /** |
|
122 * Interface implemented by the plugin |
|
123 */ |
|
124 QString iInterfaceName; |
|
125 |
|
126 /** |
|
127 * The service provider |
|
128 */ |
|
129 QString iServiceProviderName; |
|
130 |
|
131 /** |
|
132 * number of bytes sent for this plugin |
|
133 */ |
|
134 uint iBytesSent; |
|
135 |
|
136 /** |
|
137 * number of bytes received for this plugin |
|
138 */ |
|
139 uint iBytesReceived; |
|
140 |
|
141 }; |
|
142 |
|
143 |
|
144 /** |
|
145 * The structure used to hold the request created by the plugins |
|
146 */ |
|
147 struct SmfPluginRequestData |
|
148 { |
|
149 /** |
|
150 * Indicates the type of operation performed, like getting Friends |
|
151 * list, upload image etc |
|
152 */ |
|
153 SmfRequestOperation iRequestType; |
|
154 |
|
155 /** |
|
156 * The QNetworkRequest that has to be filled up by the plugins |
|
157 */ |
|
158 QNetworkRequest *iNetworkRequest; |
|
159 |
|
160 /** |
|
161 * The data to be posted in case of HTTP POST operation |
|
162 */ |
|
163 QBuffer *iPostData; |
|
164 |
|
165 /** |
|
166 * The type of HTTP transaction, like GET, POST etc |
|
167 */ |
|
168 QNetworkAccessManager::Operation iHttpOperationType; |
|
169 |
|
170 }; |
|
171 |
|
172 /** |
|
173 * The Provider Base class is the class that has to be contained as a member |
|
174 * in all Plug-in Interfaces. |
|
175 * |
|
176 * All of plug-ins should contain this class as a member and should also |
|
177 * contain a public method to get instance of this class. |
|
178 */ |
|
179 class SmfProviderBase : public QObject |
|
180 { |
|
181 Q_OBJECT |
|
182 |
|
183 public: |
|
184 /** |
|
185 * Constructor with default argument |
|
186 * @param aParent The parent object |
|
187 */ |
|
188 SmfProviderBase( QObject* aParent = 0 ); |
|
189 |
|
190 /** |
|
191 * Destructor |
|
192 */ |
|
193 ~SmfProviderBase( ); |
|
194 |
|
195 /** |
|
196 * Method to get the Localisable name of the service. |
|
197 * @return The Localisable name of the service. |
|
198 */ |
|
199 QString serviceName( ); |
|
200 |
|
201 /** |
|
202 * Method to get the Logo of the service |
|
203 * @return The Logo of the service |
|
204 */ |
|
205 QImage serviceIcon( ); |
|
206 |
|
207 /** |
|
208 * Method to get the Readable service description |
|
209 * @return The Readable service description |
|
210 */ |
|
211 QString description( ); |
|
212 |
|
213 /** |
|
214 * Method to get the Website of the service |
|
215 * @return The Website of the service |
|
216 */ |
|
217 QUrl serviceUrl( ); |
|
218 |
|
219 /** |
|
220 * Method to get the URL of the Application providing this service |
|
221 * @return The URL of the Application providing this service |
|
222 */ |
|
223 QUrl applicationUrl( ); |
|
224 |
|
225 /** |
|
226 * Method to get the Icon of the application |
|
227 * @return The Icon of the application |
|
228 */ |
|
229 QImage applicationIcon( ); |
|
230 |
|
231 /** |
|
232 * Method to get the Plugin specific ID |
|
233 * @return The Plugin specific ID |
|
234 */ |
|
235 uint pluginId( ); |
|
236 |
|
237 /** |
|
238 * Method to get the ID of the authentication application |
|
239 * for this service |
|
240 * @param aProgram The authentication application name |
|
241 * @param aArguments List of arguments required for authentication app |
|
242 * @param aMode Strting mode for authentication application |
|
243 * @return The ID of the authentication application |
|
244 */ |
|
245 uint authenticationApp( QString &aProgram, QStringList & aArguments, |
|
246 QIODevice::OpenModeFlag aMode = QIODevice::ReadWrite ); |
|
247 |
|
248 /** |
|
249 * Method to get the unique registration ID provided by the |
|
250 * Smf for authorised plugins |
|
251 * @return The unique registration ID/token provided by the Smf for |
|
252 * authorised plugins |
|
253 */ |
|
254 QString smfRegistrationId( ); |
|
255 |
|
256 /** |
|
257 * Method to get the data usage of each plugin |
|
258 * @param aUsage The data usage structure |
|
259 */ |
|
260 void getDataUsage( SmfPluginDataUsage &aUsage ); |
|
261 |
|
262 /** |
|
263 * Method to get the reference count for loading. |
|
264 * The reference count increased with each load request and decreased |
|
265 * with each unload request |
|
266 * @return The reference count value for loading of the plugins |
|
267 */ |
|
268 uint getLoadRefCount( ); |
|
269 |
|
270 private: |
|
271 QString m_serviceName; // the Localisable name of the service |
|
272 QImage m_serviceIcon; // the Logo of the service |
|
273 QString m_description; // the Readable service description |
|
274 QUrl m_serviceUrl; // the Website of the service |
|
275 QUrl m_applicationUrl; // URL of the Application providing this service |
|
276 QImage m_applicationIcon; //Icon of the application |
|
277 uint m_pluginId; // The Plugin specific ID |
|
278 uint m_authenticationAppId; // ID of the authentication application for this service |
|
279 QString m_registrationId; // unique registration ID provided by the |
|
280 // Smf for authorised plugins |
|
281 SmfPluginDataUsage m_usage; //data usage of each plugin |
|
282 uint m_loadRefCount; // reference count increased with each load request |
|
283 // and decreased with each unload request |
|
284 }; |
|
285 |
|
286 #endif /* SMFPROVIDERBASE_H_ */ |
|