creator/src/creator_calendarelement.cpp
branchRCL_3
changeset 60 6646c35e558c
parent 50 9b2cffad4b5e
equal deleted inserted replaced
50:9b2cffad4b5e 60:6646c35e558c
   486                 }
   486                 }
   487             }
   487             }
   488         }    
   488         }    
   489     }
   489     }
   490 
   490 
   491 void CCreatorCalendarElement::AsyncExecuteCommandL()
       
   492     {
       
   493     LOGSTRING("Creator: CCreatorCalendarElement::AsyncExecuteCommandL");
       
   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::AsyncExecuteCommandL: 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     if( iLoopIndex < entryAmount )
       
   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                 // We can step out from the for-loop, because the amount is given to engine.
       
   527                 // stop loop and signal end of the executing command
       
   528                 AsyncCommandFinished();
       
   529                 return;
       
   530                 }
       
   531             }       
       
   532         else if( CompareIgnoreCase(calEntryTypeAttr->Value(), KCalTypeEvent ) == 0 )
       
   533             {
       
   534             if( fieldsElement && fieldsElement->SubElements().Count() > 0 )
       
   535                 {
       
   536                 FillEntryParamsL(EEvent, fieldsElement->SubElements(), param);
       
   537                 iEngine->AppendToCommandArrayL(ECmdCreateCalendarEntryEvents, param);
       
   538                 }
       
   539             else
       
   540                 {
       
   541                 iEngine->AppendToCommandArrayL(ECmdCreateCalendarEntryEvents, 0, entryAmount);
       
   542                 CleanupStack::PopAndDestroy(param);
       
   543                 // We can step out from the for-loop, because the amount is given to engine.
       
   544                 // stop loop and signal end of the executing command
       
   545                 AsyncCommandFinished();
       
   546                 return;
       
   547                 }
       
   548             }
       
   549         else if( CompareIgnoreCase(calEntryTypeAttr->Value(), KCalTypeReminder ) == 0 )
       
   550             {
       
   551             if( fieldsElement && fieldsElement->SubElements().Count() > 0 )
       
   552                 {
       
   553                 FillEntryParamsL(EReminder, fieldsElement->SubElements(), param);
       
   554                 iEngine->AppendToCommandArrayL(ECmdCreateCalendarEntryReminders, param);
       
   555                 }
       
   556             else
       
   557                 {
       
   558                 iEngine->AppendToCommandArrayL(ECmdCreateCalendarEntryReminders, 0, entryAmount);
       
   559                 CleanupStack::PopAndDestroy(param);
       
   560                 // We can step out from the for-loop, because the amount is given to engine.
       
   561                 // stop loop and signal end of the executing command
       
   562                 AsyncCommandFinished();
       
   563                 return;
       
   564                 }
       
   565             }
       
   566         else if( CompareIgnoreCase(calEntryTypeAttr->Value(), KCalTypeAnniversary ) == 0 )
       
   567             {
       
   568             if( fieldsElement && fieldsElement->SubElements().Count() > 0 )
       
   569                 {
       
   570                 FillEntryParamsL(EAnniversary, fieldsElement->SubElements(), param);
       
   571                 iEngine->AppendToCommandArrayL(ECmdCreateCalendarEntryAnniversaries, param);
       
   572                 }
       
   573             else
       
   574                 {
       
   575                 iEngine->AppendToCommandArrayL(ECmdCreateCalendarEntryAnniversaries, 0, entryAmount);
       
   576                 CleanupStack::PopAndDestroy(param);
       
   577                 // We can step out from the for-loop, because the amount is given to engine.
       
   578                 // stop loop and signal end of the executing command
       
   579                 AsyncCommandFinished();
       
   580                 return;
       
   581                 }
       
   582             }
       
   583         else if( CompareIgnoreCase(calEntryTypeAttr->Value(), KCalTypeTodo ) == 0 )
       
   584             {
       
   585             if( fieldsElement && fieldsElement->SubElements().Count() > 0 )
       
   586                 {
       
   587                 FillEntryParamsL(ETodo, fieldsElement->SubElements(), param);
       
   588                 iEngine->AppendToCommandArrayL(ECmdCreateCalendarEntryToDos, param);
       
   589                 }
       
   590             else
       
   591                 {
       
   592                 iEngine->AppendToCommandArrayL(ECmdCreateCalendarEntryToDos, 0, entryAmount);
       
   593                 CleanupStack::PopAndDestroy(param);
       
   594                 // We can step out from the for-loop, because the amount is given to engine.
       
   595                 // stop loop and signal end of the executing command
       
   596                 AsyncCommandFinished();
       
   597                 return;
       
   598                 }
       
   599             }
       
   600         CleanupStack::Pop(); // param
       
   601         StartNextLoop();
       
   602         }
       
   603     else
       
   604         {
       
   605         // stop loop and signal end of the executing command
       
   606         AsyncCommandFinished();
       
   607         }
       
   608     }
       
   609 
       
   610 void CCreatorCalendarElement::ExecuteCommandL()
   491 void CCreatorCalendarElement::ExecuteCommandL()
   611 	{
   492 	{
   612 	LOGSTRING("Creator: CCreatorCalendarElement::ExecuteCommandL");
   493 	LOGSTRING("Creator: CCreatorCalendarElement::ExecuteCommandL");
   613 	// Amount of calendar entries:
   494 	// Amount of calendar entries:
   614 	const CCreatorScriptAttribute* calEntryAmountAttr = this->FindAttributeByName(KAmount);
   495 	const CCreatorScriptAttribute* calEntryAmountAttr = this->FindAttributeByName(KAmount);