examples/SFExamples/PIM/ContactRemove/src/ContactRemoveAppUi.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 <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                         // this is just one easy way to get a TContactItemId.
00054                         // the \PIM\PopulateContact sample code would have created
00055                         // an own card
00056                         if (KNullContactId != cntId)
00057                                 {
00058                                 TRAPD(error, iContactWriter->RemoveContactL(cntId));
00059                                 // report error on the Label control
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 // End of File

Generated by  doxygen 1.6.2