diff options
author | Nicolas Dufresne <nicolas.dufresne@collabora.co.uk> | 2011-03-15 13:46:44 -0400 |
---|---|---|
committer | Nicolas Dufresne <nicolas.dufresne@collabora.co.uk> | 2011-03-15 13:46:44 -0400 |
commit | 7c0d7486779f93ab5f02e3893fc59db2bca2381b (patch) | |
tree | afd066c92b62d013423f324a5d08e6fbe7c7da0c | |
parent | 934c602751618019c79d592e899bb028e62cbf6f (diff) |
Correctly implement event_equal
The old implementation was relying on a hash that did not contain all the
contain all the information.
-rw-r--r-- | telepathy-logger/event.c | 17 | ||||
-rw-r--r-- | telepathy-logger/text-event.c | 16 |
2 files changed, 32 insertions, 1 deletions
diff --git a/telepathy-logger/event.c b/telepathy-logger/event.c index f76c7f8..2d1765c 100644 --- a/telepathy-logger/event.c +++ b/telepathy-logger/event.c @@ -23,6 +23,7 @@ #include "event-internal.h" #include <glib.h> +#include "entity-internal.h" #define DEBUG_FLAG TPL_DEBUG_EVENT #include <telepathy-logger/debug-internal.h> @@ -180,6 +181,17 @@ tpl_event_set_property (GObject *object, }; } +static inline gboolean +account_equal (TpAccount *account1, TpAccount *account2) +{ + g_return_val_if_fail (TP_IS_PROXY (account1), FALSE); + g_return_val_if_fail (TP_IS_PROXY (account2), FALSE); + + return !tp_strdiff (tp_proxy_get_object_path (TP_PROXY (account1)), + tp_proxy_get_object_path (TP_PROXY (account2))); +} + + static gboolean tpl_event_equal_default (TplEvent *message1, TplEvent *message2) @@ -187,7 +199,10 @@ tpl_event_equal_default (TplEvent *message1, g_return_val_if_fail (TPL_IS_EVENT (message1), FALSE); g_return_val_if_fail (TPL_IS_EVENT (message2), FALSE); - return !tp_strdiff (message1->priv->log_id, message2->priv->log_id); + return message1->priv->timestamp == message2->priv->timestamp + && account_equal (message1->priv->account, message2->priv->account) + && _tpl_entity_compare (message1->priv->sender, message2->priv->sender) + && _tpl_entity_compare (message1->priv->receiver, message2->priv->receiver); } diff --git a/telepathy-logger/text-event.c b/telepathy-logger/text-event.c index 8adffe3..a1a40ad 100644 --- a/telepathy-logger/text-event.c +++ b/telepathy-logger/text-event.c @@ -166,15 +166,31 @@ tpl_text_event_set_property (GObject *object, } } + +static gboolean tpl_text_event_equal (TplEvent *event1, + TplEvent *event2) +{ + TplTextEvent *text_event1 = TPL_TEXT_EVENT (event1); + TplTextEvent *text_event2 = TPL_TEXT_EVENT (event2); + + return TPL_EVENT_CLASS (tpl_text_event_parent_class)->equal (event1, event2) + && text_event1->priv->message_type == text_event2->priv->message_type + && !tp_strdiff (text_event1->priv->message, text_event2->priv->message); +} + + static void tpl_text_event_class_init (TplTextEventClass *klass) { GObjectClass *object_class = G_OBJECT_CLASS (klass); + TplEventClass *event_class = TPL_EVENT_CLASS (klass); GParamSpec *param_spec; object_class->finalize = tpl_text_event_finalize; object_class->get_property = tpl_text_event_get_property; object_class->set_property = tpl_text_event_set_property; + event_class->equal = tpl_text_event_equal; + param_spec = g_param_spec_uint ("message-type", "MessageType", "The message type for a Text log event", |