18
|
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 |
* Manasij Roy, Nalina Hariharan
|
|
14 |
*
|
|
15 |
* Description:
|
|
16 |
* Private implementation of music related services
|
|
17 |
*
|
|
18 |
*/
|
|
19 |
|
|
20 |
#include <qdebug.h>
|
|
21 |
#include <smfmusicrating.h>
|
|
22 |
#include <smfcomment.h>
|
|
23 |
#include <smfmusicfingerprint.h>
|
|
24 |
#include <smfcontact.h>
|
|
25 |
|
|
26 |
#include "smfmusic.h"
|
|
27 |
#include "smfmusic_p.h"
|
|
28 |
#ifdef Q_OS_SYMBIAN
|
|
29 |
#include "smfclientsymbian.h"
|
|
30 |
#else
|
|
31 |
#include "smfclientqt.h"
|
|
32 |
#endif
|
|
33 |
|
|
34 |
|
|
35 |
//SmfMusicServicePrivate start
|
|
36 |
SmfMusicServicePrivate::SmfMusicServicePrivate(SmfMusicService* aMusicService)
|
|
37 |
:m_musicService(aMusicService)
|
|
38 |
{
|
|
39 |
#ifdef Q_OS_SYMBIAN
|
|
40 |
//private impl for symbian
|
|
41 |
m_SmfClientPrivate = CSmfClientSymbian::NewL(this);
|
|
42 |
#else
|
|
43 |
//TODO:- Use private impl for other platforms or else Qt impl
|
|
44 |
#endif
|
|
45 |
}
|
|
46 |
|
|
47 |
SmfMusicServicePrivate::~SmfMusicServicePrivate()
|
|
48 |
{
|
|
49 |
if(m_SmfClientPrivate)
|
|
50 |
{
|
|
51 |
delete m_SmfClientPrivate;
|
|
52 |
m_SmfClientPrivate = NULL;
|
|
53 |
}
|
|
54 |
}
|
|
55 |
|
|
56 |
void SmfMusicServicePrivate::userinfo()
|
|
57 |
{
|
|
58 |
//We need to pass Opcode and SmfProvider serialized into bytearray
|
|
59 |
SmfProvider* m_baseProvider = m_musicService->getProvider();
|
|
60 |
m_serializedDataToServer.clear();
|
|
61 |
QDataStream write(&m_serializedDataToServer,QIODevice::WriteOnly);
|
|
62 |
write<<*m_baseProvider;
|
|
63 |
|
|
64 |
QString intfName(musicServiceInterface);
|
|
65 |
int maxalloc = SmfMusicProfileMaxSize;
|
|
66 |
|
|
67 |
//call private impl's send method
|
|
68 |
m_SmfClientPrivate->sendRequest(m_serializedDataToServer, intfName,
|
|
69 |
SmfMusicGetUserInfo, maxalloc);
|
|
70 |
}
|
|
71 |
|
|
72 |
void SmfMusicServicePrivate::searchUser(SmfLocation venue, int pageNum, int perPage)
|
|
73 |
{
|
|
74 |
//We need to pass Opcode and SmfProvider serialized into bytearray
|
|
75 |
SmfProvider* m_baseProvider = m_musicService->getProvider();
|
|
76 |
m_serializedDataToServer.clear();
|
|
77 |
QDataStream write(&m_serializedDataToServer,QIODevice::WriteOnly);
|
|
78 |
write<<*m_baseProvider;
|
|
79 |
m_argFlag = 1;
|
|
80 |
write<<m_argFlag;
|
|
81 |
write<<venue;
|
|
82 |
write<<m_argFlag;
|
|
83 |
write<<pageNum;
|
|
84 |
write<<m_argFlag;
|
|
85 |
write<<perPage;
|
|
86 |
|
|
87 |
QString intfName(musicServiceInterface);
|
|
88 |
int maxalloc = SmfMusicProfileMaxSize*perPage;
|
|
89 |
|
|
90 |
//call private impl's send method
|
|
91 |
m_SmfClientPrivate->sendRequest(m_serializedDataToServer, intfName,
|
|
92 |
SmfMusicSearchUser, maxalloc);
|
|
93 |
}
|
|
94 |
|
|
95 |
void SmfMusicServicePrivate::customRequest ( const int& operationId, QByteArray* customData )
|
|
96 |
{
|
|
97 |
//We need to pass Opcode and SmfProvider serialized into bytearray
|
|
98 |
SmfProvider* m_baseProvider = m_musicService->getProvider();
|
|
99 |
m_serializedDataToServer.clear();
|
|
100 |
QDataStream write(&m_serializedDataToServer,QIODevice::WriteOnly);
|
|
101 |
write<<*m_baseProvider;
|
|
102 |
m_argFlag = 1;
|
|
103 |
write<<m_argFlag;
|
|
104 |
write<<operationId;
|
|
105 |
if(customData)
|
|
106 |
{
|
|
107 |
write<<m_argFlag;
|
|
108 |
write<<*customData;
|
|
109 |
}
|
|
110 |
else
|
|
111 |
{
|
|
112 |
m_argFlag = 0;
|
|
113 |
write<<m_argFlag;
|
|
114 |
}
|
|
115 |
|
|
116 |
QString intfName(musicServiceInterface);
|
|
117 |
//ToDo:- How much size to allocate for custo data? keeping SmfMusicProfileMaxSize for now
|
|
118 |
int maxAlloc = SmfMusicProfileMaxSize;
|
|
119 |
|
|
120 |
//call private impl's send method
|
|
121 |
m_SmfClientPrivate->sendRequest(m_serializedDataToServer, intfName,
|
|
122 |
SmfMusicServiceCustomRequest, maxAlloc);
|
|
123 |
}
|
|
124 |
|
|
125 |
void SmfMusicServicePrivate::postCurrentPlaying(SmfTrackInfo track)
|
|
126 |
{
|
|
127 |
//We need to pass Opcode and SmfProvider serialized into bytearray
|
|
128 |
SmfProvider* m_baseProvider = m_musicService->getProvider();
|
|
129 |
m_serializedDataToServer.clear();
|
|
130 |
QDataStream write(&m_serializedDataToServer,QIODevice::WriteOnly);
|
|
131 |
write<<*(m_baseProvider);
|
|
132 |
m_argFlag = 1;
|
|
133 |
write<<m_argFlag;
|
|
134 |
write<<track;
|
|
135 |
|
|
136 |
QString intfName(musicServiceInterface);
|
|
137 |
//TODO:-revisit all the maxalloc
|
|
138 |
int maxalloc = 1000;
|
|
139 |
|
|
140 |
//call private impl's send method
|
|
141 |
m_SmfClientPrivate->sendRequest(m_serializedDataToServer, intfName,
|
|
142 |
SmfMusicPostCurrentPlaying, maxalloc);
|
|
143 |
}
|
|
144 |
|
|
145 |
void SmfMusicServicePrivate::postRating(SmfTrackInfo track, SmfMusicRating rate)
|
|
146 |
{
|
|
147 |
//We need to pass Opcode and SmfProvider serialized into bytearray
|
|
148 |
SmfProvider* m_baseProvider = m_musicService->getProvider();
|
|
149 |
m_serializedDataToServer.clear();
|
|
150 |
QDataStream write(&m_serializedDataToServer,QIODevice::WriteOnly);
|
|
151 |
write<<*(m_baseProvider);
|
|
152 |
m_argFlag = 1;
|
|
153 |
write<<m_argFlag;
|
|
154 |
write<<track;
|
|
155 |
write<<m_argFlag;
|
|
156 |
write<<rate;
|
|
157 |
|
|
158 |
QString intfName(musicServiceInterface);
|
|
159 |
//TODO:-revisit all the maxalloc
|
|
160 |
int maxalloc = 1000;
|
|
161 |
|
|
162 |
//call private impl's send method
|
|
163 |
m_SmfClientPrivate->sendRequest(m_serializedDataToServer, intfName,
|
|
164 |
SmfMusicPostRating, maxalloc);
|
|
165 |
}
|
|
166 |
|
|
167 |
void SmfMusicServicePrivate::postComments(SmfTrackInfo track, SmfComment comment)
|
|
168 |
{
|
|
169 |
//We need to pass Opcode and SmfProvider serialized into bytearray
|
|
170 |
SmfProvider* m_baseProvider = m_musicService->getProvider();
|
|
171 |
m_serializedDataToServer.clear();
|
|
172 |
QDataStream write(&m_serializedDataToServer,QIODevice::WriteOnly);
|
|
173 |
write<<*(m_baseProvider);
|
|
174 |
m_argFlag = 1;
|
|
175 |
write<<m_argFlag;
|
|
176 |
write<<track;
|
|
177 |
write<<m_argFlag;
|
|
178 |
write<<comment;
|
|
179 |
|
|
180 |
QString intfName(musicServiceInterface);
|
|
181 |
//TODO:-revisit all the maxalloc
|
|
182 |
int maxalloc = 1000;
|
|
183 |
|
|
184 |
//call private impl's send method
|
|
185 |
m_SmfClientPrivate->sendRequest(m_serializedDataToServer, intfName,
|
|
186 |
SmfMusicPostComment, maxalloc);
|
|
187 |
}
|
|
188 |
|
|
189 |
void SmfMusicServicePrivate::resultsAvailable(QByteArray result, SmfRequestTypeID opcode, SmfError error)
|
|
190 |
{
|
|
191 |
//note:- "result" is serialized and we need to de-serialize it as per opcode
|
|
192 |
//Order of serialization Error value followed by data
|
|
193 |
|
|
194 |
QDataStream reader(&result,QIODevice::ReadOnly);
|
|
195 |
|
|
196 |
//Now de-serialize it based on opcode
|
|
197 |
switch(opcode)
|
|
198 |
{
|
|
199 |
case SmfMusicGetUserInfo:
|
|
200 |
{
|
|
201 |
SmfMusicProfile* m_profile = new SmfMusicProfile;
|
|
202 |
reader>>*m_profile;
|
|
203 |
|
|
204 |
emit m_musicService->userInfoAvailable(m_profile,error);
|
|
205 |
break;
|
|
206 |
}
|
|
207 |
|
|
208 |
case SmfMusicSearchUser:
|
|
209 |
{
|
|
210 |
SmfMusicProfileList* m_profileList = new SmfMusicProfileList;
|
|
211 |
reader>>*m_profileList;
|
|
212 |
|
|
213 |
//ToDo :- not incorporating paging now
|
|
214 |
SmfResultPage page;
|
|
215 |
|
|
216 |
emit m_musicService->searchInfoAvailable(m_profileList, error, page);
|
|
217 |
break;
|
|
218 |
}
|
|
219 |
|
|
220 |
case SmfMusicPostCurrentPlaying:
|
|
221 |
case SmfMusicPostRating:
|
|
222 |
case SmfMusicPostComment:
|
|
223 |
{
|
|
224 |
emit m_musicService->postfinished(error);
|
|
225 |
break;
|
|
226 |
}
|
|
227 |
|
|
228 |
case SmfMusicServiceCustomRequest:
|
|
229 |
{
|
|
230 |
int operationId;
|
|
231 |
QByteArray *data = new QByteArray;
|
|
232 |
reader>>operationId;
|
|
233 |
reader>>*data;
|
|
234 |
qDebug()<<"operationId = "<<operationId;
|
|
235 |
qDebug()<<"data size = "<<data->size();
|
|
236 |
emit m_musicService->customDataAvailable(operationId, data);
|
|
237 |
break;
|
|
238 |
}
|
|
239 |
|
|
240 |
default:
|
|
241 |
User::Panic(_L("Music Service Private = "),opcode);
|
|
242 |
}
|
|
243 |
}
|
|
244 |
//SmfMusicServicePrivate start
|
|
245 |
|
|
246 |
|
|
247 |
//SmfMusicSearchPrivate start
|
|
248 |
SmfMusicSearchPrivate::SmfMusicSearchPrivate(SmfMusicSearch *aMusicSearch)
|
|
249 |
: m_musicSearch(aMusicSearch)
|
|
250 |
{
|
|
251 |
#ifdef Q_OS_SYMBIAN
|
|
252 |
//private impl for symbian
|
|
253 |
m_SmfClientPrivate = CSmfClientSymbian::NewL(this);
|
|
254 |
#else
|
|
255 |
//TODO:- Use private impl for other platforms or else Qt impl
|
|
256 |
#endif
|
|
257 |
}
|
|
258 |
|
|
259 |
SmfMusicSearchPrivate::~SmfMusicSearchPrivate()
|
|
260 |
{
|
|
261 |
if(m_SmfClientPrivate)
|
|
262 |
{
|
|
263 |
delete m_SmfClientPrivate;
|
|
264 |
m_SmfClientPrivate = NULL;
|
|
265 |
}
|
|
266 |
}
|
|
267 |
|
|
268 |
void SmfMusicSearchPrivate::recommendations(SmfTrackInfo track, int pageNum, int perPage)
|
|
269 |
{
|
|
270 |
//We need to pass Opcode and SmfProvider serialized into bytearray
|
|
271 |
m_serializedDataToServer.clear();
|
|
272 |
SmfProvider* m_baseProvider = m_musicSearch->getProvider();
|
|
273 |
QDataStream write(&m_serializedDataToServer,QIODevice::WriteOnly);
|
|
274 |
write<<*m_baseProvider;
|
|
275 |
m_argFlag = 1;
|
|
276 |
write<<m_argFlag;
|
|
277 |
write<<track;
|
|
278 |
write<<m_argFlag;
|
|
279 |
write<<pageNum;
|
|
280 |
write<<m_argFlag;
|
|
281 |
write<<perPage;
|
|
282 |
|
|
283 |
QString intfName(musicSearchInterface);
|
|
284 |
//TODO:-revisit all the maxalloc
|
|
285 |
int maxalloc = 1000;
|
|
286 |
|
|
287 |
//call private impl's send method
|
|
288 |
m_SmfClientPrivate->sendRequest(m_serializedDataToServer, intfName,
|
|
289 |
SmfMusicGetRecommendations, maxalloc);
|
|
290 |
}
|
|
291 |
|
|
292 |
void SmfMusicSearchPrivate::tracks(SmfTrackInfo track, int pageNum, int perPage)
|
|
293 |
{
|
|
294 |
//We need to pass Opcode and SmfProvider serialized into bytearray
|
|
295 |
SmfProvider* m_baseProvider = m_musicSearch->getProvider();
|
|
296 |
m_serializedDataToServer.clear();
|
|
297 |
QDataStream write(&m_serializedDataToServer,QIODevice::WriteOnly);
|
|
298 |
write<<*m_baseProvider;
|
|
299 |
m_argFlag = 1;
|
|
300 |
write<<m_argFlag;
|
|
301 |
write<<track;
|
|
302 |
write<<m_argFlag;
|
|
303 |
write<<pageNum;
|
|
304 |
write<<m_argFlag;
|
|
305 |
write<<perPage;
|
|
306 |
|
|
307 |
QString intfName(musicSearchInterface);
|
|
308 |
//TODO:-revisit all the maxalloc
|
|
309 |
int maxalloc = 1000;
|
|
310 |
|
|
311 |
//call private impl's send method
|
|
312 |
m_SmfClientPrivate->sendRequest(m_serializedDataToServer, intfName,
|
|
313 |
SmfMusicGetTracks, maxalloc);
|
|
314 |
}
|
|
315 |
|
|
316 |
void SmfMusicSearchPrivate::trackInfo(SmfMusicFingerPrint signature, int pageNum, int perPage)
|
|
317 |
{
|
|
318 |
//We need to pass Opcode and SmfProvider serialized into bytearray
|
|
319 |
SmfProvider* m_baseProvider = m_musicSearch->getProvider();
|
|
320 |
m_serializedDataToServer.clear();
|
|
321 |
QDataStream write(&m_serializedDataToServer,QIODevice::WriteOnly);
|
|
322 |
write<<*m_baseProvider;
|
|
323 |
m_argFlag = 1;
|
|
324 |
write<<m_argFlag;
|
|
325 |
write<<signature;
|
|
326 |
write<<m_argFlag;
|
|
327 |
write<<pageNum;
|
|
328 |
write<<m_argFlag;
|
|
329 |
write<<perPage;
|
|
330 |
|
|
331 |
QString intfName(musicSearchInterface);
|
|
332 |
//TODO:-revisit all the maxalloc
|
|
333 |
int maxalloc = 1000;
|
|
334 |
|
|
335 |
//call private impl's send method
|
|
336 |
m_SmfClientPrivate->sendRequest(m_serializedDataToServer, intfName,
|
|
337 |
SmfMusicGetTrackInfo, maxalloc);
|
|
338 |
}
|
|
339 |
|
|
340 |
void SmfMusicSearchPrivate::stores(SmfTrackInfo track, int pageNum, int perPage)
|
|
341 |
{
|
|
342 |
//We need to pass Opcode and SmfProvider serialized into bytearray
|
|
343 |
SmfProvider* m_baseProvider = m_musicSearch->getProvider();
|
|
344 |
m_serializedDataToServer.clear();
|
|
345 |
QDataStream write(&m_serializedDataToServer,QIODevice::WriteOnly);
|
|
346 |
write<<*(m_baseProvider);
|
|
347 |
m_argFlag = 1;
|
|
348 |
write<<m_argFlag;
|
|
349 |
write<<track;
|
|
350 |
write<<m_argFlag;
|
|
351 |
write<<pageNum;
|
|
352 |
write<<m_argFlag;
|
|
353 |
write<<perPage;
|
|
354 |
|
|
355 |
QString intfName(musicSearchInterface);
|
|
356 |
/** @TODO:-revisit all the maxalloc */
|
|
357 |
int maxalloc = 1000;
|
|
358 |
|
|
359 |
//call private impl's send method
|
|
360 |
m_SmfClientPrivate->sendRequest(m_serializedDataToServer, intfName,
|
|
361 |
SmfMusicGetStores, maxalloc);
|
|
362 |
}
|
|
363 |
|
|
364 |
void SmfMusicSearchPrivate::customRequest ( const int& operationId, QByteArray* customData )
|
|
365 |
{
|
|
366 |
//We need to pass Opcode and SmfProvider serialized into bytearray
|
|
367 |
SmfProvider* m_baseProvider = m_musicSearch->getProvider();
|
|
368 |
m_serializedDataToServer.clear();
|
|
369 |
QDataStream write(&m_serializedDataToServer,QIODevice::WriteOnly);
|
|
370 |
write<<*m_baseProvider;
|
|
371 |
m_argFlag = 1;
|
|
372 |
write<<m_argFlag;
|
|
373 |
write<<operationId;
|
|
374 |
|
|
375 |
if(customData)
|
|
376 |
{
|
|
377 |
write<<m_argFlag;
|
|
378 |
write<<*customData;
|
|
379 |
}
|
|
380 |
else
|
|
381 |
{
|
|
382 |
m_argFlag = 0;
|
|
383 |
write<<m_argFlag;
|
|
384 |
}
|
|
385 |
|
|
386 |
QString intfName(musicSearchInterface);
|
|
387 |
/** @TODO:-revisit all the maxalloc */
|
|
388 |
int maxalloc = 1000;
|
|
389 |
|
|
390 |
//call private impl's send method
|
|
391 |
m_SmfClientPrivate->sendRequest(m_serializedDataToServer, intfName,
|
|
392 |
SmfMusicSearchCustomRequest, maxalloc);
|
|
393 |
}
|
|
394 |
|
|
395 |
|
|
396 |
|
|
397 |
void SmfMusicSearchPrivate::resultsAvailable(QByteArray result, SmfRequestTypeID opcode, SmfError error)
|
|
398 |
{
|
|
399 |
//note:- "result" is serialized and we need to de-serialize it as per opcode
|
|
400 |
//Order of serialization Error value followed by data
|
|
401 |
|
|
402 |
QDataStream reader(&result,QIODevice::ReadOnly);
|
|
403 |
|
|
404 |
//Now de-serialize it based on opcode
|
|
405 |
switch(opcode)
|
|
406 |
{
|
|
407 |
case SmfMusicGetRecommendations:
|
|
408 |
case SmfMusicGetTracks:
|
|
409 |
case SmfMusicGetTrackInfo:
|
|
410 |
{
|
|
411 |
SmfTrackInfoList* m_trackInfoList = new SmfTrackInfoList;
|
|
412 |
reader>>*(m_trackInfoList);
|
|
413 |
|
|
414 |
//ToDo :- not incorporating paging now
|
|
415 |
SmfResultPage page;
|
|
416 |
|
|
417 |
emit m_musicSearch->trackSearchAvailable(m_trackInfoList,error,page);
|
|
418 |
break;
|
|
419 |
}
|
|
420 |
|
|
421 |
case SmfMusicGetStores:
|
|
422 |
{
|
|
423 |
SmfProviderList* m_providers = new SmfProviderList;
|
|
424 |
reader>>*(m_providers);
|
|
425 |
|
|
426 |
//ToDo :- not incorporating paging now
|
|
427 |
SmfResultPage page;
|
|
428 |
|
|
429 |
emit m_musicSearch->storeSearchAvailable(m_providers,error,page);
|
|
430 |
break;
|
|
431 |
}
|
|
432 |
|
|
433 |
case SmfMusicSearchCustomRequest:
|
|
434 |
{
|
|
435 |
int operationId;
|
|
436 |
QByteArray *data = new QByteArray;
|
|
437 |
reader>>operationId;
|
|
438 |
reader>>*data;
|
|
439 |
qDebug()<<"operationId = "<<operationId;
|
|
440 |
qDebug()<<"data size = "<<data->size();
|
|
441 |
emit m_musicSearch->customDataAvailable(operationId, data);
|
|
442 |
break;
|
|
443 |
}
|
|
444 |
|
|
445 |
default:
|
|
446 |
User::Panic(_L("Music Search Private = "),opcode);
|
|
447 |
}
|
|
448 |
}
|
|
449 |
//SmfMusicSearchPrivate end
|
|
450 |
|
|
451 |
|
|
452 |
//SmfPlaylistServicePrivate start
|
|
453 |
SmfPlaylistServicePrivate::SmfPlaylistServicePrivate(SmfPlaylistService *aPlayLstSrvc)
|
|
454 |
: m_playlstSrvc(aPlayLstSrvc)
|
|
455 |
{
|
|
456 |
#ifdef Q_OS_SYMBIAN
|
|
457 |
//private impl for symbian
|
|
458 |
m_SmfClientPrivate = CSmfClientSymbian::NewL(this);
|
|
459 |
#else
|
|
460 |
//TODO:- Use private impl for other platforms or else Qt impl
|
|
461 |
#endif
|
|
462 |
}
|
|
463 |
|
|
464 |
SmfPlaylistServicePrivate::~SmfPlaylistServicePrivate()
|
|
465 |
{
|
|
466 |
if(m_SmfClientPrivate)
|
|
467 |
{
|
|
468 |
delete m_SmfClientPrivate;
|
|
469 |
m_SmfClientPrivate = NULL;
|
|
470 |
}
|
|
471 |
}
|
|
472 |
|
|
473 |
void SmfPlaylistServicePrivate::playlists(int pageNum, int perPage)
|
|
474 |
{
|
|
475 |
//We need to pass Opcode and SmfProvider serialized into bytearray
|
|
476 |
SmfProvider* m_baseProvider = m_playlstSrvc->getProvider();
|
|
477 |
m_serializedDataToServer.clear();
|
|
478 |
QDataStream write(&m_serializedDataToServer,QIODevice::WriteOnly);
|
|
479 |
write<<*(m_baseProvider);
|
|
480 |
m_argFlag = 1;
|
|
481 |
write<<m_argFlag;
|
|
482 |
write<<pageNum;
|
|
483 |
write<<m_argFlag;
|
|
484 |
write<<perPage;
|
|
485 |
|
|
486 |
QString intfName(playlistServiceInterface);
|
|
487 |
//TODO:-revisit all the maxalloc
|
|
488 |
int maxalloc = 1000;
|
|
489 |
|
|
490 |
//call private impl's send method
|
|
491 |
m_SmfClientPrivate->sendRequest(m_serializedDataToServer, intfName,
|
|
492 |
SmfMusicGetPlaylists, maxalloc);
|
|
493 |
}
|
|
494 |
|
|
495 |
void SmfPlaylistServicePrivate::playlistsOf(SmfMusicProfile *user, int pageNum, int perPage)
|
|
496 |
{
|
|
497 |
//We need to pass Opcode and SmfProvider serialized into bytearray
|
|
498 |
SmfProvider* m_baseProvider = m_playlstSrvc->getProvider();
|
|
499 |
m_serializedDataToServer.clear();
|
|
500 |
QDataStream write(&m_serializedDataToServer,QIODevice::WriteOnly);
|
|
501 |
write<<*(m_baseProvider);
|
|
502 |
if(user)
|
|
503 |
{
|
|
504 |
m_argFlag = 1;
|
|
505 |
write<<m_argFlag;
|
|
506 |
write<<*user;
|
|
507 |
}
|
|
508 |
else
|
|
509 |
{
|
|
510 |
m_argFlag = 0;
|
|
511 |
write<<m_argFlag;
|
|
512 |
}
|
|
513 |
m_argFlag = 1;
|
|
514 |
write<<m_argFlag;
|
|
515 |
write<<pageNum;
|
|
516 |
write<<m_argFlag;
|
|
517 |
write<<perPage;
|
|
518 |
|
|
519 |
QString intfName(playlistServiceInterface);
|
|
520 |
//TODO:-revisit all the maxalloc
|
|
521 |
int maxalloc = 1000;
|
|
522 |
|
|
523 |
//call private impl's send method
|
|
524 |
m_SmfClientPrivate->sendRequest(m_serializedDataToServer, intfName,
|
|
525 |
SmfMusicGetPlaylistsOfUser, maxalloc);
|
|
526 |
}
|
|
527 |
|
|
528 |
int SmfPlaylistServicePrivate::addToPlaylist(SmfPlaylist plst, SmfTrackInfoList *tracks)
|
|
529 |
{
|
|
530 |
//We need to pass Opcode and SmfProvider serialized into bytearray
|
|
531 |
SmfProvider* m_baseProvider = m_playlstSrvc->getProvider();
|
|
532 |
m_serializedDataToServer.clear();
|
|
533 |
QDataStream write(&m_serializedDataToServer,QIODevice::WriteOnly);
|
|
534 |
write<<*(m_baseProvider);
|
|
535 |
m_argFlag = 1;
|
|
536 |
write<<m_argFlag;
|
|
537 |
write<<plst;
|
|
538 |
if(tracks)
|
|
539 |
{
|
|
540 |
write<<m_argFlag;
|
|
541 |
write<<*tracks;
|
|
542 |
}
|
|
543 |
else
|
|
544 |
{
|
|
545 |
m_argFlag = 0;
|
|
546 |
write<<m_argFlag;
|
|
547 |
}
|
|
548 |
|
|
549 |
QString intfName(playlistServiceInterface);
|
|
550 |
//TODO:-revisit all the maxalloc
|
|
551 |
int maxalloc = 1000;
|
|
552 |
|
|
553 |
//call private impl's send method
|
|
554 |
return m_SmfClientPrivate->sendRequest(m_serializedDataToServer, intfName,
|
|
555 |
SmfMusicAddToPlaylist, maxalloc);
|
|
556 |
}
|
|
557 |
|
|
558 |
int SmfPlaylistServicePrivate::postCurrentPlayingPlaylist(SmfPlaylist plst)
|
|
559 |
{
|
|
560 |
//We need to pass Opcode and SmfProvider serialized into bytearray
|
|
561 |
SmfProvider* m_baseProvider = m_playlstSrvc->getProvider();
|
|
562 |
m_serializedDataToServer.clear();
|
|
563 |
QDataStream write(&m_serializedDataToServer,QIODevice::WriteOnly);
|
|
564 |
write<<*(m_baseProvider);
|
|
565 |
m_argFlag = 1;
|
|
566 |
write<<m_argFlag;
|
|
567 |
write<<plst;
|
|
568 |
|
|
569 |
QString intfName(playlistServiceInterface);
|
|
570 |
//TODO:-revisit all the maxalloc
|
|
571 |
int maxalloc = 1000;
|
|
572 |
|
|
573 |
//call private impl's send method
|
|
574 |
return m_SmfClientPrivate->sendRequest(m_serializedDataToServer, intfName,
|
|
575 |
SmfMusicPostCurrentPlayingPlaylist, maxalloc);
|
|
576 |
}
|
|
577 |
|
|
578 |
void SmfPlaylistServicePrivate::customRequest ( const int& operationId, QByteArray* customData )
|
|
579 |
{
|
|
580 |
//We need to pass Opcode and SmfProvider serialized into bytearray
|
|
581 |
SmfProvider* m_baseProvider = m_playlstSrvc->getProvider();
|
|
582 |
m_serializedDataToServer.clear();
|
|
583 |
QDataStream write(&m_serializedDataToServer,QIODevice::WriteOnly);
|
|
584 |
write<<*m_baseProvider;
|
|
585 |
m_argFlag = 1;
|
|
586 |
write<<m_argFlag;
|
|
587 |
write<<operationId;
|
|
588 |
|
|
589 |
if(customData)
|
|
590 |
{
|
|
591 |
write<<m_argFlag;
|
|
592 |
write<<*customData;
|
|
593 |
}
|
|
594 |
else
|
|
595 |
{
|
|
596 |
m_argFlag = 0;
|
|
597 |
write<<m_argFlag;
|
|
598 |
}
|
|
599 |
|
|
600 |
QString intfName(playlistServiceInterface);
|
|
601 |
//TODO:-revisit all the maxalloc
|
|
602 |
int maxalloc = 1000;
|
|
603 |
|
|
604 |
//call private impl's send method
|
|
605 |
m_SmfClientPrivate->sendRequest(m_serializedDataToServer, intfName,
|
|
606 |
SmfMusicPlaylistCustomRequest, maxalloc);
|
|
607 |
}
|
|
608 |
|
|
609 |
void SmfPlaylistServicePrivate::resultsAvailable(QByteArray result, SmfRequestTypeID opcode, SmfError error)
|
|
610 |
{
|
|
611 |
//note:- "result" is serialized and we need to de-serialize it as per opcode
|
|
612 |
//Order of serialization Error value followed by data
|
|
613 |
|
|
614 |
QDataStream reader(&result,QIODevice::ReadOnly);
|
|
615 |
|
|
616 |
//Now de-serialize it based on opcode
|
|
617 |
switch(opcode)
|
|
618 |
{
|
|
619 |
case SmfMusicGetPlaylists:
|
|
620 |
case SmfMusicGetPlaylistsOfUser:
|
|
621 |
{
|
|
622 |
SmfPlaylistList* m_playlistList = new SmfPlaylistList;
|
|
623 |
reader>>*(m_playlistList);
|
|
624 |
|
|
625 |
//ToDo:-
|
|
626 |
SmfResultPage page;
|
|
627 |
|
|
628 |
emit m_playlstSrvc->playlistsListAvailable(m_playlistList,error,page);
|
|
629 |
break;
|
|
630 |
}
|
|
631 |
|
|
632 |
case SmfMusicAddToPlaylist:
|
|
633 |
case SmfMusicPostCurrentPlayingPlaylist:
|
|
634 |
{
|
|
635 |
emit m_playlstSrvc->playlistUpdated(error);
|
|
636 |
break;
|
|
637 |
}
|
|
638 |
|
|
639 |
case SmfMusicPlaylistCustomRequest:
|
|
640 |
{
|
|
641 |
int operationId;
|
|
642 |
QByteArray *data = new QByteArray;
|
|
643 |
reader>>operationId;
|
|
644 |
reader>>*data;
|
|
645 |
qDebug()<<"operationId = "<<operationId;
|
|
646 |
qDebug()<<"data size = "<<data->size();
|
|
647 |
emit m_playlstSrvc->customDataAvailable(operationId, data);
|
|
648 |
break;
|
|
649 |
}
|
|
650 |
default:
|
|
651 |
Q_ASSERT_X(1,"SmfPlaylistServicePrivate::resultsAvailable","unknown opcode");
|
|
652 |
}
|
|
653 |
}
|
|
654 |
//SmfPlaylistServicePrivate end
|
|
655 |
|
|
656 |
|
|
657 |
//SmfMusicEventsPrivate start
|
|
658 |
SmfMusicEventsPrivate::SmfMusicEventsPrivate(SmfMusicEvents *aMusicEvent)
|
|
659 |
:m_musicEvent(aMusicEvent)
|
|
660 |
{
|
|
661 |
#ifdef Q_OS_SYMBIAN
|
|
662 |
//private impl for symbian
|
|
663 |
m_SmfClientPrivate = CSmfClientSymbian::NewL(this);
|
|
664 |
#else
|
|
665 |
//TODO:- Use private impl for other platforms or else Qt impl
|
|
666 |
#endif
|
|
667 |
}
|
|
668 |
|
|
669 |
SmfMusicEventsPrivate::~SmfMusicEventsPrivate()
|
|
670 |
{
|
|
671 |
if(m_SmfClientPrivate)
|
|
672 |
{
|
|
673 |
delete m_SmfClientPrivate;
|
|
674 |
m_SmfClientPrivate = NULL;
|
|
675 |
}
|
|
676 |
}
|
|
677 |
|
|
678 |
void SmfMusicEventsPrivate::events(SmfLocation venue, int pageNum, int perPage)
|
|
679 |
{
|
|
680 |
//We need to pass Opcode and SmfProvider serialized into bytearray
|
|
681 |
SmfProvider* m_baseProvider = m_musicEvent->getProvider();
|
|
682 |
m_serializedDataToServer.clear();
|
|
683 |
QDataStream write(&m_serializedDataToServer,QIODevice::WriteOnly);
|
|
684 |
write<<*(m_baseProvider);
|
|
685 |
m_argFlag = 1;
|
|
686 |
write<<m_argFlag;
|
|
687 |
write<<venue;
|
|
688 |
write<<m_argFlag;
|
|
689 |
write<<pageNum;
|
|
690 |
write<<m_argFlag;
|
|
691 |
write<<perPage;
|
|
692 |
|
|
693 |
QString intfName(musicEventServiceInterface);
|
|
694 |
//TODO:-revisit all the maxalloc
|
|
695 |
int maxalloc = 1000;
|
|
696 |
|
|
697 |
//call private impl's send method
|
|
698 |
m_SmfClientPrivate->sendRequest(m_serializedDataToServer, intfName,
|
|
699 |
SmfMusicGetEventsOnLoc, maxalloc);
|
|
700 |
}
|
|
701 |
|
|
702 |
void SmfMusicEventsPrivate::venues(SmfLocation location, int pageNum, int perPage)
|
|
703 |
{
|
|
704 |
//We need to pass Opcode and SmfProvider serialized into bytearray
|
|
705 |
SmfProvider* m_baseProvider = m_musicEvent->getProvider();
|
|
706 |
m_serializedDataToServer.clear();
|
|
707 |
QDataStream write(&m_serializedDataToServer,QIODevice::WriteOnly);
|
|
708 |
write<<*(m_baseProvider);
|
|
709 |
m_argFlag = 1;
|
|
710 |
write<<m_argFlag;
|
|
711 |
write<<location;
|
|
712 |
write<<m_argFlag;
|
|
713 |
write<<pageNum;
|
|
714 |
write<<m_argFlag;
|
|
715 |
write<<perPage;
|
|
716 |
|
|
717 |
QString intfName(musicEventServiceInterface);
|
|
718 |
//TODO:-revisit all the maxalloc
|
|
719 |
int maxalloc = 1000;
|
|
720 |
|
|
721 |
//call private impl's send method
|
|
722 |
m_SmfClientPrivate->sendRequest(m_serializedDataToServer, intfName,
|
|
723 |
SmfMusicGetVenueOnLoc, maxalloc);
|
|
724 |
}
|
|
725 |
|
|
726 |
void SmfMusicEventsPrivate::postEvents(SmfEventList events)
|
|
727 |
{
|
|
728 |
//We need to pass Opcode and SmfProvider serialized into bytearray
|
|
729 |
SmfProvider* m_baseProvider = m_musicEvent->getProvider();
|
|
730 |
m_serializedDataToServer.clear();
|
|
731 |
QDataStream write(&m_serializedDataToServer,QIODevice::WriteOnly);
|
|
732 |
write<<*(m_baseProvider);
|
|
733 |
m_argFlag = 1;
|
|
734 |
write<<m_argFlag;
|
|
735 |
write<<events;
|
|
736 |
|
|
737 |
QString intfName(musicEventServiceInterface);
|
|
738 |
//TODO:-revisit all the maxalloc
|
|
739 |
int maxalloc = 1000;
|
|
740 |
|
|
741 |
//call private impl's send method
|
|
742 |
m_SmfClientPrivate->sendRequest(m_serializedDataToServer, intfName,
|
|
743 |
SmfMusicPostEvents, maxalloc);
|
|
744 |
}
|
|
745 |
|
|
746 |
void SmfMusicEventsPrivate::customRequest ( const int& operationId, QByteArray* customData )
|
|
747 |
{
|
|
748 |
//We need to pass Opcode and SmfProvider serialized into bytearray
|
|
749 |
SmfProvider* m_baseProvider = m_musicEvent->getProvider();
|
|
750 |
m_serializedDataToServer.clear();
|
|
751 |
QDataStream write(&m_serializedDataToServer,QIODevice::WriteOnly);
|
|
752 |
write<<*m_baseProvider;
|
|
753 |
m_argFlag = 1;
|
|
754 |
write<<m_argFlag;
|
|
755 |
write<<operationId;
|
|
756 |
|
|
757 |
if(customData)
|
|
758 |
{
|
|
759 |
write<<m_argFlag;
|
|
760 |
write<<*customData;
|
|
761 |
}
|
|
762 |
else
|
|
763 |
{
|
|
764 |
m_argFlag = 0;
|
|
765 |
write<<m_argFlag;
|
|
766 |
}
|
|
767 |
|
|
768 |
QString intfName(musicEventServiceInterface);
|
|
769 |
//TODO:-revisit all the maxalloc
|
|
770 |
int maxalloc = 1000;
|
|
771 |
|
|
772 |
//call private impl's send method
|
|
773 |
m_SmfClientPrivate->sendRequest(m_serializedDataToServer, intfName,
|
|
774 |
SmfMusicEventsCustomRequest, maxalloc);
|
|
775 |
}
|
|
776 |
|
|
777 |
void SmfMusicEventsPrivate::resultsAvailable(QByteArray result,SmfRequestTypeID opcode,SmfError error)
|
|
778 |
{
|
|
779 |
//note:- "result" is serialized and we need to de-serialize it as per opcode
|
|
780 |
//Order of serialization Error value followed by data
|
|
781 |
|
|
782 |
QDataStream reader(&result,QIODevice::ReadOnly);
|
|
783 |
|
|
784 |
//Now de-serialize it based on opcode
|
|
785 |
switch(opcode)
|
|
786 |
{
|
|
787 |
case SmfMusicGetEventsOnLoc:
|
|
788 |
{
|
|
789 |
SmfEventList* m_events = new SmfEventList;
|
|
790 |
reader>>*(m_events);
|
|
791 |
|
|
792 |
// ToDo :-
|
|
793 |
SmfResultPage page;
|
|
794 |
|
|
795 |
m_musicEvent->eventsAvailable(m_events,error,page);
|
|
796 |
break;
|
|
797 |
}
|
|
798 |
|
|
799 |
case SmfMusicGetVenueOnLoc:
|
|
800 |
{
|
|
801 |
SmfLocationList* m_venues = new SmfLocationList;
|
|
802 |
reader>>*(m_venues);
|
|
803 |
|
|
804 |
//ToDo :-
|
|
805 |
SmfResultPage page;
|
|
806 |
|
|
807 |
m_musicEvent->venuesAvailable(m_venues,error,page);
|
|
808 |
break;
|
|
809 |
}
|
|
810 |
|
|
811 |
case SmfMusicPostEvents:
|
|
812 |
m_musicEvent->eventsUpdated(error);
|
|
813 |
break;
|
|
814 |
|
|
815 |
case SmfMusicEventsCustomRequest:
|
|
816 |
{
|
|
817 |
int operationId;
|
|
818 |
QByteArray *data = new QByteArray;
|
|
819 |
reader>>operationId;
|
|
820 |
reader>>*data;
|
|
821 |
qDebug()<<"operationId = "<<operationId;
|
|
822 |
qDebug()<<"data size = "<<data->size();
|
|
823 |
emit m_musicEvent->customDataAvailable(operationId, data);
|
|
824 |
break;
|
|
825 |
}
|
|
826 |
|
|
827 |
default:
|
|
828 |
Q_ASSERT_X(1,"SmfMusicEventsPrivate::resultsAvailable","unknown opcode");
|
|
829 |
}
|
|
830 |
}
|
|
831 |
//SmfMusicEventsPrivate end
|
|
832 |
|
|
833 |
|
|
834 |
//SmfLyricsServicePrivate start
|
|
835 |
SmfLyricsServicePrivate::SmfLyricsServicePrivate(SmfLyricsService *aLyricsSrvc)
|
|
836 |
: m_lyricsSrvc(aLyricsSrvc)
|
|
837 |
{
|
|
838 |
#ifdef Q_OS_SYMBIAN
|
|
839 |
//private impl for symbian
|
|
840 |
m_SmfClientPrivate = CSmfClientSymbian::NewL(this);
|
|
841 |
#else
|
|
842 |
//TODO:- Use private impl for other platforms or else Qt impl
|
|
843 |
#endif
|
|
844 |
}
|
|
845 |
|
|
846 |
SmfLyricsServicePrivate::~SmfLyricsServicePrivate()
|
|
847 |
{
|
|
848 |
if(m_SmfClientPrivate)
|
|
849 |
{
|
|
850 |
delete m_SmfClientPrivate;
|
|
851 |
m_SmfClientPrivate = NULL;
|
|
852 |
}
|
|
853 |
}
|
|
854 |
|
|
855 |
void SmfLyricsServicePrivate::lyrics(SmfTrackInfo track, int pageNum, int perPage)
|
|
856 |
{
|
|
857 |
//We need to pass Opcode and SmfProvider serialized into bytearray
|
|
858 |
SmfProvider* m_baseProvider = m_lyricsSrvc->getProvider();
|
|
859 |
m_serializedDataToServer.clear();
|
|
860 |
QDataStream write(&m_serializedDataToServer,QIODevice::WriteOnly);
|
|
861 |
write<<*(m_baseProvider);
|
|
862 |
m_argFlag = 1;
|
|
863 |
write<<m_argFlag;
|
|
864 |
write<<track;
|
|
865 |
write<<m_argFlag;
|
|
866 |
write<<pageNum;
|
|
867 |
write<<m_argFlag;
|
|
868 |
write<<perPage;
|
|
869 |
|
|
870 |
QString intfName(lyricsServiceInterface);
|
|
871 |
//TODO:-revisit all the maxalloc
|
|
872 |
int maxalloc = 1000;
|
|
873 |
|
|
874 |
//call private impl's send method
|
|
875 |
m_SmfClientPrivate->sendRequest(m_serializedDataToServer, intfName,
|
|
876 |
SmfMusicGetLyrics, maxalloc);
|
|
877 |
}
|
|
878 |
|
|
879 |
void SmfLyricsServicePrivate::subtitles(SmfTrackInfo track, SmfSubtitleSearchFilter filter,
|
|
880 |
int pageNum, int perPage)
|
|
881 |
{
|
|
882 |
//We need to pass Opcode and SmfProvider serialized into bytearray
|
|
883 |
SmfProvider* m_baseProvider = m_lyricsSrvc->getProvider();
|
|
884 |
QDataStream write(&m_serializedDataToServer,QIODevice::WriteOnly);
|
|
885 |
write<<*(m_baseProvider);
|
|
886 |
m_argFlag = 1;
|
|
887 |
write<<m_argFlag;
|
|
888 |
write<<track;
|
|
889 |
write<<m_argFlag;
|
|
890 |
write<<filter;
|
|
891 |
write<<m_argFlag;
|
|
892 |
write<<pageNum;
|
|
893 |
write<<m_argFlag;
|
|
894 |
write<<perPage;
|
|
895 |
|
|
896 |
QString intfName(lyricsServiceInterface);
|
|
897 |
//TODO:-revisit all the maxalloc
|
|
898 |
int maxalloc = 1000;
|
|
899 |
|
|
900 |
//call private impl's send method
|
|
901 |
m_SmfClientPrivate->sendRequest(m_serializedDataToServer, intfName,
|
|
902 |
SmfMusicGetSubtitle, maxalloc);
|
|
903 |
}
|
|
904 |
|
|
905 |
void SmfLyricsServicePrivate::customRequest ( const int& operationId, QByteArray* customData )
|
|
906 |
{
|
|
907 |
//We need to pass Opcode and SmfProvider serialized into bytearray
|
|
908 |
SmfProvider* m_baseProvider = m_lyricsSrvc->getProvider();
|
|
909 |
m_serializedDataToServer.clear();
|
|
910 |
QDataStream write(&m_serializedDataToServer,QIODevice::WriteOnly);
|
|
911 |
write<<*m_baseProvider;
|
|
912 |
m_argFlag = 1;
|
|
913 |
write<<m_argFlag;
|
|
914 |
write<<operationId;
|
|
915 |
|
|
916 |
if(customData)
|
|
917 |
{
|
|
918 |
write<<m_argFlag;
|
|
919 |
write<<*customData;
|
|
920 |
}
|
|
921 |
else
|
|
922 |
{
|
|
923 |
m_argFlag = 0;
|
|
924 |
write<<m_argFlag;
|
|
925 |
}
|
|
926 |
|
|
927 |
QString intfName(lyricsServiceInterface);
|
|
928 |
//TODO:-revisit all the maxalloc
|
|
929 |
int maxalloc = 1000;
|
|
930 |
|
|
931 |
//call private impl's send method
|
|
932 |
m_SmfClientPrivate->sendRequest(m_serializedDataToServer, intfName,
|
|
933 |
SmfMusicLyricsCustomRequest, maxalloc);
|
|
934 |
}
|
|
935 |
|
|
936 |
void SmfLyricsServicePrivate::resultsAvailable(QByteArray result, SmfRequestTypeID opcode, SmfError error)
|
|
937 |
{
|
|
938 |
//note:- "result" is serialized and we need to de-serialize it as per opcode
|
|
939 |
|
|
940 |
QDataStream reader(&result,QIODevice::ReadOnly);
|
|
941 |
|
|
942 |
//Now de-serialize it based on opcode
|
|
943 |
switch(opcode)
|
|
944 |
{
|
|
945 |
case SmfMusicGetLyrics:
|
|
946 |
{
|
|
947 |
SmfLyricsList* m_lyricsList = new SmfLyricsList;
|
|
948 |
reader>>*(m_lyricsList);
|
|
949 |
|
|
950 |
// ToDo :-
|
|
951 |
SmfResultPage page;
|
|
952 |
|
|
953 |
emit m_lyricsSrvc->lyricsAvailable(m_lyricsList,error,page);
|
|
954 |
break;
|
|
955 |
}
|
|
956 |
|
|
957 |
case SmfMusicGetSubtitle:
|
|
958 |
{
|
|
959 |
SmfSubtitleList* m_subList = new SmfSubtitleList;
|
|
960 |
reader>>*(m_subList);
|
|
961 |
|
|
962 |
// ToDo :-
|
|
963 |
SmfResultPage page;
|
|
964 |
|
|
965 |
emit m_lyricsSrvc->subtitleAvailable(m_subList,error,page);
|
|
966 |
break;
|
|
967 |
}
|
|
968 |
|
|
969 |
case SmfMusicLyricsCustomRequest:
|
|
970 |
{
|
|
971 |
int operationId;
|
|
972 |
QByteArray *data = new QByteArray;
|
|
973 |
reader>>operationId;
|
|
974 |
reader>>*data;
|
|
975 |
qDebug()<<"operationId = "<<operationId;
|
|
976 |
qDebug()<<"data size = "<<data->size();
|
|
977 |
emit m_lyricsSrvc->customDataAvailable(operationId, data);
|
|
978 |
break;
|
|
979 |
}
|
|
980 |
|
|
981 |
default:
|
|
982 |
Q_ASSERT_X(1,"SmfLyricsServicePrivate::resultsAvailable","unknown opcode");
|
|
983 |
}
|
|
984 |
}
|
|
985 |
|
|
986 |
//SmfLyricsServicePrivate end
|