diff options
author | Guillaume Desmottes <guillaume.desmottes@collabora.co.uk> | 2011-05-31 21:24:28 +0800 |
---|---|---|
committer | Guillaume Desmottes <guillaume.desmottes@collabora.co.uk> | 2011-05-31 21:36:45 +0800 |
commit | 5dc3feb4979804c710d4e872a1f05bc425fd9410 (patch) | |
tree | 56a8c25b388d10f9400aefa72a379d824806fa6b /libempathy-gtk/empathy-ui-utils.c | |
parent | d4e5a5295ff83f664c80fe3af61db0692829ea1b (diff) | |
download | gsoc2013-empathy-5dc3feb4979804c710d4e872a1f05bc425fd9410.tar gsoc2013-empathy-5dc3feb4979804c710d4e872a1f05bc425fd9410.tar.gz gsoc2013-empathy-5dc3feb4979804c710d4e872a1f05bc425fd9410.tar.bz2 gsoc2013-empathy-5dc3feb4979804c710d4e872a1f05bc425fd9410.tar.lz gsoc2013-empathy-5dc3feb4979804c710d4e872a1f05bc425fd9410.tar.xz gsoc2013-empathy-5dc3feb4979804c710d4e872a1f05bc425fd9410.tar.zst gsoc2013-empathy-5dc3feb4979804c710d4e872a1f05bc425fd9410.zip |
factor out empathy_individual_match_words()
Diffstat (limited to 'libempathy-gtk/empathy-ui-utils.c')
-rw-r--r-- | libempathy-gtk/empathy-ui-utils.c | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/libempathy-gtk/empathy-ui-utils.c b/libempathy-gtk/empathy-ui-utils.c index a1bd50f1a..ee73c14c8 100644 --- a/libempathy-gtk/empathy-ui-utils.c +++ b/libempathy-gtk/empathy-ui-utils.c @@ -44,6 +44,7 @@ #include "empathy-ui-utils.h" #include "empathy-images.h" +#include "empathy-live-search.h" #include "empathy-smiley-manager.h" #define DEBUG_FLAG EMPATHY_DEBUG_OTHER @@ -1947,3 +1948,44 @@ empathy_get_current_action_time (void) { return (tp_user_action_time_from_x11 (gtk_get_current_event_time ())); } + +gboolean +empathy_individual_match_words (FolksIndividual *individual, + GPtrArray *words) +{ + const gchar *str; + GList *personas, *l; + + /* check alias name */ + str = folks_alias_details_get_alias (FOLKS_ALIAS_DETAILS (individual)); + + if (empathy_live_search_match_words (str, words)) + return TRUE; + + personas = folks_individual_get_personas (individual); + + /* check contact id, remove the @server.com part */ + for (l = personas; l; l = l->next) + { + const gchar *p; + gchar *dup_str = NULL; + gboolean visible; + + if (!empathy_folks_persona_is_interesting (FOLKS_PERSONA (l->data))) + continue; + + str = folks_persona_get_display_id (l->data); + p = strstr (str, "@"); + if (p != NULL) + str = dup_str = g_strndup (str, p - str); + + visible = empathy_live_search_match_words (str, words); + g_free (dup_str); + if (visible) + return TRUE; + } + + /* FIXME: Add more rules here, we could check phone numbers in + * contact's vCard for example. */ + return FALSE; +} |