aboutsummaryrefslogtreecommitdiffstats
path: root/libempathy/empathy-message.c
diff options
context:
space:
mode:
authorXavier Claessens <xclaesse@src.gnome.org>2008-04-02 17:41:50 +0800
committerXavier Claessens <xclaesse@src.gnome.org>2008-04-02 17:41:50 +0800
commit137e275fa6bf039dd5581483bf0cd9ed5be88914 (patch)
treee56978c81d89599e53b8c90d6e9522875961443d /libempathy/empathy-message.c
parentc17d91d81999edd94cd4417acb8e39491076098b (diff)
downloadgsoc2013-empathy-137e275fa6bf039dd5581483bf0cd9ed5be88914.tar
gsoc2013-empathy-137e275fa6bf039dd5581483bf0cd9ed5be88914.tar.gz
gsoc2013-empathy-137e275fa6bf039dd5581483bf0cd9ed5be88914.tar.bz2
gsoc2013-empathy-137e275fa6bf039dd5581483bf0cd9ed5be88914.tar.lz
gsoc2013-empathy-137e275fa6bf039dd5581483bf0cd9ed5be88914.tar.xz
gsoc2013-empathy-137e275fa6bf039dd5581483bf0cd9ed5be88914.tar.zst
gsoc2013-empathy-137e275fa6bf039dd5581483bf0cd9ed5be88914.zip
Rework EmpathyChat's API, it is now a subclass of GtkBin.
svn path=/trunk/; revision=840
Diffstat (limited to 'libempathy/empathy-message.c')
-rw-r--r--libempathy/empathy-message.c61
1 files changed, 61 insertions, 0 deletions
diff --git a/libempathy/empathy-message.c b/libempathy/empathy-message.c
index 76b49bd1a..d6b8e5323 100644
--- a/libempathy/empathy-message.c
+++ b/libempathy/empathy-message.c
@@ -437,6 +437,67 @@ empathy_message_get_date_and_time (EmpathyMessage *message, time_t *timestamp)
return date;
}
+#define IS_SEPARATOR(ch) (ch == ' ' || ch == ',' || ch == '.' || ch == ':')
+gboolean
+empathy_message_should_highlight (EmpathyMessage *message)
+{
+ EmpathyContact *contact;
+ const gchar *msg, *to;
+ gchar *cf_msg, *cf_to;
+ gchar *ch;
+ gboolean ret_val;
+
+ g_return_val_if_fail (EMPATHY_IS_MESSAGE (message), FALSE);
+
+ ret_val = FALSE;
+
+ msg = empathy_message_get_body (message);
+ if (!msg) {
+ return FALSE;
+ }
+
+ contact = empathy_message_get_receiver (message);
+ if (!contact || !empathy_contact_is_user (contact)) {
+ return FALSE;
+ }
+
+ to = empathy_contact_get_name (contact);
+ if (!to) {
+ return FALSE;
+ }
+
+ cf_msg = g_utf8_casefold (msg, -1);
+ cf_to = g_utf8_casefold (to, -1);
+
+ ch = strstr (cf_msg, cf_to);
+ if (ch == NULL) {
+ goto finished;
+ }
+ if (ch != cf_msg) {
+ /* Not first in the message */
+ if (!IS_SEPARATOR (*(ch - 1))) {
+ goto finished;
+ }
+ }
+
+ ch = ch + strlen (cf_to);
+ if (ch >= cf_msg + strlen (cf_msg)) {
+ ret_val = TRUE;
+ goto finished;
+ }
+
+ if (IS_SEPARATOR (*ch)) {
+ ret_val = TRUE;
+ goto finished;
+ }
+
+finished:
+ g_free (cf_msg);
+ g_free (cf_to);
+
+ return ret_val;
+}
+
EmpathyMessageType
empathy_message_type_from_str (const gchar *type_str)
{