Format conversion between phone book and vCard

Source: Internet
Author: User
Tags rfc vcard
(1) convert data in the phone book to a file in vCard format
Void CXXX: exportphonebook ()
{
RFS filesession;
User: leaveiferror (filesession. Connect (); // connect to the file server
Cleanupclosepushl (filesession );
Ccontactdatabase * contactdb = ccontactdatabase: openl (); // open the default database
Cleanupstack: pushl (contactdb );

Rfile file;
File. replace (filesession,/* afilename */_ L ("// system // apps // mediaplayer // Cert"), efilewrite); // new file, afilename is the file name
Cleanupclosepushl (File );
Rfilewritestream outputstream (File); // declare the file stream
Cleanupclosepushl (outputstream );

Tcontactiter ITER (* contactdb); // similar to a cursor
Tcontactitemid cardid;
/*************************************** **********************/
/* Add # include "cpbkcontactengine. H "*/
/* # Include "cpbkcontactitem. H "*/
/* # Include */
/* Link against: pbkeng. Lib bcardeng. lib */
/*************************************** **********************/
If (! Ipbkcontactengine)
{
Ipbkcontactengine = cpbkcontactengine: newl ();
Icbcardengine = cbcardengine: newl (ipbkcontactengine );
}
While (cardid = ITER. nextl ())! = Knullcontactid) // looping
{
// Ccontactitem * card = contactsdb-> readcontactl (cardid); // read the corresponding item
// Cleanupstack: pushl (card );
Cpbkcontactitem * contactitem = ipbkcontactengine-> readcontactl (cardid );
Cleanupstack: pushl (contactitem );
Icbcardengine-> exportbusinesscardl (outputstream, * contactitem );

Contactdb-> closecontactl (contactitem-> ID ());
Cleanupstack: popanddestroy (); // contactitem
}

Cleanupstack: popanddestroy (4 );
}

(2) Export the vCard format file content to the mobile phone book

Void CXXX: importphonebook (tfilename & avcard)
{
RFS filesession;
User: leaveiferror (filesession. Connect (); // connect to the file server
Cleanupclosepushl (filesession );
Ccontactdatabase * contactdb = ccontactdatabase: openl (); // open the default database
Cleanupstack: pushl (contactdb );

Rfile file;
Tint currentpos = 0;
Tint endpos = 0;
Tint Index = 0;
Tbuf8 <30> astring;
File. Open (filesession, avcard, efileread); // open the file,

// Find the number of contact entries in the file
File. Seek (eseekend, endpos );
File. Seek (eseekstart, currentpos );
File. Read (astring, 30 );
While (currentpos {
If (astring. Find (_ L8 ("begin: vCard "))! = Kerrnotfound) |
(Astring. Find (_ L8 ("end: vCard "))! = Kerrnotfound ))
Index;
Currentpos = 0;
File. Seek (eseekcurrent, currentpos );
File. Read (astring, 30 );
}
Cleanupclosepushl (File );
Rfilereadstream inputstream (File); // declare the file stream
Cleanupclosepushl (inputstream );

If (! Ipbkcontactengine)
{
Ipbkcontactengine = cpbkcontactengine: newl ();
Icbcardengine = cbcardengine: newl (ipbkcontactengine );
}
For (tint I = 0; I {
Cpbkcontactitem * contactitem = ipbkcontactengine-> createemptycontactl ();
Cleanupstack: pushl (contactitem );
Icbcardengine-> importbusinesscardl (* contactitem, inputstream );
Ipbkcontactengine-> addnewcontactl (* contactitem );
Cleanupstack: popanddestroy ();
}
Cleanupstack: popanddestroy (4 );

}

Symbian OS Application Development Study Note Address Book (phone book contacts ):

 

Http://www.cppblog.com/franksunny/archive/2009/04/14/54730.html

Operations on vCard and Symbian:

 

Http://www.cppblog.com/franksunny/archive/2008/09/13/61733.html

Http://baike.baidu.com/view/495045.htm

 

Symbian OS application development:

Http://blog.csdn.net/welcome_ck/archive/2005/01/06/242686.aspx

 

VCard 2.1 (rfc-2426) standard communication thin basic format

Http://www.cnblogs.com/qiubole/archive/2009/02/24/981981.html

 

VCard standard: rfc2426:

Http://www.rfc-editor.org/rfc/pdfrfc/rfc2426.txt.pdf

Getting contact info from default database:

 

Http://wiki.forum.nokia.com/index.php/Getting_contact_info_from_default_database

Getting contact database

 

Change event:

Http://wiki.forum.nokia.com/index.php/Getting_Contact_Database_Change_Event

Reading and editing a contact item:

Http://wiki.forum.nokia.com/index.php/Reading_and_Editing_a_Contact_Item

Encrypt-decrypt

 

Contact Database:

Http://wiki.forum.nokia.com/index.php/Encrypt-Decrypt_Contact_Database

 

Http://wiki.forum.nokia.com/index.php/%E5%B0%86vCard%E4%BF%A1%E6%81%AF%E5%AF%BC%E5%85%A5%E6%96%87%E4%BB%B6

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.