videocollection/mpxmyvideoscollection/src/vcxmyvideosmdsalbums.cpp
author hgs
Thu, 01 Apr 2010 23:22:15 +0300
changeset 34 bbb98528c666
child 35 3738fe97f027
permissions -rw-r--r--
201009
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
34
hgs
parents:
diff changeset
     1
/*
hgs
parents:
diff changeset
     2
* Copyright (c) 2007 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 the License "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:  Provides albums support utilizing MDS.
hgs
parents:
diff changeset
    15
*
hgs
parents:
diff changeset
    16
*/
hgs
parents:
diff changeset
    17
hgs
parents:
diff changeset
    18
hgs
parents:
diff changeset
    19
// INCLUDE FILES
hgs
parents:
diff changeset
    20
#include <e32base.h>
hgs
parents:
diff changeset
    21
#include <mpxlog.h>
hgs
parents:
diff changeset
    22
#include <mdesession.h>
hgs
parents:
diff changeset
    23
#include <mdeconstants.h>
hgs
parents:
diff changeset
    24
#include <mdequery.h>
hgs
parents:
diff changeset
    25
#include <mpxmedia.h>
hgs
parents:
diff changeset
    26
#include <mpxmediaarray.h>
hgs
parents:
diff changeset
    27
#include <mpxmediacontainerdefs.h>
hgs
parents:
diff changeset
    28
#include <mpxmediageneraldefs.h>
hgs
parents:
diff changeset
    29
#include "vcxmyvideosmdsalbums.h"
hgs
parents:
diff changeset
    30
#include "vcxmyvideosmdsdb.h"
hgs
parents:
diff changeset
    31
#include "vcxmyvideoscollectionutil.h"
hgs
parents:
diff changeset
    32
#include "vcxmyvideosmdscmdqueue.h"
hgs
parents:
diff changeset
    33
hgs
parents:
diff changeset
    34
// ============================ MEMBER FUNCTIONS =============================
hgs
parents:
diff changeset
    35
hgs
parents:
diff changeset
    36
// ---------------------------------------------------------------------------
hgs
parents:
diff changeset
    37
// Constructor
hgs
parents:
diff changeset
    38
// ---------------------------------------------------------------------------
hgs
parents:
diff changeset
    39
//
hgs
parents:
diff changeset
    40
CVcxMyVideosMdsAlbums::CVcxMyVideosMdsAlbums( CVcxMyVideosMdsDb& aMdsDb,
hgs
parents:
diff changeset
    41
        MVcxMyVideosMdsAlbumsObserver* aObserver )
hgs
parents:
diff changeset
    42
: CActive( EPriorityStandard ), iMdsDb( aMdsDb ), iObserver(aObserver) 
hgs
parents:
diff changeset
    43
    {
hgs
parents:
diff changeset
    44
    }
hgs
parents:
diff changeset
    45
hgs
parents:
diff changeset
    46
// ---------------------------------------------------------------------------
hgs
parents:
diff changeset
    47
// 2nd-phase constructor
hgs
parents:
diff changeset
    48
// ---------------------------------------------------------------------------
hgs
parents:
diff changeset
    49
//
hgs
parents:
diff changeset
    50
void CVcxMyVideosMdsAlbums::ConstructL()
hgs
parents:
diff changeset
    51
    {
hgs
parents:
diff changeset
    52
    GetSchemaDefinitionsL();
hgs
parents:
diff changeset
    53
    CActiveScheduler::Add( this );
hgs
parents:
diff changeset
    54
    
hgs
parents:
diff changeset
    55
    if ( iObserver )
hgs
parents:
diff changeset
    56
        {
hgs
parents:
diff changeset
    57
        //ENotifyAdd and ENotifyModify are not supported
hgs
parents:
diff changeset
    58
        iMdsDb.iMdsSession->AddRelationItemObserverL( *this, NULL,
hgs
parents:
diff changeset
    59
                ENotifyRemove, iMdsDb.iNamespaceDef );
hgs
parents:
diff changeset
    60
hgs
parents:
diff changeset
    61
#if 0   
hgs
parents:
diff changeset
    62
        // We receive only IDs from here. We need to make query to get
hgs
parents:
diff changeset
    63
        // relation objects-> slow to use. We use the response from
hgs
parents:
diff changeset
    64
        // the add operation instead. This way we don't receive
hgs
parents:
diff changeset
    65
        // add events if someone else adds videos to our albums
hgs
parents:
diff changeset
    66
        // but the performance is the best possible.
hgs
parents:
diff changeset
    67
        iMdsDb.iMdsSession->AddRelationObserverL( *this, NULL,
hgs
parents:
diff changeset
    68
                ENotifyAdd | ENotifyModify | ENotifyRemove );        
hgs
parents:
diff changeset
    69
#endif
hgs
parents:
diff changeset
    70
        }
hgs
parents:
diff changeset
    71
    
hgs
parents:
diff changeset
    72
    //TODO: do we need this?
hgs
parents:
diff changeset
    73
    //iMdsDb.iMdsSession->AddRelationPresentObserverL();
hgs
parents:
diff changeset
    74
    }
hgs
parents:
diff changeset
    75
hgs
parents:
diff changeset
    76
// ---------------------------------------------------------------------------
hgs
parents:
diff changeset
    77
// Two-Phase Constructor
hgs
parents:
diff changeset
    78
// ---------------------------------------------------------------------------
hgs
parents:
diff changeset
    79
//
hgs
parents:
diff changeset
    80
CVcxMyVideosMdsAlbums* CVcxMyVideosMdsAlbums::NewL( CVcxMyVideosMdsDb& aMdsDb,
hgs
parents:
diff changeset
    81
        MVcxMyVideosMdsAlbumsObserver* aObserver )
hgs
parents:
diff changeset
    82
    {
hgs
parents:
diff changeset
    83
    CVcxMyVideosMdsAlbums* self = new(ELeave) CVcxMyVideosMdsAlbums( aMdsDb, aObserver );
hgs
parents:
diff changeset
    84
    CleanupStack::PushL( self );
hgs
parents:
diff changeset
    85
    self->ConstructL();
hgs
parents:
diff changeset
    86
    CleanupStack::Pop( self );
hgs
parents:
diff changeset
    87
    return self;
hgs
parents:
diff changeset
    88
    }
hgs
parents:
diff changeset
    89
hgs
parents:
diff changeset
    90
// ---------------------------------------------------------------------------
hgs
parents:
diff changeset
    91
// Destructor
hgs
parents:
diff changeset
    92
// ---------------------------------------------------------------------------
hgs
parents:
diff changeset
    93
//
hgs
parents:
diff changeset
    94
CVcxMyVideosMdsAlbums::~CVcxMyVideosMdsAlbums()
hgs
parents:
diff changeset
    95
    {
hgs
parents:
diff changeset
    96
    delete iAlbumQuery;
hgs
parents:
diff changeset
    97
    delete iVideoQuery;
hgs
parents:
diff changeset
    98
    delete iRelationQuery;
hgs
parents:
diff changeset
    99
    delete iAlbumList;
hgs
parents:
diff changeset
   100
    iItemArray.Close();
hgs
parents:
diff changeset
   101
    iResultBuffer.Close();
hgs
parents:
diff changeset
   102
    }
hgs
parents:
diff changeset
   103
hgs
parents:
diff changeset
   104
// ---------------------------------------------------------------------------
hgs
parents:
diff changeset
   105
// CVcxMyVideosMdsAlbums::Cancel
hgs
parents:
diff changeset
   106
// ---------------------------------------------------------------------------
hgs
parents:
diff changeset
   107
//
hgs
parents:
diff changeset
   108
void CVcxMyVideosMdsAlbums::Cancel( CVcxMyVideosMdsDb::TRequestType aType )
hgs
parents:
diff changeset
   109
    {
hgs
parents:
diff changeset
   110
    if ( aType == CVcxMyVideosMdsDb::EAll || aType == CVcxMyVideosMdsDb::EGetAlbums )
hgs
parents:
diff changeset
   111
        {
hgs
parents:
diff changeset
   112
        if ( iAlbumQuery )
hgs
parents:
diff changeset
   113
            {
hgs
parents:
diff changeset
   114
            iAlbumQuery->Cancel();
hgs
parents:
diff changeset
   115
            }
hgs
parents:
diff changeset
   116
        }
hgs
parents:
diff changeset
   117
hgs
parents:
diff changeset
   118
    if ( aType == CVcxMyVideosMdsDb::EAll || aType == CVcxMyVideosMdsDb::EGetAlbumContentIds )
hgs
parents:
diff changeset
   119
        {
hgs
parents:
diff changeset
   120
        if ( iRelationQuery )
hgs
parents:
diff changeset
   121
            {
hgs
parents:
diff changeset
   122
            iRelationQuery->Cancel();
hgs
parents:
diff changeset
   123
            }
hgs
parents:
diff changeset
   124
        }
hgs
parents:
diff changeset
   125
hgs
parents:
diff changeset
   126
    if ( aType == CVcxMyVideosMdsDb::EAll || aType == CVcxMyVideosMdsDb::EGetAlbumContentVideos )
hgs
parents:
diff changeset
   127
        {
hgs
parents:
diff changeset
   128
        if ( iVideoQuery )
hgs
parents:
diff changeset
   129
            {
hgs
parents:
diff changeset
   130
            iVideoQuery->Cancel();
hgs
parents:
diff changeset
   131
            }
hgs
parents:
diff changeset
   132
        }
hgs
parents:
diff changeset
   133
    
hgs
parents:
diff changeset
   134
    
hgs
parents:
diff changeset
   135
    //TODO: cancel for "add to album"
hgs
parents:
diff changeset
   136
    
hgs
parents:
diff changeset
   137
    //TODO: cancel for "remove from album"
hgs
parents:
diff changeset
   138
    
hgs
parents:
diff changeset
   139
    //TODO: cancel for "remove albums"
hgs
parents:
diff changeset
   140
    
hgs
parents:
diff changeset
   141
    // Seems like the only way to cancel these is to close session to MDS and reopen it...
hgs
parents:
diff changeset
   142
    }
hgs
parents:
diff changeset
   143
hgs
parents:
diff changeset
   144
// ---------------------------------------------------------------------------
hgs
parents:
diff changeset
   145
// CVcxMyVideosMdsAlbums::GetAlbumsL
hgs
parents:
diff changeset
   146
// ---------------------------------------------------------------------------
hgs
parents:
diff changeset
   147
//
hgs
parents:
diff changeset
   148
void CVcxMyVideosMdsAlbums::GetAlbumsL( CMPXMedia* aAlbumList,
hgs
parents:
diff changeset
   149
        MVcxMyVideosMdsAlbumsObserver& aClient )
hgs
parents:
diff changeset
   150
    {
hgs
parents:
diff changeset
   151
    CVcxMyVideosMdsCmdGetAlbums* cmd = new (ELeave) CVcxMyVideosMdsCmdGetAlbums;
hgs
parents:
diff changeset
   152
    CleanupStack::PushL( cmd );
hgs
parents:
diff changeset
   153
    cmd->iCmdType   = CVcxMyVideosMdsDb::EGetAlbums;
hgs
parents:
diff changeset
   154
    cmd->iClient    = &aClient;
hgs
parents:
diff changeset
   155
    cmd->iAlbumList = aAlbumList;
hgs
parents:
diff changeset
   156
    iMdsDb.iCmdQueue->ExecuteCmdL( cmd ); //owneship moves
hgs
parents:
diff changeset
   157
    CleanupStack::Pop( cmd );
hgs
parents:
diff changeset
   158
    }
hgs
parents:
diff changeset
   159
    
hgs
parents:
diff changeset
   160
// ---------------------------------------------------------------------------
hgs
parents:
diff changeset
   161
// CVcxMyVideosMdsAlbums::DoGetAlbumsL
hgs
parents:
diff changeset
   162
// ---------------------------------------------------------------------------
hgs
parents:
diff changeset
   163
//
hgs
parents:
diff changeset
   164
void CVcxMyVideosMdsAlbums::DoGetAlbumsL( CMPXMedia* aAlbumList,
hgs
parents:
diff changeset
   165
        MVcxMyVideosMdsAlbumsObserver& aClient )
hgs
parents:
diff changeset
   166
    {
hgs
parents:
diff changeset
   167
    MPX_DEBUG1("CVcxMyVideosMdsAlbums::DoGetAlbumsL() start");
hgs
parents:
diff changeset
   168
    
hgs
parents:
diff changeset
   169
    iAlbumList = aAlbumList; //store pointer to album list, we do not own this
hgs
parents:
diff changeset
   170
    iClient    = &aClient;
hgs
parents:
diff changeset
   171
    
hgs
parents:
diff changeset
   172
    delete iAlbumQuery;
hgs
parents:
diff changeset
   173
    iAlbumQuery = NULL;
hgs
parents:
diff changeset
   174
    
hgs
parents:
diff changeset
   175
    iAlbumQuery = iMdsDb.iMdsSession->NewObjectQueryL( *iNamespaceDef, *iAlbumObjectDef, this );
hgs
parents:
diff changeset
   176
hgs
parents:
diff changeset
   177
    CMdELogicCondition& rootCondition = iAlbumQuery->Conditions();
hgs
parents:
diff changeset
   178
    rootCondition.SetOperator( ELogicConditionOperatorOr );
hgs
parents:
diff changeset
   179
    rootCondition.AddObjectConditionL( *iAlbumObjectDef );
hgs
parents:
diff changeset
   180
    rootCondition.AddPropertyConditionL( *iTypePropertyDef,
hgs
parents:
diff changeset
   181
            TMdEIntRange( MdeConstants::Album::EAlbumUser, MdeConstants::Album::EAlbumUser,
hgs
parents:
diff changeset
   182
            EMdERangeTypeEqual ) );
hgs
parents:
diff changeset
   183
hgs
parents:
diff changeset
   184
    iAlbumQuery->FindL();
hgs
parents:
diff changeset
   185
hgs
parents:
diff changeset
   186
    MPX_DEBUG1("CVcxMyVideosMdsAlbums::DoGetAlbumsL() exit");
hgs
parents:
diff changeset
   187
    }
hgs
parents:
diff changeset
   188
hgs
parents:
diff changeset
   189
// ---------------------------------------------------------------------------
hgs
parents:
diff changeset
   190
// CVcxMyVideosMdsAlbums::GetAlbumContentIdsL
hgs
parents:
diff changeset
   191
// ---------------------------------------------------------------------------
hgs
parents:
diff changeset
   192
//
hgs
parents:
diff changeset
   193
void CVcxMyVideosMdsAlbums::GetAlbumContentIdsL( TUint32 aAlbumId,
hgs
parents:
diff changeset
   194
        RArray<TVcxMyVideosAlbumVideo>& aContentArray,
hgs
parents:
diff changeset
   195
        MVcxMyVideosMdsAlbumsObserver& aClient )
hgs
parents:
diff changeset
   196
    {
hgs
parents:
diff changeset
   197
    CVcxMyVideosMdsCmdGetAlbumContentIds* cmd = new (ELeave) CVcxMyVideosMdsCmdGetAlbumContentIds;
hgs
parents:
diff changeset
   198
    CleanupStack::PushL( cmd ); // 1->
hgs
parents:
diff changeset
   199
    cmd->iCmdType      = CVcxMyVideosMdsDb::EGetAlbumContentIds;
hgs
parents:
diff changeset
   200
    cmd->iClient       = &aClient;
hgs
parents:
diff changeset
   201
    cmd->iAlbumId      = aAlbumId;
hgs
parents:
diff changeset
   202
    cmd->iAlbumContent = &aContentArray;
hgs
parents:
diff changeset
   203
    iMdsDb.iCmdQueue->ExecuteCmdL( cmd ); //owneship moves
hgs
parents:
diff changeset
   204
    CleanupStack::Pop( cmd ); // <-1
hgs
parents:
diff changeset
   205
    }
hgs
parents:
diff changeset
   206
    
hgs
parents:
diff changeset
   207
// ---------------------------------------------------------------------------
hgs
parents:
diff changeset
   208
// CVcxMyVideosMdsAlbums::DoGetAlbumContentIdsL
hgs
parents:
diff changeset
   209
// ---------------------------------------------------------------------------
hgs
parents:
diff changeset
   210
//
hgs
parents:
diff changeset
   211
void CVcxMyVideosMdsAlbums::DoGetAlbumContentIdsL( TUint32 aAlbumId,
hgs
parents:
diff changeset
   212
        RArray<TVcxMyVideosAlbumVideo>& aContentArray,
hgs
parents:
diff changeset
   213
        MVcxMyVideosMdsAlbumsObserver& aClient )
hgs
parents:
diff changeset
   214
    {
hgs
parents:
diff changeset
   215
    MPX_DEBUG1("CVcxMyVideosMdsAlbums::DoGetAlbumContentIdsL() start");
hgs
parents:
diff changeset
   216
        
hgs
parents:
diff changeset
   217
    delete iRelationQuery;
hgs
parents:
diff changeset
   218
    iRelationQuery = NULL;
hgs
parents:
diff changeset
   219
    
hgs
parents:
diff changeset
   220
    iClient       = &aClient;
hgs
parents:
diff changeset
   221
    iAlbumId      = aAlbumId;
hgs
parents:
diff changeset
   222
    iAlbumContent = &aContentArray;
hgs
parents:
diff changeset
   223
    
hgs
parents:
diff changeset
   224
    iRelationQuery = iMdsDb.iMdsSession->NewRelationQueryL( *iNamespaceDef, this );
hgs
parents:
diff changeset
   225
hgs
parents:
diff changeset
   226
    CMdELogicCondition& rootCondition = iRelationQuery->Conditions();
hgs
parents:
diff changeset
   227
hgs
parents:
diff changeset
   228
    //relation left side contains and...
hgs
parents:
diff changeset
   229
    CMdERelationCondition& relationCondition =
hgs
parents:
diff changeset
   230
        rootCondition.AddRelationConditionL( *iContainsRelationDef, ERelationConditionSideLeft); // "AND"
hgs
parents:
diff changeset
   231
    
hgs
parents:
diff changeset
   232
    CMdELogicCondition& leftCondition = relationCondition.LeftL();
hgs
parents:
diff changeset
   233
    CMdELogicCondition& rightCondition = relationCondition.RightL();
hgs
parents:
diff changeset
   234
    
hgs
parents:
diff changeset
   235
    //...left side is album...
hgs
parents:
diff changeset
   236
    leftCondition.AddObjectConditionL( *iAlbumObjectDef );
hgs
parents:
diff changeset
   237
    //...and left id is aAlbumId..
hgs
parents:
diff changeset
   238
    leftCondition.AddObjectConditionL( aAlbumId );
hgs
parents:
diff changeset
   239
    
hgs
parents:
diff changeset
   240
    //Right side is video
hgs
parents:
diff changeset
   241
    rightCondition.AddObjectConditionL( *iMdsDb.iVideoObjectDef ); 
hgs
parents:
diff changeset
   242
    
hgs
parents:
diff changeset
   243
    iRelationQuery->FindL();
hgs
parents:
diff changeset
   244
hgs
parents:
diff changeset
   245
    MPX_DEBUG1("CVcxMyVideosMdsAlbums::DoGetAlbumContentIdsL() exit");
hgs
parents:
diff changeset
   246
    }
hgs
parents:
diff changeset
   247
hgs
parents:
diff changeset
   248
// ---------------------------------------------------------------------------
hgs
parents:
diff changeset
   249
// CVcxMyVideosMdsAlbums::GetAlbumContentVideosL
hgs
parents:
diff changeset
   250
// ---------------------------------------------------------------------------
hgs
parents:
diff changeset
   251
//
hgs
parents:
diff changeset
   252
void CVcxMyVideosMdsAlbums::GetAlbumContentVideosL( TUint32 aAlbumId, CMPXMedia& aVideoList,
hgs
parents:
diff changeset
   253
        MVcxMyVideosMdsAlbumsObserver& aClient )
hgs
parents:
diff changeset
   254
    {
hgs
parents:
diff changeset
   255
    MPX_DEBUG1("CVcxMyVideosMdsAlbums::GetAlbumContentVideosL() start");
hgs
parents:
diff changeset
   256
    
hgs
parents:
diff changeset
   257
    CVcxMyVideosMdsCmdGetAlbumContentVideos* cmd = new (ELeave) CVcxMyVideosMdsCmdGetAlbumContentVideos;
hgs
parents:
diff changeset
   258
    CleanupStack::PushL( cmd ); // 1->
hgs
parents:
diff changeset
   259
    cmd->iCmdType            = CVcxMyVideosMdsDb::EGetAlbumContentVideos;
hgs
parents:
diff changeset
   260
    cmd->iClient             = &aClient;
hgs
parents:
diff changeset
   261
    cmd->iAlbumId            = aAlbumId;
hgs
parents:
diff changeset
   262
    cmd->iAlbumContentVideos = &aVideoList;
hgs
parents:
diff changeset
   263
    iMdsDb.iCmdQueue->ExecuteCmdL( cmd ); //owneship moves
hgs
parents:
diff changeset
   264
    CleanupStack::Pop( cmd ); // <-1
hgs
parents:
diff changeset
   265
    MPX_DEBUG1("CVcxMyVideosMdsAlbums::GetAlbumContentVideosL() exit");
hgs
parents:
diff changeset
   266
    }
hgs
parents:
diff changeset
   267
hgs
parents:
diff changeset
   268
// ---------------------------------------------------------------------------
hgs
parents:
diff changeset
   269
// CVcxMyVideosMdsAlbums::DoGetAlbumContentVideosL
hgs
parents:
diff changeset
   270
// ---------------------------------------------------------------------------
hgs
parents:
diff changeset
   271
//
hgs
parents:
diff changeset
   272
void CVcxMyVideosMdsAlbums::DoGetAlbumContentVideosL( TUint32 aAlbumId, CMPXMedia& aVideoList,
hgs
parents:
diff changeset
   273
        MVcxMyVideosMdsAlbumsObserver& aClient )
hgs
parents:
diff changeset
   274
    {
hgs
parents:
diff changeset
   275
    MPX_DEBUG1("CVcxMyVideosMdsAlbums::DoGetAlbumContentVideosL() start");
hgs
parents:
diff changeset
   276
    
hgs
parents:
diff changeset
   277
    delete iVideoQuery;
hgs
parents:
diff changeset
   278
    iVideoQuery = NULL;
hgs
parents:
diff changeset
   279
hgs
parents:
diff changeset
   280
    iClient    = &aClient;
hgs
parents:
diff changeset
   281
    iVideoList = &aVideoList;
hgs
parents:
diff changeset
   282
    iAlbumId   = aAlbumId;
hgs
parents:
diff changeset
   283
    
hgs
parents:
diff changeset
   284
    iVideoQuery = iMdsDb.iMdsSession->NewObjectQueryL( *iNamespaceDef, *iMdsDb.iVideoObjectDef, this );
hgs
parents:
diff changeset
   285
    CMdELogicCondition& rootCondition = iVideoQuery->Conditions();
hgs
parents:
diff changeset
   286
    CMdERelationCondition& relationCondition = 
hgs
parents:
diff changeset
   287
            rootCondition.AddRelationConditionL( *iContainsRelationDef );
hgs
parents:
diff changeset
   288
hgs
parents:
diff changeset
   289
    CMdELogicCondition& leftCondition = relationCondition.LeftL();
hgs
parents:
diff changeset
   290
    CMdELogicCondition& rightCondition = relationCondition.RightL();
hgs
parents:
diff changeset
   291
hgs
parents:
diff changeset
   292
    //...left side is an album...
hgs
parents:
diff changeset
   293
    leftCondition.AddObjectConditionL( *iAlbumObjectDef );
hgs
parents:
diff changeset
   294
    //...and left id is aAlbumId..
hgs
parents:
diff changeset
   295
    leftCondition.AddObjectConditionL( aAlbumId );
hgs
parents:
diff changeset
   296
hgs
parents:
diff changeset
   297
    //and queried object is on the right side of the relation
hgs
parents:
diff changeset
   298
    relationCondition.SetSide( ERelationConditionSideRight );
hgs
parents:
diff changeset
   299
    
hgs
parents:
diff changeset
   300
    const TInt maxItemsInQueryResult = 500;
hgs
parents:
diff changeset
   301
    iVideoQuery->FindL( KMdEQueryDefaultMaxCount, maxItemsInQueryResult );
hgs
parents:
diff changeset
   302
    
hgs
parents:
diff changeset
   303
    MPX_DEBUG1("CVcxMyVideosMdsAlbums::DoGetAlbumContentVideosL() exit");
hgs
parents:
diff changeset
   304
    }
hgs
parents:
diff changeset
   305
hgs
parents:
diff changeset
   306
// ---------------------------------------------------------------------------
hgs
parents:
diff changeset
   307
// CVcxMyVideosMdsAlbums::GetSchemaDefinitionsL
hgs
parents:
diff changeset
   308
// ---------------------------------------------------------------------------
hgs
parents:
diff changeset
   309
//
hgs
parents:
diff changeset
   310
void CVcxMyVideosMdsAlbums::GetSchemaDefinitionsL()
hgs
parents:
diff changeset
   311
    {
hgs
parents:
diff changeset
   312
    iNamespaceDef = &(iMdsDb.iMdsSession->GetDefaultNamespaceDefL());
hgs
parents:
diff changeset
   313
    
hgs
parents:
diff changeset
   314
    _LIT( KVcxAlbumObjectName, "Album" );
hgs
parents:
diff changeset
   315
    iAlbumObjectDef = &(iNamespaceDef->GetObjectDefL( KVcxAlbumObjectName ));
hgs
parents:
diff changeset
   316
hgs
parents:
diff changeset
   317
    _LIT( KVcxTypePropertyName, "Type" );
hgs
parents:
diff changeset
   318
    iTypePropertyDef = &(iAlbumObjectDef->GetPropertyDefL( KVcxTypePropertyName ));
hgs
parents:
diff changeset
   319
hgs
parents:
diff changeset
   320
    _LIT( KVcxContainsRelationName, "Contains" );
hgs
parents:
diff changeset
   321
    iContainsRelationDef =
hgs
parents:
diff changeset
   322
        &(iNamespaceDef->GetRelationDefL( KVcxContainsRelationName ));
hgs
parents:
diff changeset
   323
    }
hgs
parents:
diff changeset
   324
hgs
parents:
diff changeset
   325
// ---------------------------------------------------------------------------
hgs
parents:
diff changeset
   326
// CVcxMyVideosMdsAlbums::Object2MediaL
hgs
parents:
diff changeset
   327
// For album objects only.
hgs
parents:
diff changeset
   328
// ---------------------------------------------------------------------------
hgs
parents:
diff changeset
   329
//
hgs
parents:
diff changeset
   330
void CVcxMyVideosMdsAlbums::Object2MediaL(
hgs
parents:
diff changeset
   331
        CMdEObject& aObject,
hgs
parents:
diff changeset
   332
        CMPXMedia& aAlbum )
hgs
parents:
diff changeset
   333
    {    
hgs
parents:
diff changeset
   334
    aAlbum.SetTObjectValueL<TMPXGeneralType>(KMPXMediaGeneralType, EMPXGroup );
hgs
parents:
diff changeset
   335
   
hgs
parents:
diff changeset
   336
    CMdEProperty* property = NULL;
hgs
parents:
diff changeset
   337
hgs
parents:
diff changeset
   338
    // ID
hgs
parents:
diff changeset
   339
    TMPXItemId mpxId;
hgs
parents:
diff changeset
   340
    mpxId.iId1 = aObject.Id();
hgs
parents:
diff changeset
   341
    mpxId.iId2 = 2;
hgs
parents:
diff changeset
   342
    aAlbum.SetTObjectValueL<TMPXItemId>( KMPXMediaGeneralId, mpxId );
hgs
parents:
diff changeset
   343
    
hgs
parents:
diff changeset
   344
    // TITLE
hgs
parents:
diff changeset
   345
    if ( aObject.Property( *iMdsDb.iTitlePropertyDef, property, 0 ) != KErrNotFound )
hgs
parents:
diff changeset
   346
        {
hgs
parents:
diff changeset
   347
        aAlbum.SetTextValueL( KMPXMediaGeneralTitle,
hgs
parents:
diff changeset
   348
                static_cast<CMdETextProperty*>(property)->Value());
hgs
parents:
diff changeset
   349
        }
hgs
parents:
diff changeset
   350
       
hgs
parents:
diff changeset
   351
    // CREATION DATE
hgs
parents:
diff changeset
   352
    if ( aObject.Property( *iMdsDb.iCreationDatePropertyDef, property, 0 ) != KErrNotFound )
hgs
parents:
diff changeset
   353
        {
hgs
parents:
diff changeset
   354
        aAlbum.SetTObjectValueL<TInt64>( KMPXMediaGeneralDate,
hgs
parents:
diff changeset
   355
                static_cast<CMdETimeProperty*>(property)->Value().Int64() );
hgs
parents:
diff changeset
   356
        }
hgs
parents:
diff changeset
   357
              
hgs
parents:
diff changeset
   358
    // MODIFIED DATE
hgs
parents:
diff changeset
   359
    if ( aObject.Property( *iMdsDb.iLastModifiedDatePropertyDef, property, 0 ) != KErrNotFound )
hgs
parents:
diff changeset
   360
        {
hgs
parents:
diff changeset
   361
        aAlbum.SetTObjectValueL<TInt64>( KVcxMediaMyVideosModifiedDate,
hgs
parents:
diff changeset
   362
                static_cast<CMdETimeProperty*>(property)->Value().Int64() );
hgs
parents:
diff changeset
   363
        }
hgs
parents:
diff changeset
   364
hgs
parents:
diff changeset
   365
#if 0 //TODO
hgs
parents:
diff changeset
   366
    // ALBUM TYPE
hgs
parents:
diff changeset
   367
    if ( aObject.Property( *iTypePropertyDef, property, 0 ) != KErrNotFound )
hgs
parents:
diff changeset
   368
        {
hgs
parents:
diff changeset
   369
        aAlbum.SetTObjectValueL<TUint16>( KVcxMediaMyVideosAlbumType,
hgs
parents:
diff changeset
   370
                static_cast<CMdETUint16Property*>(property)->Value() );
hgs
parents:
diff changeset
   371
        }
hgs
parents:
diff changeset
   372
#endif
hgs
parents:
diff changeset
   373
hgs
parents:
diff changeset
   374
    //TODO: usage count
hgs
parents:
diff changeset
   375
    
hgs
parents:
diff changeset
   376
    aAlbum.SetTObjectValueL( KMPXMediaGeneralType, EMPXGroup );
hgs
parents:
diff changeset
   377
    aAlbum.SetTObjectValueL( KMPXMediaGeneralCategory, EMPXNoCategory );
hgs
parents:
diff changeset
   378
    aAlbum.SetTObjectValueL( KVcxMediaMyVideosCategoryItemCount, 0 );
hgs
parents:
diff changeset
   379
    aAlbum.SetTObjectValueL( KVcxMediaMyVideosCategoryNewItemCount, 0 );
hgs
parents:
diff changeset
   380
hgs
parents:
diff changeset
   381
    }
hgs
parents:
diff changeset
   382
hgs
parents:
diff changeset
   383
// ---------------------------------------------------------------------------
hgs
parents:
diff changeset
   384
// CVcxMyVideosMdsAlbums::Media2ObjectL
hgs
parents:
diff changeset
   385
// Called by AddAlbumL()
hgs
parents:
diff changeset
   386
// ---------------------------------------------------------------------------
hgs
parents:
diff changeset
   387
//
hgs
parents:
diff changeset
   388
void CVcxMyVideosMdsAlbums::Media2ObjectL(
hgs
parents:
diff changeset
   389
        CMPXMedia& aAlbum,
hgs
parents:
diff changeset
   390
        CMdEObject& aObject)
hgs
parents:
diff changeset
   391
    {
hgs
parents:
diff changeset
   392
    CMdEProperty* property;
hgs
parents:
diff changeset
   393
hgs
parents:
diff changeset
   394
    // MDS ID
hgs
parents:
diff changeset
   395
    
hgs
parents:
diff changeset
   396
    // TITLE (NAME)
hgs
parents:
diff changeset
   397
    if ( aAlbum.IsSupported( KMPXMediaGeneralTitle ) )
hgs
parents:
diff changeset
   398
        {
hgs
parents:
diff changeset
   399
        if ( aObject.Property( *iMdsDb.iTitlePropertyDef, property, 0 ) != KErrNotFound )
hgs
parents:
diff changeset
   400
            {
hgs
parents:
diff changeset
   401
            static_cast<CMdETextProperty*>(property)->SetValueL(
hgs
parents:
diff changeset
   402
                    aAlbum.ValueText( KMPXMediaGeneralTitle ) );
hgs
parents:
diff changeset
   403
            }
hgs
parents:
diff changeset
   404
        else
hgs
parents:
diff changeset
   405
            {
hgs
parents:
diff changeset
   406
            aObject.AddTextPropertyL(
hgs
parents:
diff changeset
   407
                    *iMdsDb.iTitlePropertyDef, aAlbum.ValueText( KMPXMediaGeneralTitle ) );
hgs
parents:
diff changeset
   408
            }
hgs
parents:
diff changeset
   409
        }
hgs
parents:
diff changeset
   410
        
hgs
parents:
diff changeset
   411
    // KMPXMediaGeneralDate ( creation date )
hgs
parents:
diff changeset
   412
    if ( aAlbum.IsSupported( KMPXMediaGeneralDate ) )
hgs
parents:
diff changeset
   413
        {
hgs
parents:
diff changeset
   414
        TInt64 creationDateInt64 = 0;
hgs
parents:
diff changeset
   415
        creationDateInt64 = aAlbum.ValueTObjectL<TInt64>( KMPXMediaGeneralDate );
hgs
parents:
diff changeset
   416
        TTime creationDate( creationDateInt64 );
hgs
parents:
diff changeset
   417
        if ( aObject.Property( *iMdsDb.iCreationDatePropertyDef, property, 0 ) != KErrNotFound )
hgs
parents:
diff changeset
   418
            {
hgs
parents:
diff changeset
   419
            static_cast<CMdETimeProperty*>(property)->SetValueL( creationDate );
hgs
parents:
diff changeset
   420
            }
hgs
parents:
diff changeset
   421
        else
hgs
parents:
diff changeset
   422
            {
hgs
parents:
diff changeset
   423
            aObject.AddTimePropertyL( *iMdsDb.iCreationDatePropertyDef, creationDate );
hgs
parents:
diff changeset
   424
            }
hgs
parents:
diff changeset
   425
        }
hgs
parents:
diff changeset
   426
        
hgs
parents:
diff changeset
   427
    // KVcxMediaMyVideosModifiedDate
hgs
parents:
diff changeset
   428
    if ( aAlbum.IsSupported( KVcxMediaMyVideosModifiedDate ) )
hgs
parents:
diff changeset
   429
        {
hgs
parents:
diff changeset
   430
        TInt64 modifiedDateInt64 = aAlbum.ValueTObjectL<TInt64>( KVcxMediaMyVideosModifiedDate );
hgs
parents:
diff changeset
   431
        TTime modifiedDate( modifiedDateInt64 );
hgs
parents:
diff changeset
   432
        if ( aObject.Property( *iMdsDb.iLastModifiedDatePropertyDef, property, 0 ) != KErrNotFound )
hgs
parents:
diff changeset
   433
            {
hgs
parents:
diff changeset
   434
            static_cast<CMdETimeProperty*>(property)->SetValueL( modifiedDate );
hgs
parents:
diff changeset
   435
            }
hgs
parents:
diff changeset
   436
        else
hgs
parents:
diff changeset
   437
            {
hgs
parents:
diff changeset
   438
            aObject.AddTimePropertyL( *iMdsDb.iLastModifiedDatePropertyDef, modifiedDate );
hgs
parents:
diff changeset
   439
            }
hgs
parents:
diff changeset
   440
        }        
hgs
parents:
diff changeset
   441
    }
hgs
parents:
diff changeset
   442
hgs
parents:
diff changeset
   443
// ---------------------------------------------------------------------------
hgs
parents:
diff changeset
   444
// CVcxMyVideosMdsAlbums::GetSchemaDefinitionsL
hgs
parents:
diff changeset
   445
// ---------------------------------------------------------------------------
hgs
parents:
diff changeset
   446
//
hgs
parents:
diff changeset
   447
void CVcxMyVideosMdsAlbums::HandleQueryNewResults(CMdEQuery& aQuery,
hgs
parents:
diff changeset
   448
            TInt aFirstNewItemIndex,
hgs
parents:
diff changeset
   449
            TInt aNewItemCount )
hgs
parents:
diff changeset
   450
    {
hgs
parents:
diff changeset
   451
    if ( &aQuery == iVideoQuery )
hgs
parents:
diff changeset
   452
        {
hgs
parents:
diff changeset
   453
        TRAPD( err, HandleVideoQueryResultsL( aQuery, KErrNone,
hgs
parents:
diff changeset
   454
                aFirstNewItemIndex, aNewItemCount, EFalse /* completed */ ) );
hgs
parents:
diff changeset
   455
        if ( err != KErrNone )
hgs
parents:
diff changeset
   456
            {
hgs
parents:
diff changeset
   457
            MPX_DEBUG2("CVcxMyVideosMdsAlbums:: HandleVideoQueryResultsL() left: %d", err);
hgs
parents:
diff changeset
   458
            }
hgs
parents:
diff changeset
   459
        }
hgs
parents:
diff changeset
   460
    }
hgs
parents:
diff changeset
   461
hgs
parents:
diff changeset
   462
// ---------------------------------------------------------------------------
hgs
parents:
diff changeset
   463
// CVcxMyVideosMdsAlbums::HandleQueryCompleted
hgs
parents:
diff changeset
   464
// ---------------------------------------------------------------------------
hgs
parents:
diff changeset
   465
//
hgs
parents:
diff changeset
   466
void CVcxMyVideosMdsAlbums::HandleQueryCompleted( CMdEQuery& aQuery, TInt aError )
hgs
parents:
diff changeset
   467
    {
hgs
parents:
diff changeset
   468
    if ( &aQuery == iAlbumQuery )
hgs
parents:
diff changeset
   469
        {
hgs
parents:
diff changeset
   470
        TRAPD( err, HandleAlbumQueryCompletedL( aQuery, aError ) );
hgs
parents:
diff changeset
   471
        if ( err != KErrNone )
hgs
parents:
diff changeset
   472
            {
hgs
parents:
diff changeset
   473
            MPX_DEBUG2("CVcxMyVideosMdsAlbums:: HandleAlbumQueryCompletedL() left: %d", err);
hgs
parents:
diff changeset
   474
            }
hgs
parents:
diff changeset
   475
        }
hgs
parents:
diff changeset
   476
    else if ( &aQuery == iVideoQuery )
hgs
parents:
diff changeset
   477
        {
hgs
parents:
diff changeset
   478
        TRAPD( err, HandleVideoQueryResultsL( aQuery, aError, 0, 0, ETrue /* completed */ ) );
hgs
parents:
diff changeset
   479
        if ( err != KErrNone )
hgs
parents:
diff changeset
   480
            {
hgs
parents:
diff changeset
   481
            MPX_DEBUG2("CVcxMyVideosMdsAlbums:: HandleVideoQueryResultsL() left: %d", err);
hgs
parents:
diff changeset
   482
            }
hgs
parents:
diff changeset
   483
        }
hgs
parents:
diff changeset
   484
    else if ( &aQuery == iRelationQuery )
hgs
parents:
diff changeset
   485
        {
hgs
parents:
diff changeset
   486
        TRAPD( err, HandleRelationQueryCompletedL( aQuery, aError ) );
hgs
parents:
diff changeset
   487
        if ( err != KErrNone )
hgs
parents:
diff changeset
   488
            {
hgs
parents:
diff changeset
   489
            MPX_DEBUG2("CVcxMyVideosMdsAlbums:: HandleRelationQueryCompletedL() left: %d", err);
hgs
parents:
diff changeset
   490
            }
hgs
parents:
diff changeset
   491
        }
hgs
parents:
diff changeset
   492
hgs
parents:
diff changeset
   493
    iMdsDb.iCmdQueue->CmdFinished();
hgs
parents:
diff changeset
   494
    }
hgs
parents:
diff changeset
   495
hgs
parents:
diff changeset
   496
// ---------------------------------------------------------------------------
hgs
parents:
diff changeset
   497
// CVcxMyVideosMdsAlbums::HandleAlbumQueryCompletedL
hgs
parents:
diff changeset
   498
// ---------------------------------------------------------------------------
hgs
parents:
diff changeset
   499
//
hgs
parents:
diff changeset
   500
void CVcxMyVideosMdsAlbums::HandleAlbumQueryCompletedL( CMdEQuery& /*aQuery*/, TInt aError )
hgs
parents:
diff changeset
   501
    {
hgs
parents:
diff changeset
   502
    MPX_DEBUG1("CVcxMyVideosMdsAlbums::HandleAlbumQueryCompletedL() start");
hgs
parents:
diff changeset
   503
    
hgs
parents:
diff changeset
   504
    if ( aError != KErrNone )
hgs
parents:
diff changeset
   505
        {
hgs
parents:
diff changeset
   506
        MPX_DEBUG2("CVcxMyVideosMdsAlbums:: object query failed with error: %d", aError);
hgs
parents:
diff changeset
   507
        return;
hgs
parents:
diff changeset
   508
        }
hgs
parents:
diff changeset
   509
    
hgs
parents:
diff changeset
   510
    CMPXMediaArray* array = iAlbumList->Value<CMPXMediaArray>( KMPXMediaArrayContents );
hgs
parents:
diff changeset
   511
    
hgs
parents:
diff changeset
   512
    CMPXMedia* media;    
hgs
parents:
diff changeset
   513
    TInt count = iAlbumQuery->Count();
hgs
parents:
diff changeset
   514
    
hgs
parents:
diff changeset
   515
    iAlbumList->SetTObjectValueL<TInt>( KMPXMediaArrayCount, count );
hgs
parents:
diff changeset
   516
    
hgs
parents:
diff changeset
   517
    for ( TInt i = 0; i < count; i++ )
hgs
parents:
diff changeset
   518
        {
hgs
parents:
diff changeset
   519
        CMdEObject& object = iAlbumQuery->Result( i );
hgs
parents:
diff changeset
   520
hgs
parents:
diff changeset
   521
        media = CMPXMedia::NewL();
hgs
parents:
diff changeset
   522
        CleanupStack::PushL( media ); // 1->
hgs
parents:
diff changeset
   523
hgs
parents:
diff changeset
   524
        Object2MediaL( object, *media );
hgs
parents:
diff changeset
   525
        
hgs
parents:
diff changeset
   526
#ifdef _DEBUG
hgs
parents:
diff changeset
   527
        TBuf<200> title;
hgs
parents:
diff changeset
   528
        title = TVcxMyVideosCollectionUtil::Title( *media );
hgs
parents:
diff changeset
   529
        MPX_DEBUG2("CVcxMyVideosMdsAlbums:: object title: %S", &title);
hgs
parents:
diff changeset
   530
#endif        
hgs
parents:
diff changeset
   531
hgs
parents:
diff changeset
   532
        array->AppendL( media );
hgs
parents:
diff changeset
   533
hgs
parents:
diff changeset
   534
        CleanupStack::Pop( media ); // <-1
hgs
parents:
diff changeset
   535
        }
hgs
parents:
diff changeset
   536
    
hgs
parents:
diff changeset
   537
    iClient->HandleGetAlbumsResp( iAlbumList );
hgs
parents:
diff changeset
   538
    iAlbumList = NULL;
hgs
parents:
diff changeset
   539
    
hgs
parents:
diff changeset
   540
    MPX_DEBUG1("CVcxMyVideosMdsAlbums::HandleAlbumQueryCompletedL() exit");
hgs
parents:
diff changeset
   541
    }
hgs
parents:
diff changeset
   542
hgs
parents:
diff changeset
   543
// ---------------------------------------------------------------------------
hgs
parents:
diff changeset
   544
// CVcxMyVideosMdsAlbums::HandleVideoQueryCompletedL
hgs
parents:
diff changeset
   545
// ---------------------------------------------------------------------------
hgs
parents:
diff changeset
   546
//
hgs
parents:
diff changeset
   547
void CVcxMyVideosMdsAlbums::HandleVideoQueryResultsL( CMdEQuery& /*aQuery*/, TInt aError,
hgs
parents:
diff changeset
   548
    TInt aFirstNewItemIndex, TInt aNewItemCount, TBool aComplete  )
hgs
parents:
diff changeset
   549
    {
hgs
parents:
diff changeset
   550
    MPX_DEBUG1("CVcxMyVideosMdsAlbums::HandleVideoQueryResultsL() start");
hgs
parents:
diff changeset
   551
    
hgs
parents:
diff changeset
   552
    if ( aComplete )
hgs
parents:
diff changeset
   553
        {
hgs
parents:
diff changeset
   554
        // error code given only if completed
hgs
parents:
diff changeset
   555
        if ( aError != KErrNone )
hgs
parents:
diff changeset
   556
            {
hgs
parents:
diff changeset
   557
            MPX_DEBUG2("CVcxMyVideosMdsAlbums:: object query failed with error: %d", aError);
hgs
parents:
diff changeset
   558
            }
hgs
parents:
diff changeset
   559
hgs
parents:
diff changeset
   560
        iClient->HandleGetAlbumContentVideosResp( iAlbumId, *iVideoList, 
hgs
parents:
diff changeset
   561
                aError, aFirstNewItemIndex, aNewItemCount, aComplete );
hgs
parents:
diff changeset
   562
        return;
hgs
parents:
diff changeset
   563
        }
hgs
parents:
diff changeset
   564
    
hgs
parents:
diff changeset
   565
    CMPXMediaArray* array = iVideoList->Value<CMPXMediaArray>( KMPXMediaArrayContents );
hgs
parents:
diff changeset
   566
    
hgs
parents:
diff changeset
   567
    CMPXMedia* media;    
hgs
parents:
diff changeset
   568
    TInt count = iVideoQuery->Count();
hgs
parents:
diff changeset
   569
    
hgs
parents:
diff changeset
   570
    iVideoList->SetTObjectValueL<TInt>( KMPXMediaArrayCount, count );
hgs
parents:
diff changeset
   571
    
hgs
parents:
diff changeset
   572
    for ( TInt i = aFirstNewItemIndex; i < count; i++ )
hgs
parents:
diff changeset
   573
        {
hgs
parents:
diff changeset
   574
        CMdEObject& object = iVideoQuery->Result( i );
hgs
parents:
diff changeset
   575
hgs
parents:
diff changeset
   576
        media = CMPXMedia::NewL();
hgs
parents:
diff changeset
   577
        CleanupStack::PushL( media ); // 1->
hgs
parents:
diff changeset
   578
hgs
parents:
diff changeset
   579
        iMdsDb.Object2MediaL( object, *media );
hgs
parents:
diff changeset
   580
        
hgs
parents:
diff changeset
   581
#ifdef _DEBUG
hgs
parents:
diff changeset
   582
        TBuf<200> title;
hgs
parents:
diff changeset
   583
        title = TVcxMyVideosCollectionUtil::Title( *media );
hgs
parents:
diff changeset
   584
        MPX_DEBUG2("CVcxMyVideosMdsAlbums:: object title: %S", &title);
hgs
parents:
diff changeset
   585
#endif        
hgs
parents:
diff changeset
   586
hgs
parents:
diff changeset
   587
        array->AppendL( media );
hgs
parents:
diff changeset
   588
hgs
parents:
diff changeset
   589
        CleanupStack::Pop( media ); // <-1
hgs
parents:
diff changeset
   590
        }
hgs
parents:
diff changeset
   591
    
hgs
parents:
diff changeset
   592
    iClient->HandleGetAlbumContentVideosResp( iAlbumId, *iVideoList, 
hgs
parents:
diff changeset
   593
            aError, aFirstNewItemIndex, aNewItemCount, aComplete );
hgs
parents:
diff changeset
   594
    iVideoList = NULL;
hgs
parents:
diff changeset
   595
    
hgs
parents:
diff changeset
   596
    MPX_DEBUG1("CVcxMyVideosMdsAlbums::HandleVideoQueryResultsL() exit");
hgs
parents:
diff changeset
   597
    }
hgs
parents:
diff changeset
   598
hgs
parents:
diff changeset
   599
// ---------------------------------------------------------------------------
hgs
parents:
diff changeset
   600
// CVcxMyVideosMdsAlbums::HandleRelationQueryCompletedL
hgs
parents:
diff changeset
   601
// ---------------------------------------------------------------------------
hgs
parents:
diff changeset
   602
//
hgs
parents:
diff changeset
   603
void CVcxMyVideosMdsAlbums::HandleRelationQueryCompletedL( CMdEQuery& /*aQuery*/, TInt aError )
hgs
parents:
diff changeset
   604
    {
hgs
parents:
diff changeset
   605
    MPX_DEBUG1("CVcxMyVideosMdsAlbums::HandleRelationQueryCompletedL() start");
hgs
parents:
diff changeset
   606
    
hgs
parents:
diff changeset
   607
    if ( aError != KErrNone )
hgs
parents:
diff changeset
   608
        {
hgs
parents:
diff changeset
   609
        MPX_DEBUG2("CVcxMyVideosMdsAlbums:: relation query failed with error: %d", aError);
hgs
parents:
diff changeset
   610
        return;
hgs
parents:
diff changeset
   611
        }
hgs
parents:
diff changeset
   612
            
hgs
parents:
diff changeset
   613
    TInt count = iRelationQuery->Count();
hgs
parents:
diff changeset
   614
    TVcxMyVideosAlbumVideo video;
hgs
parents:
diff changeset
   615
    for ( TInt i = 0; i < count; i++ )
hgs
parents:
diff changeset
   616
        {
hgs
parents:
diff changeset
   617
        MPX_DEBUG4("Relation (id = %d): %d contains %d", iRelationQuery->Result( i ).Id(),
hgs
parents:
diff changeset
   618
                iRelationQuery->Result( i ).LeftObjectId(),
hgs
parents:
diff changeset
   619
                iRelationQuery->Result( i ).RightObjectId());
hgs
parents:
diff changeset
   620
        video.iMdsId         = iRelationQuery->Result( i ).RightObjectId();
hgs
parents:
diff changeset
   621
        video.iRelationMdsId = iRelationQuery->Result( i ).Id();
hgs
parents:
diff changeset
   622
        iAlbumContent->AppendL( video );
hgs
parents:
diff changeset
   623
        }
hgs
parents:
diff changeset
   624
    
hgs
parents:
diff changeset
   625
    iClient->HandleGetAlbumContentIdsResp( iAlbumId, *iAlbumContent );
hgs
parents:
diff changeset
   626
hgs
parents:
diff changeset
   627
    MPX_DEBUG1("CVcxMyVideosMdsAlbums::HandleRelationQueryCompletedL() exit");
hgs
parents:
diff changeset
   628
    }
hgs
parents:
diff changeset
   629
hgs
parents:
diff changeset
   630
// ---------------------------------------------------------------------------
hgs
parents:
diff changeset
   631
// CVcxMyVideosMdsAlbums::AddVideosToAlbumL
hgs
parents:
diff changeset
   632
// ---------------------------------------------------------------------------
hgs
parents:
diff changeset
   633
//
hgs
parents:
diff changeset
   634
void CVcxMyVideosMdsAlbums::AddVideosToAlbumL( CMPXMedia* aCmd,
hgs
parents:
diff changeset
   635
        MVcxMyVideosMdsAlbumsObserver& aClient )
hgs
parents:
diff changeset
   636
    {
hgs
parents:
diff changeset
   637
    MPX_DEBUG1("CVcxMyVideosMdsAlbums::AddVideosToAlbumL() start");
hgs
parents:
diff changeset
   638
    
hgs
parents:
diff changeset
   639
    CVcxMyVideosMdsCmdAddVideosToAlbum* cmd = new (ELeave) CVcxMyVideosMdsCmdAddVideosToAlbum;
hgs
parents:
diff changeset
   640
    CleanupStack::PushL( cmd ); // 1->
hgs
parents:
diff changeset
   641
    cmd->iCmdType  = CVcxMyVideosMdsDb::EAddVideosToAlbum;
hgs
parents:
diff changeset
   642
    cmd->iClient   = &aClient;
hgs
parents:
diff changeset
   643
    cmd->iMpxCmd   = aCmd;
hgs
parents:
diff changeset
   644
    iMdsDb.iCmdQueue->ExecuteCmdL( cmd ); //owneship moves
hgs
parents:
diff changeset
   645
    CleanupStack::Pop( cmd ); // <-1
hgs
parents:
diff changeset
   646
    MPX_DEBUG1("CVcxMyVideosMdsAlbums::AddVideosToAlbumL() exit");
hgs
parents:
diff changeset
   647
    }
hgs
parents:
diff changeset
   648
    
hgs
parents:
diff changeset
   649
// ---------------------------------------------------------------------------
hgs
parents:
diff changeset
   650
// CVcxMyVideosMdsAlbums::DoAddVideosToAlbumL
hgs
parents:
diff changeset
   651
// Called by iMdsDb.iCmdQueue
hgs
parents:
diff changeset
   652
// ---------------------------------------------------------------------------
hgs
parents:
diff changeset
   653
//
hgs
parents:
diff changeset
   654
void CVcxMyVideosMdsAlbums::DoAddVideosToAlbumL( CMPXMedia* aCmd,
hgs
parents:
diff changeset
   655
        MVcxMyVideosMdsAlbumsObserver& aClient )
hgs
parents:
diff changeset
   656
    {
hgs
parents:
diff changeset
   657
    iItemArray.Reset();
hgs
parents:
diff changeset
   658
    iResultBuffer.Close();
hgs
parents:
diff changeset
   659
    CMdERelation* relation;
hgs
parents:
diff changeset
   660
    CMPXMediaArray* videoArray = TVcxMyVideosCollectionUtil::MediaArrayL( *aCmd );
hgs
parents:
diff changeset
   661
    
hgs
parents:
diff changeset
   662
    TInt albumId = TVcxMyVideosCollectionUtil::Uint32ValueL( *aCmd );
hgs
parents:
diff changeset
   663
    
hgs
parents:
diff changeset
   664
    TInt count = videoArray->Count();
hgs
parents:
diff changeset
   665
    iItemArray.Reserve( count );
hgs
parents:
diff changeset
   666
    for ( TInt i = 0; i < count; i++ )
hgs
parents:
diff changeset
   667
        {
hgs
parents:
diff changeset
   668
        relation = iMdsDb.iMdsSession->NewRelationL(
hgs
parents:
diff changeset
   669
                *iContainsRelationDef, albumId,
hgs
parents:
diff changeset
   670
                TVcxMyVideosCollectionUtil::IdL( *videoArray->AtL( i ) ) );
hgs
parents:
diff changeset
   671
        CleanupStack::PushL( relation );
hgs
parents:
diff changeset
   672
        iItemArray.AppendL( relation );
hgs
parents:
diff changeset
   673
        CleanupStack::Pop( relation );
hgs
parents:
diff changeset
   674
        }
hgs
parents:
diff changeset
   675
    
hgs
parents:
diff changeset
   676
    iClient = &aClient;
hgs
parents:
diff changeset
   677
    iMpxCmd = aCmd;
hgs
parents:
diff changeset
   678
hgs
parents:
diff changeset
   679
    iAsyncOperation = EVcxAddVideosToAlbum;
hgs
parents:
diff changeset
   680
hgs
parents:
diff changeset
   681
    iMdsDb.iMdsSession->AddItemsAsyncL( iItemArray, iStatus, iResultBuffer );
hgs
parents:
diff changeset
   682
    SetActive();
hgs
parents:
diff changeset
   683
    }
hgs
parents:
diff changeset
   684
hgs
parents:
diff changeset
   685
// ---------------------------------------------------------------------------
hgs
parents:
diff changeset
   686
// CVcxMyVideosMdsAlbums::RemoveRelationsL
hgs
parents:
diff changeset
   687
// ---------------------------------------------------------------------------
hgs
parents:
diff changeset
   688
//
hgs
parents:
diff changeset
   689
void CVcxMyVideosMdsAlbums::RemoveRelationsL( RArray<TUint32>& aRelationIds,
hgs
parents:
diff changeset
   690
        RArray<TUint32>& aResults, MVcxMyVideosMdsAlbumsObserver& aClient )
hgs
parents:
diff changeset
   691
    {
hgs
parents:
diff changeset
   692
    MPX_DEBUG1("CVcxMyVideosMdsAlbums::RemoveRelationsL() start");
hgs
parents:
diff changeset
   693
    
hgs
parents:
diff changeset
   694
    CVcxMyVideosMdsCmdRemoveRelations* cmd = new (ELeave) CVcxMyVideosMdsCmdRemoveRelations;
hgs
parents:
diff changeset
   695
    CleanupStack::PushL( cmd ); // 1->
hgs
parents:
diff changeset
   696
    cmd->iCmdType     = CVcxMyVideosMdsDb::ERemoveRelations;
hgs
parents:
diff changeset
   697
    cmd->iClient      = &aClient;
hgs
parents:
diff changeset
   698
    cmd->iRelationIds = &aRelationIds;
hgs
parents:
diff changeset
   699
    cmd->iResults     = &aResults;
hgs
parents:
diff changeset
   700
    iMdsDb.iCmdQueue->ExecuteCmdL( cmd ); //owneship moves
hgs
parents:
diff changeset
   701
    CleanupStack::Pop( cmd ); // <-1
hgs
parents:
diff changeset
   702
    MPX_DEBUG1("CVcxMyVideosMdsAlbums::RemoveRelationsL() exit");    
hgs
parents:
diff changeset
   703
    }
hgs
parents:
diff changeset
   704
hgs
parents:
diff changeset
   705
// ---------------------------------------------------------------------------
hgs
parents:
diff changeset
   706
// CVcxMyVideosMdsAlbums::DoRemoveRelationsL
hgs
parents:
diff changeset
   707
// ---------------------------------------------------------------------------
hgs
parents:
diff changeset
   708
//
hgs
parents:
diff changeset
   709
void CVcxMyVideosMdsAlbums::DoRemoveRelationsL( RArray<TUint32>& aRelationIds,
hgs
parents:
diff changeset
   710
        RArray<TUint32>& aResults, MVcxMyVideosMdsAlbumsObserver& aClient )
hgs
parents:
diff changeset
   711
    {
hgs
parents:
diff changeset
   712
    MPX_DEBUG1("CVcxMyVideosMdsAlbums::DoRemoveRelationsL() start");
hgs
parents:
diff changeset
   713
hgs
parents:
diff changeset
   714
    iResultBuffer.Close();
hgs
parents:
diff changeset
   715
    
hgs
parents:
diff changeset
   716
    iClient            = &aClient;
hgs
parents:
diff changeset
   717
    iResultArrayUint32 = &aResults;
hgs
parents:
diff changeset
   718
    iIdArray           = &aRelationIds;
hgs
parents:
diff changeset
   719
    
hgs
parents:
diff changeset
   720
    iAsyncOperation = EVcxRemoveRelations;
hgs
parents:
diff changeset
   721
    
hgs
parents:
diff changeset
   722
    iMdsDb.iMdsSession->RemoveRelationsAsyncL( *iIdArray, iStatus, iResultBuffer, iNamespaceDef );
hgs
parents:
diff changeset
   723
    SetActive();
hgs
parents:
diff changeset
   724
    
hgs
parents:
diff changeset
   725
    MPX_DEBUG1("CVcxMyVideosMdsAlbums::DoRemoveRelationsL() exit");
hgs
parents:
diff changeset
   726
    }
hgs
parents:
diff changeset
   727
hgs
parents:
diff changeset
   728
// ---------------------------------------------------------------------------
hgs
parents:
diff changeset
   729
// CVcxMyVideosMdsAlbums::AddAlbumL
hgs
parents:
diff changeset
   730
// ---------------------------------------------------------------------------
hgs
parents:
diff changeset
   731
//
hgs
parents:
diff changeset
   732
void CVcxMyVideosMdsAlbums::AddAlbumL( CMPXMedia& aAlbum )
hgs
parents:
diff changeset
   733
    {
hgs
parents:
diff changeset
   734
    MPX_DEBUG1("CVcxMyVideosMdsAlbums::AddAlbumL() start");
hgs
parents:
diff changeset
   735
    
hgs
parents:
diff changeset
   736
    if ( !iMdsDb.iMdsSession )
hgs
parents:
diff changeset
   737
        {
hgs
parents:
diff changeset
   738
        MPX_DEBUG2("CVcxMyVideosMdsAlbums:: no mds session(%d), leaving", iMdsDb.iMdsError);
hgs
parents:
diff changeset
   739
        User::Leave( iMdsDb.iMdsError );
hgs
parents:
diff changeset
   740
        }
hgs
parents:
diff changeset
   741
         
hgs
parents:
diff changeset
   742
    CMdEObject* object = iMdsDb.iMdsSession->NewObjectLC(
hgs
parents:
diff changeset
   743
            *iAlbumObjectDef, KNullDesC ); // 1->
hgs
parents:
diff changeset
   744
hgs
parents:
diff changeset
   745
    Media2ObjectL( aAlbum, *object );
hgs
parents:
diff changeset
   746
    iMdsDb.SetCreationAndModifiedDatesL( *object );
hgs
parents:
diff changeset
   747
hgs
parents:
diff changeset
   748
    TUint32 mdsId;
hgs
parents:
diff changeset
   749
hgs
parents:
diff changeset
   750
#ifdef _DEBUG
hgs
parents:
diff changeset
   751
    TRAPD( err, mdsId = iMdsDb.iMdsSession->AddObjectL( *object ) );
hgs
parents:
diff changeset
   752
hgs
parents:
diff changeset
   753
    if ( err != KErrNone )
hgs
parents:
diff changeset
   754
        {
hgs
parents:
diff changeset
   755
        MPX_DEBUG2( "CVcxMyVideosMdsAlbums:: iMdsDb.iMdsSession->AddObjectL leaved with error: %d", err );
hgs
parents:
diff changeset
   756
        User::Leave( err );
hgs
parents:
diff changeset
   757
        }
hgs
parents:
diff changeset
   758
#else
hgs
parents:
diff changeset
   759
hgs
parents:
diff changeset
   760
    mdsId = iMdsDb.iMdsSession->AddObjectL( *object );
hgs
parents:
diff changeset
   761
hgs
parents:
diff changeset
   762
#endif
hgs
parents:
diff changeset
   763
    
hgs
parents:
diff changeset
   764
    if ( mdsId == KNoId )
hgs
parents:
diff changeset
   765
        {
hgs
parents:
diff changeset
   766
        MPX_DEBUG1( "CVcxMyVideosMdsAlbums::AddAlbumL could not add new album" );
hgs
parents:
diff changeset
   767
        User::Leave( KErrGeneral );
hgs
parents:
diff changeset
   768
        }
hgs
parents:
diff changeset
   769
    
hgs
parents:
diff changeset
   770
    MPX_DEBUG2( "CVcxMyVideosMdsAlbums::AddAlbumL album created, mds id: %d", mdsId );
hgs
parents:
diff changeset
   771
hgs
parents:
diff changeset
   772
    aAlbum.SetTObjectValueL<TMPXItemId>( KMPXMediaGeneralId, TMPXItemId( mdsId, KVcxMvcMediaTypeAlbum ) );
hgs
parents:
diff changeset
   773
    
hgs
parents:
diff changeset
   774
    CleanupStack::PopAndDestroy( object ); // <-1
hgs
parents:
diff changeset
   775
    
hgs
parents:
diff changeset
   776
    MPX_DEBUG1("CVcxMyVideosMdsAlbums::AddAlbumL() exit");
hgs
parents:
diff changeset
   777
    }
hgs
parents:
diff changeset
   778
hgs
parents:
diff changeset
   779
// ---------------------------------------------------------------------------
hgs
parents:
diff changeset
   780
// CVcxMyVideosMdsAlbums::RemoveAlbumsL
hgs
parents:
diff changeset
   781
// ---------------------------------------------------------------------------
hgs
parents:
diff changeset
   782
//
hgs
parents:
diff changeset
   783
void CVcxMyVideosMdsAlbums::RemoveAlbumsL( CMPXMedia* aMpxCmd, MVcxMyVideosMdsAlbumsObserver& aClient )
hgs
parents:
diff changeset
   784
    {
hgs
parents:
diff changeset
   785
    MPX_DEBUG1("CVcxMyVideosMdsAlbums::RemoveAlbumsL() start");
hgs
parents:
diff changeset
   786
    
hgs
parents:
diff changeset
   787
    CVcxMyVideosMdsCmdRemoveAlbums* cmd = new (ELeave) CVcxMyVideosMdsCmdRemoveAlbums;
hgs
parents:
diff changeset
   788
    CleanupStack::PushL( cmd ); // 1->
hgs
parents:
diff changeset
   789
    cmd->iCmdType  = CVcxMyVideosMdsDb::ERemoveAlbums;
hgs
parents:
diff changeset
   790
    cmd->iClient   = &aClient;
hgs
parents:
diff changeset
   791
    cmd->iMpxCmd   = aMpxCmd;
hgs
parents:
diff changeset
   792
    iMdsDb.iCmdQueue->ExecuteCmdL( cmd ); //owneship moves
hgs
parents:
diff changeset
   793
    CleanupStack::Pop( cmd ); // <-1
hgs
parents:
diff changeset
   794
    MPX_DEBUG1("CVcxMyVideosMdsAlbums::RemoveAlbumsL() exit");    
hgs
parents:
diff changeset
   795
    }
hgs
parents:
diff changeset
   796
hgs
parents:
diff changeset
   797
// ---------------------------------------------------------------------------
hgs
parents:
diff changeset
   798
// CVcxMyVideosMdsAlbums::DoRemoveAlbumsL
hgs
parents:
diff changeset
   799
// ---------------------------------------------------------------------------
hgs
parents:
diff changeset
   800
//
hgs
parents:
diff changeset
   801
void CVcxMyVideosMdsAlbums::DoRemoveAlbumsL( CMPXMedia* aMpxCmd,
hgs
parents:
diff changeset
   802
        MVcxMyVideosMdsAlbumsObserver& aClient )
hgs
parents:
diff changeset
   803
    {
hgs
parents:
diff changeset
   804
    MPX_DEBUG1("CVcxMyVideosMdsAlbums::DoRemoveAlbumsL() start");
hgs
parents:
diff changeset
   805
hgs
parents:
diff changeset
   806
    iResultBuffer.Close();
hgs
parents:
diff changeset
   807
hgs
parents:
diff changeset
   808
    iClient = &aClient;
hgs
parents:
diff changeset
   809
    iMpxCmd = aMpxCmd;
hgs
parents:
diff changeset
   810
    
hgs
parents:
diff changeset
   811
    RArray<TUint32> idArray;
hgs
parents:
diff changeset
   812
    CleanupClosePushL( idArray );
hgs
parents:
diff changeset
   813
hgs
parents:
diff changeset
   814
    CMPXMediaArray* mediaArray = TVcxMyVideosCollectionUtil::MediaArrayL( *aMpxCmd );
hgs
parents:
diff changeset
   815
hgs
parents:
diff changeset
   816
    TVcxMyVideosCollectionUtil::GetIdsFromMediaArrayL( *mediaArray, idArray );
hgs
parents:
diff changeset
   817
    
hgs
parents:
diff changeset
   818
    iAsyncOperation = EVcxRemoveAlbums;
hgs
parents:
diff changeset
   819
    
hgs
parents:
diff changeset
   820
    iMdsDb.iMdsSession->RemoveObjectsAsyncL( idArray, iStatus, iResultBuffer, iNamespaceDef );
hgs
parents:
diff changeset
   821
    
hgs
parents:
diff changeset
   822
    CleanupStack::PopAndDestroy( &idArray );
hgs
parents:
diff changeset
   823
    SetActive();
hgs
parents:
diff changeset
   824
hgs
parents:
diff changeset
   825
    MPX_DEBUG1("CVcxMyVideosMdsAlbums::DoRemoveAlbumsL() exit");    
hgs
parents:
diff changeset
   826
    }
hgs
parents:
diff changeset
   827
hgs
parents:
diff changeset
   828
// ---------------------------------------------------------------------------
hgs
parents:
diff changeset
   829
// CVcxMyVideosMdsAlbums::RunL
hgs
parents:
diff changeset
   830
// From CActive.
hgs
parents:
diff changeset
   831
// ---------------------------------------------------------------------------
hgs
parents:
diff changeset
   832
//
hgs
parents:
diff changeset
   833
void CVcxMyVideosMdsAlbums::RunL()
hgs
parents:
diff changeset
   834
    {
hgs
parents:
diff changeset
   835
#ifdef _DEBUG
hgs
parents:
diff changeset
   836
    TInt status = iStatus.Int();
hgs
parents:
diff changeset
   837
    if ( status != KErrNone )
hgs
parents:
diff changeset
   838
        {
hgs
parents:
diff changeset
   839
        MPX_DEBUG2("CVcxMyVideosMdsAlbums::RunL() iStatus = %d", status);
hgs
parents:
diff changeset
   840
        }
hgs
parents:
diff changeset
   841
#endif
hgs
parents:
diff changeset
   842
    
hgs
parents:
diff changeset
   843
    switch ( iAsyncOperation )
hgs
parents:
diff changeset
   844
        {
hgs
parents:
diff changeset
   845
        case EVcxAddVideosToAlbum:
hgs
parents:
diff changeset
   846
            {
hgs
parents:
diff changeset
   847
            HandleAddVideosToAlbumCompletedL();
hgs
parents:
diff changeset
   848
            }
hgs
parents:
diff changeset
   849
            break;
hgs
parents:
diff changeset
   850
            
hgs
parents:
diff changeset
   851
        case EVcxRemoveRelations:
hgs
parents:
diff changeset
   852
            HandleRemoveRelationsCompletedL();
hgs
parents:
diff changeset
   853
            break;
hgs
parents:
diff changeset
   854
            
hgs
parents:
diff changeset
   855
        case EVcxRemoveAlbums:
hgs
parents:
diff changeset
   856
            HandleRemoveAlbumsCompletedL();
hgs
parents:
diff changeset
   857
            break;
hgs
parents:
diff changeset
   858
        }
hgs
parents:
diff changeset
   859
hgs
parents:
diff changeset
   860
    iMdsDb.iCmdQueue->CmdFinished();
hgs
parents:
diff changeset
   861
    }
hgs
parents:
diff changeset
   862
hgs
parents:
diff changeset
   863
//TODO: implement RunError
hgs
parents:
diff changeset
   864
hgs
parents:
diff changeset
   865
// ---------------------------------------------------------------------------
hgs
parents:
diff changeset
   866
// CVcxMyVideosMdsAlbums::RunL
hgs
parents:
diff changeset
   867
// From CActive.
hgs
parents:
diff changeset
   868
// ---------------------------------------------------------------------------
hgs
parents:
diff changeset
   869
//
hgs
parents:
diff changeset
   870
void CVcxMyVideosMdsAlbums::DoCancel()
hgs
parents:
diff changeset
   871
    {
hgs
parents:
diff changeset
   872
    //TODO:
hgs
parents:
diff changeset
   873
    }
hgs
parents:
diff changeset
   874
hgs
parents:
diff changeset
   875
// ---------------------------------------------------------------------------
hgs
parents:
diff changeset
   876
// CVcxMyVideosMdsAlbums::HandleAddVideosToAlbumCompletedL
hgs
parents:
diff changeset
   877
// ---------------------------------------------------------------------------
hgs
parents:
diff changeset
   878
//
hgs
parents:
diff changeset
   879
void CVcxMyVideosMdsAlbums::HandleAddVideosToAlbumCompletedL()
hgs
parents:
diff changeset
   880
    {
hgs
parents:
diff changeset
   881
    MPX_DEBUG1("CVcxMyVideosMdsAlbums::HandleAddVideosToAlbumCompletedL() start");
hgs
parents:
diff changeset
   882
    
hgs
parents:
diff changeset
   883
    iMdsDb.iMdsSession->DeserializeItemsL( iResultBuffer, iItemArray );
hgs
parents:
diff changeset
   884
    
hgs
parents:
diff changeset
   885
    iClient->HandleAddVideosToAlbumResp( iMpxCmd, iItemArray );
hgs
parents:
diff changeset
   886
    iResultBuffer.Close();
hgs
parents:
diff changeset
   887
    iItemArray.Close();    
hgs
parents:
diff changeset
   888
hgs
parents:
diff changeset
   889
    MPX_DEBUG1("CVcxMyVideosMdsAlbums::HandleAddVideosToAlbumCompletedL() exit");
hgs
parents:
diff changeset
   890
    }
hgs
parents:
diff changeset
   891
hgs
parents:
diff changeset
   892
// ---------------------------------------------------------------------------
hgs
parents:
diff changeset
   893
// CVcxMyVideosMdsAlbums::HandleRemoveRelationsCompletedL
hgs
parents:
diff changeset
   894
// ---------------------------------------------------------------------------
hgs
parents:
diff changeset
   895
//
hgs
parents:
diff changeset
   896
void CVcxMyVideosMdsAlbums::HandleRemoveRelationsCompletedL()
hgs
parents:
diff changeset
   897
    {
hgs
parents:
diff changeset
   898
    MPX_DEBUG1("CVcxMyVideosMdsAlbums::HandleRemoveRelationsCompletedL() start");
hgs
parents:
diff changeset
   899
    
hgs
parents:
diff changeset
   900
    iMdsDb.iMdsSession->DeserializeIdsL( iResultBuffer, NULL, NULL, iResultArrayUint32 );
hgs
parents:
diff changeset
   901
hgs
parents:
diff changeset
   902
#ifdef _DEBUG
hgs
parents:
diff changeset
   903
    TItemId result;
hgs
parents:
diff changeset
   904
    TInt count = iResultArrayUint32->Count();
hgs
parents:
diff changeset
   905
    for ( TInt i = 0; i < count; i++ )
hgs
parents:
diff changeset
   906
        {
hgs
parents:
diff changeset
   907
        result = (*iResultArrayUint32)[i];
hgs
parents:
diff changeset
   908
        MPX_DEBUG3("relation remove result[%d] = %d", i, result);
hgs
parents:
diff changeset
   909
        }
hgs
parents:
diff changeset
   910
#endif
hgs
parents:
diff changeset
   911
    
hgs
parents:
diff changeset
   912
    iClient->HandleRemoveRelationsResp( *iIdArray, *iResultArrayUint32 );
hgs
parents:
diff changeset
   913
hgs
parents:
diff changeset
   914
    MPX_DEBUG1("CVcxMyVideosMdsAlbums::HandleRemoveRelationsCompletedL() exit");
hgs
parents:
diff changeset
   915
    }
hgs
parents:
diff changeset
   916
hgs
parents:
diff changeset
   917
// ---------------------------------------------------------------------------
hgs
parents:
diff changeset
   918
// CVcxMyVideosMdsAlbums::HandleRemoveAlbumsCompletedL
hgs
parents:
diff changeset
   919
// ---------------------------------------------------------------------------
hgs
parents:
diff changeset
   920
//
hgs
parents:
diff changeset
   921
void CVcxMyVideosMdsAlbums::HandleRemoveAlbumsCompletedL()
hgs
parents:
diff changeset
   922
    {
hgs
parents:
diff changeset
   923
    MPX_DEBUG1("CVcxMyVideosMdsAlbums::HandleRemoveAlbumsCompletedL() start");
hgs
parents:
diff changeset
   924
hgs
parents:
diff changeset
   925
    RArray<TUint32> resultArray;
hgs
parents:
diff changeset
   926
    resultArray.Reset();
hgs
parents:
diff changeset
   927
    CleanupClosePushL( resultArray );
hgs
parents:
diff changeset
   928
    
hgs
parents:
diff changeset
   929
    iMdsDb.iMdsSession->DeserializeIdsL( iResultBuffer, &resultArray, NULL, NULL  );
hgs
parents:
diff changeset
   930
hgs
parents:
diff changeset
   931
#ifdef _DEBUG
hgs
parents:
diff changeset
   932
    TItemId result;
hgs
parents:
diff changeset
   933
    TInt count = resultArray.Count();
hgs
parents:
diff changeset
   934
hgs
parents:
diff changeset
   935
    MPX_DEBUG2("CVcxMyVideosMdsAlbums:: remove albums result count = %d", count);
hgs
parents:
diff changeset
   936
hgs
parents:
diff changeset
   937
    for ( TInt i = 0; i < count; i++ )
hgs
parents:
diff changeset
   938
        {
hgs
parents:
diff changeset
   939
        result = resultArray[i];
hgs
parents:
diff changeset
   940
        MPX_DEBUG3("CVcxMyVideosMdsAlbums:: remove albums result[%d] = %d", i, result);
hgs
parents:
diff changeset
   941
        }
hgs
parents:
diff changeset
   942
#endif
hgs
parents:
diff changeset
   943
hgs
parents:
diff changeset
   944
    iClient->HandleRemoveAlbumsResp( iMpxCmd, resultArray );
hgs
parents:
diff changeset
   945
hgs
parents:
diff changeset
   946
    CleanupStack::PopAndDestroy( &resultArray );
hgs
parents:
diff changeset
   947
    
hgs
parents:
diff changeset
   948
    MPX_DEBUG1("CVcxMyVideosMdsAlbums::HandleRemoveRelationsCompletedL() exit");
hgs
parents:
diff changeset
   949
    }
hgs
parents:
diff changeset
   950
hgs
parents:
diff changeset
   951
// ----------------------------------------------------------------------------
hgs
parents:
diff changeset
   952
// CVcxMyVideosMdsAlbums::HandleRelationItemNotification
hgs
parents:
diff changeset
   953
// From MMdERelationItemObserver
hgs
parents:
diff changeset
   954
// ----------------------------------------------------------------------------
hgs
parents:
diff changeset
   955
//
hgs
parents:
diff changeset
   956
void CVcxMyVideosMdsAlbums::HandleRelationItemNotification(CMdESession& /*aSession*/, 
hgs
parents:
diff changeset
   957
        TObserverNotificationType aType,
hgs
parents:
diff changeset
   958
        const RArray<TMdERelation>& aRelationArray)
hgs
parents:
diff changeset
   959
    {
hgs
parents:
diff changeset
   960
    iObserver->HandleRelationEvent( aType, aRelationArray );
hgs
parents:
diff changeset
   961
    }
hgs
parents:
diff changeset
   962
hgs
parents:
diff changeset
   963
#if 0 //not used
hgs
parents:
diff changeset
   964
// ----------------------------------------------------------------------------
hgs
parents:
diff changeset
   965
// CVcxMyVideosMdsAlbums::HandleRelationNotification
hgs
parents:
diff changeset
   966
// From MMdERelationObserver
hgs
parents:
diff changeset
   967
// ----------------------------------------------------------------------------
hgs
parents:
diff changeset
   968
//
hgs
parents:
diff changeset
   969
void CVcxMyVideosMdsAlbums::HandleRelationNotification(CMdESession& /*aSession*/, 
hgs
parents:
diff changeset
   970
        TObserverNotificationType aType,
hgs
parents:
diff changeset
   971
        const RArray<TItemId>& aRelationIdArray)
hgs
parents:
diff changeset
   972
    {
hgs
parents:
diff changeset
   973
    iObserver->HandleRelationIdEvent( aType, aRelationIdArray );
hgs
parents:
diff changeset
   974
    
hgs
parents:
diff changeset
   975
    switch ( aType )
hgs
parents:
diff changeset
   976
        {
hgs
parents:
diff changeset
   977
        case ENotifyAdd:
hgs
parents:
diff changeset
   978
            MPX_DEBUG1("CVcxMyVideosMdsAlbums:: ENotifyAdd");
hgs
parents:
diff changeset
   979
            break;
hgs
parents:
diff changeset
   980
        case ENotifyModify:
hgs
parents:
diff changeset
   981
            MPX_DEBUG1("CVcxMyVideosMdsAlbums:: ENotifyModify");
hgs
parents:
diff changeset
   982
            break;
hgs
parents:
diff changeset
   983
        case ENotifyRemove:
hgs
parents:
diff changeset
   984
            MPX_DEBUG1("CVcxMyVideosMdsAlbums:: ENotifyRemove");
hgs
parents:
diff changeset
   985
            break;
hgs
parents:
diff changeset
   986
        }
hgs
parents:
diff changeset
   987
    }
hgs
parents:
diff changeset
   988
#endif
hgs
parents:
diff changeset
   989
hgs
parents:
diff changeset
   990
// END OF FILE