Editing Documentation/Maemo 5 Developer Guide/Using Generic Platform Components/Using Address Book API

Warning: You are not logged in. Your IP address will be recorded in this page's edit history.

Warning: This page is 35 kilobytes long; some browsers may have problems editing pages approaching or longer than 32kb. Please consider breaking the page into smaller sections.

The edit can be undone. Please check the comparison below to verify that this is what you want to do, and then save the changes below to finish undoing the edit.
Latest revision Your text
Line 1: Line 1:
-
The [[Open development/Maemo roadmap/Fremantle|Maemo 5]] Address Book is a fully-featured address book software stack. This includes the Contacts application (process name [http://maemo.org/packages/view/osso-addressbook/ osso-addressbook]), a support library which implements most of its functionality ([http://maemo.org/packages/view/libosso-abook/ libosso-abook]), and contact storage via Evolution Data Server ([http://maemo.org/packages/view/evolution-data-server-addressbook/ EDS]). As with any address book program, the Contacts application allows you to add, edit and delete contacts. But beyond basic contacts, the Address Book supports browsing and importing SIM card contacts and tightly integrates VoIP and IM contacts provided by the Telepathy communications framework.
+
= Overview =
 +
 
 +
The Maemo 5 Address Book is a fully-featured address book software stack. This includes the Contacts application (process name "osso-addressbook"), a support library which implements most of its functionality (libosso-abook), and contact storage via Evolution Data Server (EDS). As any address book program, the Contacts application allows you to add, edit and delete contacts. But beyond basic contacts, the Address Book supports browsing and importing SIM card contacts and tightly integrates VoIP and IM contacts provided by the Telepathy communications framework.
This allows Contacts and your application to automatically add IM contacts to your account when adding an IM username to a contact or add a dialog to initiate phone calls, VoIP calls, text messages, emails, or chats with a single tap, and much more.
This allows Contacts and your application to automatically add IM contacts to your account when adding an IM username to a contact or add a dialog to initiate phone calls, VoIP calls, text messages, emails, or chats with a single tap, and much more.
Line 9: Line 11:
The main components in the Maemo Address Book stack are the Contacts application (osso-addressbook), support library (libosso-abook), and Evolution Data Server.
The main components in the Maemo Address Book stack are the Contacts application (osso-addressbook), support library (libosso-abook), and Evolution Data Server.
-
[[Image:abook-components.png|frame|center|alt=Diagram of address book components|Address book components]]
+
[[Image:abook-components.png]]
=== The Contacts application (osso-addressbook) ===
=== The Contacts application (osso-addressbook) ===
Line 37: Line 39:
==== libebook ====
==== libebook ====
-
The libebook library provides access to the contacts stored in Evolution Data Server. The higher-level libosso-abook library uses libebook extensively internally, and you will not likely need to use libebook directly. For more advanced contact manipulation, libebook's EVCard class may be useful (since the main libosso-abook contact class, <code>OssoABookContact</code> is a subclass of it).
+
The libebook library provides access to the contacts stored in Evolution Data Server. The higher-level libosso-abook library uses libebook extensively internally, and you will not likely need to use libebook directly. For more advanced contact manipulation, libebook's EVCard class may be useful (since the main libosso-abook contact class, OssoABookContact is a subclass of it).
-
N.B. Developers are discouraged from using the <code>EBook</code> and <code>EBookView</code> classes of libebook because they do not provide libosso-abook's features of contact aggregation, presence abstraction, and so on.
+
N.B. Developers are discouraged from using the EBook and EBookView classes of libebook because they do not provide libosso-abook's features of contact aggregation, presence abstraction, and so on.
=== Contacts Home Applet (osso-abook-home-applet) ===
=== Contacts Home Applet (osso-abook-home-applet) ===
Line 45: Line 47:
In order to minimize the number of taps required to contact your favorite contacts, Contacts provides a way to add shortcuts to specific contacts on your home views. The Contacts Home Applet is the process that draws these shortcuts on the home view.
In order to minimize the number of taps required to contact your favorite contacts, Contacts provides a way to add shortcuts to specific contacts on your home views. The Contacts Home Applet is the process that draws these shortcuts on the home view.
-
== Non-Widget Classes ==
+
= Non-Widget Classes =
-
=== OssoABookAvatar ===
+
== OssoABookAvatar ==
 +
 
 +
=== Overview ===
Contacts may have an associated image, called their "avatar". An avatar may be retrieved from a corresponding contact on an IM account or from a user-set local image.
Contacts may have an associated image, called their "avatar". An avatar may be retrieved from a corresponding contact on an IM account or from a user-set local image.
Line 56: Line 60:
# The most-recently-changed avatar amongst all attached roster contacts (i.e., on IM servers)
# The most-recently-changed avatar amongst all attached roster contacts (i.e., on IM servers)
-
<code>OssoABookAvatar</code> is implemented by <code>OssoABookContact</code>, so <code>OssoABookAvatar</code> functions are used directly upon <code>OssoABookContacts</code>.
 
-
==== Basic Example ====
+
OssoABookAvatar is implemented by OssoABookContact, so OssoABookAvatar functions are used directly upon OssoABookContacts.
 +
 
 +
=== Basic Example ===
The most important part of a contact's avatar is the image it contains, so this example focuses on that:
The most important part of a contact's avatar is the image it contains, so this example focuses on that:
-
 
+
<pre>
-
<source lang="c">
+
include <glib.h>
-
#include <glib.h>
+
#include <libosso-abook/osso-abook.h>
#include <libosso-abook/osso-abook.h>
Line 83: Line 87:
         }
         }
}
}
-
</source>
+
</pre>
See the Additional API section for tips on caching avatar images.
See the Additional API section for tips on caching avatar images.
-
==== Additional API ====
+
=== Additional API ===
-
Because images can take a relatively long time to process and are inconvenient to compare, it's often easiest to compare simple, unique values to determine image equality. This is especially useful when caching avatar images. In this snippet, <code>image_token</code> is a hashable value:
+
Because images can take a relatively long time to process and are inconvenient to compare, it's often easiest to compare simple, unique values to determine image equality. This is especially useful when caching avatar images. In this snippet, image_token is a hashable value:
-
<source lang="c">
+
<pre>
gpointer image_token = osso_abook_avatar_get_image_token (OSSO_ABOOK_AVATAR (contact));
gpointer image_token = osso_abook_avatar_get_image_token (OSSO_ABOOK_AVATAR (contact));
-
</source>
+
</pre>
-
==== Notable Signals ====
+
=== Notable Signals ===
-
* <code>notify::avatar-image</code>
+
* notify::avatar-image
-
==== Complete API Documentation ====
+
=== Complete API Documentation ===
 +
Full details can be found in the API [http://maemo.org/api_refs/5.0/beta/libosso-abook/libosso-abook-osso-abook-avatar.html reference documentation for OssoABookAvatar].
-
Full details can be found in the API [http://maemo.org/api_refs/5.0/5.0-final/libosso-abook/libosso-abook-osso-abook-avatar.html reference documentation for OssoABookAvatar].
+
== OssoABookCaps ==
-
=== OssoABookCaps ===
+
=== Overview ===
-
<code>OssoABookContacts</code> may possess a number of different capabilities, so the <code>OssoABookCaps</code> interface (which <code>OssoABookContacts</code> implements) provides a simple means to detect these capabilities.
+
OssoABookContacts may possess a number of different capabilities, so the OssoABookCaps interface (which OssoABookContacts implements) provides a simple means to detect these capabilities.
-
==== Basic Example ====
+
=== Basic Example ===
-
The core of <code>OssoABookCaps</code> is the <code>OssoABookCapsFlags</code> enumeration, accessible by <code>osso_abook_caps_get_capabilities()</code>. Its values are orthogonal and may be bitwise-ORed or -ANDed together for more detailed capabilities checks:
+
The core of OssoABookCaps is the OssoABookCapsFlags enumeration, accessible by osso_abook_caps_get_capabilities(). Its values are orthogonal and may be bitwise-ORed or -ANDed together for more detailed capabilities checks:
-
 
+
<pre>
-
<source lang="c">
+
static void
static void
contact_print_caps_details (OssoABookContact *contact)
contact_print_caps_details (OssoABookContact *contact)
Line 131: Line 135:
                 caps_flags & (OSSO_ABOOK_CAPS_PHONE | OSSO_ABOOK_CAPS_VOICE | OSSO_ABOOK_CAPS_VIDEO) ? "yes" : "no");
                 caps_flags & (OSSO_ABOOK_CAPS_PHONE | OSSO_ABOOK_CAPS_VOICE | OSSO_ABOOK_CAPS_VIDEO) ? "yes" : "no");
}
}
-
</source>
+
</pre>
-
==== Additional API ====
+
=== Additional API ===
-
<code>OssoABookCaps</code> also contains a convenience function for getting the capabilities of our own accounts (of type <code>McAccount*</code>).
+
OssoABookCaps also contains a convenience function for getting the capabilities of our own accounts (of type McAccount*).
-
 
+
<pre>
-
<source lang="c">
+
OssoABookCapsFlags caps_flags = osso_abook_caps_from_account (account);
OssoABookCapsFlags caps_flags = osso_abook_caps_from_account (account);
-
</source>
+
</pre>
-
==== Notable Signals ====
+
=== Notable Signals ===
-
* <code>notify::capabilities</code>
+
* notify::capabilities
-
 
+
-
==== Complete API Documentation ====
+
 +
=== Complete API Documentation ===
Full details can be found in the API [http://maemo.org/api_refs/5.0/beta/libosso-abook/libosso-abook-osso-abook-caps.html reference documentation for OssoABookCaps].
Full details can be found in the API [http://maemo.org/api_refs/5.0/beta/libosso-abook/libosso-abook-osso-abook-caps.html reference documentation for OssoABookCaps].
-
=== OssoABookContact ===
+
== OssoABookContact ==
-
The central class in libosso-abook is <code>OssoABookContact</code>, which is used in a few different ways:
+
=== Overview ===
 +
 
 +
The central class in libosso-abook is OssoABookContact, which is used in a few different ways:
* as a master contact, which acts as an authoritative source of contact attributes for itself and any number of roster contacts. This use is further broken into:
* as a master contact, which acts as an authoritative source of contact attributes for itself and any number of roster contacts. This use is further broken into:
Line 160: Line 164:
In most cases, you will only be interested in master contacts (in general) because they aggregate all of the attributes of their own and their roster contacts. Every master contact is the authoritative source of a person's displayable name, avatar, presence, status message, etc. If a master contact and its roster contact(s) have multiple values for a single-instance attribute (e.g., avatar), the master contact will automatically pick an authoritative value.
In most cases, you will only be interested in master contacts (in general) because they aggregate all of the attributes of their own and their roster contacts. Every master contact is the authoritative source of a person's displayable name, avatar, presence, status message, etc. If a master contact and its roster contact(s) have multiple values for a single-instance attribute (e.g., avatar), the master contact will automatically pick an authoritative value.
-
So if you just wish to display all of your contacts' names and IM availability, you would simply use the appropriate <code>OssoABookContact</code> functions on the list of master contacts and the master contacts will automatically report their "most-online" presence amongst their attached roster contacts (if any).
+
So if you just wish to display all of your contacts' names and IM availability, you would simply use the appropriate OssoABookContact functions on the list of master contacts and the master contacts will automatically report their "most-online" presence amongst their attached roster contacts (if any).
-
 
+
-
In addition to its own functionality, <code>OssoABookContact</code> implements the <code>OssoABookAvatar</code>, <code>OssoABookCaps</code>, and <code>OssoABookPresence</code> interfaces. So <code>OssoABookContacts</code> can be used in their functions and will emit their signals. See their documentation for more details.
+
-
 
+
-
<code>OssoABookContact</code> inherits from <code>EContact</code> (which itself inherits from <code>EVCard</code>). At its core, <code>OssoABookContact</code> is based around the vCard format for storing contact attributes. We recommend against manipulating and accessing contacts at the vCard level, since it's more complicated and error-prone than using the <code>OssoABookContact</code> functionality. Note that the Maemo Address Book adds some vCard attributes (e.g., <code>gender/X-GENDER</code>, <code>Skype username/X-SKYPE</code>) that are not accessible at the EContact level, since they are not defined in <code>EContactField</code>. So we recommend using the <code>EVCard</code> functions over similar <code>EContact</code> functions whenever possible. See the <code>EContact</code> and <code>EVCard</code> documentation for more details on their API.
+
-
As with any <code>EContact</code>, changes to an <code>OssoABookContact</code> are not permanently stored until they are explicitly committed. See the example and explanation of <code>osso_abook_contact_commit()</code> below.
+
In addition to its own functionality, OssoABookContact implements the OssoABookAvatar, OssoABookCaps, and OssoABookPresence interfaces. So OssoABookContacts can be used in their functions and will emit their signals. See their documentation for more details.
-
==== Basic Examples ====
+
OssoABookContact inherits from EContact (which itself inherits from EVCard). At its core, OssoABookContact is based around the vCard format for storing contact attributes. We recommend against manipulating and accessing contacts at the vCard level, since it's more complicated and error-prone than using the OssoABookContact functionality. Note that the Maemo Address Book adds some vCard attributes (e.g., gender/X-GENDER, Skype username/X-SKYPE) that are not accessible at the EContact level, since they are not defined in EContactField. So we recommend using the EVCard functions over similar EContact functions whenever possible. See the EContact and EVCard documentation for more details on their API.
-
===== Printing out basic contact details =====
+
As with any EContact, changes to an OssoABookContact are not permanently stored until they are explicitly committed. See the example and explanation of osso_abook_contact_commit() below.
-
This example is meant to show off a few functions that you may want to use to get specific, basic Contact details. If you would like to get its avatar, see the documentation on <code>OssoABookAvatar</code>; for its IM presence or capabilities, see <code>OssoABookPresence</code> and <code>OssoABookCaps</code>.
+
=== Basic Examples ===
-
Also note that, for most cases of displaying an avatar, presence icon, etc., libosso-abook provides widgets. See <code>OssoABookAvatarImage</code>, <code>OssoABookPresenceIcon</code>, and <code>OssoABookTouchContactStarter</code>.
+
==== Printing out basic contact details ====
 +
This example is meant to show off a few functions that you may want to use to get specific, basic Contact details. If you would like to get its avatar, see the documentation on OssoABookAvatar; for its IM presence or capabilities, see OssoABookPresence and OssoABookCaps.
-
<source lang="c">
+
Also note that, for most cases of displaying an avatar, presence icon, etc., libosso-abook provides widgets. See OssoABookAvatarImage, OssoABookPresenceIcon, and OssoABookTouchContactStarter.
 +
<pre>
#include <glib.h>
#include <glib.h>
#include <libosso-abook/osso-abook.h>
#include <libosso-abook/osso-abook.h>
Line 199: Line 201:
                 osso_abook_contact_is_sim_contact (contact)      ? "yes" : "no");
                 osso_abook_contact_is_sim_contact (contact)      ? "yes" : "no");
}
}
-
</source>
+
</pre>
-
==== Additional API ====
+
=== Additional API ===
-
There are many ways to use an <code>OssoABookContact</code>, and a significant portion of that lay in its parent classes and implemented interfaces (<code>OssoABookAvatar</code>, <code>OssoABookCaps</code>, and <code>OssoABookPresence</code>). See the appropriate documentation for more details.
+
There are many ways to use an OssoABookContact, and a significant portion of that lay in its parent classes and implemented interfaces (OssoABookAvatar, OssoABookCaps, and OssoABookPresence). See the appropriate documentation for more details.
-
Here are some highlights of additional API for <code>OssoABookContact</code>.
+
Here are some highlights of additional API for OssoABookContact.
-
===== General Functions =====
+
==== General Functions ====
-
Sometimes it can be handy to get a full listing of a contact's contents. In that case, you may wish to print out the low-level vCard representation of the contact. Note that this will not include the contents of any roster contacts, in the case of a master contact. Set the last argument to <code>TRUE</code> if you wish to include the contact's avatar data (this can be very long).
+
Sometimes it can be handy to get a full listing of a contact's contents. In that case, you may wish to print out the low-level vCard representation of the contact. Note that this will not include the contents of any roster contacts, in the case of a master contact. Set the last argument to TRUE if you wish to include the contact's avatar data (this can be very long).
-
<source lang="c">
+
<pre>
osso_abook_contact_to_string (contact, EVC_FORMAT_VCARD_30, FALSE);
osso_abook_contact_to_string (contact, EVC_FORMAT_VCARD_30, FALSE);
-
</source>
+
</pre>
-
In case you need to sort some contacts, <code>osso_abook_contact_collate()</code> is a <code>strcmp()</code>-like function that does just that. So, to sort a <code>GList</code> of contacts:
+
In case you need to sort some contacts, osso_abook_contact_collate() is a strcmp()-like function that does just that. So, to sort a GList of contacts:
-
<source lang="c">
+
<pre>
/* To sort by presence, use OSSO_ABOOK_CONTACT_ORDER_PRESENCE instead */
/* To sort by presence, use OSSO_ABOOK_CONTACT_ORDER_PRESENCE instead */
g_list_sort_with_data (contacts, osso_abook_contact_collate, OSSO_ABOOK_CONTACT_ORDER_NAME);
g_list_sort_with_data (contacts, osso_abook_contact_collate, OSSO_ABOOK_CONTACT_ORDER_NAME);
-
</source>
+
</pre>
-
===== Roster Contact List Handling =====
+
 
 +
==== Roster Contact List Handling ====
In case you need to access a master contact's roster contacts, you can do so like this:
In case you need to access a master contact's roster contacts, you can do so like this:
-
<source lang="c">
+
<pre>
#include <libosso-abook/osso-abook.h>
#include <libosso-abook/osso-abook.h>
Line 243: Line 246:
         g_list_free (contacts);
         g_list_free (contacts);
}
}
-
</source>
+
</pre>
-
===== Roster Contacts =====
+
==== Roster Contacts ====
There are a number of useful functions for accessing roster contact details. This example shows off the basic ones:
There are a number of useful functions for accessing roster contact details. This example shows off the basic ones:
-
 
+
<pre>
-
<source lang="c">
+
#include <glib.h>
#include <glib.h>
#include <libosso-abook/osso-abook.h>
#include <libosso-abook/osso-abook.h>
Line 272: Line 274:
                 osso_abook_contact_has_invalid_username (contact) ?  "yes" : "no");                     
                 osso_abook_contact_has_invalid_username (contact) ?  "yes" : "no");                     
}
}
-
</source>
+
</pre>
-
===== Attribute Convenience Functions =====
+
==== Attribute Convenience Functions ====
If you need a hashable key (to temporarily use) for contacts, use:
If you need a hashable key (to temporarily use) for contacts, use:
-
<source lang="c">
+
<pre>
const char *key = osso_abook_contact_get_uid (contact);
const char *key = osso_abook_contact_get_uid (contact);
-
</source>
+
</pre>
However, if you need a persistent hashable key (such as for an on-disk cache, database, etc.), use the following function:
However, if you need a persistent hashable key (such as for an on-disk cache, database, etc.), use the following function:
-
<source lang="c">
+
<pre>
const char *key = osso_abook_contact_get_persistent_uid (contact);
const char *key = osso_abook_contact_get_persistent_uid (contact);
Line 290: Line 292:
         g_print ("This contact isn't persistent!");
         g_print ("This contact isn't persistent!");
}
}
-
</source>
+
</pre>
Sometimes it can be useful to add vCard attributes to a contact for custom applications. Say you have a networked game called Foo Bar Tetris, and you want to associate someone's username on the network with their contact:
Sometimes it can be useful to add vCard attributes to a contact for custom applications. Say you have a networked game called Foo Bar Tetris, and you want to associate someone's username on the network with their contact:
-
<source lang="c">
+
<pre>
#include <glib.h>
#include <glib.h>
#include <libosso-abook/osso-abook.h>
#include <libosso-abook/osso-abook.h>
Line 318: Line 320:
         g_free (current_username);
         g_free (current_username);
}
}
-
</source>
+
</pre>
-
==== Notable Signals ====
+
=== Notable Signals ===
-
* <code>reset</code>
+
* reset
-
* <code>contact-attached</code>
+
* contact-attached
-
* <code>contact-detached</code>
+
* contact-detached
-
==== Complete API Documentation ====
+
=== Complete API Documentation ===
-
Full details can be found in the API [http://maemo.org/api_refs/5.0/5.0-final/libosso-abook/OssoABookContact.html reference documentation for OssoABookContact].
+
Full details can be found in the API [http://maemo.org/api_refs/5.0/beta/libosso-abook/OssoABookContact.html reference documentation for OssoABookContact].
-
=== OssoABookPresence ===
+
== OssoABookPresence ==
 +
 
 +
=== Overview ===
A contact's "presence" is comprised of a few elements, including:
A contact's "presence" is comprised of a few elements, including:
;status
;status
-
: a well-known string describing the contact's availability. In Maemo 5, this string is always one of {"available", "away", "dnd" (do not disturb), "offline", and "unknown"}. The "type" (see below) is the preferred element for determining a contact's availability.  
+
:a well-known string describing the contact's availability. In Maemo 5, this string is always one of {"available", "away", "dnd" (do not disturb), "offline", and "unknown"}. The "type" (see below) is the preferred element for determining a contact's availability.  
;status message
;status message
-
: the string set by your contact (e.g., "I'm running outside")
+
:the string set by your contact (e.g., "I'm running outside")
;type
;type
-
: an integer representing the contact's availability. This is more fine-grained than "status" (see above) and the preferred way to determine a contact's availability
+
:an integer representing the contact's availability. This is more fine-grained than "status" (see above) and the preferred way to determine a contact's availability
-
 
+
-
An <code>OssoABookContact</code> master contact has the aggregated presence of all its roster contact(s). In the case of status, the master contact will have the "most-online" status amongst its roster contacts. For example, given a master contact with roster contacts having statuses "away" and "offline", the master contact's status will be "away".
+
-
<code>OssoABookPresence</code> is implemented by <code>OssoABookContact</code>, so <code>OssoABookPresence</code> functions are used directly upon <code>OssoABookContacts</code>.
+
An OssoABookContact master contact has the aggregated presence of all its roster contact(s). In the case of status, the master contact will have the "most-online" status amongst its roster contacts. For example, given a master contact with roster contacts having statuses "away" and "offline", the master contact's status will be "away".
-
==== Basic Example ====
+
OssoABookPresence is implemented by OssoABookContact, so OssoABookPresence functions are used directly upon OssoABookContacts.
-
This example shows off some of the more useful basic functions in <code>OssoABookPresence</code>. Note that you will always be using <code>OssoABookPresence</code> functions on <code>OssoABookContacts</code>, since they're the only class that implements the interface.
+
=== Basic Example ===
-
<source lang="c">
+
This example shows off some of the more useful basic functions in OssoABookPresence. Note that you will always be using OssoABookPresence functions on OssoABookContacts, since they're the only class that implements the interface.
 +
<pre>
#include <glib.h>
#include <glib.h>
#include <telepathy-glib/connection.h>
#include <telepathy-glib/connection.h>
Line 418: Line 421:
                 osso_abook_presence_state_get_nick (osso_abook_presence_get_subscribed (presence)));
                 osso_abook_presence_state_get_nick (osso_abook_presence_get_subscribed (presence)));
}
}
-
</source>
+
</pre>
-
==== Additional API ====
+
=== Additional API ===
-
The example above shows how to compare the basic <code>TpConnectionPresenceType</code> return value of <code>osso_abook_presence_get_presence_type()</code>. At a higher level, if you want to compare the relative availability of two <code>OssoABookPresences</code> (e.g., <code>OssoABookContacts</code>), you can use the convenience function <code>osso_abook_presence_compare()</code>. It works like most <code>strcmp()</code>-like functions, except that it returns a value < 0 is the first presence is more online than the other, and vice versa.
+
The example above shows how to compare the basic TpConnectionPresenceType return value of osso_abook_presence_get_presence_type(). At a higher level, if you want to compare the relative availability of two OssoABookPresences (e.g., OssoABookContacts), you can use the convenience function osso_abook_presence_compare(). It works like most strcmp()-like functions, except that it returns a value < 0 is the first presence is more online than the other, and vice versa.
-
 
+
<pre>
-
<source lang="c">
+
/* Sort the contacts in order of decreasing availability */
/* Sort the contacts in order of decreasing availability */
contacts = g_list_sort (contacts, (GCompareFunc) osso_abook_presence_compare);
contacts = g_list_sort (contacts, (GCompareFunc) osso_abook_presence_compare);
-
</source>
+
</pre>
-
==== Notable Signals ====
+
=== Notable Signals ===
-
* <code>notify::presence-location-string</code>
+
* notify::presence-location-string
-
* <code>notify::presence-status</code>
+
* notify::presence-status
-
* <code>notify::presence-status-message</code>
+
* notify::presence-status-message
-
* <code>notify::presence-type</code>
+
* notify::presence-type
-
==== Complete API Documentation ====
+
=== Complete API Documentation ===
Full details can be found in the API [http://maemo.org/api_refs/5.0/beta/libosso-abook/libosso-abook-osso-abook-presence.html reference documentation for OssoABookPresence].
Full details can be found in the API [http://maemo.org/api_refs/5.0/beta/libosso-abook/libosso-abook-osso-abook-presence.html reference documentation for OssoABookPresence].
-
== Widget Classes ==
+
= Widget Classes =
-
=== OssoABookContactChooser ===
+
== OssoABookContactChooser ==
-
<code>OssoABookContactChooser</code> is a widget that allows you to present a selectable list of contacts to the user. The contact chooser is relatively flexible so that it
+
=== Overview ===
 +
OssoABookContactChooser is a widget that allows you to present a selectable list
 +
of contacts to the user. The contact chooser is relatively flexible so that it
can be used in many different situations.   
can be used in many different situations.   
-
==== Basic Example ====
+
=== Basic Example ===
-
 
+
The following is a simple example of the use of OssoABookContactChooser:
-
The following is a simple example of the use of <code>OssoABookContactChooser</code>:
+
-
<source lang="c">
+
<pre>
static void
static void
test_contact_chooser (void)
test_contact_chooser (void)
Line 477: Line 480:
                 GList *l;
                 GList *l;
-
                 g_printf ("Selected Contacts:\n");
+
                 g_printf ("Selected Contacts:\n")
                 for (l = selection; l; l = l->next) {
                 for (l = selection; l; l = l->next) {
-
                         g_printf ("%s\n", osso_abook_contact_get_display_name(l->data));
+
                         g_printf ("%s\n", osso_abook_contact_get_display_name((l->data));
                 }
                 }
         } else {
         } else {
Line 490: Line 493:
         gtk_widget_destroy (chooser);
         gtk_widget_destroy (chooser);
}
}
-
</source>
+
</pre>
-
==== Additional API ====
+
=== Additional API ===
The contacts shown in the list can be customized in several ways.
The contacts shown in the list can be customized in several ways.
-
<code>osso_abook_contact_chooser_set_capabilities()</code> allows you to limit the contacts shown in the list to only those that have certain capabilities. For example, to
+
osso_abook_contact_chooser_set_capabilities() allows you to limit the contacts
 +
shown in the list to only those that have certain capabilities. For example, to
show only those contacts that have an associated email address:
show only those contacts that have an associated email address:
-
<source lang="c">
+
<pre>
osso_abook_contact_chooser_set_capabilities (chooser, OSSO_ABOOK_CAPS_EMAIL);
osso_abook_contact_chooser_set_capabilities (chooser, OSSO_ABOOK_CAPS_EMAIL);
-
</source>
+
</pre>
You can show only those contacts whose presence status indicates that they are
You can show only those contacts whose presence status indicates that they are
Line 507: Line 511:
contact over a messaging protocol:
contact over a messaging protocol:
-
<source lang="c">
+
<pre>
osso_abook_contact_chooser_set_hide_offline_contacts (chooser, TRUE);
osso_abook_contact_chooser_set_hide_offline_contacts (chooser, TRUE);
-
</source>
+
</pre>
If there are specific contacts that you wish to exclude from the chooser, you
If there are specific contacts that you wish to exclude from the chooser, you
Line 516: Line 520:
that are already present in the "To:" field.
that are already present in the "To:" field.
-
<source lang="c">
+
<pre>
OssoABookContact *john_doe; /* reference to a contact from the addressbook */
OssoABookContact *john_doe; /* reference to a contact from the addressbook */
Line 522: Line 526:
contacts = g_list_prepend (contacts, john_doe);
contacts = g_list_prepend (contacts, john_doe);
osso_abook_contact_chooser_set_excluded_contacts (chooser, contacts);
osso_abook_contact_chooser_set_excluded_contacts (chooser, contacts);
-
</source>
+
</pre>
If an application needs even more control,
If an application needs even more control,
-
<code>osso_abook_contact_chooser_set_visible_func()</code> provides a way for the application to supply a predicate function that will determine whether the contact should be
+
osso_abook_contact_chooser_set_visible_func() provides a way for the application
 +
to supply a predicate function that will determine whether the contact should be
shown in the chooser.
shown in the chooser.
-
<source lang="c">
+
<pre>
gboolean custom_visible_func(OssoABookContactChooser *chooser,
gboolean custom_visible_func(OssoABookContactChooser *chooser,
                             OssoABookContact *contact,
                             OssoABookContact *contact,
Line 546: Line 551:
osso_abook_contact_chooser_set_visible_func (chooser, custom_visible_func,
osso_abook_contact_chooser_set_visible_func (chooser, custom_visible_func,
                                             "foo", NULL);
                                             "foo", NULL);
-
</source>
+
</pre>
In addition to the ability to customize the contacts that are shown in the
In addition to the ability to customize the contacts that are shown in the
Line 554: Line 559:
functions to programmatically select and deselect items from the list.
functions to programmatically select and deselect items from the list.
-
==== Complete API Documentation ====
+
=== Complete API Documentation ===
Full details can be found in the API [http://maemo.org/api_refs/5.0/beta/libosso-abook/OssoABookContactChooser.html reference documentation for OssoABookContactChooser].
Full details can be found in the API [http://maemo.org/api_refs/5.0/beta/libosso-abook/OssoABookContactChooser.html reference documentation for OssoABookContactChooser].
-
=== OssoABookTreeView ===
+
== OssoABookTreeView ==
-
Although <code>OssoABookTreeView</code>'s name might imply that it inherits from <code>GtkTreeView</code>, it is actually an ancestor of <code>GtkVBox</code> that contains a <code>GtkTreeView</code> inside of a <code>HildonPannableArea</code>. It provides a convenient way to display a list of contacts and sets up the <code>GtkTreeView</code> columns automatically. It can show the contacts' name, Telephone number, presence status, and avatar image. These details can be
+
=== Overview ===
 +
 
 +
Although OssoABookTreeView's name might imply that it inherits from GtkTreeView,
 +
it is actually an ancestor of GtkVBox that contains a GtkTreeView inside of a
 +
HildonPannableArea. It provides a convenient way to display a list of contacts
 +
and sets up the TreeView columns automatically. It can show the contacts' name,
 +
Telephone number, presence status, and avatar image. These details can be
selectively enabled or disabled according to an application's requirements.
selectively enabled or disabled according to an application's requirements.
It is unlikely that an application will need or want to instantiate an
It is unlikely that an application will need or want to instantiate an
-
<code>OssoABookTreeView</code> object directly. Most of the time, applications will deal
+
OssoABookTreeView object directly. Most of the time, applications will deal
-
with <code>OssoABookContactView</code> objects, which inherits from this class and does most of the setup work for you.
+
with OssoABookContactView objects, which inherits from this class and does most
 +
of the setup work for you.
-
==== Additional API ====
+
=== Additional API ===
-
<code>OssoABookTreeView</code> is an aggregate widget, but it provides direct access to the underlying widgets as well (e.g. <code>osso_abook_tree_view_get_tree_view()</code>,
+
OssoABookTreeView is an aggregate widget, but it provides direct access to the
-
<code>osso_abook_tree_view_get_pannable_area()</code>.
+
underlying widgets as well (e.g. osso_abook_tree_view_get_tree_view(),
 +
osso_abook_tree_view_get_pannable_area().
An application can filter the list of contacts that gets displayed in the tree
An application can filter the list of contacts that gets displayed in the tree
-
view by using <code>osso_abook_tree_view_set_filter_model()</code>.  The following example shows how to display only those contacts whose names contain a certain string:
+
view by using osso_abook_tree_view_set_filter_model().  The following example
 +
shows how to display only those contacts whose names contain a certain string:
-
<source lang="c">
+
<pre>
OssoABookTreeView *view;
OssoABookTreeView *view;
OssoABookListStore *base_model;
OssoABookListStore *base_model;
Line 589: Line 603:
osso_abook_tree_view_set_base_model (view, base_model);
osso_abook_tree_view_set_base_model (view, base_model);
osso_abook_tree_view_set_filter_model (view, filter_model);
osso_abook_tree_view_set_filter_model (view, filter_model);
-
</source>
+
</pre>
-
In addition, if you only want to display those contacts associated with a particular VoIP or IM account, use the function
+
In addition, if you only want to display those contacts associated with a
-
<code>osso_abook_tree_view_set_aggregation_account()</code>.  In addition to limiting the contacts to only those specified by those accounts, it will also display the
+
particular VoIP or IM account, use the function
 +
osso_abook_tree_view_set_aggregation_account ().  In addition to limiting the
 +
contacts to only those specified by those accounts, it will also display the
presence status and avatar image for that particular account regardless of the
presence status and avatar image for that particular account regardless of the
contact's status on other VoIP or IM accounts.
contact's status on other VoIP or IM accounts.
Line 598: Line 614:
The details shown in the tree view can be controlled with the following
The details shown in the tree view can be controlled with the following
properties:
properties:
-
* <code>show-contact-avatar</code>
+
* show-contact-avatar
-
* <code>show-contact-name</code>
+
* show-contact-name
-
* <code>show-contact-presence</code>
+
* show-contact-presence
-
* <code>show-contact-telephone</code>
+
* show-contact-telephone
-
==== Complete API Documentation ====
+
=== Complete API Documentation ===
Full details can be found in the API [http://maemo.org/api_refs/5.0/beta/libosso-abook/OssoABookTreeView.html reference documentation for OssoABookTreeView].
Full details can be found in the API [http://maemo.org/api_refs/5.0/beta/libosso-abook/OssoABookTreeView.html reference documentation for OssoABookTreeView].
-
=== OssoABookContactView ===
+
== OssoABookContactView ==
-
<code>OssoABookContactView</code> provides a convenient widget for displaying a list of
+
=== Overview ===
-
contacts in a list. It builds upon <code>OssoABookTreeView</code> and adds a bit of
+
 
 +
OssoABookContactView provides a convenient widget for displaying a list of
 +
contacts in a list. It builds upon OssoABookTreeView and adds a bit of
convenience API.
convenience API.
-
==== Basic Example ====
+
=== Basic Example ===
The following example shows how to display all contacts from the Address Book in
The following example shows how to display all contacts from the Address Book in
a list.
a list.
-
<source lang="c">
+
<pre>
#include <libosso-abook/osso-abook.h>
#include <libosso-abook/osso-abook.h>
Line 642: Line 660:
         gtk_main ();
         gtk_main ();
}
}
-
</source>
+
</pre>
-
==== Additional API ====
+
=== Additional API ===
-
<code>OssoABookContactView</code> has some additional convenience API that allows you to get the contact (or properties of the contact) that currently has input focus:
+
OssoABookContactView has some additional convenience API that allows you to get
-
* <code>osso_abook_contact_view_get_focus()</code>
+
the contact (or properties of the contact) that currently has input focus:
-
* <code>osso_abook_contact_view_get_focus_avatar()</code>
+
* osso_abook_contact_view_get_focus()
-
* <code>osso_abook_contact_view_get_focus_presence()</code>
+
* osso_abook_contact_view_get_focus_avatar()
-
* <code>osso_abook_contact_view_get_focus_caps()</code>
+
* osso_abook_contact_view_get_focus_presence()
 +
* osso_abook_contact_view_get_focus_caps()
The Contact view can support both single- and multiple-selection modes.
The Contact view can support both single- and multiple-selection modes.
-
<code>osso_abook_contact_view_set_minimum_selection()</code> and
+
osso_abook_contact_view_set_minimum_selection() and
-
<code>osso_abook_contact_view_set_maximum_selection()</code> allow fine-grained control over how contacts can be selected.
+
osso_abook_contact_view_set_maximum_selection() allow fine-grained control over
 +
how contacts can be selected.
-
==== Complete API Documentation ====
+
=== Complete API Documentation ===
Full details can be found in the API [http://maemo.org/api_refs/5.0/beta/libosso-abook/OssoABookContactView.html reference documentation for OssoABookContactView].
Full details can be found in the API [http://maemo.org/api_refs/5.0/beta/libosso-abook/OssoABookContactView.html reference documentation for OssoABookContactView].
-
=== OssoABookTouchContactStarter ===
+
== OssoABookTouchContactStarter ==
-
<code>OssoABookTouchContactStarter</code> is a widget that displays the information for a contact and can be used to initiate communication with a contact (email, IM,
+
=== Overview ===
 +
OssoABookTouchContactStarter is a widget that displays the information for a
 +
contact and can be used to initiate communication with a contact (email, IM,
VoIP, etc).
VoIP, etc).
-
==== Basic Example ====
+
=== Basic Example ===
The following is a simple example that shows how to use
The following is a simple example that shows how to use
-
<code>OssoABookTouchContactStarter</code> to display the details of a particular contact.
+
OssoABookTouchContactStarter to display the details of a particular contact.
-
<source lang="c">
+
<pre>
#include <libosso-abook/osso-abook.h>
#include <libosso-abook/osso-abook.h>
Line 706: Line 728:
         return 0;
         return 0;
}
}
-
</source>
+
</pre>
-
 
+
-
==== Additional API ====
+
 +
=== Additional API ===
In addition to the basic example shown above, there are several other ways to
In addition to the basic example shown above, there are several other ways to
-
customize the <code>OssoABookTouchContactStarter</code> widget.  By default the contact starter is created in 'read-only' mode.  But if the starter was created with
+
customize the OssoABookTouchContactStarter widget.  By default the contact
-
<code>osso_abook_touch_contact_starter_new_with_editor()</code>, a contact editor can be launched by clicking the avatar icon. This allows the contact's details to be
+
starter is created in 'read-only' mode.  But if the starter was created with
-
changed directly from the contact starter widget. An editor can also be
+
osso_abook_touch_contact_starter_new_with_editor(), a contact editor can be
-
launched programmatically by calling <code>osso_abook_touch_contact_starter_start_editor()</code>.
+
launched by clicking the avatar icon. This allows the contact's details to be
 +
changed directly from the contact starter widget. An editor can also be
 +
launched programmatically by calling
 +
osso_abook_touch_contact_starter_start_editor().
A contact starter is normally interactive in the sense that it can be used to
A contact starter is normally interactive in the sense that it can be used to
initiate contact with the contact (e.g. start a phone call, start a chat, etc),
initiate contact with the contact (e.g. start a phone call, start a chat, etc),
though it can be made non-interactive by creating the starter with
though it can be made non-interactive by creating the starter with
-
<code>osso_abook_touch_contact_starter_new_not_interactive()</code>.  In addition, an
+
osso_abook_touch_contact_starter_new_not_interactive().  In addition, an
-
application can override the default actions by connecting to the <code>pre-action-start</code> signal.  For example:
+
application can override the default actions by connecting to the
 +
"pre-action-start" signal.  For example:
-
<source lang="c">
+
<pre>
gboolean
gboolean
pre_action_start_cb (OssoABookTouchContactStarter *starter,
pre_action_start_cb (OssoABookTouchContactStarter *starter,
Line 748: Line 773:
                                 G_CALLBACK (pre_action_start_cb), NULL);
                                 G_CALLBACK (pre_action_start_cb), NULL);
-
</source>
+
</pre>
-
==== Complete API Documentation ====
+
=== Complete API Documentation ===
Full details can be found in the API [http://maemo.org/api_refs/5.0/beta/libosso-abook/OssoABookTouchContactStarter.html reference documentation for OssoABookTouchContactStarter].
Full details can be found in the API [http://maemo.org/api_refs/5.0/beta/libosso-abook/OssoABookTouchContactStarter.html reference documentation for OssoABookTouchContactStarter].
-
== Glossary ==
+
= Glossary =
;aggregated contact
;aggregated contact
-
: a persistent master contact with one or more attached roster contacts.
+
:a persistent master contact with one or more attached roster contacts.
;aggregator
;aggregator
-
: an <code>OssoABookAggregator</code> object which manages connections to the EDS backends and associates master contacts with their roster contacts.
+
:an OssoABookAggregator object which manages connections to the EDS backends and associates master contacts with their roster contacts.
;master contact
;master contact
-
: an <code>OssoABookContact</code> which aggregates the attributes of zero or one persistent master contacts and zero or more roster contacts.
+
:an OssoABookContact which aggregates the attributes of zero or one persistent master contacts and zero or more roster contacts.
;persistent master contact
;persistent master contact
-
: an <code>OssoABookContact</code> which is stored in the EDS local database and has zero or more roster contacts.
+
:an OssoABookContact which is stored in the EDS local database and has zero or more roster contacts.
;roster contact
;roster contact
-
: an <code>OssoABookContact</code> which is stored in the EDS Telepathy backend and represents a (VoIP/IM username, account) pair. Roster contacts are always attached to exactly one temporary master contact or one or more persistent master contacts.
+
:an OssoABookContact which is stored in the EDS Telepathy backend and represents a (VoIP/IM username, account) pair. Roster contacts are always attached to exactly one temporary master contact or one or more persistent master contacts.
;temporary master contact
;temporary master contact
-
: a master contact which was created at run-time for a roster contact to attach to, so that all roster contacts have one or more master contacts. Temporary master contacts are not stored in the local database and their UIDs must not be stored beyond the lifetime of the contact aggregator to which they belong.
+
:a master contact which was created at run-time for a roster contact to attach to, so that all roster contacts have one or more master contacts. Temporary master contacts are not stored in the local database and their UIDs must not be stored beyond the lifetime of the contact aggregator to which they belong.
;unique identifier (UID)
;unique identifier (UID)
-
: a hashable ID which is unique across all EDS back-ends. See the definition for "temporary master contact" for relevant usage warnings.
+
:a hashable ID which is unique across all EDS back-ends. See the definition for "temporary master contact" for relevant usage warnings.
-
 
+
-
[[Category:Development]]
+
-
[[Category:Documentation]]
+
-
[[Category:Fremantle]]
+

Learn more about Contributing to the wiki.


Please note that all contributions to maemo.org wiki may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see maemo.org wiki:Copyrights for details). Do not submit copyrighted work without permission!


Cancel | Editing help (opens in new window)