Utility Functions

Utility Functions — Miscellaneous utility functions for evolution-data-server.

Synopsis

struct              tm;
const gchar *       e_get_user_cache_dir                (void);
const gchar *       e_get_user_config_dir               (void);
const gchar *       e_get_user_data_dir                 (void);
gchar *             e_util_strstrcase                   (const gchar *haystack,
                                                         const gchar *needle);
gchar *             e_util_unicode_get_utf8             (const gchar *text,
                                                         gunichar *out);
const gchar *       e_util_utf8_strstrcase              (const gchar *haystack,
                                                         const gchar *needle);
const gchar *       e_util_utf8_strstrcasedecomp        (const gchar *haystack,
                                                         const gchar *needle);
gint                e_util_utf8_strcasecmp              (const gchar *s1,
                                                         const gchar *s2);
gchar *             e_util_utf8_remove_accents          (const gchar *str);
gchar *             e_util_utf8_make_valid              (const gchar *str);
const gchar *       e_util_ensure_gdbus_string          (const gchar *str,
                                                         gchar **gdbus_str);
guint64             e_util_gthread_id                   (GThread *thread);
void                e_filename_make_safe                (gchar *string);
gsize               e_utf8_strftime                     (gchar *string,
                                                         gsize max,
                                                         const gchar *fmt,
                                                         const struct tm *tm);
gsize               e_strftime                          (gchar *string,
                                                         gsize max,
                                                         const gchar *fmt,
                                                         const struct tm *tm);
const gchar *       e_util_get_prefix                   (void);
const gchar *       e_util_get_cp_prefix                (void);
const gchar *       e_util_get_localedir                (void);
gchar *             e_util_replace_prefix               (const gchar *configure_time_prefix,
                                                         const gchar *runtime_prefix,
                                                         const gchar *configure_time_path);
gint                e_data_server_util_get_dbus_call_timeout
                                                        (void);
void                e_data_server_util_set_dbus_call_timeout
                                                        (gint timeout_msec);

Description

Details

struct tm

struct tm;


e_get_user_cache_dir ()

const gchar *       e_get_user_cache_dir                (void);

Returns a base directory in which to store user-specific, non-essential cached data for Evolution or Evolution-Data-Server.

The returned string is owned by libedataserver and must not be modified or freed.

Returns :

base directory for user-specific, non-essential data

Since 2.32


e_get_user_config_dir ()

const gchar *       e_get_user_config_dir               (void);

Returns a base directory in which to store user-specific configuration information for Evolution or Evolution-Data-Server.

The returned string is owned by libedataserver and must not be modified or freed.

Returns :

base directory for user-specific configuration information

Since 2.32


e_get_user_data_dir ()

const gchar *       e_get_user_data_dir                 (void);

Returns a base directory in which to store user-specific data for Evolution or Evolution-Data-Server.

The returned string is owned by libedataserver and must not be modified or freed.

Returns :

base directory for user-specific data

Since 2.32


e_util_strstrcase ()

gchar *             e_util_strstrcase                   (const gchar *haystack,
                                                         const gchar *needle);

Find the first instance of needle in haystack, ignoring case for bytes that are ASCII characters.

haystack :

The string to search in.

needle :

The string to search for.

Returns :

A pointer to the start of needle in haystack, or NULL if needle is not found.

e_util_unicode_get_utf8 ()

gchar *             e_util_unicode_get_utf8             (const gchar *text,
                                                         gunichar *out);

Get a UTF-8 character from the beginning of text.

text :

The string to take the UTF-8 character from.

out :

The location to store the UTF-8 character in.

Returns :

A pointer to the next character in text after out.

e_util_utf8_strstrcase ()

const gchar *       e_util_utf8_strstrcase              (const gchar *haystack,
                                                         const gchar *needle);

Find the first instance of needle in haystack, ignoring case. (No proper case folding or decomposing is done.) Both needle and haystack are UTF-8 strings.

haystack :

The string to search in.

needle :

The string to search for.

Returns :

A pointer to the first instance of needle in haystack, or NULL if no match is found, or if either of the strings are not legal UTF-8 strings.

e_util_utf8_strstrcasedecomp ()

const gchar *       e_util_utf8_strstrcasedecomp        (const gchar *haystack,
                                                         const gchar *needle);

Find the first instance of needle in haystack, where both needle and haystack are UTF-8 strings. Both strings are stripped and decomposed for comparison, and case is ignored.

haystack :

The string to search in.

needle :

The string to search for.

Returns :

A pointer to the first instance of needle in haystack, or NULL if either of the strings are not legal UTF-8 strings.

e_util_utf8_strcasecmp ()

gint                e_util_utf8_strcasecmp              (const gchar *s1,
                                                         const gchar *s2);

s1 :

s2 :

Returns :


e_util_utf8_remove_accents ()

gchar *             e_util_utf8_remove_accents          (const gchar *str);

str :

Returns :

newly allocates string, copy of 'str', without accents.

Since 2.28


e_util_utf8_make_valid ()

gchar *             e_util_utf8_make_valid              (const gchar *str);

str :

Returns :

newly allocates string, copy of 'str', which is UTF8 valid string. Invalid letters are replaced with question marks U+FFFD.

Since 3.0


e_util_ensure_gdbus_string ()

const gchar *       e_util_ensure_gdbus_string          (const gchar *str,
                                                         gchar **gdbus_str);

str :

What to convert, if NULL, then returns empty string.

gdbus_str :

In case that 'str' is not valid UTF8 string and new memory allocated, then it is returned in this variable, and its value should be freed with g_free(). It cannot be NULL.

Returns :

string usable for GDBus, or more precisely GVariant, which requires UTF8 encoded strings for a transfer. If the str is not UTF8 valid, then new string is allocated and returned in gdbus_str, on which is supposed to be called g_free().

Since 3.0


e_util_gthread_id ()

guint64             e_util_gthread_id                   (GThread *thread);

Returns a 64-bit integer hopefully uniquely identifying the thread. To be used in debugging output and logging only. The returned value is just a cast of a pointer to the 64-bit integer.

There is no guarantee that calling e_util_gthread_id() on one thread first and later after that thread has dies on another won't return the same integer.

On Linux and Win32, known to really return a unique id for each thread existing at a certain time. No guarantee that ids won't be reused after a thread has terminated, though.

thread :

A GThread pointer

Returns :

A 64-bit integer.

Since 2.32


e_filename_make_safe ()

void                e_filename_make_safe                (gchar *string);

string :


e_utf8_strftime ()

gsize               e_utf8_strftime                     (gchar *string,
                                                         gsize max,
                                                         const gchar *fmt,
                                                         const struct tm *tm);

The UTF-8 equivalent of e_strftime().

string :

The string array to store the result in.

max :

The size of array s.

fmt :

The formatting to use on tm.

tm :

The time value to format.

Returns :

The number of characters placed in s.

e_strftime ()

gsize               e_strftime                          (gchar *string,
                                                         gsize max,
                                                         const gchar *fmt,
                                                         const struct tm *tm);

This function is a wrapper around the strftime (3) function, which converts the %l and %k (12h and 24h) format variables if necessary.

string :

The string array to store the result in.

max :

The size of array s.

fmt :

The formatting to use on tm.

tm :

The time value to format.

Returns :

The number of characters placed in s.

e_util_get_prefix ()

const gchar *       e_util_get_prefix                   (void);

Returns :


e_util_get_cp_prefix ()

const gchar *       e_util_get_cp_prefix                (void);

Returns :


e_util_get_localedir ()

const gchar *       e_util_get_localedir                (void);

Returns :


e_util_replace_prefix ()

gchar *             e_util_replace_prefix               (const gchar *configure_time_prefix,
                                                         const gchar *runtime_prefix,
                                                         const gchar *configure_time_path);

configure_time_prefix :

runtime_prefix :

configure_time_path :

Returns :


e_data_server_util_get_dbus_call_timeout ()

gint                e_data_server_util_get_dbus_call_timeout
                                                        (void);

Since 3.0


e_data_server_util_set_dbus_call_timeout ()

void                e_data_server_util_set_dbus_call_timeout
                                                        (gint timeout_msec);

Sets default timeout, in miliseconds, for calls of g_dbus_proxy_call() family functions.

-1 means the default value as set by DBus itself. G_MAXINT means no timeout at all.

Default value is set also by configure option --with-dbus-call-timeout=ms and -1 is used when not set.

timeout_msec :

Default timeout for DBus calls in miliseconds.

Since 3.0