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