--- a/mcabber/src/commands.c Sun Dec 09 19:26:37 2007 +0100
+++ b/mcabber/src/commands.c Mon Dec 10 21:45:24 2007 +0100
@@ -2069,7 +2069,7 @@
// If no nickname is provided with the /join command,
// we try to get a default nickname.
if (!nick || !*nick)
- nick = default_muc_nickname();
+ nick = default_muc_nickname(roomname);
else
nick = to_utf8(nick);
// If we still have no nickname, give up
--- a/mcabber/src/jab_iq.c Sun Dec 09 19:26:37 2007 +0100
+++ b/mcabber/src/jab_iq.c Mon Dec 10 21:45:24 2007 +0100
@@ -797,7 +797,7 @@
nick = xmlnode_get_tag_data(xmldata, "nick");
passwd = xmlnode_get_tag_data(xmldata, "password");
if (!nick || !*nick)
- nick = tmpnick = default_muc_nickname();
+ nick = tmpnick = default_muc_nickname(NULL);
// Let's join now
scr_LogPrint(LPRINT_LOGNORM, "Auto-join bookmark <%s>", bjid);
jb_room_join(bjid, nick, passwd);
--- a/mcabber/src/jabglue.c Sun Dec 09 19:26:37 2007 +0100
+++ b/mcabber/src/jabglue.c Mon Dec 10 21:45:24 2007 +0100
@@ -1352,7 +1352,7 @@
jb_reset_keepalive();
}
-// jb_is_bookmarked()
+// jb_is_bookmarked(roomjid)
// Return TRUE if there's a bookmark for the given jid.
guint jb_is_bookmarked(const char *bjid)
{
@@ -1377,6 +1377,32 @@
return FALSE;
}
+// jb_get_bookmark_nick(roomjid)
+// Return the room nickname if it is present in a bookmark.
+const char *jb_get_bookmark_nick(const char *bjid)
+{
+ xmlnode x;
+
+ if (!bookmarks || !bjid)
+ 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, check the jid.
+ if (p && !strcmp(p, "conference")) {
+ fjid = xmlnode_get_attrib(x, "jid");
+ if (fjid && !strcasecmp(bjid, fjid))
+ return xmlnode_get_tag_data(x, "nick");
+ }
+ }
+ return NULL;
+}
+
+
// jb_get_all_storage_bookmarks()
// Return a GSList with all storage bookmarks.
// The caller should g_free the list (not the MUC jids).
@@ -2790,7 +2816,7 @@
// evcontext: 0, 1 == reject, accept
if (evcontext & ~EVS_CONTEXT_USER) {
- char *nickname = default_muc_nickname();
+ char *nickname = default_muc_nickname(invitation->to);
jb_room_join(invitation->to, nickname, invitation->passwd);
g_free(nickname);
} else {
--- a/mcabber/src/jabglue.h Sun Dec 09 19:26:37 2007 +0100
+++ b/mcabber/src/jabglue.h Mon Dec 10 21:45:24 2007 +0100
@@ -79,6 +79,7 @@
void jb_iqs_display_list(void);
void jb_request(const char *fjid, enum iqreq_type reqtype);
guint jb_is_bookmarked(const char *bjid);
+const char *jb_get_bookmark_nick(const char *bjid);
GSList *jb_get_all_storage_bookmarks(void);
void jb_set_storage_bookmark(const char *roomid, const char *name,
const char *nick, const char *passwd,
--- a/mcabber/src/settings.c Sun Dec 09 19:26:37 2007 +0100
+++ b/mcabber/src/settings.c Mon Dec 10 21:45:24 2007 +0100
@@ -388,10 +388,14 @@
// default_muc_nickname()
// Return the user's default nickname
// The caller should free the string after use
-char *default_muc_nickname(void)
+char *default_muc_nickname(const char *roomid)
{
char *nick;
+ nick = (char*)jb_get_bookmark_nick(roomid);
+ if (nick)
+ return g_strdup(nick);
+
// We try the "nickname" option, then the username part of the jid.
nick = (char*)settings_opt_get("nickname");
if (nick)
--- a/mcabber/src/settings.h Sun Dec 09 19:26:37 2007 +0100
+++ b/mcabber/src/settings.h Mon Dec 10 21:45:24 2007 +0100
@@ -52,7 +52,7 @@
guint get_max_history_blocks(void);
-char *default_muc_nickname(void);
+char *default_muc_nickname(const char *roomid);
const gchar *isbound(int key);