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/xmpp/biboumi_adhoc_commands.cpp | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'src/xmpp') diff --git a/src/xmpp/biboumi_adhoc_commands.cpp b/src/xmpp/biboumi_adhoc_commands.cpp index ad4faf8..c1b7323 100644 --- a/src/xmpp/biboumi_adhoc_commands.cpp +++ b/src/xmpp/biboumi_adhoc_commands.cpp @@ -147,6 +147,21 @@ void ConfigureGlobalStep1(XmppComponent&, AdhocSession& session, XmlNode& comman else value.set_inner("false"); } + + XmlSubNode persistent(x, "field"); + persistent["var"] = "persistent"; + persistent["type"] = "boolean"; + persistent["label"] = "Make all channels persistent"; + persistent["desc"] = "If true, all channels will be persistent"; + + { + XmlSubNode value(persistent, "value"); + value.set_name("value"); + if (options.col()) + value.set_inner("true"); + else + value.set_inner("false"); + } } void ConfigureGlobalStep2(XmppComponent& xmpp_component, AdhocSession& session, XmlNode& command_node) @@ -173,6 +188,9 @@ void ConfigureGlobalStep2(XmppComponent& xmpp_component, AdhocSession& session, if (bridge) bridge->set_record_history(options.col()); } + else if (field->get_tag("var") == "persistent" && + value) + options.col() = to_bool(value->get_inner()); } options.save(Database::db); -- cgit v1.2.3 From 43b5b696a311e1dbaa2623284eed042b4ca24dc5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?louiz=E2=80=99?= Date: Thu, 6 Jul 2017 22:38:09 +0200 Subject: Add some scopes around various XmlSubNode --- src/xmpp/biboumi_adhoc_commands.cpp | 364 +++++++++++++++++++----------------- 1 file changed, 196 insertions(+), 168 deletions(-) (limited to 'src/xmpp') diff --git a/src/xmpp/biboumi_adhoc_commands.cpp b/src/xmpp/biboumi_adhoc_commands.cpp index c1b7323..4129517 100644 --- a/src/xmpp/biboumi_adhoc_commands.cpp +++ b/src/xmpp/biboumi_adhoc_commands.cpp @@ -122,45 +122,48 @@ void ConfigureGlobalStep1(XmppComponent&, AdhocSession& session, XmlNode& comman XmlSubNode instructions(x, "instructions"); instructions.set_inner("Edit the form, to configure your global settings for the component."); - XmlSubNode max_histo_length(x, "field"); - max_histo_length["var"] = "max_history_length"; - max_histo_length["type"] = "text-single"; - max_histo_length["label"] = "Max history length"; - max_histo_length["desc"] = "The maximum number of lines in the history that the server sends when joining a channel"; - { - XmlSubNode value(max_histo_length, "value"); - value.set_inner(std::to_string(options.col())); + XmlSubNode max_histo_length(x, "field"); + max_histo_length["var"] = "max_history_length"; + max_histo_length["type"] = "text-single"; + max_histo_length["label"] = "Max history length"; + max_histo_length["desc"] = "The maximum number of lines in the history that the server sends when joining a channel"; + { + XmlSubNode value(max_histo_length, "value"); + value.set_inner(std::to_string(options.col())); + } } - XmlSubNode record_history(x, "field"); - record_history["var"] = "record_history"; - record_history["type"] = "boolean"; - record_history["label"] = "Record history"; - record_history["desc"] = "Whether to save the messages into the database, or not"; - { - XmlSubNode value(record_history, "value"); - value.set_name("value"); - if (options.col()) - value.set_inner("true"); - else - value.set_inner("false"); + XmlSubNode record_history(x, "field"); + record_history["var"] = "record_history"; + record_history["type"] = "boolean"; + record_history["label"] = "Record history"; + record_history["desc"] = "Whether to save the messages into the database, or not"; + { + XmlSubNode value(record_history, "value"); + value.set_name("value"); + if (options.col()) + value.set_inner("true"); + else + value.set_inner("false"); + } } - XmlSubNode persistent(x, "field"); - persistent["var"] = "persistent"; - persistent["type"] = "boolean"; - persistent["label"] = "Make all channels persistent"; - persistent["desc"] = "If true, all channels will be persistent"; - { - XmlSubNode value(persistent, "value"); - value.set_name("value"); - if (options.col()) - value.set_inner("true"); - else - value.set_inner("false"); + XmlSubNode persistent(x, "field"); + persistent["var"] = "persistent"; + persistent["type"] = "boolean"; + persistent["label"] = "Make all channels persistent"; + persistent["desc"] = "If true, all channels will be persistent"; + { + XmlSubNode value(persistent, "value"); + value.set_name("value"); + if (options.col()) + value.set_inner("true"); + else + value.set_inner("false"); + } } } @@ -224,96 +227,112 @@ void ConfigureIrcServerStep1(XmppComponent&, AdhocSession& session, XmlNode& com XmlSubNode instructions(x, "instructions"); instructions.set_inner("Edit the form, to configure the settings of the IRC server "s + server_domain); - XmlSubNode ports(x, "field"); - ports["var"] = "ports"; - ports["type"] = "text-multi"; - ports["label"] = "Ports"; - ports["desc"] = "List of ports to try, without TLS. Defaults: 6667."; - for (const auto& val: utils::split(options.col(), ';', false)) - { - XmlSubNode ports_value(ports, "value"); - ports_value.set_inner(val); - } + { + XmlSubNode ports(x, "field"); + ports["var"] = "ports"; + ports["type"] = "text-multi"; + ports["label"] = "Ports"; + ports["desc"] = "List of ports to try, without TLS. Defaults: 6667."; + for (const auto& val: utils::split(options.col(), ';', false)) + { + XmlSubNode ports_value(ports, "value"); + ports_value.set_inner(val); + } + } #ifdef BOTAN_FOUND - XmlSubNode tls_ports(x, "field"); - tls_ports["var"] = "tls_ports"; - tls_ports["type"] = "text-multi"; - tls_ports["label"] = "TLS ports"; - tls_ports["desc"] = "List of ports to try, with TLS. Defaults: 6697, 6670."; - for (const auto& val: utils::split(options.col(), ';', false)) - { - XmlSubNode tls_ports_value(tls_ports, "value"); - tls_ports_value.set_inner(val); - } + { + XmlSubNode tls_ports(x, "field"); + tls_ports["var"] = "tls_ports"; + tls_ports["type"] = "text-multi"; + tls_ports["label"] = "TLS ports"; + tls_ports["desc"] = "List of ports to try, with TLS. Defaults: 6697, 6670."; + for (const auto& val: utils::split(options.col(), ';', false)) + { + XmlSubNode tls_ports_value(tls_ports, "value"); + tls_ports_value.set_inner(val); + } + } - XmlSubNode verify_cert(x, "field"); - verify_cert["var"] = "verify_cert"; - verify_cert["type"] = "boolean"; - verify_cert["label"] = "Verify certificate"; - verify_cert["desc"] = "Whether or not to abort the connection if the server’s TLS certificate is invalid"; - XmlSubNode verify_cert_value(verify_cert, "value"); - if (options.col()) - verify_cert_value.set_inner("true"); - else - verify_cert_value.set_inner("false"); + { + XmlSubNode verify_cert(x, "field"); + verify_cert["var"] = "verify_cert"; + verify_cert["type"] = "boolean"; + verify_cert["label"] = "Verify certificate"; + verify_cert["desc"] = "Whether or not to abort the connection if the server’s TLS certificate is invalid"; + XmlSubNode verify_cert_value(verify_cert, "value"); + if (options.col()) + verify_cert_value.set_inner("true"); + else + verify_cert_value.set_inner("false"); + } - XmlSubNode fingerprint(x, "field"); - fingerprint["var"] = "fingerprint"; - fingerprint["type"] = "text-single"; - fingerprint["label"] = "SHA-1 fingerprint of the TLS certificate to trust."; - if (!options.col().empty()) - { - XmlSubNode fingerprint_value(fingerprint, "value"); - fingerprint_value.set_inner(options.col()); - } + { + XmlSubNode fingerprint(x, "field"); + fingerprint["var"] = "fingerprint"; + fingerprint["type"] = "text-single"; + fingerprint["label"] = "SHA-1 fingerprint of the TLS certificate to trust."; + if (!options.col().empty()) + { + XmlSubNode fingerprint_value(fingerprint, "value"); + fingerprint_value.set_inner(options.col()); + } + } #endif + { + XmlSubNode pass(x, "field"); + pass["var"] = "pass"; + pass["type"] = "text-private"; + pass["label"] = "Server password"; + pass["desc"] = "Will be used in a PASS command when connecting"; + if (!options.col().empty()) + { + XmlSubNode pass_value(pass, "value"); + pass_value.set_inner(options.col()); + } + } - XmlSubNode pass(x, "field"); - pass["var"] = "pass"; - pass["type"] = "text-private"; - pass["label"] = "Server password"; - pass["desc"] = "Will be used in a PASS command when connecting"; - if (!options.col().empty()) - { - XmlSubNode pass_value(pass, "value"); - pass_value.set_inner(options.col()); - } - - XmlSubNode after_cnt_cmd(x, "field"); - after_cnt_cmd["var"] = "after_connect_command"; - after_cnt_cmd["type"] = "text-single"; - after_cnt_cmd["desc"] = "Custom IRC command sent after the connection is established with the server."; - after_cnt_cmd["label"] = "After-connection IRC command"; - if (!options.col().empty()) - { - XmlSubNode after_cnt_cmd_value(after_cnt_cmd, "value"); - after_cnt_cmd_value.set_inner(options.col()); - } + { + XmlSubNode after_cnt_cmd(x, "field"); + after_cnt_cmd["var"] = "after_connect_command"; + after_cnt_cmd["type"] = "text-single"; + after_cnt_cmd["desc"] = "Custom IRC command sent after the connection is established with the server."; + after_cnt_cmd["label"] = "After-connection IRC command"; + if (!options.col().empty()) + { + XmlSubNode after_cnt_cmd_value(after_cnt_cmd, "value"); + after_cnt_cmd_value.set_inner(options.col()); + } + } if (Config::get("realname_customization", "true") == "true") { - XmlSubNode username(x, "field"); - username["var"] = "username"; - username["type"] = "text-single"; - username["label"] = "Username"; - if (!options.col().empty()) - { - XmlSubNode username_value(username, "value"); - username_value.set_inner(options.col()); - } - - XmlSubNode realname(x, "field"); - realname["var"] = "realname"; - realname["type"] = "text-single"; - realname["label"] = "Realname"; - if (!options.col().empty()) - { - XmlSubNode realname_value(realname, "value"); - realname_value.set_inner(options.col()); - } + { + XmlSubNode username(x, "field"); + username["var"] = "username"; + username["type"] = "text-single"; + username["label"] = "Username"; + if (!options.col().empty()) + { + XmlSubNode username_value(username, "value"); + username_value.set_inner(options.col()); + } + } + + { + XmlSubNode realname(x, "field"); + realname["var"] = "realname"; + realname["type"] = "text-single"; + realname["label"] = "Realname"; + if (!options.col().empty()) + { + XmlSubNode realname_value(realname, "value"); + realname_value.set_inner(options.col()); + } + } } + { XmlSubNode encoding_out(x, "field"); encoding_out["var"] = "encoding_out"; encoding_out["type"] = "text-single"; @@ -324,17 +343,20 @@ void ConfigureIrcServerStep1(XmppComponent&, AdhocSession& session, XmlNode& com XmlSubNode encoding_out_value(encoding_out, "value"); encoding_out_value.set_inner(options.col()); } + } - XmlSubNode encoding_in(x, "field"); - encoding_in["var"] = "encoding_in"; - encoding_in["type"] = "text-single"; - encoding_in["desc"] = "The encoding used to decode message received from the IRC server."; - encoding_in["label"] = "In encoding"; - if (!options.col().empty()) - { - XmlSubNode encoding_in_value(encoding_in, "value"); - encoding_in_value.set_inner(options.col()); - } + { + XmlSubNode encoding_in(x, "field"); + encoding_in["var"] = "encoding_in"; + encoding_in["type"] = "text-single"; + encoding_in["desc"] = "The encoding used to decode message received from the IRC server."; + encoding_in["label"] = "In encoding"; + if (!options.col().empty()) + { + XmlSubNode encoding_in_value(encoding_in, "value"); + encoding_in_value.set_inner(options.col()); + } + } } void ConfigureIrcServerStep2(XmppComponent&, AdhocSession& session, XmlNode& command_node) @@ -444,7 +466,6 @@ void insert_irc_channel_configuration_form(XmlNode& node, const Jid& requester, auto options = Database::get_irc_channel_options_with_server_default(requester.local + "@" + requester.domain, iid.get_server(), iid.get_local()); - XmlSubNode x(node, "jabber:x:data:x"); x["type"] = "form"; XmlSubNode title(x, "title"); @@ -452,60 +473,67 @@ void insert_irc_channel_configuration_form(XmlNode& node, const Jid& requester, XmlSubNode instructions(x, "instructions"); instructions.set_inner("Edit the form, to configure the settings of the IRC channel "s + iid.get_local()); - XmlSubNode record_history(x, "field"); - record_history["var"] = "record_history"; - record_history["type"] = "list-single"; - record_history["label"] = "Record history for this channel"; - record_history["desc"] = "If unset, the value is the one configured globally"; - { - // Value selected by default - XmlSubNode value(record_history, "value"); - value.set_inner(options.col().to_string()); + XmlSubNode record_history(x, "field"); + record_history["var"] = "record_history"; + record_history["type"] = "list-single"; + record_history["label"] = "Record history for this channel"; + record_history["desc"] = "If unset, the value is the one configured globally"; + { + // Value selected by default + XmlSubNode value(record_history, "value"); + value.set_inner(options.col().to_string()); + } + // All three possible values + for (const auto& val: {"unset", "true", "false"}) + { + XmlSubNode option(record_history, "option"); + option["label"] = val; + XmlSubNode value(option, "value"); + value.set_inner(val); + } } - // All three possible values - for (const auto& val: {"unset", "true", "false"}) + { - XmlSubNode option(record_history, "option"); - option["label"] = val; - XmlSubNode value(option, "value"); - value.set_inner(val); + XmlSubNode encoding_out(x, "field"); + encoding_out["var"] = "encoding_out"; + encoding_out["type"] = "text-single"; + encoding_out["desc"] = "The encoding used when sending messages to the IRC server. Defaults to the server's “out encoding” if unset for the channel"; + encoding_out["label"] = "Out encoding"; + if (!options.col().empty()) + { + XmlSubNode encoding_out_value(encoding_out, "value"); + encoding_out_value.set_inner(options.col()); + } } - XmlSubNode encoding_out(x, "field"); - encoding_out["var"] = "encoding_out"; - encoding_out["type"] = "text-single"; - encoding_out["desc"] = "The encoding used when sending messages to the IRC server. Defaults to the server's “out encoding” if unset for the channel"; - encoding_out["label"] = "Out encoding"; - if (!options.col().empty()) - { - XmlSubNode encoding_out_value(encoding_out, "value"); - encoding_out_value.set_inner(options.col()); - } + { + XmlSubNode encoding_in(x, "field"); + encoding_in["var"] = "encoding_in"; + encoding_in["type"] = "text-single"; + encoding_in["desc"] = "The encoding used to decode message received from the IRC server. Defaults to the server's “in encoding” if unset for the channel"; + encoding_in["label"] = "In encoding"; + if (!options.col().empty()) + { + XmlSubNode encoding_in_value(encoding_in, "value"); + encoding_in_value.set_inner(options.col()); + } + } - XmlSubNode encoding_in(x, "field"); - encoding_in["var"] = "encoding_in"; - encoding_in["type"] = "text-single"; - encoding_in["desc"] = "The encoding used to decode message received from the IRC server. Defaults to the server's “in encoding” if unset for the channel"; - encoding_in["label"] = "In encoding"; - if (!options.col().empty()) + { + XmlSubNode persistent(x, "field"); + persistent["var"] = "persistent"; + persistent["type"] = "boolean"; + persistent["desc"] = "If set to true, when all XMPP clients have left this channel, biboumi will stay idle in it, without sending a PART command."; + persistent["label"] = "Persistent"; { - XmlSubNode encoding_in_value(encoding_in, "value"); - encoding_in_value.set_inner(options.col()); + XmlSubNode value(persistent, "value"); + value.set_name("value"); + if (options.col()) + value.set_inner("true"); + else + value.set_inner("false"); } - - XmlSubNode persistent(x, "field"); - persistent["var"] = "persistent"; - persistent["type"] = "boolean"; - persistent["desc"] = "If set to true, when all XMPP clients have left this channel, biboumi will stay idle in it, without sending a PART command."; - persistent["label"] = "Persistent"; - { - XmlSubNode value(persistent, "value"); - value.set_name("value"); - if (options.col()) - value.set_inner("true"); - else - value.set_inner("false"); } } -- 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/xmpp/adhoc_command.cpp | 2 +- src/xmpp/adhoc_commands_handler.cpp | 8 ++++---- src/xmpp/biboumi_adhoc_commands.cpp | 12 ++++++------ src/xmpp/biboumi_component.cpp | 10 +++++----- src/xmpp/xmpp_component.cpp | 6 +++--- 5 files changed, 19 insertions(+), 19 deletions(-) (limited to 'src/xmpp') diff --git a/src/xmpp/adhoc_command.cpp b/src/xmpp/adhoc_command.cpp index e02bf35..fbf4ce2 100644 --- a/src/xmpp/adhoc_command.cpp +++ b/src/xmpp/adhoc_command.cpp @@ -59,7 +59,7 @@ void HelloStep2(XmppComponent&, AdhocSession& session, XmlNode& command_node) command_node.delete_all_children(); XmlSubNode note(command_node, "note"); note["type"] = "info"; - note.set_inner("Hello "s + value_str + "!"s); + note.set_inner("Hello " + value_str + "!"s); return; } } diff --git a/src/xmpp/adhoc_commands_handler.cpp b/src/xmpp/adhoc_commands_handler.cpp index 040d0ff..e4dcd5c 100644 --- a/src/xmpp/adhoc_commands_handler.cpp +++ b/src/xmpp/adhoc_commands_handler.cpp @@ -19,7 +19,7 @@ void AdhocCommandsHandler::add_command(std::string name, AdhocCommand command) { const auto found = this->commands.find(name); if (found != this->commands.end()) - throw std::runtime_error("Trying to add an ad-hoc command that already exist: "s + name); + throw std::runtime_error("Trying to add an ad-hoc command that already exist: " + name); this->commands.emplace(std::make_pair(std::move(name), std::move(command))); } @@ -59,7 +59,7 @@ XmlNode AdhocCommandsHandler::handle_request(const std::string& executor_jid, co std::forward_as_tuple(command_it->second, executor_jid, to)); TimedEventsManager::instance().add_event(TimedEvent(std::chrono::steady_clock::now() + 3600s, std::bind(&AdhocCommandsHandler::remove_session, this, sessionid, executor_jid), - "adhocsession"s + sessionid + executor_jid)); + "adhocsession" + sessionid + executor_jid)); } auto session_it = this->sessions.find(std::make_pair(sessionid, executor_jid)); if ((session_it != this->sessions.end()) && @@ -74,7 +74,7 @@ XmlNode AdhocCommandsHandler::handle_request(const std::string& executor_jid, co { this->sessions.erase(session_it); command_node["status"] = "completed"; - TimedEventsManager::instance().cancel("adhocsession"s + sessionid + executor_jid); + TimedEventsManager::instance().cancel("adhocsession" + sessionid + executor_jid); } else { @@ -87,7 +87,7 @@ XmlNode AdhocCommandsHandler::handle_request(const std::string& executor_jid, co { this->sessions.erase(session_it); command_node["status"] = "canceled"; - TimedEventsManager::instance().cancel("adhocsession"s + sessionid + executor_jid); + TimedEventsManager::instance().cancel("adhocsession" + sessionid + executor_jid); } else // unsupported action { diff --git a/src/xmpp/biboumi_adhoc_commands.cpp b/src/xmpp/biboumi_adhoc_commands.cpp index 4129517..27b079b 100644 --- a/src/xmpp/biboumi_adhoc_commands.cpp +++ b/src/xmpp/biboumi_adhoc_commands.cpp @@ -223,9 +223,9 @@ void ConfigureIrcServerStep1(XmppComponent&, AdhocSession& session, XmlNode& com XmlSubNode x(command_node, "jabber:x:data:x"); x["type"] = "form"; XmlSubNode title(x, "title"); - title.set_inner("Configure the IRC server "s + server_domain); + title.set_inner("Configure the IRC server " + server_domain); XmlSubNode instructions(x, "instructions"); - instructions.set_inner("Edit the form, to configure the settings of the IRC server "s + server_domain); + instructions.set_inner("Edit the form, to configure the settings of the IRC server " + server_domain); { XmlSubNode ports(x, "field"); @@ -469,9 +469,9 @@ void insert_irc_channel_configuration_form(XmlNode& node, const Jid& requester, XmlSubNode x(node, "jabber:x:data:x"); x["type"] = "form"; XmlSubNode title(x, "title"); - title.set_inner("Configure the IRC channel "s + iid.get_local() + " on server "s + iid.get_server()); + title.set_inner("Configure the IRC channel " + iid.get_local() + " on server " + iid.get_server()); XmlSubNode instructions(x, "instructions"); - instructions.set_inner("Edit the form, to configure the settings of the IRC channel "s + iid.get_local()); + instructions.set_inner("Edit the form, to configure the settings of the IRC channel " + iid.get_local()); { XmlSubNode record_history(x, "field"); @@ -693,7 +693,7 @@ void DisconnectUserFromServerStep2(XmppComponent& xmpp_component, AdhocSession& { XmlSubNode note(command_node, "note"); note["type"] = "info"; - note.set_inner("User "s + jid_to_disconnect + " is not connected to any IRC server."); + note.set_inner("User " + jid_to_disconnect + " is not connected to any IRC server."); session.terminate(); return ; } @@ -797,7 +797,7 @@ void GetIrcConnectionInfoStep1(XmppComponent& component, AdhocSession& session, IrcClient* irc = bridge->find_irc_client(hostname); if (!irc || !irc->is_connected()) { - message = "You are not connected to the IRC server "s + hostname; + message = "You are not connected to the IRC server " + hostname; return; } diff --git a/src/xmpp/biboumi_component.cpp b/src/xmpp/biboumi_component.cpp index 32f3968..1c7cd92 100644 --- a/src/xmpp/biboumi_component.cpp +++ b/src/xmpp/biboumi_component.cpp @@ -177,7 +177,7 @@ void BiboumiComponent::handle_presence(const Stanza& stanza) if (type != "unavailable") this->send_stanza_error("presence", from_str, to_str, id, "cancel", "remote-server-not-found", - "Not connected to IRC server "s + ex.hostname, + "Not connected to IRC server " + ex.hostname, true); } stanza_error.disable(); @@ -277,7 +277,7 @@ void BiboumiComponent::handle_message(const Stanza& stanza) { this->send_stanza_error("message", from_str, to_str, id, "cancel", "remote-server-not-found", - "Not connected to IRC server "s + ex.hostname, + "Not connected to IRC server " + ex.hostname, true); } stanza_error.disable(); @@ -586,7 +586,7 @@ void BiboumiComponent::handle_iq(const Stanza& stanza) { this->send_stanza_error("iq", from, to_str, id, "cancel", "remote-server-not-found", - "Not connected to IRC server "s + ex.hostname, + "Not connected to IRC server " + ex.hostname, true); stanza_error.disable(); return; @@ -806,7 +806,7 @@ void BiboumiComponent::send_irc_server_disco_info(const std::string& id, const s XmlSubNode identity(query, "identity"); identity["category"] = "conference"; identity["type"] = "irc"; - identity["name"] = "IRC server "s + from.local + " over Biboumi"; + identity["name"] = "IRC server " + from.local + " over Biboumi"; for (const char *ns: {DISCO_INFO_NS, MUC_NS, ADHOC_NS, PING_NS, MAM_NS, VERSION_NS}) { XmlSubNode feature(query, "feature"); @@ -849,7 +849,7 @@ void BiboumiComponent::send_irc_channel_disco_info(const std::string& id, const XmlSubNode identity(query, "identity"); identity["category"] = "conference"; identity["type"] = "irc"; - identity["name"] = "IRC channel "s + iid.get_local() + " from server " + iid.get_server() + " over biboumi"; + identity["name"] = "IRC channel " + iid.get_local() + " from server " + iid.get_server() + " over biboumi"; for (const char *ns: {DISCO_INFO_NS, MUC_NS, ADHOC_NS, PING_NS, MAM_NS, VERSION_NS}) { XmlSubNode feature(query, "feature"); diff --git a/src/xmpp/xmpp_component.cpp b/src/xmpp/xmpp_component.cpp index b138ed9..3c69b36 100644 --- a/src/xmpp/xmpp_component.cpp +++ b/src/xmpp/xmpp_component.cpp @@ -92,7 +92,7 @@ void XmppComponent::on_connected() { log_info("connected to XMPP server"); this->first_connection_try = true; - auto data = "served_hostname + \ "' xmlns:stream='http://etherx.jabber.org/streams' xmlns='" COMPONENT_NS "'>"; log_debug("XMPP SENDING: ", data); this->send_data(std::move(data)); @@ -142,7 +142,7 @@ void XmppComponent::on_remote_stream_open(const XmlNode& node) } // Try to authenticate - auto data = ""s + get_handshake_digest(this->stream_id, this->secret) + ""; + auto data = "" + get_handshake_digest(this->stream_id, this->secret) + ""; log_debug("XMPP SENDING: ", data); this->send_data(std::move(data)); } @@ -642,7 +642,7 @@ void XmppComponent::send_iq_version_request(const std::string& from, Stanza iq("iq"); { iq["type"] = "get"; - iq["id"] = "version_"s + XmppComponent::next_id(); + iq["id"] = "version_" + XmppComponent::next_id(); iq["from"] = from + "@" + this->served_hostname; iq["to"] = jid_to; XmlSubNode query(iq, "query"); -- 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/xmpp/xmpp_component.cpp | 8 +++++++- src/xmpp/xmpp_component.hpp | 7 ++++++- 2 files changed, 13 insertions(+), 2 deletions(-) (limited to 'src/xmpp') diff --git a/src/xmpp/xmpp_component.cpp b/src/xmpp/xmpp_component.cpp index 3c69b36..7366422 100644 --- a/src/xmpp/xmpp_component.cpp +++ b/src/xmpp/xmpp_component.cpp @@ -441,7 +441,8 @@ void XmppComponent::send_history_message(const std::string& muc_name, const std: this->send_stanza(message); } -void XmppComponent::send_muc_leave(const std::string& muc_name, const std::string& nick, Xmpp::body&& message, const std::string& jid_to, const bool self) +void XmppComponent::send_muc_leave(const std::string& muc_name, const std::string& nick, Xmpp::body&& message, + const std::string& jid_to, const bool self, const bool user_requested) { Stanza presence("presence"); { @@ -456,6 +457,11 @@ void XmppComponent::send_muc_leave(const std::string& muc_name, const std::strin XmlSubNode status(x, "status"); status["code"] = "110"; } + if (!user_requested) + { + XmlSubNode status(x, "status"); + status["code"] = "332"; + } if (!message_str.empty()) { XmlSubNode status(presence, "status"); diff --git a/src/xmpp/xmpp_component.hpp b/src/xmpp/xmpp_component.hpp index ebe3ec8..f4a7655 100644 --- a/src/xmpp/xmpp_component.hpp +++ b/src/xmpp/xmpp_component.hpp @@ -146,7 +146,12 @@ public: /** * Send an unavailable presence for this nick */ - void send_muc_leave(const std::string& muc_name, const std::string& nick, Xmpp::body&& message, const std::string& jid_to, const bool self); + void send_muc_leave(const std::string& muc_name, + const std::string& nick, + Xmpp::body&& message, + const std::string& jid_to, + const bool self, + const bool user_requested); /** * Indicate that a participant changed his nick */ -- cgit v1.2.3 From b2334707107e65dd15590b7472c990bbf79549eb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?louiz=E2=80=99?= Date: Fri, 14 Jul 2017 15:18:01 +0200 Subject: Send the 332 status only for our own presences --- src/xmpp/xmpp_component.cpp | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) (limited to 'src/xmpp') diff --git a/src/xmpp/xmpp_component.cpp b/src/xmpp/xmpp_component.cpp index 7366422..9c3ba90 100644 --- a/src/xmpp/xmpp_component.cpp +++ b/src/xmpp/xmpp_component.cpp @@ -454,13 +454,15 @@ void XmppComponent::send_muc_leave(const std::string& muc_name, const std::strin x["xmlns"] = MUC_USER_NS; if (self) { - XmlSubNode status(x, "status"); - status["code"] = "110"; - } - if (!user_requested) - { - XmlSubNode status(x, "status"); - status["code"] = "332"; + { + XmlSubNode status(x, "status"); + status["code"] = "110"; + } + if (!user_requested) + { + XmlSubNode status(x, "status"); + status["code"] = "332"; + } } if (!message_str.empty()) { -- cgit v1.2.3 From 84034ed3dc19f718dcc93a35dbf4c840a55efb1b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?louiz=E2=80=99?= Date: Fri, 23 Jun 2017 00:16:24 +0200 Subject: =?UTF-8?q?Use=20a=20db=20roster=20to=20manage=20biboumi=E2=80=99s?= =?UTF-8?q?=20presence=20with=20the=20contacts?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/xmpp/biboumi_component.cpp | 61 +++++++++++++++++++++++++++++++++++++++--- src/xmpp/biboumi_component.hpp | 3 +++ 2 files changed, 61 insertions(+), 3 deletions(-) (limited to 'src/xmpp') diff --git a/src/xmpp/biboumi_component.cpp b/src/xmpp/biboumi_component.cpp index 1c7cd92..f3381aa 100644 --- a/src/xmpp/biboumi_component.cpp +++ b/src/xmpp/biboumi_component.cpp @@ -83,6 +83,15 @@ void BiboumiComponent::shutdown() { for (auto& pair: this->bridges) pair.second->shutdown("Gateway shutdown"); +#ifdef USE_DATABASE + const auto full_roster = Database::get_full_roster(); + for (const Database::RosterItem& roster_item: full_roster) + { + this->send_presence_to_contact(roster_item.col(), + roster_item.col(), + "unavailable"); + } +#endif } void BiboumiComponent::clean() @@ -160,10 +169,28 @@ void BiboumiComponent::handle_presence(const Stanza& stanza) { if (type == "subscribe") { // Auto-accept any subscription request for an IRC server - this->accept_subscription(to_str, from.bare()); - this->ask_subscription(to_str, from.bare()); + this->send_presence_to_contact(to_str, from.bare(), "subscribed", id); + if (iid.type == Iid::Type::None) + this->send_presence_to_contact(to_str, from.bare(), ""); + this->send_presence_to_contact(to_str, from.bare(), "subscribe"); +#ifdef USE_DATABASE + if (!Database::has_roster_item(to_str, from.bare())) + Database::add_roster_item(to_str, from.bare()); +#endif + } + else if (type == "unsubscribe") + { +#ifdef USE_DATABASE + const bool res = Database::has_roster_item(to_str, from.bare()); + if (res) + Database::delete_roster_item(to_str, from.bare()); +#endif + } + else if (type.empty()) + { // We just receive a presence from someone (as the result of a probe, + // or a directed presence, or a normal presence change) + this->send_presence_to_contact(to_str, from.bare(), ""); } - } else { @@ -979,3 +1006,31 @@ void BiboumiComponent::ask_subscription(const std::string& from, const std::stri presence["type"] = "subscribe"; this->send_stanza(presence); } + +void BiboumiComponent::send_presence_to_contact(const std::string& from, const std::string& to, + const std::string& type, const std::string& id) +{ + Stanza presence("presence"); + presence["from"] = from; + presence["to"] = to; + if (!type.empty()) + presence["type"] = type; + if (!id.empty()) + presence["id"] = id; + this->send_stanza(presence); +} + +void BiboumiComponent::after_handshake() +{ + XmppComponent::after_handshake(); + +#ifdef USE_DATABASE + const auto contacts = Database::get_contact_list(this->get_served_hostname()); + + for (const Database::RosterItem& roster_item: contacts) + { + const auto remote_jid = roster_item.col(); + this->send_presence_to_contact(this->get_served_hostname(), remote_jid, "probe"); + } +#endif +} diff --git a/src/xmpp/biboumi_component.hpp b/src/xmpp/biboumi_component.hpp index 87311f9..2d67f8b 100644 --- a/src/xmpp/biboumi_component.hpp +++ b/src/xmpp/biboumi_component.hpp @@ -36,6 +36,8 @@ public: BiboumiComponent& operator=(const BiboumiComponent&) = delete; BiboumiComponent& operator=(BiboumiComponent&&) = delete; + void after_handshake() override final; + /** * Returns the bridge for the given user. If it does not exist, return * nullptr. @@ -87,6 +89,7 @@ public: void send_invitation(const std::string& room_target, const std::string& jid_to, const std::string& author_nick); void accept_subscription(const std::string& from, const std::string& to); void ask_subscription(const std::string& from, const std::string& to); + void send_presence_to_contact(const std::string& from, const std::string& to, const std::string& type, const std::string& id=""); /** * Handle the various stanza types */ -- cgit v1.2.3 From 71f125db1a11f4b728beee1d1aa2ef7d37f38000 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?louiz=E2=80=99?= Date: Fri, 23 Jun 2017 14:45:44 +0200 Subject: Send responses when we receive an unsubscribed presence --- src/xmpp/biboumi_component.cpp | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src/xmpp') diff --git a/src/xmpp/biboumi_component.cpp b/src/xmpp/biboumi_component.cpp index f3381aa..263b7bd 100644 --- a/src/xmpp/biboumi_component.cpp +++ b/src/xmpp/biboumi_component.cpp @@ -180,6 +180,8 @@ void BiboumiComponent::handle_presence(const Stanza& stanza) } else if (type == "unsubscribe") { + this->send_presence_to_contact(to_str, from.bare(), "unavailable", id); + this->send_presence_to_contact(to_str, from.bare(), "unsubscribe"); #ifdef USE_DATABASE const bool res = Database::has_roster_item(to_str, from.bare()); if (res) -- cgit v1.2.3 From 368bb82818d4b68e4984698ea4454091ecb049a2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?louiz=E2=80=99?= Date: Fri, 23 Jun 2017 15:05:07 +0200 Subject: Send an additional unsubscribed presence when receiving an unsubscribe one --- src/xmpp/biboumi_component.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'src/xmpp') diff --git a/src/xmpp/biboumi_component.cpp b/src/xmpp/biboumi_component.cpp index 263b7bd..91e92aa 100644 --- a/src/xmpp/biboumi_component.cpp +++ b/src/xmpp/biboumi_component.cpp @@ -181,6 +181,7 @@ void BiboumiComponent::handle_presence(const Stanza& stanza) else if (type == "unsubscribe") { this->send_presence_to_contact(to_str, from.bare(), "unavailable", id); + this->send_presence_to_contact(to_str, from.bare(), "unsubscribed"); this->send_presence_to_contact(to_str, from.bare(), "unsubscribe"); #ifdef USE_DATABASE const bool res = Database::has_roster_item(to_str, from.bare()); -- 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/xmpp/biboumi_component.cpp | 18 ++++++++++++++---- src/xmpp/biboumi_component.hpp | 3 +++ 2 files changed, 17 insertions(+), 4 deletions(-) (limited to 'src/xmpp') diff --git a/src/xmpp/biboumi_component.cpp b/src/xmpp/biboumi_component.cpp index 91e92aa..71a5f3d 100644 --- a/src/xmpp/biboumi_component.cpp +++ b/src/xmpp/biboumi_component.cpp @@ -84,8 +84,7 @@ void BiboumiComponent::shutdown() for (auto& pair: this->bridges) pair.second->shutdown("Gateway shutdown"); #ifdef USE_DATABASE - const auto full_roster = Database::get_full_roster(); - for (const Database::RosterItem& roster_item: full_roster) + for (const Database::RosterItem& roster_item: Database::get_full_roster()) { this->send_presence_to_contact(roster_item.col(), roster_item.col(), @@ -170,7 +169,7 @@ void BiboumiComponent::handle_presence(const Stanza& stanza) if (type == "subscribe") { // Auto-accept any subscription request for an IRC server this->send_presence_to_contact(to_str, from.bare(), "subscribed", id); - if (iid.type == Iid::Type::None) + if (iid.type == Iid::Type::None || bridge->find_irc_client(iid.get_server())) this->send_presence_to_contact(to_str, from.bare(), ""); this->send_presence_to_contact(to_str, from.bare(), "subscribe"); #ifdef USE_DATABASE @@ -192,7 +191,8 @@ void BiboumiComponent::handle_presence(const Stanza& stanza) else if (type.empty()) { // We just receive a presence from someone (as the result of a probe, // or a directed presence, or a normal presence change) - this->send_presence_to_contact(to_str, from.bare(), ""); + if (iid.type == Iid::Type::None) + this->send_presence_to_contact(to_str, from.bare(), ""); } } else @@ -1023,6 +1023,16 @@ void BiboumiComponent::send_presence_to_contact(const std::string& from, const s this->send_stanza(presence); } +void BiboumiComponent::on_irc_client_connected(const std::string& irc_hostname, const std::string& jid) +{ + this->send_presence_to_contact(irc_hostname + "@" + this->served_hostname, jid, ""); +} + +void BiboumiComponent::on_irc_client_disconnected(const std::string& irc_hostname, const std::string& jid) +{ + this->send_presence_to_contact(irc_hostname + "@" + this->served_hostname, jid, "unavailable"); +} + void BiboumiComponent::after_handshake() { XmppComponent::after_handshake(); diff --git a/src/xmpp/biboumi_component.hpp b/src/xmpp/biboumi_component.hpp index 2d67f8b..e5547f9 100644 --- a/src/xmpp/biboumi_component.hpp +++ b/src/xmpp/biboumi_component.hpp @@ -90,6 +90,9 @@ public: void accept_subscription(const std::string& from, const std::string& to); void ask_subscription(const std::string& from, const std::string& to); void send_presence_to_contact(const std::string& from, const std::string& to, const std::string& type, const std::string& id=""); + void on_irc_client_connected(const std::string& irc_hostname, const std::string& jid); + void on_irc_client_disconnected(const std::string& irc_hostname, const std::string& jid); + /** * Handle the various stanza types */ -- cgit v1.2.3 From dd343609d561c95a3231ab9db26d44dec6395a6f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?louiz=E2=80=99?= Date: Wed, 5 Jul 2017 20:18:26 +0200 Subject: Only send the IRC server presence if the user has this JID in their roster --- src/xmpp/biboumi_component.cpp | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'src/xmpp') diff --git a/src/xmpp/biboumi_component.cpp b/src/xmpp/biboumi_component.cpp index 71a5f3d..b951629 100644 --- a/src/xmpp/biboumi_component.cpp +++ b/src/xmpp/biboumi_component.cpp @@ -1025,12 +1025,20 @@ void BiboumiComponent::send_presence_to_contact(const std::string& from, const s void BiboumiComponent::on_irc_client_connected(const std::string& irc_hostname, const std::string& jid) { - this->send_presence_to_contact(irc_hostname + "@" + this->served_hostname, jid, ""); +#ifdef USE_DATABASE + const auto local_jid = irc_hostname + "@" + this->served_hostname; + if (Database::has_roster_item(local_jid, jid)) + this->send_presence_to_contact(local_jid, jid, ""); +#endif } void BiboumiComponent::on_irc_client_disconnected(const std::string& irc_hostname, const std::string& jid) { - this->send_presence_to_contact(irc_hostname + "@" + this->served_hostname, jid, "unavailable"); +#ifdef USE_DATABASE + const auto local_jid = irc_hostname + "@" + this->served_hostname; + if (Database::has_roster_item(local_jid, jid)) + this->send_presence_to_contact(irc_hostname + "@" + this->served_hostname, jid, "unavailable"); +#endif } void BiboumiComponent::after_handshake() -- cgit v1.2.3 From 50a2bd736ef76f7ebb7067372d5f89b59a337bec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?louiz=E2=80=99?= Date: Tue, 11 Jul 2017 19:52:09 +0200 Subject: Answer to presences of type='probe' --- src/xmpp/biboumi_component.cpp | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'src/xmpp') diff --git a/src/xmpp/biboumi_component.cpp b/src/xmpp/biboumi_component.cpp index b951629..ab66519 100644 --- a/src/xmpp/biboumi_component.cpp +++ b/src/xmpp/biboumi_component.cpp @@ -188,6 +188,12 @@ void BiboumiComponent::handle_presence(const Stanza& stanza) Database::delete_roster_item(to_str, from.bare()); #endif } + else if (type == "probe") + { + if ((iid.type == Iid::Type::Server && bridge->find_irc_client(iid.get_server())) || + iid.type == Iid::Type::None) + this->send_presence_to_contact(to_str, from.bare(), ""); + } else if (type.empty()) { // We just receive a presence from someone (as the result of a probe, // or a directed presence, or a normal presence change) -- cgit v1.2.3 From 729ea131c9857ecb2e9579359e174483c73194d0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?louiz=E2=80=99?= Date: Fri, 14 Jul 2017 15:15:53 +0200 Subject: =?UTF-8?q?Send=20an=20unsubscribed=20presence=20on=20a=20probe=20?= =?UTF-8?q?if=20we=20don=E2=80=99t=20have=20a=20roster=20entry?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/xmpp/biboumi_component.cpp | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) (limited to 'src/xmpp') diff --git a/src/xmpp/biboumi_component.cpp b/src/xmpp/biboumi_component.cpp index ab66519..d1c75d0 100644 --- a/src/xmpp/biboumi_component.cpp +++ b/src/xmpp/biboumi_component.cpp @@ -190,9 +190,18 @@ void BiboumiComponent::handle_presence(const Stanza& stanza) } else if (type == "probe") { - if ((iid.type == Iid::Type::Server && bridge->find_irc_client(iid.get_server())) || - iid.type == Iid::Type::None) - this->send_presence_to_contact(to_str, from.bare(), ""); + if ((iid.type == Iid::Type::Server && bridge->find_irc_client(iid.get_server())) + || iid.type == Iid::Type::None) + { +#ifdef USE_DATABASE + if (Database::has_roster_item(to_str, from.bare())) +#endif + this->send_presence_to_contact(to_str, from.bare(), ""); +#ifdef USE_DATABASE + else // rfc 6121 4.3.2.1 + this->send_presence_to_contact(to_str, from.bare(), "unsubscribed"); +#endif + } } else if (type.empty()) { // We just receive a presence from someone (as the result of a probe, @@ -1057,6 +1066,12 @@ void BiboumiComponent::after_handshake() for (const Database::RosterItem& roster_item: contacts) { const auto remote_jid = roster_item.col(); + // In response, we will receive a presence indicating the + // contact is online, to which we will respond with our own + // presence. + // If the contact removed us from their roster while we were + // offline, we will receive an unsubscribed presence, letting us + // stay in sync. this->send_presence_to_contact(this->get_served_hostname(), remote_jid, "probe"); } #endif -- cgit v1.2.3 From 407f95a108c275db5e9b07398f553ab573cd46bc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?louiz=E2=80=99?= Date: Thu, 20 Jul 2017 21:29:33 +0200 Subject: Do not reply with an error when receiving a presence for a user JID fix #3224 --- src/xmpp/biboumi_component.cpp | 7 ++----- src/xmpp/xmpp_component.cpp | 30 ------------------------------ src/xmpp/xmpp_component.hpp | 6 ------ 3 files changed, 2 insertions(+), 41 deletions(-) (limited to 'src/xmpp') diff --git a/src/xmpp/biboumi_component.cpp b/src/xmpp/biboumi_component.cpp index d1c75d0..13fabd7 100644 --- a/src/xmpp/biboumi_component.cpp +++ b/src/xmpp/biboumi_component.cpp @@ -210,11 +210,8 @@ void BiboumiComponent::handle_presence(const Stanza& stanza) this->send_presence_to_contact(to_str, from.bare(), ""); } } - else - { - // A user wants to join an invalid IRC channel, return a presence error to him/her - if (type.empty()) - this->send_invalid_room_error(to.local, to.resource, from_str); + else if (iid.type == Iid::Type::User) + { // Do nothing yet } } catch (const IRCNotConnected& ex) diff --git a/src/xmpp/xmpp_component.cpp b/src/xmpp/xmpp_component.cpp index 9c3ba90..42a5392 100644 --- a/src/xmpp/xmpp_component.cpp +++ b/src/xmpp/xmpp_component.cpp @@ -261,7 +261,6 @@ void XmppComponent::handle_error(const Stanza& stanza) if (!this->ever_auth) sd_notifyf(0, "STATUS=Failed to authenticate to the XMPP server: %s", error_message.data()); #endif - } void* XmppComponent::get_receive_buffer(const size_t size) const @@ -338,35 +337,6 @@ void XmppComponent::send_user_join(const std::string& from, this->send_stanza(presence); } -void XmppComponent::send_invalid_room_error(const std::string& muc_name, - const std::string& nick, - const std::string& to) -{ - Stanza presence("presence"); - { - if (!muc_name.empty ()) - presence["from"] = muc_name + "@" + this->served_hostname + "/" + nick; - else - presence["from"] = this->served_hostname; - presence["to"] = to; - presence["type"] = "error"; - XmlSubNode x(presence, "x"); - x["xmlns"] = MUC_NS; - XmlSubNode error(presence, "error"); - error["by"] = muc_name + "@" + this->served_hostname; - error["type"] = "cancel"; - XmlSubNode item_not_found(error, "item-not-found"); - item_not_found["xmlns"] = STANZA_NS; - XmlSubNode text(error, "text"); - text["xmlns"] = STANZA_NS; - text["xml:lang"] = "en"; - text.set_inner(muc_name + - " is not a valid IRC channel name. A correct room jid is of the form: #%@" + - this->served_hostname); - } - this->send_stanza(presence); -} - void XmppComponent::send_topic(const std::string& from, Xmpp::body&& topic, const std::string& to, const std::string& who) { Stanza message("message"); diff --git a/src/xmpp/xmpp_component.hpp b/src/xmpp/xmpp_component.hpp index f4a7655..22d5c48 100644 --- a/src/xmpp/xmpp_component.hpp +++ b/src/xmpp/xmpp_component.hpp @@ -123,12 +123,6 @@ public: const std::string& role, const std::string& to, const bool self); - /** - * Send an error to indicate that the user tried to join an invalid room - */ - void send_invalid_room_error(const std::string& muc_jid, - const std::string& nick, - const std::string& to); /** * Send the MUC topic to the user */ -- cgit v1.2.3 From f125de4833d65a83d1f550f4bfbff4d5e4c333b2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?louiz=E2=80=99?= Date: Thu, 20 Jul 2017 23:09:37 +0200 Subject: Add the possibility to invite any external JID to a room fix #3285 --- src/xmpp/biboumi_component.cpp | 21 ++++++++++++++++----- src/xmpp/biboumi_component.hpp | 3 +++ 2 files changed, 19 insertions(+), 5 deletions(-) (limited to 'src/xmpp') diff --git a/src/xmpp/biboumi_component.cpp b/src/xmpp/biboumi_component.cpp index 13fabd7..0e1d270 100644 --- a/src/xmpp/biboumi_component.cpp +++ b/src/xmpp/biboumi_component.cpp @@ -310,7 +310,11 @@ void BiboumiComponent::handle_message(const Stanza& stanza) const auto invite_to = invite->get_tag("to"); if (!invite_to.empty()) { - bridge->send_irc_invitation(iid, invite_to); + Jid invited_jid{invite_to}; + if (invited_jid.domain == this->get_served_hostname() || invited_jid.local.empty()) + bridge->send_irc_invitation(iid, invite_to); + else + this->send_invitation_from_fulljid(std::to_string(iid), invite_to, from_str); } } @@ -986,6 +990,16 @@ void BiboumiComponent::send_iq_room_list_result(const std::string& id, const std void BiboumiComponent::send_invitation(const std::string& room_target, const std::string& jid_to, const std::string& author_nick) +{ + if (author_nick.empty()) + this->send_invitation_from_fulljid(room_target, jid_to, room_target + "@" + this->served_hostname); + else + this->send_invitation_from_fulljid(room_target, jid_to, room_target + "@" + this->served_hostname + "/" + author_nick); +} + +void BiboumiComponent::send_invitation_from_fulljid(const std::string& room_target, + const std::string& jid_to, + const std::string& from) { Stanza message("message"); { @@ -994,10 +1008,7 @@ void BiboumiComponent::send_invitation(const std::string& room_target, XmlSubNode x(message, "x"); x["xmlns"] = MUC_USER_NS; XmlSubNode invite(x, "invite"); - if (author_nick.empty()) - invite["from"] = room_target + "@" + this->served_hostname; - else - invite["from"] = room_target + "@" + this->served_hostname + "/" + author_nick; + invite["from"] = from; } this->send_stanza(message); } diff --git a/src/xmpp/biboumi_component.hpp b/src/xmpp/biboumi_component.hpp index e5547f9..caf990e 100644 --- a/src/xmpp/biboumi_component.hpp +++ b/src/xmpp/biboumi_component.hpp @@ -87,6 +87,9 @@ public: const ChannelList& channel_list, std::vector::const_iterator begin, std::vector::const_iterator end, const ResultSetInfo& rs_info); void send_invitation(const std::string& room_target, const std::string& jid_to, const std::string& author_nick); +private: + void send_invitation_from_fulljid(const std::string& room_target, const std::string& jid_to, const std::string& from); +public: void accept_subscription(const std::string& from, const std::string& to); void ask_subscription(const std::string& from, const std::string& to); void send_presence_to_contact(const std::string& from, const std::string& to, const std::string& type, const std::string& id=""); -- cgit v1.2.3 From 308869aa73c7c03d7e9fad2a780bf132e03c8c5a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?louiz=E2=80=99?= Date: Fri, 21 Jul 2017 17:27:03 +0200 Subject: Do not ignore empty values when receiving a data form Otherwise, these fields cannot be emptied by the user fix #3281 --- src/xmpp/biboumi_adhoc_commands.cpp | 30 ++++++++++-------------------- 1 file changed, 10 insertions(+), 20 deletions(-) (limited to 'src/xmpp') diff --git a/src/xmpp/biboumi_adhoc_commands.cpp b/src/xmpp/biboumi_adhoc_commands.cpp index 27b079b..60af506 100644 --- a/src/xmpp/biboumi_adhoc_commands.cpp +++ b/src/xmpp/biboumi_adhoc_commands.cpp @@ -399,24 +399,20 @@ void ConfigureIrcServerStep2(XmppComponent&, AdhocSession& session, XmlNode& com options.col() = val; } - else if (field->get_tag("var") == "fingerprint" && value && - !value->get_inner().empty()) + else if (field->get_tag("var") == "fingerprint" && value) { options.col() = value->get_inner(); } #endif // BOTAN_FOUND - else if (field->get_tag("var") == "pass" && - value && !value->get_inner().empty()) + else if (field->get_tag("var") == "pass" && value) options.col() = value->get_inner(); - else if (field->get_tag("var") == "after_connect_command" && - value && !value->get_inner().empty()) + else if (field->get_tag("var") == "after_connect_command") options.col() = value->get_inner(); - else if (field->get_tag("var") == "username" && - value && !value->get_inner().empty()) + else if (field->get_tag("var") == "username" && value) { auto username = value->get_inner(); // The username must not contain spaces @@ -424,16 +420,13 @@ void ConfigureIrcServerStep2(XmppComponent&, AdhocSession& session, XmlNode& com options.col() = username; } - else if (field->get_tag("var") == "realname" && - value && !value->get_inner().empty()) + else if (field->get_tag("var") == "realname" && value) options.col() = value->get_inner(); - else if (field->get_tag("var") == "encoding_out" && - value && !value->get_inner().empty()) + else if (field->get_tag("var") == "encoding_out" && value) options.col() = value->get_inner(); - else if (field->get_tag("var") == "encoding_in" && - value && !value->get_inner().empty()) + else if (field->get_tag("var") == "encoding_in" && value) options.col() = value->get_inner(); } @@ -572,16 +565,13 @@ bool handle_irc_channel_configuration_form(XmppComponent& xmpp_component, const { const XmlNode *value = field->get_child("value", "jabber:x:data"); - if (field->get_tag("var") == "encoding_out" && - value && !value->get_inner().empty()) + if (field->get_tag("var") == "encoding_out" && value) options.col() = value->get_inner(); - else if (field->get_tag("var") == "encoding_in" && - value && !value->get_inner().empty()) + else if (field->get_tag("var") == "encoding_in" && value) options.col() = value->get_inner(); - else if (field->get_tag("var") == "persistent" && - value) + else if (field->get_tag("var") == "persistent" && value) options.col() = to_bool(value->get_inner()); else if (field->get_tag("var") == "record_history" && value && !value->get_inner().empty()) -- cgit v1.2.3