00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #include <eikapp.h>
00018 #include <ContactReadField.rsg>
00019
00020 #include "ContactReadFieldAppUi.h"
00021 #include "ContactReadFieldMainView.h"
00022 #include "ContactRead.h"
00023 #include "ContactReadField.hrh"
00024
00025 void CContactReadFieldAppUi::ConstructL()
00026 {
00027 BaseConstructL(EAknEnableSkin);
00028 iMainView = CContactReadFieldMainView::NewL(ClientRect());
00029
00030 iContactReader = CContactRead::NewL();
00031 }
00032
00033 CContactReadFieldAppUi::~CContactReadFieldAppUi()
00034 {
00035 delete iContactReader;
00036 #ifdef __SERIES60_3X__
00037 delete iMainView;
00038 #endif
00039 }
00040
00041 void CContactReadFieldAppUi::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 EContactReadField:
00054 {
00055 TFieldType type = KUidContactFieldGivenName;
00056 CContactDatabase& cntDb = iContactReader->CntDatabase();
00057 TContactItemId cntId = cntDb.OwnCardId();
00058
00059
00060
00061 if (KNullContactId != cntId)
00062 {
00063 CDesCArray* result = NULL;
00064 TRAPD(error, result = iContactReader->ReadTextFieldL(cntId, type));
00065
00066 if (KErrNone == error)
00067 {
00068 CleanupStack::PushL(result);
00069 if (result->Count() > 0)
00070 {
00071 iMainView->SetTextL(result->MdcaPoint(0));
00072 }
00073 else
00074 {
00075 _LIT(KFieldNotFound, "Field Not Found");
00076 iMainView->SetTextL(KFieldNotFound());
00077 }
00078 CleanupStack::PopAndDestroy(result);
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 }
00088 else
00089 {
00090 _LIT(KCardNotFound, "No Own Card");
00091 iMainView->SetTextL(KCardNotFound());
00092 }
00093 break;
00094 }
00095 default:
00096 break;
00097 }
00098 }
00099
00100
00101 #ifdef __SERIES60_3X__
00102
00103 void CContactReadFieldAppUi::HandleResourceChangeL(TInt aType)
00104 {
00105 CAknAppUi::HandleResourceChangeL(aType);
00106 iMainView->SetRect(ClientRect());
00107 }
00108
00109 #endif
00110
00111