mds_plat/harvester_framework_api/tsrc/ComposerPluginTest/src/ComposerPluginTestBlocks.cpp
changeset 0 c53acadfccc6
equal deleted inserted replaced
-1:000000000000 0:c53acadfccc6
       
     1 /*
       
     2 * Copyright (c) 2002-2009 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 "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:  
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 // [INCLUDE FILES] - do not remove
       
    20 #include <e32svr.h>
       
    21 #include <StifParser.h>
       
    22 #include <StifTestEventInterface.h>
       
    23 #include <StifTestInterface.h>
       
    24 #include "ComposerPluginTest.h"
       
    25 
       
    26 #include "mdsutils.h"
       
    27 #include "mdeconstants.h"
       
    28 
       
    29 using namespace MdeConstants;
       
    30 
       
    31 _LIT( KOpenErr, "        ModifyObjects - Open error : %d" );
       
    32 _LIT( KCommErr, "        ModifyObjects - Commit error : %d" );
       
    33 _LIT( KNull, "        ModifyObjects - NULL object" );
       
    34 _LIT( KCommit, "        ModifyObjects - Object committed" );
       
    35 _LIT( KUri, "C:\\Data\\Images\\Temp%d.jpg" );
       
    36 
       
    37 // ============================ MEMBER FUNCTIONS ===============================
       
    38 
       
    39 // -----------------------------------------------------------------------------
       
    40 // CComposerPluginTest::Delete
       
    41 // Delete here all resources allocated and opened from test methods. 
       
    42 // Called from destructor. 
       
    43 // -----------------------------------------------------------------------------
       
    44 //
       
    45 void CComposerPluginTest::Delete() 
       
    46     {
       
    47 
       
    48     }
       
    49 
       
    50 // -----------------------------------------------------------------------------
       
    51 // CComposerPluginTest::RunMethodL
       
    52 // Run specified method. Contains also table of test mothods and their names.
       
    53 // -----------------------------------------------------------------------------
       
    54 //
       
    55 TInt CComposerPluginTest::RunMethodL( 
       
    56     CStifItemParser& aItem ) 
       
    57     {
       
    58 
       
    59     static TStifFunctionInfo const KFunctions[] =
       
    60         {  
       
    61         // Copy this line for every implemented function.
       
    62         // First string is the function name used in TestScripter script file.
       
    63         // Second is the actual implementation member function. 
       
    64 
       
    65         ENTRY( "ActiveWait", CComposerPluginTest::ActiveWait ),
       
    66         ENTRY( "BeginComposerSession", CComposerPluginTest::BeginComposerSessionL ),
       
    67         ENTRY( "EndComposerSession", CComposerPluginTest::EndComposerSession ),
       
    68         ENTRY( "LoadPlugins", CComposerPluginTest::LoadPluginsL ),
       
    69         ENTRY( "SetSessions", CComposerPluginTest::SetSessions ),
       
    70         ENTRY( "RemoveSessions", CComposerPluginTest::RemoveSessions ),
       
    71         ENTRY( "ModifyObjects", CComposerPluginTest::ModifyObjectsL ),
       
    72         ENTRY( "DeleteObject", CComposerPluginTest::DeleteObjectL ),
       
    73         ENTRY( "DeleteObjects", CComposerPluginTest::DeleteObjectsL ),
       
    74         ENTRY( "WaitComposingComplete", CComposerPluginTest::WaitComposingComplete ),
       
    75 
       
    76         };
       
    77 
       
    78     const TInt count = sizeof( KFunctions ) / 
       
    79                         sizeof( TStifFunctionInfo );
       
    80 
       
    81     return RunInternalL( KFunctions, count, aItem );
       
    82 
       
    83     }
       
    84 
       
    85 // -----------------------------------------------------------------------------
       
    86 // CComposerPluginTest::HandleSessionOpened
       
    87 // -----------------------------------------------------------------------------
       
    88 //
       
    89 void CComposerPluginTest::HandleSessionOpened( CMdESession& /*aClient*/, TInt aError )
       
    90     {
       
    91     _LIT( KMsg, "CallBck HandleSessionOpened - Error code : %d" );
       
    92     TBuf <100> msg;
       
    93     msg.Format(KMsg, aError);
       
    94     iLog->Log( msg );     
       
    95     RDebug::Print(msg);
       
    96     
       
    97     // session event
       
    98     TEventIf event( TEventIf::ESetEvent, _L("Session") );
       
    99     TestModuleIf().Event( event );
       
   100     }
       
   101 
       
   102 // -----------------------------------------------------------------------------
       
   103 // CComposerPluginTest::HandleSessionError
       
   104 // -----------------------------------------------------------------------------
       
   105 //
       
   106 void CComposerPluginTest::HandleSessionError( CMdESession& /*aClient*/, TInt aError )
       
   107     {
       
   108     _LIT( KMsg, "CallBck HandleSessionError - Error code : %d" );
       
   109     TBuf <100> msg;
       
   110     msg.Format(KMsg, aError);
       
   111     iLog->Log( msg );
       
   112     RDebug::Print(msg);
       
   113     
       
   114     // session event
       
   115     TEventIf event( TEventIf::ESetEvent, _L("Session") );
       
   116     TestModuleIf().Event( event );
       
   117     }   
       
   118 
       
   119 // -----------------------------------------------------------------------------
       
   120 // CComposerPluginTest::ActiveWait
       
   121 // -----------------------------------------------------------------------------
       
   122 //
       
   123 TInt CComposerPluginTest::ActiveWait( CStifItemParser& /* aItem */ )
       
   124     {
       
   125     TTimeIntervalMicroSeconds32 timeout(2500000);
       
   126     RTimer timer;
       
   127     TRequestStatus status;
       
   128 
       
   129     timer.CreateLocal();
       
   130     timer.After(status,timeout);
       
   131 
       
   132     User::WaitForAnyRequest();
       
   133     
       
   134     timer.Close();
       
   135     
       
   136     _LIT( KMsg1, "Exit ActiveWait" );
       
   137     iLog->Log( KMsg1 );
       
   138     RDebug::Print( KMsg1 );
       
   139     
       
   140     return KErrNone;
       
   141     }
       
   142 
       
   143 // -----------------------------------------------------------------------------
       
   144 // CComposerPluginTest::BeginComposerSessionL
       
   145 // -----------------------------------------------------------------------------
       
   146 //
       
   147 TInt CComposerPluginTest::BeginComposerSessionL( CStifItemParser& /* aItem */ )
       
   148     {
       
   149     iMdEClient = NULL;
       
   150     TRAPD( error, iMdEClient = CMdESession::NewL( *this ) );
       
   151 
       
   152     _LIT( KMsg, "Exit    BeginComposerSession - Error code : %d" );
       
   153     TBuf <100> msg;
       
   154     msg.Format(KMsg, error);
       
   155     iLog->Log( msg );
       
   156     RDebug::Print(msg);
       
   157     
       
   158     User::LeaveIfError(error);
       
   159     
       
   160     return KErrNone;
       
   161     }    
       
   162 
       
   163 // -----------------------------------------------------------------------------
       
   164 // CComposerPluginTest::EndComposerSession
       
   165 // -----------------------------------------------------------------------------
       
   166 //
       
   167 TInt CComposerPluginTest::EndComposerSession( CStifItemParser& /* aItem */ )
       
   168 	{    
       
   169 	iPluginArray.ResetAndDestroy();
       
   170 	iPluginArray.Close();
       
   171 	    
       
   172 	if ( iMdEClient )
       
   173 		{
       
   174 	    delete iMdEClient;
       
   175 	    iMdEClient = NULL;
       
   176 	    }
       
   177     
       
   178 	REComSession::FinalClose();
       
   179 	
       
   180     _LIT( KMsg, "Exit EndComposerSession" );
       
   181     iLog->Log( KMsg );  
       
   182     RDebug::Print( KMsg );
       
   183 	
       
   184     return KErrNone;
       
   185     }
       
   186 
       
   187 // -----------------------------------------------------------------------------
       
   188 // CComposerPluginTest::LoadPluginsL
       
   189 // -----------------------------------------------------------------------------
       
   190 //
       
   191 TInt CComposerPluginTest::LoadPluginsL( CStifItemParser& /* aItem */ )
       
   192     {
       
   193     _LIT( KMsg1, "Enter LoadPlugins" );
       
   194     iLog->Log( KMsg1 );
       
   195     RDebug::Print( KMsg1 );
       
   196     
       
   197     TUid imageComposerUID = { 0x20007185 }; // MDS image composer plugin
       
   198     
       
   199     RImplInfoPtrArray infoArray;
       
   200     	
       
   201 	TCleanupItem cleanupItem( MdsUtils::CleanupEComArray, &infoArray );
       
   202 	CleanupStack::PushL( cleanupItem );
       
   203 	
       
   204 	CComposerPlugin::ListImplementationsL( infoArray );
       
   205 	TInt count( 0 );
       
   206 	count = infoArray.Count();
       
   207 	
       
   208 	for ( TInt i=0; i < count; i++ )
       
   209 		{
       
   210 		TUid uid = infoArray[i]->ImplementationUid();    // Create the plug-ins
       
   211 		if( uid == imageComposerUID )
       
   212 		    {
       
   213 		    iPluginArray.AppendL( CComposerPlugin::NewL( uid ) ); // and add them to array
       
   214 		    }
       
   215 		}
       
   216 		
       
   217 	CleanupStack::PopAndDestroy( &infoArray ); // infoArray, results in a call to CleanupEComArray
       
   218     
       
   219 	if( iPluginArray.Count() == 0 )
       
   220 	    {
       
   221 	    return KErrNotFound;
       
   222 	    }
       
   223 
       
   224 	
       
   225     _LIT( KMsg2, "Exit LoadPlugins" );
       
   226     iLog->Log( KMsg2 );
       
   227     RDebug::Print( KMsg2 );
       
   228     
       
   229     return KErrNone;
       
   230     }
       
   231 
       
   232 // -----------------------------------------------------------------------------
       
   233 // CComposerPluginTest::SetSessions
       
   234 // -----------------------------------------------------------------------------
       
   235 //
       
   236 TInt CComposerPluginTest::SetSessions( CStifItemParser&  /*aItem*/ )
       
   237 	{    
       
   238     _LIT( KMsg1, "Enter SetSessions" );
       
   239     iLog->Log( KMsg1 );
       
   240     RDebug::Print( KMsg1 );
       
   241     
       
   242     if( !iMdEClient )
       
   243         {
       
   244         return KErrUnknown;
       
   245         }
       
   246     
       
   247 	for ( TInt i = 0; i < iPluginArray.Count(); ++i )
       
   248 		{
       
   249 		iPluginArray[i]->SetSession( *iMdEClient );
       
   250 		}
       
   251 	
       
   252     _LIT( KMsg2, "Exit SetSessions" );
       
   253     iLog->Log( KMsg2 );
       
   254     RDebug::Print( KMsg2 );
       
   255 	
       
   256     return KErrNone;
       
   257     }
       
   258 
       
   259 // -----------------------------------------------------------------------------
       
   260 // CComposerPluginTest::RemoveSessions
       
   261 // -----------------------------------------------------------------------------
       
   262 //
       
   263 TInt CComposerPluginTest::RemoveSessions( CStifItemParser& /* aItem */ )
       
   264 	{    
       
   265     _LIT( KMsg1, "Enter RemoveSessions" );
       
   266     iLog->Log( KMsg1 );
       
   267     RDebug::Print( KMsg1 );
       
   268 	
       
   269 	for(TInt i = 0; i < iPluginArray.Count(); ++i)
       
   270 		{
       
   271 		iPluginArray[i]->RemoveSession();
       
   272 		}
       
   273 	
       
   274     _LIT( KMsg2, "Exit RemoveSessions" );
       
   275     iLog->Log( KMsg2 );
       
   276     RDebug::Print( KMsg2 );
       
   277 	
       
   278     return KErrNone;
       
   279     }
       
   280 
       
   281 // -----------------------------------------------------------------------------
       
   282 // CComposerPluginTest::ModifyObjectsL
       
   283 // -----------------------------------------------------------------------------
       
   284 //
       
   285 TInt CComposerPluginTest::ModifyObjectsL( CStifItemParser&  aItem  )
       
   286 	{   	
       
   287     _LIT( KMsg1, "Enter ModifyObjects" );
       
   288     iLog->Log( KMsg1 );
       
   289     RDebug::Print( KMsg1 );
       
   290 	
       
   291 	CMdENamespaceDef& defaultNamespace = iMdEClient->GetDefaultNamespaceDefL();
       
   292 	CMdEObjectDef& imageDef = defaultNamespace.GetObjectDefL( Image::KImageObject );
       
   293 	
       
   294 	// Mandatory parameters for any object.
       
   295 	CMdEPropertyDef& creationDef = imageDef.GetPropertyDefL( Object::KCreationDateProperty );
       
   296 	CMdEPropertyDef& modifiedDef = imageDef.GetPropertyDefL( Object::KLastModifiedDateProperty );
       
   297 	CMdEPropertyDef& sizeDef = imageDef.GetPropertyDefL( Object::KSizeProperty );
       
   298 	CMdEPropertyDef& itemTypeDef = imageDef.GetPropertyDefL( Object::KItemTypeProperty );	
       
   299 	
       
   300 	CMdEPropertyDef& descriptionPropertyDef = imageDef.GetPropertyDefL( MediaObject::KDescriptionProperty );
       
   301 	CMdEPropertyDef& widthDef = imageDef.GetPropertyDefL( MediaObject::KWidthProperty ); 
       
   302 	CMdEPropertyDef& heightDef = imageDef.GetPropertyDefL( MediaObject::KHeightProperty ); 
       
   303 	CMdEPropertyDef& commentDef = imageDef.GetPropertyDefL( MediaObject::KCommentProperty );
       
   304 	CMdEPropertyDef& lastModifiedDateDef = imageDef.GetPropertyDefL( Image::KDateTimeProperty );
       
   305 	CMdEPropertyDef& dateTimeDigitizedDef = imageDef.GetPropertyDefL( Image::KDateTimeDigitizedProperty );
       
   306 	CMdEPropertyDef& makeDef = imageDef.GetPropertyDefL( Image::KMakeProperty );
       
   307 	CMdEPropertyDef& modelDef = imageDef.GetPropertyDefL( Image::KModelProperty );
       
   308 	CMdEPropertyDef& artistDef = imageDef.GetPropertyDefL( MediaObject::KArtistProperty ); // Ei toimi
       
   309 	CMdEPropertyDef& orientationDef = imageDef.GetPropertyDefL( Image::KOrientationProperty );
       
   310 	CMdEPropertyDef& yCbCrPosDef = imageDef.GetPropertyDefL( Image::KYCbCrPositioningProperty );
       
   311 	CMdEPropertyDef& resolutionDef = imageDef.GetPropertyDefL( MediaObject::KResolutionUnitProperty );
       
   312 	CMdEPropertyDef& isoSpeedDef = imageDef.GetPropertyDefL( Image::KISOSpeedRatingsProperty );
       
   313 	CMdEPropertyDef& soundFileDef = imageDef.GetPropertyDefL( Image::KRelatedSoundFileProperty );
       
   314 	CMdEPropertyDef& exposureTimeDef = imageDef.GetPropertyDefL( Image::KExposureTimeProperty );
       
   315 	CMdEPropertyDef& apertureDef = imageDef.GetPropertyDefL(  Image::KApertureValueProperty );
       
   316 	CMdEPropertyDef& colourSpaceDef = imageDef.GetPropertyDefL( Image::KColourSpaceProperty );
       
   317 	CMdEPropertyDef& exposureBiasDef = imageDef.GetPropertyDefL( Image::KExposureBiasValueProperty );
       
   318 	CMdEPropertyDef& meteringDef = imageDef.GetPropertyDefL( Image::KMeteringModeProperty );
       
   319 	CMdEPropertyDef& exifVersionDef = imageDef.GetPropertyDefL( Image::KExifVersionProperty );
       
   320 	CMdEPropertyDef& flashPixVersionDef = imageDef.GetPropertyDefL( Image::KFlashPixVersionProperty );
       
   321 	CMdEPropertyDef& thumbXDef = imageDef.GetPropertyDefL( Image::KThumbXResolutionProperty );
       
   322 	CMdEPropertyDef& thumbYDef = imageDef.GetPropertyDefL( Image::KThumbYResolutionProperty );
       
   323 	CMdEPropertyDef& thumbResolutionUnitDef = imageDef.GetPropertyDefL( Image::KThumbResolutionUnitProperty );
       
   324 	CMdEPropertyDef& thumbCompressionDef = imageDef.GetPropertyDefL( Image::KThumbCompressionProperty );
       
   325 	CMdEPropertyDef& shutterSpeedDef = imageDef.GetPropertyDefL( Image::KShutterSpeedValueProperty );
       
   326 	CMdEPropertyDef& componentsDef = imageDef.GetPropertyDefL( Image::KComponentsConfigurationProperty );
       
   327 	CMdEPropertyDef& xResolutionDef = imageDef.GetPropertyDefL( Image::KXResolutionProperty );
       
   328 	CMdEPropertyDef& yResolutionDef = imageDef.GetPropertyDefL( Image::KYResolutionProperty );
       
   329 	CMdEPropertyDef& fNumberDef =  imageDef.GetPropertyDefL( Image::KFNumberProperty );
       
   330 	CMdEPropertyDef& focalLengthDef = imageDef.GetPropertyDefL( Image::KFocalLengthProperty );
       
   331 	CMdEPropertyDef& focalIn35Def = imageDef.GetPropertyDefL( Image::KFocalLengthIn35mmFilmProperty );
       
   332     
       
   333 	TBuf <100> msg;
       
   334 
       
   335 	TInt count( 0 );
       
   336 	
       
   337 	User::LeaveIfError( aItem.GetNextInt( count ) );
       
   338 	
       
   339 	if ( count == 1 )
       
   340 		{	
       
   341 		TItemId objectId(0);
       
   342 		TTime currTime;
       
   343 		currTime.HomeTime();
       
   344 		TPtrC inputFile;
       
   345 		    	
       
   346 		User::LeaveIfError( aItem.GetNextString( inputFile ));
       
   347 		
       
   348 		// create object
       
   349 		iMdEClient->RemoveObjectL(inputFile);
       
   350 		CMdEObject* object = iMdEClient->NewObjectLC(imageDef, inputFile);
       
   351 		
       
   352 		object->AddTimePropertyL(creationDef, currTime);
       
   353 		object->AddTimePropertyL(modifiedDef, currTime);
       
   354 		object->AddUint32PropertyL( sizeDef, 0 );
       
   355 		object->AddTextPropertyL( itemTypeDef, Image::KImageObject );
       
   356 		
       
   357 		objectId = iMdEClient->AddObjectL(*object);
       
   358 		
       
   359 		CleanupStack::PopAndDestroy( object );
       
   360 		object = NULL;
       
   361 		
       
   362 		// open object for modification
       
   363 		TRAPD( openError, object = iMdEClient->OpenObjectL(objectId) );
       
   364 			
       
   365 		if ( !object || openError != KErrNone )
       
   366 			{
       
   367 		    msg.Format(KOpenErr, openError);
       
   368 		    iLog->Log( msg );
       
   369 		    RDebug::Print(msg);
       
   370 		    
       
   371 		    User::LeaveIfError(openError);
       
   372 			}
       
   373 
       
   374 		CleanupStack::PushL( object );
       
   375 
       
   376    		CMdEProperty* property = NULL;
       
   377    		
       
   378    		
       
   379    		// Modified date
       
   380    		object->Property( lastModifiedDateDef, property );
       
   381    		
       
   382    		if ( property )
       
   383    			{
       
   384    			CMdETimeProperty* modTimeProperty = (CMdETimeProperty*)property;
       
   385    			
       
   386    			modTimeProperty->SetValueL( 1 );
       
   387    			}
       
   388    		else
       
   389    			{
       
   390    			object->AddTimePropertyL( lastModifiedDateDef, 1 );
       
   391    			}
       
   392    			
       
   393    		property = NULL;		
       
   394    		
       
   395    		// Date & time digitized
       
   396    		object->Property( dateTimeDigitizedDef, property );
       
   397    			
       
   398 		if ( property )
       
   399 			{
       
   400 			CMdETimeProperty* digiTimeProperty = (CMdETimeProperty*)property;
       
   401 			
       
   402 			digiTimeProperty->SetValueL( 9959267210000000 );
       
   403 			}
       
   404 		else
       
   405 			{
       
   406 			object->AddTimePropertyL( dateTimeDigitizedDef, 9959267210000000 );
       
   407 			}
       
   408    		
       
   409    		property = NULL;
       
   410    		
       
   411    		// Title
       
   412 		_LIT( KDesc, "Description" );
       
   413 		object->Property( descriptionPropertyDef, property );
       
   414 
       
   415 		if ( property )
       
   416 			{					
       
   417 			property->SetTextValueL( KDesc );
       
   418 			}
       
   419 		else
       
   420 			{
       
   421 			object->AddTextPropertyL( descriptionPropertyDef, KDesc );
       
   422 			}
       
   423   		
       
   424    		property = NULL;
       
   425    			
       
   426 		// Comment
       
   427         _LIT( KNoComment, "Comment" );
       
   428 		object->Property( commentDef, property );
       
   429 		
       
   430 		if ( property )
       
   431 			{					
       
   432 			property->SetTextValueL( KNoComment );
       
   433 			}
       
   434 		else
       
   435 			{
       
   436 			object->AddTextPropertyL( commentDef, KNoComment );
       
   437 			}
       
   438 		
       
   439 		property = NULL;
       
   440 		
       
   441 		// Maker
       
   442 		object->Property( makeDef, property );
       
   443 		
       
   444         _LIT( KOnkia, "Maker" );
       
   445 		if ( property )
       
   446 			{
       
   447 			property->SetTextValueL( KOnkia );
       
   448 			}
       
   449 		else
       
   450 			{
       
   451 			object->AddTextPropertyL( makeDef, KOnkia );
       
   452 			}
       
   453 			
       
   454 		property = NULL;
       
   455 			
       
   456 		// Model
       
   457 		object->Property( modelDef, property );
       
   458         _LIT( KModel, "Model" );
       
   459 		if ( property )
       
   460 			{					
       
   461 			property->SetTextValueL( KModel );
       
   462 			}
       
   463 		else
       
   464 			{
       
   465 			object->AddTextPropertyL( modelDef, KModel );
       
   466 			}
       
   467 			
       
   468 		property = NULL;
       
   469 			
       
   470 		// Width
       
   471 		object->Property( widthDef, property );
       
   472 		
       
   473 		if ( property )
       
   474 			{
       
   475 			property->SetUint16ValueL( 100 );
       
   476 			}
       
   477 		else
       
   478 			{
       
   479 			object->AddUint16PropertyL( widthDef, 100 );
       
   480 			}
       
   481 		
       
   482 		property = NULL;
       
   483 			
       
   484 		// Height
       
   485 		object->Property( heightDef, property );
       
   486 		
       
   487 		if ( property )
       
   488 			{
       
   489 			property->SetUint16ValueL( 100 );
       
   490 			}
       
   491 		else
       
   492 			{
       
   493 			object->AddUint16PropertyL( heightDef, 100 );
       
   494 			}
       
   495 			
       
   496 		property = NULL;
       
   497 			
       
   498 		// Orientation
       
   499 		object->Property( orientationDef, property );
       
   500 		
       
   501 		if ( property )
       
   502 			{
       
   503 			property->SetUint16ValueL( 8 );
       
   504 			}
       
   505 		else
       
   506 			{
       
   507 			object->AddUint16PropertyL( orientationDef, 8 );
       
   508 			}
       
   509 			
       
   510 		property = NULL;
       
   511 			
       
   512 		// YCbCr positioning
       
   513 		object->Property( yCbCrPosDef, property );
       
   514 		
       
   515 		if ( property )
       
   516 			{
       
   517 			property->SetUint16ValueL( 2 );
       
   518 			}
       
   519 		else
       
   520 			{
       
   521 			object->AddUint16PropertyL( yCbCrPosDef, 2 );
       
   522 			}
       
   523 			
       
   524 		property = NULL;
       
   525 			
       
   526 		// ISO speed
       
   527 		object->Property( isoSpeedDef, property );
       
   528 		
       
   529 		if ( property )
       
   530 			{
       
   531 			property->SetUint16ValueL( 1600 );
       
   532 			}
       
   533 		else
       
   534 			{
       
   535 			object->AddUint16PropertyL( isoSpeedDef, 1600 );
       
   536 			}
       
   537 			
       
   538 		property = NULL;
       
   539 		
       
   540 		// Related soundfile
       
   541 		_LIT(KWavName, "Wav.wav");
       
   542 		object->Property( soundFileDef, property);
       
   543 		
       
   544 		if(property)
       
   545 			{					
       
   546 			property->SetTextValueL( KWavName );
       
   547 			}
       
   548 		else
       
   549 			{
       
   550 			object->AddTextPropertyL( soundFileDef, KWavName );
       
   551 			}
       
   552 		
       
   553 		property = NULL;
       
   554 		
       
   555 		// Exposure time
       
   556 		object->Property( exposureTimeDef, property);
       
   557 		
       
   558 		if(property)
       
   559 			{					
       
   560 			property->SetReal32ValueL( 99.1f );
       
   561 			}
       
   562 		else
       
   563 			{
       
   564 			object->AddReal32PropertyL( exposureTimeDef, 99.1f );
       
   565 			}
       
   566 			
       
   567 		property = NULL;
       
   568 		
       
   569 		// Aperture
       
   570 		object->Property( apertureDef, property);
       
   571 		
       
   572 		if(property)
       
   573 			{					
       
   574 			property->SetReal32ValueL( 5.0f );
       
   575 			}
       
   576 		else
       
   577 			{
       
   578 			object->AddReal32PropertyL( apertureDef, 5.0f );
       
   579 			}
       
   580 			
       
   581 		property = NULL;
       
   582 			
       
   583 		// Colour space
       
   584 		object->Property( colourSpaceDef, property);
       
   585 		
       
   586 		if (property)
       
   587 			{
       
   588 			property->SetUint16ValueL( 65535 );
       
   589 			}
       
   590 		else
       
   591 			{
       
   592 			object->AddUint16PropertyL( colourSpaceDef, 65535 );
       
   593 			}
       
   594 			
       
   595 		property = NULL;
       
   596 			
       
   597 		// Exposure bias
       
   598 		object->Property( exposureBiasDef, property);
       
   599 		
       
   600 		if(property)
       
   601 			{					
       
   602 			property->SetReal32ValueL( 0.0f );
       
   603 			}
       
   604 		else
       
   605 			{
       
   606 			object->AddReal32PropertyL( exposureBiasDef, 0.0f );
       
   607 			}
       
   608 			
       
   609 		property = NULL;
       
   610 			
       
   611 		// Metering mode
       
   612 		object->Property( meteringDef, property);
       
   613 		
       
   614 		if (property)
       
   615 			{
       
   616 			property->SetUint16ValueL( 4 );
       
   617 			}
       
   618 		else
       
   619 			{
       
   620 			object->AddUint16PropertyL( meteringDef, 4 );
       
   621 			}
       
   622 			
       
   623 		property = NULL;
       
   624 		
       
   625 		// Thumb X
       
   626 		object->Property( thumbXDef, property);
       
   627 		
       
   628 		if(property)
       
   629 			{					
       
   630 			property->SetUint32ValueL( 64 );
       
   631 			}
       
   632 		else
       
   633 			{
       
   634 			object->AddUint32PropertyL( thumbXDef, 64 );
       
   635 			}
       
   636 			
       
   637 		property = NULL;
       
   638 		
       
   639 		// Thumb Y
       
   640 		object->Property( thumbYDef, property);
       
   641 		
       
   642 		if(property)
       
   643 			{					
       
   644 			property->SetUint32ValueL( 64 );
       
   645 			}
       
   646 		else
       
   647 			{
       
   648 			object->AddUint32PropertyL( thumbYDef, 64 );
       
   649 			}
       
   650 			
       
   651 		property = NULL;
       
   652 			
       
   653 		// Thumbnail resolution unit
       
   654 		object->Property( thumbResolutionUnitDef, property );
       
   655 		
       
   656 		if ( property )
       
   657 			{
       
   658 			property->SetUint16ValueL( 2 );
       
   659 			}
       
   660 		else
       
   661 			{
       
   662 			object->AddUint16PropertyL( thumbResolutionUnitDef, 2 );
       
   663 			}
       
   664 			
       
   665 		property = NULL;
       
   666 			
       
   667 		// Thumbnail compression
       
   668 		object->Property( thumbCompressionDef, property );
       
   669 		
       
   670 		if ( property )
       
   671 			{
       
   672 			property->SetUint16ValueL( 6 );
       
   673 			}
       
   674 		else
       
   675 			{
       
   676 			object->AddUint16PropertyL( thumbCompressionDef, 6 );
       
   677 			}
       
   678 			
       
   679 		property = NULL;
       
   680 			
       
   681 		// Shutter speed
       
   682 		object->Property( shutterSpeedDef, property );
       
   683 		
       
   684 		if ( property )
       
   685 			{					
       
   686 			property->SetReal32ValueL( 9.0f );
       
   687 			}
       
   688 		else
       
   689 			{
       
   690 			object->AddReal32PropertyL( shutterSpeedDef, 9.0f );
       
   691 			}
       
   692 			
       
   693 		property = NULL;
       
   694 			
       
   695 		// Components configuration
       
   696 		object->Property( componentsDef, property );
       
   697 		
       
   698 		if ( property )
       
   699 			{					
       
   700 			property->SetUint32ValueL( 197121 );
       
   701 			}
       
   702 		else
       
   703 			{
       
   704 			object->AddUint32PropertyL( componentsDef, 197121 );
       
   705 			}
       
   706 			
       
   707 		property = NULL;
       
   708 			
       
   709 		// X resolution
       
   710 		object->Property( xResolutionDef, property );
       
   711 		
       
   712 		if ( property )
       
   713 			{					
       
   714 			property->SetReal32ValueL( 300.0f );
       
   715 			}
       
   716 		else
       
   717 			{
       
   718 			object->AddReal32PropertyL( xResolutionDef, 300.0f );
       
   719 			}
       
   720 			
       
   721 		property = NULL;
       
   722 			
       
   723 		// Y resolution
       
   724 		object->Property( yResolutionDef, property );
       
   725 		
       
   726 		if ( property )
       
   727 			{					
       
   728 			property->SetReal32ValueL( 300.0f );
       
   729 			}
       
   730 		else
       
   731 			{
       
   732 			object->AddReal32PropertyL( yResolutionDef, 300.0f );
       
   733 			}
       
   734 			
       
   735 		property = NULL;
       
   736 		
       
   737 		// F number
       
   738 		object->Property( fNumberDef, property );
       
   739 		
       
   740 		if ( property )
       
   741 			{					
       
   742 			property->SetReal32ValueL( 2.8f );
       
   743 			}
       
   744 		else
       
   745 			{
       
   746 			object->AddReal32PropertyL( fNumberDef, 2.8f );
       
   747 			}
       
   748 			
       
   749 		property = NULL;
       
   750 			
       
   751 		// Focal length
       
   752 		object->Property( focalLengthDef, property );
       
   753 		
       
   754 		if ( property )
       
   755 			{					
       
   756 			property->SetReal32ValueL( 9.0f );
       
   757 			}
       
   758 		else
       
   759 			{
       
   760 			object->AddReal32PropertyL( focalLengthDef, 9.0f );
       
   761 			}
       
   762 			
       
   763 		property = NULL;
       
   764 		
       
   765 		// Focal length in 35 mm film
       
   766 		object->Property( focalIn35Def, property );
       
   767 		
       
   768 		if ( property )
       
   769 			{
       
   770 			property->SetUint16ValueL( 120 );
       
   771 			}
       
   772 		else
       
   773 			{
       
   774 			object->AddUint16PropertyL( focalIn35Def, 120 );
       
   775 			}
       
   776 						
       
   777 		// Commit object
       
   778 		TRAPD( commitError, iMdEClient->CommitObjectL(*object) );
       
   779 		if ( commitError != KErrNone )
       
   780 			{		
       
   781 		    msg.Format(KCommErr, commitError);
       
   782 		    iLog->Log( msg );
       
   783 		    RDebug::Print(msg);
       
   784 		    
       
   785 		    User::LeaveIfError(commitError);
       
   786 			}
       
   787 		
       
   788 		iLog->Log( KCommit );
       
   789 		RDebug::Print(KCommit);
       
   790 		
       
   791 		CleanupStack::PopAndDestroy( object );
       
   792 		}
       
   793 	
       
   794 	// modify more than one object
       
   795 	else if ( count > 1 )
       
   796 		{
       
   797 		RPointerArray<CMdEObject> objectArray;
       
   798 		CleanupClosePushL( objectArray );
       
   799 
       
   800 		CMdEObject* object = NULL;
       
   801 		TItemId objectId(0);
       
   802 		TTime currTime;
       
   803 	    TBuf <100> uri;
       
   804 		
       
   805 		for ( TInt i = 0; i < count; ++i )
       
   806 			{			
       
   807 		    uri.Format(KUri, i+1);
       
   808 			
       
   809 			// create object
       
   810 		    iMdEClient->RemoveObjectL(uri);
       
   811 			object = iMdEClient->NewObjectLC(imageDef, uri);
       
   812 			
       
   813 			currTime.HomeTime();
       
   814 			object->AddTimePropertyL(creationDef, currTime);
       
   815 			object->AddTimePropertyL(modifiedDef, currTime);
       
   816 			object->AddUint32PropertyL( sizeDef, 0 );
       
   817 			object->AddTextPropertyL( itemTypeDef, Image::KImageObject );
       
   818 			
       
   819 			objectId = iMdEClient->AddObjectL(*object);
       
   820 			
       
   821 			CleanupStack::PopAndDestroy(object);
       
   822 			object = NULL;
       
   823 			
       
   824 			// open for modification
       
   825 			TRAPD( openError, object = iMdEClient->OpenObjectL(objectId) )
       
   826 			
       
   827 			if ( !object || openError != KErrNone )
       
   828 				{
       
   829 				
       
   830 				if (openError != KErrNone)
       
   831 					{
       
   832 				    msg.Format(KOpenErr, openError);
       
   833 				    iLog->Log( msg );
       
   834 				    RDebug::Print(msg);
       
   835 				    
       
   836 				    User::LeaveIfError(openError);
       
   837 					}
       
   838 				else 
       
   839 					{
       
   840 				    iLog->Log( KNull );
       
   841 				    RDebug::Print(KNull);
       
   842 					}
       
   843 
       
   844 			    continue;
       
   845 				}
       
   846 
       
   847 	   		CMdEProperty* property = NULL;
       
   848 	   		
       
   849 	   		// Description
       
   850 	   		_LIT( KDesc, "Description" );
       
   851 			object->Property( descriptionPropertyDef, property );
       
   852 			
       
   853 			if ( property )
       
   854 				{					
       
   855 				property->SetTextValueL( KDesc );
       
   856 				}
       
   857 			else
       
   858 				{
       
   859 				object->AddTextPropertyL( descriptionPropertyDef, KDesc );
       
   860 				}
       
   861 			
       
   862 			property = NULL;
       
   863 			
       
   864 			// Width
       
   865 			object->Property( widthDef, property );
       
   866 			
       
   867 			if ( property )
       
   868 				{
       
   869 				property->SetUint16ValueL( 100 );
       
   870 				}
       
   871 			else
       
   872 				{
       
   873 				object->AddUint16PropertyL( widthDef, 100 );
       
   874 				}
       
   875 			
       
   876 			property = NULL;
       
   877 				
       
   878 			// Height
       
   879 			object->Property( heightDef, property );
       
   880 			
       
   881 			if ( property )
       
   882 				{
       
   883 				property->SetUint16ValueL( 100 );
       
   884 				}
       
   885 			else
       
   886 				{
       
   887 				object->AddUint16PropertyL( heightDef, 100 );
       
   888 				}
       
   889 			
       
   890 			property = NULL;
       
   891 			
       
   892 			// Maker
       
   893 			object->Property( makeDef, property );
       
   894 			
       
   895 	        _LIT( KOnkia, "Maker" );
       
   896 			if ( property )
       
   897 				{
       
   898 				property->SetTextValueL( KOnkia );
       
   899 				}
       
   900 			else
       
   901 				{
       
   902 				object->AddTextPropertyL( makeDef, KOnkia );
       
   903 				}
       
   904 				
       
   905 			property = NULL;
       
   906 				
       
   907 			// Model
       
   908 			object->Property( modelDef, property );
       
   909 	        _LIT( KModel, "Model" );
       
   910 			if ( property )
       
   911 				{					
       
   912 				property->SetTextValueL( KModel );
       
   913 				}
       
   914 			else
       
   915 				{
       
   916 				object->AddTextPropertyL( modelDef, KModel );
       
   917 				}
       
   918 
       
   919 			objectArray.Append( object );
       
   920 			}
       
   921 
       
   922 		TRAPD( commitError, iMdEClient->CommitObjectsL(objectArray) );
       
   923 		if ( commitError != KErrNone )
       
   924 			{			
       
   925 		    msg.Format(KCommErr, commitError);
       
   926 		    iLog->Log( msg );
       
   927 		    RDebug::Print(msg);
       
   928 		    
       
   929 		    User::LeaveIfError(commitError);
       
   930 			}
       
   931 			
       
   932 		iLog->Log( KCommit );
       
   933 		RDebug::Print(KCommit);
       
   934 		
       
   935 		objectArray.ResetAndDestroy();
       
   936 		CleanupStack::PopAndDestroy( &objectArray );
       
   937 		}
       
   938 	
       
   939     _LIT( KMsg2, "Exit ModifyObjects" );
       
   940     iLog->Log( KMsg2 );
       
   941     RDebug::Print( KMsg2 );
       
   942 	
       
   943     return KErrNone;
       
   944     }
       
   945 
       
   946 // -----------------------------------------------------------------------------
       
   947 // CComposerPluginTest::DeleteObject
       
   948 // -----------------------------------------------------------------------------
       
   949 //
       
   950 TInt CComposerPluginTest::DeleteObjectL( CStifItemParser& aItem )
       
   951 	{  
       
   952     _LIT( KMsg1, "Enter DeleteObject" );
       
   953     iLog->Log( KMsg1 );
       
   954     RDebug::Print( KMsg1 );
       
   955 	
       
   956 	TPtrC inputFile;
       
   957 	User::LeaveIfError( aItem.GetNextString( inputFile ));
       
   958 	
       
   959 	iMdEClient->RemoveObjectL(inputFile);
       
   960 	
       
   961     _LIT( KMsg2, "Exit DeleteObject" );
       
   962     iLog->Log( KMsg2 );
       
   963     RDebug::Print( KMsg2 );
       
   964 	
       
   965     return KErrNone;
       
   966 	}
       
   967 
       
   968 // -----------------------------------------------------------------------------
       
   969 // CComposerPluginTest::DeleteObjects
       
   970 // -----------------------------------------------------------------------------
       
   971 //
       
   972 TInt CComposerPluginTest::DeleteObjectsL( CStifItemParser& aItem )
       
   973 	{  
       
   974 	TInt count(0);
       
   975     TBuf <100> uri;
       
   976 	
       
   977 	User::LeaveIfError( aItem.GetNextInt( count ) );
       
   978 	
       
   979 	for ( TInt i = 0; i < count; ++i )
       
   980 		{			
       
   981 	    uri.Format(KUri, i+1);
       
   982 	    
       
   983 	    iMdEClient->RemoveObjectL(uri);
       
   984 		}
       
   985 	
       
   986     _LIT( KMsg, "Exit    DeleteObjects" );
       
   987     iLog->Log( KMsg );
       
   988     RDebug::Print(KMsg);
       
   989 	
       
   990     return KErrNone;
       
   991 	}
       
   992 
       
   993 // -----------------------------------------------------------------------------
       
   994 // CComposerPluginTest::WaitComposingComplete
       
   995 // -----------------------------------------------------------------------------
       
   996 //
       
   997 TInt CComposerPluginTest::WaitComposingComplete( CStifItemParser& aItem )
       
   998 	{    
       
   999     _LIT( KMsg1, "Enter WaitComposingComplete" );
       
  1000     iLog->Log( KMsg1 );
       
  1001     RDebug::Print( KMsg1 );
       
  1002     
       
  1003 	TBool complete = ETrue;
       
  1004 	TBool waitingForComposingToEnd = ETrue;
       
  1005 	
       
  1006 	while( waitingForComposingToEnd )
       
  1007 		{
       
  1008 		complete = ETrue;
       
  1009 		
       
  1010 		for(TInt i = 0; i < iPluginArray.Count(); ++i)
       
  1011 			{
       
  1012 			if( iPluginArray[i]->IsComposingComplete() == EFalse )
       
  1013 				{
       
  1014 				complete = EFalse;
       
  1015 				}
       
  1016 			}
       
  1017 	
       
  1018 		if( complete )
       
  1019 			{
       
  1020 			waitingForComposingToEnd = EFalse;
       
  1021 			}
       
  1022 		else 
       
  1023 			{
       
  1024 			ActiveWait( aItem );
       
  1025 			}
       
  1026 		}
       
  1027 	
       
  1028     _LIT( KMsg2, "Exit WaitComposingComplete" );
       
  1029     iLog->Log( KMsg2 );
       
  1030     RDebug::Print( KMsg2 );
       
  1031 	
       
  1032     return KErrNone;
       
  1033     }
       
  1034 
       
  1035 //  [End of File] - Do not remove