Utilities

Utilities — Various utility functions

Synopsis

#define             OSSO_ABOOK_DEFAULT_MAXIMUM_PIXBUF_SIZE
#define             OSSO_ABOOK_INVALID_FILENAME_CHARS
#define             OSSO_ABOOK_FILENAME_PLACEHOLDER_CHAR
char*               osso_abook_mc_account_get_display_string
                                                        (McAccount *account,
                                                         const char *username,
                                                         const char *format);
char*               osso_abook_mc_account_get_display_markup
                                                        (McAccount *account);
const char*         osso_abook_mc_account_get_bound_name
                                                        (McAccount *account);
gboolean            osso_abook_screen_is_landscape_mode (GdkScreen *screen);
void                osso_abook_attach_screen_size_handler
                                                        (GtkWindow *window);
GtkWidget*          osso_abook_pannable_area_new        (void);
char*               osso_abook_normalize_phone_number   (const char *phone_number);
EBookQuery*         osso_abook_query_phone_number       (const char *phone_number,
                                                         gboolean fuzzy_match);
GList*              osso_abook_sort_phone_number_matches
                                                        (GList *matches,
                                                         const char *phone_number);
void                osso_abook_load_pixbuf_async        (GFile *file,
                                                         gsize maximum_size,
                                                         int io_priority,
                                                         GCancellable *cancellable,
                                                         GAsyncReadyCallback callback,
                                                         gpointer user_data);
void                osso_abook_load_pixbuf_at_scale_async
                                                        (GFile *file,
                                                         int width,
                                                         int height,
                                                         gboolean preserve_aspect_ratio,
                                                         gsize maximum_size,
                                                         int io_priority,
                                                         GCancellable *cancellable,
                                                         GAsyncReadyCallback callback,
                                                         gpointer user_data);
GdkPixbuf*          osso_abook_load_pixbuf_finish       (GFile *file,
                                                         GAsyncResult *result,
                                                         GError **error);
char*               osso_abook_concat_names             (OssoABookNameOrder order,
                                                         const gchar *primary,
                                                         const gchar *secondary);
EBook*              osso_abook_system_book_dup_singleton
                                                        (gboolean open,
                                                         GError **error);
GtkWidget*          osso_abook_avatar_button_new        (OssoABookAvatar *avatar,
                                                         int size);
void                osso_abook_set_portrait_mode_supported
                                                        (GtkWindow *window,
                                                         gboolean flag);
void                osso_abook_set_portrait_mode_requested
                                                        (GtkWindow *window,
                                                         gboolean flag);
void                osso_abook_set_zoom_key_used        (GtkWindow *window,
                                                         gboolean flag);
gboolean            osso_abook_file_set_contents        (const char *filename,
                                                         const void *contents,
                                                         gssize length,
                                                         GError **error);
const char*         osso_abook_get_work_dir             (void);
void                osso_abook_enforce_label_width      (GtkLabel *label,
                                                         int width);
gpointer            osso_abook_get_rtcom_el             (void);
GtkWidget*          osso_abook_live_search_new_with_filter
                                                        (OssoABookFilterModel *filter);
gboolean            osso_abook_is_fax_attribute         (EVCardAttribute *attribute);
gboolean            osso_abook_is_mobile_attribute      (EVCardAttribute *attribute);
const gchar*        osso_abook_strip_sip_prefix         (const gchar *address);
EVCardAttribute*    osso_abook_convert_to_tel_attribute (EVCardAttribute *attribute);
gboolean            osso_abook_phone_numbers_equal      (const gchar *tel_a,
                                                         const gchar *tel_b,
                                                         gboolean fuzzy_match);
gboolean            osso_abook_attributes_match         (EVCardAttribute *attr_a,
                                                         EVCardAttribute *attr_b,
                                                         gboolean fuzzy_match);

Description

This module provides convenience functions for performing common tasks in libosso-abook.

Details

OSSO_ABOOK_DEFAULT_MAXIMUM_PIXBUF_SIZE

#define OSSO_ABOOK_DEFAULT_MAXIMUM_PIXBUF_SIZE  (6 * 1024 * 1024) /* 6 Mega Pixels */

The largest size allowed for avatar images


OSSO_ABOOK_INVALID_FILENAME_CHARS

#define OSSO_ABOOK_INVALID_FILENAME_CHARS "\\/:*?\"<>|"

A string of characters that are invalid to use in filenames


OSSO_ABOOK_FILENAME_PLACEHOLDER_CHAR

#define OSSO_ABOOK_FILENAME_PLACEHOLDER_CHAR '_'

A character that should be used in place of the invalid char as listed in OSSO_ABOOK_INVALID_FILENAME_CHARS


osso_abook_mc_account_get_display_string ()

char*               osso_abook_mc_account_get_display_string
                                                        (McAccount *account,
                                                         const char *username,
                                                         const char *format);

Gets a display string for the specified mission-control account. The format argument should have two '%s' conversion specifiers. The first one will correspond to the account name, the second to the username.

account : a McAccount
username : The username associated with the account, or NULL to use the default username for that account
format : a printf-style format string for the a result string or NULL to use the default format
Returns : a newly allocated string representing the account

osso_abook_mc_account_get_display_markup ()

char*               osso_abook_mc_account_get_display_markup
                                                        (McAccount *account);

Gets a display string for the McAccount formatted with Pango markup

account : A McAccount
Returns : A newly allocated markup string representing the account

osso_abook_mc_account_get_bound_name ()

const char*         osso_abook_mc_account_get_bound_name
                                                        (McAccount *account);

Gets the username that is associated with the specified McAccount

account : A McAccount
Returns : a newly-allocated string of the username that is bound to the specified account

osso_abook_screen_is_landscape_mode ()

gboolean            osso_abook_screen_is_landscape_mode (GdkScreen *screen);

Checks whether the screen is in landscape or portrait mode

screen : a GdkScreen
Returns : TRUE if the screen is in landscape mode, else FALSE

osso_abook_attach_screen_size_handler ()

void                osso_abook_attach_screen_size_handler
                                                        (GtkWindow *window);

This function tells window to monitor its current GdkScreen for size changes. If the screen changes,it will internally adjust its size request appropriately for the new screen size.

window : a GtkWindow

osso_abook_pannable_area_new ()

GtkWidget*          osso_abook_pannable_area_new        (void);

Creates a new HildonPannableArea and initializes common properties to values required by osso-addressbook

Returns : a new HildonPannableArea widget

osso_abook_normalize_phone_number ()

char*               osso_abook_normalize_phone_number   (const char *phone_number);

Warning

osso_abook_normalize_phone_number is deprecated and should not be used in newly-written code. Use e_normalize_phone_number() instead.

This function is deprecated. Use e_normalize_phone_number() instead.

phone_number : the phone number
Returns : A newly allocated string.

osso_abook_query_phone_number ()

EBookQuery*         osso_abook_query_phone_number       (const char *phone_number,
                                                         gboolean fuzzy_match);

Constructs an EBookQuery for finding contacts by phone number.

Phone numbers have no well-define format regarding region codes. Network operators choose freely wheither to include country codes when announcing phone numbers. To deal with this situation fuzzy matching can be used. When activated only the last seven digits of each phone number are considered for matches. DTMF codes are dropped for fuzzy matching.

phone_number : the phone number to match
fuzzy_match : wheither fuzzy matching is wanted
Returns : A newly allocated EBookQuery.

osso_abook_sort_phone_number_matches ()

GList*              osso_abook_sort_phone_number_matches
                                                        (GList *matches,
                                                         const char *phone_number);

Sorts contacts according to how well they match phone_number.

matches : the OssoABookContact list
phone_number : the phone number
Returns : The sorted matches list.

osso_abook_load_pixbuf_async ()

void                osso_abook_load_pixbuf_async        (GFile *file,
                                                         gsize maximum_size,
                                                         int io_priority,
                                                         GCancellable *cancellable,
                                                         GAsyncReadyCallback callback,
                                                         gpointer user_data);

Asynchronously loads a #GdkPixbuf from the specified file. If the image file is larger than maximum_size, it will be scaled down to fit.

When callback is called, the operation should be finished by calling osso_abook_load_pixbuf_finish()

file : a GFile
maximum_size : The maximum size of the pixbuf in pixels, or 0 for no maximum
io_priority : the priority level, e.g. G_PRIORITY_DEFAULT
cancellable : a GCancellable to cancel the load, or NULL
callback : the function to call when the load is complete
user_data : extra data to pass to the callback

osso_abook_load_pixbuf_at_scale_async ()

void                osso_abook_load_pixbuf_at_scale_async
                                                        (GFile *file,
                                                         int width,
                                                         int height,
                                                         gboolean preserve_aspect_ratio,
                                                         gsize maximum_size,
                                                         int io_priority,
                                                         GCancellable *cancellable,
                                                         GAsyncReadyCallback callback,
                                                         gpointer user_data);

Asynchronously loads a pixbuf from the specified file and scales it to the requested width and height. If preserve_aspect_ratio is TRUE, both width and height will always be scaled by the same factor necessary to fit into the specified dimensions. If preserve_aspect_ratio is FALSE, the image will be scaled to be exactly width x height, regardless of aspect ratio (i.e. the image may be compressed or stretched in one direction).

When callback is called, the operation should be finished by calling osso_abook_load_pixbuf_finish()

file : a GFile
width : width to scale image in pixels
height : height to scale image in pixels
preserve_aspect_ratio : whether aspect ratio should be preserved when scaling
maximum_size : The maximum size of the pixbuf in pixels, or 0 for no maximum
io_priority : the priority level, e.g. G_PRIORITY_DEFAULT
cancellable : a GCancellable to cancel the load, or NULL
callback : the function to call when the load is complete
user_data : extra data to pass to the callback

osso_abook_load_pixbuf_finish ()

GdkPixbuf*          osso_abook_load_pixbuf_finish       (GFile *file,
                                                         GAsyncResult *result,
                                                         GError **error);

Completes the asynchronous load operation. This function should be called from the GAsyncReadyCallback that was registered in osso_abook_load_pixbuf_async() or osso_abook_load_pixbuf_at_scale_async().

file : the GFile that was loaded
result : the GAsyncResult from a GAsyncReadyCallback
error : return location for an error
Returns : the pixbuf that was loaded, or NULL on error

osso_abook_concat_names ()

char*               osso_abook_concat_names             (OssoABookNameOrder order,
                                                         const gchar *primary,
                                                         const gchar *secondary);

Concatenates a contact's name according to the given order

order : a OssoABookNameOrder value
primary : A contact's primary name
secondary : A contact's secondary name
Returns : A newly-allocated string of the concatenated names

osso_abook_system_book_dup_singleton ()

EBook*              osso_abook_system_book_dup_singleton
                                                        (gboolean open,
                                                         GError **error);

Gets a reference to the system addressbook and optionally opens it

open : Whether to open the system addressbook if it is not already opened
error : a return location for an error value
Returns : the system addressbook, or NULL on error. When it is no longer needed, it should be unreferenced with g_object_unref()

osso_abook_avatar_button_new ()

GtkWidget*          osso_abook_avatar_button_new        (OssoABookAvatar *avatar,
                                                         int size);

Creates a new button containing a picture of a OssoABookAvatar's avatar image that is styled in the same way as the the button in the contact starter

avatar : The OssoABookAvatar whose avatar should be displayed
size : the size of the image displayed in the button
Returns : a new button containing the avatar's avatar image

osso_abook_set_portrait_mode_supported ()

void                osso_abook_set_portrait_mode_supported
                                                        (GtkWindow *window,
                                                         gboolean flag);

Indicates to the window manager whether the specified window should support portrait mode or not

This function exists for historical reasons. Use hildon_gtk_window_set_portrait_flags() instead

window : A GtkWindow
flag : whether this window should support portrait mode

osso_abook_set_portrait_mode_requested ()

void                osso_abook_set_portrait_mode_requested
                                                        (GtkWindow *window,
                                                         gboolean flag);

Indicates to the window manager whether the specified window requests to be displayed in portrait mode or not

This function exists for historical reasons. Use hildon_gtk_window_set_portrait_flags() instead

window : A GtkWindow
flag : whether this window should request portrait mode

osso_abook_set_zoom_key_used ()

void                osso_abook_set_zoom_key_used        (GtkWindow *window,
                                                         gboolean flag);

Indicates that the specified window will handle the hardware zoom keys

window : A GtkWindow
flag : whether zoom keys will be used

osso_abook_file_set_contents ()

gboolean            osso_abook_file_set_contents        (const char *filename,
                                                         const void *contents,
                                                         gssize length,
                                                         GError **error);

This function exists for historical reasons. Use g_file_set_contents() instead

filename : the name of the file to write
contents : the data to write to the file
length : the size of contents
error : return value for error value
Returns : TRUE on succes, FALSE on error

osso_abook_get_work_dir ()

const char*         osso_abook_get_work_dir             (void);

Gets the working directory for the libosso-abook

Returns : Path to the working directory. The string is owned by libosso-abook and should not be freed.

osso_abook_enforce_label_width ()

void                osso_abook_enforce_label_width      (GtkLabel *label,
                                                         int width);

Forces a GtkLabel to always request the specified width

label : A GtkLabel
width : the width to enforce

osso_abook_get_rtcom_el ()

gpointer            osso_abook_get_rtcom_el             (void);

Creating RTComEL object is an heavy opperation that involves DB access. This function make sure the logger is created only once. You don't have to unref the returned object.

Returns : a singleton RTComEl.

osso_abook_live_search_new_with_filter ()

GtkWidget*          osso_abook_live_search_new_with_filter
                                                        (OssoABookFilterModel *filter);

osso_abook_is_fax_attribute ()

gboolean            osso_abook_is_fax_attribute         (EVCardAttribute *attribute);

attribute : A EVCardAttribute
Returns : TRUE if attribute is a TEL attribute with the fax TYPE param, but no other media type (e.g. voice or cell), FALSE otherwise.

osso_abook_is_mobile_attribute ()

gboolean            osso_abook_is_mobile_attribute      (EVCardAttribute *attribute);

attribute : A EVCardAttribute
Returns : TRUE if attribute is a TEL attribute for a mobile phone, FALSE otherwise.

osso_abook_strip_sip_prefix ()

const gchar*        osso_abook_strip_sip_prefix         (const gchar *address);

Strip the "sip:" or "sips:" prefix if any.

address : An sip address
Returns : A pointer inside the address string, or address itself if no prefix is found.

osso_abook_convert_to_tel_attribute ()

EVCardAttribute*    osso_abook_convert_to_tel_attribute (EVCardAttribute *attribute);

Convert an attribute to a similar TEL attribute. For example it convert X-SIP:sip:+1234server.com to TEL:+1234. Or X-SKYPE:+1234 to TEL:+1234.

attribute : A EVCardAttribute
Returns : A new EVCardAttribute if the conversion is possible, NULL otherwise.

osso_abook_phone_numbers_equal ()

gboolean            osso_abook_phone_numbers_equal      (const gchar *tel_a,
                                                         const gchar *tel_b,
                                                         gboolean fuzzy_match);

Checks whether tel_a and tel_b are the same phone number. For details about fuzzy_match, see osso_abook_query_phone_number()

tel_a : a phone number
tel_b : a phone number
fuzzy_match : whether fuzzy matching is wanted
Returns : TRUE if tel_a and tel_b match, FALSE otherwise.

osso_abook_attributes_match ()

gboolean            osso_abook_attributes_match         (EVCardAttribute *attr_a,
                                                         EVCardAttribute *attr_b,
                                                         gboolean fuzzy_match);

Returns whether attr_a and attr_b have the same name and values, ignoring parameters. If fuzzy_match is true then the attributes can match even if they are not literally the same (for instance the phone number +1234567p3 would match 001234567).

attr_a : an EVCardAttribute
attr_b : an EVCardAttribute
fuzzy_match : whether fuzzy matching is wanted
Returns : TRUE if attr_a and attr_b match, FALSE otherwise.