# HG changeset patch # User Mikael Berthe # Date 1171707941 -3600 # Node ID 2913310a7be6e2c425a2bdecd3d46dab82916cd3 # Parent 39b20ea22ce948e890455b38a74754fa560c05b6 Make /roster bookmark in the status buffer show all bookmarks diff -r 39b20ea22ce9 -r 2913310a7be6 mcabber/doc/help/en/hlp_room.txt --- a/mcabber/doc/help/en/hlp_room.txt Sat Feb 17 10:35:12 2007 +0100 +++ b/mcabber/doc/help/en/hlp_room.txt Sat Feb 17 11:25:41 2007 +0100 @@ -38,3 +38,4 @@ /room bookmark [add|del] [-autojoin|+autojoin] Add, remove or update a bookmark (default is add). If autojoin is set, mcabber will automatically join the MUC room when it connects to the server. + To see the list of bookmarks, use /room bookmark in the status buffer. diff -r 39b20ea22ce9 -r 2913310a7be6 mcabber/doc/help/fr/hlp_room.txt --- a/mcabber/doc/help/fr/hlp_room.txt Sat Feb 17 10:35:12 2007 +0100 +++ b/mcabber/doc/help/fr/hlp_room.txt Sat Feb 17 11:25:41 2007 +0100 @@ -38,3 +38,4 @@ /room bookmark [add|del] [-autojoin|+autojoin] Ajoute, supprime ou met à jour le signet (par défaut, ajoute). Si "autojoin" est activé, mcabber entrera automatiquement dans la salle de conférence après s'être connecté au serveur. + Pour visualiser la liste des signets, tapez /room bookmark dans la fenêtre d'état (status). diff -r 39b20ea22ce9 -r 2913310a7be6 mcabber/src/commands.c --- a/mcabber/src/commands.c Sat Feb 17 10:35:12 2007 +0100 +++ b/mcabber/src/commands.c Sat Feb 17 11:25:41 2007 +0100 @@ -541,13 +541,15 @@ { GSList *notes; notes = jb_get_all_storage_rosternotes(); + + if (!notes) + return; + // Call display_and_free_note() for each note, // with winId = NULL (special window) g_slist_foreach(notes, (GFunc)&display_and_free_note, NULL); - if (notes) { - scr_setmsgflag_if_needed(SPECIAL_BUFFER_STATUS_ID, TRUE); - update_roster = TRUE; - } + scr_setmsgflag_if_needed(SPECIAL_BUFFER_STATUS_ID, TRUE); + update_roster = TRUE; g_slist_free(notes); } @@ -2264,6 +2266,32 @@ jb_set_storage_bookmark(roomid, name, nick, NULL, autojoin); } +static void display_all_bookmarks(void) +{ + GSList *bm, *bmp; + GString *sbuf; + + bm = jb_get_all_storage_bookmarks(); + + if (!bm) + return; + + sbuf = g_string_new(""); + + scr_WriteIncomingMessage(NULL, "List of MUC bookmarks:", 0, HBB_PREFIX_INFO); + + for (bmp = bm; bmp; bmp = g_slist_next(bmp)) { + g_string_printf(sbuf, "<%s>", (char*)bmp->data); + scr_WriteIncomingMessage(NULL, sbuf->str, 0, HBB_PREFIX_NONE); + } + + scr_setmsgflag_if_needed(SPECIAL_BUFFER_STATUS_ID, TRUE); + update_roster = TRUE; + g_string_free(sbuf, TRUE); + g_slist_free(bm); +} + + static void do_room(char *arg) { char **paramlst; @@ -2343,7 +2371,10 @@ if ((arg = check_room_subcommand(arg, TRUE, bud)) != NULL) room_whois(bud, arg, TRUE); } else if (!strcasecmp(subcmd, "bookmark")) { - if ((arg = check_room_subcommand(arg, FALSE, bud)) != NULL) + if (!arg && !buddy_getjid(BUDDATA(current_buddy)) && + buddy_gettype(BUDDATA(current_buddy)) == ROSTER_TYPE_SPECIAL) + display_all_bookmarks(); + else if ((arg = check_room_subcommand(arg, FALSE, bud)) != NULL) room_bookmark(bud, arg); } else { scr_LogPrint(LPRINT_NORMAL, "Unrecognized parameter!"); diff -r 39b20ea22ce9 -r 2913310a7be6 mcabber/src/jabglue.c --- a/mcabber/src/jabglue.c Sat Feb 17 10:35:12 2007 +0100 +++ b/mcabber/src/jabglue.c Sat Feb 17 11:25:41 2007 +0100 @@ -1269,6 +1269,35 @@ jb_reset_keepalive(); } +// jb_get_all_storage_bookmarks() +// Return a GSList with all storage bookmarks. +// The caller should g_free the list (not the MUC jids). +GSList *jb_get_all_storage_bookmarks(void) +{ + xmlnode x; + GSList *sl_bookmarks = NULL; + + // If we have no bookmarks, probably the server doesn't support them. + if (!bookmarks) + return NULL; + + // Walk through the storage bookmark tags + x = xmlnode_get_firstchild(bookmarks); + for ( ; x; x = xmlnode_get_nextsibling(x)) { + const char *fjid; + const char *p; + p = xmlnode_get_name(x); + // If the node is a conference item, let's add the note to our list. + if (p && !strcmp(p, "conference")) { + fjid = xmlnode_get_attrib(x, "jid"); + if (!fjid) + continue; + sl_bookmarks = g_slist_append(sl_bookmarks, fjid); + } + } + return sl_bookmarks; +} + // jb_set_storage_bookmark(roomid, name, nick, passwd, autojoin) // Update the private storage bookmarks: add a conference room. // If name is nil, we remove the bookmark. diff -r 39b20ea22ce9 -r 2913310a7be6 mcabber/src/jabglue.h --- a/mcabber/src/jabglue.h Sat Feb 17 10:35:12 2007 +0100 +++ b/mcabber/src/jabglue.h Sat Feb 17 11:25:41 2007 +0100 @@ -76,6 +76,7 @@ struct role_affil ra, const char *reason); void jb_iqs_display_list(void); void jb_request(const char *fjid, enum iqreq_type reqtype); +GSList *jb_get_all_storage_bookmarks(void); void jb_set_storage_bookmark(const char *roomid, const char *name, const char *nick, const char *passwd, int autojoin);