diff options
-rw-r--r-- | doc/user-guide/commands.xml | 18 | ||||
-rw-r--r-- | protocols/jabber/conference.c | 14 | ||||
-rw-r--r-- | protocols/jabber/jabber.c | 7 | ||||
-rw-r--r-- | protocols/jabber/jabber.h | 4 |
4 files changed, 39 insertions, 4 deletions
diff --git a/doc/user-guide/commands.xml b/doc/user-guide/commands.xml index 99e45b5d..6f66a39d 100644 --- a/doc/user-guide/commands.xml +++ b/doc/user-guide/commands.xml @@ -648,6 +648,24 @@ </description> </bitlbee-setting> + <bitlbee-setting name="always_use_nicks" type="boolean" scope="channel"> + <default>false</default> + + <description> + <para> + Jabber groupchat specific. This setting ensures that the nicks defined by the other members of a groupchat are used, instead of the username part of their JID. This only applies to groupchats where their real JID is known (either "non-anonymous" ones, or "semi-anonymous" from the point of view of the channel moderators) + </para> + + <para> + Enabling this may have the side effect of changing the nick of existing contacts, either in your buddy list or in other groupchats. If a contact is in multiple groupchats with different nicks, enabling this setting for all those would result in multiple nick changes when joining, and the order of those changes may vary. + </para> + + <para> + Note that manual nick changes done through the <emphasis>rename</emphasis> command always take priority + </para> + </description> + </bitlbee-setting> + <bitlbee-setting name="auto_connect" type="boolean" scope="account,global"> <default>true</default> diff --git a/protocols/jabber/conference.c b/protocols/jabber/conference.c index cc832659..3a6cff7c 100644 --- a/protocols/jabber/conference.c +++ b/protocols/jabber/conference.c @@ -27,7 +27,8 @@ static xt_status jabber_chat_join_failed(struct im_connection *ic, struct xt_node *node, struct xt_node *orig); static xt_status jabber_chat_self_message(struct im_connection *ic, struct xt_node *node, struct xt_node *orig); -struct groupchat *jabber_chat_join(struct im_connection *ic, const char *room, const char *nick, const char *password) +struct groupchat *jabber_chat_join(struct im_connection *ic, const char *room, const char *nick, const char *password, + gboolean always_use_nicks) { struct jabber_chat *jc; struct xt_node *node; @@ -58,6 +59,10 @@ struct groupchat *jabber_chat_join(struct im_connection *ic, const char *room, c return NULL; } + if (always_use_nicks) { + jc->flags = JCFLAG_ALWAYS_USE_NICKS; + } + /* roomjid isn't normalized yet, and we need an original version of the nick to send a proper presence update. */ jc->my_full_jid = roomjid; @@ -94,7 +99,7 @@ struct groupchat *jabber_chat_with(struct im_connection *ic, char *who) g_free(uuid); g_free(cserv); - c = jabber_chat_join(ic, rjid, jd->username, NULL); + c = jabber_chat_join(ic, rjid, jd->username, NULL, FALSE); g_free(rjid); if (c == NULL) { return NULL; @@ -340,6 +345,11 @@ void jabber_chat_pkt_presence(struct im_connection *ic, struct jabber_buddy *bud if (s) { *s = 0; /* Should NEVER be NULL, but who knows... */ } + + if (bud != jc->me && (jc->flags & JCFLAG_ALWAYS_USE_NICKS) && !(bud->flags & JBFLAG_IS_ANONYMOUS)) { + imcb_buddy_nick_change(ic, bud->ext_jid, bud->resource); + } + imcb_chat_add_buddy(chat, bud->ext_jid); if (s) { *s = '/'; diff --git a/protocols/jabber/jabber.c b/protocols/jabber/jabber.c index 6e7b89af..11a90ff4 100644 --- a/protocols/jabber/jabber.c +++ b/protocols/jabber/jabber.c @@ -576,7 +576,8 @@ static struct groupchat *jabber_chat_join_(struct im_connection *ic, const char imcb_error(ic, "Already present in chat `%s'", room); } else { /* jabber_chat_join without the underscore is the conference.c one */ - return jabber_chat_join(ic, room, final_nick, set_getstr(sets, "password")); + return jabber_chat_join(ic, room, final_nick, set_getstr(sets, "password"), + set_getbool(sets, "always_use_nicks")); } return NULL; @@ -685,6 +686,8 @@ static int jabber_send_typing(struct im_connection *ic, char *who, int typing) void jabber_chat_add_settings(account_t *acc, set_t **head) { + set_add(head, "always_use_nicks", "false", set_eval_bool, NULL); + /* Meh. Stupid room passwords. Not trying to obfuscate/hide them from the user for now. */ set_add(head, "password", NULL, NULL, NULL); @@ -692,6 +695,8 @@ void jabber_chat_add_settings(account_t *acc, set_t **head) void jabber_chat_free_settings(account_t *acc, set_t **head) { + set_del(head, "always_use_nicks"); + set_del(head, "password"); } diff --git a/protocols/jabber/jabber.h b/protocols/jabber/jabber.h index a52280af..d76ee08f 100644 --- a/protocols/jabber/jabber.h +++ b/protocols/jabber/jabber.h @@ -74,6 +74,7 @@ typedef struct { typedef enum { JCFLAG_MESSAGE_SENT = 1, /* Set this after sending the first message, so we can detect echoes/backlogs. */ + JCFLAG_ALWAYS_USE_NICKS = 2, } jabber_chat_flags_t; struct jabber_data { @@ -342,7 +343,8 @@ int sasl_oauth2_refresh(struct im_connection *ic, const char *refresh_token); extern const struct oauth2_service oauth2_service_google; /* conference.c */ -struct groupchat *jabber_chat_join(struct im_connection *ic, const char *room, const char *nick, const char *password); +struct groupchat *jabber_chat_join(struct im_connection *ic, const char *room, const char *nick, const char *password, + gboolean always_use_nicks); struct groupchat *jabber_chat_with(struct im_connection *ic, char *who); struct groupchat *jabber_chat_by_jid(struct im_connection *ic, const char *name); void jabber_chat_free(struct groupchat *c); |