Reading and searching fields in sysbian address book

Source: Internet
Author: User

The following is an example of adding and searching. You need to add the header file and the ability to add the response and lib to the MMP. You can find it online.

Add example:

Tbool cinformationsynview: addcontactitem ()
{
_ Partition (kfname, "kkkkk ");
_ Partition (klname, "kkkkk ");
_ Partition (knumber, "13777777778 ");
 
_ Metadata (qkuidcontactfieldgivenname, "1111 ");
_ Metadata (qkuidcontactfieldfamilyname, "2222 ");
_ Metadata (qkuidcontactfieldcompanyname, "3333 ");
_ Blank (qkuidcontactfieldjobtitle, "4444 ");
_ Metadata (qkuidcontactfieldphonenumber, "5555 ");
_ Blank (qkuidcontactfieldfax, "6666 ");
_ DEFINE (qkuidcontactfieldsipid, "7777 ");
_ Messages (qkuidcontactfieldemail, "8888 ");
// Use the engine to open the default address book
Cpbkcontactengine * ipbkcontactengine = cpbkcontactengine: newl ();

// Create an empty Communication record
Cpbkcontactitem * Contact = ipbkcontactengine-> createemptycontactl ();
Cleanupstack: pushl (contact); // 2
// Set the First Name Domain
Tpbkcontactitemfield * field = contact-> findfield (epbkfieldidfirstname );
 
Field-> textstorage ()-> settextl (qkuidcontactfieldgivenname );
// Set the Last Name Domain // 2222
Field = contact-> findfield (epbkfieldidlastname );
Field-> textstorage ()-> settextl (qkuidcontactfieldfamilyname );
 
// Sets the companyName domain // 3333
Field = contact-> findfield (epbkfieldidcompanyname );
Field-> textstorage ()-> settextl (qkuidcontactfieldcompanyname );
 
// Sets the jobtitle domain // 4444
Field = contact-> findfield (epbkfieldidjobtitle );
Field-> textstorage ()-> settextl (qkuidcontactfieldjobtitle );
 
// Set phonenumbermobile. // 5555
Field = contact-> findfield (epbkfieldidphonenumbermobile );
Field-> textstorage ()-> settextl (qkuidcontactfieldphonenumber );
 
// Set the fax domain // 6666
Field = contact-> findfield (epbkfieldidfaxnumber );
Field-> textstorage ()-> settextl (qkuidcontactfieldfax );
 
// Set the idsipid domain // 7777
// Field = contact-> findfield (epbkfieldidsipid );
// If (field! = NULL ){
// Field-> textstorage ()-> settextl (qkuidcontactfieldsipid );
//}

// Set qkuidcontactfieldemail. // 8888
Field = contact-> findfield (epbkfieldidemailaddress );
Field-> textstorage ()-> settextl (qkuidcontactfieldemail );
 
// You can add other value ranges.
//...
// Add the modified result to the database and return the ID of the contact list item. This ID can be used later
Tcontactitemid id = ipbkcontactengine-> addnewcontactl (* contact );
Cleanupstack: popanddestroy (contact );
Return etrue;
}

 

 

 

Search example

Tbool cinformationsynview: searchcontactitem ()
{// Const tdesc & atelephonenumber

_ Parameters (givenname, "1111 ");
_ Values (familyname, "2222 ");
_ Timeout (phonenumber, "5555 ");
 
Tbuf <64> givenname (givenname );
Tbuf <64> familyname (familyname );
Tbuf <64> phonenumber (phonenumber );

Ccontactdatabase * contactsdb = ccontactdatabase: openl ();
Cleanupstack: pushl (contactsdb );

Cpbkcontactengine * ipbkcontactengine1 = cpbkcontactengine: newl ();
Cleanupstack: pushl (ipbkcontactengine1 );
 
Ccontactidarray * contactidarray = ipbkcontactengine1-> matchphonenumberl (phonenumber, phonenumber. Length ());
Cleanupstack: pushl (contactidarray );
Tint matchnumber = contactidarray-> count ();
// Ipbkcontactengine1-> mcontactdbobserver
If (contactidarray-> count ()> 0)
{
For (tint I = 0; I <matchnumber; I ++)
{
Tcontactitemid owncardid = (* contactidarray) [I];
Ccontactitem * owncard = contactsdb-> readcontactl (owncardid );
Cleanupstack: pushl (owncard );
Ccontactitemfieldset & currentfieldset = owncard-> cardfields ();
Tint givennamefieldid = currentfieldset. Find (kuidcontactfieldgivenname );
Tint familynamefieldid = currentfieldset. Find (kuidcontactfieldfamilyname );
If (givennamefieldid! = Kerrnotfound & familynamefieldid! = Kerrnotfound)
{// Read data
Tptrc name = owncard-> cardfields () [givennamefieldid]. textstorage ()-> text ();
Tptrc fname = owncard-> cardfields () [familynamefieldid]. textstorage ()-> text ();
Tint nint = givenname. comparec (name );
Tint fint = familyname. comparec (fname );
If (nint! = 0 & fint! = 0 ){
Return addcontactitem ();
}
}
Cleanupstack: popanddestroy (owncard );
}
}
Delete contactidarray;
Cleanupstack: popanddestroy (contactidarray );
Cleanupstack: popanddestroy (ipbkcontactengine1 );
Cleanupstack: popanddestroy (contactsdb );
Return efalse;

}

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.