|
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), |
|
46 mOpenCategoryAlbum(TMPXItemId::InvalidId()), |
|
47 mCollectionPathLevel(VideoCollectionCommon::ELevelInvalid) |
|
48 { |
|
49 |
|
50 } |
|
51 |
|
52 // ----------------------------------------------------------------------------- |
|
53 // initialize() |
|
54 // ----------------------------------------------------------------------------- |
|
55 // |
|
56 int VideoCollectionClient::initialize(VideoDataSignalReceiver *signalReceiver) |
|
57 { |
|
58 if(!signalReceiver) |
|
59 { |
|
60 return -1; |
|
61 } |
|
62 if(mCollectionUtility && mCollectionListener) |
|
63 { |
|
64 // already initialized |
|
65 return 0; |
|
66 } |
|
67 if(!mCollectionListener) |
|
68 { |
|
69 mCollectionListener = new VideoCollectionListener(*this, *signalReceiver); |
|
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 // |
|
106 |
|
107 void VideoCollectionClient::getCategoryId(TMPXItemId &id) |
|
108 { |
|
109 id = mOpenCategoryAlbum; |
|
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 // ----------------------------------------------------------------------------- |
|
192 // openItem |
|
193 // ----------------------------------------------------------------------------- |
|
194 // |
|
195 int VideoCollectionClient::openItem(TMPXItemId &mediaId) |
|
196 { |
|
197 if(!mCollectionUtility) |
|
198 { |
|
199 return -1; |
|
200 } |
|
201 |
|
202 TInt error; |
|
203 if (mediaId.iId2 == KVcxMvcMediaTypeVideo) |
|
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 // ----------------------------------------------------------------------------- |
|
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 |
|
281 // ----------------------------------------------------------------------------- |
|
282 // |
|
283 int VideoCollectionClient::removeAlbums(const QList<TMPXItemId> &mediaIds) |
|
284 { |
|
285 int err(-1); |
|
286 |
|
287 if (mCollectionUtility && mediaIds.count()) |
|
288 { |
|
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 && mediaIds.count()) |
|
306 { |
|
307 TRAP(err, addItemsInAlbumL(albumId, mediaIds)); |
|
308 } |
|
309 |
|
310 return err; |
|
311 } |
|
312 |
|
313 // ----------------------------------------------------------------------------- |
|
314 // removeItemsFromAlbum |
|
315 // ----------------------------------------------------------------------------- |
|
316 // |
|
317 int VideoCollectionClient::removeItemsFromAlbum(TMPXItemId &albumId, |
|
318 const QList<TMPXItemId> &mediaIds) |
|
319 { |
|
320 int err(-1); |
|
321 |
|
322 if (mCollectionUtility && albumId != TMPXItemId::InvalidId() && |
|
323 albumId.iId2 == KVcxMvcMediaTypeAlbum && mediaIds.count()) |
|
324 { |
|
325 TRAP(err, removeItemsFromAlbumL(albumId, mediaIds)); |
|
326 } |
|
327 |
|
328 return err; |
|
329 } |
|
330 |
|
331 // ----------------------------------------------------------------------------- |
|
332 // startOpenCollectionL |
|
333 // ----------------------------------------------------------------------------- |
|
334 // |
|
335 void VideoCollectionClient::startOpenCollectionL(int level) |
|
336 { |
|
337 if(!mCollectionUtility) |
|
338 { |
|
339 User::Leave(KErrGeneral); |
|
340 } |
|
341 CMPXCollectionPath* collectionPath = CMPXCollectionPath::NewL(); |
|
342 CleanupStack::PushL( collectionPath ); |
|
343 |
|
344 collectionPath->AppendL( KVcxUidMyVideosMpxCollection ); |
|
345 if (level == VideoCollectionCommon::ELevelVideos) |
|
346 { |
|
347 collectionPath->AppendL( KVcxMvcCategoryIdAll ); |
|
348 |
|
349 mOpenCategoryAlbum.iId1 = KVcxMvcCategoryIdAll; |
|
350 mOpenCategoryAlbum.iId2 = 1; |
|
351 |
|
352 mCollectionPathLevel = VideoCollectionCommon::ELevelVideos; |
|
353 } |
|
354 else |
|
355 { |
|
356 mOpenCategoryAlbum = TMPXItemId::InvalidId(); |
|
357 |
|
358 mCollectionPathLevel = VideoCollectionCommon::ELevelCategory; |
|
359 } |
|
360 mCollectionUtility->Collection().OpenL( *collectionPath ); |
|
361 CleanupStack::PopAndDestroy( collectionPath ); |
|
362 |
|
363 mCollectionOpenStatus = ECollectionOpening; |
|
364 } |
|
365 |
|
366 |
|
367 // ----------------------------------------------------------------------------- |
|
368 // deleteVideosL |
|
369 // ----------------------------------------------------------------------------- |
|
370 // |
|
371 void VideoCollectionClient::deleteVideosL(QList<TMPXItemId> &mediaIds) |
|
372 { |
|
373 if(!mCollectionUtility || mediaIds.count() == 0) |
|
374 { |
|
375 User::Leave(KErrGeneral); |
|
376 } |
|
377 CMPXMediaArray* mediasToDelete = CMPXMediaArray::NewL(); |
|
378 CleanupStack::PushL( mediasToDelete ); |
|
379 |
|
380 CMPXMedia* media = NULL; |
|
381 |
|
382 TMPXItemId currentId; |
|
383 foreach(currentId, mediaIds) |
|
384 { |
|
385 media = CMPXMedia::NewL(); |
|
386 CleanupStack::PushL( media ); |
|
387 media->SetTObjectValueL( KMPXMediaGeneralId, currentId ); |
|
388 mediasToDelete->AppendL( *media ); |
|
389 CleanupStack::PopAndDestroy( media ); |
|
390 } |
|
391 |
|
392 CMPXCommand* cmd = CMPXMedia::NewL(); |
|
393 CleanupStack::PushL( cmd ); |
|
394 |
|
395 cmd->SetTObjectValueL( KMPXCommandGeneralId, KVcxCommandIdMyVideos ); |
|
396 cmd->SetTObjectValueL( KVcxMediaMyVideosCommandId, KVcxCommandMyVideosDelete ); |
|
397 cmd->SetTObjectValueL( KMPXCommandGeneralDoSync, EFalse ); |
|
398 cmd->SetTObjectValueL( KMPXCommandGeneralCollectionId, |
|
399 TUid::Uid( KVcxUidMyVideosMpxCollection ) ); |
|
400 cmd->SetCObjectValueL( KMPXMediaArrayContents, mediasToDelete ); |
|
401 |
|
402 mCollectionUtility->Collection().CommandL( *cmd ); |
|
403 |
|
404 CleanupStack::PopAndDestroy( cmd ); |
|
405 CleanupStack::PopAndDestroy( mediasToDelete ); |
|
406 } |
|
407 |
|
408 // ----------------------------------------------------------------------------- |
|
409 // openVideoL |
|
410 // ----------------------------------------------------------------------------- |
|
411 // |
|
412 void VideoCollectionClient::openVideoL(TMPXItemId &videoId) |
|
413 { |
|
414 if(!mCollectionUtility) |
|
415 { |
|
416 User::Leave(KErrGeneral); |
|
417 } |
|
418 CMPXCollectionPath* path = CMPXCollectionPath::NewL(); |
|
419 CleanupStack::PushL( path ); |
|
420 path->AppendL( KVcxUidMyVideosMpxCollection ); |
|
421 path->AppendL( KVcxMvcCategoryIdAll ); |
|
422 path->AppendL( videoId ); |
|
423 path->SelectL( videoId ); |
|
424 |
|
425 mCollectionUtility->Collection().OpenL( *path ); |
|
426 CleanupStack::PopAndDestroy( path ); |
|
427 } |
|
428 |
|
429 // ----------------------------------------------------------------------------- |
|
430 // openCategoryL |
|
431 // ----------------------------------------------------------------------------- |
|
432 // |
|
433 void VideoCollectionClient::openCategoryL(TMPXItemId &id) |
|
434 { |
|
435 if(!mCollectionUtility) |
|
436 { |
|
437 User::Leave(KErrGeneral); |
|
438 } |
|
439 CMPXCollectionPath* collectionPath = CMPXCollectionPath::NewL(); |
|
440 CleanupStack::PushL( collectionPath ); |
|
441 |
|
442 collectionPath->AppendL( KVcxUidMyVideosMpxCollection ); |
|
443 collectionPath->AppendL( id ); |
|
444 mCollectionUtility->Collection().OpenL( *collectionPath ); |
|
445 CleanupStack::PopAndDestroy( collectionPath ); |
|
446 |
|
447 mOpenCategoryAlbum = id; |
|
448 mCollectionPathLevel = VideoCollectionCommon::ELevelAlbum; |
|
449 mCollectionOpenStatus = ECollectionOpening; |
|
450 } |
|
451 |
|
452 // ----------------------------------------------------------------------------- |
|
453 // backL |
|
454 // ----------------------------------------------------------------------------- |
|
455 // |
|
456 void VideoCollectionClient::backL() |
|
457 { |
|
458 if(!mCollectionUtility) |
|
459 { |
|
460 User::Leave(KErrGeneral); |
|
461 } |
|
462 |
|
463 if (getCollectionLevel() > 2 ) |
|
464 { |
|
465 mCollectionUtility->Collection().BackL(); |
|
466 mCollectionOpenStatus = ECollectionOpening; |
|
467 |
|
468 mOpenCategoryAlbum = TMPXItemId::InvalidId(); |
|
469 |
|
470 mCollectionPathLevel = VideoCollectionCommon::ELevelCategory; |
|
471 } |
|
472 } |
|
473 |
|
474 // ----------------------------------------------------------------------------- |
|
475 // getVideoDetailsL |
|
476 // ----------------------------------------------------------------------------- |
|
477 // |
|
478 void VideoCollectionClient::getVideoDetailsL(TMPXItemId &videoId) |
|
479 { |
|
480 if(!mCollectionUtility) |
|
481 { |
|
482 User::Leave(KErrGeneral); |
|
483 } |
|
484 CMPXCommand* cmd = CMPXCommand::NewL(); |
|
485 CleanupStack::PushL( cmd ); |
|
486 |
|
487 cmd->SetTObjectValueL( KMPXCommandGeneralId, KVcxCommandIdMyVideos ); |
|
488 cmd->SetTObjectValueL( KVcxMediaMyVideosCommandId, KVcxCommandMyVideosGetMediaFullDetailsByMpxId ); |
|
489 cmd->SetTObjectValueL( KMPXMediaGeneralId, videoId ); |
|
490 mCollectionUtility->Collection().CommandL( *cmd ); |
|
491 |
|
492 CleanupStack::PopAndDestroy( cmd ); |
|
493 } |
|
494 |
|
495 // ----------------------------------------------------------------------------- |
|
496 // removeAlbumsL |
|
497 // ----------------------------------------------------------------------------- |
|
498 // |
|
499 void VideoCollectionClient::removeAlbumsL(const QList<TMPXItemId> &mediaIds) |
|
500 { |
|
501 if(!mCollectionUtility) |
|
502 { |
|
503 User::Leave(KErrGeneral); |
|
504 } |
|
505 |
|
506 CMPXCommand* cmd = CMPXCommand::NewL(); |
|
507 CleanupStack::PushL( cmd ); |
|
508 cmd->SetTObjectValueL( KMPXCommandGeneralId, KVcxCommandIdMyVideos ); |
|
509 cmd->SetTObjectValueL(KVcxMediaMyVideosCommandId, KVcxCommandMyVideosRemoveAlbums); |
|
510 cmd->SetTObjectValueL(KMPXCommandGeneralDoSync, EFalse); |
|
511 cmd->SetTObjectValueL(KMPXCommandGeneralCollectionId, TUid::Uid(KVcxUidMyVideosMpxCollection)); |
|
512 |
|
513 CMPXMediaArray* array = CMPXMediaArray::NewL(); |
|
514 CleanupStack::PushL( array ); |
|
515 CMPXMedia* media = 0; |
|
516 int count = mediaIds.count(); |
|
517 for (int i = 0; i < count; i++) |
|
518 { |
|
519 if(mediaIds.at(i).iId2 == KVcxMvcMediaTypeAlbum) |
|
520 { |
|
521 media = CMPXMedia::NewL(); |
|
522 CleanupStack::PushL(media); |
|
523 media->SetTObjectValueL(KMPXMediaGeneralId, mediaIds.at(i)); |
|
524 array->AppendL(*media); |
|
525 CleanupStack::PopAndDestroy(media); |
|
526 } |
|
527 } |
|
528 if(array->Count()) |
|
529 { |
|
530 cmd->SetCObjectValueL(KMPXMediaArrayContents, array); |
|
531 mCollectionUtility->Collection().CommandL(*cmd); |
|
532 } |
|
533 else |
|
534 { |
|
535 // invalid data provided |
|
536 User::Leave(KErrGeneral); |
|
537 } |
|
538 |
|
539 CleanupStack::PopAndDestroy( array ); |
|
540 CleanupStack::PopAndDestroy( cmd ); |
|
541 } |
|
542 |
|
543 // ----------------------------------------------------------------------------- |
|
544 // createAlbumL |
|
545 // ----------------------------------------------------------------------------- |
|
546 // |
|
547 TMPXItemId VideoCollectionClient::createAlbumL(const QString &title) |
|
548 { |
|
549 TMPXItemId albumId = TMPXItemId::InvalidId(); |
|
550 |
|
551 CMPXCommand* cmd = CMPXCommand::NewL(); |
|
552 CleanupStack::PushL( cmd ); |
|
553 |
|
554 // 1. create album |
|
555 TPtrC titlePtrC(title.utf16()); |
|
556 cmd->SetTObjectValueL(KMPXCommandGeneralId, KVcxCommandIdMyVideos); |
|
557 cmd->SetTObjectValueL(KVcxMediaMyVideosCommandId, KVcxCommandMyVideosAddAlbum); |
|
558 cmd->SetTextValueL(KMPXMediaGeneralTitle, titlePtrC); |
|
559 cmd->SetTObjectValueL(KMPXCommandGeneralDoSync, ETrue); |
|
560 cmd->SetTObjectValueL(KMPXCommandGeneralCollectionId, TUid::Uid(KVcxUidMyVideosMpxCollection)); |
|
561 |
|
562 mCollectionUtility->Collection().CommandL(*cmd); |
|
563 |
|
564 // get album id |
|
565 if (cmd->IsSupported(KMPXMediaGeneralId)) |
|
566 { |
|
567 albumId = cmd->ValueTObjectL<TMPXItemId>(KMPXMediaGeneralId); |
|
568 } |
|
569 |
|
570 // cleanup |
|
571 CleanupStack::PopAndDestroy(cmd); |
|
572 |
|
573 return albumId; |
|
574 } |
|
575 |
|
576 // ----------------------------------------------------------------------------- |
|
577 // addItemsInAlbumL |
|
578 // ----------------------------------------------------------------------------- |
|
579 // |
|
580 void VideoCollectionClient::addItemsInAlbumL(TMPXItemId &albumId, |
|
581 const QList<TMPXItemId> &mediaIds) |
|
582 { |
|
583 CMPXCommand* cmd = CMPXCommand::NewL(); |
|
584 CleanupStack::PushL(cmd); |
|
585 cmd->SetTObjectValueL(KMPXCommandGeneralId, KVcxCommandIdMyVideos); |
|
586 cmd->SetTObjectValueL(KVcxMediaMyVideosCommandId, KVcxCommandMyVideosAddToAlbum); |
|
587 cmd->SetTObjectValueL(KVcxMediaMyVideosUint32Value, albumId.iId1); |
|
588 cmd->SetTObjectValueL(KMPXCommandGeneralCollectionId, TUid::Uid(KVcxUidMyVideosMpxCollection)); |
|
589 |
|
590 CMPXMediaArray* array = CMPXMediaArray::NewL(); |
|
591 CleanupStack::PushL( array ); |
|
592 CMPXMedia* video = 0; |
|
593 int count = mediaIds.count(); |
|
594 for (int i = 0; i < count; i++) |
|
595 { |
|
596 if(mediaIds.at(i).iId2 == KVcxMvcMediaTypeVideo) |
|
597 { |
|
598 video = CMPXMedia::NewL(); |
|
599 CleanupStack::PushL(video); |
|
600 video->SetTObjectValueL(KMPXMediaGeneralId, mediaIds.at(i)); |
|
601 array->AppendL(*video); |
|
602 CleanupStack::PopAndDestroy(video); |
|
603 } |
|
604 } |
|
605 if(array->Count()) |
|
606 { |
|
607 cmd->SetCObjectValueL(KMPXMediaArrayContents, array); |
|
608 mCollectionUtility->Collection().CommandL(*cmd); |
|
609 } |
|
610 else |
|
611 { |
|
612 // invalid data provided |
|
613 User::Leave(KErrGeneral); |
|
614 } |
|
615 |
|
616 CleanupStack::PopAndDestroy(array); |
|
617 CleanupStack::PopAndDestroy(cmd); |
|
618 } |
|
619 |
|
620 // ----------------------------------------------------------------------------- |
|
621 // removeItemsFromAlbumL |
|
622 // ----------------------------------------------------------------------------- |
|
623 // |
|
624 void VideoCollectionClient::removeItemsFromAlbumL(TMPXItemId &albumId, |
|
625 const QList<TMPXItemId> &mediaIds) |
|
626 { |
|
627 CMPXCommand* cmd = CMPXCommand::NewL(); |
|
628 CleanupStack::PushL(cmd); |
|
629 cmd->SetTObjectValueL(KMPXCommandGeneralId, KVcxCommandIdMyVideos); |
|
630 cmd->SetTObjectValueL(KVcxMediaMyVideosCommandId, KVcxCommandMyVideosRemoveFromAlbum); |
|
631 cmd->SetTObjectValueL(KVcxMediaMyVideosUint32Value, albumId.iId1); |
|
632 cmd->SetTObjectValueL(KMPXCommandGeneralCollectionId, TUid::Uid(KVcxUidMyVideosMpxCollection)); |
|
633 |
|
634 CMPXMediaArray* array = CMPXMediaArray::NewL(); |
|
635 CleanupStack::PushL( array ); |
|
636 CMPXMedia* video = 0; |
|
637 int count = mediaIds.count(); |
|
638 for (int i = 0; i < count; i++) |
|
639 { |
|
640 if(mediaIds.at(i).iId2 == KVcxMvcMediaTypeVideo) |
|
641 { |
|
642 video = CMPXMedia::NewL(); |
|
643 CleanupStack::PushL(video); |
|
644 video->SetTObjectValueL(KMPXMediaGeneralId, mediaIds.at(i)); |
|
645 array->AppendL(*video); |
|
646 CleanupStack::PopAndDestroy(video); |
|
647 } |
|
648 } |
|
649 if(array->Count()) |
|
650 { |
|
651 cmd->SetCObjectValueL(KMPXMediaArrayContents, array); |
|
652 mCollectionUtility->Collection().CommandL(*cmd); |
|
653 } |
|
654 else |
|
655 { |
|
656 // invalid data provided |
|
657 User::Leave(KErrGeneral); |
|
658 } |
|
659 CleanupStack::PopAndDestroy(array); |
|
660 CleanupStack::PopAndDestroy(cmd); |
|
661 } |
|
662 |
|
663 // ----------------------------------------------------------------------------- |
|
664 // fetchMpxMediaByMpxIdL |
|
665 // ----------------------------------------------------------------------------- |
|
666 // |
|
667 void VideoCollectionClient::fetchMpxMediaByMpxIdL(TMPXItemId &aMpxId) |
|
668 { |
|
669 if(!mCollectionUtility) |
|
670 { |
|
671 User::Leave(KErrGeneral); |
|
672 } |
|
673 |
|
674 CMPXCommand* cmd = CMPXCommand::NewL(); |
|
675 CleanupStack::PushL( cmd ); |
|
676 cmd->SetTObjectValueL( KMPXCommandGeneralId, KVcxCommandIdMyVideos ); |
|
677 cmd->SetTObjectValueL( KVcxMediaMyVideosCommandId, KVcxCommandMyVideosGetMediasByMpxId ); |
|
678 cmd->SetTObjectValueL( KMPXCommandGeneralCollectionId, |
|
679 TUid::Uid( KVcxUidMyVideosMpxCollection ) ); |
|
680 |
|
681 CMPXMediaArray* idMediaArray = CMPXMediaArray::NewL(); |
|
682 CleanupStack::PushL( idMediaArray ); |
|
683 CMPXMedia* media = CMPXMedia::NewL(); |
|
684 CleanupStack::PushL( media ); |
|
685 media->SetTObjectValueL( KMPXMessageMediaGeneralId, aMpxId ); |
|
686 idMediaArray->AppendL( *media ); |
|
687 cmd->SetCObjectValueL<CMPXMediaArray>( KMPXMediaArrayContents, idMediaArray ); |
|
688 cmd->SetTObjectValueL( KMPXMediaArrayCount, idMediaArray->Count() ); |
|
689 mCollectionUtility->Collection().CommandL( *cmd ); |
|
690 |
|
691 CleanupStack::PopAndDestroy( media ); |
|
692 CleanupStack::PopAndDestroy( idMediaArray ); |
|
693 CleanupStack::PopAndDestroy( cmd ); |
|
694 } |
|
695 |