summaryrefslogtreecommitdiff
path: root/libempathy/empathy-log-store-empathy.c
diff options
context:
space:
mode:
authorJonny Lamb <jonny.lamb@collabora.co.uk>2009-03-06 11:52:29 +0000
committerXavier Claessens <xclaesse@src.gnome.org>2009-03-06 11:52:29 +0000
commit37e09159559c1246ac7770b7f96ea9611acf2b5b (patch)
tree4e2f0a4c1341fc8ffd8dea9d5409c1a800556ca0 /libempathy/empathy-log-store-empathy.c
parent0a777526729fd4cd1e2171b9ea6e5c498c17ac64 (diff)
EmpathyLogStore: Store the CM message ID in the logs, and use it when reading logs.
Signed-off-by: Jonny Lamb <jonny.lamb@collabora.co.uk> svn path=/trunk/; revision=2599
Diffstat (limited to 'libempathy/empathy-log-store-empathy.c')
-rw-r--r--libempathy/empathy-log-store-empathy.c16
1 files changed, 14 insertions, 2 deletions
diff --git a/libempathy/empathy-log-store-empathy.c b/libempathy/empathy-log-store-empathy.c
index 2930aceb5..8df57a2e2 100644
--- a/libempathy/empathy-log-store-empathy.c
+++ b/libempathy/empathy-log-store-empathy.c
@@ -246,8 +246,10 @@ log_store_empathy_add_message (EmpathyLogStore *self,
avatar_token = g_markup_escape_text (avatar->token, -1);
g_fprintf (file,
- "<message time='%s' id='%s' name='%s' token='%s' isuser='%s' type='%s'>"
- "%s</message>\n" LOG_FOOTER, timestamp, contact_id, contact_name,
+ "<message time='%s' cm_id='%d' id='%s' name='%s' token='%s' isuser='%s' type='%s'>"
+ "%s</message>\n" LOG_FOOTER, timestamp,
+ empathy_message_get_id (message),
+ contact_id, contact_name,
avatar_token ? avatar_token : "",
empathy_contact_is_user (sender) ? "true" : "false",
empathy_message_type_to_str (msg_type), body);
@@ -452,6 +454,8 @@ log_store_empathy_get_messages_for_file (EmpathyLogStore *self,
gchar *is_user_str;
gboolean is_user = FALSE;
gchar *msg_type_str;
+ gchar *cm_id_str;
+ guint cm_id;
TpChannelTextMessageType msg_type = TP_CHANNEL_TEXT_MESSAGE_TYPE_NORMAL;
if (strcmp (node->name, "message") != 0)
@@ -464,6 +468,7 @@ log_store_empathy_get_messages_for_file (EmpathyLogStore *self,
sender_avatar_token = xmlGetProp (node, "token");
is_user_str = xmlGetProp (node, "isuser");
msg_type_str = xmlGetProp (node, "type");
+ cm_id_str = xmlGetProp (node, "cm_id");
if (is_user_str)
is_user = strcmp (is_user_str, "true") == 0;
@@ -471,6 +476,9 @@ log_store_empathy_get_messages_for_file (EmpathyLogStore *self,
if (msg_type_str)
msg_type = empathy_message_type_from_str (msg_type_str);
+ if (cm_id_str)
+ sscanf (cm_id_str, "%d", &cm_id);
+
t = empathy_time_parse (time);
sender = empathy_contact_new_full (account, sender_id, sender_name);
@@ -484,6 +492,9 @@ log_store_empathy_get_messages_for_file (EmpathyLogStore *self,
empathy_message_set_timestamp (message, t);
empathy_message_set_tptype (message, msg_type);
+ if (cm_id_str)
+ empathy_message_set_id (message, cm_id);
+
messages = g_list_append (messages, message);
g_object_unref (sender);
@@ -493,6 +504,7 @@ log_store_empathy_get_messages_for_file (EmpathyLogStore *self,
xmlFree (body);
xmlFree (is_user_str);
xmlFree (msg_type_str);
+ xmlFree (cm_id_str);
}
DEBUG ("Parsed %d messages", g_list_length (messages));