00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #include <eikapp.h>
00018 #include <ContactWriteNewField.rsg>
00019
00020 #include "ContactWriteNewFieldAppUi.h"
00021 #include "ContactWriteNewFieldMainView.h"
00022 #include "ContactWrite.h"
00023 #include "ContactWriteNewField.hrh"
00024
00025 void CContactWriteNewFieldAppUi::ConstructL()
00026 {
00027 BaseConstructL(EAknEnableSkin);
00028 iMainView = CContactWriteNewFieldMainView::NewL(ClientRect());
00029 iContactWriter = CContactWrite::NewL();
00030 }
00031
00032 CContactWriteNewFieldAppUi::~CContactWriteNewFieldAppUi()
00033 {
00034 delete iContactWriter;
00035 delete iMainView;
00036 }
00037
00038 void CContactWriteNewFieldAppUi::HandleCommandL(TInt aCommand)
00039 {
00040 switch ( aCommand )
00041 {
00042 case EAknSoftkeyExit:
00043 case EEikCmdExit:
00044 {
00045 Exit();
00046 break;
00047 }
00048 case EContactWriteNewFieldAddEmployer:
00049 {
00050 _LIT(KNewEmployer, "Symbian Press Ltd");
00051 CContactDatabase& cntDb = iContactWriter->CntDatabase();
00052 TContactItemId cntId = cntDb.OwnCardId();
00053
00054
00055
00056 if (KNullContactId != cntId)
00057 {
00058 TRAPD(error, iContactWriter->AddEmployerL(cntId, KNewEmployer()));
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 CContactWriteNewFieldAppUi::HandleResourceChangeL(TInt aType)
00088 {
00089 CAknAppUi::HandleResourceChangeL(aType);
00090 iMainView->SetRect(ClientRect());
00091 }
00092
00093
00094