examples/SFExamples/PIM/ContactMove/src/ContactMoveAppUi.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 <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                         // moving the own card to a group may not be such a good idea
00053                         // let's move the "Partner" card from \PIM\ContactFind
00054                         _LIT(KStringMatch, "Partner");
00055                         CContactIdArray* cards = NULL;
00056                         TFieldType type = KUidContactFieldGivenName;
00057                         TRAPD(error, cards = iContactWriter->FindWithCallbackL(type, KStringMatch()));
00058                         // report result on the Label control
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 // End of File

Generated by  doxygen 1.6.2