30
|
1 |
/*
|
|
2 |
* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
|
|
3 |
* All rights reserved.
|
|
4 |
* This component and the accompanying materials are made available
|
|
5 |
* under the terms of "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 |
* Nokia Corporation - initial contribution.
|
|
11 |
*
|
|
12 |
* Contributors:
|
|
13 |
*
|
|
14 |
* Description: VideoCollectionClient class implementation
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
// INCLUDE FILES
|
|
19 |
#include <QObject>
|
|
20 |
#include <centralrepository.h>
|
|
21 |
#include <mpxcollectionutility.h>
|
|
22 |
#include <mpxcollectionpath.h>
|
|
23 |
#include <mpxmediageneraldefs.h>
|
|
24 |
#include <mpxmessagegeneraldefs.h>
|
|
25 |
#include <mpxmessage2.h>
|
|
26 |
#include <mpxcollectionmessagedefs.h>
|
|
27 |
#include <mpxcollectionmessage.h>
|
|
28 |
#include <mpxmessagecontainerdefs.h>
|
|
29 |
#include <mpxmediacontainerdefs.h>
|
|
30 |
#include <mpxcommandgeneraldefs.h>
|
|
31 |
#include <mpxcollectioncommanddefs.h>
|
|
32 |
#include <vcxmyvideosuids.h>
|
|
33 |
|
|
34 |
#include "videodatasignalreceiver.h"
|
|
35 |
#include "videocollectionclient.h"
|
|
36 |
#include "videocollectionlistener.h"
|
|
37 |
|
|
38 |
// -----------------------------------------------------------------------------
|
|
39 |
// VideoCollectionClient()
|
|
40 |
// -----------------------------------------------------------------------------
|
|
41 |
//
|
|
42 |
VideoCollectionClient::VideoCollectionClient() :
|
|
43 |
mCollectionUtility(0),
|
|
44 |
mCollectionOpenStatus(ECollectionNotOpen),
|
|
45 |
mCollectionListener(0),
|
34
|
46 |
mOpenCategoryAlbum(TMPXItemId::InvalidId()),
|
|
47 |
mCollectionPathLevel(VideoCollectionCommon::ELevelInvalid)
|
30
|
48 |
{
|
|
49 |
|
|
50 |
}
|
|
51 |
|
|
52 |
// -----------------------------------------------------------------------------
|
|
53 |
// initialize()
|
|
54 |
// -----------------------------------------------------------------------------
|
|
55 |
//
|
34
|
56 |
int VideoCollectionClient::initialize(VideoDataSignalReceiver *signalReceiver)
|
30
|
57 |
{
|
34
|
58 |
if(!signalReceiver)
|
|
59 |
{
|
|
60 |
return -1;
|
|
61 |
}
|
30
|
62 |
if(mCollectionUtility && mCollectionListener)
|
|
63 |
{
|
|
64 |
// already initialized
|
|
65 |
return 0;
|
|
66 |
}
|
|
67 |
if(!mCollectionListener)
|
|
68 |
{
|
34
|
69 |
mCollectionListener = new VideoCollectionListener(*this, *signalReceiver);
|
30
|
70 |
if(!mCollectionListener)
|
|
71 |
{
|
|
72 |
return -1;
|
|
73 |
}
|
|
74 |
}
|
|
75 |
if(!mCollectionUtility)
|
|
76 |
{
|
|
77 |
TRAPD( error, mCollectionUtility = MMPXCollectionUtility::NewL( mCollectionListener, KMcModeDefault ) );
|
|
78 |
if(error)
|
|
79 |
{
|
|
80 |
delete mCollectionListener;
|
|
81 |
mCollectionListener = 0;
|
|
82 |
return error;
|
|
83 |
}
|
|
84 |
}
|
|
85 |
return 0;
|
|
86 |
}
|
|
87 |
|
|
88 |
// -----------------------------------------------------------------------------
|
|
89 |
// ~VideoCollectionClient()
|
|
90 |
// -----------------------------------------------------------------------------
|
|
91 |
//
|
|
92 |
VideoCollectionClient::~VideoCollectionClient()
|
|
93 |
{
|
|
94 |
if (mCollectionUtility)
|
|
95 |
{
|
|
96 |
// closing deallocates collection utility pointer
|
|
97 |
mCollectionUtility->Close();
|
|
98 |
}
|
|
99 |
delete mCollectionListener;
|
|
100 |
}
|
|
101 |
|
|
102 |
// ---------------------------------------------------------------------------
|
|
103 |
// categoryIds
|
|
104 |
// ---------------------------------------------------------------------------
|
|
105 |
//
|
34
|
106 |
|
|
107 |
void VideoCollectionClient::getCategoryId(TMPXItemId &id)
|
30
|
108 |
{
|
34
|
109 |
id = mOpenCategoryAlbum;
|
30
|
110 |
}
|
|
111 |
|
|
112 |
// ---------------------------------------------------------------------------
|
|
113 |
// getCollectionLevel
|
|
114 |
// ---------------------------------------------------------------------------
|
|
115 |
//
|
|
116 |
int VideoCollectionClient::getCollectionLevel()
|
|
117 |
{
|
|
118 |
return mCollectionPathLevel;
|
|
119 |
}
|
|
120 |
|
|
121 |
// ---------------------------------------------------------------------------
|
|
122 |
// getOpenStatus
|
|
123 |
// ---------------------------------------------------------------------------
|
|
124 |
//
|
|
125 |
int VideoCollectionClient::getOpenStatus()
|
|
126 |
{
|
|
127 |
return mCollectionOpenStatus;
|
|
128 |
}
|
|
129 |
|
|
130 |
// ---------------------------------------------------------------------------
|
|
131 |
// setOpenStatus
|
|
132 |
// ---------------------------------------------------------------------------
|
|
133 |
//
|
|
134 |
void VideoCollectionClient::setOpenStatus(int status)
|
|
135 |
{
|
|
136 |
mCollectionOpenStatus = status;
|
|
137 |
if(mCollectionOpenStatus == ECollectionOpened)
|
|
138 |
{
|
|
139 |
startOpenCurrentState();
|
|
140 |
}
|
|
141 |
}
|
|
142 |
|
|
143 |
// -----------------------------------------------------------------------------
|
|
144 |
// startOpenCollection
|
|
145 |
// -----------------------------------------------------------------------------
|
|
146 |
//
|
|
147 |
int VideoCollectionClient::startOpenCollection(int level)
|
|
148 |
{
|
|
149 |
if(!mCollectionUtility)
|
|
150 |
{
|
|
151 |
return -1;
|
|
152 |
}
|
|
153 |
|
|
154 |
if((mCollectionOpenStatus == ECollectionOpening) && (getCollectionLevel() == level))
|
|
155 |
{
|
|
156 |
// allready opening/opened
|
|
157 |
return 0;
|
|
158 |
}
|
|
159 |
mCollectionOpenStatus = ECollectionNotOpen;
|
|
160 |
TRAPD(error, startOpenCollectionL(level));
|
|
161 |
return error;
|
|
162 |
}
|
|
163 |
|
|
164 |
// -----------------------------------------------------------------------------
|
|
165 |
// startOpenCurrentState
|
|
166 |
// -----------------------------------------------------------------------------
|
|
167 |
//
|
|
168 |
int VideoCollectionClient::startOpenCurrentState()
|
|
169 |
{
|
|
170 |
int error = -1;
|
|
171 |
if(mCollectionUtility && mCollectionOpenStatus == ECollectionOpened)
|
|
172 |
{
|
|
173 |
TRAP(error, mCollectionUtility->Collection().OpenL());
|
|
174 |
}
|
|
175 |
return error;
|
|
176 |
}
|
|
177 |
|
|
178 |
// -----------------------------------------------------------------------------
|
|
179 |
// deleteFile
|
|
180 |
// -----------------------------------------------------------------------------
|
|
181 |
int VideoCollectionClient::deleteVideos(QList<TMPXItemId> *mediaIds)
|
|
182 |
{
|
|
183 |
if(!mCollectionUtility || !mediaIds)
|
|
184 |
{
|
|
185 |
return -1;
|
|
186 |
}
|
|
187 |
TRAPD(error, deleteVideosL(*mediaIds));
|
|
188 |
return error;
|
|
189 |
}
|
|
190 |
|
|
191 |
// -----------------------------------------------------------------------------
|
34
|
192 |
// openItem
|
30
|
193 |
// -----------------------------------------------------------------------------
|
|
194 |
//
|
34
|
195 |
int VideoCollectionClient::openItem(TMPXItemId &mediaId)
|
30
|
196 |
{
|
|
197 |
if(!mCollectionUtility)
|
|
198 |
{
|
|
199 |
return -1;
|
|
200 |
}
|
|
201 |
|
|
202 |
TInt error;
|
34
|
203 |
if (mediaId.iId2 == KVcxMvcMediaTypeVideo)
|
30
|
204 |
{
|
|
205 |
TRAP(error, openVideoL(mediaId));
|
|
206 |
}
|
|
207 |
else
|
|
208 |
{
|
|
209 |
TRAP(error, openCategoryL(mediaId));
|
|
210 |
}
|
|
211 |
return error;
|
|
212 |
}
|
|
213 |
|
|
214 |
// -----------------------------------------------------------------------------
|
|
215 |
// back
|
|
216 |
// -----------------------------------------------------------------------------
|
|
217 |
//
|
|
218 |
int VideoCollectionClient::back()
|
|
219 |
{
|
|
220 |
if(!mCollectionUtility)
|
|
221 |
{
|
|
222 |
return -1;
|
|
223 |
}
|
|
224 |
TRAPD(error, backL());
|
|
225 |
return error;
|
|
226 |
}
|
|
227 |
|
|
228 |
// -----------------------------------------------------------------------------
|
|
229 |
// fetchMpxMediaByMpxId
|
|
230 |
// -----------------------------------------------------------------------------
|
|
231 |
//
|
|
232 |
int VideoCollectionClient::fetchMpxMediaByMpxId(TMPXItemId &mpxId)
|
|
233 |
{
|
|
234 |
if(!mCollectionUtility)
|
|
235 |
{
|
|
236 |
return -1;
|
|
237 |
}
|
|
238 |
|
|
239 |
TRAPD(error, fetchMpxMediaByMpxIdL(mpxId));
|
|
240 |
return error;
|
|
241 |
}
|
|
242 |
|
|
243 |
// -----------------------------------------------------------------------------
|
|
244 |
// getVideoDetails
|
|
245 |
// -----------------------------------------------------------------------------
|
|
246 |
//
|
|
247 |
int VideoCollectionClient::getVideoDetails(TMPXItemId &mediaId)
|
|
248 |
{
|
|
249 |
if(!mCollectionUtility)
|
|
250 |
{
|
|
251 |
return -1;
|
|
252 |
}
|
|
253 |
|
|
254 |
TRAPD(error, getVideoDetailsL(mediaId));
|
|
255 |
|
|
256 |
return error;
|
|
257 |
}
|
|
258 |
|
|
259 |
// -----------------------------------------------------------------------------
|
34
|
260 |
// addNewAlbum
|
|
261 |
// -----------------------------------------------------------------------------
|
|
262 |
//
|
|
263 |
TMPXItemId VideoCollectionClient::addNewAlbum(const QString &title)
|
|
264 |
{
|
|
265 |
TMPXItemId id = TMPXItemId::InvalidId();
|
|
266 |
|
|
267 |
if (mCollectionUtility && title.length())
|
|
268 |
{
|
|
269 |
TRAPD(err, id = createAlbumL(title));
|
|
270 |
if(err)
|
|
271 |
{
|
|
272 |
id = TMPXItemId::InvalidId();
|
|
273 |
}
|
|
274 |
}
|
|
275 |
|
|
276 |
return id;
|
|
277 |
}
|
|
278 |
|
|
279 |
// -----------------------------------------------------------------------------
|
|
280 |
// removeAlbums
|
30
|
281 |
// -----------------------------------------------------------------------------
|
|
282 |
//
|
34
|
283 |
int VideoCollectionClient::removeAlbums(const QList<TMPXItemId> &mediaIds)
|
30
|
284 |
{
|
34
|
285 |
int err(-1);
|
|
286 |
|
|
287 |
if (mCollectionUtility)
|
30
|
288 |
{
|
34
|
289 |
TRAP(err, removeAlbumsL(mediaIds));
|
|
290 |
}
|
|
291 |
|
|
292 |
return err;
|
|
293 |
}
|
|
294 |
|
|
295 |
// -----------------------------------------------------------------------------
|
|
296 |
// addItemsInAlbum
|
|
297 |
// -----------------------------------------------------------------------------
|
|
298 |
//
|
|
299 |
int VideoCollectionClient::addItemsInAlbum(TMPXItemId albumId,
|
|
300 |
const QList<TMPXItemId> &mediaIds)
|
|
301 |
{
|
|
302 |
int err(-1);
|
|
303 |
|
|
304 |
if (mCollectionUtility && albumId != TMPXItemId::InvalidId() &&
|
|
305 |
albumId.iId2 == KVcxMvcMediaTypeAlbum)
|
|
306 |
{
|
|
307 |
TRAP(err, addItemsInAlbumL(albumId, mediaIds));
|
30
|
308 |
}
|
|
309 |
|
34
|
310 |
return err;
|
30
|
311 |
}
|
|
312 |
|
|
313 |
// -----------------------------------------------------------------------------
|
|
314 |
// startOpenCollectionL
|
|
315 |
// -----------------------------------------------------------------------------
|
|
316 |
//
|
|
317 |
void VideoCollectionClient::startOpenCollectionL(int level)
|
|
318 |
{
|
|
319 |
if(!mCollectionUtility)
|
|
320 |
{
|
|
321 |
User::Leave(KErrGeneral);
|
|
322 |
}
|
|
323 |
CMPXCollectionPath* collectionPath = CMPXCollectionPath::NewL();
|
|
324 |
CleanupStack::PushL( collectionPath );
|
|
325 |
|
|
326 |
collectionPath->AppendL( KVcxUidMyVideosMpxCollection );
|
34
|
327 |
if (level == VideoCollectionCommon::ELevelVideos)
|
30
|
328 |
{
|
|
329 |
collectionPath->AppendL( KVcxMvcCategoryIdAll );
|
|
330 |
|
|
331 |
mOpenCategoryAlbum.iId1 = KVcxMvcCategoryIdAll;
|
|
332 |
mOpenCategoryAlbum.iId2 = 1;
|
|
333 |
|
34
|
334 |
mCollectionPathLevel = VideoCollectionCommon::ELevelVideos;
|
30
|
335 |
}
|
|
336 |
else
|
|
337 |
{
|
34
|
338 |
mOpenCategoryAlbum = TMPXItemId::InvalidId();
|
30
|
339 |
|
34
|
340 |
mCollectionPathLevel = VideoCollectionCommon::ELevelCategory;
|
30
|
341 |
}
|
|
342 |
mCollectionUtility->Collection().OpenL( *collectionPath );
|
|
343 |
CleanupStack::PopAndDestroy( collectionPath );
|
34
|
344 |
|
30
|
345 |
mCollectionOpenStatus = ECollectionOpening;
|
|
346 |
}
|
|
347 |
|
|
348 |
|
|
349 |
// -----------------------------------------------------------------------------
|
|
350 |
// deleteVideosL
|
|
351 |
// -----------------------------------------------------------------------------
|
|
352 |
//
|
|
353 |
void VideoCollectionClient::deleteVideosL(QList<TMPXItemId> &mediaIds)
|
|
354 |
{
|
|
355 |
if(!mCollectionUtility || mediaIds.count() == 0)
|
|
356 |
{
|
|
357 |
User::Leave(KErrGeneral);
|
|
358 |
}
|
|
359 |
CMPXMediaArray* mediasToDelete = CMPXMediaArray::NewL();
|
|
360 |
CleanupStack::PushL( mediasToDelete );
|
|
361 |
|
|
362 |
CMPXMedia* media = NULL;
|
|
363 |
|
|
364 |
TMPXItemId currentId;
|
|
365 |
foreach(currentId, mediaIds)
|
|
366 |
{
|
|
367 |
media = CMPXMedia::NewL();
|
|
368 |
CleanupStack::PushL( media );
|
|
369 |
media->SetTObjectValueL( KMPXMediaGeneralId, currentId );
|
|
370 |
mediasToDelete->AppendL( *media );
|
|
371 |
CleanupStack::PopAndDestroy( media );
|
|
372 |
}
|
|
373 |
|
|
374 |
CMPXCommand* cmd = CMPXMedia::NewL();
|
|
375 |
CleanupStack::PushL( cmd );
|
|
376 |
|
|
377 |
cmd->SetTObjectValueL( KMPXCommandGeneralId, KVcxCommandIdMyVideos );
|
|
378 |
cmd->SetTObjectValueL( KVcxMediaMyVideosCommandId, KVcxCommandMyVideosDelete );
|
|
379 |
cmd->SetTObjectValueL( KMPXCommandGeneralDoSync, EFalse );
|
|
380 |
cmd->SetTObjectValueL( KMPXCommandGeneralCollectionId,
|
|
381 |
TUid::Uid( KVcxUidMyVideosMpxCollection ) );
|
|
382 |
cmd->SetCObjectValueL( KMPXMediaArrayContents, mediasToDelete );
|
|
383 |
|
|
384 |
mCollectionUtility->Collection().CommandL( *cmd );
|
|
385 |
|
|
386 |
CleanupStack::PopAndDestroy( cmd );
|
|
387 |
CleanupStack::PopAndDestroy( mediasToDelete );
|
|
388 |
}
|
|
389 |
|
|
390 |
// -----------------------------------------------------------------------------
|
|
391 |
// openVideoL
|
|
392 |
// -----------------------------------------------------------------------------
|
|
393 |
//
|
|
394 |
void VideoCollectionClient::openVideoL(TMPXItemId &videoId)
|
|
395 |
{
|
|
396 |
if(!mCollectionUtility)
|
|
397 |
{
|
|
398 |
User::Leave(KErrGeneral);
|
|
399 |
}
|
|
400 |
CMPXCollectionPath* path = CMPXCollectionPath::NewL();
|
|
401 |
CleanupStack::PushL( path );
|
|
402 |
path->AppendL( KVcxUidMyVideosMpxCollection );
|
|
403 |
path->AppendL( KVcxMvcCategoryIdAll );
|
34
|
404 |
path->AppendL( videoId );
|
|
405 |
path->SelectL( videoId );
|
30
|
406 |
|
|
407 |
mCollectionUtility->Collection().OpenL( *path );
|
|
408 |
CleanupStack::PopAndDestroy( path );
|
|
409 |
}
|
|
410 |
|
|
411 |
// -----------------------------------------------------------------------------
|
|
412 |
// openCategoryL
|
|
413 |
// -----------------------------------------------------------------------------
|
|
414 |
//
|
|
415 |
void VideoCollectionClient::openCategoryL(TMPXItemId &id)
|
|
416 |
{
|
|
417 |
if(!mCollectionUtility)
|
|
418 |
{
|
|
419 |
User::Leave(KErrGeneral);
|
|
420 |
}
|
|
421 |
CMPXCollectionPath* collectionPath = CMPXCollectionPath::NewL();
|
|
422 |
CleanupStack::PushL( collectionPath );
|
|
423 |
|
|
424 |
collectionPath->AppendL( KVcxUidMyVideosMpxCollection );
|
|
425 |
collectionPath->AppendL( id );
|
|
426 |
mCollectionUtility->Collection().OpenL( *collectionPath );
|
|
427 |
CleanupStack::PopAndDestroy( collectionPath );
|
|
428 |
|
34
|
429 |
mOpenCategoryAlbum = id;
|
|
430 |
mCollectionPathLevel = VideoCollectionCommon::ELevelAlbum;
|
30
|
431 |
mCollectionOpenStatus = ECollectionOpening;
|
|
432 |
}
|
|
433 |
|
|
434 |
// -----------------------------------------------------------------------------
|
|
435 |
// backL
|
|
436 |
// -----------------------------------------------------------------------------
|
|
437 |
//
|
|
438 |
void VideoCollectionClient::backL()
|
|
439 |
{
|
|
440 |
if(!mCollectionUtility)
|
|
441 |
{
|
|
442 |
User::Leave(KErrGeneral);
|
|
443 |
}
|
|
444 |
|
|
445 |
if (getCollectionLevel() > 2 )
|
|
446 |
{
|
|
447 |
mCollectionUtility->Collection().BackL();
|
|
448 |
mCollectionOpenStatus = ECollectionOpening;
|
|
449 |
|
34
|
450 |
mOpenCategoryAlbum = TMPXItemId::InvalidId();
|
|
451 |
|
|
452 |
mCollectionPathLevel = VideoCollectionCommon::ELevelCategory;
|
30
|
453 |
}
|
|
454 |
}
|
|
455 |
|
|
456 |
// -----------------------------------------------------------------------------
|
|
457 |
// getVideoDetailsL
|
|
458 |
// -----------------------------------------------------------------------------
|
|
459 |
//
|
|
460 |
void VideoCollectionClient::getVideoDetailsL(TMPXItemId &videoId)
|
|
461 |
{
|
|
462 |
if(!mCollectionUtility)
|
|
463 |
{
|
|
464 |
User::Leave(KErrGeneral);
|
|
465 |
}
|
|
466 |
CMPXCommand* cmd = CMPXCommand::NewL();
|
|
467 |
CleanupStack::PushL( cmd );
|
|
468 |
|
|
469 |
cmd->SetTObjectValueL( KMPXCommandGeneralId, KVcxCommandIdMyVideos );
|
|
470 |
cmd->SetTObjectValueL( KVcxMediaMyVideosCommandId, KVcxCommandMyVideosGetMediaFullDetailsByMpxId );
|
|
471 |
cmd->SetTObjectValueL( KMPXMediaGeneralId, videoId );
|
|
472 |
mCollectionUtility->Collection().CommandL( *cmd );
|
|
473 |
|
|
474 |
CleanupStack::PopAndDestroy( cmd );
|
|
475 |
}
|
|
476 |
|
|
477 |
// -----------------------------------------------------------------------------
|
34
|
478 |
// removeAlbumsL
|
30
|
479 |
// -----------------------------------------------------------------------------
|
|
480 |
//
|
34
|
481 |
void VideoCollectionClient::removeAlbumsL(const QList<TMPXItemId> &mediaIds)
|
30
|
482 |
{
|
|
483 |
if(!mCollectionUtility)
|
|
484 |
{
|
|
485 |
User::Leave(KErrGeneral);
|
|
486 |
}
|
34
|
487 |
|
|
488 |
CMPXCommand* cmd = CMPXCommand::NewL();
|
|
489 |
CleanupStack::PushL( cmd );
|
|
490 |
cmd->SetTObjectValueL( KMPXCommandGeneralId, KVcxCommandIdMyVideos );
|
|
491 |
cmd->SetTObjectValueL(KVcxMediaMyVideosCommandId, KVcxCommandMyVideosRemoveAlbums);
|
|
492 |
cmd->SetTObjectValueL(KMPXCommandGeneralDoSync, EFalse);
|
|
493 |
cmd->SetTObjectValueL(KMPXCommandGeneralCollectionId, TUid::Uid(KVcxUidMyVideosMpxCollection));
|
|
494 |
|
|
495 |
CMPXMediaArray* array = CMPXMediaArray::NewL();
|
|
496 |
CleanupStack::PushL( array );
|
|
497 |
CMPXMedia* media = 0;
|
|
498 |
int count = mediaIds.count();
|
|
499 |
for (int i = 0; i < count; i++)
|
|
500 |
{
|
|
501 |
media = CMPXMedia::NewL();
|
|
502 |
CleanupStack::PushL(media);
|
|
503 |
media->SetTObjectValueL(KMPXMediaGeneralId, mediaIds.at(i));
|
|
504 |
array->AppendL(*media);
|
|
505 |
CleanupStack::PopAndDestroy(media);
|
|
506 |
}
|
|
507 |
cmd->SetCObjectValueL(KMPXMediaArrayContents, array);
|
|
508 |
|
|
509 |
mCollectionUtility->Collection().CommandL(*cmd);
|
|
510 |
|
|
511 |
CleanupStack::PopAndDestroy( array );
|
|
512 |
CleanupStack::PopAndDestroy( cmd );
|
|
513 |
}
|
|
514 |
|
|
515 |
// -----------------------------------------------------------------------------
|
|
516 |
// createAlbumL
|
|
517 |
// -----------------------------------------------------------------------------
|
|
518 |
//
|
|
519 |
TMPXItemId VideoCollectionClient::createAlbumL(const QString &title)
|
|
520 |
{
|
|
521 |
TMPXItemId albumId = TMPXItemId::InvalidId();
|
30
|
522 |
|
|
523 |
CMPXCommand* cmd = CMPXCommand::NewL();
|
|
524 |
CleanupStack::PushL( cmd );
|
34
|
525 |
|
|
526 |
// 1. create album
|
|
527 |
TPtrC titlePtrC(title.utf16());
|
|
528 |
cmd->SetTObjectValueL(KMPXCommandGeneralId, KVcxCommandIdMyVideos);
|
|
529 |
cmd->SetTObjectValueL(KVcxMediaMyVideosCommandId, KVcxCommandMyVideosAddAlbum);
|
|
530 |
cmd->SetTextValueL(KMPXMediaGeneralTitle, titlePtrC);
|
|
531 |
cmd->SetTObjectValueL(KMPXCommandGeneralDoSync, ETrue);
|
|
532 |
cmd->SetTObjectValueL(KMPXCommandGeneralCollectionId, TUid::Uid(KVcxUidMyVideosMpxCollection));
|
30
|
533 |
|
34
|
534 |
mCollectionUtility->Collection().CommandL(*cmd);
|
30
|
535 |
|
34
|
536 |
// get album id
|
|
537 |
if (cmd->IsSupported(KMPXMediaGeneralId))
|
|
538 |
{
|
|
539 |
albumId = cmd->ValueTObjectL<TMPXItemId>(KMPXMediaGeneralId);
|
30
|
540 |
}
|
34
|
541 |
|
|
542 |
// cleanup
|
|
543 |
CleanupStack::PopAndDestroy(cmd);
|
|
544 |
|
|
545 |
return albumId;
|
|
546 |
}
|
|
547 |
|
|
548 |
// -----------------------------------------------------------------------------
|
|
549 |
// addItemsInAlbumL
|
|
550 |
// -----------------------------------------------------------------------------
|
|
551 |
//
|
|
552 |
void VideoCollectionClient::addItemsInAlbumL(TMPXItemId albumId,
|
|
553 |
const QList<TMPXItemId> &mediaIds)
|
|
554 |
{
|
|
555 |
CMPXCommand* cmd = CMPXCommand::NewL();
|
|
556 |
CleanupStack::PushL(cmd);
|
|
557 |
cmd->SetTObjectValueL(KMPXCommandGeneralId, KVcxCommandIdMyVideos);
|
|
558 |
cmd->SetTObjectValueL(KVcxMediaMyVideosCommandId, KVcxCommandMyVideosAddToAlbum);
|
|
559 |
cmd->SetTObjectValueL(KVcxMediaMyVideosUint32Value, albumId.iId1);
|
|
560 |
cmd->SetTObjectValueL(KMPXCommandGeneralDoSync, EFalse);
|
|
561 |
cmd->SetTObjectValueL(KMPXCommandGeneralCollectionId, TUid::Uid(KVcxUidMyVideosMpxCollection));
|
|
562 |
|
|
563 |
CMPXMediaArray* array = CMPXMediaArray::NewL();
|
|
564 |
CleanupStack::PushL( array );
|
|
565 |
CMPXMedia* video = 0;
|
|
566 |
int count = mediaIds.count();
|
|
567 |
for (int i = 0; i < count; i++)
|
|
568 |
{
|
|
569 |
video = CMPXMedia::NewL();
|
|
570 |
CleanupStack::PushL(video);
|
|
571 |
video->SetTObjectValueL(KMPXMediaGeneralId, mediaIds.at(i));
|
|
572 |
array->AppendL(*video);
|
|
573 |
CleanupStack::PopAndDestroy(video);
|
|
574 |
}
|
|
575 |
cmd->SetCObjectValueL(KMPXMediaArrayContents, array);
|
|
576 |
|
|
577 |
mCollectionUtility->Collection().CommandL(*cmd);
|
|
578 |
|
|
579 |
CleanupStack::PopAndDestroy(array);
|
|
580 |
CleanupStack::PopAndDestroy(cmd);
|
30
|
581 |
}
|
|
582 |
|
|
583 |
// -----------------------------------------------------------------------------
|
|
584 |
// fetchMpxMediaByMpxIdL
|
|
585 |
// -----------------------------------------------------------------------------
|
|
586 |
//
|
|
587 |
void VideoCollectionClient::fetchMpxMediaByMpxIdL(TMPXItemId &aMpxId)
|
|
588 |
{
|
|
589 |
if(!mCollectionUtility)
|
|
590 |
{
|
|
591 |
User::Leave(KErrGeneral);
|
|
592 |
}
|
|
593 |
|
|
594 |
CMPXCommand* cmd = CMPXCommand::NewL();
|
|
595 |
CleanupStack::PushL( cmd );
|
|
596 |
cmd->SetTObjectValueL( KMPXCommandGeneralId, KVcxCommandIdMyVideos );
|
|
597 |
cmd->SetTObjectValueL( KVcxMediaMyVideosCommandId, KVcxCommandMyVideosGetMediasByMpxId );
|
|
598 |
cmd->SetTObjectValueL( KMPXCommandGeneralCollectionId,
|
|
599 |
TUid::Uid( KVcxUidMyVideosMpxCollection ) );
|
|
600 |
|
|
601 |
CMPXMediaArray* idMediaArray = CMPXMediaArray::NewL();
|
|
602 |
CleanupStack::PushL( idMediaArray );
|
|
603 |
CMPXMedia* media = CMPXMedia::NewL();
|
|
604 |
CleanupStack::PushL( media );
|
|
605 |
media->SetTObjectValueL( KMPXMessageMediaGeneralId, aMpxId );
|
|
606 |
idMediaArray->AppendL( *media );
|
|
607 |
cmd->SetCObjectValueL<CMPXMediaArray>( KMPXMediaArrayContents, idMediaArray );
|
|
608 |
cmd->SetTObjectValueL( KMPXMediaArrayCount, idMediaArray->Count() );
|
|
609 |
mCollectionUtility->Collection().CommandL( *cmd );
|
|
610 |
|
|
611 |
CleanupStack::PopAndDestroy( media );
|
|
612 |
CleanupStack::PopAndDestroy( idMediaArray );
|
|
613 |
CleanupStack::PopAndDestroy( cmd );
|
|
614 |
}
|
|
615 |
|