videocollection/mpxmyvideoscollection/tsrc/mpxmvcolltest/src/VCXTestMdsDbModifier.cpp
changeset 0 96612d01cf9f
child 15 cf5481c2bc0b
child 34 bbb98528c666
equal deleted inserted replaced
-1:000000000000 0:96612d01cf9f
       
     1 /*
       
     2 * Copyright (c) 2002 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of the License "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:   ?Description*
       
    15 */
       
    16 
       
    17 
       
    18 // Copied from vcxmyvideosmdsdb.cpp, keep up to date.
       
    19 
       
    20 //#include <harvesterclient.h>
       
    21 #include <e32svr.h>
       
    22 #include <e32def.h>
       
    23 #include <bautils.h>
       
    24 #include <mpxmedia.h>
       
    25 #include <mpxmediacontainerdefs.h>
       
    26 #include <mpxmediageneraldefs.h>
       
    27 #include <mpxmediageneralextdefs.h>
       
    28 #include <mpxmediaarray.h>
       
    29 #include <mpxmediavideodefs.h>
       
    30 #include <mdeconstants.h>
       
    31 #include <mdequery.h>
       
    32 
       
    33 #include <vcxmyvideosdefs.h>
       
    34 
       
    35 #include "VCXTestLog.h"
       
    36 #include "VCXTestMdsDbModifier.h"
       
    37 //#include "vcxmyvideoscollectionutil.h"
       
    38 
       
    39 _LIT( KVcxVideoObjectName, "Video" );
       
    40                                                               //1 (ID)
       
    41 _LIT( KVcxTitlePropertyName, "Title" );                       //2
       
    42 _LIT( KVcxDescriptionPropertyName, "Description" );           //3
       
    43                                                               //4 (file path = URI)
       
    44 _LIT( KVcxSizePropertyName, "Size" );                         //5
       
    45 
       
    46 _LIT( KVcxCreationDatePropertyName, "CreationDate" );         //6 creation date is saved to 2 properties
       
    47 _LIT( KVcxTimeOffsetPropertyName, "TimeOffset" );             //6
       
    48 
       
    49 _LIT( KVcxFlagsPropertyName, "RecordingFlags" );              //7 flags are saved
       
    50 _LIT( KVcxDrmPropertyName, "DRM");                            //7 to both of these
       
    51 
       
    52 _LIT( KVcxCopyrightPropertyName, "Copyright" );               //8
       
    53 _LIT( KVcxItemTypePropertyName, "ItemType" );                 //9 (mime type)
       
    54 _LIT( KVcxLastModifiedDatePropertyName, "LastModifiedDate" ); //10
       
    55 _LIT( KVcxAgeProfilePropertyName, "AgeProfile" );             //11
       
    56 _LIT( KVcxAudioLanguagePropertyName, "AudioLanguage" );       //12
       
    57 _LIT( KVcxAuthorPropertyName, "Author" );                     //13
       
    58 _LIT( KVcxOriginPropertyName, "Origin" );                     //14
       
    59 _LIT( KVcxDurationPropertyName, "Duration" );                 //15
       
    60 _LIT( KVcxLastPlayPositionPropertyName, "LastPlayPosition" ); //16
       
    61 _LIT( KVcxDownloadIdPropertyName, "DownloadID" );             //17
       
    62 _LIT( KVcxRatingPropertyName, "Rating" );                     //19
       
    63 _LIT( KVcxBitratePropertyName, "Bitrate" );                   //20
       
    64 _LIT( KVcxAudioFourCcPropertyName, "AudioFourCC" );           //21
       
    65 
       
    66 // ---------------------------------------------------------------------------
       
    67 // This is TCleanupOperation function which clears the db in use flag
       
    68 // ---------------------------------------------------------------------------
       
    69 //
       
    70 static void ClearDbInUseFlag( TAny* aBoolPtr )
       
    71     {
       
    72     *(static_cast<TBool*>(aBoolPtr)) = EFalse;
       
    73     }
       
    74 
       
    75 // ---------------------------------------------------------------------------
       
    76 // ---------------------------------------------------------------------------
       
    77 //
       
    78 CVCXTestMdsDbModifier::CVCXTestMdsDbModifier()
       
    79     {
       
    80     }
       
    81 
       
    82 // ---------------------------------------------------------------------------
       
    83 // ---------------------------------------------------------------------------
       
    84 //
       
    85 void CVCXTestMdsDbModifier::ConstructL()
       
    86     {
       
    87     VCXLOGLO1( "CVCXTestMdsDbModifier::ConstructL" );
       
    88 
       
    89     User::LeaveIfError( iRfs.Connect() );
       
    90 
       
    91     iActiveSchedulerWait = new (ELeave) CActiveSchedulerWait;
       
    92 
       
    93     //  Mark the db to be in use
       
    94     iDbInUse = ETrue;
       
    95 
       
    96     CleanupStack::PushL( TCleanupItem( ClearDbInUseFlag, &iDbInUse ) );
       
    97 
       
    98     VCXLOGLO1( "CVCXTestMdsDbModifier::ConstructL CMdESession::NewL" );
       
    99 
       
   100     //  Create session
       
   101     iMDSError = KErrNone;
       
   102 
       
   103     iMDSSession = CMdESession::NewL( *this );
       
   104     if (!iMDSSession)
       
   105         {
       
   106         //  Failed to create session, leave
       
   107         User::Leave( iMDSError );
       
   108         }
       
   109 
       
   110     //  Wait until session opened
       
   111     iActiveSchedulerWait->Start();
       
   112 
       
   113     VCXLOGLO1( "CVCXTestMdsDbModifier::ConstructL iActiveSchedulerWait->Start done" );
       
   114 
       
   115     if ( iMDSError != KErrNone )
       
   116         {
       
   117         VCXLOGLO2("Failed to create session to MDS: %d", iMDSError);
       
   118         User::LeaveIfError( iMDSError );
       
   119         }
       
   120 
       
   121     //  Get the schema definitions
       
   122     iMDSError = KErrNone;
       
   123     GetSchemaDefinitionsL();
       
   124 
       
   125     iDbInUse = EFalse;
       
   126 
       
   127     //  Is schema ok
       
   128     if ( iMDSError != KErrNone )
       
   129         {
       
   130         //  Schema not loaded, abort
       
   131         User::Leave( iMDSError );
       
   132         }
       
   133 
       
   134     //  The db is not in use anymore, iDbInUse clearer item
       
   135     CleanupStack::PopAndDestroy();
       
   136     }
       
   137 
       
   138 // ---------------------------------------------------------------------------
       
   139 // ---------------------------------------------------------------------------
       
   140 //
       
   141 CVCXTestMdsDbModifier* CVCXTestMdsDbModifier::NewL()
       
   142     {
       
   143     CVCXTestMdsDbModifier* self =
       
   144             CVCXTestMdsDbModifier::NewLC();
       
   145     CleanupStack::Pop( self );
       
   146     return self;
       
   147     }
       
   148 
       
   149 // ---------------------------------------------------------------------------
       
   150 // ---------------------------------------------------------------------------
       
   151 //
       
   152 CVCXTestMdsDbModifier* CVCXTestMdsDbModifier::NewLC()
       
   153     {
       
   154     CVCXTestMdsDbModifier* self = new( ELeave ) CVCXTestMdsDbModifier();
       
   155     CleanupStack::PushL( self );
       
   156     self->ConstructL();
       
   157     return self;
       
   158     }
       
   159 
       
   160 // ---------------------------------------------------------------------------
       
   161 // ---------------------------------------------------------------------------
       
   162 //
       
   163 CVCXTestMdsDbModifier::~CVCXTestMdsDbModifier()
       
   164     {
       
   165     VCXLOGLO1( "CVCXTestMdsDbModifier::~CVCXTestMdsDbModifier()" );
       
   166 
       
   167     if ( iMDSSession )
       
   168         {
       
   169         TRAP_IGNORE( iMDSSession->RemoveObjectObserverL( *this ) );
       
   170         }
       
   171 
       
   172     delete iMDSSession;
       
   173     delete iActiveSchedulerWait;
       
   174 
       
   175     iRfs.Close();
       
   176     }
       
   177 
       
   178 // ---------------------------------------------------------------------------
       
   179 // CVCXTestMdsDbModifier::RemoveVideoL
       
   180 // ---------------------------------------------------------------------------
       
   181 //
       
   182 TInt CVCXTestMdsDbModifier::RemoveVideoL(
       
   183         TUint32 aMdsId )
       
   184     {
       
   185     VCXLOGLO1( "CVCXTestMdsDbModifier::RemoveVideoL" );
       
   186 
       
   187     TInt retValue = KErrNone;
       
   188 
       
   189     VCXLOGLO2( "CVCXTestMdsDbModifier:: removing object %d", aMdsId );
       
   190 
       
   191     TItemId id = iMDSSession->RemoveObjectL( aMdsId );
       
   192 
       
   193     if ( id == KNoId )
       
   194         {
       
   195         VCXLOGLO1( "CVCXTestMdsDbModifier:: video not found" );
       
   196         retValue = KErrNotFound;
       
   197         }
       
   198     else
       
   199         {
       
   200         VCXLOGLO1( "CVCXTestMdsDbModifier:: remove successful" );
       
   201         }
       
   202 
       
   203     return retValue;
       
   204     }
       
   205 
       
   206 // ---------------------------------------------------------------------------
       
   207 // CVCXTestMdsDbModifier::UpdateVideoL
       
   208 // ---------------------------------------------------------------------------
       
   209 //
       
   210 void CVCXTestMdsDbModifier::UpdateVideoL(
       
   211         CMPXMedia& aVideo )
       
   212     {
       
   213     VCXLOGLO1( "CVCXTestMdsDbModifier::UpdateVideoL" );
       
   214 
       
   215     TMPXItemId mpxId = aVideo.ValueTObjectL<TMPXItemId>( KMPXMediaGeneralId );
       
   216 
       
   217     VCXLOGLO2("CVCXTestMdsDbModifier::UpdateVideoL updating object %d ", mpxId.iId1);
       
   218 
       
   219     CMdEObject* object =
       
   220             iMDSSession->OpenObjectL( mpxId.iId1, *iVideoObjectDef );
       
   221     if ( !object )
       
   222         {
       
   223         // No object with this ID was found!
       
   224         VCXLOGLO1("CVCXTestMdsDbModifier::UpdateVideoL no object found");
       
   225         User::Leave( KErrNotFound );
       
   226         }
       
   227     else
       
   228         {
       
   229         VCXLOGLO1("CVCXTestMdsDbModifier::UpdateVideoL object found");
       
   230 
       
   231         if ( object->OpenForModifications() )
       
   232             {
       
   233             CleanupStack::PushL( object ); // 1->
       
   234 
       
   235             Media2ObjectL( aVideo, *object );
       
   236 
       
   237             iMDSSession->CommitObjectL(*object);
       
   238 
       
   239             CleanupStack::PopAndDestroy(object);
       
   240             }
       
   241         else
       
   242             {
       
   243             // Object is already locked!
       
   244             VCXLOGLO1("CVCXTestMdsDbModifier::UpdateVideoL object was locked!");
       
   245             delete object;
       
   246             User::Leave( KErrInUse );
       
   247             }
       
   248         }
       
   249     }
       
   250 
       
   251 // ---------------------------------------------------------------------------
       
   252 // CVCXTestMdsDbModifier::DeleteVideoL.
       
   253 // ---------------------------------------------------------------------------
       
   254 //
       
   255 TInt CVCXTestMdsDbModifier::DeleteVideoL(
       
   256         TUint32 aFileId,
       
   257         TInt& aResultCount,
       
   258         TBool aForcedDelete /*= EFalse */ )
       
   259     {
       
   260     VCXLOGLO1( "CVCXTestMdsDbModifier::DeleteVideoL" );
       
   261 
       
   262     TInt err = KErrNone;
       
   263     aResultCount = 0;
       
   264 
       
   265     if (aForcedDelete)
       
   266         {
       
   267         TItemId id = iMDSSession->RemoveObjectL( aFileId );
       
   268 
       
   269         err = (id == KNoId) ? KErrNotFound : KErrNone;
       
   270         }
       
   271 
       
   272     return err;
       
   273     }
       
   274 
       
   275 // ---------------------------------------------------------------------------
       
   276 // From class MMdEQueryObserver.
       
   277 // ---------------------------------------------------------------------------
       
   278 //
       
   279 void CVCXTestMdsDbModifier::HandleQueryNewResults(
       
   280         CMdEQuery& /* aQuery */,
       
   281         TInt /* aFirstNewItemIndex */,
       
   282         TInt /* aNewItemCount */ )
       
   283     {
       
   284     VCXLOGLO1( "CVCXTestMdsDbModifier::HandleQueryNewResults" );
       
   285     }
       
   286 
       
   287 // ---------------------------------------------------------------------------
       
   288 // From class MMdEQueryObserver.
       
   289 // ---------------------------------------------------------------------------
       
   290 //
       
   291 void CVCXTestMdsDbModifier::HandleQueryCompleted(
       
   292         CMdEQuery& /*aQuery*/,
       
   293         TInt /*aError*/)
       
   294     {
       
   295     VCXLOGLO1( "CVCXTestMdsDbModifier::HandleQueryCompleted" );
       
   296 
       
   297     if (iActiveSchedulerWait->IsStarted())
       
   298         {
       
   299         iActiveSchedulerWait->AsyncStop();
       
   300         }
       
   301     }
       
   302 
       
   303 // ---------------------------------------------------------------------------
       
   304 // From class MMdESessionObserver.
       
   305 // ---------------------------------------------------------------------------
       
   306 //
       
   307 void CVCXTestMdsDbModifier::HandleSessionOpened(
       
   308         CMdESession& /*aSession*/,
       
   309         TInt aError)
       
   310     {
       
   311     VCXLOGLO1( "CVCXTestMdsDbModifier::HandleSessionOpened" );
       
   312 
       
   313     iActiveSchedulerWait->AsyncStop();
       
   314 
       
   315     if (aError != KErrNone)
       
   316         {
       
   317         VCXLOGLO2( "CVCXTestMdsDbModifier::HandleSessionOpened: %d", aError );
       
   318 
       
   319         iMDSError = aError;
       
   320         delete iMDSSession;
       
   321         iMDSSession = NULL;
       
   322         }
       
   323     }
       
   324 
       
   325 // ---------------------------------------------------------------------------
       
   326 // From class MMdESessionObserver.
       
   327 // ---------------------------------------------------------------------------
       
   328 //
       
   329 void CVCXTestMdsDbModifier::HandleSessionError(
       
   330         CMdESession& /*aSession*/,
       
   331         TInt aError)
       
   332     {
       
   333     VCXLOGLO1( "CVCXTestMdsDbModifier::HandleSessionError" );
       
   334 
       
   335     if (iActiveSchedulerWait->IsStarted())
       
   336         {
       
   337         iActiveSchedulerWait->AsyncStop();
       
   338         }
       
   339 
       
   340     VCXLOGLO2( "CVCXTestMdsDbModifier::HandleSessionError: %d", aError );
       
   341 
       
   342     iMDSError = aError;
       
   343     delete iMDSSession;
       
   344     iMDSSession = NULL;
       
   345     }
       
   346 
       
   347 // ---------------------------------------------------------------------------
       
   348 // From class MMdESchemaObserver.
       
   349 // ---------------------------------------------------------------------------
       
   350 //
       
   351 void CVCXTestMdsDbModifier::HandleSchemaModified()
       
   352     {
       
   353     VCXLOGLO1( "CVCXTestMdsDbModifier::HandleSchemaModified" );
       
   354     TRAP( iMDSError, GetSchemaDefinitionsL() );
       
   355     }
       
   356 
       
   357 // ---------------------------------------------------------------------------
       
   358 // CVCXTestMdsDbModifier::HandleObjectNotification
       
   359 // ---------------------------------------------------------------------------
       
   360 //
       
   361 void CVCXTestMdsDbModifier::HandleObjectNotification(
       
   362         CMdESession& /*aSession*/,
       
   363         TObserverNotificationType /* aType */,
       
   364         const RArray<TItemId>& /* aObjectIdArray */ )
       
   365     {
       
   366     VCXLOGLO1( "CVCXTestMdsDbModifier::HandleObjectNotification" );
       
   367     }
       
   368 
       
   369 // ---------------------------------------------------------------------------
       
   370 // CVCXTestMdsDbModifier::Media2ObjectL
       
   371 // Called by AddVideoL()
       
   372 // ---------------------------------------------------------------------------
       
   373 //
       
   374 void CVCXTestMdsDbModifier::Media2ObjectL(
       
   375         CMPXMedia& aVideo,
       
   376         CMdEObject& aObject)
       
   377     {
       
   378     VCXLOGLO1( "CVCXTestMdsDbModifier::Media2ObjectL" );
       
   379 
       
   380     CMdEProperty* property;
       
   381 
       
   382     // 1. MDS ID
       
   383 
       
   384     // 2. TITLE (NAME)
       
   385     if ( aVideo.IsSupported( KMPXMediaGeneralTitle ) )
       
   386         {
       
   387         VCXLOGLO1( "CVCXTestMdsDbModifier::Media2ObjectL: Setting KMPXMediaGeneralTitle" );
       
   388         if ( aObject.Property( *iTitlePropertyDef, property, 0 ) != KErrNotFound )
       
   389             {
       
   390             static_cast<CMdETextProperty*>(property)->SetValueL(
       
   391                     aVideo.ValueText( KMPXMediaGeneralTitle ) );
       
   392             }
       
   393         else
       
   394             {
       
   395             aObject.AddTextPropertyL(
       
   396                     *iTitlePropertyDef, aVideo.ValueText( KMPXMediaGeneralTitle ) );
       
   397             }
       
   398         }
       
   399 
       
   400     // 3. DESC
       
   401     if ( aVideo.IsSupported( KMPXMediaGeneralComment ) )
       
   402         {
       
   403         VCXLOGLO1( "CVCXTestMdsDbModifier::Media2ObjectL: Setting KMPXMediaGeneralComment" );
       
   404         if ( aObject.Property( *iDescriptionPropertyDef, property, 0 ) != KErrNotFound )
       
   405             {
       
   406             static_cast<CMdETextProperty*>(property)->SetValueL(
       
   407                     aVideo.ValueText( KMPXMediaGeneralComment ) );
       
   408             }
       
   409         else
       
   410             {
       
   411             aObject.AddTextPropertyL(
       
   412                     *iDescriptionPropertyDef, aVideo.ValueText( KMPXMediaGeneralComment ) );
       
   413             }
       
   414         }
       
   415 #if 0
       
   416     // 4. URI ( = file path )
       
   417     if ( aVideo.IsSupported( KMPXMediaGeneralUri ) )
       
   418         {
       
   419         VCXLOGLO1( "CVCXTestMdsDbModifier::Media2ObjectL: Setting KMPXMediaGeneralUri" );
       
   420         aObject.SetUriL( aVideo.ValueText( KMPXMediaGeneralUri ) );
       
   421         TVolumeInfo volInfo;
       
   422         // 4.1 MEDIA ID ( = drive number )
       
   423         if ( iRfs.Volume( volInfo, TVcxMyVideosCollectionUtil::DriveLetter2DriveNumber(
       
   424                 aObject.Uri() ) ) == KErrNone)
       
   425             {
       
   426             aObject.SetMediaId( volInfo.iUniqueID );
       
   427             }
       
   428         }
       
   429 #endif
       
   430 
       
   431     // 5. KMPXMediaGeneralSize
       
   432     if ( aVideo.IsSupported( KMPXMediaGeneralSize ) )
       
   433         {
       
   434         TUint32 size = 0;
       
   435         TInt sizeInMediaObject = aVideo.ValueTObjectL<TInt>( KMPXMediaGeneralSize );
       
   436         VCXLOGLO2( "CVCXTestMdsDbModifier::Media2ObjectL: Setting KMPXMediaGeneralSize: %d", sizeInMediaObject );
       
   437         size = static_cast<TUint32>( sizeInMediaObject );
       
   438 
       
   439         if ( aObject.Property( *iSizePropertyDef, property, 0 ) != KErrNotFound )
       
   440             {
       
   441             static_cast<CMdEUint32Property*>( property )->SetValueL( size );
       
   442             }
       
   443         else
       
   444             {
       
   445             aObject.AddUint32PropertyL( *iSizePropertyDef, size );
       
   446             }
       
   447         }
       
   448 
       
   449     // KMPXMediaGeneralExtSizeInt64
       
   450     if ( aVideo.IsSupported( KMPXMediaGeneralExtSizeInt64 ) )
       
   451         {
       
   452         TUint32 size = 0;
       
   453         TInt64 sizeInMediaObject = aVideo.ValueTObjectL<TInt64>( KMPXMediaGeneralExtSizeInt64 );
       
   454         VCXLOGLO2( "CVCXTestMdsDbModifier::Media2ObjectL: Setting KMPXMediaGeneralExtSizeInt64: %Ld", sizeInMediaObject );
       
   455         size = static_cast<TUint32>( sizeInMediaObject );
       
   456 
       
   457         if ( aObject.Property( *iSizePropertyDef, property, 0 ) != KErrNotFound )
       
   458             {
       
   459             static_cast<CMdEUint32Property*>( property )->SetValueL( size );
       
   460             }
       
   461         else
       
   462             {
       
   463             aObject.AddUint32PropertyL( *iSizePropertyDef, size );
       
   464             }
       
   465         }
       
   466 
       
   467     // 6. KMPXMediaGeneralDate ( creation date )
       
   468     if ( aVideo.IsSupported( KMPXMediaGeneralDate ) )
       
   469         {
       
   470         VCXLOGLO1( "CVCXTestMdsDbModifier::Media2ObjectL: Setting KMPXMediaGeneralDate" );
       
   471         TInt64 creationDateInt64 = 0;
       
   472         creationDateInt64 = aVideo.ValueTObjectL<TInt64>( KMPXMediaGeneralDate );
       
   473         TTime creationDate( creationDateInt64 );
       
   474         if ( aObject.Property( *iCreationDatePropertyDef, property, 0 ) != KErrNotFound )
       
   475             {
       
   476             static_cast<CMdETimeProperty*>(property)->SetValueL( creationDate );
       
   477             }
       
   478         else
       
   479             {
       
   480             aObject.AddTimePropertyL( *iCreationDatePropertyDef, creationDate );
       
   481             }
       
   482         }
       
   483 
       
   484     // 7. KMPXMediaGeneralFlags (including DRM flag)
       
   485     if ( aVideo.IsSupported( KMPXMediaGeneralFlags ) )
       
   486         {
       
   487         TUint32 flags = aVideo.ValueTObjectL<TUint32>( KMPXMediaGeneralFlags );
       
   488         VCXLOGLO2( "CVCXTestMdsDbModifier::Media2ObjectL: Setting KMPXMediaGeneralFlags: %d", KMPXMediaGeneralFlags );
       
   489         if ( aObject.Property( *iFlagsPropertyDef, property, 0 ) != KErrNotFound )
       
   490             {
       
   491             static_cast<CMdEUint32Property*>(property)->SetValueL( flags );
       
   492             }
       
   493         else
       
   494             {
       
   495             aObject.AddUint32PropertyL( *iFlagsPropertyDef, flags );
       
   496             }
       
   497 
       
   498         TBool drmProtected;
       
   499         if ( flags & EVcxMyVideosVideoDrmProtected )
       
   500             {
       
   501             drmProtected = ETrue;
       
   502             }
       
   503         else
       
   504             {
       
   505             drmProtected = EFalse;
       
   506             }
       
   507 
       
   508         VCXLOGLO2( "CVCXTestMdsDbModifier::Media2ObjectL: Setting drmProtected: %d", drmProtected );
       
   509 
       
   510         if ( aObject.Property( *iDrmPropertyDef, property, 0 ) != KErrNotFound )
       
   511             {
       
   512             static_cast<CMdEBoolProperty*>(property)->SetValueL( drmProtected );
       
   513             }
       
   514         else
       
   515             {
       
   516             aObject.AddBoolPropertyL( *iDrmPropertyDef, drmProtected );
       
   517             }
       
   518         }
       
   519 
       
   520     // 8. KMPXMediaGeneralCopyright
       
   521     if ( aVideo.IsSupported( KMPXMediaGeneralCopyright ))
       
   522         {
       
   523         VCXLOGLO1( "CVCXTestMdsDbModifier::Media2ObjectL: Setting KMPXMediaGeneralCopyright" );
       
   524         if ( aObject.Property( *iCopyrightPropertyDef, property, 0 ) != KErrNotFound )
       
   525             {
       
   526             static_cast<CMdETextProperty*>(property)->SetValueL(
       
   527                     aVideo.ValueText( KMPXMediaGeneralCopyright ) );
       
   528             }
       
   529         else
       
   530             {
       
   531             if ( aVideo.ValueText( KMPXMediaGeneralCopyright ).Length() )
       
   532                 {
       
   533                 aObject.AddTextPropertyL(
       
   534                         *iCopyrightPropertyDef,
       
   535                         aVideo.ValueText( KMPXMediaGeneralCopyright ) );
       
   536                 }
       
   537             }
       
   538         }
       
   539 
       
   540     // 9. KMPXMediaGeneralMimeType
       
   541     if ( aVideo.IsSupported( KMPXMediaGeneralMimeType ))
       
   542         {
       
   543         VCXLOGLO1( "CVCXTestMdsDbModifier::Media2ObjectL: Setting KMPXMediaGeneralMimeType" );
       
   544         if ( aObject.Property( *iItemTypePropertyDef, property, 0 ) != KErrNotFound )
       
   545             {
       
   546             static_cast<CMdETextProperty*>(property)->SetValueL(
       
   547                     aVideo.ValueText( KMPXMediaGeneralMimeType ) );
       
   548             }
       
   549         else
       
   550             {
       
   551             aObject.AddTextPropertyL(
       
   552                     *iItemTypePropertyDef,
       
   553                     aVideo.ValueText( KMPXMediaGeneralMimeType ) );
       
   554             }
       
   555         }
       
   556 
       
   557     // 10. KVcxMediaMyVideosModifiedDate
       
   558     if ( aVideo.IsSupported( KVcxMediaMyVideosModifiedDate ) )
       
   559         {
       
   560         VCXLOGLO1( "CVCXTestMdsDbModifier::Media2ObjectL: Setting KVcxMediaMyVideosModifiedDate" );
       
   561         TInt64 modifiedDateInt64 = aVideo.ValueTObjectL<TInt64>( KVcxMediaMyVideosModifiedDate );
       
   562         TTime modifiedDate( modifiedDateInt64 );
       
   563         if ( aObject.Property( *iLastModifiedDatePropertyDef, property, 0 ) != KErrNotFound )
       
   564             {
       
   565             static_cast<CMdETimeProperty*>(property)->SetValueL( modifiedDate );
       
   566             }
       
   567         else
       
   568             {
       
   569             aObject.AddTimePropertyL( *iLastModifiedDatePropertyDef, modifiedDate );
       
   570             }
       
   571         }
       
   572 
       
   573     // 11. KVcxMediaMyVideosAgeProfile
       
   574     if ( aVideo.IsSupported( KVcxMediaMyVideosAgeProfile ) )
       
   575         {
       
   576         TInt32 ageProfile = aVideo.ValueTObjectL<TInt32>(KVcxMediaMyVideosAgeProfile );
       
   577         VCXLOGLO2( "CVCXTestMdsDbModifier::Media2ObjectL: Setting KVcxMediaMyVideosAgeProfile: %d", ageProfile );
       
   578         if ( aObject.Property( *iAgeProfilePropertyDef, property, 0 ) != KErrNotFound )
       
   579             {
       
   580             static_cast<CMdEInt32Property*>(property)->SetValueL( ageProfile );
       
   581             }
       
   582         else
       
   583             {
       
   584             aObject.AddInt32PropertyL( *iAgeProfilePropertyDef, ageProfile );
       
   585             }
       
   586         }
       
   587 
       
   588     // 12. KVcxMediaMyVideosAudioLanguage
       
   589     if ( aVideo.IsSupported( KVcxMediaMyVideosAudioLanguage ) )
       
   590         {
       
   591         VCXLOGLO1( "CVCXTestMdsDbModifier::Media2ObjectL: Setting KVcxMediaMyVideosAudioLanguage" );
       
   592         if ( aObject.Property( *iAudioLanguagePropertyDef, property, 0 ) != KErrNotFound )
       
   593             {
       
   594             static_cast<CMdETextProperty*>(property)->SetValueL(
       
   595                     aVideo.ValueText( KVcxMediaMyVideosAudioLanguage ) );
       
   596             }
       
   597         else
       
   598             {
       
   599             aObject.AddTextPropertyL(
       
   600                     *iAudioLanguagePropertyDef,
       
   601                     aVideo.ValueText( KVcxMediaMyVideosAudioLanguage ) );
       
   602             }
       
   603         }
       
   604 
       
   605     // 13. KVcxMediaMyVideosAuthor
       
   606     if ( aVideo.IsSupported( KVcxMediaMyVideosAuthor ) )
       
   607         {
       
   608         VCXLOGLO1( "CVCXTestMdsDbModifier::Media2ObjectL: Setting KVcxMediaMyVideosAuthor" );
       
   609         if ( aObject.Property( *iAuthorPropertyDef, property, 0 ) != KErrNotFound )
       
   610             {
       
   611             static_cast<CMdETextProperty*>(property)->SetValueL(
       
   612                     aVideo.ValueText( KVcxMediaMyVideosAuthor ) );
       
   613             }
       
   614         else
       
   615             {
       
   616             aObject.AddTextPropertyL(
       
   617                     *iAuthorPropertyDef,
       
   618                     aVideo.ValueText( KVcxMediaMyVideosAuthor ) );
       
   619             }
       
   620         }
       
   621 
       
   622     // 14. KVcxMediaMyVideosOrigin
       
   623     if ( aVideo.IsSupported( KVcxMediaMyVideosOrigin ) )
       
   624         {
       
   625         TUint8 origin = aVideo.ValueTObjectL<TUint8>( KVcxMediaMyVideosOrigin );
       
   626         VCXLOGLO1( "CVCXTestMdsDbModifier::Media2ObjectL: Setting xxx" );
       
   627         if ( aObject.Property( *iOriginPropertyDef, property, 0 ) != KErrNotFound )
       
   628             {
       
   629             static_cast<CMdEUint8Property*>(property)->SetValueL( origin );
       
   630             }
       
   631         else
       
   632             {
       
   633             aObject.AddUint8PropertyL( *iOriginPropertyDef, origin );
       
   634             }
       
   635         }
       
   636 
       
   637     // 15. KVcxMediaMyVideosDuration
       
   638     if ( aVideo.IsSupported( KVcxMediaMyVideosDuration ))
       
   639         {
       
   640         VCXLOGLO1( "CVCXTestMdsDbModifier::Media2ObjectL: Setting KVcxMediaMyVideosDuration" );
       
   641         TReal32 duration = aVideo.ValueTObjectL<TReal32>( KVcxMediaMyVideosDuration );
       
   642 
       
   643         if ( aObject.Property( *iDurationPropertyDef, property, 0 ) != KErrNotFound )
       
   644             {
       
   645             static_cast<CMdEReal32Property*>(property)->SetValueL( duration );
       
   646             }
       
   647         else
       
   648             {
       
   649             aObject.AddReal32PropertyL( *iDurationPropertyDef, duration );
       
   650             }
       
   651         }
       
   652 
       
   653     // 16. KVcxMediaMyVideosLastPlaybackPosition
       
   654     if ( aVideo.IsSupported( KMPXMediaGeneralLastPlaybackPosition ))
       
   655         {
       
   656         VCXLOGLO1( "CVCXTestMdsDbModifier::Media2ObjectL: Setting KMPXMediaGeneralLastPlaybackPosition" );
       
   657         TInt pos = static_cast<CMdEReal32Property*>(property)->Value();
       
   658         aVideo.SetTObjectValueL<TInt>( KMPXMediaGeneralLastPlaybackPosition, pos );
       
   659         }
       
   660 
       
   661     // 17. DOWNLOAD ID
       
   662     if ( aVideo.IsSupported( KVcxMediaMyVideosDownloadId ) )
       
   663         {
       
   664         TUint32 dlId = aVideo.ValueTObjectL<TUint32>( KVcxMediaMyVideosDownloadId );
       
   665 
       
   666         VCXLOGLO2( "CVCXTestMdsDbModifier::Media2ObjectL: DL ID = %d", dlId );
       
   667 
       
   668         if ( aObject.Property( *iDownloadIdPropertyDef, property, 0 ) != KErrNotFound )
       
   669             {
       
   670             static_cast<CMdEUint32Property*>(property)->SetValueL( dlId );
       
   671             }
       
   672         else
       
   673             {
       
   674             aObject.AddUint32PropertyL( *iDownloadIdPropertyDef, dlId );
       
   675             }
       
   676         }
       
   677 
       
   678     // 19. RATING
       
   679     if ( aVideo.IsSupported( KVcxMediaMyVideosRating ) )
       
   680         {
       
   681         TUint8 rating = aVideo.ValueTObjectL<TUint8>( KVcxMediaMyVideosRating );
       
   682         
       
   683         if ( aObject.Property( *iRatingPropertyDef, property, 0 ) != KErrNotFound )
       
   684             {
       
   685             static_cast<CMdEUint8Property*>(property)->SetValueL( rating );
       
   686             }
       
   687         else
       
   688             {
       
   689             aObject.AddUint8PropertyL( *iRatingPropertyDef, rating );
       
   690             }
       
   691         }
       
   692     // 20. BITRATE
       
   693     if ( aVideo.IsSupported( KMPXMediaVideoBitRate ) )
       
   694         {           
       
   695         TUint16 bitrate = aVideo.ValueTObjectL<TUint16>( KMPXMediaVideoBitRate );
       
   696         
       
   697         if ( aObject.Property( *iBitratePropertyDef, property, 0 ) != KErrNotFound )
       
   698             {
       
   699             static_cast<CMdEUint16Property*>(property)->SetValueL( bitrate );
       
   700             }
       
   701         else
       
   702             {
       
   703             aObject.AddUint16PropertyL( *iBitratePropertyDef, bitrate );
       
   704             }
       
   705         }
       
   706 
       
   707     // 21. AUDIOFOURCC
       
   708     if ( aVideo.IsSupported( KVcxMediaMyVideosAudioFourCc ) )
       
   709         {
       
   710         TUint32 audioFourCc = aVideo.ValueTObjectL<TUint32>( KVcxMediaMyVideosAudioFourCc );
       
   711         
       
   712         if ( aObject.Property( *iAudioFourCcPropertyDef, property, 0 ) != KErrNotFound )
       
   713             {
       
   714             static_cast<CMdEUint32Property*>(property)->SetValueL( audioFourCc );
       
   715             }
       
   716         else
       
   717             {
       
   718             aObject.AddUint32PropertyL( *iAudioFourCcPropertyDef, audioFourCc );
       
   719             }
       
   720         }
       
   721 
       
   722     }
       
   723 
       
   724 // ---------------------------------------------------------------------------
       
   725 // ---------------------------------------------------------------------------
       
   726 //
       
   727 void CVCXTestMdsDbModifier::GetSchemaDefinitionsL()
       
   728     {
       
   729     VCXLOGLO1( "CVCXTestMdsDbModifier::GetSchemaDefinitionsL" );
       
   730 
       
   731     //  Namespace
       
   732     iNamespaceDef = &(iMDSSession->GetDefaultNamespaceDefL());
       
   733 
       
   734     //  Default object definitions
       
   735     iVideoObjectDef = &(iNamespaceDef->GetObjectDefL( KVcxVideoObjectName ));
       
   736 
       
   737     //  Base object property definitions
       
   738     iTitlePropertyDef = &(iVideoObjectDef->GetPropertyDefL(
       
   739             KVcxTitlePropertyName )); //2
       
   740     iSizePropertyDef = &(iVideoObjectDef->GetPropertyDefL(
       
   741             KVcxSizePropertyName )); //5
       
   742     iCreationDatePropertyDef = &(iVideoObjectDef->GetPropertyDefL(
       
   743             KVcxCreationDatePropertyName )); //6
       
   744     iTimeOffsetPropertyDef = &(iVideoObjectDef->GetPropertyDefL(
       
   745             KVcxTimeOffsetPropertyName )); //6
       
   746     iItemTypePropertyDef = &(iVideoObjectDef->GetPropertyDefL(
       
   747             KVcxItemTypePropertyName )); //9
       
   748     iLastModifiedDatePropertyDef = &(iVideoObjectDef->GetPropertyDefL(
       
   749             KVcxLastModifiedDatePropertyName )); //10
       
   750 
       
   751     //  Media object property definitions
       
   752     iDescriptionPropertyDef = &(iVideoObjectDef->GetPropertyDefL(
       
   753             KVcxDescriptionPropertyName)); //3
       
   754     iCopyrightPropertyDef = &(iVideoObjectDef->GetPropertyDefL(
       
   755             KVcxCopyrightPropertyName )); //8
       
   756     iAuthorPropertyDef = &(iVideoObjectDef->GetPropertyDefL(
       
   757             KVcxAuthorPropertyName )); //13
       
   758     iOriginPropertyDef = &(iVideoObjectDef->GetPropertyDefL(
       
   759             KVcxOriginPropertyName )); //14
       
   760     iDurationPropertyDef = &(iVideoObjectDef->GetPropertyDefL(
       
   761             KVcxDurationPropertyName )); //15
       
   762     iDrmPropertyDef = &(iVideoObjectDef->GetPropertyDefL(
       
   763             KVcxDrmPropertyName )); //part of flags (7)
       
   764     iRatingPropertyDef = &(iVideoObjectDef->GetPropertyDefL(
       
   765             KVcxRatingPropertyName )); //19
       
   766     iBitratePropertyDef = &(iVideoObjectDef->GetPropertyDefL(
       
   767                 KVcxBitratePropertyName )); //20
       
   768     iAudioFourCcPropertyDef = &(iVideoObjectDef->GetPropertyDefL(
       
   769                 KVcxAudioFourCcPropertyName )); //21
       
   770 
       
   771     //  Video object property definitions
       
   772     iLastPlayPositionPropertyDef = &(iVideoObjectDef->GetPropertyDefL(
       
   773             KVcxLastPlayPositionPropertyName )); //16
       
   774 
       
   775     // remove these when default mds has all fields
       
   776     TRAP_IGNORE(
       
   777 
       
   778     iFlagsPropertyDef = &(iVideoObjectDef->GetPropertyDefL(
       
   779             KVcxFlagsPropertyName )); //7
       
   780 
       
   781     iAgeProfilePropertyDef = &(iVideoObjectDef->GetPropertyDefL(
       
   782             KVcxAgeProfilePropertyName )); //11
       
   783 
       
   784     iAudioLanguagePropertyDef = &(iVideoObjectDef->GetPropertyDefL(
       
   785             KVcxAudioLanguagePropertyName )); //12
       
   786 
       
   787     iDownloadIdPropertyDef = &(iVideoObjectDef->GetPropertyDefL(
       
   788             KVcxDownloadIdPropertyName )); //17
       
   789 
       
   790           );
       
   791 
       
   792     }
       
   793 
       
   794 //  End of File