diff options
author | Will Thompson <will@willthompson.co.uk> | 2012-01-19 00:31:28 +0800 |
---|---|---|
committer | Will Thompson <will@willthompson.co.uk> | 2012-01-19 01:55:08 +0800 |
commit | b12ce233dce1dcd581b34ea9944e36e59f511497 (patch) | |
tree | 0cf710f98f76388f48790744b04c9fd50ec654bc /libempathy | |
parent | be14bbb863d0fc83402f9307e5193175d77e6d0d (diff) | |
download | gsoc2013-empathy-b12ce233dce1dcd581b34ea9944e36e59f511497.tar gsoc2013-empathy-b12ce233dce1dcd581b34ea9944e36e59f511497.tar.gz gsoc2013-empathy-b12ce233dce1dcd581b34ea9944e36e59f511497.tar.bz2 gsoc2013-empathy-b12ce233dce1dcd581b34ea9944e36e59f511497.tar.lz gsoc2013-empathy-b12ce233dce1dcd581b34ea9944e36e59f511497.tar.xz gsoc2013-empathy-b12ce233dce1dcd581b34ea9944e36e59f511497.tar.zst gsoc2013-empathy-b12ce233dce1dcd581b34ea9944e36e59f511497.zip |
Move empathy_message_should_highlight to EmpathyChat
This will give us a place to cache the GRegex object. (Of course, this
also depends on monitoring changes to the TpChat's self contact's alias,
and changes to the TpChat's self contact!)
Diffstat (limited to 'libempathy')
-rw-r--r-- | libempathy/empathy-message.c | 70 | ||||
-rw-r--r-- | libempathy/empathy-message.h | 1 |
2 files changed, 0 insertions, 71 deletions
diff --git a/libempathy/empathy-message.c b/libempathy/empathy-message.c index 9841cbb61..6111bcd8c 100644 --- a/libempathy/empathy-message.c +++ b/libempathy/empathy-message.c @@ -39,9 +39,6 @@ # include <telepathy-logger/call-event.h> #endif -#define DEBUG_FLAG EMPATHY_DEBUG_CHAT -#include "empathy-debug.h" - #include "empathy-client-factory.h" #include "empathy-message.h" #include "empathy-utils.h" @@ -636,73 +633,6 @@ empathy_message_is_backlog (EmpathyMessage *message) return priv->is_backlog; } -static GRegex * -get_highlight_regex_for (const gchar *name) -{ - GRegex *regex; - gchar *name_esc, *pattern; - GError *error = NULL; - - name_esc = g_regex_escape_string (name, -1); - pattern = g_strdup_printf ("\\b%s\\b", name_esc); - regex = g_regex_new (pattern, G_REGEX_CASELESS | G_REGEX_OPTIMIZE, 0, - &error); - - if (regex == NULL) { - DEBUG ("couldn't compile regex /%s/: %s", pattern, - error->message); - - g_error_free (error); - } - - g_free (pattern); - g_free (name_esc); - - return regex; -} - -gboolean -empathy_message_should_highlight (EmpathyMessage *message) -{ - EmpathyContact *contact; - const gchar *msg, *to; - gboolean ret_val = FALSE; - TpChannelTextMessageFlags flags; - GRegex *regex; - - g_return_val_if_fail (EMPATHY_IS_MESSAGE (message), 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_alias (contact); - if (!to) { - return FALSE; - } - - flags = empathy_message_get_flags (message); - if (flags & TP_CHANNEL_TEXT_MESSAGE_FLAG_SCROLLBACK) { - /* FIXME: Ideally we shouldn't highlight scrollback messages only if they - * have already been received by the user before (and so are in the logs) */ - return FALSE; - } - - regex = get_highlight_regex_for (to); - if (regex != NULL) { - ret_val = g_regex_match (regex, msg, 0, NULL); - g_regex_unref (regex); - } - - return ret_val; -} - TpChannelTextMessageType empathy_message_type_from_str (const gchar *type_str) { diff --git a/libempathy/empathy-message.h b/libempathy/empathy-message.h index 0c27c09e9..81da7bf43 100644 --- a/libempathy/empathy-message.h +++ b/libempathy/empathy-message.h @@ -77,7 +77,6 @@ gint64 empathy_message_get_original_timestamp (EmpathyMessage gboolean empathy_message_is_backlog (EmpathyMessage *message); gboolean empathy_message_is_incoming (EmpathyMessage *message); -gboolean empathy_message_should_highlight (EmpathyMessage *message); TpChannelTextMessageType empathy_message_type_from_str (const gchar *type_str); const gchar * empathy_message_type_to_str (TpChannelTextMessageType type); |