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 |
|
36
|
18 |
// Version : %version: 39 %
|
|
19 |
|
30
|
20 |
// INCLUDE FILES
|
36
|
21 |
#include <qobject.h>
|
30
|
22 |
#include <centralrepository.h>
|
|
23 |
#include <mpxcollectionutility.h>
|
|
24 |
#include <mpxcollectionpath.h>
|
|
25 |
#include <mpxmediageneraldefs.h>
|
|
26 |
#include <mpxmessagegeneraldefs.h>
|
|
27 |
#include <mpxmessage2.h>
|
|
28 |
#include <mpxcollectionmessagedefs.h>
|
|
29 |
#include <mpxcollectionmessage.h>
|
|
30 |
#include <mpxmessagecontainerdefs.h>
|
|
31 |
#include <mpxmediacontainerdefs.h>
|
|
32 |
#include <mpxcommandgeneraldefs.h>
|
|
33 |
#include <mpxcollectioncommanddefs.h>
|
|
34 |
#include <vcxmyvideosuids.h>
|
|
35 |
|
|
36 |
#include "videodatasignalreceiver.h"
|
|
37 |
#include "videocollectionclient.h"
|
|
38 |
#include "videocollectionlistener.h"
|
36
|
39 |
#include "videocollectiontrace.h"
|
30
|
40 |
|
|
41 |
// -----------------------------------------------------------------------------
|
|
42 |
// VideoCollectionClient()
|
|
43 |
// -----------------------------------------------------------------------------
|
|
44 |
//
|
36
|
45 |
VideoCollectionClient::VideoCollectionClient()
|
|
46 |
: mCollectionUtility( 0 )
|
|
47 |
, mCollectionOpenStatus( ECollectionNotOpen )
|
|
48 |
, mCollectionListener( 0 )
|
|
49 |
, mOpenCategoryAlbum( TMPXItemId::InvalidId() )
|
|
50 |
, mCollectionPathLevel( VideoCollectionCommon::ELevelInvalid )
|
30
|
51 |
{
|
36
|
52 |
FUNC_LOG;
|
30
|
53 |
}
|
|
54 |
|
|
55 |
// -----------------------------------------------------------------------------
|
|
56 |
// initialize()
|
|
57 |
// -----------------------------------------------------------------------------
|
|
58 |
//
|
34
|
59 |
int VideoCollectionClient::initialize(VideoDataSignalReceiver *signalReceiver)
|
30
|
60 |
{
|
36
|
61 |
FUNC_LOG;
|
34
|
62 |
if(!signalReceiver)
|
|
63 |
{
|
|
64 |
return -1;
|
|
65 |
}
|
30
|
66 |
if(mCollectionUtility && mCollectionListener)
|
|
67 |
{
|
36
|
68 |
INFO("VideoCollectionClient::initialize() already initialized.");
|
30
|
69 |
return 0;
|
|
70 |
}
|
|
71 |
if(!mCollectionListener)
|
|
72 |
{
|
34
|
73 |
mCollectionListener = new VideoCollectionListener(*this, *signalReceiver);
|
30
|
74 |
if(!mCollectionListener)
|
|
75 |
{
|
|
76 |
return -1;
|
|
77 |
}
|
|
78 |
}
|
|
79 |
if(!mCollectionUtility)
|
|
80 |
{
|
|
81 |
TRAPD( error, mCollectionUtility = MMPXCollectionUtility::NewL( mCollectionListener, KMcModeDefault ) );
|
|
82 |
if(error)
|
|
83 |
{
|
36
|
84 |
ERROR(error, "VideoCollectionClient::initialize() construction of collection utility failed.");
|
30
|
85 |
delete mCollectionListener;
|
|
86 |
mCollectionListener = 0;
|
|
87 |
return error;
|
|
88 |
}
|
|
89 |
}
|
|
90 |
return 0;
|
|
91 |
}
|
|
92 |
|
|
93 |
// -----------------------------------------------------------------------------
|
|
94 |
// ~VideoCollectionClient()
|
|
95 |
// -----------------------------------------------------------------------------
|
|
96 |
//
|
|
97 |
VideoCollectionClient::~VideoCollectionClient()
|
|
98 |
{
|
36
|
99 |
FUNC_LOG;
|
30
|
100 |
if (mCollectionUtility)
|
|
101 |
{
|
|
102 |
// closing deallocates collection utility pointer
|
|
103 |
mCollectionUtility->Close();
|
|
104 |
}
|
|
105 |
delete mCollectionListener;
|
|
106 |
}
|
|
107 |
|
|
108 |
// ---------------------------------------------------------------------------
|
|
109 |
// categoryIds
|
|
110 |
// ---------------------------------------------------------------------------
|
|
111 |
//
|
34
|
112 |
|
|
113 |
void VideoCollectionClient::getCategoryId(TMPXItemId &id)
|
30
|
114 |
{
|
36
|
115 |
FUNC_LOG;
|
34
|
116 |
id = mOpenCategoryAlbum;
|
30
|
117 |
}
|
|
118 |
|
|
119 |
// ---------------------------------------------------------------------------
|
|
120 |
// getCollectionLevel
|
|
121 |
// ---------------------------------------------------------------------------
|
|
122 |
//
|
|
123 |
int VideoCollectionClient::getCollectionLevel()
|
|
124 |
{
|
36
|
125 |
FUNC_LOG;
|
30
|
126 |
return mCollectionPathLevel;
|
|
127 |
}
|
|
128 |
|
|
129 |
// ---------------------------------------------------------------------------
|
|
130 |
// getOpenStatus
|
|
131 |
// ---------------------------------------------------------------------------
|
|
132 |
//
|
|
133 |
int VideoCollectionClient::getOpenStatus()
|
|
134 |
{
|
36
|
135 |
FUNC_LOG;
|
30
|
136 |
return mCollectionOpenStatus;
|
|
137 |
}
|
|
138 |
|
|
139 |
// ---------------------------------------------------------------------------
|
|
140 |
// setOpenStatus
|
|
141 |
// ---------------------------------------------------------------------------
|
|
142 |
//
|
36
|
143 |
void VideoCollectionClient::setOpenStatus(int status, bool startOpening)
|
30
|
144 |
{
|
36
|
145 |
FUNC_LOG;
|
|
146 |
INFO_2("VideoCollectionClient::setOpenStatus() status: %d start opening %d", status, startOpening);
|
30
|
147 |
mCollectionOpenStatus = status;
|
36
|
148 |
if(mCollectionOpenStatus == ECollectionOpened && startOpening)
|
30
|
149 |
{
|
|
150 |
startOpenCurrentState();
|
|
151 |
}
|
|
152 |
}
|
|
153 |
|
|
154 |
// -----------------------------------------------------------------------------
|
|
155 |
// startOpenCollection
|
|
156 |
// -----------------------------------------------------------------------------
|
|
157 |
//
|
|
158 |
int VideoCollectionClient::startOpenCollection(int level)
|
|
159 |
{
|
36
|
160 |
FUNC_LOG;
|
|
161 |
INFO_1("VideoCollectionClient::startOpenCollection() opening level: %d", level);
|
|
162 |
|
30
|
163 |
if(!mCollectionUtility)
|
|
164 |
{
|
|
165 |
return -1;
|
|
166 |
}
|
|
167 |
|
|
168 |
if((mCollectionOpenStatus == ECollectionOpening) && (getCollectionLevel() == level))
|
|
169 |
{
|
|
170 |
// allready opening/opened
|
|
171 |
return 0;
|
|
172 |
}
|
|
173 |
mCollectionOpenStatus = ECollectionNotOpen;
|
|
174 |
TRAPD(error, startOpenCollectionL(level));
|
|
175 |
return error;
|
|
176 |
}
|
|
177 |
|
|
178 |
// -----------------------------------------------------------------------------
|
|
179 |
// startOpenCurrentState
|
|
180 |
// -----------------------------------------------------------------------------
|
|
181 |
//
|
|
182 |
int VideoCollectionClient::startOpenCurrentState()
|
|
183 |
{
|
36
|
184 |
FUNC_LOG;
|
30
|
185 |
int error = -1;
|
|
186 |
if(mCollectionUtility && mCollectionOpenStatus == ECollectionOpened)
|
|
187 |
{
|
|
188 |
TRAP(error, mCollectionUtility->Collection().OpenL());
|
|
189 |
}
|
|
190 |
return error;
|
|
191 |
}
|
|
192 |
|
|
193 |
// -----------------------------------------------------------------------------
|
|
194 |
// deleteFile
|
|
195 |
// -----------------------------------------------------------------------------
|
|
196 |
int VideoCollectionClient::deleteVideos(QList<TMPXItemId> *mediaIds)
|
|
197 |
{
|
36
|
198 |
FUNC_LOG;
|
30
|
199 |
if(!mCollectionUtility || !mediaIds)
|
|
200 |
{
|
|
201 |
return -1;
|
|
202 |
}
|
|
203 |
TRAPD(error, deleteVideosL(*mediaIds));
|
|
204 |
return error;
|
|
205 |
}
|
|
206 |
|
|
207 |
// -----------------------------------------------------------------------------
|
34
|
208 |
// openItem
|
30
|
209 |
// -----------------------------------------------------------------------------
|
|
210 |
//
|
34
|
211 |
int VideoCollectionClient::openItem(TMPXItemId &mediaId)
|
30
|
212 |
{
|
36
|
213 |
FUNC_LOG;
|
30
|
214 |
if(!mCollectionUtility)
|
|
215 |
{
|
|
216 |
return -1;
|
|
217 |
}
|
|
218 |
|
|
219 |
TInt error;
|
34
|
220 |
if (mediaId.iId2 == KVcxMvcMediaTypeVideo)
|
30
|
221 |
{
|
|
222 |
TRAP(error, openVideoL(mediaId));
|
|
223 |
}
|
|
224 |
else
|
|
225 |
{
|
|
226 |
TRAP(error, openCategoryL(mediaId));
|
|
227 |
}
|
|
228 |
return error;
|
|
229 |
}
|
|
230 |
|
|
231 |
// -----------------------------------------------------------------------------
|
|
232 |
// back
|
|
233 |
// -----------------------------------------------------------------------------
|
|
234 |
//
|
|
235 |
int VideoCollectionClient::back()
|
|
236 |
{
|
36
|
237 |
FUNC_LOG;
|
30
|
238 |
if(!mCollectionUtility)
|
|
239 |
{
|
|
240 |
return -1;
|
|
241 |
}
|
|
242 |
TRAPD(error, backL());
|
|
243 |
return error;
|
|
244 |
}
|
|
245 |
|
|
246 |
// -----------------------------------------------------------------------------
|
|
247 |
// fetchMpxMediaByMpxId
|
|
248 |
// -----------------------------------------------------------------------------
|
|
249 |
//
|
|
250 |
int VideoCollectionClient::fetchMpxMediaByMpxId(TMPXItemId &mpxId)
|
|
251 |
{
|
36
|
252 |
FUNC_LOG;
|
30
|
253 |
if(!mCollectionUtility)
|
|
254 |
{
|
|
255 |
return -1;
|
|
256 |
}
|
|
257 |
|
|
258 |
TRAPD(error, fetchMpxMediaByMpxIdL(mpxId));
|
|
259 |
return error;
|
|
260 |
}
|
|
261 |
|
|
262 |
// -----------------------------------------------------------------------------
|
|
263 |
// getVideoDetails
|
|
264 |
// -----------------------------------------------------------------------------
|
|
265 |
//
|
|
266 |
int VideoCollectionClient::getVideoDetails(TMPXItemId &mediaId)
|
|
267 |
{
|
36
|
268 |
FUNC_LOG;
|
30
|
269 |
if(!mCollectionUtility)
|
|
270 |
{
|
|
271 |
return -1;
|
|
272 |
}
|
|
273 |
|
|
274 |
TRAPD(error, getVideoDetailsL(mediaId));
|
|
275 |
|
|
276 |
return error;
|
|
277 |
}
|
|
278 |
|
|
279 |
// -----------------------------------------------------------------------------
|
34
|
280 |
// addNewAlbum
|
|
281 |
// -----------------------------------------------------------------------------
|
|
282 |
//
|
|
283 |
TMPXItemId VideoCollectionClient::addNewAlbum(const QString &title)
|
|
284 |
{
|
36
|
285 |
FUNC_LOG;
|
|
286 |
|
34
|
287 |
TMPXItemId id = TMPXItemId::InvalidId();
|
|
288 |
|
|
289 |
if (mCollectionUtility && title.length())
|
|
290 |
{
|
|
291 |
TRAPD(err, id = createAlbumL(title));
|
|
292 |
if(err)
|
|
293 |
{
|
|
294 |
id = TMPXItemId::InvalidId();
|
|
295 |
}
|
|
296 |
}
|
|
297 |
|
|
298 |
return id;
|
|
299 |
}
|
|
300 |
|
|
301 |
// -----------------------------------------------------------------------------
|
|
302 |
// removeAlbums
|
30
|
303 |
// -----------------------------------------------------------------------------
|
|
304 |
//
|
34
|
305 |
int VideoCollectionClient::removeAlbums(const QList<TMPXItemId> &mediaIds)
|
30
|
306 |
{
|
36
|
307 |
FUNC_LOG;
|
34
|
308 |
int err(-1);
|
|
309 |
|
35
|
310 |
if (mCollectionUtility && mediaIds.count())
|
30
|
311 |
{
|
34
|
312 |
TRAP(err, removeAlbumsL(mediaIds));
|
|
313 |
}
|
|
314 |
|
|
315 |
return err;
|
|
316 |
}
|
|
317 |
|
|
318 |
// -----------------------------------------------------------------------------
|
|
319 |
// addItemsInAlbum
|
|
320 |
// -----------------------------------------------------------------------------
|
|
321 |
//
|
35
|
322 |
int VideoCollectionClient::addItemsInAlbum(TMPXItemId &albumId,
|
36
|
323 |
const QList<TMPXItemId> &mediaIds)
|
34
|
324 |
{
|
36
|
325 |
FUNC_LOG;
|
34
|
326 |
int err(-1);
|
|
327 |
|
|
328 |
if (mCollectionUtility && albumId != TMPXItemId::InvalidId() &&
|
35
|
329 |
albumId.iId2 == KVcxMvcMediaTypeAlbum && mediaIds.count())
|
34
|
330 |
{
|
|
331 |
TRAP(err, addItemsInAlbumL(albumId, mediaIds));
|
30
|
332 |
}
|
|
333 |
|
34
|
334 |
return err;
|
30
|
335 |
}
|
|
336 |
|
|
337 |
// -----------------------------------------------------------------------------
|
35
|
338 |
// removeItemsFromAlbum
|
|
339 |
// -----------------------------------------------------------------------------
|
|
340 |
//
|
|
341 |
int VideoCollectionClient::removeItemsFromAlbum(TMPXItemId &albumId,
|
36
|
342 |
const QList<TMPXItemId> &mediaIds)
|
35
|
343 |
{
|
36
|
344 |
FUNC_LOG;
|
35
|
345 |
int err(-1);
|
|
346 |
|
|
347 |
if (mCollectionUtility && albumId != TMPXItemId::InvalidId() &&
|
|
348 |
albumId.iId2 == KVcxMvcMediaTypeAlbum && mediaIds.count())
|
|
349 |
{
|
|
350 |
TRAP(err, removeItemsFromAlbumL(albumId, mediaIds));
|
|
351 |
}
|
|
352 |
|
|
353 |
return err;
|
|
354 |
}
|
|
355 |
|
|
356 |
// -----------------------------------------------------------------------------
|
36
|
357 |
// renameAlbum
|
|
358 |
// -----------------------------------------------------------------------------
|
|
359 |
//
|
|
360 |
int VideoCollectionClient::renameAlbum(const TMPXItemId &albumId,
|
|
361 |
const QString &newTitle)
|
|
362 |
{
|
|
363 |
FUNC_LOG;
|
|
364 |
int err(-1);
|
|
365 |
|
|
366 |
if(mCollectionUtility && albumId.iId2 == KVcxMvcMediaTypeAlbum &&
|
|
367 |
!newTitle.isEmpty())
|
|
368 |
{
|
|
369 |
TRAP(err, renameAlbumL(albumId, newTitle));
|
|
370 |
}
|
|
371 |
|
|
372 |
return err;
|
|
373 |
}
|
|
374 |
|
|
375 |
// -----------------------------------------------------------------------------
|
30
|
376 |
// startOpenCollectionL
|
|
377 |
// -----------------------------------------------------------------------------
|
|
378 |
//
|
|
379 |
void VideoCollectionClient::startOpenCollectionL(int level)
|
|
380 |
{
|
36
|
381 |
FUNC_LOG;
|
|
382 |
INFO_1("VideoCollectionClient::startOpenCollectionL() level: %d", level);
|
|
383 |
|
30
|
384 |
if(!mCollectionUtility)
|
|
385 |
{
|
|
386 |
User::Leave(KErrGeneral);
|
|
387 |
}
|
|
388 |
CMPXCollectionPath* collectionPath = CMPXCollectionPath::NewL();
|
|
389 |
CleanupStack::PushL( collectionPath );
|
|
390 |
|
|
391 |
collectionPath->AppendL( KVcxUidMyVideosMpxCollection );
|
34
|
392 |
if (level == VideoCollectionCommon::ELevelVideos)
|
30
|
393 |
{
|
|
394 |
collectionPath->AppendL( KVcxMvcCategoryIdAll );
|
|
395 |
|
36
|
396 |
mOpenCategoryAlbum = TMPXItemId(KVcxMvcCategoryIdAll, KVcxMvcMediaTypeCategory);
|
34
|
397 |
mCollectionPathLevel = VideoCollectionCommon::ELevelVideos;
|
30
|
398 |
}
|
|
399 |
else
|
|
400 |
{
|
34
|
401 |
mOpenCategoryAlbum = TMPXItemId::InvalidId();
|
|
402 |
mCollectionPathLevel = VideoCollectionCommon::ELevelCategory;
|
30
|
403 |
}
|
|
404 |
mCollectionUtility->Collection().OpenL( *collectionPath );
|
|
405 |
CleanupStack::PopAndDestroy( collectionPath );
|
34
|
406 |
|
30
|
407 |
mCollectionOpenStatus = ECollectionOpening;
|
|
408 |
}
|
|
409 |
|
|
410 |
// -----------------------------------------------------------------------------
|
|
411 |
// deleteVideosL
|
|
412 |
// -----------------------------------------------------------------------------
|
|
413 |
//
|
|
414 |
void VideoCollectionClient::deleteVideosL(QList<TMPXItemId> &mediaIds)
|
|
415 |
{
|
36
|
416 |
FUNC_LOG;
|
30
|
417 |
if(!mCollectionUtility || mediaIds.count() == 0)
|
|
418 |
{
|
|
419 |
User::Leave(KErrGeneral);
|
|
420 |
}
|
|
421 |
CMPXMediaArray* mediasToDelete = CMPXMediaArray::NewL();
|
|
422 |
CleanupStack::PushL( mediasToDelete );
|
|
423 |
|
|
424 |
CMPXMedia* media = NULL;
|
|
425 |
|
|
426 |
TMPXItemId currentId;
|
|
427 |
foreach(currentId, mediaIds)
|
|
428 |
{
|
|
429 |
media = CMPXMedia::NewL();
|
|
430 |
CleanupStack::PushL( media );
|
|
431 |
media->SetTObjectValueL( KMPXMediaGeneralId, currentId );
|
|
432 |
mediasToDelete->AppendL( *media );
|
|
433 |
CleanupStack::PopAndDestroy( media );
|
|
434 |
}
|
|
435 |
|
|
436 |
CMPXCommand* cmd = CMPXMedia::NewL();
|
|
437 |
CleanupStack::PushL( cmd );
|
|
438 |
|
|
439 |
cmd->SetTObjectValueL( KMPXCommandGeneralId, KVcxCommandIdMyVideos );
|
|
440 |
cmd->SetTObjectValueL( KVcxMediaMyVideosCommandId, KVcxCommandMyVideosDelete );
|
|
441 |
cmd->SetTObjectValueL( KMPXCommandGeneralDoSync, EFalse );
|
|
442 |
cmd->SetTObjectValueL( KMPXCommandGeneralCollectionId,
|
|
443 |
TUid::Uid( KVcxUidMyVideosMpxCollection ) );
|
|
444 |
cmd->SetCObjectValueL( KMPXMediaArrayContents, mediasToDelete );
|
|
445 |
|
|
446 |
mCollectionUtility->Collection().CommandL( *cmd );
|
|
447 |
|
|
448 |
CleanupStack::PopAndDestroy( cmd );
|
|
449 |
CleanupStack::PopAndDestroy( mediasToDelete );
|
|
450 |
}
|
|
451 |
|
|
452 |
// -----------------------------------------------------------------------------
|
|
453 |
// openVideoL
|
|
454 |
// -----------------------------------------------------------------------------
|
|
455 |
//
|
|
456 |
void VideoCollectionClient::openVideoL(TMPXItemId &videoId)
|
|
457 |
{
|
36
|
458 |
FUNC_LOG;
|
30
|
459 |
if(!mCollectionUtility)
|
|
460 |
{
|
|
461 |
User::Leave(KErrGeneral);
|
|
462 |
}
|
|
463 |
CMPXCollectionPath* path = CMPXCollectionPath::NewL();
|
|
464 |
CleanupStack::PushL( path );
|
|
465 |
path->AppendL( KVcxUidMyVideosMpxCollection );
|
|
466 |
path->AppendL( KVcxMvcCategoryIdAll );
|
34
|
467 |
path->AppendL( videoId );
|
|
468 |
path->SelectL( videoId );
|
30
|
469 |
|
|
470 |
mCollectionUtility->Collection().OpenL( *path );
|
|
471 |
CleanupStack::PopAndDestroy( path );
|
|
472 |
}
|
|
473 |
|
|
474 |
// -----------------------------------------------------------------------------
|
|
475 |
// openCategoryL
|
|
476 |
// -----------------------------------------------------------------------------
|
|
477 |
//
|
|
478 |
void VideoCollectionClient::openCategoryL(TMPXItemId &id)
|
|
479 |
{
|
36
|
480 |
FUNC_LOG;
|
30
|
481 |
if(!mCollectionUtility)
|
|
482 |
{
|
|
483 |
User::Leave(KErrGeneral);
|
|
484 |
}
|
|
485 |
CMPXCollectionPath* collectionPath = CMPXCollectionPath::NewL();
|
|
486 |
CleanupStack::PushL( collectionPath );
|
|
487 |
|
|
488 |
collectionPath->AppendL( KVcxUidMyVideosMpxCollection );
|
|
489 |
collectionPath->AppendL( id );
|
|
490 |
mCollectionUtility->Collection().OpenL( *collectionPath );
|
|
491 |
CleanupStack::PopAndDestroy( collectionPath );
|
|
492 |
|
34
|
493 |
mOpenCategoryAlbum = id;
|
|
494 |
mCollectionPathLevel = VideoCollectionCommon::ELevelAlbum;
|
30
|
495 |
mCollectionOpenStatus = ECollectionOpening;
|
|
496 |
}
|
|
497 |
|
|
498 |
// -----------------------------------------------------------------------------
|
|
499 |
// backL
|
|
500 |
// -----------------------------------------------------------------------------
|
|
501 |
//
|
|
502 |
void VideoCollectionClient::backL()
|
|
503 |
{
|
36
|
504 |
FUNC_LOG;
|
30
|
505 |
if(!mCollectionUtility)
|
|
506 |
{
|
|
507 |
User::Leave(KErrGeneral);
|
36
|
508 |
}
|
30
|
509 |
|
|
510 |
if (getCollectionLevel() > 2 )
|
|
511 |
{
|
|
512 |
mCollectionUtility->Collection().BackL();
|
|
513 |
mCollectionOpenStatus = ECollectionOpening;
|
|
514 |
|
34
|
515 |
mOpenCategoryAlbum = TMPXItemId::InvalidId();
|
|
516 |
|
|
517 |
mCollectionPathLevel = VideoCollectionCommon::ELevelCategory;
|
30
|
518 |
}
|
|
519 |
}
|
|
520 |
|
|
521 |
// -----------------------------------------------------------------------------
|
|
522 |
// getVideoDetailsL
|
|
523 |
// -----------------------------------------------------------------------------
|
|
524 |
//
|
|
525 |
void VideoCollectionClient::getVideoDetailsL(TMPXItemId &videoId)
|
|
526 |
{
|
36
|
527 |
FUNC_LOG;
|
30
|
528 |
if(!mCollectionUtility)
|
|
529 |
{
|
|
530 |
User::Leave(KErrGeneral);
|
|
531 |
}
|
|
532 |
CMPXCommand* cmd = CMPXCommand::NewL();
|
|
533 |
CleanupStack::PushL( cmd );
|
|
534 |
|
|
535 |
cmd->SetTObjectValueL( KMPXCommandGeneralId, KVcxCommandIdMyVideos );
|
|
536 |
cmd->SetTObjectValueL( KVcxMediaMyVideosCommandId, KVcxCommandMyVideosGetMediaFullDetailsByMpxId );
|
|
537 |
cmd->SetTObjectValueL( KMPXMediaGeneralId, videoId );
|
|
538 |
mCollectionUtility->Collection().CommandL( *cmd );
|
|
539 |
|
|
540 |
CleanupStack::PopAndDestroy( cmd );
|
|
541 |
}
|
|
542 |
|
|
543 |
// -----------------------------------------------------------------------------
|
34
|
544 |
// removeAlbumsL
|
30
|
545 |
// -----------------------------------------------------------------------------
|
|
546 |
//
|
34
|
547 |
void VideoCollectionClient::removeAlbumsL(const QList<TMPXItemId> &mediaIds)
|
30
|
548 |
{
|
36
|
549 |
FUNC_LOG;
|
30
|
550 |
if(!mCollectionUtility)
|
|
551 |
{
|
|
552 |
User::Leave(KErrGeneral);
|
|
553 |
}
|
34
|
554 |
|
|
555 |
CMPXCommand* cmd = CMPXCommand::NewL();
|
|
556 |
CleanupStack::PushL( cmd );
|
|
557 |
cmd->SetTObjectValueL( KMPXCommandGeneralId, KVcxCommandIdMyVideos );
|
|
558 |
cmd->SetTObjectValueL(KVcxMediaMyVideosCommandId, KVcxCommandMyVideosRemoveAlbums);
|
|
559 |
cmd->SetTObjectValueL(KMPXCommandGeneralDoSync, EFalse);
|
|
560 |
cmd->SetTObjectValueL(KMPXCommandGeneralCollectionId, TUid::Uid(KVcxUidMyVideosMpxCollection));
|
|
561 |
|
|
562 |
CMPXMediaArray* array = CMPXMediaArray::NewL();
|
|
563 |
CleanupStack::PushL( array );
|
|
564 |
CMPXMedia* media = 0;
|
|
565 |
int count = mediaIds.count();
|
|
566 |
for (int i = 0; i < count; i++)
|
|
567 |
{
|
35
|
568 |
if(mediaIds.at(i).iId2 == KVcxMvcMediaTypeAlbum)
|
|
569 |
{
|
|
570 |
media = CMPXMedia::NewL();
|
|
571 |
CleanupStack::PushL(media);
|
|
572 |
media->SetTObjectValueL(KMPXMediaGeneralId, mediaIds.at(i));
|
|
573 |
array->AppendL(*media);
|
|
574 |
CleanupStack::PopAndDestroy(media);
|
|
575 |
}
|
34
|
576 |
}
|
35
|
577 |
if(array->Count())
|
|
578 |
{
|
|
579 |
cmd->SetCObjectValueL(KMPXMediaArrayContents, array);
|
|
580 |
mCollectionUtility->Collection().CommandL(*cmd);
|
|
581 |
}
|
|
582 |
else
|
|
583 |
{
|
|
584 |
// invalid data provided
|
36
|
585 |
ERROR(KErrGeneral, "VideoCollectionClient::removeItemsFromAlbumL() no albums found");
|
35
|
586 |
User::Leave(KErrGeneral);
|
|
587 |
}
|
34
|
588 |
|
|
589 |
CleanupStack::PopAndDestroy( array );
|
|
590 |
CleanupStack::PopAndDestroy( cmd );
|
|
591 |
}
|
|
592 |
|
|
593 |
// -----------------------------------------------------------------------------
|
|
594 |
// createAlbumL
|
|
595 |
// -----------------------------------------------------------------------------
|
|
596 |
//
|
|
597 |
TMPXItemId VideoCollectionClient::createAlbumL(const QString &title)
|
|
598 |
{
|
36
|
599 |
FUNC_LOG;
|
34
|
600 |
TMPXItemId albumId = TMPXItemId::InvalidId();
|
30
|
601 |
|
|
602 |
CMPXCommand* cmd = CMPXCommand::NewL();
|
|
603 |
CleanupStack::PushL( cmd );
|
34
|
604 |
|
|
605 |
// 1. create album
|
|
606 |
TPtrC titlePtrC(title.utf16());
|
|
607 |
cmd->SetTObjectValueL(KMPXCommandGeneralId, KVcxCommandIdMyVideos);
|
|
608 |
cmd->SetTObjectValueL(KVcxMediaMyVideosCommandId, KVcxCommandMyVideosAddAlbum);
|
|
609 |
cmd->SetTextValueL(KMPXMediaGeneralTitle, titlePtrC);
|
|
610 |
cmd->SetTObjectValueL(KMPXCommandGeneralDoSync, ETrue);
|
|
611 |
cmd->SetTObjectValueL(KMPXCommandGeneralCollectionId, TUid::Uid(KVcxUidMyVideosMpxCollection));
|
30
|
612 |
|
34
|
613 |
mCollectionUtility->Collection().CommandL(*cmd);
|
30
|
614 |
|
34
|
615 |
// get album id
|
|
616 |
if (cmd->IsSupported(KMPXMediaGeneralId))
|
|
617 |
{
|
|
618 |
albumId = cmd->ValueTObjectL<TMPXItemId>(KMPXMediaGeneralId);
|
30
|
619 |
}
|
34
|
620 |
|
|
621 |
// cleanup
|
|
622 |
CleanupStack::PopAndDestroy(cmd);
|
|
623 |
|
|
624 |
return albumId;
|
|
625 |
}
|
|
626 |
|
|
627 |
// -----------------------------------------------------------------------------
|
|
628 |
// addItemsInAlbumL
|
|
629 |
// -----------------------------------------------------------------------------
|
|
630 |
//
|
35
|
631 |
void VideoCollectionClient::addItemsInAlbumL(TMPXItemId &albumId,
|
34
|
632 |
const QList<TMPXItemId> &mediaIds)
|
|
633 |
{
|
36
|
634 |
FUNC_LOG;
|
34
|
635 |
CMPXCommand* cmd = CMPXCommand::NewL();
|
|
636 |
CleanupStack::PushL(cmd);
|
|
637 |
cmd->SetTObjectValueL(KMPXCommandGeneralId, KVcxCommandIdMyVideos);
|
|
638 |
cmd->SetTObjectValueL(KVcxMediaMyVideosCommandId, KVcxCommandMyVideosAddToAlbum);
|
|
639 |
cmd->SetTObjectValueL(KVcxMediaMyVideosUint32Value, albumId.iId1);
|
|
640 |
cmd->SetTObjectValueL(KMPXCommandGeneralCollectionId, TUid::Uid(KVcxUidMyVideosMpxCollection));
|
|
641 |
|
|
642 |
CMPXMediaArray* array = CMPXMediaArray::NewL();
|
|
643 |
CleanupStack::PushL( array );
|
|
644 |
CMPXMedia* video = 0;
|
|
645 |
int count = mediaIds.count();
|
|
646 |
for (int i = 0; i < count; i++)
|
|
647 |
{
|
35
|
648 |
if(mediaIds.at(i).iId2 == KVcxMvcMediaTypeVideo)
|
|
649 |
{
|
|
650 |
video = CMPXMedia::NewL();
|
|
651 |
CleanupStack::PushL(video);
|
|
652 |
video->SetTObjectValueL(KMPXMediaGeneralId, mediaIds.at(i));
|
|
653 |
array->AppendL(*video);
|
|
654 |
CleanupStack::PopAndDestroy(video);
|
|
655 |
}
|
|
656 |
}
|
|
657 |
if(array->Count())
|
|
658 |
{
|
|
659 |
cmd->SetCObjectValueL(KMPXMediaArrayContents, array);
|
|
660 |
mCollectionUtility->Collection().CommandL(*cmd);
|
|
661 |
}
|
|
662 |
else
|
|
663 |
{
|
|
664 |
// invalid data provided
|
36
|
665 |
ERROR(KErrGeneral, "VideoCollectionClient::removeItemsFromAlbumL() no videos found");
|
35
|
666 |
User::Leave(KErrGeneral);
|
34
|
667 |
}
|
35
|
668 |
|
|
669 |
CleanupStack::PopAndDestroy(array);
|
|
670 |
CleanupStack::PopAndDestroy(cmd);
|
|
671 |
}
|
|
672 |
|
|
673 |
// -----------------------------------------------------------------------------
|
|
674 |
// removeItemsFromAlbumL
|
|
675 |
// -----------------------------------------------------------------------------
|
|
676 |
//
|
|
677 |
void VideoCollectionClient::removeItemsFromAlbumL(TMPXItemId &albumId,
|
|
678 |
const QList<TMPXItemId> &mediaIds)
|
|
679 |
{
|
36
|
680 |
FUNC_LOG;
|
35
|
681 |
CMPXCommand* cmd = CMPXCommand::NewL();
|
|
682 |
CleanupStack::PushL(cmd);
|
|
683 |
cmd->SetTObjectValueL(KMPXCommandGeneralId, KVcxCommandIdMyVideos);
|
|
684 |
cmd->SetTObjectValueL(KVcxMediaMyVideosCommandId, KVcxCommandMyVideosRemoveFromAlbum);
|
|
685 |
cmd->SetTObjectValueL(KVcxMediaMyVideosUint32Value, albumId.iId1);
|
|
686 |
cmd->SetTObjectValueL(KMPXCommandGeneralCollectionId, TUid::Uid(KVcxUidMyVideosMpxCollection));
|
34
|
687 |
|
35
|
688 |
CMPXMediaArray* array = CMPXMediaArray::NewL();
|
|
689 |
CleanupStack::PushL( array );
|
|
690 |
CMPXMedia* video = 0;
|
|
691 |
int count = mediaIds.count();
|
|
692 |
for (int i = 0; i < count; i++)
|
|
693 |
{
|
|
694 |
if(mediaIds.at(i).iId2 == KVcxMvcMediaTypeVideo)
|
|
695 |
{
|
|
696 |
video = CMPXMedia::NewL();
|
|
697 |
CleanupStack::PushL(video);
|
|
698 |
video->SetTObjectValueL(KMPXMediaGeneralId, mediaIds.at(i));
|
|
699 |
array->AppendL(*video);
|
|
700 |
CleanupStack::PopAndDestroy(video);
|
|
701 |
}
|
|
702 |
}
|
|
703 |
if(array->Count())
|
|
704 |
{
|
|
705 |
cmd->SetCObjectValueL(KMPXMediaArrayContents, array);
|
|
706 |
mCollectionUtility->Collection().CommandL(*cmd);
|
|
707 |
}
|
|
708 |
else
|
|
709 |
{
|
|
710 |
// invalid data provided
|
36
|
711 |
ERROR(KErrGeneral, "VideoCollectionClient::removeItemsFromAlbumL() no videos found");
|
35
|
712 |
User::Leave(KErrGeneral);
|
|
713 |
}
|
34
|
714 |
CleanupStack::PopAndDestroy(array);
|
|
715 |
CleanupStack::PopAndDestroy(cmd);
|
30
|
716 |
}
|
|
717 |
|
|
718 |
// -----------------------------------------------------------------------------
|
36
|
719 |
// renameAlbumL
|
|
720 |
// -----------------------------------------------------------------------------
|
|
721 |
//
|
|
722 |
void VideoCollectionClient::renameAlbumL(const TMPXItemId &albumId, const QString newTitle)
|
|
723 |
{
|
|
724 |
FUNC_LOG;
|
|
725 |
CMPXMedia *media = CMPXMedia::NewL();
|
|
726 |
CleanupStack::PushL(media);
|
|
727 |
TPtrC titlePtrC(newTitle.utf16());
|
|
728 |
media->SetTObjectValueL<TMPXItemId>(KMPXMediaGeneralId, albumId);
|
|
729 |
media->SetTextValueL(KMPXMediaGeneralTitle, titlePtrC);
|
|
730 |
|
|
731 |
CMPXCommand* cmd = CMPXMedia::NewL();
|
|
732 |
CleanupStack::PushL( cmd );
|
|
733 |
|
|
734 |
cmd->SetTObjectValueL(KMPXCommandGeneralId, KMPXCommandIdCollectionSet);
|
|
735 |
cmd->SetCObjectValueL<CMPXMedia>(KMPXCommandColSetMedia, media);
|
|
736 |
cmd->SetTObjectValueL(KMPXCommandGeneralDoSync, ETrue);
|
|
737 |
cmd->SetTObjectValueL(KMPXCommandGeneralCollectionId,
|
|
738 |
TUid::Uid(KVcxUidMyVideosMpxCollection));
|
|
739 |
|
|
740 |
mCollectionUtility->Collection().CommandL(*cmd);
|
|
741 |
|
|
742 |
CleanupStack::PopAndDestroy(cmd);
|
|
743 |
CleanupStack::PopAndDestroy(media);
|
|
744 |
}
|
|
745 |
|
|
746 |
// -----------------------------------------------------------------------------
|
30
|
747 |
// fetchMpxMediaByMpxIdL
|
|
748 |
// -----------------------------------------------------------------------------
|
|
749 |
//
|
|
750 |
void VideoCollectionClient::fetchMpxMediaByMpxIdL(TMPXItemId &aMpxId)
|
|
751 |
{
|
36
|
752 |
FUNC_LOG;
|
30
|
753 |
if(!mCollectionUtility)
|
|
754 |
{
|
|
755 |
User::Leave(KErrGeneral);
|
|
756 |
}
|
|
757 |
|
|
758 |
CMPXCommand* cmd = CMPXCommand::NewL();
|
|
759 |
CleanupStack::PushL( cmd );
|
|
760 |
cmd->SetTObjectValueL( KMPXCommandGeneralId, KVcxCommandIdMyVideos );
|
|
761 |
cmd->SetTObjectValueL( KVcxMediaMyVideosCommandId, KVcxCommandMyVideosGetMediasByMpxId );
|
|
762 |
cmd->SetTObjectValueL( KMPXCommandGeneralCollectionId,
|
|
763 |
TUid::Uid( KVcxUidMyVideosMpxCollection ) );
|
|
764 |
|
|
765 |
CMPXMediaArray* idMediaArray = CMPXMediaArray::NewL();
|
|
766 |
CleanupStack::PushL( idMediaArray );
|
|
767 |
CMPXMedia* media = CMPXMedia::NewL();
|
|
768 |
CleanupStack::PushL( media );
|
|
769 |
media->SetTObjectValueL( KMPXMessageMediaGeneralId, aMpxId );
|
|
770 |
idMediaArray->AppendL( *media );
|
|
771 |
cmd->SetCObjectValueL<CMPXMediaArray>( KMPXMediaArrayContents, idMediaArray );
|
|
772 |
cmd->SetTObjectValueL( KMPXMediaArrayCount, idMediaArray->Count() );
|
|
773 |
mCollectionUtility->Collection().CommandL( *cmd );
|
|
774 |
|
|
775 |
CleanupStack::PopAndDestroy( media );
|
|
776 |
CleanupStack::PopAndDestroy( idMediaArray );
|
|
777 |
CleanupStack::PopAndDestroy( cmd );
|
|
778 |
}
|
|
779 |
|
36
|
780 |
// End of file.
|