mcabber/src/jabglue.c
changeset 1018 45d022fbce3a
parent 1017 41f9a2a4c1de
child 1019 9d5f6e0ea7b3
equal deleted inserted replaced
1017:41f9a2a4c1de 1018:45d022fbce3a
  1280 // If note is nil, we remove the existing note.
  1280 // If note is nil, we remove the existing note.
  1281 void jb_set_storage_rosternotes(const char *barejid, const char *note)
  1281 void jb_set_storage_rosternotes(const char *barejid, const char *note)
  1282 {
  1282 {
  1283   xmlnode x;
  1283   xmlnode x;
  1284   bool changed = FALSE;
  1284   bool changed = FALSE;
       
  1285   const char *cdate = NULL;
  1285 
  1286 
  1286   if (!barejid)
  1287   if (!barejid)
  1287     return;
  1288     return;
  1288 
  1289 
  1289   // If we have no rosternotes, probably the server doesn't support them.
  1290   // If we have no rosternotes, probably the server doesn't support them.
  1305       if (!jid)
  1306       if (!jid)
  1306         continue;
  1307         continue;
  1307       if (!strcmp(jid, barejid)) {
  1308       if (!strcmp(jid, barejid)) {
  1308         // We've found a note for this jid.  Let's hide it and we'll
  1309         // We've found a note for this jid.  Let's hide it and we'll
  1309         // create a new one.
  1310         // create a new one.
       
  1311         cdate = xmlnode_get_attrib(x, "cdate");
  1310         xmlnode_hide(x);
  1312         xmlnode_hide(x);
  1311         changed = TRUE;
  1313         changed = TRUE;
  1312         break;
  1314         break;
  1313       }
  1315       }
  1314     }
  1316     }
  1315   }
  1317   }
  1316 
  1318 
  1317   // Let's create a node for this jid, if the note is not NULL.
  1319   // Let's create a node for this jid, if the note is not NULL.
  1318   if (note) {
  1320   if (note) {
       
  1321     char mdate[20];
       
  1322     time_t now;
       
  1323     time(&now);
       
  1324     to_iso8601(mdate, now);
       
  1325     if (!cdate)
       
  1326       cdate = mdate;
  1319     x = xmlnode_insert_tag(rosternotes, "note");
  1327     x = xmlnode_insert_tag(rosternotes, "note");
  1320     xmlnode_put_attrib(x, "jid", barejid);
  1328     xmlnode_put_attrib(x, "jid", barejid);
       
  1329     xmlnode_put_attrib(x, "cdate", cdate);
       
  1330     xmlnode_put_attrib(x, "mdate", mdate);
  1321     xmlnode_insert_cdata(x, note, -1);
  1331     xmlnode_insert_cdata(x, note, -1);
  1322     changed = TRUE;
  1332     changed = TRUE;
  1323   }
  1333   }
  1324 
  1334 
  1325   if (!changed)
  1335   if (!changed)