00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #include <eikapp.h>
00018 #include <ContactRemove.rsg>
00019
00020 #include "ContactRemoveAppUi.h"
00021 #include "ContactRemoveMainView.h"
00022 #include "ContactWrite.h"
00023 #include "ContactRemove.hrh"
00024
00025 void CContactRemoveAppUi::ConstructL()
00026 {
00027 BaseConstructL(EAknEnableSkin);
00028 iMainView = CContactRemoveMainView::NewL(ClientRect());
00029
00030 iContactWriter = CContactWrite::NewL();
00031 }
00032
00033 CContactRemoveAppUi::~CContactRemoveAppUi()
00034 {
00035 delete iContactWriter;
00036 delete iMainView;
00037 }
00038
00039 void CContactRemoveAppUi::HandleCommandL(TInt aCommand)
00040 {
00041 switch ( aCommand )
00042 {
00043 case EAknSoftkeyExit:
00044 case EEikCmdExit:
00045 {
00046 Exit();
00047 break;
00048 }
00049 case EContactRemove:
00050 {
00051 CContactDatabase& cntDb = iContactWriter->CntDatabase();
00052 TContactItemId cntId = cntDb.OwnCardId();
00053
00054
00055
00056 if (KNullContactId != cntId)
00057 {
00058 TRAPD(error, iContactWriter->RemoveContactL(cntId));
00059
00060 if (KErrNone == error)
00061 {
00062 _LIT(KSuccess, "It Worked!");
00063 iMainView->SetTextL(KSuccess());
00064 }
00065 else
00066 {
00067 _LIT(KErrorMsg, "Symbian Error Code = %D");
00068 TBuf<32> errorBuf;
00069 errorBuf.Format(KErrorMsg(), error);
00070 iMainView->SetTextL(errorBuf);
00071 }
00072 }
00073 else
00074 {
00075 _LIT(KNotFound, "No Own Card");
00076 iMainView->SetTextL(KNotFound());
00077 }
00078 break;
00079 }
00080 default:
00081 break;
00082 }
00083 }
00084
00085
00086
00087 void CContactRemoveAppUi::HandleResourceChangeL(TInt aType)
00088 {
00089 CAknAppUi::HandleResourceChangeL(aType);
00090 iMainView->SetRect(ClientRect());
00091 }
00092
00093
00094