summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCosimo Alfarano <cosimo.alfarano@collabora.co.uk>2010-03-08 12:36:19 +0100
committerCosimo Alfarano <cosimo.alfarano@collabora.co.uk>2010-03-12 14:07:50 +0100
commit2d01efa2235a521fb6568d1fb072f79847befca4 (patch)
tree9d11df3a47bc3fbddfa0e7d62a56628d0bdaafed
parent5f8cebc439597e30eb6fc0f315770a6d5f2d1a8a (diff)
downloadtelepathy-logger-2d01efa2235a521fb6568d1fb072f79847befca4.tar.gz
Changed create_message_token timestamp type from str to gint64
This way it is passed a unique repr of the data. With the str if any other format string was used, a different token would be produced
-rw-r--r--telepathy-logger/channel-text.c11
-rw-r--r--telepathy-logger/log-entry-text.c4
-rw-r--r--telepathy-logger/log-manager.c2
-rw-r--r--telepathy-logger/log-store-empathy.c2
-rw-r--r--telepathy-logger/util.c8
-rw-r--r--telepathy-logger/util.h2
6 files changed, 15 insertions, 14 deletions
diff --git a/telepathy-logger/channel-text.c b/telepathy-logger/channel-text.c
index 0b329f1..c3700c0 100644
--- a/telepathy-logger/channel-text.c
+++ b/telepathy-logger/channel-text.c
@@ -696,8 +696,7 @@ got_message_pending_messages_cb (TpProxy *proxy,
"message-received", NULL);
tpl_message_token = create_message_token (channel_path,
- tpl_time_to_string_local (message_timestamp,
- TPL_LOG_STORE_INDEX_TIMESTAMP_FORMAT), message_id);
+ message_timestamp, message_id);
/* look for the current token among the TPL indexed tokens/log_id */
l = g_list_find_custom (indexed_pending_msg, tpl_message_token,
@@ -1047,9 +1046,7 @@ on_sent_signal_cb (TpChannel *proxy,
g_return_if_fail (TPL_IS_CHANNEL_TEXT (tpl_text));
channel_path = tp_proxy_get_object_path (TP_PROXY (tpl_text));
- log_id = create_message_token (channel_path,
- tpl_time_to_string_local (arg_Timestamp,
- TPL_LOG_STORE_INDEX_TIMESTAMP_FORMAT),
+ log_id = create_message_token (channel_path, arg_Timestamp,
TPL_LOG_ENTRY_MSG_ID_ACKNOWLEDGED);
/* Initialize data for TplContact */
@@ -1257,9 +1254,7 @@ on_received_signal_cb (TpChannel *proxy,
TplLogStore *index = tpl_log_store_sqlite_dup ();
const gchar *account_path = tp_proxy_get_object_path (TP_PROXY (account));
const gchar *channel_path = tp_proxy_get_object_path (TP_PROXY (tpl_text));
- gchar *log_id = create_message_token (channel_path,
- tpl_time_to_string_local (arg_Timestamp,
- TPL_LOG_STORE_INDEX_TIMESTAMP_FORMAT), arg_ID);
+ gchar *log_id = create_message_token (channel_path, arg_Timestamp, arg_ID);
/* First, check if log_id has already been logged
*
diff --git a/telepathy-logger/log-entry-text.c b/telepathy-logger/log-entry-text.c
index 669a2b7..71c302a 100644
--- a/telepathy-logger/log-entry-text.c
+++ b/telepathy-logger/log-entry-text.c
@@ -347,7 +347,7 @@ tpl_log_entry_text_set_chatroom (TplLogEntryText *self,
/* Methods inherited by TplLogEntry */
-time_t
+gint64
tpl_log_entry_text_get_timestamp (TplLogEntryText *self)
{
TplLogEntry *logentry = TPL_LOG_ENTRY (self);
@@ -420,7 +420,7 @@ tpl_log_entry_text_get_receiver (TplLogEntryText *self)
void
tpl_log_entry_text_set_timestamp (TplLogEntryText *self,
- time_t data)
+ gint64 data)
{
TplLogEntry *logentry = TPL_LOG_ENTRY (self);
TPL_LOG_ENTRY_GET_CLASS (self)->set_timestamp (logentry, data);
diff --git a/telepathy-logger/log-manager.c b/telepathy-logger/log-manager.c
index 6452427..8794524 100644
--- a/telepathy-logger/log-manager.c
+++ b/telepathy-logger/log-manager.c
@@ -451,7 +451,7 @@ log_manager_message_date_cmp (gconstpointer a,
{
TplLogEntry *one = (TplLogEntry *) a;
TplLogEntry *two = (TplLogEntry *) b;
- time_t one_time, two_time;
+ gint64 one_time, two_time;
g_assert (TPL_IS_LOG_ENTRY (one));
g_assert (TPL_IS_LOG_ENTRY (two));
diff --git a/telepathy-logger/log-store-empathy.c b/telepathy-logger/log-store-empathy.c
index d727a96..b6272a7 100644
--- a/telepathy-logger/log-store-empathy.c
+++ b/telepathy-logger/log-store-empathy.c
@@ -553,7 +553,7 @@ log_store_empathy_get_messages_for_file (TplLogStore *self,
* token */
instead_of_channel_path = g_strconcat (
tp_proxy_get_object_path (account), sender_id, NULL);
- log_id = create_message_token (instead_of_channel_path, time_, cm_id);
+ log_id = create_message_token (instead_of_channel_path, t, cm_id);
message = tpl_log_entry_text_new (log_id,
tp_proxy_get_object_path (account), TPL_LOG_ENTRY_DIRECTION_NONE);
tpl_log_entry_set_pending_msg_id (TPL_LOG_ENTRY (message), cm_id);
diff --git a/telepathy-logger/util.c b/telepathy-logger/util.c
index 8193369..1bfdd91 100644
--- a/telepathy-logger/util.c
+++ b/telepathy-logger/util.c
@@ -21,16 +21,21 @@
#include "util.h"
+#include "datetime.h"
+#include "log-store-index.h"
+
/* Bug#26838 prevents us to trust Messages' iface message-token
* header, so I need to create a token which TPL can trust to be unique
* within itself */
gchar *
create_message_token (const gchar *channel,
- const gchar *date,
+ gint64 timestamp,
guint msgid)
{
GChecksum *log_id = g_checksum_new (G_CHECKSUM_SHA1);
gchar *retval;
+ gchar *date = tpl_time_to_string_local (timestamp,
+ TPL_LOG_STORE_INDEX_TIMESTAMP_FORMAT);
g_checksum_update (log_id, (guchar *) channel, -1);
g_checksum_update (log_id, (guchar *) date, -1);
@@ -39,6 +44,7 @@ create_message_token (const gchar *channel,
retval = g_strdup (g_checksum_get_string (log_id));
g_checksum_free (log_id);
+ g_free (date);
return retval;
}
diff --git a/telepathy-logger/util.h b/telepathy-logger/util.h
index 18df252..062f91a 100644
--- a/telepathy-logger/util.h
+++ b/telepathy-logger/util.h
@@ -42,7 +42,7 @@
return; \
}
-gchar *create_message_token (const gchar *channel, const gchar *date,
+gchar *create_message_token (const gchar *channel, time_t timestamp,
guint msgid);