creator/src/creator_logelement.cpp
branchRCL_3
changeset 60 6646c35e558c
parent 50 9b2cffad4b5e
equal deleted inserted replaced
50:9b2cffad4b5e 60:6646c35e558c
    43     iIsCommandElement = ETrue;
    43     iIsCommandElement = ETrue;
    44     }
    44     }
    45 /*
    45 /*
    46  * 
    46  * 
    47  */
    47  */
    48 
       
    49 void CCreatorLogElement::AsyncExecuteCommandL()
       
    50     {
       
    51     const CCreatorScriptAttribute* amountAttr = FindAttributeByName(KAmount);
       
    52     TInt logAmount = 1;    
       
    53     if( amountAttr )
       
    54         {
       
    55         logAmount = ConvertStrToIntL(amountAttr->Value());
       
    56         }
       
    57     // Get 'fields' element 
       
    58     CCreatorScriptElement* fieldsElement = FindSubElement(KFields);
       
    59     if( fieldsElement && fieldsElement->SubElements().Count() > 0 )
       
    60         {
       
    61         // Get sub-elements
       
    62         const RPointerArray<CCreatorScriptElement>& fields = fieldsElement->SubElements();        
       
    63         // Create log entries, the amount of entries is defined by logAmount:
       
    64         if( iLoopIndex < logAmount )
       
    65             {
       
    66             TInt direction = -1;
       
    67             CLogsParameters* param = new (ELeave) CLogsParameters;
       
    68             CleanupStack::PushL(param);
       
    69             
       
    70             for( TInt i = 0; i < fields.Count(); ++i )
       
    71                 {
       
    72                 CCreatorScriptElement* field = fields[i];
       
    73                 TPtrC elemName = field->Name();
       
    74                 TPtrC elemContent = field->Content();
       
    75                 const CCreatorScriptAttribute* randomAttr = field->FindAttributeByName(KRandomLength);
       
    76                 const CCreatorScriptAttribute* increaseAttr = field->FindAttributeByName(KIncrease);
       
    77                 TBool increase( EFalse );
       
    78                 if ( increaseAttr )
       
    79                     {
       
    80                     increase = ConvertStrToBooleanL( increaseAttr->Value() );
       
    81                     }
       
    82                 
       
    83                 if( elemName == KDirection )
       
    84                     {
       
    85                     direction = GetLogCommandL(elemContent, randomAttr || elemContent.Length() == 0); 
       
    86                     }
       
    87                 else if( elemName == KDuration )
       
    88                     {
       
    89                     if( randomAttr || elemContent.Length() == 0 )
       
    90                         {
       
    91                         param->iDuration = iEngine->RandomNumber(7200);
       
    92                         }
       
    93                     else
       
    94                         {
       
    95                         param->iDuration = ConvertStrToIntL(elemContent);
       
    96                         }
       
    97                     }
       
    98                 else if( elemName == KPhonenumber )
       
    99                     {
       
   100                     if( randomAttr || elemContent.Length() == 0 )
       
   101                         {
       
   102                         SetContentToTextParamL(param->iPhoneNumber, iEngine->RandomString(CCreatorEngine::EPhoneNumber));
       
   103                         }
       
   104                     else
       
   105                         {
       
   106                         if ( increase )
       
   107                             {
       
   108                             delete param->iPhoneNumber;
       
   109                             param->iPhoneNumber = NULL;
       
   110                             param->iPhoneNumber = HBufC::NewL( elemContent.Length() + 3 );
       
   111                             IncreasePhoneNumL( elemContent, iLoopIndex, param->iPhoneNumber );
       
   112                             }
       
   113                         else
       
   114                             {
       
   115                             SetContentToTextParamL(param->iPhoneNumber, elemContent);
       
   116                             }
       
   117                         }                    
       
   118                     }
       
   119                 else if( elemName == KDatetime )
       
   120                     {
       
   121                     if( randomAttr || elemContent.Length() == 0 )
       
   122                         {
       
   123                         param->iEventTime = iEngine->RandomTime(iEngine->RandomDate(CCreatorEngine::EDatePast), CCreatorEngine::EDatePast); 
       
   124                         }
       
   125                     else
       
   126                         {
       
   127                         param->iEventTime = ConvertToDateTimeL(elemContent);
       
   128                         }
       
   129                     }
       
   130                 }
       
   131             
       
   132             if( direction == -1 )
       
   133                 {
       
   134                 direction = GetLogCommandL(KEmpty, ETrue); 
       
   135                 }
       
   136             iEngine->AppendToCommandArrayL(direction, param);
       
   137             CleanupStack::Pop(); // param
       
   138             StartNextLoop();
       
   139             }
       
   140         else
       
   141             {
       
   142             AsyncCommandFinished();
       
   143             }
       
   144         }
       
   145     else
       
   146         {
       
   147         if( iLoopIndex < logAmount )
       
   148             {
       
   149             iEngine->AppendToCommandArrayL(GetLogCommandL(KEmpty, ETrue), 0, 1);
       
   150             StartNextLoop();
       
   151             }
       
   152         else
       
   153             {
       
   154             AsyncCommandFinished();
       
   155             }
       
   156         }
       
   157     }
       
   158 
       
   159 
       
   160 void CCreatorLogElement::ExecuteCommandL()
    48 void CCreatorLogElement::ExecuteCommandL()
   161     {
    49     {
   162     const CCreatorScriptAttribute* amountAttr = FindAttributeByName(KAmount);
    50     const CCreatorScriptAttribute* amountAttr = FindAttributeByName(KAmount);
   163     TInt logAmount = 1;    
    51     TInt logAmount = 1;    
   164     if( amountAttr )
    52     if( amountAttr )