org.symbian.tools.wrttools.doc.WebDeveloper/html/GUID-662F2E2E-9538-42E5-9B5A-5664F1C11A9E.html
author Eugene Ostroukhov <eugeneo@symbian.org>
Fri, 11 Jun 2010 13:33:03 -0700
changeset 372 1e408ee32d8a
parent 229 716254ccbcc0
permissions -rw-r--r--
Added templates for WRT 1.1 platform services


<!DOCTYPE html
  PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en"><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"/><meta name="copyright" content="(C) Copyright 2009"/><meta name="DC.rights.owner" content="(C) Copyright 2009"/><meta name="DC.Type" content="mobileconcept"/><meta name="DC.Title" content="Accessing and managing information about contacts"/><meta name="DC.Relation" scheme="URI" content="GUID-D581028C-06ED-422D-866E-AE6C93075084"/><meta name="DC.Relation" scheme="URI" content="GUID-AE9A928B-F938-49B5-BC9E-72CB42046571"/><meta name="DC.Relation" scheme="URI" content="GUID-1EFD7043-E9B8-4B4E-9EA6-A20B3EECC14A"/><meta name="DC.Relation" scheme="URI" content="GUID-46EABDC1-37CB-412A-ACAD-1A1A9466BB68"/><meta name="DC.Format" content="XHTML"/><meta name="DC.Identifier" content="GUID-662F2E2E-9538-42E5-9B5A-5664F1C11A9E"/><title>Accessing
and managing information about contacts </title><script type="text/javascript">
      function initPage() {}
    </script><link href="../PRODUCT_PLUGIN/book.css" rel="stylesheet" type="text/css"/><link href="css/s60/style.css" rel="stylesheet" type="text/css" media="all"/></head><body onload="initPage();"><div class="body"><div class="contentLeft prTxt"><h1 class="pageHeading" id="GUID-662F2E2E-9538-42E5-9B5A-5664F1C11A9E">Accessing
and managing information about contacts</h1><div>
<p>The <a href="GUID-A5853293-7B83-4CCE-9C29-B2B8F0CD8A18.html#GUID-A5853293-7B83-4CCE-9C29-B2B8F0CD8A18">Contacts
Service API</a> allows <span>widgets</span> to access and manage information
about contacts. This information can reside in one or more contacts databases
stored on a device or in the SIM card database. You can use the Contacts Service
to create <span>widgets</span> that:</p>
<ul>
<li><p>Retrieve information about contacts, contact groups, and
contacts databases</p></li>
<li><p>Create, edit, and delete contacts and contact groups</p>
</li>
<li><p>Import and export contacts</p></li>
<li><p>Organize contacts into contact groups</p></li>
</ul>
<p>The default contacts database is stored on the device and its URI is <code>cntdb://c:contacts.cdb</code>.
It is created when the first contact is added to it. The URI for the SIM card
database is <code>sim://global_adn</code>.</p>
<div><h3>Accessing the API and supported methods</h3>
<p>To create a <a href="GUID-04095E9A-50E7-4E5F-BD6F-71DA281A0080.html#GUID-04095E9A-50E7-4E5F-BD6F-71DA281A0080">service
object</a> for the Contacts Service API, use <code>Service.Contact</code> to
identify the service provider and <code>IDataSource</code> to identify
the supported interface:</p>

<pre class="codeblock" id="GUID-1A95AE32-7A84-4D0F-BC51-F1B718CA4C90">var so = device.getServiceObject("Service.Contact", "IDataSource");</pre>
<p>The <code>IDataSource</code> interface provides the following
methods:</p>
<ul>
<li><p><a href="GUID-37C9E5F0-BEA9-4E0B-A40D-B953B3551007.html#GUID-37C9E5F0-BEA9-4E0B-A40D-B953B3551007"><code>GetList()</code></a></p>

<p>Use the <code>GetList()</code> method to retrieve information
about contacts, contact groups, or contacts databases.</p>

</li>
<li><p><a href="GUID-20D66938-A870-43D7-9515-AC7E22AEDC14.html#GUID-20D66938-A870-43D7-9515-AC7E22AEDC14"><code>Add()</code></a></p>

<p>Use the <code>Add()</code> method to add a contact or contact
group to a contacts database. You can also use this method to edit an existing
contact or contact group.</p>

</li>
<li><p><a href="GUID-E6FAAB7C-EE2D-4464-9D0F-B1D89E26ABCF.html#GUID-E6FAAB7C-EE2D-4464-9D0F-B1D89E26ABCF"><code>Delete()</code></a></p>

<p>Use the <code>Delete()</code> method to delete one or more contacts
or contact groups from a contacts database.</p>

</li>
<li><p><a href="GUID-154DA5F4-32F6-42E2-A107-A7C72F6F9DE5.html#GUID-154DA5F4-32F6-42E2-A107-A7C72F6F9DE5"><code>Import()</code></a></p>

<p>Use the <code>Import()</code> method to import a contact to
a contacts database. The information must be imported from a vCard file.</p>

</li>
<li><p><a href="GUID-CA7C3A7B-6733-47E0-9C6F-FBFB0993F034.html#GUID-CA7C3A7B-6733-47E0-9C6F-FBFB0993F034"><code>Export()</code></a></p>

<p>Use the <code>Export()</code> method to export a contact from
a contacts database. The information is exported to a vCard file.</p>

</li>
<li><p><a href="GUID-F2CE0F94-324C-4D45-BD37-DA55F9DAC077.html#GUID-F2CE0F94-324C-4D45-BD37-DA55F9DAC077"><code>Organise()</code></a></p>

<p>Use the <code>Organise()</code> method to add contacts to a
contact group or to remove contacts from a contact group.</p>

</li>
<li><p><a href="GUID-231C11D4-82B3-4202-8E86-DE8A3556C9DE.html#GUID-231C11D4-82B3-4202-8E86-DE8A3556C9DE"><code>Cancel()</code></a></p>

<p>Use the <code>Cancel()</code> method to cancel an ongoing asynchronous
call. This method is valid for any asynchronous call made through the Contacts
Service API.</p>

</li>
</ul>
</div>
<div><h3>Using the service in a widget</h3>
<p>To access and manage information about contacts using the Contacts Service
API:</p>
<ol>
<li id="GUID-E8ECDB2F-00C4-488F-A253-87FABDA66CA6-GENIDd0e7501"><a name="GUID-E8ECDB2F-00C4-488F-A253-87FABDA66CA6-GENIDd0e7501"><!----></a><p>Create a service
object for the API using <a href="GUID-04095E9A-50E7-4E5F-BD6F-71DA281A0080.html#GUID-04095E9A-50E7-4E5F-BD6F-71DA281A0080"><code>device.getServiceObject()</code></a>.</p>
</li>
<li id="GUID-0625B45D-A5C9-4ADA-BC21-07963F957A7C-GENIDd0e7510"><a name="GUID-0625B45D-A5C9-4ADA-BC21-07963F957A7C-GENIDd0e7510"><!----></a><p>Define the
tasks you want to perform and choose the correct methods for them.</p>
</li>
<li id="GUID-DBD9997B-CD51-45F9-9ED0-38A98AF08A12-GENIDd0e7515"><a name="GUID-DBD9997B-CD51-45F9-9ED0-38A98AF08A12-GENIDd0e7515"><!----></a><p>Optionally,
define how you want the results filtered.</p></li>
<li id="GUID-AAB5C193-F848-4B0A-AF03-6BA7425BD10B-GENIDd0e7519"><a name="GUID-AAB5C193-F848-4B0A-AF03-6BA7425BD10B-GENIDd0e7519"><!----></a><p>Define a handler
method to process the results.</p></li>
<li id="GUID-F0C3D20F-6F77-4C88-AF35-39DA70DE701B-GENIDd0e7523"><a name="GUID-F0C3D20F-6F77-4C88-AF35-39DA70DE701B-GENIDd0e7523"><!----></a><p>Use the methods
defined in step 2 to perform the tasks. Use asynchronous methods together
with <a href="GUID-C7C3B541-8D28-4DC6-9003-ECF57F26C608.html#GUID-C7C3B541-8D28-4DC6-9003-ECF57F26C608"><code>callback()</code></a>.</p>
</li>
<li id="GUID-0ABE0CB0-D76C-444B-AE53-0D435B3C6E74-GENIDd0e7532"><a name="GUID-0ABE0CB0-D76C-444B-AE53-0D435B3C6E74-GENIDd0e7532"><!----></a><p>Process the
results in the handler method defined in step 4.</p></li>
</ol>
<p>For the complete source of a sample widget that demonstrates how to
use this service, see <a href="GUID-B2BCD2C0-DA4D-4830-9BF3-5DA50879A3A1.html#GUID-B2BCD2C0-DA4D-4830-9BF3-5DA50879A3A1">the
full example</a>.</p>
</div>
</div></div></div><div class="footer"><hr/><div class="copy">© Nokia 2009.</div></div></body></html>