diff options
author | Florent Le Coz <louiz@louiz.org> | 2014-02-17 01:43:58 +0100 |
---|---|---|
committer | Florent Le Coz <louiz@louiz.org> | 2014-02-17 01:43:58 +0100 |
commit | cf9f3a1f2855b358aa9bbc31f234801e9e1efc28 (patch) | |
tree | a89ac719df9cd7cbd4fa02e1994ce7eb34180f43 | |
parent | abcf16bc28a5f72d9e7f964a5f2b432f55dfe5b6 (diff) | |
download | biboumi-cf9f3a1f2855b358aa9bbc31f234801e9e1efc28.tar.gz biboumi-cf9f3a1f2855b358aa9bbc31f234801e9e1efc28.tar.bz2 biboumi-cf9f3a1f2855b358aa9bbc31f234801e9e1efc28.tar.xz biboumi-cf9f3a1f2855b358aa9bbc31f234801e9e1efc28.zip |
Include role and affiliation in the join presence of the nick change process
-rw-r--r-- | src/bridge/bridge.cpp | 12 | ||||
-rw-r--r-- | src/bridge/bridge.hpp | 12 | ||||
-rw-r--r-- | src/irc/irc_client.cpp | 5 | ||||
-rw-r--r-- | src/xmpp/xmpp_component.cpp | 10 | ||||
-rw-r--r-- | src/xmpp/xmpp_component.hpp | 8 |
5 files changed, 37 insertions, 10 deletions
diff --git a/src/bridge/bridge.cpp b/src/bridge/bridge.cpp index be0d270..6460e6b 100644 --- a/src/bridge/bridge.cpp +++ b/src/bridge/bridge.cpp @@ -195,10 +195,18 @@ void Bridge::send_muc_leave(Iid&& iid, std::string&& nick, const std::string& me this->xmpp->send_muc_leave(std::move(iid.chan) + "%" + std::move(iid.server), std::move(nick), this->make_xmpp_body(message), this->user_jid, self); } -void Bridge::send_nick_change(Iid&& iid, const std::string& old_nick, const std::string& new_nick, const bool self) +void Bridge::send_nick_change(Iid&& iid, + const std::string& old_nick, + const std::string& new_nick, + const char user_mode, + const bool self) { + std::string affiliation; + std::string role; + std::tie(role, affiliation) = get_role_affiliation_from_irc_mode(user_mode); + this->xmpp->send_nick_change(std::move(iid.chan) + "%" + std::move(iid.server), - old_nick, new_nick, this->user_jid, self); + old_nick, new_nick, affiliation, role, this->user_jid, self); } void Bridge::send_xmpp_message(const std::string& from, const std::string& author, const std::string& msg) diff --git a/src/bridge/bridge.hpp b/src/bridge/bridge.hpp index c43b049..b3a5d02 100644 --- a/src/bridge/bridge.hpp +++ b/src/bridge/bridge.hpp @@ -84,9 +84,15 @@ public: void send_muc_leave(Iid&& iid, std::string&& nick, const std::string& message, const bool self); /** * Send presences to indicate that an user old_nick (ourself if self == - * true) changed his nick to new_nick - */ - void send_nick_change(Iid&& iid, const std::string& old_nick, const std::string& new_nick, const bool self); + * true) changed his nick to new_nick. The user_mode is needed because + * the xmpp presence needs ton contain the role and affiliation of the + * user. + */ + void send_nick_change(Iid&& iid, + const std::string& old_nick, + const std::string& new_nick, + const char user_mode, + const bool self); void kick_muc_user(Iid&& iid, const std::string& target, const std::string& reason, const std::string& author); void send_nickname_conflict_error(const Iid& iid, const std::string& nickname); /** diff --git a/src/irc/irc_client.cpp b/src/irc/irc_client.cpp index a84f96e..bb2fc75 100644 --- a/src/irc/irc_client.cpp +++ b/src/irc/irc_client.cpp @@ -469,8 +469,9 @@ void IrcClient::on_nick(const IrcMessage& message) Iid iid; iid.chan = chan_name; iid.server = this->hostname; - bool self = channel->get_self()->nick == old_nick; - this->bridge->send_nick_change(std::move(iid), old_nick, new_nick, self); + const bool self = channel->get_self()->nick == old_nick; + const char user_mode = user->get_most_significant_mode(this->sorted_user_modes); + this->bridge->send_nick_change(std::move(iid), old_nick, new_nick, user_mode, self); user->nick = new_nick; if (self) { diff --git a/src/xmpp/xmpp_component.cpp b/src/xmpp/xmpp_component.cpp index bf06101..facdbd4 100644 --- a/src/xmpp/xmpp_component.cpp +++ b/src/xmpp/xmpp_component.cpp @@ -413,7 +413,13 @@ void XmppComponent::send_muc_leave(std::string&& muc_name, std::string&& nick, X this->send_stanza(presence); } -void XmppComponent::send_nick_change(const std::string& muc_name, const std::string& old_nick, const std::string& new_nick, const std::string& jid_to, const bool self) +void XmppComponent::send_nick_change(const std::string& muc_name, + const std::string& old_nick, + const std::string& new_nick, + const std::string& affiliation, + const std::string& role, + const std::string& jid_to, + const bool self) { Stanza presence("presence"); presence["to"] = jid_to; @@ -441,7 +447,7 @@ void XmppComponent::send_nick_change(const std::string& muc_name, const std::str presence.close(); this->send_stanza(presence); - this->send_user_join(muc_name, new_nick, "", "", "", jid_to, self); + this->send_user_join(muc_name, new_nick, "", affiliation, role, jid_to, self); } void XmppComponent::kick_user(const std::string& muc_name, diff --git a/src/xmpp/xmpp_component.hpp b/src/xmpp/xmpp_component.hpp index fb9282b..27a735a 100644 --- a/src/xmpp/xmpp_component.hpp +++ b/src/xmpp/xmpp_component.hpp @@ -97,7 +97,13 @@ public: /** * Indicate that a participant changed his nick */ - void send_nick_change(const std::string& muc_name, const std::string& old_nick, const std::string& new_nick, const std::string& jid_to, const bool self); + void send_nick_change(const std::string& muc_name, + const std::string& old_nick, + const std::string& new_nick, + const std::string& affiliation, + const std::string& role, + const std::string& jid_to, + const bool self); /** * An user is kicked from a room */ |