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