examples/SFExamples/PIM/ContactFind/src/ContactFindAppUi.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 <ContactFind.rsg>
00019 
00020 #include "ContactFindAppUi.h"
00021 #include "ContactFindMainView.h"
00022 #include "ContactRead.h"
00023 #include "ContactFind.hrh"
00024 
00025 void CContactFindAppUi::ConstructL()
00026         {
00027         BaseConstructL(EAknEnableSkin);
00028         iMainView = CContactFindMainView::NewL(ClientRect());
00029 
00030         iContactReader = CContactRead::NewL();
00031         }
00032         
00033 CContactFindAppUi::~CContactFindAppUi()
00034     {
00035     delete iContactReader;
00036 #ifdef __SERIES60_3X__
00037         delete iMainView;
00038 #endif
00039     }
00040 
00041 void CContactFindAppUi::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 EContactFind:
00054                         {
00055                         // \PIM\PopulateContact should have created at a card with the
00056                         // name set to "Partner"
00057                         _LIT(KStringMatch, "Partner");
00058                         CContactIdArray* result = NULL;
00059                         TFieldType type = KUidContactFieldGivenName;
00060                         TRAPD(error, result = iContactReader->FindWithCallbackL(type, KStringMatch()));
00061                         // report result on the Label control
00062                         if (KErrNone == error && NULL != result)
00063                                 {
00064                                 // No CleanupStack::PushL this time. Nothing can leave.
00065                                 TBuf<64> textBuf;
00066                                 _LIT(KPrefix, "success :");
00067                                 _LIT(KCardId, " %D");
00068                                 textBuf.Append(KPrefix());
00069                                 for (TInt ii = 0; ii < result->Count() && ii < 3; ++ii)
00070                                         {
00071                                         textBuf.AppendFormat(KCardId(), (*result)[ii]);
00072                                         }
00073                                 delete result;
00074                                 iMainView->SetTextL(textBuf);
00075                                 }
00076                         else
00077                                 {
00078                                 _LIT(KErrorMsg, "Symbian Error Code = %D");
00079                                 TBuf<32> errorBuf;
00080                                 errorBuf.Format(KErrorMsg(), error);
00081                                 iMainView->SetTextL(errorBuf);
00082                                 }
00083                         break;
00084                         }
00085                 default:
00086                         break;
00087                 }
00088         }
00089 
00090         
00091 #ifdef __SERIES60_3X__
00092 
00093 void CContactFindAppUi::HandleResourceChangeL(TInt aType)
00094         {
00095         CAknAppUi::HandleResourceChangeL(aType);
00096         iMainView->SetRect(ClientRect());
00097         }
00098 
00099 #endif
00100         
00101 // End of File

Generated by  doxygen 1.6.2