aboutsummaryrefslogtreecommitdiffstats
path: root/libempathy
diff options
context:
space:
mode:
authorWill Thompson <will@willthompson.co.uk>2012-01-26 00:01:32 +0800
committerWill Thompson <will@willthompson.co.uk>2012-01-26 00:01:32 +0800
commitddd8a9a000833d87260f81c4459063b32e2e14e7 (patch)
treee41b456cfd9857fec9f122be2fdd94cc4da07eab /libempathy
parent6b453cffcd14296f9625eb54af7cb87dc75c9c5f (diff)
parentcb4d7495d1ed8fabe40e552a4107ce6398814323 (diff)
downloadgsoc2013-empathy-ddd8a9a000833d87260f81c4459063b32e2e14e7.tar
gsoc2013-empathy-ddd8a9a000833d87260f81c4459063b32e2e14e7.tar.gz
gsoc2013-empathy-ddd8a9a000833d87260f81c4459063b32e2e14e7.tar.bz2
gsoc2013-empathy-ddd8a9a000833d87260f81c4459063b32e2e14e7.tar.lz
gsoc2013-empathy-ddd8a9a000833d87260f81c4459063b32e2e14e7.tar.xz
gsoc2013-empathy-ddd8a9a000833d87260f81c4459063b32e2e14e7.tar.zst
gsoc2013-empathy-ddd8a9a000833d87260f81c4459063b32e2e14e7.zip
Merge branch 'highlight-regex'
Diffstat (limited to 'libempathy')
-rw-r--r--libempathy/empathy-message.c69
-rw-r--r--libempathy/empathy-message.h1
-rw-r--r--libempathy/empathy-tp-chat.c19
3 files changed, 19 insertions, 70 deletions
diff --git a/libempathy/empathy-message.c b/libempathy/empathy-message.c
index 995f49ab7..6111bcd8c 100644
--- a/libempathy/empathy-message.c
+++ b/libempathy/empathy-message.c
@@ -633,75 +633,6 @@ empathy_message_is_backlog (EmpathyMessage *message)
return priv->is_backlog;
}
-#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;
- TpChannelTextMessageFlags flags;
-
- 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_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;
- }
-
- 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;
-}
-
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);
diff --git a/libempathy/empathy-tp-chat.c b/libempathy/empathy-tp-chat.c
index 96eda77b8..fcef6e8a7 100644
--- a/libempathy/empathy-tp-chat.c
+++ b/libempathy/empathy-tp-chat.c
@@ -69,6 +69,7 @@ static void tp_chat_iface_init (EmpathyContactListIface *iface);
enum {
PROP_0,
PROP_ACCOUNT,
+ PROP_SELF_CONTACT,
PROP_REMOTE_CONTACT,
PROP_N_MESSAGES_SENDING,
PROP_TITLE,
@@ -948,6 +949,7 @@ tp_chat_got_renamed_contacts_cb (TpConnection *connection,
/* We change our nick */
tp_clear_object (&self->priv->user);
self->priv->user = g_object_ref (new);
+ g_object_notify (chat, "self-contact");
}
check_almost_ready (self);
@@ -1068,6 +1070,7 @@ tp_chat_got_self_contact_cb (TpConnection *connection,
self->priv->user = g_object_ref (contact);
empathy_contact_set_is_user (self->priv->user, TRUE);
+ g_object_notify (chat, "self-contact");
check_almost_ready (self);
}
@@ -1083,6 +1086,9 @@ tp_chat_get_property (GObject *object,
case PROP_ACCOUNT:
g_value_set_object (value, self->priv->account);
break;
+ case PROP_SELF_CONTACT:
+ g_value_set_object (value, self->priv->user);
+ break;
case PROP_REMOTE_CONTACT:
g_value_set_object (value, self->priv->remote_contact);
break;
@@ -1171,6 +1177,19 @@ empathy_tp_chat_class_init (EmpathyTpChatClass *klass)
G_PARAM_CONSTRUCT_ONLY |
G_PARAM_STATIC_STRINGS));
+ /**
+ * EmpathyTpChat:self-contact:
+ *
+ * Not to be confused with TpChannel:group-self-contact.
+ */
+ g_object_class_install_property (object_class,
+ PROP_SELF_CONTACT,
+ g_param_spec_object ("self-contact",
+ "The local contact",
+ "The EmpathyContact for the local user on this channel",
+ EMPATHY_TYPE_CONTACT,
+ G_PARAM_READABLE));
+
g_object_class_install_property (object_class,
PROP_REMOTE_CONTACT,
g_param_spec_object ("remote-contact",