examples/SFExamples/PIM/AgendaAdd/src/AgendaAddAppUi.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 <AgendaAdd.rsg>
00019 
00020 #include "AgendaAddAppUi.h"
00021 #include "AgendaAddMainView.h"
00022 #include "CalWrite.h"
00023 #include "AgendaAdd.hrh"
00024 
00025 void CAgendaAddAppUi::ConstructL()
00026         {
00027         BaseConstructL(EAknEnableSkin);
00028         iMainView = CAgendaAddMainView::NewL(ClientRect());
00029 
00030 
00031         iCalendarWriter = CCalWrite::NewL();
00032         }
00033         
00034 CAgendaAddAppUi::~CAgendaAddAppUi()
00035     {
00036     delete iCalendarWriter;
00037 #ifdef __SERIES60_3X__
00038         delete iMainView;
00039 #endif
00040     }
00041 
00042 void CAgendaAddAppUi::HandleCommandL(TInt aCommand)
00043         {
00044         switch ( aCommand )
00045                 {
00046 #ifdef __SERIES60_3X__
00047                 case EAknSoftkeyExit:
00048 #endif
00049                 case EEikCmdExit:
00050                         {
00051                         User::Exit(0);
00052                         break;
00053                         }
00054                 case EAgendaAdd:
00055                         {
00056                         _LIT(KNewEntry, "New Entry");
00057                         // create entry 13 months from now as \PIM\PopulateAgenda
00058                         // would have created entries a year from now.
00059                         TTime nextYear;
00060                         nextYear.UniversalTime();
00061                         nextYear += TTimeIntervalMonths(13);
00062                         TRAPD(error, iCalendarWriter->AddNewL(nextYear, KNewEntry()));
00063                         // report error on the Label control
00064                         if (KErrNone == error)
00065                                 {
00066                                 _LIT(KSuccess, "It Worked!");
00067                                 iMainView->SetTextL(KSuccess());
00068                                 }
00069                         else
00070                                 {
00071                                 _LIT(KErrorMsg, "Symbian Error Code = %D");
00072                                 TBuf<32> errorBuf;
00073                                 errorBuf.Format(KErrorMsg(), error);
00074                                 iMainView->SetTextL(errorBuf);
00075                                 }
00076                         break;
00077                         }
00078                 default:
00079                         break;
00080                 }
00081         }
00082 
00083         
00084 #ifdef __SERIES60_3X__
00085 
00086 void CAgendaAddAppUi::HandleResourceChangeL(TInt aType)
00087         {
00088         CAknAppUi::HandleResourceChangeL(aType);
00089         iMainView->SetRect(ClientRect());
00090         }
00091 
00092 #endif
00093         
00094 // End of File

Generated by  doxygen 1.6.2