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 | + | = 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. | ||
- | This tutorial is focused on using Address Book functionality within third-party applications. It does not cover all classes nor does it cover any classes exhaustively. For information on the classes, see the [http://maemo.org/api_refs/5.0/ | + | This tutorial is focused on using Address Book functionality within third-party applications. It does not cover all classes nor does it cover any classes exhaustively. For information on the classes, see the [http://maemo.org/api_refs/5.0/beta/libosso-abook/ reference documentation]. |
== Components == | == Components == | ||
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 | + | [[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, | + | 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 | + | 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 = | |
- | + | == 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) | ||
- | |||
- | + | 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> | |
- | < | + | include <glib.h> |
- | + | ||
#include <libosso-abook/osso-abook.h> | #include <libosso-abook/osso-abook.h> | ||
Line 83: | Line 87: | ||
} | } | ||
} | } | ||
- | </ | + | </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 === | |
- | 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, | + | 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: |
- | < | + | <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)); | ||
- | </ | + | </pre> |
- | + | === Notable Signals === | |
- | * | + | * notify::avatar-image |
- | + | === 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]. | ||
- | + | == OssoABookCaps == | |
- | === | + | === Overview === |
- | + | 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 === | |
- | The core of | + | 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> | |
- | < | + | |
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"); | ||
} | } | ||
- | </ | + | </pre> |
- | + | === Additional API === | |
- | + | OssoABookCaps also contains a convenience function for getting the capabilities of our own accounts (of type McAccount*). | |
- | + | <pre> | |
- | < | + | |
OssoABookCapsFlags caps_flags = osso_abook_caps_from_account (account); | OssoABookCapsFlags caps_flags = osso_abook_caps_from_account (account); | ||
- | </ | + | </pre> |
- | + | === Notable Signals === | |
- | * | + | * notify::capabilities |
- | + | ||
- | + | ||
+ | === 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 == | |
- | The central class in libosso-abook is | + | === 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 | + | 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, 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. | |
- | + | 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. | |
- | + | 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. | |
- | + | === Basic Examples === | |
- | + | ==== 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. | ||
- | < | + | 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"); | ||
} | } | ||
- | </ | + | </pre> |
- | + | === Additional API === | |
- | There are many ways to use an | + | 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 | + | Here are some highlights of additional API for OssoABookContact. |
- | + | ==== 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 | + | 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). |
- | < | + | <pre> |
osso_abook_contact_to_string (contact, EVC_FORMAT_VCARD_30, FALSE); | osso_abook_contact_to_string (contact, EVC_FORMAT_VCARD_30, FALSE); | ||
- | </ | + | </pre> |
- | In case you need to sort some 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: |
- | < | + | <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); | ||
- | </ | + | </pre> |
- | + | ||
+ | ==== 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: | ||
- | < | + | <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); | ||
} | } | ||
- | </ | + | </pre> |
- | + | ==== 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> | |
- | < | + | |
#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"); | ||
} | } | ||
- | </ | + | </pre> |
- | + | ==== 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: | ||
- | < | + | <pre> |
const char *key = osso_abook_contact_get_uid (contact); | const char *key = osso_abook_contact_get_uid (contact); | ||
- | </ | + | </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: | ||
- | < | + | <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!"); | ||
} | } | ||
- | </ | + | </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: | ||
- | < | + | <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); | ||
} | } | ||
- | </ | + | </pre> |
- | + | === Notable Signals === | |
- | * | + | * reset |
- | * | + | * contact-attached |
- | * | + | * contact-detached |
- | + | === Complete API Documentation === | |
- | Full details can be found in the API [http://maemo.org/api_refs/5.0/ | + | 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 == | |
+ | |||
+ | === 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 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". | |
- | + | OssoABookPresence is implemented by OssoABookContact, so OssoABookPresence functions are used directly upon OssoABookContacts. | |
- | + | === Basic Example === | |
- | < | + | 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))); | ||
} | } | ||
- | </ | + | </pre> |
- | + | === Additional API === | |
- | The example above shows how to compare the basic | + | 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> | |
- | < | + | |
/* 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); | ||
- | </ | + | </pre> |
- | + | === Notable Signals === | |
- | * | + | * notify::presence-location-string |
- | * | + | * notify::presence-status |
- | * | + | * notify::presence-status-message |
- | * | + | * notify::presence-type |
- | + | === 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 = | |
- | + | == OssoABookContactChooser == | |
- | + | === 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 === | |
- | + | The following is a simple example of the use of OssoABookContactChooser: | |
- | The following is a simple example of the use of | + | |
- | < | + | <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); | ||
} | } | ||
- | </ | + | </pre> |
- | + | === 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. | ||
- | + | 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: | ||
- | < | + | <pre> |
osso_abook_contact_chooser_set_capabilities (chooser, OSSO_ABOOK_CAPS_EMAIL); | osso_abook_contact_chooser_set_capabilities (chooser, OSSO_ABOOK_CAPS_EMAIL); | ||
- | </ | + | </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: | ||
- | < | + | <pre> |
osso_abook_contact_chooser_set_hide_offline_contacts (chooser, TRUE); | osso_abook_contact_chooser_set_hide_offline_contacts (chooser, TRUE); | ||
- | </ | + | </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. | ||
- | < | + | <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); | ||
- | </ | + | </pre> |
If an application needs even more control, | If an application needs even more control, | ||
- | + | 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. | ||
- | < | + | <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); | ||
- | </ | + | </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 === | |
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 == | |
- | Although | + | === 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 | ||
- | + | OssoABookTreeView object directly. Most of the time, applications will deal | |
- | with | + | with OssoABookContactView objects, which inherits from this class and does most |
+ | of the setup work for you. | ||
- | + | === Additional API === | |
- | + | OssoABookTreeView is an aggregate widget, but it provides direct access to the | |
- | + | 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 | + | 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: | ||
- | < | + | <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); | ||
- | </ | + | </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 |
- | + | 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: | ||
- | * | + | * show-contact-avatar |
- | * | + | * show-contact-name |
- | * | + | * show-contact-presence |
- | * | + | * show-contact-telephone |
- | + | === 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 == | |
- | + | === Overview === | |
- | contacts in a list. It builds upon | + | |
+ | 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 === | |
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. | ||
- | < | + | <pre> |
#include <libosso-abook/osso-abook.h> | #include <libosso-abook/osso-abook.h> | ||
Line 642: | Line 660: | ||
gtk_main (); | gtk_main (); | ||
} | } | ||
- | </ | + | </pre> |
- | + | === Additional API === | |
- | + | OssoABookContactView has some additional convenience API that allows you to get | |
- | * | + | the contact (or properties of the contact) that currently has input focus: |
- | * | + | * osso_abook_contact_view_get_focus() |
- | * | + | * osso_abook_contact_view_get_focus_avatar() |
- | * | + | * 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. | ||
- | + | osso_abook_contact_view_set_minimum_selection() and | |
- | + | osso_abook_contact_view_set_maximum_selection() allow fine-grained control over | |
+ | how contacts can be selected. | ||
- | + | === 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 == | |
- | + | === 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 === | |
The following is a simple example that shows how to use | The following is a simple example that shows how to use | ||
- | + | OssoABookTouchContactStarter to display the details of a particular contact. | |
- | < | + | <pre> |
#include <libosso-abook/osso-abook.h> | #include <libosso-abook/osso-abook.h> | ||
Line 706: | Line 728: | ||
return 0; | return 0; | ||
} | } | ||
- | </ | + | </pre> |
- | + | ||
- | + | ||
+ | === 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 | + | customize the OssoABookTouchContactStarter widget. By default the contact |
- | + | 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 | + | 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 | ||
- | + | osso_abook_touch_contact_starter_new_not_interactive(). In addition, an | |
- | application can override the default actions by connecting to the | + | application can override the default actions by connecting to the |
+ | "pre-action-start" signal. For example: | ||
- | < | + | <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); | ||
- | </ | + | </pre> |
- | + | === 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 = | |
;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 | + | :an OssoABookAggregator object which manages connections to the EDS backends and associates master contacts with their roster contacts. |
;master contact | ;master contact | ||
- | : an | + | :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 | + | :an OssoABookContact which is stored in the EDS local database and has zero or more roster contacts. |
;roster contact | ;roster contact | ||
- | : an | + | :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. |
- | + | ||
- | + | ||
- | + | ||
- | + |
Learn more about Contributing to the wiki.