From 9f7782bb0c5915969fd7477e0ed7c10b1a5c2d9c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?louiz=E2=80=99?= Date: Thu, 6 Jul 2017 22:24:42 +0200 Subject: =?UTF-8?q?Add=20a=20global=20=E2=80=9Cpersistent=E2=80=9D=20optio?= =?UTF-8?q?n?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/bridge/bridge.cpp | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'src/bridge') diff --git a/src/bridge/bridge.cpp b/src/bridge/bridge.cpp index 23ecfe9..81ca147 100644 --- a/src/bridge/bridge.cpp +++ b/src/bridge/bridge.cpp @@ -436,9 +436,14 @@ void Bridge::leave_irc_channel(Iid&& iid, const std::string& status_message, con // acknowledgment from the server bool persistent = false; #ifdef USE_DATABASE - const auto coptions = Database::get_irc_channel_options_with_server_default(this->user_jid, - iid.get_server(), iid.get_local()); - persistent = coptions.col(); + const auto goptions = Database::get_global_options(this->user_jid); + if (goptions.col()) + persistent = true; + else + { + const auto coptions = Database::get_irc_channel_options_with_server_default(this->user_jid, iid.get_server(), iid.get_local()); + persistent = coptions.col(); + } #endif if (channel->joined && !channel->parting && !persistent) { -- cgit v1.2.3 From faed8952cb6ba063e5424364df69cef193fb736e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?louiz=E2=80=99?= Date: Sat, 8 Jul 2017 14:04:35 +0200 Subject: Remove a bunch of useless string_literal usage --- src/bridge/bridge.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'src/bridge') diff --git a/src/bridge/bridge.cpp b/src/bridge/bridge.cpp index 81ca147..f4c7412 100644 --- a/src/bridge/bridge.cpp +++ b/src/bridge/bridge.cpp @@ -378,7 +378,7 @@ void Bridge::forward_affiliation_role_change(const Iid& iid, const std::string& } else if (message.command == "472" && message.arguments.size() >= 2) { - std::string error_message = "Unknown mode: "s + message.arguments[1]; + std::string error_message = "Unknown mode: " + message.arguments[1]; if (message.arguments.size() >= 3) error_message = message.arguments[2]; this->xmpp.send_stanza_error("iq", from, std::to_string(iid), id, "cancel", "not-allowed", @@ -465,7 +465,7 @@ void Bridge::leave_irc_channel(Iid&& iid, const std::string& status_message, con { if (channel && channel->joined) this->send_muc_leave(iid, channel->get_self()->nick, - "Biboumi note: "s + std::to_string(resources - 1) + " resources are still in this channel.", + "Biboumi note: " + std::to_string(resources - 1) + " resources are still in this channel.", true, resource); this->remove_resource_from_chan(key, resource); if (this->number_of_channels_the_resource_is_in(iid.get_server(), resource) == 0) @@ -702,12 +702,12 @@ void Bridge::send_xmpp_version_to_irc(const Iid& iid, const std::string& name, c { std::string result(name + " " + version + " " + os); - this->send_private_message(iid, "\01VERSION "s + result + "\01", "NOTICE"); + this->send_private_message(iid, "\01VERSION " + result + "\01", "NOTICE"); } void Bridge::send_irc_ping_result(const Iid& iid, const std::string& id) { - this->send_private_message(iid, "\01PING "s + utils::revstr(id) + "\01", "NOTICE"); + this->send_private_message(iid, "\01PING " + utils::revstr(id) + "\01", "NOTICE"); } void Bridge::send_irc_user_ping_request(const std::string& irc_hostname, const std::string& nick, @@ -923,7 +923,7 @@ void Bridge::send_xmpp_message(const std::string& from, const std::string& autho if (!author.empty()) { IrcUser user(author); - body = "\u000303"s + user.nick + (user.host.empty()? + body = "\u000303" + user.nick + (user.host.empty()? "\u0003: ": (" (\u000310" + user.host + "\u000303)\u0003: ")) + msg; } -- cgit v1.2.3 From 9fa1852c7ea094086f45e840fa22cc83d56b744e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?louiz=E2=80=99?= Date: Sat, 8 Jul 2017 18:10:47 +0200 Subject: =?UTF-8?q?Send=20status=20code=3D'332'=20on=20biboumi=20or=20IRC?= =?UTF-8?q?=20server=E2=80=99s=20shutdown?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/bridge/bridge.cpp | 9 +++++---- src/bridge/bridge.hpp | 5 ++++- 2 files changed, 9 insertions(+), 5 deletions(-) (limited to 'src/bridge') diff --git a/src/bridge/bridge.cpp b/src/bridge/bridge.cpp index f4c7412..89a0af3 100644 --- a/src/bridge/bridge.cpp +++ b/src/bridge/bridge.cpp @@ -455,7 +455,7 @@ void Bridge::leave_irc_channel(Iid&& iid, const std::string& status_message, con } else if (channel->joined) { - this->send_muc_leave(iid, channel->get_self()->nick, "", true, resource); + this->send_muc_leave(iid, channel->get_self()->nick, "", true, true, resource); } // Since there are no resources left in that channel, we don't // want to receive private messages using this room's JID @@ -466,7 +466,7 @@ void Bridge::leave_irc_channel(Iid&& iid, const std::string& status_message, con if (channel && channel->joined) this->send_muc_leave(iid, channel->get_self()->nick, "Biboumi note: " + std::to_string(resources - 1) + " resources are still in this channel.", - true, resource); + true, true, resource); this->remove_resource_from_chan(key, resource); if (this->number_of_channels_the_resource_is_in(iid.get_server(), resource) == 0) this->remove_resource_from_server(iid.get_server(), resource); @@ -883,16 +883,17 @@ void Bridge::send_presence_error(const Iid& iid, const std::string& nick, void Bridge::send_muc_leave(const Iid& iid, const std::string& nick, const std::string& message, const bool self, + const bool user_requested, const std::string& resource) { if (!resource.empty()) this->xmpp.send_muc_leave(std::to_string(iid), nick, this->make_xmpp_body(message), - this->user_jid + "/" + resource, self); + this->user_jid + "/" + resource, self, user_requested); else { for (const auto &res: this->resources_in_chan[iid.to_tuple()]) this->xmpp.send_muc_leave(std::to_string(iid), nick, this->make_xmpp_body(message), - this->user_jid + "/" + res, self); + this->user_jid + "/" + res, self, user_requested); if (self) this->remove_all_resources_from_chan(iid.to_tuple()); diff --git a/src/bridge/bridge.hpp b/src/bridge/bridge.hpp index 033291c..496b439 100644 --- a/src/bridge/bridge.hpp +++ b/src/bridge/bridge.hpp @@ -169,7 +169,10 @@ public: /** * Send an unavailable presence from this participant */ - void send_muc_leave(const Iid& iid, const std::string& nick, const std::string& message, const bool self, const std::string& resource = ""); + void send_muc_leave(const Iid& iid, const std::string& nick, + const std::string& message, const bool self, + const bool user_requested, + const std::string& resource=""); /** * Send presences to indicate that an user old_nick (ourself if self == * true) changed his nick to new_nick. The user_mode is needed because -- cgit v1.2.3 From 8232c2cccc07f78a573f4bc39841f9b20693d8db Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?louiz=E2=80=99?= Date: Sat, 8 Jul 2017 19:21:53 +0200 Subject: Remove an unused variable --- src/bridge/bridge.cpp | 1 - 1 file changed, 1 deletion(-) (limited to 'src/bridge') diff --git a/src/bridge/bridge.cpp b/src/bridge/bridge.cpp index 89a0af3..27726e4 100644 --- a/src/bridge/bridge.cpp +++ b/src/bridge/bridge.cpp @@ -856,7 +856,6 @@ void Bridge::send_message(const Iid& iid, const std::string& nick, const std::st } else { - std::string target = std::to_string(iid); const auto it = this->preferred_user_from.find(iid.get_local()); if (it != this->preferred_user_from.end()) { -- cgit v1.2.3 From f9a6f973966430b108642ac57d54db5fd0d5535e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?louiz=E2=80=99?= Date: Tue, 4 Jul 2017 20:42:40 +0200 Subject: Implement the roster presences from IRC servers --- src/bridge/bridge.cpp | 10 ++++++++++ src/bridge/bridge.hpp | 4 +++- 2 files changed, 13 insertions(+), 1 deletion(-) (limited to 'src/bridge') diff --git a/src/bridge/bridge.cpp b/src/bridge/bridge.cpp index 27726e4..33006c3 100644 --- a/src/bridge/bridge.cpp +++ b/src/bridge/bridge.cpp @@ -1081,6 +1081,16 @@ void Bridge::send_xmpp_invitation(const Iid& iid, const std::string& author) this->xmpp.send_invitation(std::to_string(iid), this->user_jid + "/" + resource, author); } +void Bridge::on_irc_client_connected(const std::string& hostname) +{ + this->xmpp.on_irc_client_connected(hostname, this->user_jid); +} + +void Bridge::on_irc_client_disconnected(const std::string& hostname) +{ + this->xmpp.on_irc_client_disconnected(hostname, this->user_jid); +} + void Bridge::set_preferred_from_jid(const std::string& nick, const std::string& full_jid) { auto it = this->preferred_user_from.find(nick); diff --git a/src/bridge/bridge.hpp b/src/bridge/bridge.hpp index 496b439..c10631b 100644 --- a/src/bridge/bridge.hpp +++ b/src/bridge/bridge.hpp @@ -201,6 +201,8 @@ public: void send_xmpp_ping_request(const std::string& nick, const std::string& hostname, const std::string& id); void send_xmpp_invitation(const Iid& iid, const std::string& author); + void on_irc_client_connected(const std::string& hostname); + void on_irc_client_disconnected(const std::string& hostname); /** * Misc @@ -301,8 +303,8 @@ private: using ChannelKey = std::tuple; public: std::map> resources_in_chan; -private: std::map> resources_in_server; +private: /** * Manage which resource is in which channel */ -- cgit v1.2.3 From f7cbe8531dd6bd2f91718ac14a564e21d6a0ef11 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?louiz=E2=80=99?= Date: Sun, 16 Jul 2017 20:20:38 +0200 Subject: Correctly remove the last resource from the channel, in persistent mode fix #3277 --- src/bridge/bridge.cpp | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src/bridge') diff --git a/src/bridge/bridge.cpp b/src/bridge/bridge.cpp index 33006c3..e0cb36d 100644 --- a/src/bridge/bridge.cpp +++ b/src/bridge/bridge.cpp @@ -457,6 +457,8 @@ void Bridge::leave_irc_channel(Iid&& iid, const std::string& status_message, con { this->send_muc_leave(iid, channel->get_self()->nick, "", true, true, resource); } + if (persistent) + this->remove_resource_from_chan(key, resource); // Since there are no resources left in that channel, we don't // want to receive private messages using this room's JID this->remove_all_preferred_from_jid_of_room(iid.get_local()); -- cgit v1.2.3