videocollection/mpxmyvideoscollection/src/vcxmyvideosmdsdb.cpp
branchRCL_3
changeset 16 67eb01668b0e
parent 15 8f0df5c82986
child 18 baf439b22ddd
equal deleted inserted replaced
15:8f0df5c82986 16:67eb01668b0e
     9 * Initial Contributors:
     9 * Initial Contributors:
    10 * Nokia Corporation - initial contribution.
    10 * Nokia Corporation - initial contribution.
    11 *
    11 *
    12 * Contributors:
    12 * Contributors:
    13 *
    13 *
    14 * Description:    MPX My Videos collection plugin's MDS database class*
    14 * Description:   MPX My Videos collection plugin's MDS database class*
    15 */
    15 */
    16 
       
    17 
    16 
    18 
    17 
    19 
    18 
    20 //#include <harvesterclient.h>
    19 //#include <harvesterclient.h>
    21 #include <mpxlog.h>
    20 #include <mpxlog.h>
    27 #include <mpxmediacontainerdefs.h>
    26 #include <mpxmediacontainerdefs.h>
    28 #include <mpxmediageneraldefs.h>
    27 #include <mpxmediageneraldefs.h>
    29 #include <mpxmediageneralextdefs.h>
    28 #include <mpxmediageneralextdefs.h>
    30 #include <mpxmediaarray.h>
    29 #include <mpxmediaarray.h>
    31 #include <mpxmediavideodefs.h>
    30 #include <mpxmediavideodefs.h>
    32 #include <centralrepository.h>
       
    33 #include "vcxmyvideosmdsdb.h"
    31 #include "vcxmyvideosmdsdb.h"
    34 #include "vcxmyvideoscollectionutil.h"
    32 #include "vcxmyvideoscollectionutil.h"
       
    33 #include "vcxmyvideosmdsalbums.h"
       
    34 #include "vcxmyvideoscollectionutil.h"
       
    35 #include "vcxmyvideosmdscmdqueue.h"
    35 
    36 
    36 _LIT( KVcxVideoObjectName, "Video" );
    37 _LIT( KVcxVideoObjectName, "Video" );
    37                                                               //1 (ID)
    38                                                               //1 (ID)
    38 _LIT( KVcxTitlePropertyName, "Title" );                       //2
    39 _LIT( KVcxTitlePropertyName, "Title" );                       //2
    39 _LIT( KVcxDescriptionPropertyName, "Description" );           //3
    40 _LIT( KVcxDescriptionPropertyName, "Description" );           //3
    53 _LIT( KVcxAudioLanguagePropertyName, "AudioLanguage" );       //14
    54 _LIT( KVcxAudioLanguagePropertyName, "AudioLanguage" );       //14
    54 _LIT( KVcxAuthorPropertyName, "Author" );                     //15
    55 _LIT( KVcxAuthorPropertyName, "Author" );                     //15
    55 _LIT( KVcxOriginPropertyName, "Origin" );                     //16
    56 _LIT( KVcxOriginPropertyName, "Origin" );                     //16
    56 _LIT( KVcxDurationPropertyName, "Duration" );                 //17
    57 _LIT( KVcxDurationPropertyName, "Duration" );                 //17
    57 _LIT( KVcxLastPlayPositionPropertyName, "LastPlayPosition" ); //10
    58 _LIT( KVcxLastPlayPositionPropertyName, "LastPlayPosition" ); //10
    58 _LIT( KVcxDownloadIdPropertyName, "DownloadID" );             //18
       
    59 _LIT( KVcxRatingPropertyName, "Rating" );                     //19
    59 _LIT( KVcxRatingPropertyName, "Rating" );                     //19
    60 _LIT( KVcxBitratePropertyName, "Bitrate" );                   //20
    60 _LIT( KVcxBitratePropertyName, "Bitrate" );                   //20
    61 _LIT( KVcxAudioFourCcPropertyName, "AudioFourCC" );           //21
    61 _LIT( KVcxAudioFourCcPropertyName, "AudioFourCC" );           //21
    62 _LIT( KVcxWidthPropertyName, "Width" );                       //22
    62 _LIT( KVcxWidthPropertyName, "Width" );                       //22
    63 _LIT( KVcxHeightPropertyName, "Height" );                     //23
    63 _LIT( KVcxHeightPropertyName, "Height" );                     //23
   160 
   160 
   161 // ---------------------------------------------------------------------------
   161 // ---------------------------------------------------------------------------
   162 // CVcxMyVideosMdsDb::CVcxMyVideosMdsDb
   162 // CVcxMyVideosMdsDb::CVcxMyVideosMdsDb
   163 // ---------------------------------------------------------------------------
   163 // ---------------------------------------------------------------------------
   164 //
   164 //
   165 CVcxMyVideosMdsDb::CVcxMyVideosMdsDb( MVcxMyVideosMdsDbObserver* aObserver, RFs& aFs )
   165 CVcxMyVideosMdsDb::CVcxMyVideosMdsDb( MVcxMyVideosMdsDbObserver* aObserver,
   166 : iFs( aFs ), iMdsDbObserver(aObserver) 
   166         RFs& aFs, MVcxMyVideosMdsAlbumsObserver* aAlbumsObserver )
       
   167 : iFs( aFs ), iMdsDbObserver(aObserver), iAlbumsObserver(aAlbumsObserver) 
   167     {
   168     {
   168     }
   169     }
   169 
   170 
   170 // ---------------------------------------------------------------------------
   171 // ---------------------------------------------------------------------------
   171 // CVcxMyVideosMdsDb::ConstructL
   172 // CVcxMyVideosMdsDb::ConstructL
   173 //
   174 //
   174 void CVcxMyVideosMdsDb::ConstructL()
   175 void CVcxMyVideosMdsDb::ConstructL()
   175     {
   176     {
   176     MPX_DEBUG1( "CVcxMyVideosMdsDb::ConstructL start" );
   177     MPX_DEBUG1( "CVcxMyVideosMdsDb::ConstructL start" );
   177 
   178 
       
   179     iCmdQueue = CVcxMyVideosMdsCmdQueue::NewL( *this );
       
   180 
   178     iActiveSchedulerWait = new (ELeave) CActiveSchedulerWait;
   181     iActiveSchedulerWait = new (ELeave) CActiveSchedulerWait;
   179     
   182     
   180     OpenMdsSessionL();
   183     OpenMdsSessionL();
       
   184 
       
   185         
       
   186     iAlbums = CVcxMyVideosMdsAlbums::NewL( *this, iAlbumsObserver );
       
   187     
       
   188     TCallBack callBack( AsyncHandleQueryCompleted, this );    
       
   189     iAsyncHandleQueryCompleteCaller = new (ELeave) CAsyncCallBack( callBack,
       
   190             CActive::EPriorityStandard );
   181 
   191 
   182     iMdsShutdownMonitor = CVcxMdsShutdownMonitor::NewL(
   192     iMdsShutdownMonitor = CVcxMdsShutdownMonitor::NewL(
   183             *this, KHarvesterPSShutdown, KMdSShutdown, EFalse );
   193             *this, KHarvesterPSShutdown, KMdSShutdown, EFalse );
   184         
   194 
   185     MPX_DEBUG1( "CVcxMyVideosMdsDb::ConstructL exit" );
   195     MPX_DEBUG1( "CVcxMyVideosMdsDb::ConstructL exit" );
   186     }
   196     }
   187 
   197 
   188 // ---------------------------------------------------------------------------
   198 // ---------------------------------------------------------------------------
   189 // CVcxMyVideosMdsDb::OpenMdsSessionL
   199 // CVcxMyVideosMdsDb::OpenMdsSessionL
   196     iMdsSessionError = KErrNone;
   206     iMdsSessionError = KErrNone;
   197 
   207 
   198     delete iMdsSession;
   208     delete iMdsSession;
   199     iMdsSession = NULL;
   209     iMdsSession = NULL;
   200     iMdsSession = CMdESession::NewL( *this );
   210     iMdsSession = CMdESession::NewL( *this );
   201     
       
   202     if ( !iMdsSession )
   211     if ( !iMdsSession )
   203         {
   212         {
   204         User::Leave( KErrGeneral );
   213         User::Leave( KErrGeneral );
   205         }
   214         }
   206     
   215     
   220         iMdsSession->AddObjectObserverL( *this, NULL );
   229         iMdsSession->AddObjectObserverL( *this, NULL );
   221     
   230     
   222         iMdsSession->AddObjectPresentObserverL( *this );
   231         iMdsSession->AddObjectPresentObserverL( *this );
   223         
   232         
   224         GetSchemaDefinitionsL();
   233         GetSchemaDefinitionsL();
       
   234         
       
   235         if ( iAlbums )
       
   236             {
       
   237             iAlbums->GetSchemaDefinitionsL();
       
   238             iAlbums->SetObservingL();
       
   239             }
   225         }
   240         }
   226     else
   241     else
   227         {
   242         {
   228         MPX_DEBUG2( "CVcxMyVideosMdsDb:: session opening failed: %d", iMdsSessionError );
   243         MPX_DEBUG2( "CVcxMyVideosMdsDb:: session opening failed: %d", iMdsSessionError );
   229         iMdsSessionError = KErrGeneral; // this ensures that next time when mds is tried to use, it tries to open session again
   244         iMdsSessionError = KErrGeneral; // this ensures that next time when mds is tried to use, it tries to open session again
   241         TBool aPresent, const RArray<TItemId>& aObjectIdArray)
   256         TBool aPresent, const RArray<TItemId>& aObjectIdArray)
   242     {
   257     {
   243     MPX_DEBUG1( "CVcxMyVideosMdsDb::--------------------------------------------------------------." );
   258     MPX_DEBUG1( "CVcxMyVideosMdsDb::--------------------------------------------------------------." );
   244     MPX_DEBUG3( "CVcxMyVideosMdsDb::HandleObjectPresentNotification( aPresent = %1d, count = %3d) |", aPresent, aObjectIdArray.Count() );
   259     MPX_DEBUG3( "CVcxMyVideosMdsDb::HandleObjectPresentNotification( aPresent = %1d, count = %3d) |", aPresent, aObjectIdArray.Count() );
   245     MPX_DEBUG1( "CVcxMyVideosMdsDb::--------------------------------------------------------------'" );
   260     MPX_DEBUG1( "CVcxMyVideosMdsDb::--------------------------------------------------------------'" );
   246     //iMdsDbObserver->HandleObjectPresentNotification();
       
   247 
   261 
   248     TObserverNotificationType type;
   262     TObserverNotificationType type;
   249     if ( aPresent )
   263     if ( aPresent )
   250         {
   264         {
   251         type = ENotifyAdd;
   265         type = ENotifyAdd;
   259     }
   273     }
   260 
   274 
   261 // ---------------------------------------------------------------------------
   275 // ---------------------------------------------------------------------------
   262 // ---------------------------------------------------------------------------
   276 // ---------------------------------------------------------------------------
   263 //
   277 //
   264 CVcxMyVideosMdsDb* CVcxMyVideosMdsDb::NewL( MVcxMyVideosMdsDbObserver* aObserver, RFs& aFs )
   278 CVcxMyVideosMdsDb* CVcxMyVideosMdsDb::NewL( MVcxMyVideosMdsDbObserver* aObserver,
       
   279         RFs& aFs, MVcxMyVideosMdsAlbumsObserver* aAlbumsObserver )
   265     {
   280     {
   266     CVcxMyVideosMdsDb* self =
   281     CVcxMyVideosMdsDb* self =
   267             CVcxMyVideosMdsDb::NewLC( aObserver, aFs );
   282             CVcxMyVideosMdsDb::NewLC( aObserver, aFs, aAlbumsObserver );
   268     CleanupStack::Pop( self );
   283     CleanupStack::Pop( self );
   269     return self;
   284     return self;
   270     }
   285     }
   271 
   286 
   272 
   287 
   273 // ---------------------------------------------------------------------------
   288 // ---------------------------------------------------------------------------
   274 // ---------------------------------------------------------------------------
   289 // ---------------------------------------------------------------------------
   275 //
   290 //
   276 CVcxMyVideosMdsDb* CVcxMyVideosMdsDb::NewLC(
   291 CVcxMyVideosMdsDb* CVcxMyVideosMdsDb::NewLC( MVcxMyVideosMdsDbObserver* aObserver,
   277         MVcxMyVideosMdsDbObserver* aObserver, RFs& aFs )
   292         RFs& aFs, MVcxMyVideosMdsAlbumsObserver* aAlbumsObserver )
   278     {
   293     {
   279     CVcxMyVideosMdsDb* self = new( ELeave ) CVcxMyVideosMdsDb( aObserver, aFs );
   294     CVcxMyVideosMdsDb* self = new( ELeave ) CVcxMyVideosMdsDb( aObserver, aFs, aAlbumsObserver );
   280     CleanupStack::PushL( self );
   295     CleanupStack::PushL( self );
   281     self->ConstructL();
   296     self->ConstructL();
   282     return self;
   297     return self;
   283     }
   298     }
   284 
   299 
   288 //
   303 //
   289 CVcxMyVideosMdsDb::~CVcxMyVideosMdsDb()
   304 CVcxMyVideosMdsDb::~CVcxMyVideosMdsDb()
   290     {
   305     {
   291     MPX_DEBUG1( "CVcxMyVideosMdsDb::~CVcxMyVideosMdsDb() start" );
   306     MPX_DEBUG1( "CVcxMyVideosMdsDb::~CVcxMyVideosMdsDb() start" );
   292 
   307 
   293     Cancel();
   308     Cancel( EGetVideoList );
       
   309 
       
   310     delete iAlbums;
       
   311     delete iCmdQueue;
   294     delete iVideoQuery;
   312     delete iVideoQuery;
   295     delete iMdsSession;
   313     delete iMdsSession;
   296     delete iActiveSchedulerWait;
   314     delete iActiveSchedulerWait;
   297     delete iRepository;
   315     delete iAsyncHandleQueryCompleteCaller;
   298     delete iMdsShutdownMonitor;
   316     delete iMdsShutdownMonitor;
   299 
       
   300     MPX_DEBUG1( "CVcxMyVideosMdsDb::~CVcxMyVideosMdsDb() exit" );
   317     MPX_DEBUG1( "CVcxMyVideosMdsDb::~CVcxMyVideosMdsDb() exit" );
   301     }
   318     }
   302 
   319 
   303 // ---------------------------------------------------------------------------
   320 // ---------------------------------------------------------------------------
   304 // CVcxMyVideosMdsDb::Cancel
   321 // CVcxMyVideosMdsDb::Cancel
   305 // ---------------------------------------------------------------------------
   322 // ---------------------------------------------------------------------------
   306 //
   323 //
   307 void CVcxMyVideosMdsDb::Cancel()
   324 void CVcxMyVideosMdsDb::Cancel( TRequestType aType )
   308     {
   325     {
   309     MPX_DEBUG1("CVcxMyVideosMdsDb::Cancel() start");
   326     MPX_DEBUG1("CVcxMyVideosMdsDb::Cancel() start");
   310     
   327     
   311     if ( iVideoQuery )
   328     iCmdQueue->Cancel( aType );
   312         {
   329     
   313         iVideoQuery->Cancel();
   330     if ( aType == EAll || aType == EGetVideoList )
   314         }
   331         {
   315     iVideoListFetchingIsOngoing = EFalse;
   332         if ( iVideoQuery )
   316 
   333             {
       
   334             iVideoQuery->Cancel();
       
   335             }
       
   336         iVideoListFetchingIsOngoing = EFalse;
       
   337         }
       
   338 
       
   339     if ( aType != EGetVideoList )
       
   340         {
       
   341         iAlbums->CancelQueries( aType );
       
   342         }
       
   343     
   317     MPX_DEBUG1("CVcxMyVideosMdsDb::Cancel() exit");
   344     MPX_DEBUG1("CVcxMyVideosMdsDb::Cancel() exit");
   318     }
   345     }
   319     
   346     
   320 // ---------------------------------------------------------------------------
   347 // ---------------------------------------------------------------------------
   321 // CVcxMyVideosMdsDb::AddVideoL
   348 // CVcxMyVideosMdsDb::AddVideoL
   333     // Value from aVideo is taken in use in Media2ObjectL if aVideo contains creation date
   360     // Value from aVideo is taken in use in Media2ObjectL if aVideo contains creation date
   334     SetCreationAndModifiedDatesL( *object ); // use current time
   361     SetCreationAndModifiedDatesL( *object ); // use current time
   335     
   362     
   336     object->AddUint8PropertyL( *iOriginPropertyDef,
   363     object->AddUint8PropertyL( *iOriginPropertyDef,
   337             aVideo.ValueTObjectL<TUint8>( KVcxMediaMyVideosOrigin ) );
   364             aVideo.ValueTObjectL<TUint8>( KVcxMediaMyVideosOrigin ) );
   338 
   365     
   339     CMdEProperty* property;
   366     CMdEProperty* property;
   340 
   367 
   341     //  Type can not be modified normally, so set it here
   368     //  Type can not be modified normally, so set it here
   342     if ( aVideo.IsSupported( KMPXMediaGeneralMimeType ) )
   369     if ( aVideo.IsSupported( KMPXMediaGeneralMimeType ) )
   343         {
   370         {
   408     else
   435     else
   409         {
   436         {
   410         MPX_DEBUG2( "CVcxMyVideosMdsDb:: MdsSessionL().RemoveObjectL left: %d", err );
   437         MPX_DEBUG2( "CVcxMyVideosMdsDb:: MdsSessionL().RemoveObjectL left: %d", err );
   411         retValue = err;        
   438         retValue = err;        
   412         }
   439         }
   413 
   440         
   414     MPX_DEBUG1( "CVcxMyVideosMdsDb::RemoveVideoL() exit" );        
   441     MPX_DEBUG1( "CVcxMyVideosMdsDb::RemoveVideoL() exit" );        
   415     return retValue;
   442     return retValue;
   416     }
   443     }
   417 
   444 
   418 // ---------------------------------------------------------------------------
   445 // ---------------------------------------------------------------------------
   427 
   454 
   428     MPX_DEBUG2("CVcxMyVideosMdsDb::UpdateVideoL updating object %d ", mpxId.iId1);
   455     MPX_DEBUG2("CVcxMyVideosMdsDb::UpdateVideoL updating object %d ", mpxId.iId1);
   429     
   456     
   430     CMdEObject* object =
   457     CMdEObject* object =
   431             MdsSessionL().OpenObjectL( mpxId.iId1, *iVideoObjectDef );
   458             MdsSessionL().OpenObjectL( mpxId.iId1, *iVideoObjectDef );
   432     if ( object == NULL )
   459     if ( !object )
   433         {
   460         {
   434         // No object with this ID was found!
   461         // No object with this ID was found!
   435         MPX_DEBUG1("CVcxMyVideosMdsDb::UpdateVideoL no object found");
   462         MPX_DEBUG1("CVcxMyVideosMdsDb::UpdateVideoL no object found");
   436         User::Leave( KErrNotFound );
   463         User::Leave( KErrNotFound );
   437         }
   464         }
   455             MPX_DEBUG1("CVcxMyVideosMdsDb::UpdateVideoL object was locked!");
   482             MPX_DEBUG1("CVcxMyVideosMdsDb::UpdateVideoL object was locked!");
   456             delete object;
   483             delete object;
   457             User::Leave( KErrInUse );
   484             User::Leave( KErrInUse );
   458             }
   485             }
   459         }
   486         }
   460 
       
   461     MPX_DEBUG1( "CVcxMyVideosMdsDb::UpdateVideoL() exit" );
   487     MPX_DEBUG1( "CVcxMyVideosMdsDb::UpdateVideoL() exit" );
   462     }
   488     }
   463 
   489 
   464 // ---------------------------------------------------------------------------
   490 // ---------------------------------------------------------------------------
   465 // CVcxMyVideosMdsDb::CreateVideoListL
   491 // CVcxMyVideosMdsDb::CreateVideoListL
   467 //
   493 //
   468 void CVcxMyVideosMdsDb::CreateVideoListL( TVcxMyVideosSortingOrder aSortingOrder,
   494 void CVcxMyVideosMdsDb::CreateVideoListL( TVcxMyVideosSortingOrder aSortingOrder,
   469         TBool aAscending, TBool aFullDetails, CMPXMedia*& aVideoList )
   495         TBool aAscending, TBool aFullDetails, CMPXMedia*& aVideoList )
   470     {
   496     {
   471     MPX_DEBUG1( "CVcxMyVideosMdsDb::CreateVideoListL() start" );
   497     MPX_DEBUG1( "CVcxMyVideosMdsDb::CreateVideoListL() start" );
       
   498     
       
   499     CVcxMyVideosMdsCmdGetVideoList* cmd = new (ELeave) CVcxMyVideosMdsCmdGetVideoList;
       
   500     CleanupStack::PushL( cmd ); // 1->
       
   501     cmd->iCmdType      = CVcxMyVideosMdsDb::EGetVideoList;
       
   502     cmd->iSortingOrder = aSortingOrder;
       
   503     cmd->iAscending    = aAscending;
       
   504     cmd->iFullDetails  = aFullDetails;
       
   505     cmd->iVideoList    = &aVideoList;
       
   506 
       
   507     iCmdQueue->ExecuteCmdL( cmd ); //ownership moves
       
   508     CleanupStack::Pop( cmd ); // <-1
       
   509     }
       
   510     
       
   511 // ---------------------------------------------------------------------------
       
   512 // CVcxMyVideosMdsDb::DoCreateVideoListL
       
   513 // ---------------------------------------------------------------------------
       
   514 //
       
   515 void CVcxMyVideosMdsDb::DoCreateVideoListL( TVcxMyVideosSortingOrder aSortingOrder,
       
   516         TBool aAscending, TBool aFullDetails, CMPXMedia*& aVideoList )
       
   517     {
       
   518     MPX_FUNC( "CVcxMyVideosMdsDb::DoCreateVideoListL" );
   472         
   519         
   473     if ( iVideoListFetchingIsOngoing )
   520     if ( iVideoListFetchingIsOngoing )
   474         {
   521         {
   475         MPX_DEBUG1("CVcxMyVideosMdsDb:: video list fetching already going on, returning current list");
   522         MPX_DEBUG1("CVcxMyVideosMdsDb:: video list fetching already going on, returning current list");
   476         aVideoList = iVideoList;
   523         aVideoList = iVideoList;
   551 
   598 
   552     iVideoListFetchingIsOngoing = ETrue;
   599     iVideoListFetchingIsOngoing = ETrue;
   553 
   600 
   554     iFullDetails = aFullDetails;
   601     iFullDetails = aFullDetails;
   555     
   602     
   556     iVideoQuery->FindL(KMdEQueryDefaultMaxCount, 500);
   603     const TInt maxItemsInQueryResult = 500;
       
   604     iVideoQuery->FindL( KMdEQueryDefaultMaxCount, maxItemsInQueryResult );
   557 
   605 
   558     aVideoList->SetTObjectValueL<TMPXGeneralType>( KMPXMediaGeneralType, EMPXGroup );            
   606     aVideoList->SetTObjectValueL<TMPXGeneralType>( KMPXMediaGeneralType, EMPXGroup );            
   559     aVideoList->SetTObjectValueL( KMPXMediaArrayCount, mediaArray->Count() );
   607     aVideoList->SetTObjectValueL( KMPXMediaArrayCount, mediaArray->Count() );
   560 
   608 
   561     iVideoList = aVideoList; // lets store the pointer, ownership stays at observer
   609     iVideoList = aVideoList; // lets store the pointer, ownership stays at observer
   562 
       
   563     MPX_DEBUG1( "CVcxMyVideosMdsDb::CreateVideoListL() exit" );
       
   564     }
   610     }
   565 
   611 
   566 // ---------------------------------------------------------------------------
   612 // ---------------------------------------------------------------------------
   567 // From class MMdEQueryObserver.
   613 // From class MMdEQueryObserver.
   568 // ---------------------------------------------------------------------------
   614 // ---------------------------------------------------------------------------
   622         CleanupStack::Pop( media ); // <-1
   668         CleanupStack::Pop( media ); // <-1
   623         }
   669         }
   624     
   670     
   625     iMdsDbObserver->HandleCreateVideoListResp( iVideoList, aFirstNewItemIndex,
   671     iMdsDbObserver->HandleCreateVideoListResp( iVideoList, aFirstNewItemIndex,
   626             EFalse /* not complete yet */);
   672             EFalse /* not complete yet */);
   627 
       
   628     MPX_DEBUG1("CVcxMyVideosMdsDb::HandleQueryNewResults() exit");
   673     MPX_DEBUG1("CVcxMyVideosMdsDb::HandleQueryNewResults() exit");
   629     }
   674     }
   630 
   675 
   631 
   676 
   632             
   677             
   633 // ---------------------------------------------------------------------------
   678 // ---------------------------------------------------------------------------
   634 // From class MMdEQueryObserver.
   679 // From class MMdEQueryObserver.
   635 // ---------------------------------------------------------------------------
   680 // ---------------------------------------------------------------------------
   636 //
   681 //
   637 void CVcxMyVideosMdsDb::HandleQueryCompleted(
   682 void CVcxMyVideosMdsDb::HandleQueryCompleted(
   638 #if _DEBUG
       
   639         CMdEQuery& aQuery,
       
   640 #else
       
   641         CMdEQuery& /*aQuery*/,
   683         CMdEQuery& /*aQuery*/,
       
   684         TInt /*aError*/)
       
   685     {
       
   686     iAsyncHandleQueryCompleteCaller->CallBack();
       
   687     }
       
   688 
       
   689 // ---------------------------------------------------------------------------
       
   690 // CVcxMyVideosMdsDb::AsyncHandleQueryCompleted
       
   691 // ---------------------------------------------------------------------------
       
   692 //
       
   693 TInt CVcxMyVideosMdsDb::AsyncHandleQueryCompleted( TAny* aThis )
       
   694     {
       
   695     MPX_FUNC( "CVcxMyVideosMdsDb::AsyncHandleQueryCompleted" );
       
   696 
       
   697     CVcxMyVideosMdsDb* thisObj = static_cast<CVcxMyVideosMdsDb*>( aThis );
       
   698     
       
   699     if ( !thisObj->iVideoList )
       
   700         {
       
   701         MPX_DEBUG1("CVcxMyVideosMdsDb:: iVideoList is NULL, should never happen");
       
   702         return KErrNone;
       
   703         }
       
   704 
       
   705 #ifdef _DEBUG
       
   706     CMPXMediaArray* array = thisObj->iVideoList->Value<CMPXMediaArray>( KMPXMediaArrayContents );
   642 #endif
   707 #endif
   643         TInt /*aError*/)
   708 
   644     {
   709     MPX_DEBUG2("CVcxMyVideosMdsDb:: query contains %d items", thisObj->iVideoQuery->Count());
   645     MPX_DEBUG1( "CVcxMyVideosMdsDb::HandleQueryCompleted() start" );
       
   646 
       
   647     if ( !iVideoList )
       
   648         {
       
   649         MPX_DEBUG1("CVcxMyVideosMdsDb:: iVideoList is NULL, should never happen");
       
   650         return;
       
   651         }
       
   652 
       
   653 #ifdef _DEBUG
       
   654     CMPXMediaArray* array = iVideoList->Value<CMPXMediaArray>( KMPXMediaArrayContents );
       
   655 #endif
       
   656 
       
   657     MPX_DEBUG2("CVcxMyVideosMdsDb:: query contains %d items", aQuery.Count());
       
   658     MPX_DEBUG2("CVcxMyVideosMdsDb:: iVideoList contains %d items", array->Count());
   710     MPX_DEBUG2("CVcxMyVideosMdsDb:: iVideoList contains %d items", array->Count());
   659     
   711     
   660     if (iActiveSchedulerWait->IsStarted())
   712     if ( thisObj->iActiveSchedulerWait->IsStarted() )
   661         {
   713         {
   662         iActiveSchedulerWait->AsyncStop();
   714         thisObj->iActiveSchedulerWait->AsyncStop();
   663         }
   715         }
   664     
   716     
   665     iVideoListFetchingIsOngoing = EFalse;
   717     thisObj->iVideoListFetchingIsOngoing = EFalse;
   666     iMdsDbObserver->HandleCreateVideoListResp( iVideoList, KErrNotFound /* KErrNotFound = no new items */,
   718     thisObj->iMdsDbObserver->HandleCreateVideoListResp( thisObj->iVideoList, KErrNotFound /* KErrNotFound = no new items */,
   667             ETrue /* complete */);
   719             ETrue /* complete */);
   668 
   720     
   669     MPX_DEBUG1( "CVcxMyVideosMdsDb::HandleQueryCompleted() exit" );
   721     thisObj->iVideoList = NULL; // not owned by us -> just clear
   670     
   722     
   671     iVideoList = NULL; // not owned by us -> just clear
   723     thisObj->iCmdQueue->CmdFinished();
       
   724     return KErrNone;
   672     }
   725     }
   673 
   726 
   674 // ---------------------------------------------------------------------------
   727 // ---------------------------------------------------------------------------
   675 // CVcxMyVideosMdsDb::CreateVideoL
   728 // CVcxMyVideosMdsDb::CreateVideoL
   676 // ---------------------------------------------------------------------------
   729 // ---------------------------------------------------------------------------
   679     {
   732     {
   680     MPX_DEBUG1( "CVcxMyVideosMdsDb::CreateVideoL() start" );
   733     MPX_DEBUG1( "CVcxMyVideosMdsDb::CreateVideoL() start" );
   681 
   734 
   682     CMdEObject* object = ObjectL( aId );
   735     CMdEObject* object = ObjectL( aId );
   683 
   736 
   684     CMPXMedia* video = NULL;
   737     if ( !object )
   685 
   738         {
   686     if ( object )
   739         MPX_DEBUG2("CVcxMyVideosMdsDb:: mds id %d not found from mds", aId);
   687         {
   740         return NULL;
   688         CleanupStack::PushL( object ); // 1->
   741         }
   689 
   742         
   690         video = CMPXMedia::NewL( );
   743     CleanupStack::PushL( object ); // 1->
   691         CleanupStack::PushL( video ); // 2->
   744 
   692 
   745     CMPXMedia* video = CMPXMedia::NewL( );
   693         Object2MediaL( *object, *video, aFullDetails );
   746     CleanupStack::PushL( video ); // 2->
   694 
   747 
   695         CleanupStack::Pop( video );            // <-2
   748     Object2MediaL( *object, *video, aFullDetails );
   696         CleanupStack::PopAndDestroy( object ); // <-1
   749 
   697         }
   750     CleanupStack::Pop( video );            // <-2
   698 
   751     CleanupStack::PopAndDestroy( object ); // <-1
   699     MPX_DEBUG1( "CVcxMyVideosMdsDb::CreateVideoL() exit" );
   752     MPX_DEBUG1( "CVcxMyVideosMdsDb::CreateVideoL() exit" );
   700 
   753 
   701     return video;
   754     return video;
   702     }
   755     }
   703 
   756 
   717         {
   770         {
   718         MPX_DEBUG2( "CVcxMyVideosMdsDb::HandleSessionOpened: %d", aError );
   771         MPX_DEBUG2( "CVcxMyVideosMdsDb::HandleSessionOpened: %d", aError );
   719 
   772 
   720         iMdsSessionError = aError;
   773         iMdsSessionError = aError;
   721         }
   774         }
   722         
       
   723     MPX_DEBUG1("CVcxMyVideosMdsDb::HandleSessionOpened() exit" );
   775     MPX_DEBUG1("CVcxMyVideosMdsDb::HandleSessionOpened() exit" );
   724     }
   776     }
   725 
   777 
   726 // ---------------------------------------------------------------------------
   778 // ---------------------------------------------------------------------------
   727 // From class MMdESessionObserver.
   779 // From class MMdESessionObserver.
   768     
   820     
   769 // ---------------------------------------------------------------------------
   821 // ---------------------------------------------------------------------------
   770 // CVcxMyVideosMdsDb::ObjectL
   822 // CVcxMyVideosMdsDb::ObjectL
   771 // ---------------------------------------------------------------------------
   823 // ---------------------------------------------------------------------------
   772 //
   824 //
   773 CMdEObject* CVcxMyVideosMdsDb::ObjectL( const TItemId aId )
   825 CMdEObject* CVcxMyVideosMdsDb::ObjectL( const TItemId aId, TBool aIsVideo )
   774     {
   826     {
   775     MPX_DEBUG1("CVcxMyVideosMdsDb::ObjectL start");
   827     MPX_DEBUG1("CVcxMyVideosMdsDb::ObjectL start");
   776 
       
   777     //  If the id is not valid, just return NULL, because
   828     //  If the id is not valid, just return NULL, because
   778     //  MdsSessionL().GetObjectL leaves in that case
   829     //  MdsSessionL().GetObjectL leaves in that case
   779     if ( aId == KNoId )
   830     if ( aId == KNoId )
   780         {
   831         {
   781         return NULL;
   832         return NULL;
   782         }
   833         }
   783 
   834 
   784     CMdEObject* object = NULL;
   835     CMdEObject* object;
   785     object = MdsSessionL().GetObjectL( aId, *iVideoObjectDef );
   836     if ( aIsVideo )
   786 
   837         {
       
   838         object = MdsSessionL().GetObjectL( aId, *iVideoObjectDef );
       
   839         }
       
   840     else
       
   841         {
       
   842         object = MdsSessionL().GetObjectL( aId, *iAlbums->iAlbumObjectDef );
       
   843         }
       
   844     
   787     if ( object )
   845     if ( object )
   788         {
   846         {
   789         MPX_DEBUG2( "CVcxMyVideosMdsDb::ObjectL found, id: %d", aId );
   847         MPX_DEBUG2( "CVcxMyVideosMdsDb::ObjectL found, id: %d", aId );
   790         }
   848         }
   791     else
   849     else
   966 
  1024 
   967     //16. ORIGIN, KVcxMediaMyVideosOrigin
  1025     //16. ORIGIN, KVcxMediaMyVideosOrigin
   968     if ( aObject.Property( *iOriginPropertyDef, property, 0 ) != KErrNotFound )
  1026     if ( aObject.Property( *iOriginPropertyDef, property, 0 ) != KErrNotFound )
   969         {
  1027         {
   970         TUint8 origin = static_cast<CMdEUint8Property*>(property)->Value();
  1028         TUint8 origin = static_cast<CMdEUint8Property*>(property)->Value();
       
  1029 #ifdef VIDEO_COLLECTION_PLUGIN_TB92
   971         if( origin != EVcxMyVideosOriginCapturedWithCamera )
  1030         if( origin != EVcxMyVideosOriginCapturedWithCamera )
   972             {
  1031             {
   973             origin = EVcxMyVideosOriginOther;
  1032             origin = EVcxMyVideosOriginOther;
   974             }           
  1033             }           
       
  1034 #else
       
  1035         if ( origin != EVcxMyVideosOriginCapturedWithCamera &&
       
  1036 				 origin != EVcxMyVideosOriginDownloaded
       
  1037 				)
       
  1038             {
       
  1039             origin = EVcxMyVideosOriginOther;
       
  1040             }
       
  1041 
       
  1042 #endif
   975         aVideo.SetTObjectValueL<TUint8>( KVcxMediaMyVideosOrigin, origin );
  1043         aVideo.SetTObjectValueL<TUint8>( KVcxMediaMyVideosOrigin, origin );
   976         }
  1044         }
   977 
  1045 
   978     //17. DURATION, (KMPXMediaGeneralDuration can't be used since it is TInt
  1046     //17. DURATION, (KMPXMediaGeneralDuration can't be used since it is TInt
   979     //   and we need TReal32 ) (BRIEF)
  1047     //   and we need TReal32 ) (BRIEF)
   990         {        
  1058         {        
   991         TInt pos = static_cast<CMdEReal32Property*>(property)->Value();
  1059         TInt pos = static_cast<CMdEReal32Property*>(property)->Value();
   992         
  1060         
   993         aVideo.SetTObjectValueL<TInt>( KMPXMediaGeneralLastPlaybackPosition, pos );
  1061         aVideo.SetTObjectValueL<TInt>( KMPXMediaGeneralLastPlaybackPosition, pos );
   994         }
  1062         }
   995 
  1063     
   996     //18. DOWNLOAD ID (BRIEF)
       
   997     if ( aObject.Property( *iDownloadIdPropertyDef, property, 0 ) != KErrNotFound )
       
   998         {
       
   999         aVideo.SetTObjectValueL<TUint32>( KVcxMediaMyVideosDownloadId,
       
  1000                 static_cast<CMdEUint32Property*>(property)->Value() );
       
  1001         }
       
  1002     else
       
  1003         {
       
  1004         aVideo.SetTObjectValueL<TUint32>( KVcxMediaMyVideosDownloadId, 0 );
       
  1005         }
       
  1006 
       
  1007     //19. RATING (FULL)
  1064     //19. RATING (FULL)
  1008     if ( aObject.Property( *iRatingPropertyDef, property, 0 ) != KErrNotFound
  1065     if ( aObject.Property( *iRatingPropertyDef, property, 0 ) != KErrNotFound
  1009             && aFullDetails )
  1066             && aFullDetails )
  1010         {
  1067         {
  1011         aVideo.SetTObjectValueL<TUint8>( KVcxMediaMyVideosRating,
  1068         aVideo.SetTObjectValueL<TUint8>( KVcxMediaMyVideosRating,
  1134             aObject.AddUint32PropertyL( *iSizePropertyDef, size );
  1191             aObject.AddUint32PropertyL( *iSizePropertyDef, size );
  1135             }
  1192             }
  1136         }
  1193         }
  1137 #endif // SYMBIAN_ENABLE_64_BIT_FILE_SERVER_API
  1194 #endif // SYMBIAN_ENABLE_64_BIT_FILE_SERVER_API
  1138 
  1195 
  1139 #if 1
       
  1140     // 6. KMPXMediaGeneralDate ( creation date )
  1196     // 6. KMPXMediaGeneralDate ( creation date )
  1141     SetCreationDateToObjectL( aVideo, aObject );
  1197     SetCreationDateToObjectL( aVideo, aObject );
  1142 #endif
       
  1143     
  1198     
  1144     // 7. KMPXMediaGeneralFlags (including DRM flag)
  1199     // 7. KMPXMediaGeneralFlags (including DRM flag)
  1145     if ( aVideo.IsSupported( KMPXMediaGeneralFlags ) )
  1200     if ( aVideo.IsSupported( KMPXMediaGeneralFlags ) )
  1146         {
  1201         {
  1147         TUint32 flags = aVideo.ValueTObjectL<TUint32>( KMPXMediaGeneralFlags );
  1202         TUint32 flags = aVideo.ValueTObjectL<TUint32>( KMPXMediaGeneralFlags );
  1334             
  1389             
  1335             flags &= ~EVcxMyVideosVideoNew;
  1390             flags &= ~EVcxMyVideosVideoNew;
  1336             
  1391             
  1337             static_cast<CMdEUint32Property*>(property)->SetValueL( flags );
  1392             static_cast<CMdEUint32Property*>(property)->SetValueL( flags );
  1338             }
  1393             }
       
  1394         
  1339         if ( aObject.Property( *iLastPlayPositionPropertyDef, property, 0 ) != KErrNotFound )
  1395         if ( aObject.Property( *iLastPlayPositionPropertyDef, property, 0 ) != KErrNotFound )
  1340             {
  1396             {
  1341             static_cast<CMdEReal32Property*>(property)->SetValueL( lastPlaybackPos );
  1397             static_cast<CMdEReal32Property*>(property)->SetValueL( lastPlaybackPos );
  1342             }
  1398             }
  1343         else
  1399         else
  1344             {
  1400             {
  1345             aObject.AddReal32PropertyL( *iLastPlayPositionPropertyDef, lastPlaybackPos );
  1401             aObject.AddReal32PropertyL( *iLastPlayPositionPropertyDef, lastPlaybackPos );
  1346             }
  1402             }
  1347         }
  1403         }
  1348     
  1404     
  1349     // 18. DOWNLOAD ID
       
  1350     if ( aVideo.IsSupported( KVcxMediaMyVideosDownloadId ) )
       
  1351         {
       
  1352         TUint32 dlId = aVideo.ValueTObjectL<TUint32>( KVcxMediaMyVideosDownloadId );
       
  1353         
       
  1354         if ( aObject.Property( *iDownloadIdPropertyDef, property, 0 ) != KErrNotFound )
       
  1355             {
       
  1356             static_cast<CMdEUint32Property*>(property)->SetValueL( dlId );
       
  1357             }
       
  1358         else
       
  1359             {
       
  1360             aObject.AddUint32PropertyL( *iDownloadIdPropertyDef, dlId );
       
  1361             }
       
  1362         }
       
  1363 
       
  1364     // 19. RATING
  1405     // 19. RATING
  1365     if ( aVideo.IsSupported( KVcxMediaMyVideosRating ) )
  1406     if ( aVideo.IsSupported( KVcxMediaMyVideosRating ) )
  1366         {
  1407         {
  1367         TUint8 rating = aVideo.ValueTObjectL<TUint8>( KVcxMediaMyVideosRating );
  1408         TUint8 rating = aVideo.ValueTObjectL<TUint8>( KVcxMediaMyVideosRating );
  1368         
  1409         
  1524     iDrmPropertyDef = &(iVideoObjectDef->GetPropertyDefL(
  1565     iDrmPropertyDef = &(iVideoObjectDef->GetPropertyDefL(
  1525             KVcxDrmPropertyName )); //part of flags (7)
  1566             KVcxDrmPropertyName )); //part of flags (7)
  1526     iRatingPropertyDef = &(iVideoObjectDef->GetPropertyDefL(
  1567     iRatingPropertyDef = &(iVideoObjectDef->GetPropertyDefL(
  1527             KVcxRatingPropertyName )); //19
  1568             KVcxRatingPropertyName )); //19
  1528     iBitratePropertyDef = &(iVideoObjectDef->GetPropertyDefL(
  1569     iBitratePropertyDef = &(iVideoObjectDef->GetPropertyDefL(
  1529             KVcxBitratePropertyName )); //20
  1570                 KVcxBitratePropertyName )); //20
  1530     iAudioFourCcPropertyDef = &(iVideoObjectDef->GetPropertyDefL(
  1571     iAudioFourCcPropertyDef = &(iVideoObjectDef->GetPropertyDefL(
  1531             KVcxAudioFourCcPropertyName )); //21
  1572                 KVcxAudioFourCcPropertyName )); //21
  1532     iWidthPropertyDef = &(iVideoObjectDef->GetPropertyDefL(
  1573     iWidthPropertyDef = &(iVideoObjectDef->GetPropertyDefL(
  1533             KVcxWidthPropertyName )); //22
  1574             KVcxWidthPropertyName )); //22
  1534     iHeightPropertyDef = &(iVideoObjectDef->GetPropertyDefL(
  1575     iHeightPropertyDef = &(iVideoObjectDef->GetPropertyDefL(
  1535             KVcxHeightPropertyName )); //23
  1576             KVcxHeightPropertyName )); //23
  1536     iArtistPropertyDef = &(iVideoObjectDef->GetPropertyDefL(
  1577     iArtistPropertyDef = &(iVideoObjectDef->GetPropertyDefL(
  1546     iAgeProfilePropertyDef = &(iVideoObjectDef->GetPropertyDefL(
  1587     iAgeProfilePropertyDef = &(iVideoObjectDef->GetPropertyDefL(
  1547             KVcxAgeProfilePropertyName )); //13
  1588             KVcxAgeProfilePropertyName )); //13
  1548 
  1589 
  1549     iAudioLanguagePropertyDef = &(iVideoObjectDef->GetPropertyDefL(
  1590     iAudioLanguagePropertyDef = &(iVideoObjectDef->GetPropertyDefL(
  1550             KVcxAudioLanguagePropertyName )); //14
  1591             KVcxAudioLanguagePropertyName )); //14
  1551 
  1592     
  1552     iDownloadIdPropertyDef = &(iVideoObjectDef->GetPropertyDefL(
       
  1553             KVcxDownloadIdPropertyName )); //18
       
  1554 
       
  1555     }
  1593     }
  1556 
  1594 
  1557 // ---------------------------------------------------------------------------
  1595 // ---------------------------------------------------------------------------
  1558 // CVcxMyVideosMdsDb::DoHandleObjectNotificationL
  1596 // CVcxMyVideosMdsDb::DoHandleObjectNotificationL
  1559 // ---------------------------------------------------------------------------
  1597 // ---------------------------------------------------------------------------