videocollection/videocollectionwrapper/src/videocollectionclient.cpp
author hgs
Thu, 01 Apr 2010 23:22:15 +0300
changeset 34 bbb98528c666
parent 30 4f111d64a341
child 35 3738fe97f027
permissions -rw-r--r--
201009
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
    
hgs
parents: 30
diff changeset
   287
    if (mCollectionUtility)
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
//
hgs
parents: 30
diff changeset
   299
int VideoCollectionClient::addItemsInAlbum(TMPXItemId albumId,
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() &&
hgs
parents: 30
diff changeset
   305
        albumId.iId2 == KVcxMvcMediaTypeAlbum)
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
// -----------------------------------------------------------------------------
hgs
parents:
diff changeset
   314
// startOpenCollectionL
hgs
parents:
diff changeset
   315
// -----------------------------------------------------------------------------
hgs
parents:
diff changeset
   316
//
hgs
parents:
diff changeset
   317
void VideoCollectionClient::startOpenCollectionL(int level)
hgs
parents:
diff changeset
   318
{
hgs
parents:
diff changeset
   319
    if(!mCollectionUtility)
hgs
parents:
diff changeset
   320
    {
hgs
parents:
diff changeset
   321
        User::Leave(KErrGeneral);
hgs
parents:
diff changeset
   322
    }
hgs
parents:
diff changeset
   323
    CMPXCollectionPath* collectionPath = CMPXCollectionPath::NewL();
hgs
parents:
diff changeset
   324
    CleanupStack::PushL( collectionPath );
hgs
parents:
diff changeset
   325
  
hgs
parents:
diff changeset
   326
    collectionPath->AppendL( KVcxUidMyVideosMpxCollection );
34
hgs
parents: 30
diff changeset
   327
    if (level == VideoCollectionCommon::ELevelVideos)
30
hgs
parents:
diff changeset
   328
    {
hgs
parents:
diff changeset
   329
    	collectionPath->AppendL( KVcxMvcCategoryIdAll );
hgs
parents:
diff changeset
   330
    	
hgs
parents:
diff changeset
   331
		mOpenCategoryAlbum.iId1 = KVcxMvcCategoryIdAll;
hgs
parents:
diff changeset
   332
    	mOpenCategoryAlbum.iId2 = 1;
hgs
parents:
diff changeset
   333
    	
34
hgs
parents: 30
diff changeset
   334
    	mCollectionPathLevel = VideoCollectionCommon::ELevelVideos;
30
hgs
parents:
diff changeset
   335
    }
hgs
parents:
diff changeset
   336
    else
hgs
parents:
diff changeset
   337
    {
34
hgs
parents: 30
diff changeset
   338
        mOpenCategoryAlbum = TMPXItemId::InvalidId();
30
hgs
parents:
diff changeset
   339
    	
34
hgs
parents: 30
diff changeset
   340
    	mCollectionPathLevel = VideoCollectionCommon::ELevelCategory;
30
hgs
parents:
diff changeset
   341
    }
hgs
parents:
diff changeset
   342
    mCollectionUtility->Collection().OpenL( *collectionPath );
hgs
parents:
diff changeset
   343
    CleanupStack::PopAndDestroy( collectionPath );  
34
hgs
parents: 30
diff changeset
   344
30
hgs
parents:
diff changeset
   345
    mCollectionOpenStatus = ECollectionOpening;
hgs
parents:
diff changeset
   346
}
hgs
parents:
diff changeset
   347
hgs
parents:
diff changeset
   348
hgs
parents:
diff changeset
   349
// -----------------------------------------------------------------------------
hgs
parents:
diff changeset
   350
// deleteVideosL
hgs
parents:
diff changeset
   351
// -----------------------------------------------------------------------------
hgs
parents:
diff changeset
   352
//
hgs
parents:
diff changeset
   353
void VideoCollectionClient::deleteVideosL(QList<TMPXItemId> &mediaIds)
hgs
parents:
diff changeset
   354
{
hgs
parents:
diff changeset
   355
    if(!mCollectionUtility || mediaIds.count() == 0)
hgs
parents:
diff changeset
   356
    {
hgs
parents:
diff changeset
   357
        User::Leave(KErrGeneral);
hgs
parents:
diff changeset
   358
    }
hgs
parents:
diff changeset
   359
    CMPXMediaArray* mediasToDelete = CMPXMediaArray::NewL();
hgs
parents:
diff changeset
   360
    CleanupStack::PushL( mediasToDelete );
hgs
parents:
diff changeset
   361
    
hgs
parents:
diff changeset
   362
    CMPXMedia* media = NULL;
hgs
parents:
diff changeset
   363
hgs
parents:
diff changeset
   364
    TMPXItemId currentId;
hgs
parents:
diff changeset
   365
    foreach(currentId, mediaIds)
hgs
parents:
diff changeset
   366
    {
hgs
parents:
diff changeset
   367
        media = CMPXMedia::NewL();
hgs
parents:
diff changeset
   368
        CleanupStack::PushL( media );
hgs
parents:
diff changeset
   369
        media->SetTObjectValueL( KMPXMediaGeneralId, currentId );
hgs
parents:
diff changeset
   370
        mediasToDelete->AppendL( *media );
hgs
parents:
diff changeset
   371
        CleanupStack::PopAndDestroy( media );
hgs
parents:
diff changeset
   372
    }
hgs
parents:
diff changeset
   373
    
hgs
parents:
diff changeset
   374
    CMPXCommand* cmd = CMPXMedia::NewL();
hgs
parents:
diff changeset
   375
    CleanupStack::PushL( cmd );
hgs
parents:
diff changeset
   376
hgs
parents:
diff changeset
   377
    cmd->SetTObjectValueL( KMPXCommandGeneralId, KVcxCommandIdMyVideos );
hgs
parents:
diff changeset
   378
    cmd->SetTObjectValueL( KVcxMediaMyVideosCommandId, KVcxCommandMyVideosDelete );    
hgs
parents:
diff changeset
   379
    cmd->SetTObjectValueL( KMPXCommandGeneralDoSync, EFalse );
hgs
parents:
diff changeset
   380
    cmd->SetTObjectValueL( KMPXCommandGeneralCollectionId, 
hgs
parents:
diff changeset
   381
                           TUid::Uid( KVcxUidMyVideosMpxCollection ) );
hgs
parents:
diff changeset
   382
    cmd->SetCObjectValueL( KMPXMediaArrayContents, mediasToDelete );
hgs
parents:
diff changeset
   383
hgs
parents:
diff changeset
   384
    mCollectionUtility->Collection().CommandL( *cmd );
hgs
parents:
diff changeset
   385
hgs
parents:
diff changeset
   386
    CleanupStack::PopAndDestroy( cmd );  
hgs
parents:
diff changeset
   387
    CleanupStack::PopAndDestroy( mediasToDelete ); 
hgs
parents:
diff changeset
   388
}
hgs
parents:
diff changeset
   389
hgs
parents:
diff changeset
   390
// -----------------------------------------------------------------------------
hgs
parents:
diff changeset
   391
// openVideoL
hgs
parents:
diff changeset
   392
// -----------------------------------------------------------------------------
hgs
parents:
diff changeset
   393
//
hgs
parents:
diff changeset
   394
void VideoCollectionClient::openVideoL(TMPXItemId &videoId)
hgs
parents:
diff changeset
   395
{
hgs
parents:
diff changeset
   396
    if(!mCollectionUtility)
hgs
parents:
diff changeset
   397
    {
hgs
parents:
diff changeset
   398
        User::Leave(KErrGeneral);
hgs
parents:
diff changeset
   399
    } 
hgs
parents:
diff changeset
   400
    CMPXCollectionPath* path = CMPXCollectionPath::NewL();
hgs
parents:
diff changeset
   401
    CleanupStack::PushL( path );
hgs
parents:
diff changeset
   402
    path->AppendL( KVcxUidMyVideosMpxCollection );
hgs
parents:
diff changeset
   403
    path->AppendL( KVcxMvcCategoryIdAll );
34
hgs
parents: 30
diff changeset
   404
    path->AppendL( videoId );
hgs
parents: 30
diff changeset
   405
    path->SelectL( videoId );
30
hgs
parents:
diff changeset
   406
      
hgs
parents:
diff changeset
   407
    mCollectionUtility->Collection().OpenL( *path );
hgs
parents:
diff changeset
   408
    CleanupStack::PopAndDestroy( path );  
hgs
parents:
diff changeset
   409
}
hgs
parents:
diff changeset
   410
hgs
parents:
diff changeset
   411
// -----------------------------------------------------------------------------
hgs
parents:
diff changeset
   412
// openCategoryL
hgs
parents:
diff changeset
   413
// -----------------------------------------------------------------------------
hgs
parents:
diff changeset
   414
//
hgs
parents:
diff changeset
   415
void VideoCollectionClient::openCategoryL(TMPXItemId &id)
hgs
parents:
diff changeset
   416
{    
hgs
parents:
diff changeset
   417
    if(!mCollectionUtility)
hgs
parents:
diff changeset
   418
    {
hgs
parents:
diff changeset
   419
        User::Leave(KErrGeneral);
hgs
parents:
diff changeset
   420
    } 
hgs
parents:
diff changeset
   421
    CMPXCollectionPath* collectionPath = CMPXCollectionPath::NewL();
hgs
parents:
diff changeset
   422
    CleanupStack::PushL( collectionPath );
hgs
parents:
diff changeset
   423
  
hgs
parents:
diff changeset
   424
    collectionPath->AppendL( KVcxUidMyVideosMpxCollection );
hgs
parents:
diff changeset
   425
    collectionPath->AppendL( id );
hgs
parents:
diff changeset
   426
    mCollectionUtility->Collection().OpenL( *collectionPath );
hgs
parents:
diff changeset
   427
    CleanupStack::PopAndDestroy( collectionPath );  
hgs
parents:
diff changeset
   428
    
34
hgs
parents: 30
diff changeset
   429
	mOpenCategoryAlbum = id;
hgs
parents: 30
diff changeset
   430
	mCollectionPathLevel = VideoCollectionCommon::ELevelAlbum;
30
hgs
parents:
diff changeset
   431
    mCollectionOpenStatus = ECollectionOpening;
hgs
parents:
diff changeset
   432
}
hgs
parents:
diff changeset
   433
hgs
parents:
diff changeset
   434
// -----------------------------------------------------------------------------
hgs
parents:
diff changeset
   435
// backL
hgs
parents:
diff changeset
   436
// -----------------------------------------------------------------------------
hgs
parents:
diff changeset
   437
//
hgs
parents:
diff changeset
   438
void VideoCollectionClient::backL()
hgs
parents:
diff changeset
   439
{
hgs
parents:
diff changeset
   440
    if(!mCollectionUtility)
hgs
parents:
diff changeset
   441
    {
hgs
parents:
diff changeset
   442
        User::Leave(KErrGeneral);
hgs
parents:
diff changeset
   443
    } 
hgs
parents:
diff changeset
   444
    
hgs
parents:
diff changeset
   445
    if (getCollectionLevel() > 2 )
hgs
parents:
diff changeset
   446
    {
hgs
parents:
diff changeset
   447
    	mCollectionUtility->Collection().BackL();
hgs
parents:
diff changeset
   448
    	mCollectionOpenStatus = ECollectionOpening;
hgs
parents:
diff changeset
   449
    	
34
hgs
parents: 30
diff changeset
   450
    	mOpenCategoryAlbum = TMPXItemId::InvalidId();
hgs
parents: 30
diff changeset
   451
hgs
parents: 30
diff changeset
   452
    	mCollectionPathLevel = VideoCollectionCommon::ELevelCategory;
30
hgs
parents:
diff changeset
   453
    }
hgs
parents:
diff changeset
   454
}
hgs
parents:
diff changeset
   455
hgs
parents:
diff changeset
   456
// -----------------------------------------------------------------------------
hgs
parents:
diff changeset
   457
// getVideoDetailsL
hgs
parents:
diff changeset
   458
// -----------------------------------------------------------------------------
hgs
parents:
diff changeset
   459
//
hgs
parents:
diff changeset
   460
void VideoCollectionClient::getVideoDetailsL(TMPXItemId &videoId)
hgs
parents:
diff changeset
   461
{
hgs
parents:
diff changeset
   462
    if(!mCollectionUtility)
hgs
parents:
diff changeset
   463
    {
hgs
parents:
diff changeset
   464
        User::Leave(KErrGeneral);
hgs
parents:
diff changeset
   465
    }
hgs
parents:
diff changeset
   466
    CMPXCommand* cmd = CMPXCommand::NewL();
hgs
parents:
diff changeset
   467
    CleanupStack::PushL( cmd );
hgs
parents:
diff changeset
   468
    
hgs
parents:
diff changeset
   469
    cmd->SetTObjectValueL( KMPXCommandGeneralId, KVcxCommandIdMyVideos );
hgs
parents:
diff changeset
   470
    cmd->SetTObjectValueL( KVcxMediaMyVideosCommandId, KVcxCommandMyVideosGetMediaFullDetailsByMpxId );
hgs
parents:
diff changeset
   471
    cmd->SetTObjectValueL( KMPXMediaGeneralId, videoId );
hgs
parents:
diff changeset
   472
    mCollectionUtility->Collection().CommandL( *cmd );
hgs
parents:
diff changeset
   473
    
hgs
parents:
diff changeset
   474
    CleanupStack::PopAndDestroy( cmd );  
hgs
parents:
diff changeset
   475
}
hgs
parents:
diff changeset
   476
hgs
parents:
diff changeset
   477
// -----------------------------------------------------------------------------
34
hgs
parents: 30
diff changeset
   478
// removeAlbumsL
30
hgs
parents:
diff changeset
   479
// -----------------------------------------------------------------------------
hgs
parents:
diff changeset
   480
//
34
hgs
parents: 30
diff changeset
   481
void VideoCollectionClient::removeAlbumsL(const QList<TMPXItemId> &mediaIds)
30
hgs
parents:
diff changeset
   482
{
hgs
parents:
diff changeset
   483
    if(!mCollectionUtility)
hgs
parents:
diff changeset
   484
    {
hgs
parents:
diff changeset
   485
        User::Leave(KErrGeneral);
hgs
parents:
diff changeset
   486
    }
34
hgs
parents: 30
diff changeset
   487
hgs
parents: 30
diff changeset
   488
    CMPXCommand* cmd = CMPXCommand::NewL();
hgs
parents: 30
diff changeset
   489
    CleanupStack::PushL( cmd );
hgs
parents: 30
diff changeset
   490
    cmd->SetTObjectValueL( KMPXCommandGeneralId, KVcxCommandIdMyVideos );
hgs
parents: 30
diff changeset
   491
    cmd->SetTObjectValueL(KVcxMediaMyVideosCommandId, KVcxCommandMyVideosRemoveAlbums);
hgs
parents: 30
diff changeset
   492
    cmd->SetTObjectValueL(KMPXCommandGeneralDoSync, EFalse);
hgs
parents: 30
diff changeset
   493
    cmd->SetTObjectValueL(KMPXCommandGeneralCollectionId, TUid::Uid(KVcxUidMyVideosMpxCollection));
hgs
parents: 30
diff changeset
   494
  
hgs
parents: 30
diff changeset
   495
    CMPXMediaArray* array = CMPXMediaArray::NewL();
hgs
parents: 30
diff changeset
   496
    CleanupStack::PushL( array );
hgs
parents: 30
diff changeset
   497
    CMPXMedia* media = 0;
hgs
parents: 30
diff changeset
   498
    int count = mediaIds.count();
hgs
parents: 30
diff changeset
   499
    for (int i = 0; i < count; i++)
hgs
parents: 30
diff changeset
   500
    {
hgs
parents: 30
diff changeset
   501
        media = CMPXMedia::NewL();
hgs
parents: 30
diff changeset
   502
        CleanupStack::PushL(media);
hgs
parents: 30
diff changeset
   503
        media->SetTObjectValueL(KMPXMediaGeneralId, mediaIds.at(i));
hgs
parents: 30
diff changeset
   504
        array->AppendL(*media);
hgs
parents: 30
diff changeset
   505
        CleanupStack::PopAndDestroy(media);
hgs
parents: 30
diff changeset
   506
    }
hgs
parents: 30
diff changeset
   507
    cmd->SetCObjectValueL(KMPXMediaArrayContents, array);
hgs
parents: 30
diff changeset
   508
hgs
parents: 30
diff changeset
   509
    mCollectionUtility->Collection().CommandL(*cmd);
hgs
parents: 30
diff changeset
   510
hgs
parents: 30
diff changeset
   511
    CleanupStack::PopAndDestroy( array );  
hgs
parents: 30
diff changeset
   512
    CleanupStack::PopAndDestroy( cmd );  
hgs
parents: 30
diff changeset
   513
}
hgs
parents: 30
diff changeset
   514
hgs
parents: 30
diff changeset
   515
// -----------------------------------------------------------------------------
hgs
parents: 30
diff changeset
   516
// createAlbumL
hgs
parents: 30
diff changeset
   517
// -----------------------------------------------------------------------------
hgs
parents: 30
diff changeset
   518
//
hgs
parents: 30
diff changeset
   519
TMPXItemId VideoCollectionClient::createAlbumL(const QString &title)
hgs
parents: 30
diff changeset
   520
{
hgs
parents: 30
diff changeset
   521
    TMPXItemId albumId = TMPXItemId::InvalidId();
30
hgs
parents:
diff changeset
   522
    
hgs
parents:
diff changeset
   523
    CMPXCommand* cmd = CMPXCommand::NewL();
hgs
parents:
diff changeset
   524
    CleanupStack::PushL( cmd );
34
hgs
parents: 30
diff changeset
   525
hgs
parents: 30
diff changeset
   526
    // 1. create album
hgs
parents: 30
diff changeset
   527
    TPtrC titlePtrC(title.utf16());
hgs
parents: 30
diff changeset
   528
    cmd->SetTObjectValueL(KMPXCommandGeneralId, KVcxCommandIdMyVideos);
hgs
parents: 30
diff changeset
   529
    cmd->SetTObjectValueL(KVcxMediaMyVideosCommandId, KVcxCommandMyVideosAddAlbum);
hgs
parents: 30
diff changeset
   530
    cmd->SetTextValueL(KMPXMediaGeneralTitle, titlePtrC);
hgs
parents: 30
diff changeset
   531
    cmd->SetTObjectValueL(KMPXCommandGeneralDoSync, ETrue);
hgs
parents: 30
diff changeset
   532
    cmd->SetTObjectValueL(KMPXCommandGeneralCollectionId, TUid::Uid(KVcxUidMyVideosMpxCollection));
30
hgs
parents:
diff changeset
   533
    
34
hgs
parents: 30
diff changeset
   534
    mCollectionUtility->Collection().CommandL(*cmd);
30
hgs
parents:
diff changeset
   535
    
34
hgs
parents: 30
diff changeset
   536
    // get album id
hgs
parents: 30
diff changeset
   537
    if (cmd->IsSupported(KMPXMediaGeneralId))
hgs
parents: 30
diff changeset
   538
    {
hgs
parents: 30
diff changeset
   539
        albumId = cmd->ValueTObjectL<TMPXItemId>(KMPXMediaGeneralId);        
30
hgs
parents:
diff changeset
   540
    }
34
hgs
parents: 30
diff changeset
   541
hgs
parents: 30
diff changeset
   542
    // cleanup
hgs
parents: 30
diff changeset
   543
    CleanupStack::PopAndDestroy(cmd);
hgs
parents: 30
diff changeset
   544
hgs
parents: 30
diff changeset
   545
    return albumId;
hgs
parents: 30
diff changeset
   546
}
hgs
parents: 30
diff changeset
   547
hgs
parents: 30
diff changeset
   548
// -----------------------------------------------------------------------------
hgs
parents: 30
diff changeset
   549
// addItemsInAlbumL
hgs
parents: 30
diff changeset
   550
// -----------------------------------------------------------------------------
hgs
parents: 30
diff changeset
   551
//
hgs
parents: 30
diff changeset
   552
void VideoCollectionClient::addItemsInAlbumL(TMPXItemId albumId,
hgs
parents: 30
diff changeset
   553
    const QList<TMPXItemId> &mediaIds)
hgs
parents: 30
diff changeset
   554
{
hgs
parents: 30
diff changeset
   555
    CMPXCommand* cmd = CMPXCommand::NewL();
hgs
parents: 30
diff changeset
   556
    CleanupStack::PushL(cmd);
hgs
parents: 30
diff changeset
   557
    cmd->SetTObjectValueL(KMPXCommandGeneralId, KVcxCommandIdMyVideos);
hgs
parents: 30
diff changeset
   558
    cmd->SetTObjectValueL(KVcxMediaMyVideosCommandId, KVcxCommandMyVideosAddToAlbum);
hgs
parents: 30
diff changeset
   559
    cmd->SetTObjectValueL(KVcxMediaMyVideosUint32Value, albumId.iId1);
hgs
parents: 30
diff changeset
   560
    cmd->SetTObjectValueL(KMPXCommandGeneralDoSync, EFalse);
hgs
parents: 30
diff changeset
   561
    cmd->SetTObjectValueL(KMPXCommandGeneralCollectionId, TUid::Uid(KVcxUidMyVideosMpxCollection));
hgs
parents: 30
diff changeset
   562
hgs
parents: 30
diff changeset
   563
    CMPXMediaArray* array = CMPXMediaArray::NewL();
hgs
parents: 30
diff changeset
   564
    CleanupStack::PushL( array );
hgs
parents: 30
diff changeset
   565
    CMPXMedia* video = 0;
hgs
parents: 30
diff changeset
   566
    int count = mediaIds.count();
hgs
parents: 30
diff changeset
   567
    for (int i = 0; i < count; i++)
hgs
parents: 30
diff changeset
   568
    {
hgs
parents: 30
diff changeset
   569
        video = CMPXMedia::NewL();
hgs
parents: 30
diff changeset
   570
        CleanupStack::PushL(video);
hgs
parents: 30
diff changeset
   571
        video->SetTObjectValueL(KMPXMediaGeneralId, mediaIds.at(i));
hgs
parents: 30
diff changeset
   572
        array->AppendL(*video);
hgs
parents: 30
diff changeset
   573
        CleanupStack::PopAndDestroy(video);
hgs
parents: 30
diff changeset
   574
    }
hgs
parents: 30
diff changeset
   575
    cmd->SetCObjectValueL(KMPXMediaArrayContents, array);
hgs
parents: 30
diff changeset
   576
hgs
parents: 30
diff changeset
   577
    mCollectionUtility->Collection().CommandL(*cmd);
hgs
parents: 30
diff changeset
   578
hgs
parents: 30
diff changeset
   579
    CleanupStack::PopAndDestroy(array);
hgs
parents: 30
diff changeset
   580
    CleanupStack::PopAndDestroy(cmd);
30
hgs
parents:
diff changeset
   581
}
hgs
parents:
diff changeset
   582
hgs
parents:
diff changeset
   583
// -----------------------------------------------------------------------------
hgs
parents:
diff changeset
   584
// fetchMpxMediaByMpxIdL
hgs
parents:
diff changeset
   585
// -----------------------------------------------------------------------------
hgs
parents:
diff changeset
   586
//
hgs
parents:
diff changeset
   587
void VideoCollectionClient::fetchMpxMediaByMpxIdL(TMPXItemId &aMpxId)
hgs
parents:
diff changeset
   588
{
hgs
parents:
diff changeset
   589
    if(!mCollectionUtility)
hgs
parents:
diff changeset
   590
    {
hgs
parents:
diff changeset
   591
        User::Leave(KErrGeneral);
hgs
parents:
diff changeset
   592
    }
hgs
parents:
diff changeset
   593
hgs
parents:
diff changeset
   594
    CMPXCommand* cmd = CMPXCommand::NewL();
hgs
parents:
diff changeset
   595
    CleanupStack::PushL( cmd );
hgs
parents:
diff changeset
   596
    cmd->SetTObjectValueL( KMPXCommandGeneralId, KVcxCommandIdMyVideos );
hgs
parents:
diff changeset
   597
    cmd->SetTObjectValueL( KVcxMediaMyVideosCommandId, KVcxCommandMyVideosGetMediasByMpxId );
hgs
parents:
diff changeset
   598
    cmd->SetTObjectValueL( KMPXCommandGeneralCollectionId,
hgs
parents:
diff changeset
   599
                                   TUid::Uid( KVcxUidMyVideosMpxCollection ) );
hgs
parents:
diff changeset
   600
   
hgs
parents:
diff changeset
   601
    CMPXMediaArray* idMediaArray = CMPXMediaArray::NewL();
hgs
parents:
diff changeset
   602
    CleanupStack::PushL( idMediaArray );
hgs
parents:
diff changeset
   603
    CMPXMedia* media = CMPXMedia::NewL();
hgs
parents:
diff changeset
   604
    CleanupStack::PushL( media );
hgs
parents:
diff changeset
   605
    media->SetTObjectValueL( KMPXMessageMediaGeneralId, aMpxId );
hgs
parents:
diff changeset
   606
    idMediaArray->AppendL( *media );
hgs
parents:
diff changeset
   607
    cmd->SetCObjectValueL<CMPXMediaArray>( KMPXMediaArrayContents, idMediaArray );
hgs
parents:
diff changeset
   608
    cmd->SetTObjectValueL( KMPXMediaArrayCount, idMediaArray->Count() );
hgs
parents:
diff changeset
   609
    mCollectionUtility->Collection().CommandL( *cmd );
hgs
parents:
diff changeset
   610
   
hgs
parents:
diff changeset
   611
    CleanupStack::PopAndDestroy( media );  
hgs
parents:
diff changeset
   612
    CleanupStack::PopAndDestroy( idMediaArray );  
hgs
parents:
diff changeset
   613
    CleanupStack::PopAndDestroy( cmd );  
hgs
parents:
diff changeset
   614
}
hgs
parents:
diff changeset
   615