summaryrefslogtreecommitdiff
path: root/telepathy-logger/util.c
diff options
context:
space:
mode:
authorCosimo Alfarano <cosimo.alfarano@collabora.co.uk>2010-03-03 14:30:00 +0000
committerCosimo Alfarano <cosimo.alfarano@collabora.co.uk>2010-03-12 14:07:43 +0100
commiteb8bd37327b668ff964cbcd8b5b4a8be645c8de1 (patch)
tree50e62bc5edb3a54ce2a85e014246fc2a0a2dcd50 /telepathy-logger/util.c
parentb38e68a0472b570879a1492b68ab3b95b157dbd0 (diff)
downloadtelepathy-logger-eb8bd37327b668ff964cbcd8b5b4a8be645c8de1.tar.gz
TplLogEntry/TplLogEntryText: added several fields/props
pending_msg_id: the entry's pending msd_id or -1 if sent/ack'd channel_path: the channel path relative to the channel originating the entry log_id: changed type, from guint to (gchar *), to represent a literal token, thus the constructor for TplLogEntry changed to follow the log_id type change. Due to the type change, a small amend has been done on TplLogStoreEmapthy. TplLogStoreDefault has been created since with the introduction of log_id as a literal token, TplLogStoreEmpathy won't be compatible anymore with the current TPL default LS. A utility function has been added to util.c, returning a message_token which TPL clients can trust to be unique within TPL, this until Bug#26838 will be solved. TplLogManager has been updated with the new TPL_LOG_STORE_DEFAULT instance. TpLChannelText has been updated with the TplLogStoreText constructor update.
Diffstat (limited to 'telepathy-logger/util.c')
-rw-r--r--telepathy-logger/util.c44
1 files changed, 44 insertions, 0 deletions
diff --git a/telepathy-logger/util.c b/telepathy-logger/util.c
new file mode 100644
index 0000000..8193369
--- /dev/null
+++ b/telepathy-logger/util.c
@@ -0,0 +1,44 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+/*
+ * Copyright (C) 2009 Collabora Ltd.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Authors: Cosimo Alfarano <cosimo.alfarano@collabora.co.uk>
+ */
+
+#include "util.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,
+ guint msgid)
+{
+ GChecksum *log_id = g_checksum_new (G_CHECKSUM_SHA1);
+ gchar *retval;
+
+ g_checksum_update (log_id, (guchar *) channel, -1);
+ g_checksum_update (log_id, (guchar *) date, -1);
+ g_checksum_update (log_id, (guchar *) &msgid, sizeof (unsigned int));
+
+ retval = g_strdup (g_checksum_get_string (log_id));
+
+ g_checksum_free (log_id);
+
+ return retval;
+}