examples/SFExamples/PIM/ContactWriteNewField/src/ContactWriteNewFieldAppUi.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 <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                         // this is just one easy way to get a TContactItemId.
00054                         // the \PIM\PopulateContact sample code would have created
00055                         // an own card without an employer.
00056                         if (KNullContactId != cntId)
00057                                 {
00058                                 TRAPD(error, iContactWriter->AddEmployerL(cntId, KNewEmployer()));
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 CContactWriteNewFieldAppUi::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