videocollection/mpxmyvideoscollection/src/vcxmyvideosmdsdb.cpp
changeset 15 cf5481c2bc0b
parent 2 dec420019252
child 17 69946d1824c4
equal deleted inserted replaced
2:dec420019252 15:cf5481c2bc0b
     1 /*
     1 /*
     2 * Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies).
     2 * Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies).
     3 * All rights reserved.
     3 * All rights reserved.
     4 * This component and the accompanying materials are made available
     4 * This component and the accompanying materials are made available
     5 * under the terms of the License "Eclipse Public License v1.0"
     5 * under the terms of "Eclipse Public License v1.0"
     6 * which accompanies this distribution, and is available
     6 * which accompanies this distribution, and is available
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
     8 *
     8 *
     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>
    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 "vcxmyvideosmdsdb.h"
    31 #include "vcxmyvideosmdsdb.h"
    33 #include "vcxmyvideoscollectionutil.h"
    32 #include "vcxmyvideoscollectionutil.h"
       
    33 #include "vcxmyvideosmdsalbums.h"
       
    34 #include "vcxmyvideoscollectionutil.h"
       
    35 #include "vcxmyvideosmdscmdqueue.h"
    34 
    36 
    35 _LIT( KVcxVideoObjectName, "Video" );
    37 _LIT( KVcxVideoObjectName, "Video" );
    36                                                               //1 (ID)
    38                                                               //1 (ID)
    37 _LIT( KVcxTitlePropertyName, "Title" );                       //2
    39 _LIT( KVcxTitlePropertyName, "Title" );                       //2
    38 _LIT( KVcxDescriptionPropertyName, "Description" );           //3
    40 _LIT( KVcxDescriptionPropertyName, "Description" );           //3
    52 _LIT( KVcxAudioLanguagePropertyName, "AudioLanguage" );       //14
    54 _LIT( KVcxAudioLanguagePropertyName, "AudioLanguage" );       //14
    53 _LIT( KVcxAuthorPropertyName, "Author" );                     //15
    55 _LIT( KVcxAuthorPropertyName, "Author" );                     //15
    54 _LIT( KVcxOriginPropertyName, "Origin" );                     //16
    56 _LIT( KVcxOriginPropertyName, "Origin" );                     //16
    55 _LIT( KVcxDurationPropertyName, "Duration" );                 //17
    57 _LIT( KVcxDurationPropertyName, "Duration" );                 //17
    56 _LIT( KVcxLastPlayPositionPropertyName, "LastPlayPosition" ); //10
    58 _LIT( KVcxLastPlayPositionPropertyName, "LastPlayPosition" ); //10
    57 _LIT( KVcxDownloadIdPropertyName, "DownloadID" );             //18
       
    58 _LIT( KVcxRatingPropertyName, "Rating" );                     //19
    59 _LIT( KVcxRatingPropertyName, "Rating" );                     //19
    59 _LIT( KVcxBitratePropertyName, "Bitrate" );                   //20
    60 _LIT( KVcxBitratePropertyName, "Bitrate" );                   //20
    60 _LIT( KVcxAudioFourCcPropertyName, "AudioFourCC" );           //21
    61 _LIT( KVcxAudioFourCcPropertyName, "AudioFourCC" );           //21
    61 _LIT( KVcxWidthPropertyName, "Width" );                       //22
    62 _LIT( KVcxWidthPropertyName, "Width" );                       //22
    62 _LIT( KVcxHeightPropertyName, "Height" );                     //23
    63 _LIT( KVcxHeightPropertyName, "Height" );                     //23
    64 
    65 
    65 
    66 
    66 // ---------------------------------------------------------------------------
    67 // ---------------------------------------------------------------------------
    67 // ---------------------------------------------------------------------------
    68 // ---------------------------------------------------------------------------
    68 //
    69 //
    69 CVcxMyVideosMdsDb::CVcxMyVideosMdsDb( MVcxMyVideosMdsDbObserver* aObserver, RFs& aFs )
    70 CVcxMyVideosMdsDb::CVcxMyVideosMdsDb( MVcxMyVideosMdsDbObserver* aObserver,
    70 : iFs( aFs ), iMdsDbObserver(aObserver) 
    71         MVcxMyVideosMdsAlbumsObserver* aAlbumsObserver, RFs& aFs )
       
    72 : iFs( aFs ), iMdsDbObserver(aObserver), iAlbumsObserver(aAlbumsObserver) 
    71     {
    73     {
    72     }
    74     }
    73 
    75 
    74 // ---------------------------------------------------------------------------
    76 // ---------------------------------------------------------------------------
    75 // ---------------------------------------------------------------------------
    77 // ---------------------------------------------------------------------------
    76 //
    78 //
    77 void CVcxMyVideosMdsDb::ConstructL()
    79 void CVcxMyVideosMdsDb::ConstructL()
    78     {
    80     {
    79     MPX_FUNC( "CVcxMyVideosMdsDb::ConstructL" );
    81     MPX_FUNC( "CVcxMyVideosMdsDb::ConstructL" );
    80 
    82 
       
    83     iCmdQueue = CVcxMyVideosMdsCmdQueue::NewL( *this );
       
    84 
    81     iActiveSchedulerWait = new (ELeave) CActiveSchedulerWait;
    85     iActiveSchedulerWait = new (ELeave) CActiveSchedulerWait;
    82     
    86     
    83     MPX_DEBUG1( "CVcxMyVideosMdsDb::ConstructL CMdESession::NewL" );
    87     MPX_DEBUG1( "CVcxMyVideosMdsDb::ConstructL CMdESession::NewL" );
    84 
    88 
    85     //  Create session
    89     //  Create session
    86     iMDSError = KErrNone;
    90     iMdsError = KErrNone;
    87 
    91 
    88     iMDSSession = CMdESession::NewL( *this );
    92     iMdsSession = CMdESession::NewL( *this );
    89     if (!iMDSSession)
    93     if (!iMdsSession)
    90         {
    94         {
    91         //  Failed to create session, leave
    95         //  Failed to create session, leave
    92         User::Leave( iMDSError );
    96         User::Leave( iMdsError );
    93         }
    97         }
    94 
    98 
    95     //  Wait until session opened
    99     //  Wait until session opened
    96     iActiveSchedulerWait->Start();
   100     iActiveSchedulerWait->Start();
    97 
   101 
    98     MPX_DEBUG1( "CVcxMyVideosMdsDb::ConstructL iActiveSchedulerWait->Start done" );
   102     MPX_DEBUG1( "CVcxMyVideosMdsDb::ConstructL iActiveSchedulerWait->Start done" );
    99 
   103 
   100     if ( iMDSError != KErrNone )
   104     if ( iMdsError != KErrNone )
   101         {
   105         {
   102         MPX_DEBUG2("Failed to create session to MDS: %d", iMDSError);
   106         MPX_DEBUG2("Failed to create session to MDS: %d", iMdsError);
   103         User::LeaveIfError( iMDSError );
   107         User::LeaveIfError( iMdsError );
   104         }
   108         }
   105 
   109 
   106     //  Get the schema definitions
   110     //  Get the schema definitions
   107     iMDSError = KErrNone;
   111     iMdsError = KErrNone;
   108     GetSchemaDefinitionsL();
   112     GetSchemaDefinitionsL();
   109 
   113 
   110     //  Is schema ok
   114     //  Is schema ok
   111     if ( iMDSError != KErrNone )
   115     if ( iMdsError != KErrNone )
   112         {
   116         {
   113         //  Schema not loaded, abort
   117         //  Schema not loaded, abort
   114         User::Leave( iMDSError );
   118         User::Leave( iMdsError );
   115         }
   119         }
   116 
   120 
   117     MPX_DEBUG1( "CVcxMyVideosMdsDb::ConstructL Adding observers" );
   121     MPX_DEBUG1( "CVcxMyVideosMdsDb::ConstructL Adding observers" );
   118 
   122 
   119     // We order all object notifications. If we set video condition, then we wont
   123     // We order all object notifications. If we set video condition, then we wont
   120     // receive remove notifications at all (mds feature). Extra notifications
   124     // receive remove notifications at all (mds feature). Extra notifications
   121     // do not bother us much since we try to fetch the item from the db
   125     // do not bother us much since we try to fetch the item from the db
   122     // after the add notification anyways, and then we use video condition.
   126     // after the add notification anyways, and then we use video condition.
   123     // Eventually extra events are ignored.    
   127     // Eventually extra events are ignored.    
   124     iMDSSession->AddObjectObserverL( *this, NULL );
   128     iMdsSession->AddObjectObserverL( *this, NULL );
   125     
   129     
   126     iMDSSession->AddObjectPresentObserverL( *this );    
   130     iMdsSession->AddObjectPresentObserverL( *this );
       
   131     
       
   132     iAlbums = CVcxMyVideosMdsAlbums::NewL( *this, iAlbumsObserver );
       
   133     
       
   134     TCallBack callBack( AsyncHandleQueryCompleted, this );    
       
   135     iAsyncHandleQueryCompleteCaller = new (ELeave) CAsyncCallBack( callBack,
       
   136             CActive::EPriorityStandard );
   127     }
   137     }
   128 
   138 
   129 // ---------------------------------------------------------------------------
   139 // ---------------------------------------------------------------------------
   130 // ---------------------------------------------------------------------------
   140 // ---------------------------------------------------------------------------
   131 //
   141 //
   133         TBool aPresent, const RArray<TItemId>& aObjectIdArray)
   143         TBool aPresent, const RArray<TItemId>& aObjectIdArray)
   134     {
   144     {
   135     MPX_DEBUG1( "CVcxMyVideosMdsDb::--------------------------------------------------------------." );
   145     MPX_DEBUG1( "CVcxMyVideosMdsDb::--------------------------------------------------------------." );
   136     MPX_DEBUG3( "CVcxMyVideosMdsDb::HandleObjectPresentNotification( aPresent = %1d, count = %3d) |", aPresent, aObjectIdArray.Count() );
   146     MPX_DEBUG3( "CVcxMyVideosMdsDb::HandleObjectPresentNotification( aPresent = %1d, count = %3d) |", aPresent, aObjectIdArray.Count() );
   137     MPX_DEBUG1( "CVcxMyVideosMdsDb::--------------------------------------------------------------'" );
   147     MPX_DEBUG1( "CVcxMyVideosMdsDb::--------------------------------------------------------------'" );
   138     //iMdsDbObserver->HandleObjectPresentNotification();
       
   139 
   148 
   140     TObserverNotificationType type;
   149     TObserverNotificationType type;
   141     if ( aPresent )
   150     if ( aPresent )
   142         {
   151         {
   143         type = ENotifyAdd;
   152         type = ENotifyAdd;
   151     }
   160     }
   152 
   161 
   153 // ---------------------------------------------------------------------------
   162 // ---------------------------------------------------------------------------
   154 // ---------------------------------------------------------------------------
   163 // ---------------------------------------------------------------------------
   155 //
   164 //
   156 CVcxMyVideosMdsDb* CVcxMyVideosMdsDb::NewL( MVcxMyVideosMdsDbObserver* aObserver, RFs& aFs )
   165 CVcxMyVideosMdsDb* CVcxMyVideosMdsDb::NewL( MVcxMyVideosMdsDbObserver* aObserver,
       
   166         MVcxMyVideosMdsAlbumsObserver* aAlbumsObserver, RFs& aFs )
   157     {
   167     {
   158     CVcxMyVideosMdsDb* self =
   168     CVcxMyVideosMdsDb* self =
   159             CVcxMyVideosMdsDb::NewLC( aObserver, aFs );
   169             CVcxMyVideosMdsDb::NewLC( aObserver, aAlbumsObserver, aFs );
   160     CleanupStack::Pop( self );
   170     CleanupStack::Pop( self );
   161     return self;
   171     return self;
   162     }
   172     }
   163 
   173 
   164 
   174 
   165 // ---------------------------------------------------------------------------
   175 // ---------------------------------------------------------------------------
   166 // ---------------------------------------------------------------------------
   176 // ---------------------------------------------------------------------------
   167 //
   177 //
   168 CVcxMyVideosMdsDb* CVcxMyVideosMdsDb::NewLC(
   178 CVcxMyVideosMdsDb* CVcxMyVideosMdsDb::NewLC( MVcxMyVideosMdsDbObserver* aObserver,
   169         MVcxMyVideosMdsDbObserver* aObserver, RFs& aFs )
   179         MVcxMyVideosMdsAlbumsObserver* aAlbumsObserver, RFs& aFs )
   170     {
   180     {
   171     CVcxMyVideosMdsDb* self = new( ELeave ) CVcxMyVideosMdsDb( aObserver, aFs );
   181     CVcxMyVideosMdsDb* self = new( ELeave ) CVcxMyVideosMdsDb( aObserver, aAlbumsObserver, aFs );
   172     CleanupStack::PushL( self );
   182     CleanupStack::PushL( self );
   173     self->ConstructL();
   183     self->ConstructL();
   174     return self;
   184     return self;
   175     }
   185     }
   176 
   186 
   180 //
   190 //
   181 CVcxMyVideosMdsDb::~CVcxMyVideosMdsDb()
   191 CVcxMyVideosMdsDb::~CVcxMyVideosMdsDb()
   182     {
   192     {
   183     MPX_FUNC( "CVcxMyVideosMdsDb::~CVcxMyVideosMdsDb()" );
   193     MPX_FUNC( "CVcxMyVideosMdsDb::~CVcxMyVideosMdsDb()" );
   184 
   194 
   185     if ( iMDSSession )
       
   186         {
       
   187         TRAP_IGNORE( iMDSSession->RemoveObjectObserverL( *this ) );        
       
   188         }
       
   189 
       
   190     Cancel();
   195     Cancel();
   191     
   196 
       
   197     delete iCmdQueue;    
       
   198 
       
   199     if ( iMdsSession )
       
   200         {
       
   201         TRAP_IGNORE( iMdsSession->RemoveObjectObserverL( *this ) );        
       
   202         }
       
   203 
   192     delete iVideoQuery;
   204     delete iVideoQuery;
   193     delete iMDSSession;
   205     delete iAlbums;
       
   206     delete iMdsSession;
   194     delete iActiveSchedulerWait;
   207     delete iActiveSchedulerWait;
       
   208     delete iAsyncHandleQueryCompleteCaller;
   195     }
   209     }
   196 
   210 
   197 // ---------------------------------------------------------------------------
   211 // ---------------------------------------------------------------------------
   198 // CVcxMyVideosMdsDb::Cancel
   212 // CVcxMyVideosMdsDb::Cancel
   199 // ---------------------------------------------------------------------------
   213 // ---------------------------------------------------------------------------
   200 //
   214 //
   201 void CVcxMyVideosMdsDb::Cancel()
   215 void CVcxMyVideosMdsDb::Cancel( TRequestType aType )
   202     {
   216     {
   203     MPX_FUNC("CVcxMyVideosMdsDb::Cancel()");
   217     MPX_FUNC("CVcxMyVideosMdsDb::Cancel()");
   204     
   218     
   205     if ( iVideoQuery )
   219     iCmdQueue->Cancel( aType );
   206         {
   220     
   207         iVideoQuery->Cancel();
   221     if ( aType == EAll || aType == EGetVideoList )
   208         }
   222         {
   209     iVideoListFetchingIsOngoing = EFalse;
   223         if ( iVideoQuery )
       
   224             {
       
   225             iVideoQuery->Cancel();
       
   226             }
       
   227         iVideoListFetchingIsOngoing = EFalse;
       
   228         }
       
   229 
       
   230     iAlbums->Cancel( aType );    
   210     }
   231     }
   211     
   232     
   212 // ---------------------------------------------------------------------------
   233 // ---------------------------------------------------------------------------
   213 // CVcxMyVideosMdsDb::AddVideoL
   234 // CVcxMyVideosMdsDb::AddVideoL
   214 // ---------------------------------------------------------------------------
   235 // ---------------------------------------------------------------------------
   217         CMPXMedia& aVideo, 
   238         CMPXMedia& aVideo, 
   218         TUint32& aMdsId )
   239         TUint32& aMdsId )
   219     {
   240     {
   220     MPX_FUNC( "CVcxMyVideosMdsDb::AddVideoL" );
   241     MPX_FUNC( "CVcxMyVideosMdsDb::AddVideoL" );
   221 
   242 
   222     if ( !iMDSSession )
   243     if ( !iMdsSession )
   223         {
   244         {
   224         MPX_DEBUG2("CVcxMyVideosMdsDb:: no mds session(%d), leaving", iMDSError);
   245         MPX_DEBUG2("CVcxMyVideosMdsDb:: no mds session(%d), leaving", iMdsError);
   225         User::Leave( iMDSError );
   246         User::Leave( iMdsError );
   226         }
   247         }
   227          
   248          
   228     CMdEObject* object = iMDSSession->NewObjectLC(
   249     CMdEObject* object = iMdsSession->NewObjectLC(
   229             *iVideoObjectDef, aVideo.ValueText( KMPXMediaGeneralUri ) ); // 1->
   250             *iVideoObjectDef, aVideo.ValueText( KMPXMediaGeneralUri ) ); // 1->
   230 
   251 
   231     // check if the file exists and use the creation time from the file
   252     // Value from aVideo is taken in use in Media2ObjectL if aVideo contains creation date
   232     
   253     SetCreationAndModifiedDatesL( *object ); // use current time
   233     TTime time;
   254     
   234     time.UniversalTime();
       
   235 	TTimeIntervalSeconds timeOffset = User::UTCOffset();
       
   236 	TTime localTime = time + timeOffset;
       
   237         
       
   238     object->AddTimePropertyL( *iCreationDatePropertyDef, localTime ); 
       
   239 	object->AddInt16PropertyL( *iTimeOffsetPropertyDef, timeOffset.Int() / 60 );
       
   240     object->AddTimePropertyL( *iLastModifiedDatePropertyDef, localTime );
       
   241     object->AddUint8PropertyL( *iOriginPropertyDef,
   255     object->AddUint8PropertyL( *iOriginPropertyDef,
   242             aVideo.ValueTObjectL<TUint8>( KVcxMediaMyVideosOrigin ) );
   256             aVideo.ValueTObjectL<TUint8>( KVcxMediaMyVideosOrigin ) );
   243 
   257     
   244     CMdEProperty* property;
   258     CMdEProperty* property;
   245 
   259 
   246     //  Type can not be modified normally, so set it here
   260     //  Type can not be modified normally, so set it here
   247     if ( aVideo.IsSupported( KMPXMediaGeneralMimeType ) )
   261     if ( aVideo.IsSupported( KMPXMediaGeneralMimeType ) )
   248         {
   262         {
   258                 aVideo.ValueText( KMPXMediaGeneralMimeType ) );
   272                 aVideo.ValueText( KMPXMediaGeneralMimeType ) );
   259             }
   273             }
   260         }
   274         }
   261 
   275 
   262     Media2ObjectL( aVideo, *object );
   276     Media2ObjectL( aVideo, *object );
   263     TRAPD( err, aMdsId = iMDSSession->AddObjectL( *object ) );
   277     TRAPD( err, aMdsId = iMdsSession->AddObjectL( *object ) );
   264 
   278 
   265     if ( err != KErrNone )
   279     if ( err != KErrNone )
   266         {
   280         {
   267         MPX_DEBUG2( "CVcxMyVideosMdsDb:: iMDSSession->AddObjectL leaved with error: %d", err );
   281         MPX_DEBUG2( "CVcxMyVideosMdsDb:: iMdsSession->AddObjectL leaved with error: %d", err );
   268         User::Leave( err );
   282         User::Leave( err );
   269         }
   283         }
   270         
   284         
   271     if ( aMdsId == KNoId )
   285     if ( aMdsId == KNoId )
   272         {
   286         {
   288 //
   302 //
   289 TInt CVcxMyVideosMdsDb::RemoveVideo( TUint32 aMdsId )
   303 TInt CVcxMyVideosMdsDb::RemoveVideo( TUint32 aMdsId )
   290     {
   304     {
   291     MPX_FUNC( "CVcxMyVideosMdsDb::RemoveVideoL" );
   305     MPX_FUNC( "CVcxMyVideosMdsDb::RemoveVideoL" );
   292 
   306 
   293     if ( !iMDSSession )
   307     if ( !iMdsSession )
   294         {
   308         {
   295         MPX_DEBUG2("CVcxMyVideosMdsDb:: no mds session, returning %d", iMDSError);
   309         MPX_DEBUG2("CVcxMyVideosMdsDb:: no mds session, returning %d", iMdsError);
   296         return iMDSError;
   310         return iMdsError;
   297         }
   311         }
   298 
   312 
   299     TInt retValue( KErrNone );
   313     TInt retValue( KErrNone );
   300     TItemId id( 0 ); //init to avoid warning
   314     TItemId id( 0 ); //init to avoid warning
   301 
   315 
   302     MPX_DEBUG2( "CVcxMyVideosMdsDb:: removing object %d", aMdsId );
   316     MPX_DEBUG2( "CVcxMyVideosMdsDb:: removing object %d", aMdsId );
   303     
   317     
   304     TRAPD( err,  id = iMDSSession->RemoveObjectL( aMdsId ) );
   318     TRAPD( err,  id = iMdsSession->RemoveObjectL( aMdsId ) );
   305 
   319 
   306     if ( err == KErrNone )
   320     if ( err == KErrNone )
   307         {
   321         {
   308         if ( id == KNoId )
   322         if ( id == KNoId )
   309             {
   323             {
   315             MPX_DEBUG1( "CVcxMyVideosMdsDb:: remove successful" );
   329             MPX_DEBUG1( "CVcxMyVideosMdsDb:: remove successful" );
   316             }
   330             }
   317         }
   331         }
   318     else
   332     else
   319         {
   333         {
   320         MPX_DEBUG2( "CVcxMyVideosMdsDb:: iMDSSession->RemoveObjectL left: %d", err );
   334         MPX_DEBUG2( "CVcxMyVideosMdsDb:: iMdsSession->RemoveObjectL left: %d", err );
   321         retValue = err;        
   335         retValue = err;        
   322         }
   336         }
   323         
   337         
   324     return retValue;
   338     return retValue;
   325     }
   339     }
   330 //
   344 //
   331 void CVcxMyVideosMdsDb::UpdateVideoL( CMPXMedia& aVideo )
   345 void CVcxMyVideosMdsDb::UpdateVideoL( CMPXMedia& aVideo )
   332     {
   346     {
   333     MPX_FUNC( "CVcxMyVideosMdsDb::UpdateVideoL" );
   347     MPX_FUNC( "CVcxMyVideosMdsDb::UpdateVideoL" );
   334 
   348 
   335     if ( !iMDSSession )
   349     if ( !iMdsSession )
   336         {
   350         {
   337         MPX_DEBUG2("CVcxMyVideosMdsDb:: no mds session(%d), leaving", iMDSError);
   351         MPX_DEBUG2("CVcxMyVideosMdsDb:: no mds session(%d), leaving", iMdsError);
   338         User::Leave( iMDSError );
   352         User::Leave( iMdsError );
   339         }
   353         }
   340 
   354 
   341     TMPXItemId mpxId = aVideo.ValueTObjectL<TMPXItemId>( KMPXMediaGeneralId );
   355     TMPXItemId mpxId = aVideo.ValueTObjectL<TMPXItemId>( KMPXMediaGeneralId );
   342 
   356 
   343     MPX_DEBUG2("CVcxMyVideosMdsDb::UpdateVideoL updating object %d ", mpxId.iId1);
   357     MPX_DEBUG2("CVcxMyVideosMdsDb::UpdateVideoL updating object %d ", mpxId.iId1);
   344     
   358     
   345     CMdEObject* object =
   359     CMdEObject* object =
   346             iMDSSession->OpenObjectL( mpxId.iId1, *iVideoObjectDef );
   360             iMdsSession->OpenObjectL( mpxId.iId1, *iVideoObjectDef );
   347     if ( object == NULL )
   361     if ( !object )
   348         {
   362         {
   349         // No object with this ID was found!
   363         // No object with this ID was found!
   350         MPX_DEBUG1("CVcxMyVideosMdsDb::UpdateVideoL no object found");
   364         MPX_DEBUG1("CVcxMyVideosMdsDb::UpdateVideoL no object found");
   351         User::Leave( KErrNotFound );
   365         User::Leave( KErrNotFound );
   352         }
   366         }
   358             {
   372             {
   359             CleanupStack::PushL( object ); // 1->
   373             CleanupStack::PushL( object ); // 1->
   360             
   374             
   361             Media2ObjectL( aVideo, *object );
   375             Media2ObjectL( aVideo, *object );
   362             
   376             
   363             iMDSSession->CommitObjectL(*object);
   377             iMdsSession->CommitObjectL(*object);
   364 
   378 
   365             CleanupStack::PopAndDestroy(object);
   379             CleanupStack::PopAndDestroy(object);
   366             }
   380             }
   367         else
   381         else
   368             {
   382             {
   380 //
   394 //
   381 void CVcxMyVideosMdsDb::CreateVideoListL( TVcxMyVideosSortingOrder aSortingOrder,
   395 void CVcxMyVideosMdsDb::CreateVideoListL( TVcxMyVideosSortingOrder aSortingOrder,
   382         TBool aAscending, TBool aFullDetails, CMPXMedia*& aVideoList )
   396         TBool aAscending, TBool aFullDetails, CMPXMedia*& aVideoList )
   383     {
   397     {
   384     MPX_FUNC( "CVcxMyVideosMdsDb::CreateVideoListL" );
   398     MPX_FUNC( "CVcxMyVideosMdsDb::CreateVideoListL" );
   385 
   399     
   386     if ( !iMDSSession )
   400     CVcxMyVideosMdsCmdGetVideoList* cmd = new (ELeave) CVcxMyVideosMdsCmdGetVideoList;
   387         {
   401     CleanupStack::PushL( cmd ); // 1->
   388         MPX_DEBUG2("CVcxMyVideosMdsDb:: no mds session(%d), leaving", iMDSError);
   402     cmd->iCmdType      = CVcxMyVideosMdsDb::EGetVideoList;
   389         User::Leave( iMDSError );
   403     cmd->iSortingOrder = aSortingOrder;
       
   404     cmd->iAscending    = aAscending;
       
   405     cmd->iFullDetails  = aFullDetails;
       
   406     cmd->iVideoList    = &aVideoList;
       
   407 
       
   408     iCmdQueue->ExecuteCmdL( cmd ); //ownership moves
       
   409     CleanupStack::Pop( cmd ); // <-1
       
   410     }
       
   411     
       
   412 // ---------------------------------------------------------------------------
       
   413 // CVcxMyVideosMdsDb::DoCreateVideoListL
       
   414 // ---------------------------------------------------------------------------
       
   415 //
       
   416 void CVcxMyVideosMdsDb::DoCreateVideoListL( TVcxMyVideosSortingOrder aSortingOrder,
       
   417         TBool aAscending, TBool aFullDetails, CMPXMedia*& aVideoList )
       
   418     {
       
   419     MPX_FUNC( "CVcxMyVideosMdsDb::DoCreateVideoListL" );
       
   420 
       
   421     if ( !iMdsSession )
       
   422         {
       
   423         MPX_DEBUG2("CVcxMyVideosMdsDb:: no mds session(%d), leaving", iMdsError);
       
   424         User::Leave( iMdsError );
   390         }
   425         }
   391         
   426         
   392     if ( iVideoListFetchingIsOngoing )
   427     if ( iVideoListFetchingIsOngoing )
   393         {
   428         {
   394         MPX_DEBUG1("CVcxMyVideosMdsDb:: video list fetching already going on, returning current list");
   429         MPX_DEBUG1("CVcxMyVideosMdsDb:: video list fetching already going on, returning current list");
   403     CMPXMediaArray* mediaArray = aVideoList->Value<CMPXMediaArray>( KMPXMediaArrayContents );
   438     CMPXMediaArray* mediaArray = aVideoList->Value<CMPXMediaArray>( KMPXMediaArrayContents );
   404     
   439     
   405     delete iVideoQuery;
   440     delete iVideoQuery;
   406     iVideoQuery = NULL;
   441     iVideoQuery = NULL;
   407     
   442     
   408     iVideoQuery = iMDSSession->NewObjectQueryL(
   443     iVideoQuery = iMdsSession->NewObjectQueryL(
   409             *iNamespaceDef,
   444             *iNamespaceDef,
   410             *iVideoObjectDef,
   445             *iVideoObjectDef,
   411             this);
   446             this);
   412 
   447 
   413     iVideoQuery->SetResultMode( EQueryResultModeItem );
   448     iVideoQuery->SetResultMode( EQueryResultModeItem );
   470 
   505 
   471     iVideoListFetchingIsOngoing = ETrue;
   506     iVideoListFetchingIsOngoing = ETrue;
   472 
   507 
   473     iFullDetails = aFullDetails;
   508     iFullDetails = aFullDetails;
   474     
   509     
   475     iVideoQuery->FindL(KMdEQueryDefaultMaxCount, 500);
   510     const TInt maxItemsInQueryResult = 500;
       
   511     iVideoQuery->FindL( KMdEQueryDefaultMaxCount, maxItemsInQueryResult );
   476 
   512 
   477     aVideoList->SetTObjectValueL<TMPXGeneralType>( KMPXMediaGeneralType, EMPXGroup );            
   513     aVideoList->SetTObjectValueL<TMPXGeneralType>( KMPXMediaGeneralType, EMPXGroup );            
   478     aVideoList->SetTObjectValueL( KMPXMediaArrayCount, mediaArray->Count() );
   514     aVideoList->SetTObjectValueL( KMPXMediaArrayCount, mediaArray->Count() );
   479 
   515 
   480     iVideoList = aVideoList; // lets store the pointer, ownership stays at observer
   516     iVideoList = aVideoList; // lets store the pointer, ownership stays at observer
   548 // ---------------------------------------------------------------------------
   584 // ---------------------------------------------------------------------------
   549 // From class MMdEQueryObserver.
   585 // From class MMdEQueryObserver.
   550 // ---------------------------------------------------------------------------
   586 // ---------------------------------------------------------------------------
   551 //
   587 //
   552 void CVcxMyVideosMdsDb::HandleQueryCompleted(
   588 void CVcxMyVideosMdsDb::HandleQueryCompleted(
   553 #if _DEBUG
       
   554         CMdEQuery& aQuery,
       
   555 #else
       
   556         CMdEQuery& /*aQuery*/,
   589         CMdEQuery& /*aQuery*/,
       
   590         TInt /*aError*/)
       
   591     {
       
   592     iAsyncHandleQueryCompleteCaller->CallBack();
       
   593     }
       
   594 
       
   595 // ---------------------------------------------------------------------------
       
   596 // CVcxMyVideosMdsDb::AsyncHandleQueryCompleted
       
   597 // ---------------------------------------------------------------------------
       
   598 //
       
   599 TInt CVcxMyVideosMdsDb::AsyncHandleQueryCompleted( TAny* aThis )
       
   600     {
       
   601     MPX_FUNC( "CVcxMyVideosMdsDb::AsyncHandleQueryCompleted" );
       
   602 
       
   603     CVcxMyVideosMdsDb* thisObj = static_cast<CVcxMyVideosMdsDb*>( aThis );
       
   604     
       
   605     if ( !thisObj->iVideoList )
       
   606         {
       
   607         MPX_DEBUG1("CVcxMyVideosMdsDb:: iVideoList is NULL, should never happen");
       
   608         return KErrNone;
       
   609         }
       
   610 
       
   611 #ifdef _DEBUG
       
   612     CMPXMediaArray* array = thisObj->iVideoList->Value<CMPXMediaArray>( KMPXMediaArrayContents );
   557 #endif
   613 #endif
   558         TInt /*aError*/)
   614 
   559     {
   615     MPX_DEBUG2("CVcxMyVideosMdsDb:: query contains %d items", thisObj->iVideoQuery->Count());
   560     MPX_FUNC( "CVcxMyVideosMdsDb::HandleQueryCompleted" );
       
   561 
       
   562     if ( !iVideoList )
       
   563         {
       
   564         MPX_DEBUG1("CVcxMyVideosMdsDb:: iVideoList is NULL, should never happen");
       
   565         return;
       
   566         }
       
   567 
       
   568 #ifdef _DEBUG
       
   569     CMPXMediaArray* array = iVideoList->Value<CMPXMediaArray>( KMPXMediaArrayContents );
       
   570 #endif
       
   571 
       
   572     MPX_DEBUG2("CVcxMyVideosMdsDb:: query contains %d items", aQuery.Count());
       
   573     MPX_DEBUG2("CVcxMyVideosMdsDb:: iVideoList contains %d items", array->Count());
   616     MPX_DEBUG2("CVcxMyVideosMdsDb:: iVideoList contains %d items", array->Count());
   574     
   617     
   575     if (iActiveSchedulerWait->IsStarted())
   618     if ( thisObj->iActiveSchedulerWait->IsStarted() )
   576         {
   619         {
   577         iActiveSchedulerWait->AsyncStop();
   620         thisObj->iActiveSchedulerWait->AsyncStop();
   578         }
   621         }
   579     
   622     
   580     iVideoListFetchingIsOngoing = EFalse;
   623     thisObj->iVideoListFetchingIsOngoing = EFalse;
   581     iMdsDbObserver->HandleCreateVideoListResp( iVideoList, KErrNotFound /* KErrNotFound = no new items */,
   624     thisObj->iMdsDbObserver->HandleCreateVideoListResp( thisObj->iVideoList, KErrNotFound /* KErrNotFound = no new items */,
   582             ETrue /* complete */);
   625             ETrue /* complete */);
   583     
   626     
   584     iVideoList = NULL; // not owned by us -> just clear
   627     thisObj->iVideoList = NULL; // not owned by us -> just clear
       
   628     
       
   629     thisObj->iCmdQueue->CmdFinished();
       
   630     return KErrNone;
   585     }
   631     }
   586 
   632 
   587 // ---------------------------------------------------------------------------
   633 // ---------------------------------------------------------------------------
   588 // CVcxMyVideosMdsDb::CreateVideoL
   634 // CVcxMyVideosMdsDb::CreateVideoL
   589 // ---------------------------------------------------------------------------
   635 // ---------------------------------------------------------------------------
   592     {
   638     {
   593     MPX_FUNC( "CVcxMyVideosMdsDb::CreateVideoL" );
   639     MPX_FUNC( "CVcxMyVideosMdsDb::CreateVideoL" );
   594 
   640 
   595     CMdEObject* object = ObjectL( aId );
   641     CMdEObject* object = ObjectL( aId );
   596 
   642 
   597     CMPXMedia* video = NULL;
   643     if ( !object )
   598 
   644         {
   599     if ( object )
   645         MPX_DEBUG2("CVcxMyVideosMdsDb:: mds id %d not found from mds", aId);
   600         {
   646         return NULL;
   601         CleanupStack::PushL( object ); // 1->
   647         }
   602 
   648         
   603         video = CMPXMedia::NewL( );
   649     CleanupStack::PushL( object ); // 1->
   604         CleanupStack::PushL( video ); // 2->
   650 
   605 
   651     CMPXMedia* video = CMPXMedia::NewL( );
   606         Object2MediaL( *object, *video, aFullDetails );
   652     CleanupStack::PushL( video ); // 2->
   607 
   653 
   608         CleanupStack::Pop( video );            // <-2
   654     Object2MediaL( *object, *video, aFullDetails );
   609         CleanupStack::PopAndDestroy( object ); // <-1
   655 
   610         }
   656     CleanupStack::Pop( video );            // <-2
       
   657     CleanupStack::PopAndDestroy( object ); // <-1
   611 
   658 
   612     return video;
   659     return video;
   613     }
   660     }
   614 
   661 
   615 // ---------------------------------------------------------------------------
   662 // ---------------------------------------------------------------------------
   626 
   673 
   627     if ( aError != KErrNone )
   674     if ( aError != KErrNone )
   628         {
   675         {
   629         MPX_DEBUG2( "CVcxMyVideosMdsDb::HandleSessionOpened: %d", aError );
   676         MPX_DEBUG2( "CVcxMyVideosMdsDb::HandleSessionOpened: %d", aError );
   630 
   677 
   631         iMDSError = aError;
   678         iMdsError = aError;
   632         delete iMDSSession;
   679         delete iMdsSession;
   633         iMDSSession = NULL;
   680         iMdsSession = NULL;
   634         }
   681         }
   635     }
   682     }
   636 
   683 
   637 // ---------------------------------------------------------------------------
   684 // ---------------------------------------------------------------------------
   638 // From class MMdESessionObserver.
   685 // From class MMdESessionObserver.
   652 
   699 
   653     if ( iVideoListFetchingIsOngoing )
   700     if ( iVideoListFetchingIsOngoing )
   654         {
   701         {
   655         MPX_DEBUG1( "CVcxMyVideosMdsDb:: Videolist fetching was going on");
   702         MPX_DEBUG1( "CVcxMyVideosMdsDb:: Videolist fetching was going on");
   656         iVideoListFetchingIsOngoing = EFalse;
   703         iVideoListFetchingIsOngoing = EFalse;
   657 //        delete iVideoQuery;
       
   658 //        iVideoQuery = NULL;
       
   659         iMdsDbObserver->HandleCreateVideoListResp( iVideoList, -1 /* -1 = no new items */,
   704         iMdsDbObserver->HandleCreateVideoListResp( iVideoList, -1 /* -1 = no new items */,
   660                 ETrue /* complete */);
   705                 ETrue /* complete */);
   661         }
   706         }
   662         
   707         
   663     MPX_DEBUG2( "CVcxMyVideosMdsDb::HandleSessionError: %d", aError );
   708     MPX_DEBUG2( "CVcxMyVideosMdsDb::HandleSessionError: %d", aError );
   664 
   709 
   665     iMDSError = aError;
   710     iMdsError = aError;
   666     delete iMDSSession;
   711     delete iMdsSession;
   667     iMDSSession = NULL;
   712     iMdsSession = NULL;
   668     }
   713     }
   669 
   714 
   670 // ---------------------------------------------------------------------------
   715 // ---------------------------------------------------------------------------
   671 // CVcxMyVideosMdsDb::HandleObjectNotification
   716 // CVcxMyVideosMdsDb::HandleObjectNotification
   672 // ---------------------------------------------------------------------------
   717 // ---------------------------------------------------------------------------
   674 void CVcxMyVideosMdsDb::HandleObjectNotification(
   719 void CVcxMyVideosMdsDb::HandleObjectNotification(
   675         CMdESession& /*aSession*/,
   720         CMdESession& /*aSession*/,
   676         TObserverNotificationType aType,
   721         TObserverNotificationType aType,
   677         const RArray<TItemId>& aObjectIdArray)
   722         const RArray<TItemId>& aObjectIdArray)
   678     {
   723     {
   679     TRAP( iMDSError, DoHandleObjectNotificationL( aType, aObjectIdArray ));
   724     TRAP( iMdsError, DoHandleObjectNotificationL( aType, aObjectIdArray ));
   680     }
   725     }
   681     
   726     
   682 // ---------------------------------------------------------------------------
   727 // ---------------------------------------------------------------------------
   683 // CVcxMyVideosMdsDb::ObjectL
   728 // CVcxMyVideosMdsDb::ObjectL
   684 // ---------------------------------------------------------------------------
   729 // ---------------------------------------------------------------------------
   685 //
   730 //
   686 CMdEObject* CVcxMyVideosMdsDb::ObjectL( const TItemId aId )
   731 CMdEObject* CVcxMyVideosMdsDb::ObjectL( const TItemId aId, TBool aIsVideo )
   687     {
   732     {
   688     if ( !iMDSSession )
   733     if ( !iMdsSession )
   689         {
   734         {
   690         MPX_DEBUG2("CVcxMyVideosMdsDb:: no mds session(%d), leaving", iMDSError);
   735         MPX_DEBUG2("CVcxMyVideosMdsDb:: no mds session(%d), leaving", iMdsError);
   691         User::Leave( iMDSError );
   736         User::Leave( iMdsError );
   692         }
   737         }
   693 
   738 
   694     //  If the id is not valid, just return NULL, because
   739     //  If the id is not valid, just return NULL, because
   695     //  iMDSSession->GetObjectL leaves in that case
   740     //  iMdsSession->GetObjectL leaves in that case
   696     if ( aId == KNoId )
   741     if ( aId == KNoId )
   697         {
   742         {
   698         return NULL;
   743         return NULL;
   699         }
   744         }
   700 
   745 
   701     CMdEObject* object = iMDSSession->GetObjectL( aId, *iVideoObjectDef );
   746     CMdEObject* object;
   702 
   747     if ( aIsVideo )
       
   748         {
       
   749         object = iMdsSession->GetObjectL( aId, *iVideoObjectDef );
       
   750         }
       
   751     else
       
   752         {
       
   753         object = iMdsSession->GetObjectL( aId, *iAlbums->iAlbumObjectDef );
       
   754         }
       
   755     
   703     if ( object )
   756     if ( object )
   704         {
   757         {
   705         MPX_DEBUG2( "CVcxMyVideosMdsDb::ObjectL found, id: %d", aId );
   758         MPX_DEBUG2( "CVcxMyVideosMdsDb::ObjectL found, id: %d", aId );
   706         }
   759         }
   707     else
   760     else
   901         {        
   954         {        
   902         TInt pos = static_cast<CMdEReal32Property*>(property)->Value();
   955         TInt pos = static_cast<CMdEReal32Property*>(property)->Value();
   903         
   956         
   904         aVideo.SetTObjectValueL<TInt>( KMPXMediaGeneralLastPlaybackPosition, pos );
   957         aVideo.SetTObjectValueL<TInt>( KMPXMediaGeneralLastPlaybackPosition, pos );
   905         }
   958         }
   906 
   959     
   907     //18. DOWNLOAD ID (BRIEF)
       
   908     if ( aObject.Property( *iDownloadIdPropertyDef, property, 0 ) != KErrNotFound )
       
   909         {
       
   910         aVideo.SetTObjectValueL<TUint32>( KVcxMediaMyVideosDownloadId,
       
   911                 static_cast<CMdEUint32Property*>(property)->Value() );
       
   912         }
       
   913     else
       
   914         {
       
   915         aVideo.SetTObjectValueL<TUint32>( KVcxMediaMyVideosDownloadId, 0 );
       
   916         }
       
   917 
       
   918     //19. RATING (FULL)
   960     //19. RATING (FULL)
   919     if ( aObject.Property( *iRatingPropertyDef, property, 0 ) != KErrNotFound
   961     if ( aObject.Property( *iRatingPropertyDef, property, 0 ) != KErrNotFound
   920             && aFullDetails )
   962             && aFullDetails )
   921         {
   963         {
   922         aVideo.SetTObjectValueL<TUint8>( KVcxMediaMyVideosRating,
   964         aVideo.SetTObjectValueL<TUint8>( KVcxMediaMyVideosRating,
  1045             aObject.AddUint32PropertyL( *iSizePropertyDef, size );
  1087             aObject.AddUint32PropertyL( *iSizePropertyDef, size );
  1046             }
  1088             }
  1047         }
  1089         }
  1048 #endif // SYMBIAN_ENABLE_64_BIT_FILE_SERVER_API
  1090 #endif // SYMBIAN_ENABLE_64_BIT_FILE_SERVER_API
  1049 
  1091 
  1050 #if 0    
       
  1051     // 6. KMPXMediaGeneralDate ( creation date )
  1092     // 6. KMPXMediaGeneralDate ( creation date )
  1052     if ( aVideo.IsSupported( KMPXMediaGeneralDate ) )
  1093     SetCreationDateToObjectL( aVideo, aObject );
  1053         {
       
  1054         TInt64 creationDateInt64 = 0;
       
  1055         creationDateInt64 = aVideo.ValueTObjectL<TInt64>( KMPXMediaGeneralDate );
       
  1056         TTime creationDate( creationDateInt64 );
       
  1057         if ( aObject.Property( *iCreationDatePropertyDef, property, 0 ) != KErrNotFound )
       
  1058             {
       
  1059             static_cast<CMdETimeProperty*>(property)->SetValueL( creationDate );
       
  1060             }
       
  1061         else
       
  1062             {
       
  1063             aObject.AddTimePropertyL( *iCreationDatePropertyDef, creationDate );
       
  1064             }
       
  1065         }
       
  1066 #endif
       
  1067     
  1094     
  1068     // 7. KMPXMediaGeneralFlags (including DRM flag)
  1095     // 7. KMPXMediaGeneralFlags (including DRM flag)
  1069     if ( aVideo.IsSupported( KMPXMediaGeneralFlags ) )
  1096     if ( aVideo.IsSupported( KMPXMediaGeneralFlags ) )
  1070         {
  1097         {
  1071         TUint32 flags = aVideo.ValueTObjectL<TUint32>( KMPXMediaGeneralFlags );
  1098         TUint32 flags = aVideo.ValueTObjectL<TUint32>( KMPXMediaGeneralFlags );
  1269             {
  1296             {
  1270             aObject.AddReal32PropertyL( *iLastPlayPositionPropertyDef, lastPlaybackPos );
  1297             aObject.AddReal32PropertyL( *iLastPlayPositionPropertyDef, lastPlaybackPos );
  1271             }
  1298             }
  1272         }
  1299         }
  1273     
  1300     
  1274     // 18. DOWNLOAD ID
       
  1275     if ( aVideo.IsSupported( KVcxMediaMyVideosDownloadId ) )
       
  1276         {
       
  1277         TUint32 dlId = aVideo.ValueTObjectL<TUint32>( KVcxMediaMyVideosDownloadId );
       
  1278         
       
  1279         if ( aObject.Property( *iDownloadIdPropertyDef, property, 0 ) != KErrNotFound )
       
  1280             {
       
  1281             static_cast<CMdEUint32Property*>(property)->SetValueL( dlId );
       
  1282             }
       
  1283         else
       
  1284             {
       
  1285             aObject.AddUint32PropertyL( *iDownloadIdPropertyDef, dlId );
       
  1286             }
       
  1287         }
       
  1288 
       
  1289     // 19. RATING
  1301     // 19. RATING
  1290     if ( aVideo.IsSupported( KVcxMediaMyVideosRating ) )
  1302     if ( aVideo.IsSupported( KVcxMediaMyVideosRating ) )
  1291         {
  1303         {
  1292         TUint8 rating = aVideo.ValueTObjectL<TUint8>( KVcxMediaMyVideosRating );
  1304         TUint8 rating = aVideo.ValueTObjectL<TUint8>( KVcxMediaMyVideosRating );
  1293         
  1305         
  1375             }
  1387             }
  1376         }
  1388         }
  1377     }
  1389     }
  1378 
  1390 
  1379 // ---------------------------------------------------------------------------
  1391 // ---------------------------------------------------------------------------
       
  1392 // CVcxMyVideosMdsDb::SetCreationDateToObjectL
       
  1393 // ---------------------------------------------------------------------------
       
  1394 //
       
  1395 void CVcxMyVideosMdsDb::SetCreationDateToObjectL( const CMPXMedia& aVideo, CMdEObject& aObject )
       
  1396     {
       
  1397     CMdEProperty* property;
       
  1398     
       
  1399     if ( aVideo.IsSupported( KMPXMediaGeneralDate ) )
       
  1400         {
       
  1401         TInt64 creationDateInt64 = 0;
       
  1402         creationDateInt64 = aVideo.ValueTObjectL<TInt64>( KMPXMediaGeneralDate );
       
  1403         TTime creationDate( creationDateInt64 );
       
  1404         if ( aObject.Property( *iCreationDatePropertyDef, property, 0 ) != KErrNotFound )
       
  1405             {
       
  1406             static_cast<CMdETimeProperty*>(property)->SetValueL( creationDate );
       
  1407             }
       
  1408         else
       
  1409             {
       
  1410             aObject.AddTimePropertyL( *iCreationDatePropertyDef, creationDate );
       
  1411             }
       
  1412 #ifdef _DEBUG
       
  1413         TDateTime dT = creationDate.DateTime();
       
  1414         TBuf<200> buf;
       
  1415         buf.Format(_L("date from aVideo to aObject: %2d.%2d.%4d %2d:%2d:%2d"),
       
  1416                 dT.Day()+1, dT.Month()+1, dT.Year(), dT.Hour(), dT.Minute(), dT.Second() ); 
       
  1417         MPX_DEBUG2("%S", &buf ); 
       
  1418 #endif
       
  1419         }
       
  1420     }
       
  1421 
       
  1422 // ---------------------------------------------------------------------------
  1380 // CVcxMyVideosMdsDb::GetSchemaDefinitionsL
  1423 // CVcxMyVideosMdsDb::GetSchemaDefinitionsL
  1381 // ---------------------------------------------------------------------------
  1424 // ---------------------------------------------------------------------------
  1382 //
  1425 //
  1383 void CVcxMyVideosMdsDb::GetSchemaDefinitionsL()
  1426 void CVcxMyVideosMdsDb::GetSchemaDefinitionsL()
  1384     {
  1427     {
  1385     MPX_FUNC( "CVcxMyVideosMdsDb::GetSchemaDefinitionsL" );
  1428     MPX_FUNC( "CVcxMyVideosMdsDb::GetSchemaDefinitionsL" );
  1386 
  1429 
  1387     //  Namespace
  1430     //  Namespace
  1388     iNamespaceDef = &(iMDSSession->GetDefaultNamespaceDefL());
  1431     iNamespaceDef = &(iMdsSession->GetDefaultNamespaceDefL());
  1389     
  1432     
  1390     //  Default object definitions
  1433     //  Default object definitions
  1391     iVideoObjectDef = &(iNamespaceDef->GetObjectDefL( KVcxVideoObjectName ));
  1434     iVideoObjectDef = &(iNamespaceDef->GetObjectDefL( KVcxVideoObjectName ));
  1392 
  1435 
  1393     //  Base object property definitions
  1436     //  Base object property definitions
  1418     iDrmPropertyDef = &(iVideoObjectDef->GetPropertyDefL(
  1461     iDrmPropertyDef = &(iVideoObjectDef->GetPropertyDefL(
  1419             KVcxDrmPropertyName )); //part of flags (7)
  1462             KVcxDrmPropertyName )); //part of flags (7)
  1420     iRatingPropertyDef = &(iVideoObjectDef->GetPropertyDefL(
  1463     iRatingPropertyDef = &(iVideoObjectDef->GetPropertyDefL(
  1421             KVcxRatingPropertyName )); //19
  1464             KVcxRatingPropertyName )); //19
  1422     iBitratePropertyDef = &(iVideoObjectDef->GetPropertyDefL(
  1465     iBitratePropertyDef = &(iVideoObjectDef->GetPropertyDefL(
  1423             KVcxBitratePropertyName )); //20
  1466                 KVcxBitratePropertyName )); //20
  1424     iAudioFourCcPropertyDef = &(iVideoObjectDef->GetPropertyDefL(
  1467     iAudioFourCcPropertyDef = &(iVideoObjectDef->GetPropertyDefL(
  1425             KVcxAudioFourCcPropertyName )); //21
  1468                 KVcxAudioFourCcPropertyName )); //21
  1426     iWidthPropertyDef = &(iVideoObjectDef->GetPropertyDefL(
  1469     iWidthPropertyDef = &(iVideoObjectDef->GetPropertyDefL(
  1427             KVcxWidthPropertyName )); //22
  1470             KVcxWidthPropertyName )); //22
  1428     iHeightPropertyDef = &(iVideoObjectDef->GetPropertyDefL(
  1471     iHeightPropertyDef = &(iVideoObjectDef->GetPropertyDefL(
  1429             KVcxHeightPropertyName )); //23
  1472             KVcxHeightPropertyName )); //23
  1430     iArtistPropertyDef = &(iVideoObjectDef->GetPropertyDefL(
  1473     iArtistPropertyDef = &(iVideoObjectDef->GetPropertyDefL(
  1441             KVcxAgeProfilePropertyName )); //13
  1484             KVcxAgeProfilePropertyName )); //13
  1442 
  1485 
  1443     iAudioLanguagePropertyDef = &(iVideoObjectDef->GetPropertyDefL(
  1486     iAudioLanguagePropertyDef = &(iVideoObjectDef->GetPropertyDefL(
  1444             KVcxAudioLanguagePropertyName )); //14
  1487             KVcxAudioLanguagePropertyName )); //14
  1445 
  1488 
       
  1489 #if 0
  1446     iDownloadIdPropertyDef = &(iVideoObjectDef->GetPropertyDefL(
  1490     iDownloadIdPropertyDef = &(iVideoObjectDef->GetPropertyDefL(
  1447             KVcxDownloadIdPropertyName )); //18
  1491             KVcxDownloadIdPropertyName )); //18
  1448 
  1492 #endif
       
  1493     
  1449     }
  1494     }
  1450 
  1495 
  1451 // ---------------------------------------------------------------------------
  1496 // ---------------------------------------------------------------------------
  1452 // CVcxMyVideosMdsDb::DoHandleObjectNotificationL
  1497 // CVcxMyVideosMdsDb::DoHandleObjectNotificationL
  1453 // ---------------------------------------------------------------------------
  1498 // ---------------------------------------------------------------------------
  1484         CleanupStack::PopAndDestroy( &idArray ); // <-1
  1529         CleanupStack::PopAndDestroy( &idArray ); // <-1
  1485         }
  1530         }
  1486             
  1531             
  1487     }
  1532     }
  1488 
  1533 
       
  1534 // ---------------------------------------------------------------------------
       
  1535 // CVcxMyVideosMdsDb::SetCreationAndModifiedDatesL
       
  1536 // ---------------------------------------------------------------------------
       
  1537 //
       
  1538 void CVcxMyVideosMdsDb::SetCreationAndModifiedDatesL( CMdEObject& aObject )
       
  1539     {
       
  1540     TTime time;
       
  1541     time.UniversalTime();
       
  1542     TTimeIntervalSeconds timeOffset = User::UTCOffset();
       
  1543     TTime localTime = time + timeOffset;
       
  1544 
       
  1545     const TInt secondsInMinute( 60 );    
       
  1546     aObject.AddTimePropertyL( *iCreationDatePropertyDef, localTime ); 
       
  1547     aObject.AddInt16PropertyL( *iTimeOffsetPropertyDef, timeOffset.Int() / secondsInMinute );
       
  1548     aObject.AddTimePropertyL( *iLastModifiedDatePropertyDef, localTime );
       
  1549     }