Mercurial > ~mikael > mcabber > hg
comparison mcabber/src/jabglue.c @ 1017:41f9a2a4c1de
Only update server private storage data if they've changed
We do not want to call send_storage_bookmarks() and send_storage_rosternotes()
when the data haven't been updated.
author | Mikael Berthe <mikael@lilotux.net> |
---|---|
date | Wed, 15 Nov 2006 19:23:40 +0100 |
parents | 4d3c48844746 |
children | 45d022fbce3a |
comparison
equal
deleted
inserted
replaced
1016:4d3c48844746 | 1017:41f9a2a4c1de |
---|---|
1180 // If name is nil, we remove the bookmark. | 1180 // If name is nil, we remove the bookmark. |
1181 void jb_set_storage_bookmark(const char *roomid, const char *name, | 1181 void jb_set_storage_bookmark(const char *roomid, const char *name, |
1182 const char *nick, const char *passwd, int autojoin) | 1182 const char *nick, const char *passwd, int autojoin) |
1183 { | 1183 { |
1184 xmlnode x; | 1184 xmlnode x; |
1185 bool changed = FALSE; | |
1185 | 1186 |
1186 if (!roomid) | 1187 if (!roomid) |
1187 return; | 1188 return; |
1188 | 1189 |
1189 // If we have no bookmarks, probably the server doesn't support them. | 1190 // If we have no bookmarks, probably the server doesn't support them. |
1206 continue; | 1207 continue; |
1207 if (!strcmp(jid, roomid)) { | 1208 if (!strcmp(jid, roomid)) { |
1208 // We've found a bookmark for this room. Let's hide it and we'll | 1209 // We've found a bookmark for this room. Let's hide it and we'll |
1209 // create a new one. | 1210 // create a new one. |
1210 xmlnode_hide(x); | 1211 xmlnode_hide(x); |
1212 changed = TRUE; | |
1211 break; | 1213 break; |
1212 } | 1214 } |
1213 } | 1215 } |
1214 } | 1216 } |
1215 | 1217 |
1221 xmlnode_put_attrib(x, "autojoin", autojoin ? "1" : "0"); | 1223 xmlnode_put_attrib(x, "autojoin", autojoin ? "1" : "0"); |
1222 if (nick) | 1224 if (nick) |
1223 xmlnode_insert_cdata(xmlnode_insert_tag(x, "nick"), nick, -1); | 1225 xmlnode_insert_cdata(xmlnode_insert_tag(x, "nick"), nick, -1); |
1224 if (passwd) | 1226 if (passwd) |
1225 xmlnode_insert_cdata(xmlnode_insert_tag(x, "password"), passwd, -1); | 1227 xmlnode_insert_cdata(xmlnode_insert_tag(x, "password"), passwd, -1); |
1226 } | 1228 changed = TRUE; |
1229 } | |
1230 | |
1231 if (!changed) | |
1232 return; | |
1227 | 1233 |
1228 if (online) | 1234 if (online) |
1229 send_storage_bookmarks(); | 1235 send_storage_bookmarks(); |
1230 else | 1236 else |
1231 scr_LogPrint(LPRINT_LOGNORM, | 1237 scr_LogPrint(LPRINT_LOGNORM, |
1273 // Update the private storage rosternotes: add/delete a note. | 1279 // Update the private storage rosternotes: add/delete a note. |
1274 // If note is nil, we remove the existing note. | 1280 // If note is nil, we remove the existing note. |
1275 void jb_set_storage_rosternotes(const char *barejid, const char *note) | 1281 void jb_set_storage_rosternotes(const char *barejid, const char *note) |
1276 { | 1282 { |
1277 xmlnode x; | 1283 xmlnode x; |
1284 bool changed = FALSE; | |
1278 | 1285 |
1279 if (!barejid) | 1286 if (!barejid) |
1280 return; | 1287 return; |
1281 | 1288 |
1282 // If we have no rosternotes, probably the server doesn't support them. | 1289 // If we have no rosternotes, probably the server doesn't support them. |
1299 continue; | 1306 continue; |
1300 if (!strcmp(jid, barejid)) { | 1307 if (!strcmp(jid, barejid)) { |
1301 // We've found a note for this jid. Let's hide it and we'll | 1308 // We've found a note for this jid. Let's hide it and we'll |
1302 // create a new one. | 1309 // create a new one. |
1303 xmlnode_hide(x); | 1310 xmlnode_hide(x); |
1311 changed = TRUE; | |
1304 break; | 1312 break; |
1305 } | 1313 } |
1306 } | 1314 } |
1307 } | 1315 } |
1308 | 1316 |
1309 // Let's create a node for this jid, if the note is not NULL. | 1317 // Let's create a node for this jid, if the note is not NULL. |
1310 if (note) { | 1318 if (note) { |
1311 x = xmlnode_insert_tag(rosternotes, "note"); | 1319 x = xmlnode_insert_tag(rosternotes, "note"); |
1312 xmlnode_put_attrib(x, "jid", barejid); | 1320 xmlnode_put_attrib(x, "jid", barejid); |
1313 xmlnode_insert_cdata(x, note, -1); | 1321 xmlnode_insert_cdata(x, note, -1); |
1314 } | 1322 changed = TRUE; |
1323 } | |
1324 | |
1325 if (!changed) | |
1326 return; | |
1315 | 1327 |
1316 if (online) | 1328 if (online) |
1317 send_storage_rosternotes(); | 1329 send_storage_rosternotes(); |
1318 else | 1330 else |
1319 scr_LogPrint(LPRINT_LOGNORM, | 1331 scr_LogPrint(LPRINT_LOGNORM, |