Difference between retrieving contact data from EDB and using the icontact interface in ipvs mobile system

Source: Internet
Author: User

1. Briefly introduce EDB

Previously, wm5 systems generally used CEDB databases, and EDB is one of the new features in wm5. To improve application performance and long-term portability, CEDB has been replaced by EDB. EDB utilizes the storage subsystem used by SQL mobile and provides performance significantly better than CEDB (especially when used together with persistent storage ). Because CEDB provides the same function set as EDB, all functions have the same name and parameter list. However, EDB also contains no functions in CEDB, And the creation method is also different. It is more complex than CEDB. Generally, the CEDB database is used in the system before wm5, EDB is one of the new features in wm5. To improve application performance and long-term portability, CEDB has been replaced by EDB. EDB utilizes the storage subsystem used by SQL mobile and provides performance significantly better than CEDB (especially when used together with persistent storage ). Because CEDB provides the same function set as EDB, all functions have the same name and parameter list. However, EDB also contains functions not included in CEDB, And the creation method is different, which is more complex than CEDB. (The above is taken from a webpage ). In wm6.1, you can use File Viewer to view the EDB database created by the mobile system of Microsoft for contacts, emails, and other systems. In/Windows, you can see Pim. VOL (access clog in this volume. DB, contacts database, and other databases), cemail. VOL (mainly used for email, SMS, and MSM databases ).

2. Introduction to poom

Poom is a set of COM interface libraries based on Microsoft COM technology for personal information management on mobile phones (PIM. In my personal understanding, he is actually some interfaces written by Microsoft (used to retrieve personal information). the deepest part of the interface should actually be the method of reading the EDB database, so why is it slower to use poom to retrieve contact information than to use EDB directly? Continue and you will find the difference.

3. perform specific code operations to retrieve data

Using the poom method to retrieve contact contacts is also excerpted in my space. You can also refer to the following URL:

Http://blog.csdn.net/durone/archive/2006/06/07/778589.aspx

The following describes how to obtain contact information using EDB:

# Define EDB (next post)

# Pragma comment (Lib, "coredll. lib ")

/*!

@ Brief

Open the EDB.

@ Param [in] datebasename the point to the Datebase name.

@ Param [out] ceguid a buffer that is filled with the ceguid of the mounted database.

@ Return HR:

Not null if open successed "n

Null if open failed

*/

Handle openedb (tchar * datebasename, ceguid)

{

Create_invalidguid (& ceguid );

Ceoid OID = 0;

// Pim. Vol is a volume that stores personal information, including contacts and appointment tables.

If (false = cemountdbvolex (& ceguid, l "Pim. Vol", null, open_existing ))

{

DWORD dwerr = getlasterror ();

Ceunmountdbvol (& ceguid );

Return NULL;

}

Handle hedb = NULL;

// Open EDB

Hedb = ceopendatabaseinsession (null, & ceguid, & OID, datebasename, null, cedb_autoincrement, null );

Return hedb;

}

/*!

@ Brief

Close the EDB.

@ Param [in] hedb the handle of the EDB.

@ Param [in] ceguid a buffer that is filled with the ceguid of the mounted database.

*/

Hresult closeedb (handle hedb, ceguid)

{

Hresult hR = e_fail;

If (null! = Hedb)

{

Closehandle (hedb); // close the EDB

}

If (null! = & Ceguid)

{

Ceflushdbvol (& ceguid );

Ceunmountdbvol (& ceguid); // unload the mount.

}

HR = s_ OK;

Return hr;

}

 

// The following function is used to filter the content required by my struct and save it.

Void getcontactinformationbyedb (cepropval pdate,

Smartdialcontent * psmart)

{

// Smartdialcontent is a struct defined by myself

Switch (pdate. propid)

{

Case pimpr_first_name:

Wcscat (psmart-> m_szname, pdate. Val. lpwstr );

Break;

Case pimpr_middle_name:

If (wcslen (psmart-> m_szname)> 0)

{

Wcscat (psmart-> m_szname, l "");

}

Wcscat (psmart-> m_szname, pdate. Val. lpwstr );

Break;

Case pimpr_last_name:

Wcscat (psmart-> m_szfamilyname, pdate. Val. lpwstr );

Break;

Case pimpr_assistant_telephone_number:

Filtratedialernumber (pdate. Val. lpwstr );

Wcscpy (psmart-> m_szphonenumber [0], pdate. Val. lpwstr );

Break;

Case pimpr_mobile_telephone_number:

Filtratedialernumber (pdate. Val. lpwstr );

Wcscpy (psmart-> m_szphonenumber [1], pdate. Val. lpwstr );

Break;

Case pimpr_business_telephone_number:

Filtratedialernumber (pdate. Val. lpwstr );

Wcscpy (psmart-> m_szphonenumber [2], pdate. Val. lpwstr );

Break;

Case pimpr_business2_telephone_number:

Filtratedialernumber (pdate. Val. lpwstr );

Wcscpy (psmart-> m_szphonenumber [3], pdate. Val. lpwstr );

Break;

Case pimpr_home_telephone_number:

Filtratedialernumber (pdate. Val. lpwstr );

Wcscpy (psmart-> m_szphonenumber [4], pdate. Val. lpwstr );

Break;

Case pimpr_home2_telephone_number:

Filtratedialernumber (pdate. Val. lpwstr );

Wcscpy (psmart-> m_szphonenumber [5], pdate. Val. lpwstr );

Break;

Case pimpr_company_telephone_number:

Filtratedialernumber (pdate. Val. lpwstr );

Wcscpy (psmart-> m_szphonenumber [6], pdate. Val. lpwstr );

Break;

Case pimpr_pager_number:

Filtratedialernumber (pdate. Val. lpwstr );

Wcscpy (psmart-> m_szphonenumber [7], pdate. Val. lpwstr );

Break;

Case pimpr_car_telephone_number:

Wcscpy (psmart-> m_szphonenumber [8], pdate. Val. lpwstr );

Break;

Case pimpr_radio_telephone_number:

Filtratedialernumber (pdate. Val. lpwstr );

Wcscpy (psmart-> m_szphonenumber [9], pdate. Val. lpwstr );

Break;

Case pimpr_business_fax_number:

Filtratedialernumber (pdate. Val. lpwstr );

Wcscpy (psmart-> m_szphonenumber [10], pdate. Val. lpwstr );

Break;

Case pimpr_home_fax_number:

Filtratedialernumber (pdate. Val. lpwstr );

Wcscpy (psmart-> m_szphonenumber [11], pdate. Val. lpwstr );

Break;

Default:

Break;

}

}

Hresult getcontactfromedb (smartdial_list * pcontactlist, smartdial_list * psimlist)

{

Hresult hR = e_fail;

Ceguid g_ceguid = {0 };

// Contacts database is the access contact. In fact, the SIM card content is also in it.

Handle hedb = openedb (L "Contacts Database", g_ceguid );

If (null = hedb)

{

Return hr;

}

Dword count = 0;

Const int max_buf_size = 256;

Word wnumrecprops = 0; // Number of readable attributes in a record of the database

Lpbyte lprecprops = NULL; // byte pointer to the read data

Pcepropval = NULL; // structure of each record

DWORD dwbuflen = max_buf_size;

// Move the cursor of the database to the start point of the database.

Ceoid = ceseekdatabaseex (hedb, cedb_seek_beginning, 0, & COUNT );

// Read the ending cyclically from the header, and read each time. obtain the required content from the lpbyte.

While (true)

{

// Read recordprops, return lprecprops

Ceoid = cereadrecordprops (hedb, cedb_allowrealloc, & wnumrecprops, null, & lprecprops, & dwbuflen );

If (! Ceoid)

{

Switch (getlasterror ())

{

Case error_no_more_items:

// Assert (false );

Break;

Default:

Return hr;

}

Break;

}

// Convert byte content into the data structure type of our operation

Pcepropval = (pcepropval) lprecprops;

Smartdialcontent * psmart = new smartdialcontent ();

Psmart-> m_bindex = false;

Psmart-> m_loid = ceoid; // ceoid is the index number of the database record, that is, the key ID

// Refresh each record attribute and save it if needed. wnumrecprops table

// Shows the total number of attribute values of a read record that can be read.

For (Int J = 0; j <wnumrecprops; j ++)

{

If (pcepropval [J]. wflags! = Cedb_propnotfound)

{

Wchar pstring [256] = {0 };

If (loword (pcepropval [J]. propid) = cevt_ui4 & pcepropval [J]. propid = pimpr_contact_type)

{

// Pimpr_contacttype_device indicates that the record is stored on the mobile phone

If (pimpr_contacttype_device = pcepropval [J]. Val. uival)

{

Psmart-> m_itype = outlook_type;

Continue;

}

// Pimpr_contacttype_device indicates that the record is stored on the SIM card

Else if (pimpr_contacttype_sim = pcepropval [J]. Val. uival)

{

Psmart-> m_itype = sim_type;

Continue;

}

}

If (loword (pcepropval [J]. propid) = cevt_lpwstr)

{

// Click it to select the string to my struct.

Getcontactinformationbyedb (pcepropval [J], psmart );

Continue;

}

}

}

If (outlook_type = psmart-> m_itype)

{

Pcontactlist-> push_back (psmart );

}

Else

{

// Because the SIM phone number Save in // thepimpr_mobile_telephone_number of the database

If (0 <wcslen (psmart-> m_szphonenumber [1])

{

// Change the SIM phone number Place.

Wcscpy (psmart-> m_szphonenumber [12], psmart-> m_szphonenumber [1]);

Memset (psmart-> m_szphonenumber [1], 0x00, sizeof (psmart-> m_szphonenumber [1]);

}

Psimlist-> push_back (psmart );

}

} // While

If (null! = Localfree (lprecprops) // realloc the lprecprops

Assert (false );

Closeedb (hedb, g_ceguid );

Return hr;

}

 

4. Efficiency Comparison

If you have 500 contacts on your phone, you can test the following two methods:

Poom method EDB Method

The time is about 3300 Ms.

You can see that the EDB method is much faster than the poom method.

From:

Http://hi.baidu.com/evaletchen/blog/item/fab808366a73c5daa2cc2bf2.html

 

 

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.