Use C ++ to access the Symbian phone book

Source: Internet
Author: User

In Symbian OS, the phone book is operated and managed through a default database (contacts. CDB. Therefore, in the Symbian system, you can use the contacts model API to access and manage the phone book. Here, the main class is ccontactdatabase (Database Class, set of all the phone books ), ccontactitem (which represents a separate phone book entry, identified by a unique tcontactitemid. For example, a contact in a phone book), ccontactitemfield (domain class, each phone book entry has many classes, such as Name Domain (epbkfieldidfirstname, epbkfieldidlastname), telephone number domain (epbkfieldidphonenumbergeneral )...).
The series60 developer has extended this model and used the "Phone Book engine". Below are several key classes.

Class cpbkcontactengine

The telephone book engine is implemented through cpbkcontactengine. If a default database already exists, cpbkcontactengine: newl () is connected to the database. Otherwise, the database is created.

Class cpbkcontactitem

The cpbkcontactitem class represents a specific entry in the phone book database, such as a contact. It provides access and search functions for the tpbkcontactitemfield array.

Class tpbkcontactitemfield

Tpbkcontactitemfield is the domain class of a thin phone entry, such as someone's telephone domain or someone's email.

// For more information about the phone book engine, see the SDK help.

// Haha, I will post a piece of code for accessing the phone book below. I hope you can correct it more.

Void cphoneengine: displaycontactinfol (mobjectprovider * amopparent)
{

Rpbkviewresourcefile phonebookresource (* (ceikonenv: static ()));

If (! Phonebookresource. isopen ())
{
Phonebookresource. openl ();
}

// Add searching array to parameters
Ccontactdatabase: tcontactviewfilter filter (ccontactdatabase: ephonable );
Cpbkmultipleentryfetchdlg: tparams Params;
Params. icontactview = & ipbkcontactengine-> filteredcontactsviewl (filter );

// Launch fetching Dialog
Cpbkmultipleentryfetchdlg * fetchdlg = cpbkmultipleentryfetchdlg: newl (Params, * ipbkcontactengine );
Fetchdlg-> setmopparent (amopparent );
Tint okpressed = fetchdlg-> executeld ();
Cleanupstack: pushl (Params. imarkedentries );

If (okpressed)
{

// Get the first selected contacts ID Array
Const tcontactitemid cid = (* Params. imarkedentries) [0];

// Open the selected contact using phonebook engine,
Cpbkcontactitem * pbkitem = ipbkcontactengine-> readcontactlc (CID );

// Get the first name
Tpbkcontactitemfield * fnamefield = pbkitem-> findfield (epbkfieldidfirstname );
Fnamefield-> gettextl (ifirstname );

// Get the last name
Tpbkcontactitemfield * lnamefield = pbkitem-> findfield (epbkfieldidlastname );
Lnamefield-> gettextl (ilastname );

// Get the general phonenumber
Tpbkcontactitemfield * phonefieldgeneral = pbkitem-> findfield (epbkfieldidphonenumbergeneral );
Phonefieldgeneral-> gettextl (inumbergeneral );

// Get the mobile phonenumber
Tpbkcontactitemfield * phonefieldmobile = pbkitem-> findfield (epbkfieldidphonenumbermobile );
Phonefieldmobile-> gettextl (inumbermoblie );

// Get the email address
Tbuf <30> emailaddress;
Tpbkcontactitemfield * emailfield = pbkitem-> findfield (epbkfieldidemailaddress );
Emailfield-> gettextl (emailaddress );

// Add codes to get other fields you interested in

//......

Cleanupstack: popanddestroy (pbkitem); // pbkitem, emailadd
}

// Release the resource
Cleanupstack: popanddestroy (); // imarkedentries
Phonebookresource. Close (); // close the phonebook View
}

// Note: Please indicate the source of the post or reference the above content!

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.