// The name folder is opened in a window.
// # Include <cpbkviewstate. h>
// Readdevicedata writedevicedata
// Pbkview. Lib
Void cledpointappui: openinfraredl ()
{
Cpbkviewstate * pbkviewparam = cpbkviewstate: newlc ();
Pbkviewparam-> setfocusedcontactid (0 );
// Package and return object in a buffer.
Hbufc8 * parambuf = pbkviewparam-> packlc ();
// Uid of the name clip
Const tuid appuid =
{
0x101f4cce
};
// Open the page
Ccoeappui: activateviewl (tvwsviewid (appuid, tuid: UID (1 )),
Cpbkviewstate: UID (), * parambuf );
// Cleanup
Cleanupstack: popanddestroy (2); // parambuf, pbkviewparam
}
Enumeration value corresponding to a field in a business card
Epbkfieldidlastname
Epbkfieldidfirstname
Epbkfieldidphonenumbermobile phone no.
Epbkfieldidphonenumberstandard phone number
Epbkfieldidemailaddress email
Epbkfieldidcompanyname
Epbkfieldidjobtitle
Epbkfieldidfaxnumber Fax
// ------------------------------------------ Open the name folder window ----------------------------------------
Cpbkviewstate * pbkviewparam = cpbkviewstate: newlc ();
Pbkviewparam-> setfocusedcontactid (0); // set the selected ID in this window.
// Package and return object in a buffer.
Hbufc8 * parambuf = pbkviewparam-> packlc ();
// Uid of the name clip
Const tuid appuid =
{
0x101f4cce
};
// Open the page
Ccoeenv: static ()-> Appui ()-> activateviewl (tvwsviewid (appuid, tuid: UID (1 )),
Cpbkviewstate: UID (), * parambuf );
Cleanupstack: popanddestroy (2); // parambuf, pbkviewparam
// ---------------------------------------- Create a new business card ----------------------------------------
// Ipbkcontactengine is a member variable of the class.
// Address book
// Ipbkcontactengine = cpbkcontactengine: newl ();
Rpbkviewresourcefile phonebookresource (* (ceikonenv: static ()));
If (! Phonebookresource. isopen ())
{
Phonebookresource. openl ();
}
Cpbkcontactitem * contactitem = ipbkcontactengine-> createemptycontactl ();
Cleanupstack: pushl (contactitem );
Cpbkcontacteditordlg * Editor = cpbkcontacteditordlg: newl (
* Ipbkcontactengine, * contactitem, etrue );
Tcontactitemid id = Editor-> executeld ();
Cleanupstack: popanddestroy (contactitem );
Phonebookresource. Close ();
// ---------------------------------------- Create a new business card and set the default field ----------------------------------------
// Ipbkcontactengine is a member variable of the class.
// Address book
// Ipbkcontactengine = cpbkcontactengine: newl ();
Rpbkviewresourcefile phonebookresource (* (ceikonenv: static ()));
If (! Phonebookresource. isopen ())
{
Phonebookresource. openl ();
}
Cpbkcontactitem * contactitem = ipbkcontactengine-> createemptycontactl ();
Cleanupstack: pushl (contactitem );
// Set the field content
Tpbkcontactitemfield * fieldfirstname = contactitem-> findfield (epbkfieldidfirstname );
Fieldfirstname-> textstorage ()-> settextl (_ L ("costya "));
Cpbkcontacteditordlg * Editor = cpbkcontacteditordlg: newl (
* Ipbkcontactengine, * contactitem, etrue );
Tcontactitemid id = Editor-> executeld ();
Cleanupstack: popanddestroy (contactitem );
Phonebookresource. Close (); // close the phonebook View
// ------------------------------------------ Modify a business card ----------------------------------------
// Obtain the tcontactitem ID of the record
Tcontactitemid tid = iallrecord [aid]-> irecordid;
Rpbkviewresourcefile phonebookresource (* (ceikonenv: static ()));
If (! Phonebookresource. isopen ())
{
Phonebookresource. openl ();
}
Cpbkcontactitem * contactitem = ipbkcontactengine-> opencontactl (TID );
Cleanupstack: pushl (contactitem );
Cpbkcontacteditordlg * Editor = cpbkcontacteditordlg: newl (
* Ipbkcontactengine, * contactitem, efalse );
Tcontactitemid id = Editor-> executeld ();
Cleanupstack: popanddestroy (contactitem );
Ipbkcontactengine-> closecontactl (TID );
Phonebookresource. Close ();
// ------------------------------------------ Search for a business card ----------------------------------------
// Obtain the contact address book tcontactitemid
Tcontactitemid tid = iallrecord [aid]-> irecordid;
Cpbkcontactitem * pcontactitem = ipbkcontactengine-> opencontactl (TID );
// Execute the next record if the record set is empty.
If (pcontactitem = NULL)
{
Return;
}
// If the record is not searched, execute the next line.
If (TID! = Pcontactitem-> ID ())
{
Return;
}
// It is the record to be searched. Start to assemble the business card string below
Tpbkcontactitemfield * pcntfield;
Tbuf <500> bvalue;
Tbuf <100> bname;
// Get the last name
Bvalue. Zero ();
Pcntfield = pcontactitem-> findfield (epbkfieldidlastname );
If (pcntfield)
{
Pcntfield-> gettextl (bvalue );
Bname. Zero ();
Ceikonenv: static ()-> readresource (bname, r_card_first_name );
Bcard. append (bname );
Bcard. append (bvalue );
Bcard. append (krn );
}
// Get the name
Bvalue. Zero ();
Pcntfield = pcontactitem-> findfield (epbkfieldidfirstname );
If (pcntfield)
{
Pcntfield-> gettextl (bvalue );
Bname. Zero ();
Ceikonenv: static ()-> readresource (bname, r_card_last_name );
Bcard. append (bname );
Bcard. append (bvalue );
Bcard. append (krn );
}
// Obtain the mobile phone number
Bvalue. Zero ();
Pcntfield = pcontactitem-> findfield (epbkfieldidphonenumbermobile );
If (pcntfield)
{
Pcntfield-> gettextl (bvalue );
Bname. Zero ();
Ceikonenv: static ()-> readresource (bname, r_card_phone );
Bcard. append (bname );
Bcard. append (bvalue );
Bcard. append (krn );
}
Delete pcontactitem;
Pcontactitem = NULL;
Ipbkcontactengine-> closecontactl (TID );
// At This Point, Bcard obtains the business card information.
// ------------------------------------------ When the name folder changes ----------------------------------------
Class cControl: Public cbase,
Public mpbkcontactdbobserver
{
Public:
// When the address book changes, the system automatically calls this function.
Virtual void handledatabaseeventl (tcontactdbobserverevent aevent );
PRIVATE:
// Address Book Engine
Cpbkcontactengine * ipbkcontactengine;
// Address book Monitoring
Cpbkcontactchangenotifier * ipbkcontactnotifier;
}
Void CXXX: constructl ()
{
// Create the address book Engine
Ipbkcontactengine = cpbkcontactengine: newl ();
// Create an Event Notification class
Ipbkcontactnotifier = cpbkcontactchangenotifier: newl (* ipbkcontactengine, this );
}
Void CXXX: handledatabaseeventl (tcontactdbobserverevent aevent)
{
// The changed item.
Tcontactitemid contactid = aevent. icontactid;
Switch (aevent. itype)
{
// When modifying the address book
Case econtactdbobservereventcontactchanged:
{
Break;
}
// When deleting the address book
Case econtactdbobservereventcontactdeleted:
{
Break;
}
// When adding the address book
Case econtactdbobservereventcontactadded:
{
Break;
}
Default:
{
}
Break;
}
}
// ------------------------------------------ Open the details page of a contact ----------------------------------------
// Obtain the tcontactitem ID of the record
Tcontactitemid tid = // tcontactitem of the business card
Const tuid appuid =
{
0x101f4cce
};
Const tuid kextviewuid =
{
4
}; // View uid of the corresponding information page
Cpbkviewstate * pbkviewparam = cpbkviewstate: newlc ();
Tint contact_id = tid;
Pbkviewparam-> setfocusedcontactid (contact_id );
Hbufc8 * parambuf = pbkviewparam-> packlc ();
Ccoeenv: static ()-> Appui ()-> activateviewl (tvwsviewid (appuid, kextviewuid), cpbkviewstate: UID (),
* Parambuf );
Cleanupstack: popanddestroy (2); // parambuf, pbkviewpara
// --------------------- In the address book, when a person has multiple mobile phones, the phone number selection box is displayed. -------------------------------
Rpbkviewresourcefile pbkviewresourcefile (* ccoeenv: static ());
Pbkviewresourcefile. openl ();
Const tcontactitemid cid = // get the ID in the address book;
Tbuf <128> phonenumber;
Tbuf <128> phonename;
Tbool namefound = efalse;
Cpbkcontactitem * pbkitem = ipbkcontactengine-> readcontactlc (CID );
Cpbkphonenumberselect * DLG = new (eleave) cpbkphonenumberselect ();
Cpbkphonenumberselect: tparams addparams (* pbkitem );
Tbool selected = DLG-> executeld (addparams );
If (selected)
{
// Obtain the selected fields, such as mobile, mobile (office), telephone, and home phone. You can find the additional fields through numtmp-> label ().
Const tpbkcontactitemfield * numtmp = addparams. selectedfield ();
If (numtmp)
{
Phonenumber = numtmp-> text ();
}
Tpbkcontactitemfield * nametmp;
If (nametmp = pbkitem-> findfield (epbkfieldidfirstname ))! = NULL)
{
Phonename = nametmp-> text ();
If (phonename. Length ()> 0)
{
Namefound = etrue;
}
}
If (nametmp = pbkitem-> findfield (epbkfieldidlastname ))! = NULL)
{
If (namefound)
{
Phonename. append (_ L (""));
Phonename. append (nametmp-> text ());
}
Else
{
Phonename = nametmp-> text ();
}
}
}
Cleanupstack: popanddestroy (1); // cpbkcontactitem
Pbkviewresourcefile. Close ();
// If there is a call, call
If (0 <phonenumber. Length ())
{
// Until now, phonenumber is the selected phone number.
}