mds_plat/metadata_engine_api/tsrc/src/MdETestScripterEditCommands.cpp
changeset 58 fe894bb075c2
parent 51 87e65c44ff3a
child 60 79f826a55db2
equal deleted inserted replaced
51:87e65c44ff3a 58:fe894bb075c2
     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:  ?Description
       
    15 *
       
    16 */
       
    17 
       
    18 // [INCLUDE FILES] - do not remove
       
    19 #include <mdeobject.h>
       
    20 #include <mdeconstants.h>
       
    21 #include <StifParser.h>
       
    22 #include <StifTestInterface.h>
       
    23 #include <StifTestEventInterface.h>
       
    24 #include "MdETestScripter.h"
       
    25 #include "MdETestScripterAO.h"
       
    26 
       
    27 // -----------------------------------------------------------------------------
       
    28 // CMdETestScripter::BelongsToSessionL
       
    29 // -----------------------------------------------------------------------------
       
    30 //
       
    31 TInt CMdETestScripter::BelongsToSessionL( CStifItemParser& aItem )
       
    32     {
       
    33     TInt mode;
       
    34     TInt state;
       
    35 
       
    36     User::LeaveIfError( aItem.GetNextInt( mode ));
       
    37     CMdEInstanceItem* instanceItem = GetInstanceItemByArrayIndexL( mode, aItem );
       
    38     User::LeaveIfError( aItem.GetNextInt( state ));
       
    39 
       
    40     TL( instanceItem->BelongsToSession() == (TBool)state );
       
    41 
       
    42     return KErrNone;
       
    43     }
       
    44 
       
    45 // -----------------------------------------------------------------------------
       
    46 // CMdETestScripter::SessionL
       
    47 // -----------------------------------------------------------------------------
       
    48 //
       
    49 TInt CMdETestScripter::SessionL( CStifItemParser& aItem )
       
    50     {
       
    51     TInt mode;
       
    52 
       
    53     User::LeaveIfError( aItem.GetNextInt( mode ));
       
    54     CMdEInstanceItem* instanceItem = GetInstanceItemByArrayIndexL( mode, aItem );
       
    55     TL( iMdeSession == &instanceItem->Session());
       
    56 
       
    57     return KErrNone;
       
    58     }
       
    59 
       
    60 // -----------------------------------------------------------------------------
       
    61 // CMdETestScripter::InDatabaseL
       
    62 // -----------------------------------------------------------------------------
       
    63 //
       
    64 TInt CMdETestScripter::InDatabaseL( CStifItemParser& aItem )
       
    65     {
       
    66     TInt mode;
       
    67     TInt state;
       
    68 
       
    69     User::LeaveIfError( aItem.GetNextInt( mode ));
       
    70     CMdEInstanceItem* instanceItem = GetInstanceItemByArrayIndexL( mode, aItem );
       
    71     User::LeaveIfError( aItem.GetNextInt( state ));
       
    72     TL( instanceItem->InDatabase() == (TBool)state );
       
    73 
       
    74     return KErrNone;
       
    75     }
       
    76 
       
    77 // -----------------------------------------------------------------------------
       
    78 // CMdETestScripter::AddItemsL
       
    79 // -----------------------------------------------------------------------------
       
    80 //
       
    81 TInt CMdETestScripter::AddItemsL( CStifItemParser& aItem )
       
    82     {
       
    83     TInt mode1, err = KErrNone;
       
    84     User::LeaveIfError( aItem.GetNextInt( mode1 ));
       
    85 
       
    86     if ( mode1 == KSync )
       
    87         {
       
    88         RPointerArray<CMdEInstanceItem> itemArray;
       
    89         FormInstanceItemArrayL( aItem, itemArray );
       
    90         err = iMdeSession->AddItemsL( itemArray );
       
    91         }
       
    92     else if ( mode1 == KAsync )
       
    93         {
       
    94         FormInstanceItemArrayL( aItem, iItemArray );
       
    95         TEventIf event( TEventIf::ESetEvent, TName( KMdEItemsAsyncAdd ) );
       
    96         iAsyncHandler->Start( this, event );
       
    97         iMdEDataBuf.Close();// make sure the last async request buffer cleaned before using again.
       
    98         iMdeSession->AddItemsAsyncL( iItemArray, iAsyncHandler->iStatus, iMdEDataBuf );
       
    99         }
       
   100     else
       
   101         {
       
   102         User::Leave( KErrArgument );
       
   103         }
       
   104 
       
   105     return err;
       
   106     }
       
   107 
       
   108 // -----------------------------------------------------------------------------
       
   109 // CMdETestScripter::UpdateItemsL
       
   110 // -----------------------------------------------------------------------------
       
   111 //
       
   112 TInt CMdETestScripter::UpdateItemsL( CStifItemParser& aItem )
       
   113     {
       
   114     TInt mode1, err = KErrNone;
       
   115     User::LeaveIfError( aItem.GetNextInt( mode1 ));
       
   116 
       
   117     if ( mode1 == KSync )
       
   118         {
       
   119         RPointerArray<CMdEInstanceItem> itemArray;
       
   120         FormInstanceItemArrayL( aItem, itemArray );
       
   121         err = iMdeSession->UpdateItemsL( itemArray );
       
   122         }
       
   123     else if ( mode1 == KAsync )
       
   124         {
       
   125         FormInstanceItemArrayL( aItem, iItemArray );
       
   126         TEventIf event( TEventIf::ESetEvent, TName( KMdEItemsAsyncUpdate ) );
       
   127         iAsyncHandler->Start( this, event );
       
   128         iMdEDataBuf.Close();// make sure the last async request buffer cleaned before using again.
       
   129         iMdeSession->UpdateItemsAsyncL( iItemArray, iAsyncHandler->iStatus, iMdEDataBuf );
       
   130         }
       
   131     else
       
   132         {
       
   133         User::Leave( KErrArgument );
       
   134         }
       
   135 
       
   136     return err;
       
   137     }
       
   138 
       
   139 // -----------------------------------------------------------------------------
       
   140 // CMdETestScripter::AddRelationDefL
       
   141 // -----------------------------------------------------------------------------
       
   142 //
       
   143 TInt CMdETestScripter::AddRelationDefL( CStifItemParser& aItem )
       
   144     {
       
   145     TPtrC relationString;
       
   146 
       
   147     CMdENamespaceDef* namespaceDef = SanitizeArrayIndexL( iNamespaceDefArray, *iNamespaceDefNameArray, aItem );
       
   148     User::LeaveIfError( aItem.GetNextString( relationString ));
       
   149     TRAPD( err, iMdeSession->AddRelationDefL( *namespaceDef, relationString ) );
       
   150     if( KErrAlreadyExists == err )
       
   151         {
       
   152         TEventIf event( TEventIf::ESetEvent, TName( KMdESchemaModified ) );
       
   153         TestModuleIf().Event( event );
       
   154         }
       
   155     return err;
       
   156     }
       
   157 
       
   158 // -----------------------------------------------------------------------------
       
   159 // CMdETestScripter::AddEventDefL
       
   160 // -----------------------------------------------------------------------------
       
   161 //
       
   162 TInt CMdETestScripter::AddEventDefL( CStifItemParser& aItem )
       
   163     {
       
   164     TPtrC eventString;
       
   165 
       
   166     CMdENamespaceDef* namespaceDef = SanitizeArrayIndexL( iNamespaceDefArray, *iNamespaceDefNameArray, aItem );
       
   167     User::LeaveIfError( aItem.GetNextString( eventString ));
       
   168     TRAPD( err, iMdeSession->AddEventDefL( *namespaceDef, eventString ) );
       
   169     if( KErrAlreadyExists == err )
       
   170         {
       
   171         TEventIf event( TEventIf::ESetEvent, TName( KMdESchemaModified ) );
       
   172         TestModuleIf().Event( event );
       
   173        	}
       
   174     return err;
       
   175     }
       
   176 
       
   177 // -----------------------------------------------------------------------------
       
   178 // CMdETestScripter::PropertyDefCountL
       
   179 // -----------------------------------------------------------------------------
       
   180 //
       
   181 TInt CMdETestScripter::PropertyDefCountL( CStifItemParser& aItem )
       
   182     {
       
   183     TInt count;
       
   184 
       
   185     CMdEObjectDef* objectDef = SanitizeArrayIndexL( iObjectDefArray, *iObjectDefNameArray, aItem);
       
   186     User::LeaveIfError( aItem.GetNextInt( count ));
       
   187     TL( objectDef->PropertyDefCount() == count );
       
   188 
       
   189     return KErrNone;
       
   190     }
       
   191 
       
   192 // -----------------------------------------------------------------------------
       
   193 // CMdETestScripter::PropertyDefL
       
   194 // -----------------------------------------------------------------------------
       
   195 //
       
   196 TInt CMdETestScripter::PropertyDefL( CStifItemParser& aItem )
       
   197     {
       
   198     TInt index;
       
   199 
       
   200     TPtrC name;
       
   201     User::LeaveIfError( aItem.GetNextString( name ));   
       
   202 
       
   203     CMdENamespaceDef* space = SanitizeArrayIndexL( iNamespaceDefArray, *iNamespaceDefNameArray, aItem);
       
   204     CMdEObjectDef* objectDef = SanitizeArrayIndexL( iObjectDefArray, *iObjectDefNameArray, aItem);
       
   205     User::LeaveIfError( aItem.GetNextInt( index ));
       
   206     CMdEPropertyDef& propertyDef = objectDef->PropertyDefL( index );
       
   207     TL( &propertyDef );
       
   208     iPropertyDefArray.Append( &propertyDef );
       
   209     AppendNameL( iPropertyDefNameArray, name );
       
   210 
       
   211     return KErrNone;
       
   212     }
       
   213 
       
   214 // -----------------------------------------------------------------------------
       
   215 // CMdETestScripter::GetPropertyDefL
       
   216 // -----------------------------------------------------------------------------
       
   217 //
       
   218 TInt CMdETestScripter::GetPropertyDefL( CStifItemParser& aItem )
       
   219     {
       
   220     TPtrC propertyString;
       
   221     
       
   222     TPtrC name;
       
   223     User::LeaveIfError( aItem.GetNextString( name ));   
       
   224 
       
   225     CMdEObjectDef* objectDef = SanitizeArrayIndexL( iObjectDefArray, *iObjectDefNameArray, aItem);
       
   226     User::LeaveIfError( aItem.GetNextString( propertyString ));
       
   227     CMdEPropertyDef& propertyDef = objectDef->GetPropertyDefL( propertyString );
       
   228     iPropertyDefArray.Append( &propertyDef );
       
   229     AppendNameL( iPropertyDefNameArray, name );
       
   230 
       
   231     return KErrNone;
       
   232     }
       
   233 
       
   234 // -----------------------------------------------------------------------------
       
   235 // CMdETestScripter::CompareL
       
   236 // -----------------------------------------------------------------------------
       
   237 //
       
   238 TInt CMdETestScripter::CompareL( CStifItemParser& aItem )
       
   239     {
       
   240     TInt mode;
       
   241 
       
   242     TInt expected;
       
   243 
       
   244     User::LeaveIfError( aItem.GetNextInt( mode ));
       
   245     TInt result( -1 );
       
   246 
       
   247     if ( mode == EObjectDef )
       
   248         {
       
   249         CMdEObjectDef* item1 = SanitizeArrayIndexL( iObjectDefArray, *iObjectDefNameArray, aItem );
       
   250         CMdEObjectDef* item2 = SanitizeArrayIndexL( iObjectDefArray, *iObjectDefNameArray, aItem );
       
   251         result = item1->Compare( *item2 );
       
   252         }
       
   253     else if ( mode == ERelationDef )
       
   254         {
       
   255         CMdERelationDef* item1 = SanitizeArrayIndexL( iRelationDefArray, *iRelationDefNameArray, aItem );
       
   256         CMdERelationDef* item2 = SanitizeArrayIndexL( iRelationDefArray, *iRelationDefNameArray, aItem );
       
   257         result = item1->Compare( *item2 );
       
   258         }
       
   259     else if ( mode == EEventDef )
       
   260         {
       
   261         CMdEEventDef* item1 = SanitizeArrayIndexL( iEventDefArray, *iEventDefNameArray, aItem );
       
   262         CMdEEventDef* item2 = SanitizeArrayIndexL( iEventDefArray, *iEventDefNameArray, aItem );
       
   263         result = item1->Compare( *item2 );
       
   264         }
       
   265     else if ( mode == EPropertyDef )
       
   266         {
       
   267         CMdEPropertyDef* item1 = SanitizeArrayIndexL( iPropertyDefArray, *iPropertyDefNameArray, aItem );
       
   268         CMdEPropertyDef* item2 = SanitizeArrayIndexL( iPropertyDefArray, *iPropertyDefNameArray, aItem );
       
   269         result = item1->Compare( *item2 );
       
   270         }
       
   271     else if ( mode == ENamespaceDef )
       
   272         {
       
   273         CMdENamespaceDef* item1 = SanitizeArrayIndexL( iNamespaceDefArray, *iNamespaceDefNameArray, aItem );
       
   274         CMdENamespaceDef* item2 = SanitizeArrayIndexL( iNamespaceDefArray, *iNamespaceDefNameArray, aItem );
       
   275         result = item1->Compare( *item2 );
       
   276         }
       
   277     else
       
   278         {
       
   279         User::Leave( KErrArgument );
       
   280         }
       
   281         
       
   282     User::LeaveIfError( aItem.GetNextInt( expected ));
       
   283     TL( result == expected );
       
   284 
       
   285     return KErrNone;
       
   286     }
       
   287 
       
   288 // -----------------------------------------------------------------------------
       
   289 // CMdETestScripter::ReadOnlyL
       
   290 // -----------------------------------------------------------------------------
       
   291 //
       
   292 TInt CMdETestScripter::ReadOnlyL( CStifItemParser& aItem )
       
   293     {
       
   294     TInt mode;
       
   295     TBool state;
       
   296 
       
   297     User::LeaveIfError( aItem.GetNextInt( mode ));
       
   298 
       
   299     if ( mode == EPropertyDef )
       
   300         {
       
   301         CMdEPropertyDef* propertyDef = SanitizeArrayIndexL( iPropertyDefArray, *iPropertyDefNameArray, aItem );
       
   302         User::LeaveIfError( aItem.GetNextInt( state ));
       
   303         TL( propertyDef->ReadOnly() == (TBool)state );
       
   304         }
       
   305     else if ( mode == ENamespaceDef )
       
   306         {
       
   307         CMdENamespaceDef* namespaceDef = SanitizeArrayIndexL( iNamespaceDefArray, *iNamespaceDefNameArray, aItem );
       
   308         User::LeaveIfError( aItem.GetNextInt( state ));
       
   309         TL( namespaceDef->ReadOnly() == state );
       
   310         }
       
   311 
       
   312     return KErrNone;
       
   313     }
       
   314 
       
   315 // -----------------------------------------------------------------------------
       
   316 // CMdETestScripter::MandatoryL
       
   317 // -----------------------------------------------------------------------------
       
   318 //
       
   319 TInt CMdETestScripter::MandatoryL( CStifItemParser& aItem )
       
   320     {
       
   321     TBool state;
       
   322 
       
   323     CMdEPropertyDef* propertyDef = SanitizeArrayIndexL( iPropertyDefArray, *iPropertyDefNameArray, aItem );
       
   324     User::LeaveIfError( aItem.GetNextInt( state ));
       
   325     TL( propertyDef->Mandatory() == (TBool)state );
       
   326 
       
   327     return KErrNone;
       
   328     }    
       
   329 
       
   330 // -----------------------------------------------------------------------------
       
   331 // CMdETestScripter::MinInt32ValueL
       
   332 // -----------------------------------------------------------------------------
       
   333 //
       
   334 TInt CMdETestScripter::MinInt32ValueL( CStifItemParser& aItem )
       
   335     {
       
   336     TPtrC value;
       
   337 
       
   338     CMdEPropertyDef* propertyDef = SanitizeArrayIndexL( iPropertyDefArray, *iPropertyDefNameArray, aItem );
       
   339     User::LeaveIfError( aItem.GetNextString( value ));
       
   340     TLex lex( value );
       
   341     TInt32 valueU;
       
   342     lex.BoundedVal( valueU, 0x7FFFFFFF );
       
   343     TL( propertyDef->MinInt32ValueL() == valueU );
       
   344 
       
   345     return KErrNone;
       
   346     }
       
   347 
       
   348 // -----------------------------------------------------------------------------
       
   349 // CMdETestScripter::MaxInt32ValueL
       
   350 // -----------------------------------------------------------------------------
       
   351 //
       
   352 TInt CMdETestScripter::MaxInt32ValueL( CStifItemParser& aItem )
       
   353     {
       
   354     TPtrC value;
       
   355 
       
   356     CMdEPropertyDef* propertyDef = SanitizeArrayIndexL( iPropertyDefArray, *iPropertyDefNameArray, aItem );
       
   357     User::LeaveIfError( aItem.GetNextString( value ));
       
   358     TLex lex( value );
       
   359     TInt32 valueU;
       
   360     lex.BoundedVal( valueU, 0x7FFFFFFF );
       
   361     TL( propertyDef->MaxInt32ValueL() == valueU );
       
   362 
       
   363     return KErrNone;
       
   364     }
       
   365 
       
   366 // -----------------------------------------------------------------------------
       
   367 // CMdETestScripter::MinUint32ValueL
       
   368 // -----------------------------------------------------------------------------
       
   369 //
       
   370 TInt CMdETestScripter::MinUint32ValueL( CStifItemParser& aItem )
       
   371     {
       
   372     TPtrC value;
       
   373 
       
   374     CMdEPropertyDef* propertyDef = SanitizeArrayIndexL( iPropertyDefArray, *iPropertyDefNameArray, aItem );
       
   375     User::LeaveIfError( aItem.GetNextString( value ));
       
   376     TLex lex( value );
       
   377     TUint32 valueU;
       
   378     lex.BoundedVal( valueU, EDecimal, 0xFFFFFFFF );
       
   379     TL( propertyDef->MinUint32ValueL() == valueU );
       
   380 
       
   381     return KErrNone;
       
   382     }
       
   383 
       
   384 // -----------------------------------------------------------------------------
       
   385 // CMdETestScripter::MaxUint32ValueL
       
   386 // -----------------------------------------------------------------------------
       
   387 //
       
   388 TInt CMdETestScripter::MaxUint32ValueL( CStifItemParser& aItem )
       
   389     {
       
   390     TPtrC value;
       
   391 
       
   392     CMdEPropertyDef* propertyDef = SanitizeArrayIndexL( iPropertyDefArray, *iPropertyDefNameArray, aItem );
       
   393     User::LeaveIfError( aItem.GetNextString( value ));
       
   394     TLex lex( value );
       
   395     TUint32 valueU;
       
   396     lex.BoundedVal( valueU, EDecimal, 0xFFFFFFFF );
       
   397     TL( propertyDef->MaxUint32ValueL() == valueU );
       
   398 
       
   399     return KErrNone;
       
   400     }
       
   401 
       
   402 // -----------------------------------------------------------------------------
       
   403 // CMdETestScripter::MinInt64ValueL
       
   404 // -----------------------------------------------------------------------------
       
   405 //
       
   406 TInt CMdETestScripter::MinInt64ValueL( CStifItemParser& aItem )
       
   407     {
       
   408     TPtrC value;
       
   409 
       
   410     CMdEPropertyDef* propertyDef = SanitizeArrayIndexL( iPropertyDefArray, *iPropertyDefNameArray, aItem );
       
   411     User::LeaveIfError( aItem.GetNextString( value ));
       
   412     TLex lex( value );
       
   413     TInt64 value64;
       
   414     lex.Val( value64, 0x7FFFFFFFFFFFFFFF );
       
   415     TL( propertyDef->MinInt64ValueL() == value64 );
       
   416 
       
   417     return KErrNone;
       
   418     }
       
   419 
       
   420 // -----------------------------------------------------------------------------
       
   421 // CMdETestScripter::MaxInt64ValueL
       
   422 // -----------------------------------------------------------------------------
       
   423 //
       
   424 TInt CMdETestScripter::MaxInt64ValueL( CStifItemParser& aItem )
       
   425     {
       
   426     TPtrC value;
       
   427 
       
   428     CMdEPropertyDef* propertyDef = SanitizeArrayIndexL( iPropertyDefArray, *iPropertyDefNameArray, aItem );
       
   429     User::LeaveIfError( aItem.GetNextString( value ));
       
   430     TLex lex( value );
       
   431     TInt64 value64;
       
   432     lex.Val( value64, 0x7FFFFFFFFFFFFFFF );
       
   433     TL( propertyDef->MaxInt64ValueL() == value64 );
       
   434 
       
   435     return KErrNone;
       
   436     }
       
   437 
       
   438 // -----------------------------------------------------------------------------
       
   439 // CMdETestScripter::MinRealValueL
       
   440 // -----------------------------------------------------------------------------
       
   441 //
       
   442 TInt CMdETestScripter::MinRealValueL( CStifItemParser& aItem )
       
   443     {
       
   444     TPtrC value;
       
   445 
       
   446     CMdEPropertyDef* propertyDef = SanitizeArrayIndexL( iPropertyDefArray, *iPropertyDefNameArray, aItem );
       
   447     aItem.SetParsingType( CStifItemParser::EQuoteStyleParsing );
       
   448     User::LeaveIfError( aItem.GetNextString( value ));
       
   449     TLex lex( value );
       
   450     TReal valueR;
       
   451     lex.Val( valueR );
       
   452     TL( propertyDef->MinRealValueL() == valueR );
       
   453 
       
   454     return KErrNone;
       
   455     }
       
   456 
       
   457 // -----------------------------------------------------------------------------
       
   458 // CMdETestScripter::MaxRealValueL
       
   459 // -----------------------------------------------------------------------------
       
   460 //
       
   461 TInt CMdETestScripter::MaxRealValueL( CStifItemParser& aItem )
       
   462     {
       
   463     TPtrC value;
       
   464 
       
   465     CMdEPropertyDef* propertyDef = SanitizeArrayIndexL( iPropertyDefArray, *iPropertyDefNameArray, aItem );
       
   466     aItem.SetParsingType( CStifItemParser::EQuoteStyleParsing );
       
   467     User::LeaveIfError( aItem.GetNextString( value ));
       
   468     TLex lex( value );
       
   469     TReal valueR;
       
   470     lex.Val( valueR );
       
   471     TL( propertyDef->MaxRealValueL() == valueR );
       
   472 
       
   473     return KErrNone;
       
   474     }
       
   475 
       
   476 // -----------------------------------------------------------------------------
       
   477 // CMdETestScripter::MinTimeValueL
       
   478 // -----------------------------------------------------------------------------
       
   479 //
       
   480 TInt CMdETestScripter::MinTimeValueL( CStifItemParser& aItem )
       
   481     {
       
   482     TPtrC value;
       
   483 
       
   484     CMdEPropertyDef* propertyDef = SanitizeArrayIndexL( iPropertyDefArray, *iPropertyDefNameArray, aItem );
       
   485     User::LeaveIfError( aItem.GetNextString( value ));
       
   486     TTime time;
       
   487     TL( time.Set( value ) == KErrNone );
       
   488     TL( propertyDef->MinTimeValueL() == time );
       
   489 
       
   490     return KErrNone;
       
   491     }
       
   492 
       
   493 // -----------------------------------------------------------------------------
       
   494 // CMdETestScripter::MaxTimeValueL
       
   495 // -----------------------------------------------------------------------------
       
   496 //
       
   497 TInt CMdETestScripter::MaxTimeValueL( CStifItemParser& aItem )
       
   498     {
       
   499     TPtrC value;
       
   500 
       
   501     CMdEPropertyDef* propertyDef = SanitizeArrayIndexL( iPropertyDefArray, *iPropertyDefNameArray, aItem );
       
   502     User::LeaveIfError( aItem.GetNextString( value ));
       
   503     TTime time;
       
   504     TL( time.Set( value ) == KErrNone );
       
   505     TL( propertyDef->MaxTimeValueL() == time );
       
   506 
       
   507     return KErrNone;
       
   508     }
       
   509 
       
   510 // -----------------------------------------------------------------------------
       
   511 // CMdETestScripter::MinTextLengthL
       
   512 // -----------------------------------------------------------------------------
       
   513 //
       
   514 TInt CMdETestScripter::MinTextLengthL( CStifItemParser& aItem )
       
   515     {
       
   516     TInt value;
       
   517 
       
   518     CMdEPropertyDef* propertyDef = SanitizeArrayIndexL( iPropertyDefArray, *iPropertyDefNameArray, aItem );
       
   519     User::LeaveIfError( aItem.GetNextInt( value ));
       
   520     TL( propertyDef->MinTextLengthL() == value );
       
   521 
       
   522     return KErrNone;
       
   523     }
       
   524 
       
   525 // -----------------------------------------------------------------------------
       
   526 // CMdETestScripter::MaxTextLengthL
       
   527 // -----------------------------------------------------------------------------
       
   528 //
       
   529 TInt CMdETestScripter::MaxTextLengthL( CStifItemParser& aItem )
       
   530     {
       
   531     TInt value;
       
   532 
       
   533     CMdEPropertyDef* propertyDef = SanitizeArrayIndexL( iPropertyDefArray, *iPropertyDefNameArray, aItem );
       
   534     User::LeaveIfError( aItem.GetNextInt( value ));
       
   535     TL( propertyDef->MaxTextLengthL() == value );
       
   536 
       
   537     return KErrNone;
       
   538     }
       
   539 
       
   540 // -----------------------------------------------------------------------------
       
   541 // CMdETestScripter::DefL
       
   542 // -----------------------------------------------------------------------------
       
   543 //
       
   544 TInt CMdETestScripter::DefL( CStifItemParser& aItem )
       
   545     {
       
   546     TInt mode;
       
   547     TPtrC name;
       
   548     User::LeaveIfError( aItem.GetNextString( name ));
       
   549 
       
   550     User::LeaveIfError( aItem.GetNextInt( mode ));
       
   551 
       
   552     if ( mode == EObjectDef )
       
   553         {
       
   554            CMdEObject* object = SanitizeArrayIndexL( iObjectArray, *iObjectNameArray, aItem);
       
   555            CMdEObjectDef& objDef = object->Def();
       
   556         TL( &objDef );
       
   557         iObjectDefArray.Append( &objDef );
       
   558         AppendNameL( iObjectDefNameArray, name );
       
   559         }
       
   560     else if ( mode == ERelationDef )
       
   561         {
       
   562            CMdERelation* relation = SanitizeArrayIndexL( iRelationArray, *iRelationNameArray, aItem);
       
   563            CMdERelationDef& relDef = relation->Def();        
       
   564         TL( &relDef );
       
   565         iRelationDefArray.Append( &relDef );
       
   566         AppendNameL( iRelationDefNameArray, name );
       
   567         }
       
   568     else if ( mode == EPropertyDef )
       
   569         {
       
   570            CMdEProperty* property = SanitizeArrayIndexL( iPropertyArray, *iPropertyNameArray, aItem);
       
   571            const CMdEPropertyDef& propDef = property->Def();      
       
   572         TL( &propDef );
       
   573         iPropertyDefArray.Append( &propDef );
       
   574         AppendNameL( iPropertyDefNameArray, name );
       
   575         }
       
   576     else if ( mode == EEventDef )
       
   577         {
       
   578         CMdEEvent* event = SanitizeArrayIndexL( iEventArray, *iEventNameArray, aItem );
       
   579         CMdEEventDef& eventDef = event->Def();
       
   580         TL( &eventDef );
       
   581         iEventDefArray.Append( &eventDef );
       
   582         AppendNameL( iEventDefNameArray, name );
       
   583         }
       
   584     else
       
   585         {
       
   586         User::Leave( KErrArgument );
       
   587         }
       
   588 
       
   589     return KErrNone;
       
   590     }
       
   591 
       
   592 // -----------------------------------------------------------------------------
       
   593 // CMdETestScripter::SetDefL
       
   594 // -----------------------------------------------------------------------------
       
   595 //
       
   596 TInt CMdETestScripter::SetDefL( CStifItemParser& aItem )
       
   597     {
       
   598 
       
   599     CMdEObject* object = SanitizeArrayIndexL( iObjectArray, *iObjectNameArray, aItem );
       
   600     CMdEObjectDef* objectDef = SanitizeArrayIndexL( iObjectDefArray, *iObjectDefNameArray, aItem );
       
   601     object->SetDefL( *objectDef );
       
   602 
       
   603     return KErrNone;
       
   604     }
       
   605 
       
   606 // -----------------------------------------------------------------------------
       
   607 // CMdETestScripter::UriL
       
   608 // -----------------------------------------------------------------------------
       
   609 //
       
   610 TInt CMdETestScripter::UriL( CStifItemParser& aItem )
       
   611     {
       
   612 
       
   613     TPtrC uri;
       
   614 
       
   615     CMdEObject* object = SanitizeArrayIndexL( iObjectArray, *iObjectNameArray, aItem );
       
   616     User::LeaveIfError( aItem.GetNextString( uri ));
       
   617     TL( object->Uri().Compare( uri ) == 0 );
       
   618 
       
   619     return KErrNone;
       
   620     }
       
   621 
       
   622 // -----------------------------------------------------------------------------
       
   623 // CMdETestScripter::SetUriL
       
   624 // -----------------------------------------------------------------------------
       
   625 //
       
   626 TInt CMdETestScripter::SetUriL( CStifItemParser& aItem )
       
   627     {
       
   628 
       
   629     TPtrC uri;
       
   630 
       
   631     CMdEObject* object = SanitizeArrayIndexL( iObjectArray, *iObjectNameArray, aItem );
       
   632     User::LeaveIfError( aItem.GetNextString( uri ));
       
   633     object->SetUriL( uri );
       
   634 
       
   635     return KErrNone;
       
   636     }
       
   637 
       
   638 // -----------------------------------------------------------------------------
       
   639 // CMdETestScripter::ConfidentialL
       
   640 // -----------------------------------------------------------------------------
       
   641 //
       
   642 TInt CMdETestScripter::ConfidentialL( CStifItemParser& aItem )
       
   643     {
       
   644     TInt state;
       
   645 
       
   646     CMdEObject* object = SanitizeArrayIndexL( iObjectArray, *iObjectNameArray, aItem );
       
   647     User::LeaveIfError( aItem.GetNextInt( state ));
       
   648     TL( object->Confidential() == (TBool)state );
       
   649 
       
   650     return KErrNone;
       
   651     }
       
   652 
       
   653 // -----------------------------------------------------------------------------
       
   654 // CMdETestScripter::SetConfidentialL
       
   655 // -----------------------------------------------------------------------------
       
   656 //
       
   657 TInt CMdETestScripter::SetConfidentialL( CStifItemParser& aItem )
       
   658     {
       
   659     TInt state;
       
   660 
       
   661     CMdEObject* object = SanitizeArrayIndexL( iObjectArray, *iObjectNameArray, aItem );
       
   662     User::LeaveIfError( aItem.GetNextInt( state ));
       
   663 
       
   664     object->SetConfidential( (TBool)state );
       
   665 
       
   666     return KErrNone;
       
   667     }
       
   668 
       
   669 // -----------------------------------------------------------------------------
       
   670 // CMdETestScripter::PlaceholderL
       
   671 // -----------------------------------------------------------------------------
       
   672 //
       
   673 TInt CMdETestScripter::PlaceholderL( CStifItemParser& aItem )
       
   674     {
       
   675     TInt state;
       
   676 
       
   677     CMdEObject* object = SanitizeArrayIndexL( iObjectArray, *iObjectNameArray, aItem );
       
   678     User::LeaveIfError( aItem.GetNextInt( state ));
       
   679     TL( object->Placeholder() == (TBool)state );
       
   680 
       
   681     return KErrNone;
       
   682     }
       
   683 
       
   684 // -----------------------------------------------------------------------------
       
   685 // CMdETestScripter::SetPlaceholderL
       
   686 // -----------------------------------------------------------------------------
       
   687 //
       
   688 TInt CMdETestScripter::SetPlaceholderL( CStifItemParser& aItem )
       
   689     {
       
   690     TInt state;
       
   691 
       
   692     CMdEObject* object = SanitizeArrayIndexL( iObjectArray, *iObjectNameArray, aItem );
       
   693     User::LeaveIfError( aItem.GetNextInt( state ));
       
   694 
       
   695     object->SetPlaceholder( (TBool)state );
       
   696 
       
   697     return KErrNone;
       
   698     }
       
   699 
       
   700 // -----------------------------------------------------------------------------
       
   701 // CMdETestScripter::MediaIdL
       
   702 // -----------------------------------------------------------------------------
       
   703 //
       
   704 TInt CMdETestScripter::MediaIdL( CStifItemParser& aItem )
       
   705     {
       
   706     TInt mediaId;
       
   707 
       
   708     CMdEObject* object = SanitizeArrayIndexL( iObjectArray, *iObjectNameArray, aItem );
       
   709     User::LeaveIfError( aItem.GetNextInt( mediaId ));
       
   710 
       
   711     TL( object->MediaId() == mediaId );
       
   712 
       
   713     return KErrNone;
       
   714     }
       
   715 
       
   716 // -----------------------------------------------------------------------------
       
   717 // CMdETestScripter::SetMediaIdL
       
   718 // -----------------------------------------------------------------------------
       
   719 //
       
   720 TInt CMdETestScripter::SetMediaIdL( CStifItemParser& aItem )
       
   721     {
       
   722     TInt mediaId;
       
   723 
       
   724     CMdEObject* object = SanitizeArrayIndexL( iObjectArray, *iObjectNameArray, aItem );
       
   725     User::LeaveIfError( aItem.GetNextInt( mediaId ));
       
   726 
       
   727     object->SetMediaId( mediaId );
       
   728 
       
   729     return KErrNone;
       
   730     }
       
   731 
       
   732 // -----------------------------------------------------------------------------
       
   733 // CMdETestScripter::UsageCountL
       
   734 // -----------------------------------------------------------------------------
       
   735 //
       
   736 TInt CMdETestScripter::UsageCountL( CStifItemParser& aItem )
       
   737     {
       
   738 
       
   739     TInt count;
       
   740 
       
   741     CMdEObject* object = SanitizeArrayIndexL( iObjectArray, *iObjectNameArray, aItem );
       
   742     User::LeaveIfError( aItem.GetNextInt( count ));
       
   743 
       
   744     TL( object->UsageCount() == count );
       
   745 
       
   746     return KErrNone;
       
   747     }
       
   748 
       
   749 // -----------------------------------------------------------------------------
       
   750 // CMdETestScripter::GuidL
       
   751 // -----------------------------------------------------------------------------
       
   752 //
       
   753 TInt CMdETestScripter::GuidL( CStifItemParser& aItem )
       
   754     {
       
   755     TInt mode;
       
   756 
       
   757     TInt guidHighExpected;
       
   758     TInt guidLowExpected;
       
   759     TInt64 guidHigh;
       
   760     TInt64 guidLow;
       
   761 
       
   762     User::LeaveIfError( aItem.GetNextInt( mode ));
       
   763     if ( mode == EObject )
       
   764         {
       
   765         CMdEObject* object = SanitizeArrayIndexL( iObjectArray, *iObjectNameArray, aItem );
       
   766         User::LeaveIfError( aItem.GetNextInt( guidHighExpected ));
       
   767         User::LeaveIfError( aItem.GetNextInt( guidLowExpected ));        
       
   768         object->Guid( guidHigh, guidLow );
       
   769         }
       
   770     else if ( mode == ERelation )
       
   771         {
       
   772         CMdERelation* relation = SanitizeArrayIndexL( iRelationArray, *iRelationNameArray, aItem );
       
   773         User::LeaveIfError( aItem.GetNextInt( guidHighExpected ));
       
   774         User::LeaveIfError( aItem.GetNextInt( guidLowExpected ));     
       
   775         relation->Guid( guidHigh, guidLow );
       
   776         }
       
   777           
       
   778     TL( guidHighExpected == guidHigh );
       
   779     TL( guidLowExpected == guidLow );
       
   780 
       
   781     return KErrNone;
       
   782     }
       
   783 
       
   784 // -----------------------------------------------------------------------------
       
   785 // CMdETestScripter::SetGuidL
       
   786 // -----------------------------------------------------------------------------
       
   787 //
       
   788 TInt CMdETestScripter::SetGuidL( CStifItemParser& aItem )
       
   789     {
       
   790     TInt mode;
       
   791     
       
   792     TInt guidHigh;
       
   793     TInt guidLow;
       
   794 
       
   795     User::LeaveIfError( aItem.GetNextInt( mode ));
       
   796     if ( mode == EObject )
       
   797         {
       
   798         CMdEObject* object = SanitizeArrayIndexL( iObjectArray, *iObjectNameArray, aItem );
       
   799         User::LeaveIfError( aItem.GetNextInt( guidHigh ));
       
   800         User::LeaveIfError( aItem.GetNextInt( guidLow ));        
       
   801         object->SetGuid( guidHigh, guidLow );
       
   802         }
       
   803     else if ( mode == ERelation )
       
   804         {
       
   805         CMdERelation* relation = SanitizeArrayIndexL( iRelationArray, *iRelationNameArray, aItem );
       
   806         User::LeaveIfError( aItem.GetNextInt( guidHigh ));
       
   807         User::LeaveIfError( aItem.GetNextInt( guidLow ));     
       
   808         relation->SetGuid( guidHigh, guidLow );
       
   809         }
       
   810         
       
   811     return KErrNone;
       
   812     }
       
   813 
       
   814 // -----------------------------------------------------------------------------
       
   815 // CMdETestScripter::OpenForModifications
       
   816 // -----------------------------------------------------------------------------
       
   817 //
       
   818 TInt CMdETestScripter::OpenForModificationsL( CStifItemParser& aItem )
       
   819     {
       
   820     TInt open;
       
   821 
       
   822     CMdEObject* object = SanitizeArrayIndexL( iObjectArray, *iObjectNameArray, aItem );
       
   823     User::LeaveIfError( aItem.GetNextInt( open ));
       
   824 
       
   825     TBool state = object->OpenForModifications();
       
   826     TL( (TBool)open == state );
       
   827 
       
   828     return KErrNone;
       
   829     }
       
   830 
       
   831 // -----------------------------------------------------------------------------
       
   832 // CMdETestScripter::NewObjectL
       
   833 // -----------------------------------------------------------------------------
       
   834 //
       
   835 TInt CMdETestScripter::NewObjectL( CStifItemParser& aItem )
       
   836     {
       
   837     TInt mode;
       
   838     CMdEObject* object = NULL;
       
   839 
       
   840     TPtrC name;
       
   841     User::LeaveIfError( aItem.GetNextString( name ));    
       
   842     
       
   843     CMdEObjectDef* objectDef = SanitizeArrayIndexL( iObjectDefArray, *iObjectDefNameArray, aItem );
       
   844     User::LeaveIfError( aItem.GetNextInt( mode ));
       
   845 
       
   846     if ( mode == KL )
       
   847         {
       
   848         object = iMdeSession->NewObjectL(
       
   849             *objectDef, MdeConstants::Object::KAutomaticUri );
       
   850         }
       
   851     else if ( mode == KLC )
       
   852         {
       
   853         object = iMdeSession->NewObjectLC(
       
   854             *objectDef, MdeConstants::Object::KAutomaticUri );
       
   855         CleanupStack::Pop( object );
       
   856         }
       
   857     else
       
   858         {
       
   859         User::Leave( KErrArgument );
       
   860         }
       
   861 
       
   862     TL( object );
       
   863     iObjectArray.Append( object );
       
   864     AppendNameL( iObjectNameArray, name );    
       
   865 
       
   866     return KErrNone;
       
   867     }
       
   868 
       
   869 // -----------------------------------------------------------------------------
       
   870 // CMdETestScripter::AddObjectL
       
   871 // -----------------------------------------------------------------------------
       
   872 //
       
   873 TInt CMdETestScripter::AddObjectL( CStifItemParser& aItem )
       
   874     {
       
   875     CMdEObject* object = SanitizeArrayIndexL( iObjectArray, *iObjectNameArray, aItem );
       
   876 
       
   877     TItemId id = iMdeSession->AddObjectL( *object );
       
   878     TL( id != KNoId );
       
   879     TL( object->Id() == id );
       
   880 
       
   881     return KErrNone;
       
   882     }
       
   883 
       
   884 // -----------------------------------------------------------------------------
       
   885 // CMdETestScripter::AddObjectsL
       
   886 // -----------------------------------------------------------------------------
       
   887 //
       
   888 TInt CMdETestScripter::AddObjectsL( CStifItemParser& aItem )
       
   889     {
       
   890     TInt count;
       
   891     RPointerArray<CMdEObject> objectArray;
       
   892 
       
   893     TInt firstIndex = GetObjectIndexL( aItem );
       
   894     User::LeaveIfError( aItem.GetNextInt( count ));
       
   895 
       
   896     for ( TInt i = 0; i < count; ++i )
       
   897         {
       
   898         objectArray.Append( iObjectArray[ firstIndex + i ] );
       
   899         }
       
   900 
       
   901     TInt err = iMdeSession->AddObjectsL( objectArray );
       
   902     objectArray.Reset();
       
   903     T1L ( err, KErrNone );
       
   904 
       
   905     return KErrNone;
       
   906     }
       
   907 
       
   908 // -----------------------------------------------------------------------------
       
   909 // CMdETestScripter::GetObjectL
       
   910 // -----------------------------------------------------------------------------
       
   911 //
       
   912 TInt CMdETestScripter::GetObjectL( CStifItemParser& aItem )
       
   913     {
       
   914     TPtrC name;
       
   915     User::LeaveIfError( aItem.GetNextString( name ));
       
   916 
       
   917     TInt mode1;
       
   918     TInt mode2;
       
   919     CMdEObject* newObject = NULL;
       
   920     CMdEObjectDef* objectDef = NULL;
       
   921     CMdENamespaceDef* namespaceDef = NULL;
       
   922     TInt64 guidHigh = 0;
       
   923     TInt64 guidLow = 0;
       
   924 
       
   925     CMdEObject* object = SanitizeArrayIndexL( iObjectArray, *iObjectNameArray, aItem );
       
   926 
       
   927     User::LeaveIfError( aItem.GetNextInt( mode1 ));
       
   928     User::LeaveIfError( aItem.GetNextInt( mode2 ));
       
   929 
       
   930     if ( mode2 == EObjectDef )
       
   931         {
       
   932         objectDef = SanitizeArrayIndexL( iObjectDefArray, *iObjectDefNameArray, aItem );
       
   933         }
       
   934         else if ( mode2 == ENamespaceDef )
       
   935         {
       
   936         namespaceDef = SanitizeArrayIndexL( iNamespaceDefArray, *iNamespaceDefNameArray, aItem );
       
   937         }
       
   938 
       
   939     if ( mode1 == KById && mode2 == EObjectDef )
       
   940         {
       
   941         newObject = iMdeSession->GetObjectL( object->Id(), *objectDef );
       
   942         }
       
   943     else if ( mode1 == KById && mode2 == ENamespaceDef )
       
   944         {
       
   945         newObject = iMdeSession->GetObjectL( object->Id(), namespaceDef );
       
   946         }
       
   947     else if ( mode1 == KByUri && mode2 == EObjectDef )
       
   948         {
       
   949         newObject = iMdeSession->GetObjectL( object->Uri(), *objectDef );
       
   950         }
       
   951     else if ( mode1 == KByUri && mode2 == ENamespaceDef )
       
   952         {
       
   953         newObject = iMdeSession->GetObjectL( object->Uri(), namespaceDef );
       
   954         }
       
   955     else if ( mode1 == KByGuid && mode2 == EObjectDef )
       
   956         {
       
   957         object->Guid( guidHigh, guidLow );
       
   958         newObject = iMdeSession->GetObjectL( guidHigh, guidLow, *objectDef );
       
   959         }
       
   960     else if ( mode1 == KByGuid && mode2 == ENamespaceDef )
       
   961         {
       
   962         object->Guid( guidHigh, guidLow );
       
   963         newObject = iMdeSession->GetObjectL( guidHigh, guidLow, namespaceDef );
       
   964         }
       
   965     else
       
   966         {
       
   967         User::Leave( KErrArgument );
       
   968         }
       
   969 
       
   970     TL( newObject );
       
   971     iObjectArray.Append( newObject );   
       
   972     AppendNameL( iObjectNameArray, name );
       
   973 
       
   974     iLog->Log( _L( "Object Id = %d URI = %S Propertycount = %d" ),
       
   975         newObject->Id(), &newObject->Uri(), newObject->PropertyCount() );
       
   976 
       
   977     return KErrNone;
       
   978     }
       
   979 
       
   980 // -----------------------------------------------------------------------------
       
   981 // CMdETestScripter::GetFullObjectL
       
   982 // -----------------------------------------------------------------------------
       
   983 //
       
   984 TInt CMdETestScripter::GetFullObjectL( CStifItemParser& aItem )
       
   985     {
       
   986     TInt mode;
       
   987     CMdEObject* newObject = NULL;
       
   988     TPtrC name;
       
   989     User::LeaveIfError( aItem.GetNextString( name ));
       
   990     
       
   991     CMdEObjectDef* objectDef = SanitizeArrayIndexL( iObjectDefArray, *iObjectDefNameArray, aItem );
       
   992     CMdEObject* object = SanitizeArrayIndexL( iObjectArray, *iObjectNameArray, aItem );
       
   993     User::LeaveIfError( aItem.GetNextInt( mode ));
       
   994     if ( mode == KById )
       
   995         {
       
   996         newObject = iMdeSession->GetFullObjectL( object->Id());
       
   997        }
       
   998     else if ( mode == KByUri )
       
   999         {
       
  1000         newObject = iMdeSession->GetFullObjectL( object->Uri());
       
  1001         }
       
  1002     else if ( mode == KByGuid )
       
  1003         {
       
  1004         TInt64 guidHigh;
       
  1005         TInt64 guidLow;
       
  1006 
       
  1007         object->Guid( guidHigh, guidLow );
       
  1008         newObject = iMdeSession->GetFullObjectL( guidHigh, guidLow );
       
  1009         }
       
  1010     else
       
  1011         {
       
  1012         User::Leave( KErrArgument );
       
  1013         }
       
  1014     TL( newObject );
       
  1015     iObjectArray.Append( newObject );
       
  1016     AppendNameL( iObjectNameArray, name );
       
  1017 
       
  1018     return KErrNone;
       
  1019     }
       
  1020 
       
  1021 // -----------------------------------------------------------------------------
       
  1022 // CMdETestScripter::CheckObjectL
       
  1023 // -----------------------------------------------------------------------------
       
  1024 //
       
  1025 TInt CMdETestScripter::CheckObjectL( CStifItemParser& aItem )
       
  1026     {
       
  1027     TInt objIndex;
       
  1028     TInt mode;
       
  1029     TMdEObject tObject;
       
  1030 
       
  1031     objIndex = GetObjectIndexL( aItem );
       
  1032     User::LeaveIfError( aItem.GetNextInt( mode ));
       
  1033 
       
  1034     if ( mode == KById )
       
  1035         {
       
  1036         iMdeSession->CheckObjectL( tObject, iObjectArray[ objIndex ]->Id() );
       
  1037         CheckTMdEObjectL( tObject, *iObjectArray[ objIndex ] );
       
  1038         }
       
  1039     else if ( mode == KByUri )
       
  1040         {
       
  1041         iMdeSession->CheckObjectL( tObject, iObjectArray[ objIndex ]->Uri() );
       
  1042         CheckTMdEObjectL( tObject, *iObjectArray[ objIndex ] );
       
  1043         }
       
  1044     else if ( mode == KByIds )
       
  1045         {
       
  1046         TInt count;
       
  1047         RArray<TItemId> ids;
       
  1048         RArray<TMdEObject> tObjects;
       
  1049 
       
  1050         User::LeaveIfError( aItem.GetNextInt( count ));
       
  1051         TL( iObjectArray.Count() > objIndex + count - 1 );
       
  1052 
       
  1053         for ( TInt i = 0; i < count; ++i )
       
  1054             {
       
  1055             ids.Append( iObjectArray[ objIndex + i ]->Id() );
       
  1056             }
       
  1057         iMdeSession->CheckObjectL( tObjects, ids );
       
  1058         CheckTMdEObjectArrayL( tObjects, objIndex, count );
       
  1059 
       
  1060         tObjects.Reset();
       
  1061         ids.Reset();
       
  1062         }
       
  1063     else
       
  1064         {
       
  1065         User::Leave( KErrArgument );
       
  1066         }
       
  1067 
       
  1068     return KErrNone;
       
  1069     }
       
  1070 
       
  1071 // -----------------------------------------------------------------------------
       
  1072 // CMdETestScripter::RemoveObjectL
       
  1073 // -----------------------------------------------------------------------------
       
  1074 //
       
  1075 TInt CMdETestScripter::RemoveObjectL( CStifItemParser& aItem )
       
  1076     {
       
  1077     TInt mode;
       
  1078 
       
  1079     CMdEObject* object = SanitizeArrayIndexL( iObjectArray, *iObjectNameArray, aItem );
       
  1080     User::LeaveIfError( aItem.GetNextInt( mode ));
       
  1081 
       
  1082     TItemId id = KNoId;
       
  1083 
       
  1084     if ( mode == KById )
       
  1085         {
       
  1086         id = iMdeSession->RemoveObjectL( object->Id() );
       
  1087         }
       
  1088     else if ( mode == KByUri )
       
  1089         {
       
  1090         id = iMdeSession->RemoveObjectL( object->Uri() );
       
  1091         }
       
  1092     else
       
  1093         {
       
  1094         User::Leave( KErrArgument );
       
  1095         }
       
  1096 
       
  1097     TL( id != KNoId );
       
  1098 
       
  1099     return KErrNone;
       
  1100     }
       
  1101 
       
  1102 // -----------------------------------------------------------------------------
       
  1103 // CMdETestScripter::RemoveObjectsL
       
  1104 // -----------------------------------------------------------------------------
       
  1105 //
       
  1106 TInt CMdETestScripter::RemoveObjectsL( CStifItemParser& aItem )
       
  1107     {
       
  1108     TInt mode1;
       
  1109     TInt mode2;
       
  1110     TInt objIndex;
       
  1111     TInt count;
       
  1112     TInt needMacroVerifyResult;
       
  1113     RArray<TItemId> objectIdArray;
       
  1114     RPointerArray<TDesC> objectUriArray;
       
  1115     RArray<TItemId> successful;
       
  1116     TRequestStatus status = KRequestPending;
       
  1117 
       
  1118     User::LeaveIfError( aItem.GetNextInt( mode1 ));
       
  1119     User::LeaveIfError( aItem.GetNextInt( mode2 ));
       
  1120     objIndex = GetObjectIndexL( aItem );
       
  1121     User::LeaveIfError( aItem.GetNextInt( count ));
       
  1122     TL( iObjectArray.Count() > objIndex + count - 1 );
       
  1123     TRAPD( err, aItem.GetNextInt( needMacroVerifyResult ) );
       
  1124     if ( KErrNone != err )
       
  1125         {
       
  1126         needMacroVerifyResult = 1;
       
  1127         }
       
  1128 
       
  1129     for ( TInt i = 0; i < count; ++i )
       
  1130         {
       
  1131         if ( mode2 == KById )
       
  1132             {
       
  1133             objectIdArray.Append( iObjectArray[ objIndex + i ]->Id() );
       
  1134             }
       
  1135         else if ( mode2 == KByUri )
       
  1136             {
       
  1137             objectUriArray.Append( &iObjectArray[ objIndex + i ]->Uri() );
       
  1138             }
       
  1139         }
       
  1140 
       
  1141     if ( mode1 == KSync && mode2 == KById )
       
  1142         {
       
  1143         iMdeSession->RemoveObjectsL( objectIdArray, successful );
       
  1144         }
       
  1145     else if ( mode1 == KSync && mode2 == KByUri )
       
  1146         {
       
  1147         iMdeSession->RemoveObjectsL( objectUriArray, successful );
       
  1148         }
       
  1149     else if ( mode1 == KAsync && mode2 == KById )
       
  1150         {
       
  1151         iItemCount = count;
       
  1152         TEventIf event( TEventIf::ESetEvent, TName( KMdEObjectsAsyncRemoved ) );
       
  1153         iAsyncHandler->Start( this, event );
       
  1154         iMdEDataBuf.Close();// make sure the last async request buffer cleaned before using again.
       
  1155         iMdeSession->RemoveObjectsAsyncL( objectIdArray, iAsyncHandler->iStatus, iMdEDataBuf );
       
  1156         }
       
  1157     else if ( mode1 == KAsync && mode2 == KByUri )
       
  1158         {
       
  1159         iItemCount = count;
       
  1160         TEventIf event( TEventIf::ESetEvent, TName( KMdEObjectsAsyncRemoved ) );
       
  1161         iAsyncHandler->Start( this, event );
       
  1162         iMdEDataBuf.Close();// make sure the last async request buffer cleaned before using again.
       
  1163         iMdeSession->RemoveObjectsAsyncL( objectUriArray, iAsyncHandler->iStatus, iMdEDataBuf );
       
  1164         }
       
  1165     else
       
  1166         {
       
  1167         User::Leave( KErrArgument );
       
  1168         }
       
  1169 
       
  1170     if( needMacroVerifyResult && KSync == mode1 )
       
  1171         {
       
  1172         TL( successful.Count() == count );
       
  1173         for ( TInt i = 0; i < successful.Count(); ++i )
       
  1174             {
       
  1175             TL( successful[ i ] != KNoId );
       
  1176             }
       
  1177         }
       
  1178 
       
  1179     successful.Reset();
       
  1180     objectIdArray.Reset();
       
  1181     
       
  1182     return KErrNone;
       
  1183     }
       
  1184 
       
  1185 // -----------------------------------------------------------------------------
       
  1186 // CMdETestScripter::RemoveAllObjectsL
       
  1187 // -----------------------------------------------------------------------------
       
  1188 //
       
  1189 TInt CMdETestScripter::RemoveAllObjectsL( CStifItemParser& /* aItem */ )
       
  1190     {
       
  1191     TInt count = iObjectArray.Count();
       
  1192     RArray<TItemId> successful;
       
  1193     RArray<TItemId> objectIdArray;
       
  1194 
       
  1195     for ( TInt i = 0; i < count; ++i )
       
  1196         {
       
  1197         objectIdArray.Append( iObjectArray[ i ]->Id() );
       
  1198         }
       
  1199 
       
  1200     if (count)
       
  1201         {
       
  1202         iMdeSession->RemoveObjectsL( objectIdArray, successful );
       
  1203         }
       
  1204     objectIdArray.Reset();
       
  1205     successful.Reset();
       
  1206 
       
  1207     return KErrNone;
       
  1208     }
       
  1209 // -----------------------------------------------------------------------------
       
  1210 // CMdETestScripter::OpenObjectL
       
  1211 // -----------------------------------------------------------------------------
       
  1212 //
       
  1213 TInt CMdETestScripter::OpenObjectL( CStifItemParser& aItem )
       
  1214     {
       
  1215     _LIT( KMsg1, "Enter OpenObjectL" );
       
  1216     iLog->Log( KMsg1 );
       
  1217     RDebug::Print( KMsg1 );
       
  1218     
       
  1219     TPtrC name;
       
  1220     User::LeaveIfError( aItem.GetNextString( name ));      
       
  1221 
       
  1222     TInt mode1;
       
  1223     TInt mode2;
       
  1224     CMdEObject* newObject = NULL;
       
  1225     CMdEObjectDef* objectDef = NULL;
       
  1226     CMdENamespaceDef* namespaceDef = NULL;
       
  1227     TInt64 guidHigh = 0;
       
  1228     TInt64 guidLow = 0;
       
  1229 
       
  1230     CMdEObject* object = SanitizeArrayIndexL( iObjectArray, *iObjectNameArray, aItem );
       
  1231     User::LeaveIfError( aItem.GetNextInt( mode1 ));
       
  1232     User::LeaveIfError( aItem.GetNextInt( mode2 ));
       
  1233 
       
  1234     if ( mode2 == EObjectDef )
       
  1235         {
       
  1236         objectDef = SanitizeArrayIndexL( iObjectDefArray, *iObjectDefNameArray, aItem );
       
  1237         }
       
  1238         else if ( mode2 == ENamespaceDef )
       
  1239         {
       
  1240         namespaceDef = SanitizeArrayIndexL( iNamespaceDefArray, *iNamespaceDefNameArray, aItem );
       
  1241         }
       
  1242 
       
  1243     if ( mode1 == KById && mode2 == EObjectDef )
       
  1244         {
       
  1245         newObject = iMdeSession->OpenObjectL( object->Id(), *objectDef );
       
  1246         }
       
  1247     else if ( mode1 == KById && mode2 == ENamespaceDef )
       
  1248         {
       
  1249         newObject = iMdeSession->OpenObjectL( object->Id(), namespaceDef );
       
  1250         }
       
  1251     else if ( mode1 == KByUri && mode2 == EObjectDef )
       
  1252         {
       
  1253         newObject = iMdeSession->OpenObjectL( object->Uri(), *objectDef );
       
  1254         }
       
  1255     else if ( mode1 == KByUri && mode2 == ENamespaceDef )
       
  1256         {
       
  1257         newObject = iMdeSession->OpenObjectL( object->Uri(), namespaceDef );
       
  1258         }
       
  1259     else if ( mode1 == KByGuid && mode2 == EObjectDef )
       
  1260         {
       
  1261         object->Guid( guidHigh, guidLow );
       
  1262         newObject = iMdeSession->OpenObjectL( guidHigh, guidLow, *objectDef );
       
  1263         }
       
  1264     else if ( mode1 == KByGuid && mode2 == ENamespaceDef )
       
  1265         {
       
  1266         object->Guid( guidHigh, guidLow );
       
  1267         newObject = iMdeSession->OpenObjectL( guidHigh, guidLow, namespaceDef );
       
  1268         }
       
  1269     else
       
  1270         {
       
  1271         User::Leave( KErrArgument );
       
  1272         }
       
  1273     TL( newObject );
       
  1274     iObjectArray.Append( newObject );
       
  1275     AppendNameL( iObjectNameArray, name );
       
  1276 
       
  1277     _LIT( KMsg2, "Exit OpenObjectL" );
       
  1278     iLog->Log( KMsg2 );
       
  1279     RDebug::Print( KMsg2 );
       
  1280     
       
  1281     return KErrNone;
       
  1282     }
       
  1283 
       
  1284 // -----------------------------------------------------------------------------
       
  1285 // CMdETestScripter::OpenFullObjectL
       
  1286 // -----------------------------------------------------------------------------
       
  1287 //
       
  1288 TInt CMdETestScripter::OpenFullObjectL( CStifItemParser& aItem )
       
  1289     {
       
  1290     TInt mode;
       
  1291     TPtrC name;
       
  1292     User::LeaveIfError( aItem.GetNextString( name ));  
       
  1293     CMdEObject* newObject = NULL;
       
  1294 
       
  1295     CMdEObject* object = SanitizeArrayIndexL( iObjectArray, *iObjectNameArray, aItem );
       
  1296     
       
  1297     User::LeaveIfError( aItem.GetNextInt( mode ));
       
  1298 
       
  1299     if ( mode == KById )
       
  1300         {
       
  1301         newObject = iMdeSession->OpenFullObjectL( object->Id() );
       
  1302         }
       
  1303     else if ( mode == KByUri )
       
  1304         {
       
  1305         newObject = iMdeSession->OpenFullObjectL( object->Uri() );
       
  1306         }
       
  1307     else if ( mode == KByGuid )
       
  1308         {
       
  1309         TInt64 guidHigh;
       
  1310         TInt64 guidLow;
       
  1311 
       
  1312         object->Guid( guidHigh, guidLow );
       
  1313         newObject = iMdeSession->OpenFullObjectL( guidHigh, guidLow );
       
  1314         }
       
  1315     else
       
  1316         {
       
  1317         User::Leave( KErrArgument );
       
  1318         }
       
  1319     TL( newObject );
       
  1320     if ( !newObject->OpenForModifications() )
       
  1321         {
       
  1322         return KErrLocked;
       
  1323         }
       
  1324     iObjectArray.Append( newObject );
       
  1325     AppendNameL( iObjectNameArray, name );
       
  1326     return KErrNone;
       
  1327     }
       
  1328 
       
  1329 // -----------------------------------------------------------------------------
       
  1330 // CMdETestScripter::CommitObjectL
       
  1331 // -----------------------------------------------------------------------------
       
  1332 //
       
  1333 TInt CMdETestScripter::CommitObjectL( CStifItemParser& aItem )
       
  1334     {
       
  1335     CMdEObject* object = SanitizeArrayIndexL( iObjectArray, *iObjectNameArray, aItem );
       
  1336     iMdeSession->CommitObjectL( *object );
       
  1337 
       
  1338     return KErrNone;
       
  1339     }
       
  1340 
       
  1341 // -----------------------------------------------------------------------------
       
  1342 // CMdETestScripter::CommitObjectsL
       
  1343 // -----------------------------------------------------------------------------
       
  1344 //
       
  1345 TInt CMdETestScripter::CommitObjectsL( CStifItemParser& aItem )
       
  1346     {
       
  1347     TInt objIndex;
       
  1348     TInt count;
       
  1349     RPointerArray<CMdEObject> objectArray;
       
  1350 
       
  1351     objIndex = GetObjectIndexL( aItem );
       
  1352 
       
  1353     User::LeaveIfError( aItem.GetNextInt( count ));
       
  1354 
       
  1355     for ( TInt i = 0; i < count; ++i )
       
  1356         {
       
  1357         objectArray.Append( iObjectArray[ objIndex + i ] );
       
  1358         }
       
  1359 
       
  1360     iMdeSession->CommitObjectsL( objectArray );
       
  1361     
       
  1362     objectArray.Reset();
       
  1363 
       
  1364     return KErrNone;
       
  1365     }
       
  1366 
       
  1367 // -----------------------------------------------------------------------------
       
  1368 // CMdETestScripter::CancelObjectL
       
  1369 // -----------------------------------------------------------------------------
       
  1370 //
       
  1371 TInt CMdETestScripter::CancelObjectL( CStifItemParser& aItem )
       
  1372     {
       
  1373     CMdEObject* object = SanitizeArrayIndexL( iObjectArray, *iObjectNameArray, aItem );
       
  1374 
       
  1375     iMdeSession->CancelObjectL( *object );
       
  1376 
       
  1377     return KErrNone;
       
  1378     }
       
  1379 
       
  1380 // -----------------------------------------------------------------------------
       
  1381 // CMdETestScripter::PropertyL
       
  1382 // -----------------------------------------------------------------------------
       
  1383 //
       
  1384 TInt CMdETestScripter::PropertyL( CStifItemParser& aItem )
       
  1385     {
       
  1386     TInt mode;
       
  1387     TPtrC name;
       
  1388     User::LeaveIfError( aItem.GetNextString( name ));  
       
  1389     User::LeaveIfError( aItem.GetNextInt( mode ));
       
  1390 
       
  1391     const CMdEObject* object = SanitizeArrayIndexL( iObjectArray, *iObjectNameArray, aItem );    
       
  1392     CMdEProperty* property;
       
  1393 
       
  1394     if ( mode == KByIndex )
       
  1395         {
       
  1396         TInt index;
       
  1397 
       
  1398         User::LeaveIfError( aItem.GetNextInt( index ));
       
  1399         property = &object->PropertyL( index );
       
  1400         }
       
  1401     else if ( mode == KByDef )
       
  1402         {
       
  1403         CMdEPropertyDef* propertyDef = SanitizeArrayIndexL( iPropertyDefArray, *iPropertyDefNameArray, aItem );
       
  1404         TInt startAt;
       
  1405         User::LeaveIfError( aItem.GetNextInt( startAt ));        
       
  1406         TL( object->Property( *propertyDef, property, startAt ) != KErrNotFound );
       
  1407         }
       
  1408     else
       
  1409         {
       
  1410         User::Leave( KErrArgument );
       
  1411         }
       
  1412     TL( property );
       
  1413 
       
  1414     iPropertyArray.Append ( property );
       
  1415     AppendNameL( iPropertyNameArray, name );
       
  1416     return KErrNone;
       
  1417     }
       
  1418 
       
  1419 // -----------------------------------------------------------------------------
       
  1420 // CMdETestScripter::PropertyCountL
       
  1421 // -----------------------------------------------------------------------------
       
  1422 //
       
  1423 TInt CMdETestScripter::PropertyCountL( CStifItemParser& aItem )
       
  1424     {
       
  1425     TInt mode;
       
  1426     TInt count;
       
  1427     TInt state = 0;
       
  1428 
       
  1429     User::LeaveIfError( aItem.GetNextInt( mode ));
       
  1430     const CMdEObject* object = SanitizeArrayIndexL( iObjectArray, *iObjectNameArray, aItem );
       
  1431 
       
  1432     if ( mode == EObject )
       
  1433         {
       
  1434         state = object->PropertyCount();
       
  1435         }
       
  1436     else if ( mode == EPropertyDef )
       
  1437         {
       
  1438         CMdEPropertyDef* propertyDef = SanitizeArrayIndexL( iPropertyDefArray, *iPropertyDefNameArray, aItem );
       
  1439         state = object->PropertyCount( *propertyDef );
       
  1440         }
       
  1441     else
       
  1442         {
       
  1443         User::Leave( KErrArgument );
       
  1444         }
       
  1445 
       
  1446     User::LeaveIfError( aItem.GetNextInt( count ));
       
  1447     TL( count == state );
       
  1448 
       
  1449     return KErrNone;
       
  1450     }
       
  1451 
       
  1452 // -----------------------------------------------------------------------------
       
  1453 // CMdETestScripter::AddBoolPropertyL
       
  1454 // -----------------------------------------------------------------------------
       
  1455 //
       
  1456 TInt CMdETestScripter::AddBoolPropertyL( CStifItemParser& aItem )
       
  1457     {
       
  1458     TInt value;
       
  1459 
       
  1460     CMdEObject* object = SanitizeArrayIndexL( iObjectArray, *iObjectNameArray, aItem );
       
  1461     CMdEPropertyDef* propertyDef = SanitizeArrayIndexL( iPropertyDefArray, *iPropertyDefNameArray, aItem );
       
  1462     User::LeaveIfError( aItem.GetNextInt( value ));
       
  1463 
       
  1464     CMdEProperty& prop = object->AddBoolPropertyL( *propertyDef, (TBool)value );
       
  1465     TL( &prop );
       
  1466 
       
  1467     return KErrNone;
       
  1468     }
       
  1469 
       
  1470 // -----------------------------------------------------------------------------
       
  1471 // CMdETestScripter::AddInt8PropertyL
       
  1472 // -----------------------------------------------------------------------------
       
  1473 //
       
  1474 TInt CMdETestScripter::AddInt8PropertyL( CStifItemParser& aItem )
       
  1475     {
       
  1476     TInt value;
       
  1477     CMdEObject* object = SanitizeArrayIndexL( iObjectArray, *iObjectNameArray, aItem );
       
  1478     
       
  1479     CMdEPropertyDef* propertyDef = SanitizeArrayIndexL( iPropertyDefArray, *iPropertyDefNameArray, aItem );
       
  1480 
       
  1481     User::LeaveIfError( aItem.GetNextInt( value ));
       
  1482 
       
  1483     CMdEProperty& prop = object->AddInt8PropertyL( *propertyDef, value );
       
  1484     TL( &prop );
       
  1485 
       
  1486     return KErrNone;
       
  1487     }
       
  1488 
       
  1489 // -----------------------------------------------------------------------------
       
  1490 // CMdETestScripter::AddUint8PropertyL
       
  1491 // -----------------------------------------------------------------------------
       
  1492 //
       
  1493 TInt CMdETestScripter::AddUint8PropertyL( CStifItemParser& aItem )
       
  1494     {
       
  1495     TInt value;
       
  1496 
       
  1497     CMdEObject* object = SanitizeArrayIndexL( iObjectArray, *iObjectNameArray, aItem );
       
  1498     CMdEPropertyDef* propertyDef = SanitizeArrayIndexL( iPropertyDefArray, *iPropertyDefNameArray, aItem );
       
  1499     User::LeaveIfError( aItem.GetNextInt( value ));
       
  1500 
       
  1501     CMdEProperty& prop = object->AddUint8PropertyL( *propertyDef, value );
       
  1502     TL( &prop );
       
  1503 
       
  1504     return KErrNone;
       
  1505     }
       
  1506 
       
  1507 // -----------------------------------------------------------------------------
       
  1508 // CMdETestScripter::AddInt16PropertyL
       
  1509 // -----------------------------------------------------------------------------
       
  1510 //
       
  1511 TInt CMdETestScripter::AddInt16PropertyL( CStifItemParser& aItem )
       
  1512     {
       
  1513     TInt value;
       
  1514 
       
  1515     CMdEObject* object = SanitizeArrayIndexL( iObjectArray, *iObjectNameArray, aItem );
       
  1516     CMdEPropertyDef* propertyDef = SanitizeArrayIndexL( iPropertyDefArray, *iPropertyDefNameArray, aItem );
       
  1517     User::LeaveIfError( aItem.GetNextInt( value ));
       
  1518 
       
  1519     CMdEProperty& prop = object->AddInt16PropertyL( *propertyDef, value );
       
  1520     TL( &prop );
       
  1521 
       
  1522     return KErrNone;
       
  1523     }
       
  1524 
       
  1525 // -----------------------------------------------------------------------------
       
  1526 // CMdETestScripter::AddUint16PropertyL
       
  1527 // -----------------------------------------------------------------------------
       
  1528 //
       
  1529 TInt CMdETestScripter::AddUint16PropertyL( CStifItemParser& aItem )
       
  1530     {
       
  1531     TInt value;
       
  1532 
       
  1533     CMdEObject* object = SanitizeArrayIndexL( iObjectArray, *iObjectNameArray, aItem );
       
  1534     CMdEPropertyDef* propertyDef = SanitizeArrayIndexL( iPropertyDefArray, *iPropertyDefNameArray, aItem );
       
  1535     User::LeaveIfError( aItem.GetNextInt( value ));    
       
  1536     
       
  1537     CMdEProperty& prop = object->AddUint16PropertyL( *propertyDef, value );
       
  1538     TL( &prop );
       
  1539 
       
  1540     return KErrNone;
       
  1541     }
       
  1542 
       
  1543 // -----------------------------------------------------------------------------
       
  1544 // CMdETestScripter::AddInt32PropertyL
       
  1545 // -----------------------------------------------------------------------------
       
  1546 //
       
  1547 TInt CMdETestScripter::AddInt32PropertyL( CStifItemParser& aItem )
       
  1548     {
       
  1549     TInt value;
       
  1550 
       
  1551     CMdEObject* object = SanitizeArrayIndexL( iObjectArray, *iObjectNameArray, aItem );
       
  1552     CMdEPropertyDef* propertyDef = SanitizeArrayIndexL( iPropertyDefArray, *iPropertyDefNameArray, aItem );
       
  1553     User::LeaveIfError( aItem.GetNextInt( value ));
       
  1554 
       
  1555     CMdEProperty& prop = object->AddInt32PropertyL( *propertyDef, value );
       
  1556     TL( &prop );
       
  1557 
       
  1558     return KErrNone;
       
  1559     }
       
  1560 
       
  1561 // -----------------------------------------------------------------------------
       
  1562 // CMdETestScripter::AddUint32PropertyL
       
  1563 // -----------------------------------------------------------------------------
       
  1564 //
       
  1565 TInt CMdETestScripter::AddUint32PropertyL( CStifItemParser& aItem )
       
  1566     {
       
  1567     TInt value;
       
  1568     CMdEObject* object = SanitizeArrayIndexL( iObjectArray, *iObjectNameArray, aItem );
       
  1569     CMdEPropertyDef* propertyDef = SanitizeArrayIndexL( iPropertyDefArray, *iPropertyDefNameArray, aItem );
       
  1570     User::LeaveIfError( aItem.GetNextInt( value ));
       
  1571 
       
  1572     CMdEProperty& prop = object->AddUint32PropertyL( *propertyDef, value );
       
  1573     TL( &prop );
       
  1574 
       
  1575     return KErrNone;
       
  1576     }
       
  1577 
       
  1578 // -----------------------------------------------------------------------------
       
  1579 // CMdETestScripter::AddInt64PropertyL
       
  1580 // -----------------------------------------------------------------------------
       
  1581 //
       
  1582 TInt CMdETestScripter::AddInt64PropertyL( CStifItemParser& aItem )
       
  1583     {
       
  1584     TInt value;
       
  1585     CMdEObject* object = SanitizeArrayIndexL( iObjectArray, *iObjectNameArray, aItem );
       
  1586     CMdEPropertyDef* propertyDef = SanitizeArrayIndexL( iPropertyDefArray, *iPropertyDefNameArray, aItem );
       
  1587     User::LeaveIfError( aItem.GetNextInt( value ));
       
  1588 
       
  1589     CMdEProperty& prop = object->AddInt64PropertyL( *propertyDef, value );
       
  1590     TL( &prop );
       
  1591 
       
  1592     return KErrNone;
       
  1593     }
       
  1594 
       
  1595 // -----------------------------------------------------------------------------
       
  1596 // CMdETestScripter::AddReal32PropertyL
       
  1597 // -----------------------------------------------------------------------------
       
  1598 //
       
  1599 TInt CMdETestScripter::AddReal32PropertyL( CStifItemParser& aItem )
       
  1600     {
       
  1601     TInt value;
       
  1602 
       
  1603     CMdEObject* object = SanitizeArrayIndexL( iObjectArray, *iObjectNameArray, aItem );
       
  1604     CMdEPropertyDef* propertyDef = SanitizeArrayIndexL( iPropertyDefArray, *iPropertyDefNameArray, aItem );
       
  1605     User::LeaveIfError( aItem.GetNextInt( value ));
       
  1606 
       
  1607     CMdEProperty& prop = object->AddReal32PropertyL( *propertyDef, value );
       
  1608     TL( &prop );
       
  1609 
       
  1610     return KErrNone;
       
  1611     }
       
  1612 
       
  1613 // -----------------------------------------------------------------------------
       
  1614 // CMdETestScripter::AddReal64PropertyL
       
  1615 // -----------------------------------------------------------------------------
       
  1616 //
       
  1617 TInt CMdETestScripter::AddReal64PropertyL( CStifItemParser& aItem )
       
  1618     {
       
  1619     TInt value;
       
  1620 
       
  1621     CMdEObject* object = SanitizeArrayIndexL( iObjectArray, *iObjectNameArray, aItem );
       
  1622     CMdEPropertyDef* propertyDef = SanitizeArrayIndexL( iPropertyDefArray, *iPropertyDefNameArray, aItem );
       
  1623 
       
  1624     User::LeaveIfError( aItem.GetNextInt( value ));
       
  1625 
       
  1626     CMdEProperty& prop = object->AddReal64PropertyL( *propertyDef, value );
       
  1627     TL( &prop );
       
  1628 
       
  1629     return KErrNone;
       
  1630     }
       
  1631 
       
  1632 // -----------------------------------------------------------------------------
       
  1633 // CMdETestScripter::AddTextPropertyL
       
  1634 // -----------------------------------------------------------------------------
       
  1635 //
       
  1636 TInt CMdETestScripter::AddTextPropertyL( CStifItemParser& aItem )
       
  1637     {
       
  1638     TPtrC value;
       
  1639 
       
  1640     CMdEObject* object = SanitizeArrayIndexL( iObjectArray, *iObjectNameArray, aItem );
       
  1641     CMdEPropertyDef* propertyDef = SanitizeArrayIndexL( iPropertyDefArray, *iPropertyDefNameArray, aItem );
       
  1642  
       
  1643     aItem.SetParsingType( CStifItemParser::EQuoteStyleParsing );
       
  1644     User::LeaveIfError( aItem.GetNextString( value ));
       
  1645 
       
  1646     CMdEProperty& prop = object->AddTextPropertyL( *propertyDef, value );
       
  1647     TL( &prop );
       
  1648 
       
  1649     return KErrNone;
       
  1650     }
       
  1651 
       
  1652 // -----------------------------------------------------------------------------
       
  1653 // CMdETestScripter::AddTimePropertyL
       
  1654 // -----------------------------------------------------------------------------
       
  1655 //
       
  1656 TInt CMdETestScripter::AddTimePropertyL( CStifItemParser& aItem )
       
  1657     {
       
  1658     TPtrC value;
       
  1659 
       
  1660     CMdEObject* object = SanitizeArrayIndexL( iObjectArray, *iObjectNameArray, aItem );
       
  1661     CMdEPropertyDef* propertyDef = SanitizeArrayIndexL( iPropertyDefArray, *iPropertyDefNameArray, aItem );  
       
  1662     User::LeaveIfError( aItem.GetNextString( value ));
       
  1663 
       
  1664     TTime time;
       
  1665     TL( time.Set( value ) == KErrNone );
       
  1666     CMdEProperty& prop = object->AddTimePropertyL( *propertyDef, time );
       
  1667     TL( &prop );
       
  1668 
       
  1669     return KErrNone;
       
  1670     }
       
  1671 
       
  1672 // -----------------------------------------------------------------------------
       
  1673 // CMdETestScripter::ObjectL
       
  1674 // -----------------------------------------------------------------------------
       
  1675 //
       
  1676 TInt CMdETestScripter::ObjectL( CStifItemParser& aItem )
       
  1677     {
       
  1678     CMdEProperty* property = SanitizeArrayIndexL( iPropertyArray, *iPropertyNameArray, aItem );
       
  1679     CMdEObject* object = SanitizeArrayIndexL( iObjectArray, *iObjectNameArray, aItem );
       
  1680     TL( object == &property->Object() );
       
  1681 
       
  1682     return KErrNone;
       
  1683     }
       
  1684 
       
  1685 // -----------------------------------------------------------------------------
       
  1686 // CMdETestScripter::BoolValueL
       
  1687 // -----------------------------------------------------------------------------
       
  1688 //
       
  1689 TInt CMdETestScripter::BoolValueL( CStifItemParser& aItem )
       
  1690     {
       
  1691     TInt value;
       
  1692 
       
  1693     CMdEProperty* property = SanitizeArrayIndexL( iPropertyArray, *iPropertyNameArray, aItem );  
       
  1694     User::LeaveIfError( aItem.GetNextInt( value ));
       
  1695 
       
  1696     TL( property->BoolValueL() == value );
       
  1697 
       
  1698     return KErrNone;
       
  1699     }
       
  1700 // -----------------------------------------------------------------------------
       
  1701 // CMdETestScripter::Int8ValueL
       
  1702 // -----------------------------------------------------------------------------
       
  1703 //
       
  1704 TInt CMdETestScripter::Int8ValueL( CStifItemParser& aItem )
       
  1705     {
       
  1706     TInt value;
       
  1707 
       
  1708     CMdEProperty* property = SanitizeArrayIndexL( iPropertyArray, *iPropertyNameArray, aItem );  
       
  1709     User::LeaveIfError( aItem.GetNextInt( value ));
       
  1710     TL( property->Int8ValueL() == value );
       
  1711 
       
  1712     return KErrNone;
       
  1713     }
       
  1714 
       
  1715 // -----------------------------------------------------------------------------
       
  1716 // CMdETestScripter::Uint8ValueL
       
  1717 // -----------------------------------------------------------------------------
       
  1718 //
       
  1719 TInt CMdETestScripter::Uint8ValueL( CStifItemParser& aItem )
       
  1720     {
       
  1721     TInt value;
       
  1722 
       
  1723     CMdEProperty* property = SanitizeArrayIndexL( iPropertyArray, *iPropertyNameArray, aItem );  
       
  1724     User::LeaveIfError( aItem.GetNextInt( value ));
       
  1725     TL( property->Uint8ValueL() == value );
       
  1726 
       
  1727     return KErrNone;
       
  1728     }
       
  1729 
       
  1730 // -----------------------------------------------------------------------------
       
  1731 // CMdETestScripter::Int16ValueL
       
  1732 // -----------------------------------------------------------------------------
       
  1733 //
       
  1734 TInt CMdETestScripter::Int16ValueL( CStifItemParser& aItem )
       
  1735     {
       
  1736     TInt value;
       
  1737 
       
  1738     CMdEProperty* property = SanitizeArrayIndexL( iPropertyArray, *iPropertyNameArray, aItem );  
       
  1739     User::LeaveIfError( aItem.GetNextInt( value ));
       
  1740     TL( property->Int16ValueL() == value );
       
  1741 
       
  1742     return KErrNone;
       
  1743     }
       
  1744 
       
  1745 // -----------------------------------------------------------------------------
       
  1746 // CMdETestScripter::Uint16ValueL
       
  1747 // -----------------------------------------------------------------------------
       
  1748 //
       
  1749 TInt CMdETestScripter::Uint16ValueL( CStifItemParser& aItem )
       
  1750     {
       
  1751     TInt value;
       
  1752     CMdEProperty* property = SanitizeArrayIndexL( iPropertyArray, *iPropertyNameArray, aItem );  
       
  1753     User::LeaveIfError( aItem.GetNextInt( value ));
       
  1754     TL( property->Uint16ValueL() == value );
       
  1755 
       
  1756     return KErrNone;
       
  1757     }
       
  1758 
       
  1759 // -----------------------------------------------------------------------------
       
  1760 // CMdETestScripter::Int32ValueL
       
  1761 // -----------------------------------------------------------------------------
       
  1762 //
       
  1763 TInt CMdETestScripter::Int32ValueL( CStifItemParser& aItem )
       
  1764     {
       
  1765     TInt value;
       
  1766     CMdEProperty* property = SanitizeArrayIndexL( iPropertyArray, *iPropertyNameArray, aItem );  
       
  1767     User::LeaveIfError( aItem.GetNextInt( value ));
       
  1768     TL( property->Int32ValueL() == value );
       
  1769 
       
  1770     return KErrNone;
       
  1771     }
       
  1772 
       
  1773 // -----------------------------------------------------------------------------
       
  1774 // CMdETestScripter::Uint32ValueL
       
  1775 // -----------------------------------------------------------------------------
       
  1776 //
       
  1777 TInt CMdETestScripter::Uint32ValueL( CStifItemParser& aItem )
       
  1778     {
       
  1779     TInt value;
       
  1780     CMdEProperty* property = SanitizeArrayIndexL( iPropertyArray, *iPropertyNameArray, aItem );  
       
  1781     User::LeaveIfError( aItem.GetNextInt( value ));
       
  1782     TL( property->Uint32ValueL() == value );
       
  1783 
       
  1784     return KErrNone;
       
  1785     }
       
  1786 
       
  1787 // -----------------------------------------------------------------------------
       
  1788 // CMdETestScripter::Int64ValueL
       
  1789 // -----------------------------------------------------------------------------
       
  1790 //
       
  1791 TInt CMdETestScripter::Int64ValueL( CStifItemParser& aItem )
       
  1792     {
       
  1793     TInt value;
       
  1794     CMdEProperty* property = SanitizeArrayIndexL( iPropertyArray, *iPropertyNameArray, aItem );  
       
  1795     User::LeaveIfError( aItem.GetNextInt( value ));
       
  1796     TL( property->Int64ValueL() == value );
       
  1797 
       
  1798     return KErrNone;
       
  1799     }
       
  1800 
       
  1801 // -----------------------------------------------------------------------------
       
  1802 // CMdETestScripter::Real32ValueL
       
  1803 // -----------------------------------------------------------------------------
       
  1804 //
       
  1805 TInt CMdETestScripter::Real32ValueL( CStifItemParser& aItem )
       
  1806     {
       
  1807     TInt value;
       
  1808     CMdEProperty* property = SanitizeArrayIndexL( iPropertyArray, *iPropertyNameArray, aItem );  
       
  1809     User::LeaveIfError( aItem.GetNextInt( value ));
       
  1810     TL( property->Real32ValueL() == value );
       
  1811 
       
  1812     return KErrNone;
       
  1813     }
       
  1814 
       
  1815 // -----------------------------------------------------------------------------
       
  1816 // CMdETestScripter::Real64ValueL
       
  1817 // -----------------------------------------------------------------------------
       
  1818 //
       
  1819 TInt CMdETestScripter::Real64ValueL( CStifItemParser& aItem )
       
  1820     {
       
  1821     TInt value;
       
  1822     CMdEProperty* property = SanitizeArrayIndexL( iPropertyArray, *iPropertyNameArray, aItem );  
       
  1823     User::LeaveIfError( aItem.GetNextInt( value ));
       
  1824     TL( property->Real64ValueL() == value );
       
  1825 
       
  1826     return KErrNone;
       
  1827     }
       
  1828 
       
  1829 // -----------------------------------------------------------------------------
       
  1830 // CMdETestScripter::TimeValueL
       
  1831 // -----------------------------------------------------------------------------
       
  1832 //
       
  1833 TInt CMdETestScripter::TimeValueL( CStifItemParser& aItem )
       
  1834     {
       
  1835     TPtrC value;
       
  1836     CMdEProperty* property = SanitizeArrayIndexL( iPropertyArray, *iPropertyNameArray, aItem );  
       
  1837     User::LeaveIfError( aItem.GetNextString( value ));
       
  1838 
       
  1839     TTime time;
       
  1840     TL( time.Set( value ) == KErrNone );
       
  1841     TL( property->TimeValueL() == time );
       
  1842 
       
  1843     return KErrNone;
       
  1844     }
       
  1845 
       
  1846 // -----------------------------------------------------------------------------
       
  1847 // CMdETestScripter::TextValueL
       
  1848 // -----------------------------------------------------------------------------
       
  1849 //
       
  1850 TInt CMdETestScripter::TextValueL( CStifItemParser& aItem )
       
  1851     {
       
  1852     TPtrC value;
       
  1853 
       
  1854     CMdEProperty* property = SanitizeArrayIndexL( iPropertyArray, *iPropertyNameArray, aItem );  
       
  1855     aItem.SetParsingType( CStifItemParser::EQuoteStyleParsing );
       
  1856     User::LeaveIfError( aItem.GetNextString( value ));
       
  1857 
       
  1858     TL( value.Compare( property->TextValueL()) == 0 );
       
  1859 
       
  1860     return KErrNone;
       
  1861     }
       
  1862 
       
  1863 // -----------------------------------------------------------------------------
       
  1864 // CMdETestScripter::SetBoolValueL
       
  1865 // -----------------------------------------------------------------------------
       
  1866 //
       
  1867 TInt CMdETestScripter::SetBoolValueL( CStifItemParser& aItem )
       
  1868     {
       
  1869     TInt value;
       
  1870     CMdEProperty* property = SanitizeArrayIndexL( iPropertyArray, *iPropertyNameArray, aItem ); 
       
  1871     User::LeaveIfError( aItem.GetNextInt( value ));
       
  1872 
       
  1873     property->SetBoolValueL( value );
       
  1874 
       
  1875     return KErrNone;
       
  1876     }
       
  1877 
       
  1878 // -----------------------------------------------------------------------------
       
  1879 // CMdETestScripter::SetInt8ValueL
       
  1880 // -----------------------------------------------------------------------------
       
  1881 //
       
  1882 TInt CMdETestScripter::SetInt8ValueL( CStifItemParser& aItem )
       
  1883     {
       
  1884     TInt value;
       
  1885     CMdEProperty* property = SanitizeArrayIndexL( iPropertyArray, *iPropertyNameArray, aItem ); 
       
  1886     User::LeaveIfError( aItem.GetNextInt( value ));
       
  1887 
       
  1888     property->SetInt8ValueL( value );
       
  1889 
       
  1890     return KErrNone;
       
  1891     }
       
  1892 
       
  1893 // -----------------------------------------------------------------------------
       
  1894 // CMdETestScripter::SetUint8ValueL
       
  1895 // -----------------------------------------------------------------------------
       
  1896 //
       
  1897 TInt CMdETestScripter::SetUint8ValueL( CStifItemParser& aItem )
       
  1898     {
       
  1899     TInt value;
       
  1900     CMdEProperty* property = SanitizeArrayIndexL( iPropertyArray, *iPropertyNameArray, aItem ); 
       
  1901     User::LeaveIfError( aItem.GetNextInt( value ));
       
  1902     property->SetUint8ValueL( value );
       
  1903 
       
  1904     return KErrNone;
       
  1905     }
       
  1906 
       
  1907 // -----------------------------------------------------------------------------
       
  1908 // CMdETestScripter::SetInt16ValueL
       
  1909 // -----------------------------------------------------------------------------
       
  1910 //
       
  1911 TInt CMdETestScripter::SetInt16ValueL( CStifItemParser& aItem )
       
  1912     {
       
  1913     TInt value;
       
  1914     CMdEProperty* property = SanitizeArrayIndexL( iPropertyArray, *iPropertyNameArray, aItem ); 
       
  1915     User::LeaveIfError( aItem.GetNextInt( value ));
       
  1916     property->SetInt16ValueL( value );
       
  1917 
       
  1918     return KErrNone;
       
  1919     }
       
  1920 
       
  1921 // -----------------------------------------------------------------------------
       
  1922 // CMdETestScripter::SetUint16ValueL
       
  1923 // -----------------------------------------------------------------------------
       
  1924 //
       
  1925 TInt CMdETestScripter::SetUint16ValueL( CStifItemParser& aItem )
       
  1926     {
       
  1927     TInt value;
       
  1928     CMdEProperty* property = SanitizeArrayIndexL( iPropertyArray, *iPropertyNameArray, aItem );
       
  1929     User::LeaveIfError( aItem.GetNextInt( value ));
       
  1930     property->SetUint16ValueL( value );
       
  1931 
       
  1932     return KErrNone;
       
  1933     }
       
  1934 
       
  1935 // -----------------------------------------------------------------------------
       
  1936 // CMdETestScripter::SetInt32ValueL
       
  1937 // -----------------------------------------------------------------------------
       
  1938 //
       
  1939 TInt CMdETestScripter::SetInt32ValueL( CStifItemParser& aItem )
       
  1940     {
       
  1941     TInt value;
       
  1942     CMdEProperty* property = SanitizeArrayIndexL( iPropertyArray, *iPropertyNameArray, aItem ); 
       
  1943     User::LeaveIfError( aItem.GetNextInt( value ));
       
  1944     property->SetInt32ValueL( value );
       
  1945 
       
  1946     return KErrNone;
       
  1947     }
       
  1948 
       
  1949 // -----------------------------------------------------------------------------
       
  1950 // CMdETestScripter::SetUint32ValueL
       
  1951 // -----------------------------------------------------------------------------
       
  1952 //
       
  1953 TInt CMdETestScripter::SetUint32ValueL( CStifItemParser& aItem )
       
  1954     {
       
  1955     TInt value;
       
  1956     CMdEProperty* property = SanitizeArrayIndexL( iPropertyArray, *iPropertyNameArray, aItem ); 
       
  1957     User::LeaveIfError( aItem.GetNextInt( value ));
       
  1958     property->SetUint32ValueL( value );
       
  1959 
       
  1960     return KErrNone;
       
  1961     }
       
  1962 
       
  1963 // -----------------------------------------------------------------------------
       
  1964 // CMdETestScripter::SetInt64ValueL
       
  1965 // -----------------------------------------------------------------------------
       
  1966 //
       
  1967 TInt CMdETestScripter::SetInt64ValueL( CStifItemParser& aItem )
       
  1968     {
       
  1969     TInt value;
       
  1970     CMdEProperty* property = SanitizeArrayIndexL( iPropertyArray, *iPropertyNameArray, aItem ); 
       
  1971     User::LeaveIfError( aItem.GetNextInt( value ));
       
  1972 
       
  1973     property->SetInt64ValueL( value );
       
  1974 
       
  1975     return KErrNone;
       
  1976     }
       
  1977 
       
  1978 // -----------------------------------------------------------------------------
       
  1979 // CMdETestScripter::SetReal32ValueL
       
  1980 // -----------------------------------------------------------------------------
       
  1981 //
       
  1982 TInt CMdETestScripter::SetReal32ValueL( CStifItemParser& aItem )
       
  1983     {
       
  1984     TInt value;
       
  1985     CMdEProperty* property = SanitizeArrayIndexL( iPropertyArray, *iPropertyNameArray, aItem );
       
  1986     User::LeaveIfError( aItem.GetNextInt( value ));
       
  1987     property->SetReal32ValueL( value );
       
  1988 
       
  1989     return KErrNone;
       
  1990     }
       
  1991 
       
  1992 // -----------------------------------------------------------------------------
       
  1993 // CMdETestScripter::SetReal64ValueL
       
  1994 // -----------------------------------------------------------------------------
       
  1995 //
       
  1996 TInt CMdETestScripter::SetReal64ValueL( CStifItemParser& aItem )
       
  1997     {
       
  1998     TInt value;
       
  1999     CMdEProperty* property = SanitizeArrayIndexL( iPropertyArray, *iPropertyNameArray, aItem ); 
       
  2000     User::LeaveIfError( aItem.GetNextInt( value ));
       
  2001 
       
  2002     property->SetReal64ValueL( value );
       
  2003 
       
  2004     return KErrNone;
       
  2005     }
       
  2006 
       
  2007 // -----------------------------------------------------------------------------
       
  2008 // CMdETestScripter::SetTimeValueL
       
  2009 // -----------------------------------------------------------------------------
       
  2010 //
       
  2011 TInt CMdETestScripter::SetTimeValueL( CStifItemParser& aItem )
       
  2012     {
       
  2013     TPtrC value;
       
  2014     CMdEProperty* property = SanitizeArrayIndexL( iPropertyArray, *iPropertyNameArray, aItem );
       
  2015     User::LeaveIfError( aItem.GetNextString( value ));
       
  2016     TTime time;
       
  2017     TL( time.Set( value ) == KErrNone );
       
  2018     property->SetTimeValueL( time );
       
  2019     return KErrNone;
       
  2020     }
       
  2021 
       
  2022 // -----------------------------------------------------------------------------
       
  2023 // CMdETestScripter::SetTextValueL
       
  2024 // -----------------------------------------------------------------------------
       
  2025 //
       
  2026 TInt CMdETestScripter::SetTextValueL( CStifItemParser& aItem )
       
  2027     {
       
  2028     TPtrC value;
       
  2029     CMdEProperty* property = SanitizeArrayIndexL( iPropertyArray, *iPropertyNameArray, aItem );
       
  2030     aItem.SetParsingType( CStifItemParser::EQuoteStyleParsing );
       
  2031     User::LeaveIfError( aItem.GetNextString( value ));
       
  2032     property->SetTextValueL( value );
       
  2033 
       
  2034     return KErrNone;
       
  2035     }
       
  2036 
       
  2037 // -----------------------------------------------------------------------------
       
  2038 // CMdETestScripter::RemovePropertyL
       
  2039 // -----------------------------------------------------------------------------
       
  2040 //
       
  2041 TInt CMdETestScripter::RemovePropertyL( CStifItemParser& aItem )
       
  2042     {
       
  2043     TPtrC propertyDefName;
       
  2044 
       
  2045     CMdEObject* object = SanitizeArrayIndexL( iObjectArray, *iObjectNameArray, aItem );
       
  2046     User::LeaveIfError( aItem.GetNextString( propertyDefName ));
       
  2047 
       
  2048     CMdEPropertyDef& propertyDef = object->Def().GetPropertyDefL( propertyDefName );
       
  2049     CMdEProperty* property = NULL;
       
  2050     TInt propIndex = object->Property( propertyDef, property );
       
  2051     TL( propIndex );
       
  2052     object->RemoveProperty( propIndex );
       
  2053 
       
  2054     return KErrNone;
       
  2055     }
       
  2056 
       
  2057 // -----------------------------------------------------------------------------
       
  2058 // CMdETestScripter::FreeTextCountL
       
  2059 // -----------------------------------------------------------------------------
       
  2060 //
       
  2061 TInt CMdETestScripter::FreeTextCountL( CStifItemParser& aItem )
       
  2062     {
       
  2063     TInt count;
       
  2064 
       
  2065     CMdEObject* object = SanitizeArrayIndexL( iObjectArray, *iObjectNameArray, aItem );
       
  2066     User::LeaveIfError( aItem.GetNextInt( count ));
       
  2067 
       
  2068     TInt state = object->FreeTextCount();
       
  2069     TL( count == state );
       
  2070 
       
  2071     return KErrNone;
       
  2072     }
       
  2073 
       
  2074 // -----------------------------------------------------------------------------
       
  2075 // CMdETestScripter::FreeTextL
       
  2076 // -----------------------------------------------------------------------------
       
  2077 //
       
  2078 TInt CMdETestScripter::FreeTextL( CStifItemParser& aItem )
       
  2079     {
       
  2080     TInt index;
       
  2081     TPtrC text;
       
  2082 
       
  2083     CMdEObject* object = SanitizeArrayIndexL( iObjectArray, *iObjectNameArray, aItem );
       
  2084     User::LeaveIfError( aItem.GetNextInt( index ));
       
  2085     User::LeaveIfError( aItem.GetNextString( text ));
       
  2086 
       
  2087     TPtrC state = object->FreeText( index );
       
  2088     TL( text.Compare( state ) == 0 );
       
  2089 
       
  2090     return KErrNone;
       
  2091     }
       
  2092 
       
  2093 // -----------------------------------------------------------------------------
       
  2094 // CMdETestScripter::FreeTextIndexL
       
  2095 // -----------------------------------------------------------------------------
       
  2096 //
       
  2097 TInt CMdETestScripter::FreeTextIndexL( CStifItemParser& aItem )
       
  2098     {
       
  2099     TInt index;
       
  2100     TPtrC value;
       
  2101 
       
  2102     CMdEObject* object = SanitizeArrayIndexL( iObjectArray, *iObjectNameArray, aItem );
       
  2103     User::LeaveIfError( aItem.GetNextInt( index ));
       
  2104     User::LeaveIfError( aItem.GetNextString( value ));
       
  2105 
       
  2106     TInt state = object->FreeTextIndex( value );
       
  2107     TA1L( state, index );
       
  2108 
       
  2109     return KErrNone;
       
  2110     }
       
  2111 
       
  2112 // -----------------------------------------------------------------------------
       
  2113 // CMdETestScripter::AddFreeTextL
       
  2114 // -----------------------------------------------------------------------------
       
  2115 //
       
  2116 TInt CMdETestScripter::AddFreeTextL( CStifItemParser& aItem )
       
  2117     {
       
  2118     TPtrC value;
       
  2119 
       
  2120     CMdEObject* object = SanitizeArrayIndexL( iObjectArray, *iObjectNameArray, aItem );
       
  2121     User::LeaveIfError( aItem.GetNextString( value ));
       
  2122 
       
  2123     object->AddFreeTextL( value );
       
  2124 
       
  2125     return KErrNone;
       
  2126     }
       
  2127 
       
  2128 // -----------------------------------------------------------------------------
       
  2129 // CMdETestScripter::RemoveFreeTextL
       
  2130 // -----------------------------------------------------------------------------
       
  2131 //
       
  2132 TInt CMdETestScripter::RemoveFreeTextL( CStifItemParser& aItem )
       
  2133     {
       
  2134     TInt index;
       
  2135 
       
  2136     CMdEObject* object = SanitizeArrayIndexL( iObjectArray, *iObjectNameArray, aItem );
       
  2137     User::LeaveIfError( aItem.GetNextInt( index ));
       
  2138 
       
  2139     object->RemoveFreeText( index );
       
  2140 
       
  2141     return KErrNone;
       
  2142     }
       
  2143 
       
  2144 // -----------------------------------------------------------------------------
       
  2145 // CMdETestScripter::MovePropertiesL
       
  2146 // -----------------------------------------------------------------------------
       
  2147 //
       
  2148 TInt CMdETestScripter::MovePropertiesL( CStifItemParser& aItem )
       
  2149     {
       
  2150     CMdEObject* sourceObj = SanitizeArrayIndexL( iObjectArray, *iObjectNameArray, aItem );
       
  2151     CMdEObject* targetObj = SanitizeArrayIndexL( iObjectArray, *iObjectNameArray, aItem );
       
  2152 
       
  2153     targetObj->MovePropertiesL( *sourceObj );
       
  2154 
       
  2155     return KErrNone;
       
  2156     }
       
  2157 
       
  2158 // -----------------------------------------------------------------------------
       
  2159 // CMdETestScripter::NewRelationL
       
  2160 // -----------------------------------------------------------------------------
       
  2161 //
       
  2162 TInt CMdETestScripter::NewRelationL( CStifItemParser& aItem )
       
  2163     {
       
  2164     TPtrC name;
       
  2165     User::LeaveIfError( aItem.GetNextString( name ));  
       
  2166     TPtrC relationString;
       
  2167     TInt parameter;
       
  2168     TInt mode;
       
  2169 
       
  2170     CMdEObject* sourceObj = SanitizeArrayIndexL( iObjectArray, *iObjectNameArray, aItem );
       
  2171     CMdERelationDef* relationDef = SanitizeArrayIndexL( iRelationDefArray, *iRelationDefNameArray, aItem );
       
  2172     CMdEObject* targetObj = SanitizeArrayIndexL( iObjectArray, *iObjectNameArray, aItem );
       
  2173     User::LeaveIfError( aItem.GetNextInt( parameter ));
       
  2174     User::LeaveIfError( aItem.GetNextInt( mode ));
       
  2175 
       
  2176     CMdERelation* relation = NULL;
       
  2177 
       
  2178     if ( mode == KL )
       
  2179         {
       
  2180         relation = iMdeSession->NewRelationL( *relationDef, sourceObj->Id(), targetObj->Id(), parameter );
       
  2181         }
       
  2182     else if ( mode == KLC )
       
  2183         {
       
  2184         relation = iMdeSession->NewRelationLC( *relationDef, sourceObj->Id(), targetObj->Id(), parameter );
       
  2185         CleanupStack::Pop( relation );
       
  2186         }
       
  2187     else
       
  2188         {
       
  2189         User::Leave( KErrArgument );
       
  2190         }
       
  2191 
       
  2192     TL( relation );
       
  2193     iRelationArray.Append( relation );
       
  2194     AppendNameL( iRelationNameArray, name );
       
  2195 
       
  2196     return KErrNone;
       
  2197     }
       
  2198 
       
  2199 // -----------------------------------------------------------------------------
       
  2200 // CMdETestScripter::AddRelationL
       
  2201 // -----------------------------------------------------------------------------
       
  2202 //
       
  2203 TInt CMdETestScripter::AddRelationL( CStifItemParser& aItem )
       
  2204     {
       
  2205     CMdERelation* relation = SanitizeArrayIndexL( iRelationArray, *iRelationNameArray, aItem );
       
  2206 
       
  2207     TItemId id = iMdeSession->AddRelationL( *relation );
       
  2208     TL( id != KNoId );
       
  2209     TL( relation->Id() == id );
       
  2210 
       
  2211     return KErrNone;
       
  2212     }
       
  2213 
       
  2214 // -----------------------------------------------------------------------------
       
  2215 // CMdETestScripter::LeftObjectIdL
       
  2216 // -----------------------------------------------------------------------------
       
  2217 //
       
  2218 TInt CMdETestScripter::LeftObjectIdL( CStifItemParser& aItem )
       
  2219     {
       
  2220     CMdERelation* relation = SanitizeArrayIndexL( iRelationArray, *iRelationNameArray, aItem );
       
  2221     CMdEObject* object = SanitizeArrayIndexL( iObjectArray, *iObjectNameArray, aItem );
       
  2222 
       
  2223     TL( relation->LeftObjectId() == object->Id() );
       
  2224 
       
  2225     return KErrNone;
       
  2226     }
       
  2227 
       
  2228 // -----------------------------------------------------------------------------
       
  2229 // CMdETestScripter::RightObjectIdL
       
  2230 // -----------------------------------------------------------------------------
       
  2231 //
       
  2232 TInt CMdETestScripter::RightObjectIdL( CStifItemParser& aItem )
       
  2233     {
       
  2234     CMdERelation* relation = SanitizeArrayIndexL( iRelationArray, *iRelationNameArray, aItem );
       
  2235     CMdEObject* object = SanitizeArrayIndexL( iObjectArray, *iObjectNameArray, aItem );
       
  2236 
       
  2237     TL( relation->RightObjectId() == object->Id() );
       
  2238 
       
  2239     return KErrNone;
       
  2240     }
       
  2241 
       
  2242 // -----------------------------------------------------------------------------
       
  2243 // CMdETestScripter::ParameterL
       
  2244 // -----------------------------------------------------------------------------
       
  2245 //
       
  2246 TInt CMdETestScripter::ParameterL( CStifItemParser& aItem )
       
  2247     {
       
  2248     TInt parameter;
       
  2249 
       
  2250     CMdERelation* relation = SanitizeArrayIndexL( iRelationArray, *iRelationNameArray, aItem );
       
  2251     User::LeaveIfError( aItem.GetNextInt( parameter ));
       
  2252 
       
  2253     TL( relation->Parameter() == parameter );
       
  2254 
       
  2255     return KErrNone;
       
  2256     }
       
  2257 
       
  2258 // -----------------------------------------------------------------------------
       
  2259 // CMdETestScripter::SetParameterL
       
  2260 // -----------------------------------------------------------------------------
       
  2261 //
       
  2262 TInt CMdETestScripter::SetParameterL( CStifItemParser& aItem )
       
  2263     {
       
  2264     TInt parameter;
       
  2265 
       
  2266     CMdERelation* relation = SanitizeArrayIndexL( iRelationArray, *iRelationNameArray, aItem );
       
  2267     User::LeaveIfError( aItem.GetNextInt( parameter ));
       
  2268 
       
  2269     relation->SetParameter( parameter );
       
  2270 
       
  2271     return KErrNone;
       
  2272     }
       
  2273 
       
  2274 // -----------------------------------------------------------------------------
       
  2275 // CMdETestScripter::SetLeftObjectIdL
       
  2276 // -----------------------------------------------------------------------------
       
  2277 //
       
  2278 TInt CMdETestScripter::SetLeftObjectIdL( CStifItemParser& aItem )
       
  2279     {
       
  2280     CMdERelation* relation = SanitizeArrayIndexL( iRelationArray, *iRelationNameArray, aItem );
       
  2281     CMdEObject* object = SanitizeArrayIndexL( iObjectArray, *iObjectNameArray, aItem );
       
  2282 
       
  2283     relation->SetLeftObjectIdL( object->Id() );
       
  2284 
       
  2285     return KErrNone;
       
  2286     }
       
  2287 
       
  2288 // -----------------------------------------------------------------------------
       
  2289 // CMdETestScripter::SetRightObjectIdL
       
  2290 // -----------------------------------------------------------------------------
       
  2291 //
       
  2292 TInt CMdETestScripter::SetRightObjectIdL( CStifItemParser& aItem )
       
  2293     {
       
  2294     CMdERelation* relation = SanitizeArrayIndexL( iRelationArray, *iRelationNameArray, aItem );
       
  2295     CMdEObject* object = SanitizeArrayIndexL( iObjectArray, *iObjectNameArray, aItem );
       
  2296 
       
  2297     relation->SetRightObjectIdL( object->Id() );
       
  2298 
       
  2299     return KErrNone;
       
  2300     }
       
  2301 
       
  2302 // -----------------------------------------------------------------------------
       
  2303 // CMdETestScripter::LastModifiedDateL
       
  2304 // -----------------------------------------------------------------------------
       
  2305 //
       
  2306 TInt CMdETestScripter::LastModifiedDateL( CStifItemParser& aItem )
       
  2307     {
       
  2308     TPtrC value;
       
  2309 
       
  2310     CMdERelation* relation = SanitizeArrayIndexL( iRelationArray, *iRelationNameArray, aItem );
       
  2311     User::LeaveIfError( aItem.GetNextString( value ));
       
  2312 
       
  2313     TTime time;
       
  2314     TL( time.Set( value ) == KErrNone );
       
  2315 
       
  2316     TL( relation->LastModifiedDate() == time );
       
  2317 
       
  2318     return KErrNone;
       
  2319     }
       
  2320 
       
  2321 // -----------------------------------------------------------------------------
       
  2322 // CMdETestScripter::SetLastModifiedDateL
       
  2323 // -----------------------------------------------------------------------------
       
  2324 //
       
  2325 TInt CMdETestScripter::SetLastModifiedDateL( CStifItemParser& aItem )
       
  2326     {
       
  2327     TPtrC value;
       
  2328 
       
  2329     CMdERelation* relation = SanitizeArrayIndexL( iRelationArray, *iRelationNameArray, aItem );
       
  2330     User::LeaveIfError( aItem.GetNextString( value ));
       
  2331 
       
  2332     TTime time;
       
  2333     TL( time.Set( value ) == KErrNone );
       
  2334 
       
  2335     relation->SetLastModifiedDate( time );
       
  2336 
       
  2337     return KErrNone;
       
  2338     }
       
  2339 
       
  2340 // -----------------------------------------------------------------------------
       
  2341 // CMdETestScripter::GetRelationL
       
  2342 // -----------------------------------------------------------------------------
       
  2343 //
       
  2344 TInt CMdETestScripter::GetRelationL( CStifItemParser& aItem )
       
  2345     {
       
  2346     TPtrC name;
       
  2347     User::LeaveIfError( aItem.GetNextString( name ));      
       
  2348     
       
  2349     CMdERelation* relation = SanitizeArrayIndexL( iRelationArray, *iRelationNameArray, aItem );
       
  2350 
       
  2351     CMdERelation* newRelation = iMdeSession->GetRelationL( relation->Id());
       
  2352 
       
  2353     TL( newRelation );
       
  2354     iRelationArray.Append( newRelation );
       
  2355     AppendNameL( iRelationNameArray, name );
       
  2356 
       
  2357     return KErrNone;
       
  2358     }
       
  2359 
       
  2360 // -----------------------------------------------------------------------------
       
  2361 // CMdETestScripter::UpdateRelationL
       
  2362 // -----------------------------------------------------------------------------
       
  2363 //
       
  2364 TInt CMdETestScripter::UpdateRelationL( CStifItemParser& aItem )
       
  2365     {
       
  2366     CMdERelation* relation = SanitizeArrayIndexL( iRelationArray, *iRelationNameArray, aItem );
       
  2367 
       
  2368     TItemId id = iMdeSession->UpdateRelationL( *relation );
       
  2369     TL( id != KNoId );
       
  2370 
       
  2371     return KErrNone;
       
  2372     }
       
  2373 
       
  2374 // -----------------------------------------------------------------------------
       
  2375 // CMdETestScripter::RemoveRelationL
       
  2376 // -----------------------------------------------------------------------------
       
  2377 //
       
  2378 TInt CMdETestScripter::RemoveRelationL( CStifItemParser& aItem )
       
  2379     {
       
  2380     CMdERelation* relation = SanitizeArrayIndexL( iRelationArray, *iRelationNameArray, aItem );
       
  2381 
       
  2382     TItemId id = iMdeSession->RemoveRelationL( relation->Id() );
       
  2383     TL( id != KNoId );
       
  2384 
       
  2385     return KErrNone;
       
  2386     }
       
  2387 
       
  2388 // -----------------------------------------------------------------------------
       
  2389 // CMdETestScripter::RemoveRelationsL
       
  2390 // -----------------------------------------------------------------------------
       
  2391 //
       
  2392 TInt CMdETestScripter::RemoveRelationsL( CStifItemParser& aItem )
       
  2393     {
       
  2394     TInt mode;
       
  2395     TInt relIndex;
       
  2396     TInt count;
       
  2397     RArray<TItemId> relationIdArray;
       
  2398 
       
  2399     User::LeaveIfError( aItem.GetNextInt( mode ));
       
  2400     relIndex = GetRelationIndexL( aItem );
       
  2401 
       
  2402     User::LeaveIfError( aItem.GetNextInt( count ));
       
  2403     TL( iRelationArray.Count() > relIndex + count - 1 );
       
  2404 
       
  2405     for ( TInt i = 0; i < count; ++i )
       
  2406         {
       
  2407         relationIdArray.Append( iRelationArray[ relIndex + i ]->Id() );
       
  2408         }
       
  2409 
       
  2410     if ( mode == KSync )
       
  2411         {
       
  2412         RArray<TItemId> successful;
       
  2413 
       
  2414         iMdeSession->RemoveRelationsL( relationIdArray, successful );
       
  2415         }
       
  2416     else if ( mode == KAsync )
       
  2417         {
       
  2418         iItemCount = count;
       
  2419         TEventIf event( TEventIf::ESetEvent, TName( KMdERelationsAsyncRemoved ) );
       
  2420         iAsyncHandler->Start( this, event );
       
  2421         iMdEDataBuf.Close();// make sure the last async request buffer cleaned before using again.
       
  2422         iMdeSession->RemoveRelationsAsyncL( relationIdArray, iAsyncHandler->iStatus, iMdEDataBuf );
       
  2423         }
       
  2424     else
       
  2425         {
       
  2426         User::Leave( KErrArgument );
       
  2427         }
       
  2428 
       
  2429     return KErrNone;
       
  2430     }
       
  2431 
       
  2432 // -----------------------------------------------------------------------------
       
  2433 // CMdETestScripter::NewEventL
       
  2434 // -----------------------------------------------------------------------------
       
  2435 //
       
  2436 TInt CMdETestScripter::NewEventL( CStifItemParser& aItem )
       
  2437     {
       
  2438     TPtrC name;
       
  2439     User::LeaveIfError( aItem.GetNextString( name ));  
       
  2440 
       
  2441     TPtrC eventSource;
       
  2442     TPtrC eventParticipant;
       
  2443     TPtrC value;
       
  2444     TInt mode;
       
  2445 
       
  2446     CMdEObject* object = SanitizeArrayIndexL( iObjectArray, *iObjectNameArray, aItem );
       
  2447     CMdEEventDef* eventDef = SanitizeArrayIndexL( iEventDefArray, *iEventDefNameArray, aItem );
       
  2448     
       
  2449     User::LeaveIfError( aItem.GetNextString( eventSource ));
       
  2450     User::LeaveIfError( aItem.GetNextString( eventParticipant ));
       
  2451     User::LeaveIfError( aItem.GetNextString( value ));
       
  2452     User::LeaveIfError( aItem.GetNextInt( mode ));
       
  2453 
       
  2454     TTime time;
       
  2455     TL( time.Set( value ) == KErrNone );
       
  2456     CMdEEvent* event = NULL;
       
  2457 
       
  2458     if ( mode == KL )
       
  2459         {
       
  2460         event = iMdeSession->NewEventL(
       
  2461             *eventDef, object->Id(),
       
  2462             time, &eventSource, &eventParticipant );
       
  2463         }
       
  2464     else if ( mode == KLC )
       
  2465         {
       
  2466         event = iMdeSession->NewEventLC(
       
  2467             *eventDef, object->Id(),
       
  2468             time, &eventSource, &eventParticipant );
       
  2469         CleanupStack::Pop( event );
       
  2470         }
       
  2471     else
       
  2472         {
       
  2473         User::Leave( KErrArgument );
       
  2474         }
       
  2475 
       
  2476     TL( event );
       
  2477     iEventArray.Append( event );
       
  2478     AppendNameL( iEventNameArray, name );
       
  2479 
       
  2480     return KErrNone;
       
  2481     }
       
  2482 
       
  2483 // -----------------------------------------------------------------------------
       
  2484 // CMdETestScripter::AddEventL
       
  2485 // -----------------------------------------------------------------------------
       
  2486 //
       
  2487 TInt CMdETestScripter::AddEventL( CStifItemParser& aItem )
       
  2488     {
       
  2489     CMdEEvent* event = SanitizeArrayIndexL( iEventArray, *iEventNameArray, aItem );
       
  2490 
       
  2491     TItemId id = iMdeSession->AddEventL( *event );
       
  2492     TL( id != KNoId );
       
  2493     TL( event->Id() == id );
       
  2494 
       
  2495     return KErrNone;
       
  2496     }
       
  2497 
       
  2498 // -----------------------------------------------------------------------------
       
  2499 // CMdETestScripter::ObjectIdL
       
  2500 // -----------------------------------------------------------------------------
       
  2501 //
       
  2502 TInt CMdETestScripter::ObjectIdL( CStifItemParser& aItem )
       
  2503     {
       
  2504     CMdEEvent* event = SanitizeArrayIndexL( iEventArray, *iEventNameArray, aItem );
       
  2505     CMdEObject* object = SanitizeArrayIndexL( iObjectArray, *iObjectNameArray, aItem );
       
  2506 
       
  2507     TL( event->ObjectId() == object->Id() );
       
  2508 
       
  2509     return KErrNone;
       
  2510     }
       
  2511 
       
  2512 // -----------------------------------------------------------------------------
       
  2513 // CMdETestScripter::TimeL
       
  2514 // -----------------------------------------------------------------------------
       
  2515 //
       
  2516 TInt CMdETestScripter::TimeL( CStifItemParser& aItem )
       
  2517     {
       
  2518     TPtrC value;
       
  2519 
       
  2520     CMdEEvent* event = SanitizeArrayIndexL( iEventArray, *iEventNameArray, aItem );
       
  2521     User::LeaveIfError( aItem.GetNextString( value ));
       
  2522 
       
  2523     TTime time;
       
  2524     TL( time.Set( value ) == KErrNone );
       
  2525 
       
  2526     TL( event->Time() == time );
       
  2527 
       
  2528     return KErrNone;
       
  2529     }
       
  2530 
       
  2531 // -----------------------------------------------------------------------------
       
  2532 // CMdETestScripter::SourceL
       
  2533 // -----------------------------------------------------------------------------
       
  2534 //
       
  2535 TInt CMdETestScripter::SourceL( CStifItemParser& aItem )
       
  2536     {
       
  2537     TPtrC source;
       
  2538     TInt expected;
       
  2539 
       
  2540     CMdEEvent* event = SanitizeArrayIndexL( iEventArray, *iEventNameArray, aItem );
       
  2541     User::LeaveIfError( aItem.GetNextString( source ));
       
  2542     User::LeaveIfError( aItem.GetNextInt( expected ));
       
  2543 
       
  2544     TInt result = event->Source()->Compare( source );
       
  2545     TL( result == expected );
       
  2546 
       
  2547     return KErrNone;
       
  2548     }
       
  2549 
       
  2550 // -----------------------------------------------------------------------------
       
  2551 // CMdETestScripter::ParticipantL
       
  2552 // -----------------------------------------------------------------------------
       
  2553 //
       
  2554 TInt CMdETestScripter::ParticipantL( CStifItemParser& aItem )
       
  2555     {
       
  2556     TPtrC participant;
       
  2557     TInt expected;
       
  2558 
       
  2559     CMdEEvent* event = SanitizeArrayIndexL( iEventArray, *iEventNameArray, aItem );
       
  2560     User::LeaveIfError( aItem.GetNextString( participant ));
       
  2561     User::LeaveIfError( aItem.GetNextInt( expected ));
       
  2562 
       
  2563     TInt result = event->Participant()->Compare( participant );
       
  2564     TL( result == expected );
       
  2565 
       
  2566     return KErrNone;
       
  2567     }
       
  2568 
       
  2569 // -----------------------------------------------------------------------------
       
  2570 // CMdETestScripter::GetEventL
       
  2571 // -----------------------------------------------------------------------------
       
  2572 //
       
  2573 TInt CMdETestScripter::GetEventL( CStifItemParser& aItem )
       
  2574     {
       
  2575     TPtrC name;
       
  2576     User::LeaveIfError( aItem.GetNextString( name ));    
       
  2577     CMdEEvent* event = SanitizeArrayIndexL( iEventArray, *iEventNameArray, aItem );
       
  2578 
       
  2579     CMdEEvent* newEvent = iMdeSession->GetEventL( event->Id());
       
  2580 
       
  2581     TL( event );
       
  2582     iEventArray.Append( newEvent );
       
  2583     AppendNameL( iEventNameArray, name );
       
  2584     return KErrNone;
       
  2585     }
       
  2586 
       
  2587 // -----------------------------------------------------------------------------
       
  2588 // CMdETestScripter::RemoveEventL
       
  2589 // -----------------------------------------------------------------------------
       
  2590 //
       
  2591 TInt CMdETestScripter::RemoveEventL( CStifItemParser& aItem )
       
  2592     {
       
  2593     CMdEEvent* event = SanitizeArrayIndexL( iEventArray, *iEventNameArray, aItem );
       
  2594     TItemId id = iMdeSession->RemoveEventL( event->Id() );
       
  2595     TL( id != KNoId );
       
  2596 
       
  2597     return KErrNone;
       
  2598     }
       
  2599 
       
  2600 // -----------------------------------------------------------------------------
       
  2601 // CMdETestScripter::RemoveEventsL
       
  2602 // -----------------------------------------------------------------------------
       
  2603 //
       
  2604 TInt CMdETestScripter::RemoveEventsL( CStifItemParser& aItem )
       
  2605     {
       
  2606     TInt mode;
       
  2607     TInt eventIndex;
       
  2608     TInt count;
       
  2609     RArray<TItemId> successful;
       
  2610     RArray<TItemId> eventIdArray;
       
  2611 
       
  2612     User::LeaveIfError( aItem.GetNextInt( mode ));
       
  2613     eventIndex = GetEventIndexL( aItem );
       
  2614     User::LeaveIfError( eventIndex );
       
  2615     TL( iEventArray.Count() > eventIndex );
       
  2616     User::LeaveIfError( aItem.GetNextInt( count ));
       
  2617     TL( iEventArray.Count() > eventIndex + count - 1 );
       
  2618 
       
  2619     for ( TInt i = 0; i < count; ++i )
       
  2620         {
       
  2621         eventIdArray.Append( iEventArray[ eventIndex + i ]->Id() );
       
  2622         }
       
  2623 
       
  2624     if ( mode == KSync )
       
  2625         {
       
  2626         iMdeSession->RemoveEventsL( eventIdArray, successful );
       
  2627         }
       
  2628     else if ( mode == KAsync )
       
  2629         {
       
  2630         iItemCount = count;
       
  2631         TEventIf event( TEventIf::ESetEvent, TName( KMdEEventsAsyncRemoved ) );
       
  2632         iAsyncHandler->Start( this, event );
       
  2633         iMdEDataBuf.Close();// make sure the last async request buffer cleaned before using again.
       
  2634         iMdeSession->RemoveEventsAsyncL( eventIdArray, iAsyncHandler->iStatus, iMdEDataBuf );
       
  2635         }
       
  2636     else
       
  2637         {
       
  2638         User::Leave( KErrArgument );
       
  2639         }
       
  2640 
       
  2641     successful.Reset();
       
  2642     eventIdArray.Reset();
       
  2643 
       
  2644     return KErrNone;
       
  2645     }
       
  2646 
       
  2647 // End of File