examples/SFExamples/PIM/PopulateContact/src/PopulateContactAppUi.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 <PopulateContact.rsg>
00019 
00020 #include "PopulateContactAppUi.h"
00021 #include "PopulateContactMainView.h"
00022 #include "ContactWrite.h"
00023 #include "PopulateContact.hrh"
00024 
00025 void CPopulateContactAppUi::ConstructL()
00026         {
00027         BaseConstructL(EAknEnableSkin);
00028         iMainView = CPopulateContactMainView::NewL(ClientRect());
00029 
00030         iContactWriter = CContactWrite::NewL();
00031         }
00032         
00033 CPopulateContactAppUi::~CPopulateContactAppUi()
00034     {
00035     delete iContactWriter;
00036 #ifdef __SERIES60_3X__
00037         delete iMainView;
00038 #endif
00039     }
00040 
00041 void CPopulateContactAppUi::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 EPopulateContact:
00054                         {
00055                         TRAPD(error, iContactWriter->PopulateContactL());
00056                         // report error on the Label control
00057                         if (KErrNone == error)
00058                                 {
00059                                 _LIT(KSuccess, "It Worked!");
00060                                 iMainView->SetTextL(KSuccess());
00061                                 }
00062                         else
00063                                 {
00064                                 _LIT(KErrorMsg, "Symbian Error Code = %D");
00065                                 TBuf<32> errorBuf;
00066                                 errorBuf.Format(KErrorMsg(), error);
00067                                 iMainView->SetTextL(errorBuf);
00068                                 }
00069                         break;
00070                         }
00071                 case EDeleteDatabase:
00072                         {
00073                         TRAPD(error, iContactWriter->CntDatabase().DeleteDefaultFileL());
00074                         // report error on the Label control
00075                         if (KErrNone == error)
00076                                 {
00077                                 _LIT(KSuccess, "It Worked!");
00078                                 iMainView->SetTextL(KSuccess());
00079                                 }
00080                         else
00081                                 {
00082                                 _LIT(KErrorMsg, "Symbian Error Code = %D");
00083                                 TBuf<32> errorBuf;
00084                                 errorBuf.Format(KErrorMsg(), error);
00085                                 iMainView->SetTextL(errorBuf);
00086                                 }
00087                         break;
00088                         }
00089                 default:
00090                         break;
00091                 }
00092         }
00093 
00094         
00095 #ifdef __SERIES60_3X__
00096 
00097 void CPopulateContactAppUi::HandleResourceChangeL(TInt aType)
00098         {
00099         CAknAppUi::HandleResourceChangeL(aType);
00100         iMainView->SetRect(ClientRect());
00101         }
00102 
00103 #endif
00104         
00105 // End of File

Generated by  doxygen 1.6.2