#include <string.h>
#include <stdio.h>
#include <stdlib.h>
+
+/* FIXME: g_mapped_file_free has been deprecated in GLib 2.22, but the
+ * replacement symbol, g_mapped_file_unref is not available in older Glib
+ * and we're not ready to bump our version requirement just for this. When
+ * we're ready to bump our version requirement, just revert this patch. */
+#undef G_DISABLE_DEPRECATED
#include <glib/gstdio.h>
+#define G_DISABLE_DEPRECATED
#include <telepathy-glib/util.h>
+#include <telepathy-glib/defs.h>
#include "empathy-log-store.h"
#include "empathy-log-store-empathy.h"
priv->account_manager = empathy_account_manager_dup_singleton ();
}
+static gchar *
+log_store_account_to_dirname (EmpathyAccount *account)
+{
+ const gchar *name;
+
+ name = empathy_account_get_unique_name (account);
+ if (g_str_has_prefix (name, TP_ACCOUNT_OBJECT_PATH_BASE))
+ name += strlen (TP_ACCOUNT_OBJECT_PATH_BASE);
+
+ return g_strdelimit (g_strdup (name), "/", '_');
+}
+
+
static gchar *
log_store_empathy_get_dir (EmpathyLogStore *self,
EmpathyAccount *account,
priv = GET_PRIV (self);
- /* unique name is an object path, ignore the initial / and replace the others
- * by % */
- escaped = g_strdup (empathy_account_get_unique_name (account) + 1);
-
- g_strdelimit (escaped, "/", '%');
+ escaped = log_store_account_to_dirname (account);
if (chatroom)
basedir = g_build_path (G_DIR_SEPARATOR_S, priv->basedir, escaped,
{
EmpathyLogStoreEmpathyPriv *priv = GET_PRIV (self);
EmpathyLogSearchHit *hit;
- gchar *unescaped;
gchar *account_name;
const gchar *end;
gchar **strv;
guint len;
+ GList *accounts, *l;
if (!g_str_has_suffix (filename, LOG_FILENAME_SUFFIX))
return NULL;
else
account_name = strv[len-3];
- unescaped = g_strdup_printf ("/%s", g_strdelimit (account_name, "%", '/'));
+ accounts = empathy_account_manager_dup_accounts (priv->account_manager);
+
+ for (l = accounts; l != NULL; l = g_list_next (l))
+ {
+ EmpathyAccount *account = EMPATHY_ACCOUNT (l->data);
+ gchar *name;
+
+ name = log_store_account_to_dirname (account);
+ if (!tp_strdiff (name, account_name))
+ {
+ g_assert (hit->account == NULL);
+ hit->account = account;
+ g_object_ref (account);
+ }
+ g_object_unref (account);
+ g_free (name);
+ }
+ g_list_free (accounts);
- hit->account = empathy_account_manager_lookup (priv->account_manager,
- unescaped);
hit->filename = g_strdup (filename);
- g_free (unescaped);
g_strfreev (strv);
return hit;
empathy_message_set_sender (message, sender);
empathy_message_set_timestamp (message, t);
empathy_message_set_tptype (message, msg_type);
+ empathy_message_set_is_backlog (message, TRUE);
if (cm_id_str)
empathy_message_set_id (message, cm_id);
priv = GET_PRIV (self);
- dir = g_build_filename (priv->basedir,
- empathy_account_get_unique_name (account), NULL);
+ dir = log_store_empathy_get_dir (self, account, NULL, FALSE);
hits = log_store_empathy_get_chats_for_dir (self, dir, FALSE);