⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 contatcssearchappui.cpp

📁 Search Phone number example is for search the phone number from contact books in symbian c++
💻 CPP
字号:
/* ====================================================================
 * File: ContatcsSearchAppUi.cpp
 * Created: 09/07/07
 * Author: 
 * Copyright (c):  All rights reserved
 * ==================================================================== */

#include <avkon.hrh>
#include <aknnotewrappers.h> 
#include <CNTFLDST.H>
#include <CNTITEM.H>

#include "ContatcsSearch.pan"
#include "ContatcsSearchAppUi.h"
#include "ContatcsSearchAppView.h"
#include "ContatcsSearch.hrh"

// phone number to search
_LIT(KToken,"+9199 083 44484");
// ConstructL is called by the application framework
void CContatcsSearchAppUi::ConstructL()
    {
    BaseConstructL();

    iAppView = CContatcsSearchAppView::NewL(ClientRect());    

    AddToStackL(iAppView);
    }

CContatcsSearchAppUi::CContatcsSearchAppUi()                              
    {
	// no implementation required
    }

CContatcsSearchAppUi::~CContatcsSearchAppUi()
    {
    if (iAppView)
        {
        RemoveFromStack(iAppView);
        delete iAppView;
        iAppView = NULL;
        }
	if (iContactsDb)
	{
		delete iContactsDb;
		iContactsDb = NULL;
	}
    if (iMyIdArray)
    {
    	delete iMyIdArray;
    	iMyIdArray = NULL;
    }
    }

// handle any menu commands
void CContatcsSearchAppUi::HandleCommandL(TInt aCommand)
    {
    switch(aCommand)
        {
        case EEikCmdExit:
        case EAknSoftkeyExit:
            Exit();
            break;

        case EContatcsSearchCommand1:
            {
			SearchPhNum();			
            }
            break;

        default:
            Panic(EContatcsSearchBasicUi);
            break;
        }
    }


void CContatcsSearchAppUi::SearchPhNum()	
    {

    TBuf<20> token(KToken);
    TBuf<128> callNameBuf;

    // Opens the default contact database           
    iContactsDb = CContactDatabase::OpenL();

    // Search for all phonebook items matching phone number
    iMyIdArray= iContactsDb->MatchPhoneNumberL(token,15);
    // Count of matchings found
    callNameBuf.AppendNum(iMyIdArray->Count());
    CEikonEnv::InfoWinL(_L("Count of Matches"),callNameBuf);

    // Reading matched contacts info
    for(TInt i = 0;i < iMyIdArray->Count();i++)
	{
	TContactItemId id = (*iMyIdArray)[i];
        // Read contact using id
	CContactItem* contact = iContactsDb->ReadContactL(id);
	CleanupStack::PushL(contact);
        // Get a reference to the contact item's field set
	CContactItemFieldSet& fieldSet = contact->CardFields();
        // Read and display all fields
	for ( TInt j = 0 ; j < fieldSet.Count() ; j++ )
		{
		const CContactItemField& field = fieldSet[j] ;
                // phone numbers are stored in database using text fields
		callNameBuf.Copy(field.TextStorage()->Text());
		CEikonEnv::InfoWinL(callNameBuf,field.Label());
		}
	CleanupStack::PopAndDestroy();
	}
    }

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -