00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #include <eikapp.h>
00018 #include <ContactMove.rsg>
00019
00020 #include "ContactMoveAppUi.h"
00021 #include "ContactMoveMainView.h"
00022 #include "ContactWrite.h"
00023 #include "ContactMove.hrh"
00024
00025 void CContactMoveAppUi::ConstructL()
00026 {
00027
00028 BaseConstructL(EAknEnableSkin);
00029 iMainView = CContactMoveMainView::NewL(ClientRect());
00030
00031 iContactWriter = CContactWrite::NewL();
00032 }
00033
00034 CContactMoveAppUi::~CContactMoveAppUi()
00035 {
00036 delete iContactWriter;
00037 delete iMainView;
00038 }
00039
00040 void CContactMoveAppUi::HandleCommandL(TInt aCommand)
00041 {
00042 switch ( aCommand )
00043 {
00044 case EAknSoftkeyExit:
00045 case EEikCmdExit:
00046 {
00047 Exit();
00048 break;
00049 }
00050 case EContactMove:
00051 {
00052
00053
00054 _LIT(KStringMatch, "Partner");
00055 CContactIdArray* cards = NULL;
00056 TFieldType type = KUidContactFieldGivenName;
00057 TRAPD(error, cards = iContactWriter->FindWithCallbackL(type, KStringMatch()));
00058
00059 if (KErrNone == error && NULL != cards)
00060 {
00061 CleanupStack::PushL(cards);
00062 if (cards->Count() > 0)
00063 {
00064 _LIT(KGroup, "NewGroup");
00065 TRAP(error, iContactWriter->MoveContactL((*cards)[0], KGroup()));
00066 if (error == KErrNone)
00067 {
00068 _LIT(KSuccess, "It Worked !");
00069 iMainView->SetTextL(KSuccess());
00070 }
00071 }
00072 else
00073 {
00074 _LIT(KNotFoundMsg, "Card Not Found");
00075 iMainView->SetTextL(KNotFoundMsg());
00076 }
00077 CleanupStack::PopAndDestroy(cards);
00078 }
00079 if (error != KErrNone)
00080 {
00081 _LIT(KErrorMsg, "Symbian Error Code = %D");
00082 TBuf<32> errorBuf;
00083 errorBuf.Format(KErrorMsg(), error);
00084 iMainView->SetTextL(errorBuf);
00085 }
00086 break;
00087 }
00088 default:
00089 break;
00090 }
00091 }
00092
00093
00094
00095 void CContactMoveAppUi::HandleResourceChangeL(TInt aType)
00096 {
00097 CAknAppUi::HandleResourceChangeL(aType);
00098 iMainView->SetRect(ClientRect());
00099 }
00100
00101
00102