Mercurial > hg
comparison mcabber/src/jabglue.c @ 1008:bbf53cd43fbb
Functions to update room bookmarks
author | Mikael Berthe <mikael@lilotux.net> |
---|---|
date | Sun, 12 Nov 2006 10:45:13 +0100 |
parents | c8b1a52b2fd6 |
children | 54405d09b15a |
comparison
equal
deleted
inserted
replaced
1007:35b83557ffe1 | 1008:bbf53cd43fbb |
---|---|
1150 } | 1150 } |
1151 | 1151 |
1152 jab_send(jc, x); | 1152 jab_send(jc, x); |
1153 xmlnode_free(x); | 1153 xmlnode_free(x); |
1154 jb_reset_keepalive(); | 1154 jb_reset_keepalive(); |
1155 } | |
1156 | |
1157 // jb_set_storage_bookmark(roomid, name, nick, passwd, autojoin) | |
1158 // Update the private storage bookmarks: add a conference room. | |
1159 // If name is nil, we remove the bookmark. | |
1160 void jb_set_storage_bookmark(const char *roomid, const char *name, | |
1161 const char *nick, const char *passwd, int autojoin) | |
1162 { | |
1163 xmlnode x; | |
1164 | |
1165 if (!roomid) | |
1166 return; | |
1167 | |
1168 // If we have no bookmarks, probably the server doesn't support them. | |
1169 if (!bookmarks) { | |
1170 scr_LogPrint(LPRINT_LOGNORM, | |
1171 "Sorry, your server doesn't seem to support private storage."); | |
1172 return; | |
1173 } | |
1174 | |
1175 // Walk through the storage tags | |
1176 x = xmlnode_get_firstchild(bookmarks); | |
1177 for ( ; x; x = xmlnode_get_nextsibling(x)) { | |
1178 const char *jid; | |
1179 const char *p; | |
1180 p = xmlnode_get_name(x); | |
1181 // If the current node is a conference item, see if we have to replace it. | |
1182 if (p && !strcmp(p, "conference")) { | |
1183 jid = xmlnode_get_attrib(x, "jid"); | |
1184 if (!jid) | |
1185 continue; | |
1186 if (!strcmp(jid, roomid)) { | |
1187 // We've found a bookmark for this room. Let's hide it and we'll | |
1188 // create a new one. | |
1189 xmlnode_hide(x); | |
1190 break; | |
1191 } | |
1192 } | |
1193 } | |
1194 | |
1195 // Let's create a node/bookmark for this roomid, if the name is not NULL. | |
1196 if (name) { | |
1197 x = xmlnode_insert_tag(bookmarks, "conference"); | |
1198 xmlnode_put_attrib(x, "jid", roomid); | |
1199 xmlnode_put_attrib(x, "name", name); | |
1200 xmlnode_put_attrib(x, "autojoin", autojoin ? "1" : "0"); | |
1201 if (nick) | |
1202 xmlnode_insert_cdata(xmlnode_insert_tag(x, "nick"), nick, -1); | |
1203 if (passwd) | |
1204 xmlnode_insert_cdata(xmlnode_insert_tag(x, "password"), passwd, -1); | |
1205 } | |
1206 | |
1207 if (online) | |
1208 send_storage_bookmarks(); | |
1209 else | |
1210 scr_LogPrint(LPRINT_LOGNORM, | |
1211 "Warning: you're not connected to the server."); | |
1155 } | 1212 } |
1156 | 1213 |
1157 static void gotmessage(char *type, const char *from, const char *body, | 1214 static void gotmessage(char *type, const char *from, const char *body, |
1158 const char *enc, time_t timestamp) | 1215 const char *enc, time_t timestamp) |
1159 { | 1216 { |
1315 if (previous_state != JCONN_STATE_OFF) | 1372 if (previous_state != JCONN_STATE_OFF) |
1316 scr_LogPrint(LPRINT_LOGNORM, "[Jabber] Not connected to the server"); | 1373 scr_LogPrint(LPRINT_LOGNORM, "[Jabber] Not connected to the server"); |
1317 | 1374 |
1318 online = FALSE; | 1375 online = FALSE; |
1319 mystatus = offline; | 1376 mystatus = offline; |
1320 if (mystatusmsg) { | 1377 // Free status message |
1321 g_free(mystatusmsg); | 1378 g_free(mystatusmsg); |
1322 mystatusmsg = NULL; | 1379 mystatusmsg = NULL; |
1323 } | 1380 // Free bookmarks |
1381 xmlnode_free(bookmarks); | |
1382 bookmarks = NULL; | |
1383 // Free roster | |
1324 roster_free(); | 1384 roster_free(); |
1385 // Update display | |
1325 update_roster = TRUE; | 1386 update_roster = TRUE; |
1326 scr_UpdateBuddyWindow(); | 1387 scr_UpdateBuddyWindow(); |
1327 break; | 1388 break; |
1328 | 1389 |
1329 case JCONN_STATE_CONNECTED: | 1390 case JCONN_STATE_CONNECTED: |