aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEmilio Pozuelo Monfort <emilio.pozuelo@collabora.co.uk>2011-04-20 16:19:10 +0800
committerEmilio Pozuelo Monfort <emilio.pozuelo@collabora.co.uk>2011-04-20 23:14:22 +0800
commitcd1838c89bc66d192331aef1db8733f954935af5 (patch)
treed347bf46dbc67719df59fdcb635b66b7ab467bc0
parent10dd9c770ceeaa7d9c572c5999b82ba5477f27ee (diff)
downloadgsoc2013-empathy-cd1838c89bc66d192331aef1db8733f954935af5.tar
gsoc2013-empathy-cd1838c89bc66d192331aef1db8733f954935af5.tar.gz
gsoc2013-empathy-cd1838c89bc66d192331aef1db8733f954935af5.tar.bz2
gsoc2013-empathy-cd1838c89bc66d192331aef1db8733f954935af5.tar.lz
gsoc2013-empathy-cd1838c89bc66d192331aef1db8733f954935af5.tar.xz
gsoc2013-empathy-cd1838c89bc66d192331aef1db8733f954935af5.tar.zst
gsoc2013-empathy-cd1838c89bc66d192331aef1db8733f954935af5.zip
Don't ignore call events
-rw-r--r--libempathy/empathy-message.c53
1 files changed, 32 insertions, 21 deletions
diff --git a/libempathy/empathy-message.c b/libempathy/empathy-message.c
index 65ea2ae40..5af02008f 100644
--- a/libempathy/empathy-message.c
+++ b/libempathy/empathy-message.c
@@ -26,6 +26,8 @@
#include <string.h>
+#include <glib/gi18n-lib.h>
+
#include <telepathy-glib/util.h>
#include <telepathy-glib/account.h>
#include <telepathy-glib/account-manager.h>
@@ -33,6 +35,7 @@
#include <telepathy-logger/entity.h>
#include <telepathy-logger/event.h>
#include <telepathy-logger/text-event.h>
+#include <telepathy-logger/call-event.h>
#include "empathy-message.h"
#include "empathy-utils.h"
@@ -287,29 +290,42 @@ empathy_message_from_tpl_log_event (TplEvent *logevent)
tpl_event_get_account_path (logevent));
g_object_unref (acc_man);
- /* TODO Currently only TplTextEvent exists as subclass of TplEvent, in
- * future more TplEvent will exist and EmpathyMessage should probably
- * be enhanced to support other types of log entries (ie TplCallEvent).
- *
- * For now we just check (simply) that we are dealing with the only supported type,
- * then there will be a if/then/else or switch handling all the supported
- * cases.
- */
- if (!TPL_IS_TEXT_EVENT (logevent))
- return NULL;
-
- body = g_strdup (tpl_text_event_get_message (
- TPL_TEXT_EVENT (logevent)));
+ if (TPL_IS_TEXT_EVENT (logevent)) {
+ body = g_strdup (tpl_text_event_get_message (
+ TPL_TEXT_EVENT (logevent)));
+
+ retval = empathy_message_new (body);
+
+ empathy_message_set_tptype (retval,
+ tpl_text_event_get_message_type (TPL_TEXT_EVENT (logevent)));
+ empathy_message_set_is_backlog (retval, TRUE);
+
+ g_free (body);
+ } else if (TPL_IS_CALL_EVENT (logevent)) {
+ TplCallEvent *call = TPL_CALL_EVENT (logevent);
+ if (tpl_call_event_get_end_reason (call) == TPL_CALL_END_REASON_NO_ANSWER)
+ body = g_strdup_printf (_("Missed call from %s"),
+ tpl_entity_get_alias (tpl_event_get_sender (logevent)));
+ else if (tpl_entity_get_entity_type (tpl_event_get_sender (logevent)) == TPL_ENTITY_SELF)
+ body = g_strdup_printf (_("Called %s"),
+ tpl_entity_get_alias (tpl_event_get_receiver (logevent)));
+ else
+ body = g_strdup_printf (_("Call from %s"),
+ tpl_entity_get_alias (tpl_event_get_sender (logevent)));
+
+ retval = empathy_message_new (body);
+ g_free (body);
+ }
+
receiver = tpl_event_get_receiver (logevent);
sender = tpl_event_get_sender (logevent);
- retval = empathy_message_new (body);
if (receiver != NULL) {
contact = empathy_contact_from_tpl_contact (account, receiver);
empathy_message_set_receiver (retval, contact);
g_object_unref (contact);
}
-
+
if (sender != NULL) {
contact = empathy_contact_from_tpl_contact (account, sender);
empathy_message_set_sender (retval, contact);
@@ -317,12 +333,7 @@ empathy_message_from_tpl_log_event (TplEvent *logevent)
}
empathy_message_set_timestamp (retval,
- tpl_event_get_timestamp (logevent));
- empathy_message_set_tptype (retval,
- tpl_text_event_get_message_type (TPL_TEXT_EVENT (logevent)));
- empathy_message_set_is_backlog (retval, TRUE);
-
- g_free (body);
+ tpl_event_get_timestamp (logevent));
return retval;
}