55 * If not supplied by the user default values are used. |
55 * If not supplied by the user default values are used. |
56 * @param names the subject or any keywords to be used to filter albums with that name |
56 * @param names the subject or any keywords to be used to filter albums with that name |
57 * @param user the user whose albums are requested |
57 * @param user the user whose albums are requested |
58 * @param pageNum Page number to download, SMF_FIRST_PAGE denotes fresh query. |
58 * @param pageNum Page number to download, SMF_FIRST_PAGE denotes fresh query. |
59 * @param perPage Item per page, default is SMF_ITEMS_PER_PAGE |
59 * @param perPage Item per page, default is SMF_ITEMS_PER_PAGE |
60 */ |
60 * @return SmfError. SmfNoError if success, else appropriate error code |
61 void SmfGalleryPrivate::albums(QStringList names, SmfContact* user, int pageNum, int perPage) |
61 */ |
62 { |
62 SmfError SmfGalleryPrivate::albums(QStringList names, SmfContact* user, int pageNum, int perPage) |
63 //We need to pass Opcode and SmfProvider serialized into bytearray |
63 { |
64 SmfProvider* m_baseProvider = m_gallery->getProvider(); |
64 SmfError err = SmfNoError; |
65 m_serializedDataToServer.clear(); |
65 //We need to pass Opcode and SmfProvider serialized into bytearray |
66 QDataStream write(&m_serializedDataToServer,QIODevice::WriteOnly); |
66 SmfProvider* m_baseProvider = m_gallery->getProvider(); |
67 write<<*m_baseProvider; |
67 m_serializedDataToServer.clear(); |
68 m_argFlag = 1; |
68 QDataStream write(&m_serializedDataToServer,QIODevice::WriteOnly); |
69 write<<m_argFlag; |
69 write<<*m_baseProvider; |
70 write<<names; |
70 |
|
71 QByteArray dataToPlugins; |
|
72 QDataStream streamToPlugin(&dataToPlugins, QIODevice::WriteOnly); |
|
73 m_argFlag = 1; |
|
74 streamToPlugin<<m_argFlag; |
|
75 streamToPlugin<<names; |
71 if(user) |
76 if(user) |
72 { |
77 { |
73 write<<m_argFlag; |
78 streamToPlugin<<m_argFlag; |
74 write<<*user; |
79 streamToPlugin<<*user; |
75 } |
80 } |
76 else |
81 else |
77 { |
82 { |
78 m_argFlag = 0; |
83 m_argFlag = 0; |
79 write<<m_argFlag; |
84 streamToPlugin<<m_argFlag; |
80 } |
85 } |
81 m_argFlag = 1; |
86 m_argFlag = 1; |
82 write<<m_argFlag; |
87 streamToPlugin<<m_argFlag; |
83 write<<pageNum; |
88 streamToPlugin<<pageNum; |
84 write<<m_argFlag; |
89 streamToPlugin<<m_argFlag; |
85 write<<perPage; |
90 streamToPlugin<<perPage; |
|
91 |
|
92 write<<dataToPlugins; |
86 |
93 |
87 QString intfName(galleryInterface); |
94 QString intfName(galleryInterface); |
88 int maxalloc = MaxSmfPictureAlbumSize*perPage; |
95 int maxalloc = MaxSmfPictureAlbumSize*perPage; |
89 |
96 |
90 //call private impl's send method |
97 //call private impl's send method |
91 m_SmfClientPrivate->sendRequest(m_serializedDataToServer, intfName, |
98 m_SmfClientPrivate->sendRequest(m_serializedDataToServer, intfName, |
92 SmfPictureGetAlbums, maxalloc); |
99 SmfPictureGetAlbums, maxalloc); |
|
100 return err; |
93 } |
101 } |
94 |
102 |
95 |
103 |
96 /** |
104 /** |
97 * Get the picture listing asynchronously. The picturesAvailable() signal is |
105 * Get the picture listing asynchronously. The picturesAvailable() signal is |
99 * When the list is big user can specify the page number and per page item data. |
107 * When the list is big user can specify the page number and per page item data. |
100 * If not supplied by the user default values are used. |
108 * If not supplied by the user default values are used. |
101 * @param albums album(s) whose pictures are being requested |
109 * @param albums album(s) whose pictures are being requested |
102 * @param pageNum Page number to download, SMF_FIRST_PAGE denotes fresh query. |
110 * @param pageNum Page number to download, SMF_FIRST_PAGE denotes fresh query. |
103 * @param perPage Item per page, default is SMF_ITEMS_PER_PAGE |
111 * @param perPage Item per page, default is SMF_ITEMS_PER_PAGE |
104 */ |
112 * @return SmfError. SmfNoError if success, else appropriate error code |
105 void SmfGalleryPrivate::pictures(SmfPictureAlbumList &albums,int pageNum,int perPage) |
113 */ |
106 { |
114 SmfError SmfGalleryPrivate::pictures(SmfPictureAlbumList &albums,int pageNum,int perPage) |
107 //We need to pass Opcode and SmfProvider serialized into bytearray |
115 { |
108 SmfProvider* m_baseProvider = m_gallery->getProvider(); |
116 SmfError err = SmfNoError; |
109 m_serializedDataToServer.clear(); |
117 //We need to pass Opcode and SmfProvider serialized into bytearray |
110 QDataStream write(&m_serializedDataToServer,QIODevice::WriteOnly); |
118 SmfProvider* m_baseProvider = m_gallery->getProvider(); |
111 write<<*m_baseProvider; |
119 m_serializedDataToServer.clear(); |
112 m_argFlag = 1; |
120 QDataStream write(&m_serializedDataToServer,QIODevice::WriteOnly); |
113 write<<m_argFlag; |
121 write<<*m_baseProvider; |
114 write<<albums; |
122 |
115 write<<m_argFlag; |
123 QByteArray dataToPlugins; |
116 write<<pageNum; |
124 QDataStream streamToPlugin(&dataToPlugins, QIODevice::WriteOnly); |
117 write<<m_argFlag; |
125 |
118 write<<perPage; |
126 m_argFlag = 1; |
|
127 streamToPlugin<<m_argFlag; |
|
128 streamToPlugin<<albums; |
|
129 streamToPlugin<<m_argFlag; |
|
130 streamToPlugin<<pageNum; |
|
131 streamToPlugin<<m_argFlag; |
|
132 streamToPlugin<<perPage; |
|
133 |
|
134 write<<dataToPlugins; |
119 |
135 |
120 QString intfName(galleryInterface); |
136 QString intfName(galleryInterface); |
121 int maxalloc = MaxSmfPictureSize*perPage; |
137 int maxalloc = MaxSmfPictureSize*perPage; |
122 |
138 |
123 //call private impl's send method |
139 //call private impl's send method |
124 m_SmfClientPrivate->sendRequest(m_serializedDataToServer, intfName, |
140 m_SmfClientPrivate->sendRequest(m_serializedDataToServer, intfName, |
125 SmfPictureGetPictures, maxalloc); |
141 SmfPictureGetPictures, maxalloc); |
|
142 return err; |
126 } |
143 } |
127 |
144 |
128 /** |
145 /** |
129 * Returns a user title/caption for the picture |
146 * Returns a user title/caption for the picture |
130 */ |
147 * @return SmfError. SmfNoError if success, else appropriate error code |
131 void SmfGalleryPrivate::description ( SmfPicture& picture ) |
148 */ |
132 { |
149 SmfError SmfGalleryPrivate::description ( SmfPicture& picture ) |
133 //We need to pass Opcode and SmfProvider serialized into bytearray |
150 { |
134 SmfProvider* m_baseProvider = m_gallery->getProvider(); |
151 SmfError err = SmfNoError; |
135 m_serializedDataToServer.clear(); |
152 //We need to pass Opcode and SmfProvider serialized into bytearray |
136 QDataStream write(&m_serializedDataToServer,QIODevice::WriteOnly); |
153 SmfProvider* m_baseProvider = m_gallery->getProvider(); |
137 write<<*m_baseProvider; |
154 m_serializedDataToServer.clear(); |
138 m_argFlag = 1; |
155 QDataStream write(&m_serializedDataToServer,QIODevice::WriteOnly); |
139 write<<m_argFlag; |
156 write<<*m_baseProvider; |
140 write<<picture; |
157 |
141 |
158 QByteArray dataToPlugins; |
|
159 QDataStream streamToPlugin(&dataToPlugins, QIODevice::WriteOnly); |
|
160 |
|
161 m_argFlag = 1; |
|
162 streamToPlugin<<m_argFlag; |
|
163 streamToPlugin<<picture; |
|
164 |
|
165 write<<dataToPlugins; |
|
166 |
142 QString intfName(galleryInterface); |
167 QString intfName(galleryInterface); |
143 // ToDo :- Setting max limit of description string as 1000 |
168 // ToDo :- Setting max limit of description string as 1000 |
144 int maxalloc = 1000; |
169 int maxalloc = 1000; |
145 |
170 |
146 //call private impl's send method |
171 //call private impl's send method |
147 m_SmfClientPrivate->sendRequest(m_serializedDataToServer, intfName, |
172 m_SmfClientPrivate->sendRequest(m_serializedDataToServer, intfName, |
148 SmfPictureDescription, maxalloc); |
173 SmfPictureDescription, maxalloc); |
|
174 return err; |
149 } |
175 } |
150 |
176 |
151 /** |
177 /** |
152 * Upload an image.Implemented as slot to connect to UI controls more easily |
178 * Upload an image.Implemented as slot to connect to UI controls more easily |
153 * uploadFinished() signal is emitted with the success value of the upload |
179 * uploadFinished() signal is emitted with the success value of the upload |
154 * @param image the image to be uploaded |
180 * @param image the image to be uploaded |
155 * @param album the optional destination album name |
181 * @param album the optional destination album name |
156 */ |
182 * @return SmfError. SmfNoError if success, else appropriate error code |
157 void SmfGalleryPrivate::upload(SmfPicture* image, SmfPictureAlbum* album) |
183 */ |
158 { |
184 SmfError SmfGalleryPrivate::upload(SmfPicture* image, SmfPictureAlbum* album) |
159 //We need to pass Opcode and SmfProvider serialized into bytearray |
185 { |
160 SmfProvider* m_baseProvider = m_gallery->getProvider(); |
186 SmfError err = SmfNoError; |
161 m_serializedDataToServer.clear(); |
187 //We need to pass Opcode and SmfProvider serialized into bytearray |
162 QDataStream write(&m_serializedDataToServer,QIODevice::WriteOnly); |
188 SmfProvider* m_baseProvider = m_gallery->getProvider(); |
163 write<<*m_baseProvider; |
189 m_serializedDataToServer.clear(); |
|
190 QDataStream write(&m_serializedDataToServer,QIODevice::WriteOnly); |
|
191 write<<*m_baseProvider; |
|
192 |
|
193 QByteArray dataToPlugins; |
|
194 QDataStream streamToPlugin(&dataToPlugins, QIODevice::WriteOnly); |
|
195 |
164 if(image) |
196 if(image) |
165 { |
197 { |
166 m_argFlag = 1; |
198 m_argFlag = 1; |
167 write<<m_argFlag; |
199 streamToPlugin<<m_argFlag; |
168 write<<*image; |
200 streamToPlugin<<*image; |
169 } |
201 } |
170 else |
202 else |
171 { |
203 { |
172 m_argFlag = 0; |
204 m_argFlag = 0; |
173 write<<m_argFlag; |
205 streamToPlugin<<m_argFlag; |
174 } |
206 } |
175 |
207 |
176 if(album) |
208 if(album) |
177 { |
209 { |
178 m_argFlag = 1; |
210 m_argFlag = 1; |
179 write<<m_argFlag; |
211 streamToPlugin<<m_argFlag; |
180 write<<*album; |
212 streamToPlugin<<*album; |
181 } |
213 } |
182 else |
214 else |
183 { |
215 { |
184 m_argFlag = 0; |
216 m_argFlag = 0; |
185 write<<m_argFlag; |
217 streamToPlugin<<m_argFlag; |
186 } |
218 } |
187 |
219 |
|
220 write<<dataToPlugins; |
|
221 |
188 QString intfName(galleryInterface); |
222 QString intfName(galleryInterface); |
189 int maxalloc = 100; // ToDo:- limit set as 100 |
223 int maxalloc = 100; // ToDo:- limit set as 100 |
190 |
224 |
191 //call private impl's send method |
225 //call private impl's send method |
192 m_SmfClientPrivate->sendRequest(m_serializedDataToServer, intfName, |
226 m_SmfClientPrivate->sendRequest(m_serializedDataToServer, intfName, |
193 SmfPictureUpload, maxalloc); |
227 SmfPictureUpload, maxalloc); |
|
228 return err; |
194 } |
229 } |
195 |
230 |
196 /** |
231 /** |
197 * Upload an list image.Implemented as slot to connect to UI controls more easily |
232 * Upload an list image.Implemented as slot to connect to UI controls more easily |
198 * uploadFinished() signal is emitted with the success value of the upload |
233 * uploadFinished() signal is emitted with the success value of the upload |
199 * @param images the list image to be uploaded |
234 * @param images the list image to be uploaded |
200 * @param album the optional destination album name |
235 * @param album the optional destination album name |
201 */ |
236 * @return SmfError. SmfNoError if success, else appropriate error code |
202 void SmfGalleryPrivate::upload(SmfPictureList* images, SmfPictureAlbum* album) |
237 */ |
203 { |
238 SmfError SmfGalleryPrivate::upload(SmfPictureList* images, SmfPictureAlbum* album) |
|
239 { |
|
240 SmfError err = SmfNoError; |
204 //We need to pass Opcode and SmfProvider serialized into bytearray |
241 //We need to pass Opcode and SmfProvider serialized into bytearray |
205 m_serializedDataToServer.clear(); |
242 m_serializedDataToServer.clear(); |
206 SmfProvider* m_baseProvider = m_gallery->getProvider(); |
243 SmfProvider* m_baseProvider = m_gallery->getProvider(); |
207 QDataStream write(&m_serializedDataToServer,QIODevice::WriteOnly); |
244 QDataStream write(&m_serializedDataToServer,QIODevice::WriteOnly); |
208 write<<*m_baseProvider; |
245 write<<*m_baseProvider; |
|
246 |
|
247 QByteArray dataToPlugins; |
|
248 QDataStream streamToPlugin(&dataToPlugins, QIODevice::WriteOnly); |
|
249 |
209 if(images) |
250 if(images) |
210 { |
251 { |
211 m_argFlag = 1; |
252 m_argFlag = 1; |
212 write<<m_argFlag; |
253 streamToPlugin<<m_argFlag; |
213 write<<*images; |
254 streamToPlugin<<*images; |
214 } |
255 } |
215 else |
256 else |
216 { |
257 { |
217 m_argFlag = 0; |
258 m_argFlag = 0; |
218 write<<m_argFlag; |
259 streamToPlugin<<m_argFlag; |
219 } |
260 } |
220 |
261 |
221 if(album) |
262 if(album) |
222 { |
263 { |
223 m_argFlag = 1; |
264 m_argFlag = 1; |
224 write<<m_argFlag; |
265 streamToPlugin<<m_argFlag; |
225 write<<*album; |
266 streamToPlugin<<*album; |
226 } |
267 } |
227 else |
268 else |
228 { |
269 { |
229 m_argFlag = 0; |
270 m_argFlag = 0; |
230 write<<m_argFlag; |
271 streamToPlugin<<m_argFlag; |
231 } |
272 } |
|
273 |
|
274 write<<dataToPlugins; |
232 |
275 |
233 QString intfName(galleryInterface); |
276 QString intfName(galleryInterface); |
234 int maxalloc = 1000; // ToDo:- limit set as 1000 |
277 int maxalloc = 1000; // ToDo:- limit set as 1000 |
235 |
278 |
236 //call private impl's send method |
279 //call private impl's send method |
237 m_SmfClientPrivate->sendRequest(m_serializedDataToServer, intfName, |
280 m_SmfClientPrivate->sendRequest(m_serializedDataToServer, intfName, |
238 SmfPictureMultiUpload, maxalloc); |
281 SmfPictureMultiUpload, maxalloc); |
|
282 return err; |
239 } |
283 } |
240 |
284 |
241 /** |
285 /** |
242 * Posts a comment for an image. uploadFinished() signal is emitted |
286 * Posts a comment for an image. uploadFinished() signal is emitted |
243 * with success of the post once comment is posted. |
287 * with success of the post once comment is posted. |
244 * @param image Image to comment on |
288 * @param image Image to comment on |
245 * @param comment Comment to post |
289 * @param comment Comment to post |
246 */ |
290 * @return SmfError. SmfNoError if success, else appropriate error code |
247 void SmfGalleryPrivate::postComment(SmfPicture image, SmfComment comment) |
291 */ |
248 { |
292 SmfError SmfGalleryPrivate::postComment(SmfPicture image, SmfComment comment) |
249 //We need to pass Opcode and SmfProvider serialized into bytearray |
293 { |
250 SmfProvider* m_baseProvider = m_gallery->getProvider(); |
294 SmfError err = SmfNoError; |
251 m_serializedDataToServer.clear(); |
295 //We need to pass Opcode and SmfProvider serialized into bytearray |
252 QDataStream write(&m_serializedDataToServer,QIODevice::WriteOnly); |
296 SmfProvider* m_baseProvider = m_gallery->getProvider(); |
253 write<<*m_baseProvider; |
297 m_serializedDataToServer.clear(); |
254 m_argFlag = 1; |
298 QDataStream write(&m_serializedDataToServer,QIODevice::WriteOnly); |
255 write<<m_argFlag; |
299 write<<*m_baseProvider; |
256 write<<image; |
300 |
257 write<<m_argFlag; |
301 QByteArray dataToPlugins; |
258 write<<comment; |
302 QDataStream streamToPlugin(&dataToPlugins, QIODevice::WriteOnly); |
|
303 |
|
304 m_argFlag = 1; |
|
305 streamToPlugin<<m_argFlag; |
|
306 streamToPlugin<<image; |
|
307 streamToPlugin<<m_argFlag; |
|
308 streamToPlugin<<comment; |
|
309 |
|
310 write<<dataToPlugins; |
259 |
311 |
260 QString intfName(galleryInterface); |
312 QString intfName(galleryInterface); |
261 int maxalloc = 100; // ToDo:- limit set as 100 |
313 int maxalloc = 100; // ToDo:- limit set as 100 |
262 //call private impl's send method |
314 //call private impl's send method |
263 m_SmfClientPrivate->sendRequest(m_serializedDataToServer, intfName, |
315 m_SmfClientPrivate->sendRequest(m_serializedDataToServer, intfName, |
264 SmfPicturePostComment, maxalloc); |
316 SmfPicturePostComment, maxalloc); |
|
317 return err; |
265 } |
318 } |
266 |
319 |
267 /** |
320 /** |
268 * Request for a custom operation. |
321 * Request for a custom operation. |
269 * @param operationId OperationId |
322 * @param operationId OperationId |
270 * @param customData Custom data to be sent |
323 * @param customData Custom data to be sent |
|
324 * @return SmfError. SmfNoError if success, else appropriate error code |
271 * Note:-Interpretation of operationId and customData is upto the concerned |
325 * Note:-Interpretation of operationId and customData is upto the concerned |
272 * plugin and client application. service provider should provide some |
326 * plugin and client application. service provider should provide some |
273 * serializing-deserializing utilities for these custom data |
327 * serializing-deserializing utilities for these custom data |
274 */ |
328 */ |
275 void SmfGalleryPrivate::customRequest ( const int& operationId, QByteArray* customData ) |
329 SmfError SmfGalleryPrivate::customRequest ( const int& operationId, QByteArray* customData ) |
276 { |
330 { |
277 //We need to pass Opcode and SmfProvider serialized into bytearray |
331 SmfError err = SmfNoError; |
278 SmfProvider* m_baseProvider = m_gallery->getProvider(); |
332 //We need to pass Opcode and SmfProvider serialized into bytearray |
279 m_serializedDataToServer.clear(); |
333 SmfProvider* m_baseProvider = m_gallery->getProvider(); |
280 QDataStream write(&m_serializedDataToServer,QIODevice::WriteOnly); |
334 m_serializedDataToServer.clear(); |
281 write<<*m_baseProvider; |
335 QDataStream write(&m_serializedDataToServer,QIODevice::WriteOnly); |
282 m_argFlag = 1; |
336 write<<*m_baseProvider; |
283 write<<m_argFlag; |
337 |
284 write<<operationId; |
338 QByteArray dataToPlugins; |
|
339 QDataStream streamToPlugin(&dataToPlugins, QIODevice::WriteOnly); |
|
340 |
|
341 m_argFlag = 1; |
|
342 streamToPlugin<<m_argFlag; |
|
343 streamToPlugin<<operationId; |
285 if(customData) |
344 if(customData) |
286 { |
345 { |
287 write<<m_argFlag; |
346 streamToPlugin<<m_argFlag; |
288 write<<*customData; |
347 streamToPlugin<<*customData; |
289 } |
348 } |
290 else |
349 else |
291 { |
350 { |
292 m_argFlag = 0; |
351 m_argFlag = 0; |
293 write<<m_argFlag; |
352 streamToPlugin<<m_argFlag; |
294 } |
353 } |
295 |
354 |
|
355 write<<dataToPlugins; |
|
356 |
296 QString intfName(galleryInterface); |
357 QString intfName(galleryInterface); |
297 //ToDo:- How much size to allocate for custo data? keeping MaxSmfPictureSize for now |
358 //ToDo:- How much size to allocate for custo data? keeping MaxSmfPictureSize for now |
298 int maxAlloc = MaxSmfPictureSize; |
359 int maxAlloc = MaxSmfPictureSize; |
299 |
360 |
300 //call private impl's send method |
361 //call private impl's send method |
301 m_SmfClientPrivate->sendRequest(m_serializedDataToServer, intfName, |
362 m_SmfClientPrivate->sendRequest(m_serializedDataToServer, intfName, |
302 SmfPictureCustomRequest, maxAlloc); |
363 SmfPictureCustomRequest, maxAlloc); |
|
364 return err; |
|
365 } |
|
366 |
|
367 SmfError SmfGalleryPrivate::cancelRequest() |
|
368 { |
|
369 qDebug()<<"Inside SmfGalleryPrivate::cancelRequest()"; |
|
370 QByteArray notused; |
|
371 QByteArray retData = m_SmfClientPrivate->sendSyncRequest(notused,SmfCancelRequest,1000, notused); |
|
372 |
|
373 //De-serialize it into SmfError |
|
374 QDataStream reader(&retData,QIODevice::ReadOnly); |
|
375 int val; |
|
376 reader>>val; |
|
377 SmfError error = (SmfError) val; |
|
378 return error; |
303 } |
379 } |
304 |
380 |
305 |
381 |
306 /** |
382 /** |
307 * To notify availibility of asynchronous requests. |
383 * To notify availibility of asynchronous requests. |