examples/SFExamples/PIM/PopulateAgenda/src/PopulateAgendaAppUi.cpp

00001 // 
00002 // Copyright (c) 2002-2009 Nokia Corporation and/or its subsidiary(-ies).
00003 // All rights reserved.
00004 // This component and the accompanying materials are made available
00005 // under the terms of the License "Eclipse Public License v1.0"
00006 // which accompanies this distribution, and is available
00007 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
00008 // 
00009 // Initial Contributors:
00010 // Nokia Corporation - initial contribution.
00011 // 
00012 // Contributors:
00013 // 
00014 // Description:
00015 // 
00016 
00017 #include <eikapp.h>
00018 #include <PopulateAgenda.rsg>
00019 
00020 #include "PopulateAgendaAppUi.h"
00021 #include "PopulateAgendaMainView.h"
00022 #include "CalWrite.h"
00023 #include "PopulateAgenda.hrh"
00024 
00025 void CPopulateAgendaAppUi::ConstructL()
00026         {
00027         BaseConstructL(EAknEnableSkin);
00028         iMainView = CPopulateAgendaMainView::NewL(ClientRect());
00029 
00030         iCalendarWriter = CCalWrite::NewL();
00031         }
00032         
00033 CPopulateAgendaAppUi::~CPopulateAgendaAppUi()
00034     {
00035     delete iCalendarWriter;
00036 #ifdef __SERIES60_3X__
00037         delete iMainView;
00038 #endif
00039     }
00040 
00041 void CPopulateAgendaAppUi::HandleCommandL(TInt aCommand)
00042         {
00043         switch ( aCommand )
00044                 {
00045 #ifdef __SERIES60_3X__
00046                 case EAknSoftkeyExit:
00047 #endif
00048                 case EEikCmdExit:
00049                         {
00050                         User::Exit(0);
00051                         break;
00052                         }
00053                 case EPopulateAgenda:
00054                         {
00055                         _LIT(KNewEntry1, "My First Meeting");
00056                         _LIT(KNewEntry2, "My Second Meeting");
00057                         _LIT(KAttendee1, "first person ");
00058                         _LIT(KAttendee2, "second person ");
00059                         // create entry a year from now at midnight
00060                         TTime temp;
00061                         temp.UniversalTime();
00062                         TDateTime futureDate = temp.DateTime();
00063                         futureDate.SetHour(0);
00064                         futureDate.SetMinute(0);
00065                         futureDate.SetSecond(0);
00066                         futureDate.SetMicroSecond(0);
00067                         TTime nextYear(futureDate);
00068                         nextYear += TTimeIntervalYears(1);
00069                         // with 2 other attendees.
00070                         CDesCArrayFlat* people = new (ELeave) CDesCArrayFlat(2);
00071                         CleanupStack::PushL(people);
00072                         people->AppendL(KAttendee1);
00073                         people->AppendL(KAttendee2);
00074                         TRAPD(error, iCalendarWriter->AddNewL(nextYear, KNewEntry1(), *people));
00075                         // report error on the Label control
00076                         if (KErrNone == error)
00077                                 {
00078                                 // and a second entry one day before the first.
00079                                 nextYear -= TTimeIntervalDays(1);
00080                                 TRAP(error, iCalendarWriter->AddNewL(nextYear, KNewEntry2(), *people));
00081                                 if (KErrNone == error)
00082                                         {
00083                                         _LIT(KSuccess, "It Worked!");
00084                                         iMainView->SetTextL(KSuccess());
00085                                         }
00086                                 }
00087                         if (KErrNone != error)
00088                                 {
00089                                 _LIT(KErrorMsg, "Symbian Error Code = %D");
00090                                 TBuf<32> errorBuf;
00091                                 errorBuf.Format(KErrorMsg(), error);
00092                                 iMainView->SetTextL(errorBuf);
00093                                 }
00094                         CleanupStack::PopAndDestroy(people);
00095                         break;
00096                         }
00097                 default:
00098                         break;
00099                 }
00100         }
00101 
00102         
00103 #ifdef __SERIES60_3X__
00104 
00105 void CPopulateAgendaAppUi::HandleResourceChangeL(TInt aType)
00106         {
00107         CAknAppUi::HandleResourceChangeL(aType);
00108         iMainView->SetRect(ClientRect());
00109         }
00110 
00111 #endif
00112         
00113 // End of File

Generated by  doxygen 1.6.2