changeset 1018:45d022fbce3a

XEP-0145: Handle dates Save cdate and mdate when creating/updating an annotation.
author Mikael Berthe <mikael@lilotux.net>
date Wed, 15 Nov 2006 19:27:59 +0100
parents 41f9a2a4c1de
children 9d5f6e0ea7b3
files mcabber/src/jabglue.c
diffstat 1 files changed, 10 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/mcabber/src/jabglue.c	Wed Nov 15 19:23:40 2006 +0100
+++ b/mcabber/src/jabglue.c	Wed Nov 15 19:27:59 2006 +0100
@@ -1282,6 +1282,7 @@
 {
   xmlnode x;
   bool changed = FALSE;
+  const char *cdate = NULL;
 
   if (!barejid)
     return;
@@ -1307,6 +1308,7 @@
       if (!strcmp(jid, barejid)) {
         // We've found a note for this jid.  Let's hide it and we'll
         // create a new one.
+        cdate = xmlnode_get_attrib(x, "cdate");
         xmlnode_hide(x);
         changed = TRUE;
         break;
@@ -1316,8 +1318,16 @@
 
   // Let's create a node for this jid, if the note is not NULL.
   if (note) {
+    char mdate[20];
+    time_t now;
+    time(&now);
+    to_iso8601(mdate, now);
+    if (!cdate)
+      cdate = mdate;
     x = xmlnode_insert_tag(rosternotes, "note");
     xmlnode_put_attrib(x, "jid", barejid);
+    xmlnode_put_attrib(x, "cdate", cdate);
+    xmlnode_put_attrib(x, "mdate", mdate);
     xmlnode_insert_cdata(x, note, -1);
     changed = TRUE;
   }