diff options
author | Cosimo Alfarano <cosimo.alfarano@collabora.co.uk> | 2010-02-23 19:32:57 +0000 |
---|---|---|
committer | Cosimo Alfarano <cosimo.alfarano@collabora.co.uk> | 2010-02-25 17:26:57 +0000 |
commit | 8d4d46e440c7a6bd321fc098265db8ede27c07de (patch) | |
tree | bcdffe751459a38bd950d5424d628d831c5243a7 | |
parent | 8e24107b437f63d9b2ca93e0d5b7379ee87af98d (diff) | |
download | empathy-8d4d46e440c7a6bd321fc098265db8ede27c07de.tar.gz |
TPL Enabling patch, all-in-one.
By default TPL is disabled, use --enable-tpl configure option to enable it.
-rw-r--r-- | configure.ac | 28 | ||||
-rw-r--r-- | libempathy-gtk/Makefile.am | 2 | ||||
-rw-r--r-- | libempathy-gtk/empathy-chat.c | 183 | ||||
-rw-r--r-- | libempathy-gtk/empathy-contact-menu.c | 18 | ||||
-rw-r--r-- | libempathy-gtk/empathy-log-window.c | 533 | ||||
-rw-r--r-- | libempathy/Makefile.am | 34 | ||||
-rw-r--r-- | libempathy/empathy-contact.c | 30 | ||||
-rw-r--r-- | libempathy/empathy-contact.h | 7 | ||||
-rw-r--r-- | libempathy/empathy-log-manager.h | 4 | ||||
-rw-r--r-- | libempathy/empathy-log-store-empathy.h | 4 | ||||
-rw-r--r-- | libempathy/empathy-log-store.h | 4 | ||||
-rw-r--r-- | libempathy/empathy-message.c | 78 | ||||
-rw-r--r-- | libempathy/empathy-message.h | 6 | ||||
-rw-r--r-- | src/Makefile.am | 2 | ||||
-rw-r--r-- | src/empathy-chat-window.c | 2 | ||||
-rw-r--r-- | src/empathy.c | 18 |
16 files changed, 909 insertions, 44 deletions
diff --git a/configure.ac b/configure.ac index 57ad3ed7c..5ba9fc487 100644 --- a/configure.ac +++ b/configure.ac @@ -33,6 +33,7 @@ GLIB_REQUIRED=2.22.0 GTK_REQUIRED=2.18.0 GCONF_REQUIRED=1.2.0 TELEPATHY_GLIB_REQUIRED=0.9.2 +TELEPATHY_LOGGER=0.1.0 ENCHANT_REQUIRED=1.2.0 ISO_CODES_REQUIRED=0.35 LIBNOTIFY_REQUIRED=0.4.4 @@ -135,6 +136,30 @@ AS_COMPILER_FLAG(-Wmissing-declarations, ERROR_CFLAGS="$ERROR_CFLAGS -Wmissing-d AC_SUBST(ERROR_CFLAGS) # ----------------------------------------------------------- +# Enable TPL +# ----------------------------------------------------------- + +# It needs to be defined before PKG_CHECK_MODULES calls +AC_ARG_ENABLE(tpl, + AC_HELP_STRING([--enable-tpl],[enable telepathy-logger code and disable the + empathy logger]), enable_tpl=$enableval, enable_tpl=no ) +AM_CONDITIONAL(ENABLE_TPL, test "x$enable_tpl" = "xyes") + +if test x${enable_tpl} = xyes; then + AC_DEFINE(ENABLE_TPL, [], [Enable TPL code]) +fi + +if test "x$enable_tpl" = "xyes"; then + PKG_CHECK_MODULES(TPL, + [ + libtelepathy-logger = $TELEPATHY_LOGGER + ]) + AC_SUBST(TPL_CFLAGS) + AC_SUBST(TPL_LIBS) +fi + + +# ----------------------------------------------------------- # Pkg-Config dependency checks # ----------------------------------------------------------- @@ -528,6 +553,9 @@ Configure summary: Meego widgets ..............: ${have_meego} Control center embedding....: ${have_control_center_embedding} + Logging: + Telepathy Logger............: ${enable_tpl} + Connectivity: NetworkManager integration..: ${have_nm} ConnMan integration.........: ${have_connman} diff --git a/libempathy-gtk/Makefile.am b/libempathy-gtk/Makefile.am index 674579a22..c9736ac43 100644 --- a/libempathy-gtk/Makefile.am +++ b/libempathy-gtk/Makefile.am @@ -7,6 +7,7 @@ AM_CPPFLAGS = \ -DDATADIR=\""$(datadir)"\" \ -DPKGDATADIR=\""$(pkgdatadir)"\" \ $(LIBEMPATHYGTK_CFLAGS) \ + $(TPL_CFLAGS) \ $(LIBNOTIFY_CFLAGS) \ $(ENCHANT_CFLAGS) \ $(LIBCHAMPLAIN_CFLAGS) \ @@ -129,6 +130,7 @@ nodist_libempathy_gtk_la_SOURCES =\ libempathy_gtk_la_LIBADD = \ $(LIBEMPATHYGTK_LIBS) \ $(LIBNOTIFY_LIBS) \ + $(TPL_LIBS) \ $(ENCHANT_LIBS) \ $(LIBCHAMPLAIN_LIBS) \ $(GEOCLUE_LIBS) \ diff --git a/libempathy-gtk/empathy-chat.c b/libempathy-gtk/empathy-chat.c index 1361840fa..2c563c665 100644 --- a/libempathy-gtk/empathy-chat.c +++ b/libempathy-gtk/empathy-chat.c @@ -36,8 +36,12 @@ #include <telepathy-glib/account-manager.h> #include <telepathy-glib/util.h> +#ifdef ENABLE_TPL +#include <telepathy-logger/log-manager.h> +#else #include <libempathy/empathy-log-manager.h> +#endif /* ENABLE_TPL */ #include <libempathy/empathy-contact-list.h> #include <libempathy/empathy-utils.h> #include <libempathy/empathy-dispatcher.h> @@ -72,7 +76,11 @@ typedef struct { EmpathyContact *remote_contact; gboolean show_contacts; +#ifdef ENABLE_TPL + TplLogManager *log_manager; +#else EmpathyLogManager *log_manager; +#endif /* ENABLE_TPL */ TpAccountManager *account_manager; GList *input_history; GList *input_history_current; @@ -100,6 +108,29 @@ typedef struct { /* TRUE if the pending messages can be displayed. This is to avoid to show * pending messages *before* messages from logs. (#603980) */ gboolean can_show_pending; + + /* FIXME: retrieving_backlogs flag is a workaround for Bug#610994 and should + * be differently handled since it introduces another race condition, which + * is really hard to occur, but still possible. + * + * With the current workaround (which has the race above), we need to be + * sure to ACK any pending messages only when the retrieval of backlogs is + * finished, that's why using retrieving_backlogs flag. + * empathy_chat_messages_read () will check this variable and not ACK + * anything when TRUE. It will be set TRUE at chat_constructed () and set + * back to FALSE when the backlog has been retrieved and the pending + * messages actually showed to the user. + * + * Race condition introduced with this workaround: + * Scenario: a message is pending, the user is notified and selects the tab. + * the tab with a pending message is focused before the messages are properly + * shown (since the preparation of the window is slower AND async WRT the + * tab showing), which means the user won't see any new messages (rare but + * possible), if he/she will change tab focus before the messages are + * properly shown, the tab will be set as 'seen' and the user won't be + * notified again about the already notified pending messages when the + * messages in tab will be properly shown */ + gboolean retrieving_backlogs; } EmpathyChatPriv; typedef struct { @@ -1708,31 +1739,128 @@ chat_input_populate_popup_cb (GtkTextView *view, } } + +#ifdef ENABLE_TPL +static gboolean +chat_log_filter (TplLogEntry *log, + gpointer user_data) +#else static gboolean chat_log_filter (EmpathyMessage *message, gpointer user_data) +#endif /* ENABLE_TPL */ { - EmpathyChat *chat = (EmpathyChat *) user_data; + EmpathyChat *chat = user_data; +#ifdef ENABLE_TPL + EmpathyMessage *message; +#endif /* ENABLE_TPL */ EmpathyChatPriv *priv = GET_PRIV (chat); const GList *pending; +#ifdef ENABLE_TPL + g_return_val_if_fail (TPL_IS_LOG_ENTRY (log), FALSE); +#else + g_return_val_if_fail (EMPATHY_IS_MESSAGE (message), FALSE); +#endif /* ENABLE_TPL */ + g_return_val_if_fail (EMPATHY_IS_CHAT (chat), FALSE); + pending = empathy_tp_chat_get_pending_messages (priv->tp_chat); +#ifdef ENABLE_TPL + message = empathy_message_from_tpl_log_entry (log); +#endif /* ENABLE_TPL */ for (; pending; pending = g_list_next (pending)) { if (empathy_message_equal (message, pending->data)) { return FALSE; } } - +#ifdef ENABLE_TPL + g_object_unref (message); +#endif return TRUE; } + +static void +show_pending_messages (EmpathyChat *chat) { + EmpathyChatPriv *priv = GET_PRIV (chat); + const GList *messages, *l; + + g_return_if_fail (EMPATHY_IS_CHAT (chat)); + + if (chat->view == NULL || priv->tp_chat == NULL) + return; + + if (!priv->can_show_pending) + return; + + messages = empathy_tp_chat_get_pending_messages (priv->tp_chat); + + for (l = messages; l != NULL ; l = g_list_next (l)) { + EmpathyMessage *message = EMPATHY_MESSAGE (l->data); + chat_message_received (chat, message); + } +} + + +#ifdef ENABLE_TPL +static void +got_filtered_messages_cb (GObject *manager, + GAsyncResult *result, + gpointer user_data) +{ + GList *l; + GList *messages; + EmpathyChat *chat = EMPATHY_CHAT (user_data); + EmpathyChatPriv *priv = GET_PRIV (chat); + GError *error = NULL; + + messages = tpl_log_manager_async_operation_finish (result, &error); + + if (error != NULL) { + DEBUG ("%s. Aborting.", error->message); + empathy_chat_view_append_event (chat->view, + _("Failed to retrieve recent logs")); + g_error_free (error); + goto out; + } + + for (l = messages; l; l = g_list_next (l)) { + EmpathyMessage *message; + g_assert (TPL_IS_LOG_ENTRY (l->data)); + + message = empathy_message_from_tpl_log_entry (l->data); + g_object_unref (l->data); + + empathy_chat_view_append_message (chat->view, message); + g_object_unref (message); + } + g_list_free (messages); + +out: + priv->retrieving_backlogs = FALSE; + /* in case of TPL error, skip backlog and show pending messages */ + priv->can_show_pending = TRUE; + show_pending_messages (chat); + + /* FIXME: See Bug#610994, we are forcing the ACK of the queue. See comments + * about it in EmpathyChatPriv definition */ + empathy_chat_messages_read (chat); + + /* Turn back on scrolling */ + empathy_chat_view_scroll (chat->view, TRUE); +} +#endif /* ENABLE_TPL */ + + static void chat_add_logs (EmpathyChat *chat) { EmpathyChatPriv *priv = GET_PRIV (chat); gboolean is_chatroom; +#ifndef ENABLE_TPL GList *messages, *l; +#endif /* ENABLE_TPL */ if (!priv->id) { return; @@ -1744,6 +1872,7 @@ chat_add_logs (EmpathyChat *chat) /* Add messages from last conversation */ is_chatroom = priv->handle_type == TP_HANDLE_TYPE_ROOM; +#ifndef ENABLE_TPL messages = empathy_log_manager_get_filtered_messages (priv->log_manager, priv->account, priv->id, @@ -1761,6 +1890,18 @@ chat_add_logs (EmpathyChat *chat) /* Turn back on scrolling */ empathy_chat_view_scroll (chat->view, TRUE); +#else + priv->retrieving_backlogs = TRUE; + tpl_log_manager_get_filtered_messages_async (priv->log_manager, + priv->account, + priv->id, + is_chatroom, + 5, + chat_log_filter, + chat, + got_filtered_messages_cb, + (gpointer) chat); +#endif /* ENABLE_TPL */ } static gint @@ -2046,26 +2187,6 @@ chat_hpaned_pos_changed_cb (GtkWidget* hpaned, gpointer user_data) return TRUE; } - -static void -show_pending_messages (EmpathyChat *chat) { - EmpathyChatPriv *priv = GET_PRIV (chat); - const GList *messages, *l; - - if (chat->view == NULL || priv->tp_chat == NULL) - return; - - if (!priv->can_show_pending) - return; - - messages = empathy_tp_chat_get_pending_messages (priv->tp_chat); - - for (l = messages; l != NULL ; l = g_list_next (l)) { - EmpathyMessage *message = EMPATHY_MESSAGE (l->data); - chat_message_received (chat, message); - } -} - static void chat_create_ui (EmpathyChat *chat) { @@ -2293,8 +2414,12 @@ chat_constructed (GObject *object) if (priv->handle_type != TP_HANDLE_TYPE_ROOM) chat_add_logs (chat); +#ifndef ENABLE_TPL + /* When async API are involved, pending message are shown at the end of the + * callbacks' chain fired by chat_add_logs */ priv->can_show_pending = TRUE; show_pending_messages (chat); +#endif /* ENABLE_TPL */ } static void @@ -2437,7 +2562,11 @@ empathy_chat_init (EmpathyChat *chat) EMPATHY_TYPE_CHAT, EmpathyChatPriv); chat->priv = priv; +#ifndef ENABLE_TPL priv->log_manager = empathy_log_manager_dup_singleton (); +#else + priv->log_manager = tpl_log_manager_dup_singleton (); +#endif /* ENABLE_TPL */ priv->contacts_width = -1; priv->input_history = NULL; priv->input_history_current = NULL; @@ -2945,9 +3074,13 @@ empathy_chat_messages_read (EmpathyChat *self) g_return_if_fail (EMPATHY_IS_CHAT (self)); - if (priv->tp_chat != NULL) { - empathy_tp_chat_acknowledge_all_messages (priv->tp_chat); + /* FIXME: See Bug#610994, See comments about it in EmpathyChatPriv + * definition. If we are still retrieving the backlogs, do not ACK */ + if (priv->retrieving_backlogs) + return; + + if (priv->tp_chat != NULL ) { + empathy_tp_chat_acknowledge_all_messages (priv->tp_chat); } - priv->unread_messages = 0; } diff --git a/libempathy-gtk/empathy-contact-menu.c b/libempathy-gtk/empathy-contact-menu.c index 3d194fced..54bb4b286 100644 --- a/libempathy-gtk/empathy-contact-menu.c +++ b/libempathy-gtk/empathy-contact-menu.c @@ -25,9 +25,13 @@ #include <glib/gi18n-lib.h> #include <gtk/gtk.h> +#ifdef ENABLE_TPL +#include <telepathy-logger/log-manager.h> +#else -#include <libempathy/empathy-call-factory.h> #include <libempathy/empathy-log-manager.h> +#endif /* ENABLE_TPL */ +#include <libempathy/empathy-call-factory.h> #include <libempathy/empathy-contact-manager.h> #include <libempathy/empathy-dispatcher.h> #include <libempathy/empathy-utils.h> @@ -307,18 +311,30 @@ contact_log_menu_item_activate_cb (EmpathyContact *contact) GtkWidget * empathy_contact_log_menu_item_new (EmpathyContact *contact) { +#ifndef ENABLE_TPL EmpathyLogManager *manager; +#else + TplLogManager *manager; +#endif /* ENABLE_TPL */ gboolean have_log; GtkWidget *item; GtkWidget *image; g_return_val_if_fail (EMPATHY_IS_CONTACT (contact), NULL); +#ifndef ENABLE_TPL manager = empathy_log_manager_dup_singleton (); have_log = empathy_log_manager_exists (manager, empathy_contact_get_account (contact), empathy_contact_get_id (contact), FALSE); +#else + manager = tpl_log_manager_dup_singleton (); + have_log = tpl_log_manager_exists (manager, + empathy_contact_get_account (contact), + empathy_contact_get_id (contact), + FALSE); +#endif /* ENABLE_TPL */ g_object_unref (manager); item = gtk_image_menu_item_new_with_mnemonic (_("_Previous Conversations")); diff --git a/libempathy-gtk/empathy-log-window.c b/libempathy-gtk/empathy-log-window.c index f12abf374..7044d2e91 100644 --- a/libempathy-gtk/empathy-log-window.c +++ b/libempathy-gtk/empathy-log-window.c @@ -31,8 +31,13 @@ #include <gtk/gtk.h> #include <telepathy-glib/account-manager.h> +#ifdef ENABLE_TPL +#include <telepathy-logger/log-manager.h> +#endif /* ENABLE_TPL */ +#ifndef ENABLE_TPL #include <libempathy/empathy-log-manager.h> +#endif /* ENABLE_TPL */ #include <libempathy/empathy-chatroom-manager.h> #include <libempathy/empathy-chatroom.h> #include <libempathy/empathy-message.h> @@ -71,7 +76,11 @@ typedef struct { gchar *last_find; +#ifndef ENABLE_TPL EmpathyLogManager *log_manager; +#else + TplLogManager *log_manager; +#endif /* ENABLE_TPL */ /* Those are only used while waiting for the account chooser to be ready */ TpAccount *selected_account; @@ -204,7 +213,11 @@ empathy_log_window_show (TpAccount *account, } window = g_new0 (EmpathyLogWindow, 1); +#ifndef ENABLE_TPL window->log_manager = empathy_log_manager_dup_singleton (); +#else + window->log_manager = tpl_log_manager_dup_singleton (); +#endif /* ENABLE_TPL */ filename = empathy_file_lookup ("empathy-log-window.ui", "libempathy-gtk"); @@ -339,6 +352,64 @@ log_window_entry_find_changed_cb (GtkWidget *entry, gtk_widget_set_sensitive (window->button_find, is_sensitive); } +#ifdef ENABLE_TPL +static void +got_messages_for_date_cb (GObject *manager, + GAsyncResult *result, + gpointer user_data) +{ + EmpathyLogWindow *window = user_data; + GList *messages; + GList *l; + gboolean can_do_previous; + gboolean can_do_next; + GError *error = NULL; + + messages = tpl_log_manager_async_operation_finish (result, &error); + + if (error != NULL) { + DEBUG ("Unable to retrieve messages for the selected date: %s. Aborting", + error->message); + empathy_chat_view_append_event (window->chatview_find, + "Unable to retrieve messages for the selected date"); + g_error_free (error); + return; + } + + for (l = messages; l; l = l->next) { + EmpathyMessage *message; + + g_assert (TPL_IS_LOG_ENTRY (l->data)); + + message = empathy_message_from_tpl_log_entry (l->data); + g_object_unref (l->data); + empathy_chat_view_append_message (window->chatview_find, message); + g_object_unref (message); + } + g_list_free (messages); + + /* Scroll to the most recent messages */ + empathy_chat_view_scroll (window->chatview_find, TRUE); + + /* Highlight and find messages */ + empathy_chat_view_highlight (window->chatview_find, + window->last_find, + FALSE); + empathy_chat_view_find_next (window->chatview_find, + window->last_find, + TRUE, + FALSE); + empathy_chat_view_find_abilities (window->chatview_find, + window->last_find, + FALSE, + &can_do_previous, + &can_do_next); + gtk_widget_set_sensitive (window->button_previous, can_do_previous); + gtk_widget_set_sensitive (window->button_next, can_do_next); + gtk_widget_set_sensitive (window->button_find, FALSE); +} +#endif /* ENABLE_TPL */ + static void log_window_find_changed_cb (GtkTreeSelection *selection, EmpathyLogWindow *window) @@ -350,11 +421,13 @@ log_window_find_changed_cb (GtkTreeSelection *selection, gchar *chat_id; gboolean is_chatroom; gchar *date; +#ifndef ENABLE_TPL EmpathyMessage *message; GList *messages; GList *l; gboolean can_do_previous; gboolean can_do_next; +#endif /* ENABLE_TPL */ /* Get selected information */ view = GTK_TREE_VIEW (window->treeview_find); @@ -386,15 +459,26 @@ log_window_find_changed_cb (GtkTreeSelection *selection, empathy_chat_view_scroll (window->chatview_find, FALSE); /* Get messages */ +#ifndef ENABLE_TPL messages = empathy_log_manager_get_messages_for_date (window->log_manager, account, chat_id, is_chatroom, date); +#else + tpl_log_manager_get_messages_for_date_async (window->log_manager, + account, + chat_id, + is_chatroom, + date, + got_messages_for_date_cb, + window); +#endif /* ENABLE_TPL */ g_object_unref (account); g_free (date); g_free (chat_id); +#ifndef ENABLE_TPL for (l = messages; l; l = l->next) { message = l->data; empathy_chat_view_append_message (window->chatview_find, message); @@ -420,19 +504,89 @@ log_window_find_changed_cb (GtkTreeSelection *selection, gtk_widget_set_sensitive (window->button_previous, can_do_previous); gtk_widget_set_sensitive (window->button_next, can_do_next); gtk_widget_set_sensitive (window->button_find, FALSE); +#endif /* ENABLE_TPL */ +} + + +#ifdef ENABLE_TPL +static void +log_manager_searched_new_cb (GObject *manager, + GAsyncResult *result, + gpointer user_data) +{ + GList *hits; + GList *l; + GtkTreeIter iter; + GtkListStore *store = user_data; + GError *error = NULL; + + hits = tpl_log_manager_async_operation_finish (result, &error); + + if (error != NULL) { + DEBUG ("%s. Aborting", error->message); + g_error_free (error); + return; + } + + for (l = hits; l; l = l->next) { + TplLogSearchHit *hit; + const gchar *account_name; + const gchar *account_icon; + gchar *date_readable; + + hit = l->data; + + /* Protect against invalid data (corrupt or old log files. */ + if (!hit->account || !hit->chat_id) { + continue; + } + + date_readable = tpl_log_manager_get_date_readable (hit->date); + account_name = tp_account_get_display_name (hit->account); + account_icon = tp_account_get_icon_name (hit->account); + + gtk_list_store_append (store, &iter); + gtk_list_store_set (store, &iter, + COL_FIND_ACCOUNT_ICON, account_icon, + COL_FIND_ACCOUNT_NAME, account_name, + COL_FIND_ACCOUNT, hit->account, + COL_FIND_CHAT_NAME, hit->chat_id, /* FIXME */ + COL_FIND_CHAT_ID, hit->chat_id, + COL_FIND_IS_CHATROOM, hit->is_chatroom, + COL_FIND_DATE, hit->date, + COL_FIND_DATE_READABLE, date_readable, + -1); + + g_free (date_readable); + + /* FIXME: Update COL_FIND_CHAT_NAME */ + if (hit->is_chatroom) { + } else { + } + } + + if (hits) { + tpl_log_manager_search_free (hits); + } } +#endif /* ENABLE_TPL */ + static void log_window_find_populate (EmpathyLogWindow *window, const gchar *search_criteria) { +#ifndef ENABLE_TPL GList *hits, *l; +#endif /* ENABLE_TPL */ GtkTreeView *view; GtkTreeModel *model; GtkTreeSelection *selection; GtkListStore *store; +#ifndef ENABLE_TPL GtkTreeIter iter; +#endif /* ENABLE_TPL */ view = GTK_TREE_VIEW (window->treeview_find); model = gtk_tree_view_get_model (view); @@ -448,6 +602,10 @@ log_window_find_populate (EmpathyLogWindow *window, return; } +#ifdef ENABLE_TPL + tpl_log_manager_search_new_async (window->log_manager, search_criteria, + log_manager_searched_new_cb, (gpointer) store); +#else hits = empathy_log_manager_search_new (window->log_manager, search_criteria); for (l = hits; l; l = l->next) { @@ -490,6 +648,7 @@ log_window_find_populate (EmpathyLogWindow *window, if (hits) { empathy_log_manager_search_free (hits); } +#endif /* ENABLE_TPL */ } static void @@ -655,18 +814,87 @@ log_window_chats_changed_cb (GtkTreeSelection *selection, log_window_chats_get_messages (window, NULL); } +#ifdef ENABLE_TPL +static void +log_manager_got_chats_cb (GObject *manager, + GAsyncResult *result, + gpointer user_data) +{ + EmpathyLogWindow *window = user_data; + GList *chats; + GList *l; + EmpathyAccountChooser *account_chooser; + TpAccount *account; + GtkTreeView *view; + GtkTreeModel *model; + GtkTreeSelection *selection; + GtkListStore *store; + GtkTreeIter iter; + GError *error = NULL; + + chats = tpl_log_manager_async_operation_finish (result, &error); + + if (error != NULL) { + DEBUG ("%s. Aborting", error->message); + g_error_free (error); + return; + } + + account_chooser = EMPATHY_ACCOUNT_CHOOSER (window->account_chooser_chats); + account = empathy_account_chooser_dup_account (account_chooser); + + view = GTK_TREE_VIEW (window->treeview_chats); + model = gtk_tree_view_get_model (view); + selection = gtk_tree_view_get_selection (view); + store = GTK_LIST_STORE (model); + + for (l = chats; l; l = l->next) { + TplLogSearchHit *hit; + + hit = l->data; + + gtk_list_store_append (store, &iter); + gtk_list_store_set (store, &iter, + COL_CHAT_ICON, "empathy-available", /* FIXME */ + COL_CHAT_NAME, hit->chat_id, + COL_CHAT_ACCOUNT, account, + COL_CHAT_ID, hit->chat_id, + COL_CHAT_IS_CHATROOM, hit->is_chatroom, + -1); + + /* FIXME: Update COL_CHAT_ICON/NAME */ + if (hit->is_chatroom) { + } else { + } + } + tpl_log_manager_search_free (chats); + + /* Unblock signals */ + g_signal_handlers_unblock_by_func (selection, + log_window_chats_changed_cb, + window); + + g_object_unref (account); +} +#endif /* ENABLE_TPL */ + + static void log_window_chats_populate (EmpathyLogWindow *window) { EmpathyAccountChooser *account_chooser; TpAccount *account; +#ifndef ENABLE_TPL GList *chats, *l; +#endif /* ENABLE_TPL */ GtkTreeView *view; GtkTreeModel *model; GtkTreeSelection *selection; GtkListStore *store; +#ifndef ENABLE_TPL GtkTreeIter iter; +#endif /* ENABLE_TPL */ account_chooser = EMPATHY_ACCOUNT_CHOOSER (window->account_chooser_chats); account = empathy_account_chooser_dup_account (account_chooser); @@ -688,6 +916,10 @@ log_window_chats_populate (EmpathyLogWindow *window) gtk_list_store_clear (store); +#ifdef ENABLE_TPL + tpl_log_manager_get_chats_async (window->log_manager, account, + log_manager_got_chats_cb, (gpointer) window); +#else chats = empathy_log_manager_get_chats (window->log_manager, account); for (l = chats; l; l = l->next) { EmpathyLogSearchHit *hit; @@ -717,6 +949,7 @@ log_window_chats_populate (EmpathyLogWindow *window) g_object_unref (account); +#endif /* ENABLE_TPL */ } static void @@ -886,6 +1119,219 @@ log_window_chats_get_selected (EmpathyLogWindow *window, return TRUE; } +#ifdef ENABLE_TPL +static void +log_window_got_messages_for_date_cb (GObject *manager, + GAsyncResult *result, + gpointer user_data) +{ + EmpathyLogWindow *window = user_data; + GList *messages; + GList *l; + GError *error = NULL; + + messages = tpl_log_manager_async_operation_finish (result, &error); + + if (error != NULL) { + DEBUG ("Unable to retrieve messages for the selected date: %s. Aborting", + error->message); + empathy_chat_view_append_event (window->chatview_find, + "Unable to retrieve messages for the selected date"); + g_error_free (error); + return; + } + + for (l = messages; l; l = l->next) { + EmpathyMessage *message = empathy_message_from_tpl_log_entry (l->data); + g_object_unref (l->data); + empathy_chat_view_append_message (window->chatview_chats, + message); + g_object_unref (message); + } + g_list_free (messages); + + /* Turn back on scrolling */ + empathy_chat_view_scroll (window->chatview_find, TRUE); + + /* Give the search entry main focus */ + gtk_widget_grab_focus (window->entry_chats); +} + + +static void +log_window_get_messages_for_date (EmpathyLogWindow *window, + const gchar *date) +{ + TpAccount *account; + gchar *chat_id; + gboolean is_chatroom; + + gtk_calendar_clear_marks (GTK_CALENDAR (window->calendar_chats)); + + if (!log_window_chats_get_selected (window, &account, + &chat_id, &is_chatroom)) { + return; + } + + /* Clear all current messages shown in the textview */ + empathy_chat_view_clear (window->chatview_chats); + + /* Turn off scrolling temporarily */ + empathy_chat_view_scroll (window->chatview_find, FALSE); + + /* Get messages */ + tpl_log_manager_get_messages_for_date_async (window->log_manager, + account, chat_id, + is_chatroom, + date, + log_window_got_messages_for_date_cb, + (gpointer) window); +} + +static void +log_manager_got_dates_cb (GObject *manager, + GAsyncResult *result, + gpointer user_data) +{ + EmpathyLogWindow *window = user_data; + GList *dates; + GList *l; + guint year_selected; + guint year; + guint month; + guint month_selected; + guint day; + gboolean day_selected = FALSE; + const gchar *date = NULL; + GError *error = NULL; + + dates = tpl_log_manager_async_operation_finish (result, &error); + + if (error != NULL) { + DEBUG ("Unable to retrieve messages' dates: %s. Aborting", + error->message); + empathy_chat_view_append_event (window->chatview_find, + "Unable to retrieve messages' dates"); + return; + } + + for (l = dates; l; l = l->next) { + const gchar *str; + + str = l->data; + if (!str) { + continue; + } + + sscanf (str, "%4d%2d%2d", &year, &month, &day); + gtk_calendar_get_date (GTK_CALENDAR (window->calendar_chats), + &year_selected, + &month_selected, + NULL); + + month_selected++; + + if (!l->next) { + date = str; + } + + if (year != year_selected || month != month_selected) { + continue; + } + + DEBUG ("Marking date:'%s'", str); + gtk_calendar_mark_day (GTK_CALENDAR (window->calendar_chats), day); + + if (l->next) { + continue; + } + + day_selected = TRUE; + + gtk_calendar_select_day (GTK_CALENDAR (window->calendar_chats), day); + } + + if (!day_selected) { + /* Unselect the day in the calendar */ + gtk_calendar_select_day (GTK_CALENDAR (window->calendar_chats), 0); + } + + g_signal_handlers_unblock_by_func (window->calendar_chats, + log_window_calendar_chats_day_selected_cb, + window); + + if (date) { + log_window_get_messages_for_date (window, date); + } + + g_list_foreach (dates, (GFunc) g_free, NULL); + g_list_free (dates); +} + + +static void +log_window_chats_get_messages (EmpathyLogWindow *window, + const gchar *date_to_show) +{ + TpAccount *account; + gchar *chat_id; + gboolean is_chatroom; + const gchar *date; + guint year_selected; + guint year; + guint month; + guint month_selected; + guint day; + + + if (!log_window_chats_get_selected (window, &account, + &chat_id, &is_chatroom)) { + return; + } + + g_signal_handlers_block_by_func (window->calendar_chats, + log_window_calendar_chats_day_selected_cb, + window); + + /* Either use the supplied date or get the last */ + date = date_to_show; + if (!date) { + /* Get a list of dates and show them on the calendar */ + tpl_log_manager_get_dates_async (window->log_manager, + account, chat_id, + is_chatroom, + log_manager_got_dates_cb, (gpointer) window); + /* signal unblocked at the end of the CB flow */ + } else { + sscanf (date, "%4d%2d%2d", &year, &month, &day); + gtk_calendar_get_date (GTK_CALENDAR (window->calendar_chats), + &year_selected, + &month_selected, + NULL); + + month_selected++; + + if (year != year_selected && month != month_selected) { + day = 0; + } + + gtk_calendar_select_day (GTK_CALENDAR (window->calendar_chats), day); + + g_signal_handlers_unblock_by_func (window->calendar_chats, + log_window_calendar_chats_day_selected_cb, + window); + } + + if (date) { + log_window_get_messages_for_date (window, date); + } + + g_object_unref (account); + g_free (chat_id); +} + +#else + static void log_window_chats_get_messages (EmpathyLogWindow *window, const gchar *date_to_show) @@ -1022,6 +1468,8 @@ OUT: g_free (chat_id); } +#endif /* ENABLE_TPL */ + static void log_window_calendar_chats_day_selected_cb (GtkWidget *calendar, EmpathyLogWindow *window) @@ -1046,6 +1494,67 @@ log_window_calendar_chats_day_selected_cb (GtkWidget *calendar, g_free (date); } + +#ifdef ENABLE_TPL +static void +log_window_updating_calendar_month_cb (GObject *manager, + GAsyncResult *result, gpointer user_data) +{ + EmpathyLogWindow *window = user_data; + GList *dates; + GList *l; + guint year_selected; + guint month_selected; + GError *error = NULL; + + dates = tpl_log_manager_async_operation_finish (result, &error); + + if (error != NULL) { + DEBUG ("Unable to retrieve messages' dates: %s. Aborting", + error->message); + empathy_chat_view_append_event (window->chatview_find, + "Unable to retrieve messages' dates"); + g_error_free (error); + return; + } + + gtk_calendar_clear_marks (GTK_CALENDAR (window->calendar_chats)); + g_object_get (window->calendar_chats, + "month", &month_selected, + "year", &year_selected, + NULL); + + /* We need this here because it appears that the months start from 0 */ + month_selected++; + + for (l = dates; l; l = l->next) { + const gchar *str; + guint year; + guint month; + guint day; + + str = l->data; + if (!str) { + continue; + } + + sscanf (str, "%4d%2d%2d", &year, &month, &day); + + if (year == year_selected && month == month_selected) { + DEBUG ("Marking date:'%s'", str); + gtk_calendar_mark_day (GTK_CALENDAR (window->calendar_chats), day); + } + } + + g_list_foreach (dates, (GFunc) g_free, NULL); + g_list_free (dates); + + DEBUG ("Currently showing month %d and year %d", month_selected, + year_selected); +} +#endif /* ENABLE_TPL */ + + static void log_window_calendar_chats_month_changed_cb (GtkWidget *calendar, EmpathyLogWindow *window) @@ -1053,11 +1562,13 @@ log_window_calendar_chats_month_changed_cb (GtkWidget *calendar, TpAccount *account; gchar *chat_id; gboolean is_chatroom; +#ifndef ENABLE_TPL guint year_selected; guint month_selected; GList *dates; GList *l; +#endif /* ENABLE_TPL */ gtk_calendar_clear_marks (GTK_CALENDAR (calendar)); @@ -1067,20 +1578,24 @@ log_window_calendar_chats_month_changed_cb (GtkWidget *calendar, return; } + /* Get the log object for this contact */ +#ifdef ENABLE_TPL + tpl_log_manager_get_dates_async (window->log_manager, account, + chat_id, is_chatroom, + log_window_updating_calendar_month_cb, + (gpointer) window); +#else + dates = empathy_log_manager_get_dates (window->log_manager, account, + chat_id, is_chatroom); + g_object_get (calendar, "month", &month_selected, "year", &year_selected, NULL); - /* We need this hear because it appears that the months start from 0 */ + /* We need this here because it appears that the months start from 0 */ month_selected++; - /* Get the log object for this contact */ - dates = empathy_log_manager_get_dates (window->log_manager, account, - chat_id, is_chatroom); - g_object_unref (account); - g_free (chat_id); - for (l = dates; l; l = l->next) { const gchar *str; guint year; @@ -1105,6 +1620,10 @@ log_window_calendar_chats_month_changed_cb (GtkWidget *calendar, DEBUG ("Currently showing month %d and year %d", month_selected, year_selected); +#endif /* ENABLE_TPL */ + + g_object_unref (account); + g_free (chat_id); } static void diff --git a/libempathy/Makefile.am b/libempathy/Makefile.am index f6f0c0a23..1f1423952 100644 --- a/libempathy/Makefile.am +++ b/libempathy/Makefile.am @@ -8,6 +8,7 @@ AM_CPPFLAGS = \ -DDATADIR=\""$(datadir)"\" \ -DLOCALEDIR=\""$(datadir)/locale"\" \ -DG_LOG_DOMAIN=\"empathy\" \ + $(TPL_CFLAGS) \ $(LIBEMPATHY_CFLAGS) \ $(GEOCLUE_CFLAGS) \ $(NETWORK_MANAGER_CFLAGS) \ @@ -48,9 +49,6 @@ libempathy_headers = \ empathy-irc-network.h \ empathy-irc-server.h \ empathy-location.h \ - empathy-log-manager.h \ - empathy-log-store-empathy.h \ - empathy-log-store.h \ empathy-message.h \ empathy-status-presets.h \ empathy-time.h \ @@ -63,6 +61,14 @@ libempathy_headers = \ empathy-types.h \ empathy-utils.h +if !ENABLE_TPL +libempathy_headers += \ + empathy-log-manager.h \ + empathy-log-store-empathy.h \ + empathy-log-store.h \ + $(NULL) +endif + libempathy_la_SOURCES = \ $(libempathy_headers) \ empathy-account-settings.c \ @@ -87,9 +93,6 @@ libempathy_la_SOURCES = \ empathy-irc-network-manager.c \ empathy-irc-network.c \ empathy-irc-server.c \ - empathy-log-manager.c \ - empathy-log-store-empathy.c \ - empathy-log-store.c \ empathy-message.c \ empathy-status-presets.c \ empathy-time.c \ @@ -101,6 +104,14 @@ libempathy_la_SOURCES = \ empathy-tp-roomlist.c \ empathy-utils.c +if !ENABLE_TPL +libempathy_la_SOURCES += \ + empathy-log-manager.c \ + empathy-log-store-empathy.c \ + empathy-log-store.c \ + $(NULL) +endif + # do not distribute generated files nodist_libempathy_la_SOURCES =\ $(BUILT_SOURCES) @@ -109,6 +120,7 @@ libempathy_la_LIBADD = \ $(top_builddir)/extensions/libemp-extensions.la \ $(LIBEMPATHY_LIBS) \ $(GEOCLUE_LIBS) \ + $(TPL_LIBS) \ $(NETWORK_MANAGER_LIBS) \ $(CONNMAN_LIBS) @@ -181,9 +193,10 @@ dtd_DATA = \ empathy-chatroom-manager.dtd \ empathy-irc-networks.dtd +if !ENABLE_TPL stylesheetdir = $(datadir)/empathy -stylesheet_DATA = \ - empathy-log-manager.xsl +stylesheet_DATA = empathy-log-manager.xsl +endif ircnetworksdir = $(datadir)/empathy ircnetworks_DATA = \ @@ -191,10 +204,13 @@ ircnetworks_DATA = \ EXTRA_DIST = \ empathy-marshal.list \ - $(stylesheet_DATA) \ $(dtd_DATA) \ $(ircnetworks_DATA) +if !ENABLE_TPL +EXTRA_DIST += $(stylesheet_DATA) +endif + CLEANFILES = \ $(BUILT_SOURCES) \ stamp-empathy-enum-types.h diff --git a/libempathy/empathy-contact.c b/libempathy/empathy-contact.c index a440ef23b..feba1c0b7 100644 --- a/libempathy/empathy-contact.c +++ b/libempathy/empathy-contact.c @@ -27,6 +27,9 @@ #include <telepathy-glib/account-manager.h> #include <telepathy-glib/util.h> +#ifdef ENABEL_TPL +#include <telepathy-logger/contact.h> +#endif /* ENABLE_TPL */ #include "empathy-contact.h" #include "empathy-utils.h" @@ -408,6 +411,33 @@ empathy_contact_new (TpContact *tp_contact) NULL); } +#ifdef ENABLE_TPL +EmpathyContact * +empathy_contact_from_tpl_contact (TpAccount *account, + TplContact *tpl_contact) +{ + EmpathyContact *retval; + gboolean is_user; + + g_return_val_if_fail (TPL_IS_CONTACT (tpl_contact), NULL); + + is_user = (TPL_CONTACT_USER == tpl_contact_get_contact_type (tpl_contact)); + + retval = g_object_new (EMPATHY_TYPE_CONTACT, + "id", tpl_contact_get_alias (tpl_contact), + "name", tpl_contact_get_identifier (tpl_contact), + "account", account, + "is-user", is_user, + NULL); + + if (!EMP_STR_EMPTY (tpl_contact_get_avatar_token (tpl_contact))) + empathy_contact_load_avatar_cache (retval, + tpl_contact_get_avatar_token (tpl_contact)); + + return retval; +} +#endif /* ENABLE_TPL */ + EmpathyContact * empathy_contact_new_for_log (TpAccount *account, const gchar *id, diff --git a/libempathy/empathy-contact.h b/libempathy/empathy-contact.h index 2dd6bc0fb..231f95b9d 100644 --- a/libempathy/empathy-contact.h +++ b/libempathy/empathy-contact.h @@ -26,6 +26,9 @@ #include <telepathy-glib/contact.h> #include <telepathy-glib/account.h> +#ifdef ENABLE_TPL +#include <telepathy-logger/contact.h> +#endif /* ENABLE_TPL */ G_BEGIN_DECLS @@ -70,6 +73,10 @@ typedef enum { GType empathy_contact_get_type (void) G_GNUC_CONST; EmpathyContact * empathy_contact_new (TpContact *tp_contact); +#ifdef ENABLE_TPL +EmpathyContact * empathy_contact_from_tpl_contact (TpAccount *account, + TplContact *tpl_contact); +#endif /* ENABLE_TPL */ EmpathyContact * empathy_contact_new_for_log (TpAccount *account, const gchar *id, const gchar *name, gboolean is_user); TpContact * empathy_contact_get_tp_contact (EmpathyContact *contact); diff --git a/libempathy/empathy-log-manager.h b/libempathy/empathy-log-manager.h index 25f1b5fcd..4e4097dc7 100644 --- a/libempathy/empathy-log-manager.h +++ b/libempathy/empathy-log-manager.h @@ -24,6 +24,9 @@ #ifndef __EMPATHY_LOG_MANAGER_H__ #define __EMPATHY_LOG_MANAGER_H__ +#include <config.h> +#ifndef ENABLE_TPL + #include <glib-object.h> #include "empathy-message.h" @@ -100,4 +103,5 @@ void empathy_log_manager_observe (EmpathyLogManager *log_manager, G_END_DECLS +#endif /* ENABLE_TPL */ #endif /* __EMPATHY_LOG_MANAGER_H__ */ diff --git a/libempathy/empathy-log-store-empathy.h b/libempathy/empathy-log-store-empathy.h index e77076a5b..3b26d2ccf 100644 --- a/libempathy/empathy-log-store-empathy.h +++ b/libempathy/empathy-log-store-empathy.h @@ -25,6 +25,9 @@ #ifndef __EMPATHY_LOG_STORE_EMPATHY_H__ #define __EMPATHY_LOG_STORE_EMPATHY_H__ +#include <config.h> +#ifndef ENABLE_TPL + #include <glib.h> G_BEGIN_DECLS @@ -63,4 +66,5 @@ GType empathy_log_store_empathy_get_type (void); G_END_DECLS +#endif /* ENABLE_TPL */ #endif /* __EMPATHY_LOG_STORE_EMPATHY_H__ */ diff --git a/libempathy/empathy-log-store.h b/libempathy/empathy-log-store.h index 94bc87386..185e38c93 100644 --- a/libempathy/empathy-log-store.h +++ b/libempathy/empathy-log-store.h @@ -23,6 +23,9 @@ #ifndef __EMPATHY_LOG_STORE_H__ #define __EMPATHY_LOG_STORE_H__ +#include <config.h> +#ifndef ENABLE_TPL + #include <glib-object.h> #include <telepathy-glib/account.h> @@ -98,4 +101,5 @@ GList *empathy_log_store_get_filtered_messages (EmpathyLogStore *self, G_END_DECLS +#endif /* ENABLE_TPL */ #endif /* __EMPATHY_LOG_STORE_H__ */ diff --git a/libempathy/empathy-message.c b/libempathy/empathy-message.c index 0fe457886..a46d7d9a7 100644 --- a/libempathy/empathy-message.c +++ b/libempathy/empathy-message.c @@ -27,6 +27,14 @@ #include <string.h> #include <telepathy-glib/util.h> +#ifdef ENABLE_TPL +#include <telepathy-glib/account.h> +#include <telepathy-glib/account-manager.h> + +#include <telepathy-logger/contact.h> +#include <telepathy-logger/log-entry.h> +#include <telepathy-logger/log-entry-text.h> +#endif /* ENABLE_TPL */ #include "empathy-message.h" #include "empathy-utils.h" @@ -252,6 +260,71 @@ empathy_message_new (const gchar *body) NULL); } +#ifdef ENABLE_TPL +EmpathyMessage * +empathy_message_from_tpl_log_entry (TplLogEntry *logentry) +{ + EmpathyMessage *retval = NULL; + TpAccountManager *acc_man = NULL; + TpAccount *account = NULL; + TplContact *receiver = NULL; + TplContact *sender = NULL; + gchar *body= NULL; + + g_return_val_if_fail (TPL_IS_LOG_ENTRY (logentry), NULL); + + acc_man = tp_account_manager_dup (); + /* FIXME Currently Empathy shows in the log viewer only valid accounts, so it + * won't be selected any non-existing (ie removed) account. + * When #610455 will be fixed, calling tp_account_manager_ensure_account () + * might add a not existing account to the AM. tp_account_new () probably + * will be the best way to handle it. + * Note: When creating an EmpathyContact from a TplContact instance, the + * TpAccount is passed *only* to let EmpathyContact be able to retrieve the + * avatar (contact_get_avatar_filename () need a TpAccount). + * If the way EmpathyContact stores the avatar is changes, it might not be + * needed anymore any TpAccount passing and the following call will be + * useless */ + account = tp_account_manager_ensure_account (acc_man, + tpl_log_entry_get_account_path (logentry)); + g_object_unref (acc_man); + + /* TODO Currently only TplLogEntryText exists as subclass of TplLogEntry, in + * future more TplLogEntry will exist and EmpathyMessage should probably + * be enhanced to support other types of log entries (ie TplLogEntryCall). + * + * 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_LOG_ENTRY_TEXT (logentry)) + return NULL; + + body = g_strdup (tpl_log_entry_text_get_message ( + TPL_LOG_ENTRY_TEXT (logentry))); + receiver = tpl_log_entry_text_get_receiver (TPL_LOG_ENTRY_TEXT (logentry)); + sender = tpl_log_entry_text_get_sender (TPL_LOG_ENTRY_TEXT (logentry)); + + retval = empathy_message_new (body); + if (receiver != NULL) + empathy_message_set_receiver (retval, + empathy_contact_from_tpl_contact (account, receiver)); + if (sender != NULL) + empathy_message_set_sender (retval, + empathy_contact_from_tpl_contact (account, sender)); + + empathy_message_set_timestamp (retval, + tpl_log_entry_get_timestamp (logentry)); + empathy_message_set_id (retval, + tpl_log_entry_text_get_log_id (TPL_LOG_ENTRY_TEXT (logentry))); + empathy_message_set_is_backlog (retval, FALSE); + + g_free (body); + + return retval; +} +#endif /* ENABLE_TPL */ + TpChannelTextMessageType empathy_message_get_tptype (EmpathyMessage *message) { @@ -593,7 +666,12 @@ empathy_message_equal (EmpathyMessage *message1, EmpathyMessage *message2) priv1 = GET_PRIV (message1); priv2 = GET_PRIV (message2); +#ifdef ENABLE_TPL + if (priv1->timestamp == priv2->timestamp && + !tp_strdiff (priv1->body, priv2->body)) { +#else if (priv1->id == priv2->id && !tp_strdiff (priv1->body, priv2->body)) { +#endif /* ENABLE_TPL */ return TRUE; } diff --git a/libempathy/empathy-message.h b/libempathy/empathy-message.h index 512869373..d8d0c9603 100644 --- a/libempathy/empathy-message.h +++ b/libempathy/empathy-message.h @@ -26,6 +26,9 @@ #define __EMPATHY_MESSAGE_H__ #include <glib-object.h> +#ifdef ENABLE_TPL +#include <telepathy-logger/log-entry.h> +#endif #include "empathy-contact.h" #include "empathy-time.h" @@ -53,6 +56,9 @@ struct _EmpathyMessageClass { GType empathy_message_get_type (void) G_GNUC_CONST; EmpathyMessage * empathy_message_new (const gchar *body); +#ifdef ENABLE_TPL +EmpathyMessage * empathy_message_from_tpl_log_entry (TplLogEntry *logentry); +#endif /* ENABLE_TPL */ TpChannelTextMessageType empathy_message_get_tptype (EmpathyMessage *message); void empathy_message_set_tptype (EmpathyMessage *message, TpChannelTextMessageType type); diff --git a/src/Makefile.am b/src/Makefile.am index 9460fc959..3f8d15733 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -13,6 +13,7 @@ CPPFLAGS_COMMON = \ AM_LDFLAGS = -lm AM_CPPFLAGS = \ $(CPPFLAGS_COMMON) \ + $(TPL_CFLAGS) \ $(LIBNOTIFY_CFLAGS) \ $(LIBCHAMPLAIN_CFLAGS) \ $(WEBKIT_CFLAGS) \ @@ -22,6 +23,7 @@ LDADD = \ $(top_builddir)/libempathy-gtk/libempathy-gtk.la \ $(top_builddir)/libempathy/libempathy.la \ $(top_builddir)/extensions/libemp-extensions.la \ + $(TPL_LIBS) \ $(LIBNOTIFY_LIBS) \ $(EMPATHY_LIBS) \ $(LIBCHAMPLAIN_LIBS) \ diff --git a/src/empathy-chat-window.c b/src/empathy-chat-window.c index d8c68dc03..2e2f5c003 100644 --- a/src/empathy-chat-window.c +++ b/src/empathy-chat-window.c @@ -1315,6 +1315,8 @@ chat_window_new_message_cb (EmpathyChat *chat, if (has_focus && priv->current_chat == chat) { /* window and tab are focused so consider the message to be read */ + + /* FIXME: see Bug#610994 and coments about it in EmpathyChatPriv */ empathy_chat_messages_read (chat); return; } diff --git a/src/empathy.c b/src/empathy.c index 5ba8be1b2..a530b4ae0 100644 --- a/src/empathy.c +++ b/src/empathy.c @@ -44,6 +44,13 @@ #include <telepathy-glib/connection-manager.h> #include <telepathy-glib/interfaces.h> +#ifdef ENABLE_TPL +#include <telepathy-logger/log-manager.h> +#include <telepathy-logger/log-store-empathy.h> +#else + +#include <libempathy/empathy-log-manager.h> +#endif /* ENABLE_TPL */ #include <libempathy/empathy-idle.h> #include <libempathy/empathy-utils.h> #include <libempathy/empathy-call-factory.h> @@ -53,7 +60,6 @@ #include <libempathy/empathy-connection-managers.h> #include <libempathy/empathy-dispatcher.h> #include <libempathy/empathy-dispatch-operation.h> -#include <libempathy/empathy-log-manager.h> #include <libempathy/empathy-ft-factory.h> #include <libempathy/empathy-tp-chat.h> #include <libempathy/empathy-tp-call.h> @@ -547,7 +553,11 @@ main (int argc, char *argv[]) EmpathyStatusIcon *icon; EmpathyDispatcher *dispatcher; TpAccountManager *account_manager; +#ifdef ENABLE_TPL + TplLogManager *log_manager; +#else EmpathyLogManager *log_manager; +#endif /* ENABLE_TPL */ EmpathyChatroomManager *chatroom_manager; EmpathyCallFactory *call_factory; EmpathyFTFactory *ft_factory; @@ -560,7 +570,7 @@ main (int argc, char *argv[]) #ifdef ENABLE_DEBUG TpDebugSender *debug_sender; -#endif +#endif /* ENABLE_TPL */ GOptionContext *optcontext; GOptionEntry options[] = { @@ -654,8 +664,12 @@ main (int argc, char *argv[]) G_CALLBACK (unique_app_message_cb), window); /* Logging */ +#ifdef ENABLE_TPL + log_manager = tpl_log_manager_dup_singleton (); +#else log_manager = empathy_log_manager_dup_singleton (); empathy_log_manager_observe (log_manager, dispatcher); +#endif chatroom_manager = empathy_chatroom_manager_dup_singleton (NULL); empathy_chatroom_manager_observe (chatroom_manager, dispatcher); |