creator/src/creator_impselement.cpp
branchRCL_3
changeset 60 6646c35e558c
parent 50 9b2cffad4b5e
equal deleted inserted replaced
50:9b2cffad4b5e 60:6646c35e558c
    41 CCreatorImpsServerElement::CCreatorImpsServerElement(CCreatorEngine* aEngine) 
    41 CCreatorImpsServerElement::CCreatorImpsServerElement(CCreatorEngine* aEngine) 
    42 : 
    42 : 
    43 CCreatorScriptElement(aEngine)
    43 CCreatorScriptElement(aEngine)
    44     {
    44     {
    45     iIsCommandElement = ETrue;
    45     iIsCommandElement = ETrue;
    46     }
       
    47 
       
    48 void CCreatorImpsServerElement::AsyncExecuteCommandL()
       
    49     {
       
    50     const CCreatorScriptAttribute* amountAttr = FindAttributeByName(KAmount);
       
    51     TInt entryAmount = 1;    
       
    52     if( amountAttr )
       
    53         {
       
    54         entryAmount = ConvertStrToIntL(amountAttr->Value());
       
    55         }
       
    56     // Get 'fields' element 
       
    57     CCreatorScriptElement* fieldsElement = FindSubElement(KFields);
       
    58     if( fieldsElement && fieldsElement->SubElements().Count() > 0 )
       
    59         {
       
    60         // Get sub-elements
       
    61         const RPointerArray<CCreatorScriptElement>& fields = fieldsElement->SubElements();        
       
    62         // Create note entries, the amount of entries is defined by entryAmount:
       
    63         if( iLoopIndex < entryAmount )
       
    64             {            
       
    65             CIMPSParameters* param = new (ELeave) CIMPSParameters;
       
    66             CleanupStack::PushL(param);
       
    67             
       
    68             for( TInt i = 0; i < fields.Count(); ++i )
       
    69                 {
       
    70                 CCreatorScriptElement* field = fields[i];
       
    71                 TPtrC elemName = field->Name();
       
    72                 TPtrC elemContent = field->Content();
       
    73                 const CCreatorScriptAttribute* randomAttr = fields[i]->FindAttributeByName(KRandomLength);
       
    74                 TBool useRandom = EFalse;
       
    75                 if( randomAttr || elemContent.Length() == 0 )
       
    76                     {
       
    77                     useRandom = ETrue;
       
    78                     }
       
    79                 
       
    80                 if( elemName == KName )
       
    81                     {
       
    82                     if( useRandom )
       
    83                         {
       
    84                         param->SetRandomNameL(*iEngine);
       
    85                         }
       
    86                     else
       
    87                         {
       
    88                         SetContentToTextParamL(param->iServerName, elemContent);
       
    89                         }                    
       
    90                     }
       
    91                 if( elemName == KUrl )
       
    92                     {
       
    93                     if( useRandom )
       
    94                         {
       
    95                         param->SetRandomUrlL(*iEngine);
       
    96                         }
       
    97                     else
       
    98                         {
       
    99                         SetContentToTextParamL(param->iServerURL, elemContent);
       
   100                         }
       
   101                     }
       
   102                 if( elemName == KUsername )
       
   103                     {
       
   104                     if( useRandom )
       
   105                         {
       
   106                         param->SetRandomUsernameL(*iEngine);
       
   107                         }
       
   108                     else
       
   109                         {
       
   110                         SetContentToTextParamL(param->iServerUsername, elemContent);
       
   111                         }
       
   112                     }
       
   113                 if( elemName == KPassword )
       
   114                     {
       
   115                     if( useRandom )
       
   116                         {
       
   117                         param->SetRandomPasswordL(*iEngine);
       
   118                         }
       
   119                     else
       
   120                         {
       
   121                         SetContentToTextParamL(param->iServerPassword, elemContent);
       
   122                         }
       
   123                     }
       
   124                 if( elemName == KConnectionMethodName )
       
   125                     {
       
   126                     if( useRandom || CompareIgnoreCase(elemContent, creatorimps::KDefault) == 0 )
       
   127                         {
       
   128                         param->SetDefaultAccessPointL();
       
   129                         }
       
   130                     else
       
   131                         {
       
   132                         SetContentToTextParamL(param->iServerAccessPointName, elemContent);
       
   133                         }
       
   134                     }
       
   135                 }
       
   136             iEngine->AppendToCommandArrayL(ECmdCreateMiscEntryIMPSServers, param);
       
   137             CleanupStack::Pop(); // param
       
   138             StartNextLoop();
       
   139             }
       
   140         else
       
   141             {
       
   142             AsyncCommandFinished();
       
   143             }
       
   144         }
       
   145     else
       
   146         {
       
   147         iEngine->AppendToCommandArrayL(ECmdCreateMiscEntryIMPSServers, 0, entryAmount);
       
   148         AsyncCommandFinished();
       
   149         }
       
   150     }
    46     }
   151 
    47 
   152 void CCreatorImpsServerElement::ExecuteCommandL()
    48 void CCreatorImpsServerElement::ExecuteCommandL()
   153     {
    49     {
   154     const CCreatorScriptAttribute* amountAttr = FindAttributeByName(KAmount);
    50     const CCreatorScriptAttribute* amountAttr = FindAttributeByName(KAmount);