creator/src/creator_calendarelement.cpp
branchRCL_3
changeset 21 b3cee849fa46
parent 20 48060abbbeaf
child 22 fad26422216a
equal deleted inserted replaced
20:48060abbbeaf 21:b3cee849fa46
     1 /*
       
     2 * Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies). 
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:  
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #include "creator_calendarelement.h"
       
    20 #include "creator_traces.h"
       
    21 #include "creator_calendar.h"
       
    22 
       
    23 using namespace creatorcalendar;
       
    24 
       
    25 CCreatorCalendarElement* CCreatorCalendarElement::NewL(CCreatorEngine* aEngine, const TDesC& aName, const TDesC& aContext )
       
    26     {
       
    27     CCreatorCalendarElement* self = new (ELeave) CCreatorCalendarElement(aEngine);
       
    28     CleanupStack::PushL(self);
       
    29     self->ConstructL(aName, aContext);
       
    30     CleanupStack::Pop(self);
       
    31     return self;
       
    32     }
       
    33 
       
    34 void CCreatorCalendarElement::FillEntryParamsL(TEntryType aType, const RPointerArray<CCreatorScriptElement>& fields, CCalenderInterimParameters* parameters)
       
    35     {
       
    36     if( parameters == 0 )
       
    37         return;
       
    38     
       
    39     TBool startResolved = EFalse;    
       
    40     TBool endResolved = EFalse;
       
    41     
       
    42     for( TInt i = 0; i < fields.Count(); ++i )
       
    43         {
       
    44         TPtrC elemName = fields[i]->Name();
       
    45         TPtrC elemContent = fields[i]->Content();
       
    46         const CCreatorScriptAttribute* randomAttr = fields[i]->FindAttributeByName(KRandomLength);
       
    47         
       
    48         if( elemName == KSummary || elemName == KDescription )
       
    49             {           
       
    50             if( randomAttr || elemContent.Length() == 0 )
       
    51                 {      
       
    52                 TPtrC reason;
       
    53                 if( aType == EAppointment )
       
    54                     {
       
    55                     reason.Set(iEngine->RandomString (CCreatorEngine::EMeetingReason ));                    
       
    56                     }
       
    57                 else if( aType == EEvent )
       
    58                     {
       
    59                     reason.Set(iEngine->RandomString(CCreatorEngine::EMemoText));                    
       
    60                     }
       
    61                 else if( aType == EReminder )
       
    62                     {
       
    63                     reason.Set(iEngine->RandomString(CCreatorEngine::EReminderText));                    
       
    64                     }
       
    65                 else if( aType == EAnniversary )
       
    66                     {                   
       
    67                     reason.Set(iEngine->RandomString(CCreatorEngine::EAnniversaryReason));                    
       
    68                     }
       
    69                 else if( aType == ETodo )
       
    70                     {
       
    71                     reason.Set(iEngine->RandomString(CCreatorEngine::EToDoText));                    
       
    72                     }
       
    73                 
       
    74                 if( elemName == KDescription )
       
    75                     {
       
    76                     delete parameters->iDescription;
       
    77                     parameters->iDescription = 0;
       
    78                     parameters->iDescription = HBufC::NewL(reason.Length());
       
    79                     parameters->iDescription->Des().Copy(reason);
       
    80                     }
       
    81                 else if(elemName == KSummary)
       
    82                     {
       
    83                     delete parameters->iSummary;
       
    84                     parameters->iSummary = 0;
       
    85                     parameters->iSummary = HBufC::NewL(reason.Length());
       
    86                     parameters->iSummary->Des().Copy(reason);
       
    87                     }
       
    88                 }
       
    89             else if( elemName == KDescription )                
       
    90                 {                
       
    91                 delete parameters->iDescription;
       
    92                 parameters->iDescription = 0;
       
    93                 parameters->iDescription = HBufC::NewL(elemContent.Length());
       
    94                 parameters->iDescription->Des().Copy(elemContent);
       
    95                 }
       
    96             else if( elemName == KSummary)
       
    97                 {
       
    98                 delete parameters->iSummary;
       
    99                 parameters->iSummary = 0;
       
   100                 parameters->iSummary = HBufC::NewL(elemContent.Length());
       
   101                 parameters->iSummary->Des().Copy(elemContent);
       
   102                 }
       
   103             }
       
   104         else if( elemName == KLocation )
       
   105             {
       
   106             delete parameters->iLocation;
       
   107             parameters->iLocation = 0;
       
   108             
       
   109             if( randomAttr || elemContent.Length() == 0 )
       
   110                 {
       
   111                 TPtrC reason = iEngine->RandomString (CCreatorEngine::EMeetingPlace );
       
   112                 parameters->iLocation = HBufC::NewL(reason.Length());
       
   113                 parameters->iLocation->Des().Copy(reason);
       
   114                 }
       
   115             else
       
   116                 {
       
   117                 parameters->iLocation = HBufC::NewL(elemContent.Length());
       
   118                 parameters->iLocation->Des().Copy(elemContent);
       
   119                 }
       
   120             }
       
   121         else if( elemName == KStarttime )
       
   122             {
       
   123             if( randomAttr || elemContent.Length() == 0 )
       
   124                 {                
       
   125                 // Random start time used. If end time is already resolved, let's use that one for the basis. 
       
   126                 if( endResolved )
       
   127                     {                    
       
   128                     parameters->iStartTime = iEngine->RandomTime(parameters->iEndTime, CCreatorEngine::EDatePast);                    
       
   129                     }
       
   130                 else
       
   131                     {
       
   132                     // Past or future:
       
   133                     CCreatorEngine::TRandomDateType pastOrfuture = 
       
   134                     (CCreatorEngine::TRandomDateType) iEngine->RandomNumber((TInt) CCreatorEngine::EDatePast,
       
   135                                                                             (TInt) CCreatorEngine::EDateFuture);
       
   136                     
       
   137                     parameters->iStartTime = 
       
   138                         iEngine->RandomTime(iEngine->RandomDate(pastOrfuture), pastOrfuture);  
       
   139                     }
       
   140                 }
       
   141             else
       
   142                 {
       
   143                 parameters->iStartTime = ConvertToDateTimeL(elemContent);                
       
   144                 }            
       
   145             startResolved = ETrue;
       
   146             }
       
   147         else if( elemName == KEndtime )
       
   148             {
       
   149             if( randomAttr || elemContent.Length() == 0 )
       
   150                 {
       
   151                 // Random end time used. If start time is already resolved, let's use that one.                
       
   152                 if( startResolved )
       
   153                     {                    
       
   154                     parameters->iEndTime = iEngine->RandomTime(parameters->iStartTime, CCreatorEngine::EDateFuture);                    
       
   155                     }
       
   156                 else
       
   157                     {
       
   158                     // Past or future:
       
   159                     CCreatorEngine::TRandomDateType pastOrfuture = 
       
   160                     (CCreatorEngine::TRandomDateType) iEngine->RandomNumber((TInt) CCreatorEngine::EDatePast,
       
   161                             (TInt) CCreatorEngine::EDateFuture);
       
   162                     
       
   163                     parameters->iEndTime = 
       
   164                     iEngine->RandomTime(iEngine->RandomDate(pastOrfuture), pastOrfuture);  
       
   165                     }                          
       
   166                 }
       
   167             else
       
   168                 {
       
   169                 parameters->iEndTime = ConvertToDateTimeL(elemContent);
       
   170                 }
       
   171             if( aType == ETodo )
       
   172                 {
       
   173                 parameters->iTodoDueTime = parameters->iEndTime;
       
   174                 }
       
   175             }
       
   176         else if( elemName == KRecurrentFreq )
       
   177             {
       
   178             TInt randomFreq = 0;
       
   179             if( randomAttr || elemContent.Length() == 0 )
       
   180                 {
       
   181                 randomFreq = iEngine->RandomNumber(1, 4);
       
   182                 }
       
   183             if(randomFreq == 1 || CompareIgnoreCase(elemContent, KDaily) == 0 )
       
   184                 parameters->iRecurrentFrequency = TCalRRule::EDaily;
       
   185             else if( randomFreq == 2 || CompareIgnoreCase(elemContent, KWeekly) == 0 )
       
   186                 parameters->iRecurrentFrequency = TCalRRule::EWeekly;
       
   187             else if( randomFreq == 3 || CompareIgnoreCase(elemContent, KMonthly) == 0 )
       
   188                 parameters->iRecurrentFrequency = TCalRRule::EMonthly;
       
   189             else if( randomFreq == 4 || CompareIgnoreCase(elemContent, KYearly) == 0 )
       
   190                 parameters->iRecurrentFrequency = TCalRRule::EYearly;
       
   191             else
       
   192                 parameters->iRecurrentFrequency = TCalRRule::EInvalid;            
       
   193             }
       
   194         else if( elemName == KRecurrentInterval )
       
   195             {
       
   196             if( randomAttr || elemContent.Length() == 0 )
       
   197                 {
       
   198                 parameters->iRecurrentInterval = iEngine->RandomNumber(1,7);
       
   199                 }
       
   200             else
       
   201                 {
       
   202                 parameters->iRecurrentInterval = ConvertStrToIntL(elemContent);
       
   203                 }
       
   204             }
       
   205         else if( elemName == KRecurrentFrom )
       
   206             {
       
   207             if( randomAttr || elemContent.Length() == 0 )
       
   208                 {
       
   209                 if( startResolved )
       
   210                     {
       
   211                     // Let's use the start time if it's resolved.
       
   212                     parameters->iRecurrentStartTime = parameters->iStartTime;
       
   213                     }
       
   214                 else
       
   215                     {
       
   216                     parameters->iRecurrentStartTime = iEngine->RandomDate(CCreatorEngine::EDateFuture);
       
   217                     }
       
   218                 }
       
   219             else
       
   220                 {
       
   221                 parameters->iRecurrentStartTime = ConvertToDateTimeL(elemContent);
       
   222                 }           
       
   223             }
       
   224         else if( elemName == KRecurrentTo )
       
   225             {
       
   226             if( randomAttr || elemContent.Length() == 0 )
       
   227                 {
       
   228                 parameters->iRepeatingCount = iEngine->RandomNumber(1, 6);
       
   229                 //parameters->iRecurrentEndTime = iEngine->RandomDate(CCreatorEngine::EDateFuture);                
       
   230                 }
       
   231             else
       
   232                 {
       
   233                 parameters->iRecurrentEndTime = ConvertToDateTimeL(elemContent);
       
   234                 }           
       
   235             }
       
   236         else if( elemName == KRepeatingCount )
       
   237             {
       
   238             if( randomAttr || elemContent.Length() == 0 )
       
   239                 {
       
   240                 parameters->iRepeatingCount = iEngine->RandomNumber(1, 52);
       
   241                 }
       
   242             else
       
   243                 {
       
   244                 parameters->iRepeatingCount = ConvertStrToIntL(elemContent);
       
   245                 }
       
   246             }
       
   247         else if( elemName == KAlarmtime )
       
   248             {
       
   249             if( randomAttr || elemContent.Length() == 0 )
       
   250                 {                
       
   251                 parameters->iUseRandomAlarmTime = ETrue;
       
   252                 }
       
   253             else
       
   254                 {
       
   255                 parameters->iAlarmTime = ConvertToDateTimeL(elemContent);
       
   256                 }
       
   257             }
       
   258         else if( elemName == KOrganizername )
       
   259             {
       
   260             delete parameters->iOrganizerName;
       
   261             parameters->iOrganizerName = 0;
       
   262             if( randomAttr || elemContent.Length() == 0 )
       
   263                 {
       
   264                 TPtrC name = iEngine->RandomString (CCreatorEngine::EFirstName );
       
   265                 parameters->iOrganizerName = HBufC::NewL(name.Length());
       
   266                 parameters->iOrganizerName->Des().Copy(name);
       
   267                 }
       
   268             else
       
   269                 {            
       
   270                 parameters->iOrganizerName = HBufC::NewL(elemContent.Length());
       
   271                 parameters->iOrganizerName->Des().Copy(elemContent);
       
   272                 }
       
   273             }
       
   274         else if( elemName == KOrganizeremail )
       
   275             {
       
   276             delete parameters->iOrganizerEmail;
       
   277             parameters->iOrganizerEmail = 0;
       
   278             if( randomAttr || elemContent.Length() == 0 )
       
   279                 {
       
   280                 TDesC* email = iEngine->CreateEmailAddressLC();
       
   281                 parameters->iOrganizerEmail = (HBufC*) email;
       
   282                 CleanupStack::Pop(); // email
       
   283                 }
       
   284             else
       
   285                 {
       
   286                 parameters->iOrganizerEmail = HBufC::NewL(elemContent.Length());
       
   287                 parameters->iOrganizerEmail->Des().Copy(elemContent);
       
   288                 }
       
   289             }
       
   290         else if( elemName == KStatus )
       
   291             {
       
   292             if( randomAttr || elemContent.Length() == 0 )
       
   293                 {
       
   294                 if( aType == ETodo )
       
   295                 	{
       
   296                 	parameters->iStatus = (CCalEntry::TStatus) iEngine->RandomNumber(CCalEntry::ETodoNeedsAction, CCalEntry::ETodoInProcess);
       
   297                 	}
       
   298                 else
       
   299                 	{
       
   300                 	parameters->iStatus = (CCalEntry::TStatus) iEngine->RandomNumber(CCalEntry::ETentative, CCalEntry::ECancelled);
       
   301                 	}
       
   302                 }
       
   303             else if( CompareIgnoreCase(elemContent, KCalStatusTentative) == 0 )
       
   304                 {
       
   305                 parameters->iStatus = CCalEntry::ETentative;
       
   306                 }
       
   307             else if( CompareIgnoreCase(elemContent, KCalStatusConfirmed) == 0 )
       
   308                 {
       
   309                 parameters->iStatus = CCalEntry::EConfirmed;
       
   310                 }
       
   311             else if( CompareIgnoreCase(elemContent, KCalStatusCancelled) == 0 )
       
   312                 {
       
   313                 parameters->iStatus = CCalEntry::ECancelled;
       
   314                 }
       
   315             else if( CompareIgnoreCase(elemContent, KCalStatusNeedsAction) == 0 )
       
   316                 {
       
   317                 parameters->iStatus = CCalEntry::ETodoNeedsAction;
       
   318                 }
       
   319             else if( CompareIgnoreCase(elemContent, KCalStatusCompleted) == 0 )
       
   320                 {
       
   321                 parameters->iStatus = CCalEntry::ETodoCompleted;
       
   322                 }
       
   323             else if( CompareIgnoreCase(elemContent, KCalStatusInProcess) == 0 )
       
   324                 {
       
   325                 parameters->iStatus = CCalEntry::ETodoInProcess;
       
   326                 }
       
   327             else
       
   328                 {
       
   329                 parameters->iStatus = CCalEntry::ENullStatus;
       
   330                 }
       
   331             }
       
   332         else if( elemName == KPriority )
       
   333             {
       
   334             if( randomAttr || elemContent.Length() == 0 )
       
   335                 {
       
   336                 parameters->iTodoPriority = iEngine->RandomNumber(1,3);
       
   337                 }            
       
   338             else if( CompareIgnoreCase(elemContent, KPriorityHigh) == 0)
       
   339                 {
       
   340                 parameters->iTodoPriority = 1;
       
   341                 }
       
   342             else if( CompareIgnoreCase(elemContent, KPriorityMedium) == 0)
       
   343                 {
       
   344                 parameters->iTodoPriority = 2;
       
   345                 }
       
   346             else if( CompareIgnoreCase(elemContent, KPriorityLow) == 0 )
       
   347                 {
       
   348                 parameters->iTodoPriority = 3;
       
   349                 }
       
   350             else
       
   351                 {
       
   352                 parameters->iTodoPriority = ConvertStrToIntL(elemContent);
       
   353                 }
       
   354             }
       
   355         else if( elemName == KAttendees )
       
   356             {            
       
   357             const RPointerArray<CCreatorScriptElement>& attendeesSubElems = fields[i]->SubElements();
       
   358             for( TInt j = 0; j < attendeesSubElems.Count(); ++j )
       
   359                 {
       
   360                 TPtrC eName = attendeesSubElems[j]->Name();
       
   361                 TPtrC eContent = attendeesSubElems[j]->Content();
       
   362                 if( eName == KContactSetRef )
       
   363                     {
       
   364                     AppendContactSetReferenceL(*attendeesSubElems[j], parameters->iAttendeeLinkIds);
       
   365                     }
       
   366                 else if( eName == KAttendee )
       
   367                     {
       
   368                     CCreatorCalenderAttendee* calAtt = CCreatorCalenderAttendee::NewL();
       
   369                     CleanupStack::PushL(calAtt);
       
   370                     const RPointerArray<CCreatorScriptElement>& attendeeFields = attendeesSubElems[j]->SubElements();
       
   371                     // Make sure that at least email is given:
       
   372                     if(attendeeFields.Count() == 0 )
       
   373                     	{
       
   374                     	CCreatorScriptElement* emailField =  CCreatorScriptElement::NewL(iEngine, KEmail );
       
   375                     	CleanupStack::PushL(emailField);
       
   376                     	fields[i]->SubElements().AppendL(emailField);
       
   377                     	CleanupStack::Pop(); // emailField	
       
   378                     	}
       
   379                     for( TInt k = 0; k < attendeeFields.Count(); ++k )
       
   380                         {
       
   381                         const CCreatorScriptAttribute* randomAttr = attendeeFields[k]->FindAttributeByName(KRandomLength);
       
   382                         TPtrC attElemName = attendeeFields[k]->Name();
       
   383                         TPtrC attElemCont = attendeeFields[k]->Content();
       
   384                         if( attElemName == KCommonname )
       
   385                             {
       
   386                             if( randomAttr || attElemCont.Length() == 0)
       
   387                                 {
       
   388                                 // Random data:
       
   389                                 calAtt->SetCommonNameL(iEngine->RandomString(CCreatorEngine::EFirstName));
       
   390                                 }
       
   391                             else
       
   392                                 {
       
   393                                 calAtt->SetCommonNameL(attElemCont);
       
   394                                 }
       
   395                             }
       
   396                         else if( attElemName == KEmail )
       
   397                             {
       
   398                             if( randomAttr || attElemCont.Length() == 0)
       
   399                                 {
       
   400                                 // Random data:
       
   401                                 TDesC* email = iEngine->CreateEmailAddressLC();
       
   402                                 calAtt->SetEmailAddressL(*email);
       
   403                                 CleanupStack::PopAndDestroy(); // email
       
   404                                 }
       
   405                             else
       
   406                                 {                                
       
   407                                 calAtt->SetEmailAddressL(attElemCont);
       
   408                                 }
       
   409                             }
       
   410                         else if( attElemName == KRole )
       
   411                             {
       
   412                             if( randomAttr || attElemCont.Length() == 0)
       
   413                                 {
       
   414                                 // Random role:
       
   415                                 CCalAttendee::TCalRole randomRole = 
       
   416                                     (CCalAttendee::TCalRole) iEngine->RandomNumber(
       
   417                                             (TInt) CCalAttendee::EReqParticipant, 
       
   418                                             (TInt) CCalAttendee::EChair);
       
   419                                 calAtt->SetRole(randomRole);
       
   420                                 }                                
       
   421                             else if( CompareIgnoreCase(attElemCont, KRoleRequired) == 0 )
       
   422                                 {
       
   423                                 calAtt->SetRole(CCalAttendee::EReqParticipant);
       
   424                                 }
       
   425                             else if( CompareIgnoreCase(attElemCont, KRoleOptional) == 0 )
       
   426                                 {
       
   427                                 calAtt->SetRole(CCalAttendee::EOptParticipant);
       
   428                                 }
       
   429                             else if( CompareIgnoreCase(attElemCont, KRoleNonPart) == 0 )
       
   430                                 {
       
   431                                 calAtt->SetRole(CCalAttendee::ENonParticipant);
       
   432                                 }
       
   433                             else if( CompareIgnoreCase(attElemCont, KRoleChair) == 0 )
       
   434                                 {
       
   435                                 calAtt->SetRole(CCalAttendee::EChair);
       
   436                                 }
       
   437                             }
       
   438                         else if( attElemName == KStatus )
       
   439                             {
       
   440                             if( randomAttr || attElemCont.Length() == 0)
       
   441                                 {
       
   442                                 // Random role:
       
   443                                 CCalAttendee::TCalStatus randomStatus = 
       
   444                                 (CCalAttendee::TCalStatus) iEngine->RandomNumber(
       
   445                                         (TInt) CCalAttendee::ENeedsAction, 
       
   446                                         (TInt) CCalAttendee::EInProcess);
       
   447                                 calAtt->SetStatus(randomStatus);
       
   448                                 }                                
       
   449                             else if( CompareIgnoreCase(attElemCont, KStatusNeedsAction) == 0 )
       
   450                                 {
       
   451                                 calAtt->SetStatus(CCalAttendee::ENeedsAction);
       
   452                                 }
       
   453                             else if( CompareIgnoreCase(attElemCont, KStatusAccepted) == 0 )
       
   454                                 {
       
   455                                 calAtt->SetStatus(CCalAttendee::EAccepted);
       
   456                                 }
       
   457                             else if( CompareIgnoreCase(attElemCont, KStatusTentative) == 0 )
       
   458                                 {
       
   459                                 calAtt->SetStatus(CCalAttendee::ETentative);
       
   460                                 }
       
   461                             else if( CompareIgnoreCase(attElemCont, KStatusConfirmed) == 0 )
       
   462                                 {
       
   463                                 calAtt->SetStatus(CCalAttendee::EConfirmed);
       
   464                                 }
       
   465                             else if( CompareIgnoreCase(attElemCont, KStatusDeclined) == 0 )
       
   466                                 {
       
   467                                 calAtt->SetStatus(CCalAttendee::EDeclined);
       
   468                                 }
       
   469                             else if( CompareIgnoreCase(attElemCont, KStatusCompleted) == 0 )
       
   470                                 {
       
   471                                 calAtt->SetStatus(CCalAttendee::ECompleted);
       
   472                                 }
       
   473                             else if( CompareIgnoreCase(attElemCont, KStatusDelegated) == 0 )
       
   474                                 {                                
       
   475                                 calAtt->SetStatus(CCalAttendee::EDelegated);
       
   476                                 }
       
   477                             else if( CompareIgnoreCase(attElemCont, KStatusInProcess) == 0 )
       
   478                                 {                                
       
   479                                 calAtt->SetStatus(CCalAttendee::EInProcess);
       
   480                                 }
       
   481                             }
       
   482                         }
       
   483                     parameters->iAttendees.AppendL(calAtt);
       
   484                     CleanupStack::Pop(); // calAtt
       
   485                     }
       
   486                 }
       
   487             }
       
   488         }    
       
   489     }
       
   490 
       
   491 void CCreatorCalendarElement::ExecuteCommandL()
       
   492 	{
       
   493 	LOGSTRING("Creator: CCreatorCalendarElement::ExecuteCommandL");
       
   494 	// Amount of calendar entries:
       
   495 	const CCreatorScriptAttribute* calEntryAmountAttr = this->FindAttributeByName(KAmount);
       
   496 	const CCreatorScriptAttribute* calEntryTypeAttr = this->FindAttributeByName(KType);    
       
   497 	TInt entryAmount = 1;    
       
   498 	if( calEntryAmountAttr )
       
   499 		{
       
   500 		entryAmount = ConvertStrToIntL(calEntryAmountAttr->Value());
       
   501 		}
       
   502 	if( calEntryTypeAttr == 0 )
       
   503 		{
       
   504 		LOGSTRING("ERROR in CCreatorCalendarElement::ExecuteCommandL: Type attribute is missing.");
       
   505 		User::Leave(KErrGeneral); // type is required attribute
       
   506 		}
       
   507 
       
   508 	// Find fields element:
       
   509 	CCreatorScriptElement* fieldsElement = FindSubElement(KFields);
       
   510 	
       
   511 	for( TInt cI = 0; cI < entryAmount; ++cI )
       
   512 		{
       
   513 		CCalenderInterimParameters* param = new (ELeave) CCalenderInterimParameters;
       
   514 		CleanupStack::PushL(param);
       
   515 		if( CompareIgnoreCase(calEntryTypeAttr->Value(), KCalTypeAppointment) == 0 )
       
   516 			{
       
   517 			if( fieldsElement && fieldsElement->SubElements().Count() > 0 )
       
   518 				{
       
   519 				FillEntryParamsL(EAppointment, fieldsElement->SubElements(), param);
       
   520 				iEngine->AppendToCommandArrayL(ECmdCreateCalendarEntryAppointments, param);
       
   521 				}
       
   522 			else
       
   523 				{
       
   524 				iEngine->AppendToCommandArrayL(ECmdCreateCalendarEntryAppointments, 0, entryAmount);
       
   525 				CleanupStack::PopAndDestroy(param);
       
   526 				break; // We can step out from the for-loop, because the amount is given to engine.
       
   527 				}
       
   528 			}		
       
   529 		else if( CompareIgnoreCase(calEntryTypeAttr->Value(), KCalTypeEvent ) == 0 )
       
   530 			{
       
   531 			if( fieldsElement && fieldsElement->SubElements().Count() > 0 )
       
   532 				{
       
   533 				FillEntryParamsL(EEvent, fieldsElement->SubElements(), param);
       
   534 				iEngine->AppendToCommandArrayL(ECmdCreateCalendarEntryEvents, param);
       
   535 				}
       
   536 			else
       
   537 				{
       
   538 				iEngine->AppendToCommandArrayL(ECmdCreateCalendarEntryEvents, 0, entryAmount);
       
   539 				CleanupStack::PopAndDestroy(param);
       
   540 				break;  // We can step out from the for-loop, because the amount is given to engine.
       
   541 				}
       
   542 			}
       
   543 		else if( CompareIgnoreCase(calEntryTypeAttr->Value(), KCalTypeReminder ) == 0 )
       
   544 			{
       
   545 			if( fieldsElement && fieldsElement->SubElements().Count() > 0 )
       
   546 				{
       
   547 				FillEntryParamsL(EReminder, fieldsElement->SubElements(), param);
       
   548 				iEngine->AppendToCommandArrayL(ECmdCreateCalendarEntryReminders, param);
       
   549 				}
       
   550 			else
       
   551 				{
       
   552 				iEngine->AppendToCommandArrayL(ECmdCreateCalendarEntryReminders, 0, entryAmount);
       
   553 				CleanupStack::PopAndDestroy(param);
       
   554 				break;  // We can step out from the for-loop, because the amount is given to engine.
       
   555 				}
       
   556 			}
       
   557 		else if( CompareIgnoreCase(calEntryTypeAttr->Value(), KCalTypeAnniversary ) == 0 )
       
   558 			{
       
   559 			if( fieldsElement && fieldsElement->SubElements().Count() > 0 )
       
   560 				{
       
   561 				FillEntryParamsL(EAnniversary, fieldsElement->SubElements(), param);
       
   562 				iEngine->AppendToCommandArrayL(ECmdCreateCalendarEntryAnniversaries, param);
       
   563 				}
       
   564 			else
       
   565 				{
       
   566 				iEngine->AppendToCommandArrayL(ECmdCreateCalendarEntryAnniversaries, 0, entryAmount);
       
   567 				CleanupStack::PopAndDestroy(param);
       
   568 				break;  // We can step out from the for-loop, because the amount is given to engine.
       
   569 				}
       
   570 			}
       
   571 		else if( CompareIgnoreCase(calEntryTypeAttr->Value(), KCalTypeTodo ) == 0 )
       
   572 			{
       
   573 			if( fieldsElement && fieldsElement->SubElements().Count() > 0 )
       
   574 				{
       
   575 				FillEntryParamsL(ETodo, fieldsElement->SubElements(), param);
       
   576 				iEngine->AppendToCommandArrayL(ECmdCreateCalendarEntryToDos, param);
       
   577 				}
       
   578 			else
       
   579 				{
       
   580 				iEngine->AppendToCommandArrayL(ECmdCreateCalendarEntryToDos, 0, entryAmount);
       
   581 				CleanupStack::PopAndDestroy(param);
       
   582 				break;  // We can step out from the for-loop, because the amount is given to engine.
       
   583 				}
       
   584 			}
       
   585 		CleanupStack::Pop(); // param
       
   586 		}
       
   587 	}
       
   588 
       
   589 CCreatorCalendarElement::CCreatorCalendarElement(CCreatorEngine* aEngine) 
       
   590 : 
       
   591 CCreatorScriptElement(aEngine)
       
   592     {
       
   593     iIsCommandElement = ETrue;
       
   594     }