By default TPL is disabled, use --enable-tpl configure option to enable it.
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
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
# -----------------------------------------------------------
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}
-DDATADIR=\""$(datadir)"\" \
-DPKGDATADIR=\""$(pkgdatadir)"\" \
$(LIBEMPATHYGTK_CFLAGS) \
+ $(TPL_CFLAGS) \
$(LIBNOTIFY_CFLAGS) \
$(ENCHANT_CFLAGS) \
$(LIBCHAMPLAIN_CFLAGS) \
libempathy_gtk_la_LIBADD = \
$(LIBEMPATHYGTK_LIBS) \
$(LIBNOTIFY_LIBS) \
+ $(TPL_LIBS) \
$(ENCHANT_LIBS) \
$(LIBCHAMPLAIN_LIBS) \
$(GEOCLUE_LIBS) \
#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>
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;
/* 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 {
}
}
+
+#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;
/* 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,
/* 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
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)
{
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
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;
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;
}
#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>
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"));
#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>
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;
}
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");
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)
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);
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);
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);
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) {
if (hits) {
empathy_log_manager_search_free (hits);
}
+#endif /* ENABLE_TPL */
}
static void
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);
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;
g_object_unref (account);
+#endif /* ENABLE_TPL */
}
static void
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)
g_free (chat_id);
}
+#endif /* ENABLE_TPL */
+
static void
log_window_calendar_chats_day_selected_cb (GtkWidget *calendar,
EmpathyLogWindow *window)
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)
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));
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;
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
-DDATADIR=\""$(datadir)"\" \
-DLOCALEDIR=\""$(datadir)/locale"\" \
-DG_LOG_DOMAIN=\"empathy\" \
+ $(TPL_CFLAGS) \
$(LIBEMPATHY_CFLAGS) \
$(GEOCLUE_CFLAGS) \
$(NETWORK_MANAGER_CFLAGS) \
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 \
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 \
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 \
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)
$(top_builddir)/extensions/libemp-extensions.la \
$(LIBEMPATHY_LIBS) \
$(GEOCLUE_LIBS) \
+ $(TPL_LIBS) \
$(NETWORK_MANAGER_LIBS) \
$(CONNMAN_LIBS)
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 = \
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
#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"
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,
#include <telepathy-glib/contact.h>
#include <telepathy-glib/account.h>
+#ifdef ENABLE_TPL
+#include <telepathy-logger/contact.h>
+#endif /* ENABLE_TPL */
G_BEGIN_DECLS
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);
#ifndef __EMPATHY_LOG_MANAGER_H__
#define __EMPATHY_LOG_MANAGER_H__
+#include <config.h>
+#ifndef ENABLE_TPL
+
#include <glib-object.h>
#include "empathy-message.h"
G_END_DECLS
+#endif /* ENABLE_TPL */
#endif /* __EMPATHY_LOG_MANAGER_H__ */
#ifndef __EMPATHY_LOG_STORE_EMPATHY_H__
#define __EMPATHY_LOG_STORE_EMPATHY_H__
+#include <config.h>
+#ifndef ENABLE_TPL
+
#include <glib.h>
G_BEGIN_DECLS
G_END_DECLS
+#endif /* ENABLE_TPL */
#endif /* __EMPATHY_LOG_STORE_EMPATHY_H__ */
#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>
G_END_DECLS
+#endif /* ENABLE_TPL */
#endif /* __EMPATHY_LOG_STORE_H__ */
#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"
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)
{
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;
}
#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"
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);
AM_LDFLAGS = -lm
AM_CPPFLAGS = \
$(CPPFLAGS_COMMON) \
+ $(TPL_CFLAGS) \
$(LIBNOTIFY_CFLAGS) \
$(LIBCHAMPLAIN_CFLAGS) \
$(WEBKIT_CFLAGS) \
$(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) \
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;
}
#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>
#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>
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;
#ifdef ENABLE_DEBUG
TpDebugSender *debug_sender;
-#endif
+#endif /* ENABLE_TPL */
GOptionContext *optcontext;
GOptionEntry options[] = {
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);