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