|
1 |
|
2 <!DOCTYPE html |
|
3 PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> |
|
4 <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 |
|
5 and managing information about contacts </title><script type="text/javascript"> |
|
6 function initPage() {} |
|
7 </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 |
|
8 and managing information about contacts</h1><div> |
|
9 <p>The <a href="GUID-A5853293-7B83-4CCE-9C29-B2B8F0CD8A18.html#GUID-A5853293-7B83-4CCE-9C29-B2B8F0CD8A18">Contacts |
|
10 Service API</a> allows <span>widgets</span> to access and manage information |
|
11 about contacts. This information can reside in one or more contacts databases |
|
12 stored on a device or in the SIM card database. You can use the Contacts Service |
|
13 to create <span>widgets</span> that:</p> |
|
14 <ul> |
|
15 <li><p>Retrieve information about contacts, contact groups, and |
|
16 contacts databases</p></li> |
|
17 <li><p>Create, edit, and delete contacts and contact groups</p> |
|
18 </li> |
|
19 <li><p>Import and export contacts</p></li> |
|
20 <li><p>Organize contacts into contact groups</p></li> |
|
21 </ul> |
|
22 <p>The default contacts database is stored on the device and its URI is <code>cntdb://c:contacts.cdb</code>. |
|
23 It is created when the first contact is added to it. The URI for the SIM card |
|
24 database is <code>sim://global_adn</code>.</p> |
|
25 <div><h3>Accessing the API and supported methods</h3> |
|
26 <p>To create a <a href="GUID-04095E9A-50E7-4E5F-BD6F-71DA281A0080.html#GUID-04095E9A-50E7-4E5F-BD6F-71DA281A0080">service |
|
27 object</a> for the Contacts Service API, use <code>Service.Contact</code> to |
|
28 identify the service provider and <code>IDataSource</code> to identify |
|
29 the supported interface:</p> |
|
30 |
|
31 <pre class="codeblock" id="GUID-1A95AE32-7A84-4D0F-BC51-F1B718CA4C90">var so = device.getServiceObject("Service.Contact", "IDataSource");</pre> |
|
32 <p>The <code>IDataSource</code> interface provides the following |
|
33 methods:</p> |
|
34 <ul> |
|
35 <li><p><a href="GUID-37C9E5F0-BEA9-4E0B-A40D-B953B3551007.html#GUID-37C9E5F0-BEA9-4E0B-A40D-B953B3551007"><code>GetList()</code></a></p> |
|
36 |
|
37 <p>Use the <code>GetList()</code> method to retrieve information |
|
38 about contacts, contact groups, or contacts databases.</p> |
|
39 |
|
40 </li> |
|
41 <li><p><a href="GUID-20D66938-A870-43D7-9515-AC7E22AEDC14.html#GUID-20D66938-A870-43D7-9515-AC7E22AEDC14"><code>Add()</code></a></p> |
|
42 |
|
43 <p>Use the <code>Add()</code> method to add a contact or contact |
|
44 group to a contacts database. You can also use this method to edit an existing |
|
45 contact or contact group.</p> |
|
46 |
|
47 </li> |
|
48 <li><p><a href="GUID-E6FAAB7C-EE2D-4464-9D0F-B1D89E26ABCF.html#GUID-E6FAAB7C-EE2D-4464-9D0F-B1D89E26ABCF"><code>Delete()</code></a></p> |
|
49 |
|
50 <p>Use the <code>Delete()</code> method to delete one or more contacts |
|
51 or contact groups from a contacts database.</p> |
|
52 |
|
53 </li> |
|
54 <li><p><a href="GUID-154DA5F4-32F6-42E2-A107-A7C72F6F9DE5.html#GUID-154DA5F4-32F6-42E2-A107-A7C72F6F9DE5"><code>Import()</code></a></p> |
|
55 |
|
56 <p>Use the <code>Import()</code> method to import a contact to |
|
57 a contacts database. The information must be imported from a vCard file.</p> |
|
58 |
|
59 </li> |
|
60 <li><p><a href="GUID-CA7C3A7B-6733-47E0-9C6F-FBFB0993F034.html#GUID-CA7C3A7B-6733-47E0-9C6F-FBFB0993F034"><code>Export()</code></a></p> |
|
61 |
|
62 <p>Use the <code>Export()</code> method to export a contact from |
|
63 a contacts database. The information is exported to a vCard file.</p> |
|
64 |
|
65 </li> |
|
66 <li><p><a href="GUID-F2CE0F94-324C-4D45-BD37-DA55F9DAC077.html#GUID-F2CE0F94-324C-4D45-BD37-DA55F9DAC077"><code>Organise()</code></a></p> |
|
67 |
|
68 <p>Use the <code>Organise()</code> method to add contacts to a |
|
69 contact group or to remove contacts from a contact group.</p> |
|
70 |
|
71 </li> |
|
72 <li><p><a href="GUID-231C11D4-82B3-4202-8E86-DE8A3556C9DE.html#GUID-231C11D4-82B3-4202-8E86-DE8A3556C9DE"><code>Cancel()</code></a></p> |
|
73 |
|
74 <p>Use the <code>Cancel()</code> method to cancel an ongoing asynchronous |
|
75 call. This method is valid for any asynchronous call made through the Contacts |
|
76 Service API.</p> |
|
77 |
|
78 </li> |
|
79 </ul> |
|
80 </div> |
|
81 <div><h3>Using the service in a widget</h3> |
|
82 <p>To access and manage information about contacts using the Contacts Service |
|
83 API:</p> |
|
84 <ol> |
|
85 <li id="GUID-E8ECDB2F-00C4-488F-A253-87FABDA66CA6-GENIDd0e7501"><a name="GUID-E8ECDB2F-00C4-488F-A253-87FABDA66CA6-GENIDd0e7501"><!----></a><p>Create a service |
|
86 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> |
|
87 </li> |
|
88 <li id="GUID-0625B45D-A5C9-4ADA-BC21-07963F957A7C-GENIDd0e7510"><a name="GUID-0625B45D-A5C9-4ADA-BC21-07963F957A7C-GENIDd0e7510"><!----></a><p>Define the |
|
89 tasks you want to perform and choose the correct methods for them.</p> |
|
90 </li> |
|
91 <li id="GUID-DBD9997B-CD51-45F9-9ED0-38A98AF08A12-GENIDd0e7515"><a name="GUID-DBD9997B-CD51-45F9-9ED0-38A98AF08A12-GENIDd0e7515"><!----></a><p>Optionally, |
|
92 define how you want the results filtered.</p></li> |
|
93 <li id="GUID-AAB5C193-F848-4B0A-AF03-6BA7425BD10B-GENIDd0e7519"><a name="GUID-AAB5C193-F848-4B0A-AF03-6BA7425BD10B-GENIDd0e7519"><!----></a><p>Define a handler |
|
94 method to process the results.</p></li> |
|
95 <li id="GUID-F0C3D20F-6F77-4C88-AF35-39DA70DE701B-GENIDd0e7523"><a name="GUID-F0C3D20F-6F77-4C88-AF35-39DA70DE701B-GENIDd0e7523"><!----></a><p>Use the methods |
|
96 defined in step 2 to perform the tasks. Use asynchronous methods together |
|
97 with <a href="GUID-C7C3B541-8D28-4DC6-9003-ECF57F26C608.html#GUID-C7C3B541-8D28-4DC6-9003-ECF57F26C608"><code>callback()</code></a>.</p> |
|
98 </li> |
|
99 <li id="GUID-0ABE0CB0-D76C-444B-AE53-0D435B3C6E74-GENIDd0e7532"><a name="GUID-0ABE0CB0-D76C-444B-AE53-0D435B3C6E74-GENIDd0e7532"><!----></a><p>Process the |
|
100 results in the handler method defined in step 4.</p></li> |
|
101 </ol> |
|
102 <p>For the complete source of a sample widget that demonstrates how to |
|
103 use this service, see <a href="GUID-B2BCD2C0-DA4D-4830-9BF3-5DA50879A3A1.html#GUID-B2BCD2C0-DA4D-4830-9BF3-5DA50879A3A1">the |
|
104 full example</a>.</p> |
|
105 </div> |
|
106 </div></div></div><div class="footer"><hr/><div class="copy">© Nokia 2009.</div></div></body></html> |