From 67920cae23f4b8020559d7548fd1dff8de44e962 Mon Sep 17 00:00:00 2001 From: Nicolas Dufresne Date: Thu, 24 Feb 2011 10:17:15 +0000 Subject: Port empathy to Telepathy logger 0.2.0 --- libempathy/empathy-contact.c | 9 +++++++-- libempathy/empathy-message.c | 30 ++++++++++++++---------------- libempathy/empathy-message.h | 4 ++-- 3 files changed, 23 insertions(+), 20 deletions(-) (limited to 'libempathy') diff --git a/libempathy/empathy-contact.c b/libempathy/empathy-contact.c index 0547ef82d..73539b406 100644 --- a/libempathy/empathy-contact.c +++ b/libempathy/empathy-contact.c @@ -1161,12 +1161,17 @@ static gboolean contact_has_log (EmpathyContact *contact) { TplLogManager *manager; + TplEntity *entity; gboolean have_log; manager = tpl_log_manager_dup_singleton (); + entity = tpl_entity_new (empathy_contact_get_id (contact), + TPL_ENTITY_CONTACT, NULL, NULL); + have_log = tpl_log_manager_exists (manager, - empathy_contact_get_account (contact), empathy_contact_get_id (contact), - FALSE); + empathy_contact_get_account (contact), entity, TPL_EVENT_MASK_TEXT); + + g_object_unref (entity); g_object_unref (manager); return have_log; diff --git a/libempathy/empathy-message.c b/libempathy/empathy-message.c index ca3b020ac..e194573db 100644 --- a/libempathy/empathy-message.c +++ b/libempathy/empathy-message.c @@ -31,8 +31,8 @@ #include #include -#include -#include +#include +#include #include "empathy-message.h" #include "empathy-utils.h" @@ -259,7 +259,7 @@ empathy_message_new (const gchar *body) } EmpathyMessage * -empathy_message_from_tpl_log_entry (TplEntry *logentry) +empathy_message_from_tpl_log_event (TplEvent *logevent) { EmpathyMessage *retval = NULL; TpAccountManager *acc_man = NULL; @@ -269,7 +269,7 @@ empathy_message_from_tpl_log_entry (TplEntry *logentry) gchar *body= NULL; EmpathyContact *contact; - g_return_val_if_fail (TPL_IS_ENTRY (logentry), NULL); + g_return_val_if_fail (TPL_IS_EVENT (logevent), NULL); acc_man = tp_account_manager_dup (); /* FIXME Currently Empathy shows in the log viewer only valid accounts, so it @@ -284,24 +284,24 @@ empathy_message_from_tpl_log_entry (TplEntry *logentry) * needed anymore any TpAccount passing and the following call will be * useless */ account = tp_account_manager_ensure_account (acc_man, - tpl_entry_get_account_path (logentry)); + tpl_event_get_account_path (logevent)); g_object_unref (acc_man); - /* TODO Currently only TplLogEntryText exists as subclass of TplEntry, in - * future more TplEntry will exist and EmpathyMessage should probably - * be enhanced to support other types of log entries (ie TplLogEntryCall). + /* 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_ENTRY_TEXT (logentry)) + if (!TPL_IS_TEXT_EVENT (logevent)) return NULL; - body = g_strdup (tpl_entry_text_get_message ( - TPL_ENTRY_TEXT (logentry))); - receiver = tpl_entry_get_receiver (logentry); - sender = tpl_entry_get_sender (logentry); + body = g_strdup (tpl_text_event_get_message ( + TPL_TEXT_EVENT (logevent))); + receiver = tpl_event_get_receiver (logevent); + sender = tpl_event_get_sender (logevent); retval = empathy_message_new (body); if (receiver != NULL) { @@ -317,9 +317,7 @@ empathy_message_from_tpl_log_entry (TplEntry *logentry) } empathy_message_set_timestamp (retval, - tpl_entry_get_timestamp (logentry)); - empathy_message_set_id (retval, - tpl_entry_text_get_pending_msg_id (TPL_ENTRY_TEXT (logentry))); + tpl_event_get_timestamp (logevent)); empathy_message_set_is_backlog (retval, TRUE); g_free (body); diff --git a/libempathy/empathy-message.h b/libempathy/empathy-message.h index b7a63f81e..1db0eff60 100644 --- a/libempathy/empathy-message.h +++ b/libempathy/empathy-message.h @@ -26,7 +26,7 @@ #define __EMPATHY_MESSAGE_H__ #include -#include +#include #include "empathy-contact.h" #include "empathy-time.h" @@ -54,7 +54,7 @@ struct _EmpathyMessageClass { GType empathy_message_get_type (void) G_GNUC_CONST; EmpathyMessage * empathy_message_new (const gchar *body); -EmpathyMessage * empathy_message_from_tpl_log_entry (TplEntry *logentry); +EmpathyMessage * empathy_message_from_tpl_log_event (TplEvent *logevent); TpChannelTextMessageType empathy_message_get_tptype (EmpathyMessage *message); void empathy_message_set_tptype (EmpathyMessage *message, TpChannelTextMessageType type); -- cgit v1.2.3