From 1a09c965eb3723cdaab9ea556f30ffbc7f09a6dd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?louiz=E2=80=99?= Date: Wed, 29 Mar 2017 23:32:43 +0200 Subject: Remove two sneaky log_debug --- src/xmpp/adhoc_command.hpp | 2 +- src/xmpp/adhoc_session.cpp | 2 +- src/xmpp/biboumi_adhoc_commands.cpp | 14 +++++++------- src/xmpp/biboumi_component.cpp | 2 -- src/xmpp/jid.cpp | 3 +-- src/xmpp/xmpp_component.cpp | 8 ++++---- src/xmpp/xmpp_component.hpp | 6 +++--- 7 files changed, 17 insertions(+), 20 deletions(-) (limited to 'src/xmpp') diff --git a/src/xmpp/adhoc_command.hpp b/src/xmpp/adhoc_command.hpp index 7c4de47..ced4549 100644 --- a/src/xmpp/adhoc_command.hpp +++ b/src/xmpp/adhoc_command.hpp @@ -17,7 +17,7 @@ class AdhocCommand { friend class AdhocSession; public: - AdhocCommand(std::vector&& callback, const std::string& name, const bool admin_only); + AdhocCommand(std::vector&& callbacks, const std::string& name, const bool admin_only); ~AdhocCommand() = default; AdhocCommand(const AdhocCommand&) = default; AdhocCommand(AdhocCommand&&) = default; diff --git a/src/xmpp/adhoc_session.cpp b/src/xmpp/adhoc_session.cpp index dda4bea..e2d6c0e 100644 --- a/src/xmpp/adhoc_session.cpp +++ b/src/xmpp/adhoc_session.cpp @@ -1,7 +1,7 @@ #include #include -#include +#include AdhocSession::AdhocSession(const AdhocCommand& command, const std::string& owner_jid, const std::string& to_jid): diff --git a/src/xmpp/biboumi_adhoc_commands.cpp b/src/xmpp/biboumi_adhoc_commands.cpp index 5ec11da..85f945d 100644 --- a/src/xmpp/biboumi_adhoc_commands.cpp +++ b/src/xmpp/biboumi_adhoc_commands.cpp @@ -24,7 +24,7 @@ using namespace std::string_literals; void DisconnectUserStep1(XmppComponent& xmpp_component, AdhocSession&, XmlNode& command_node) { - auto& biboumi_component = static_cast(xmpp_component); + auto& biboumi_component = dynamic_cast(xmpp_component); XmlSubNode x(command_node, "jabber:x:data:x"); x["type"] = "form"; @@ -55,7 +55,7 @@ void DisconnectUserStep1(XmppComponent& xmpp_component, AdhocSession&, XmlNode& void DisconnectUserStep2(XmppComponent& xmpp_component, AdhocSession& session, XmlNode& command_node) { - auto& biboumi_component = static_cast(xmpp_component); + auto& biboumi_component = dynamic_cast(xmpp_component); // Find out if the jids, and the quit message are provided in the form. std::string quit_message; @@ -151,7 +151,7 @@ void ConfigureGlobalStep1(XmppComponent&, AdhocSession& session, XmlNode& comman void ConfigureGlobalStep2(XmppComponent& xmpp_component, AdhocSession& session, XmlNode& command_node) { - BiboumiComponent& biboumi_component = static_cast(xmpp_component); + auto& biboumi_component = dynamic_cast(xmpp_component); const XmlNode* x = command_node.get_child("x", "jabber:x:data"); if (x) @@ -533,7 +533,7 @@ void DisconnectUserFromServerStep1(XmppComponent& xmpp_component, AdhocSession& } else { // Send a form to select the user to disconnect - auto& biboumi_component = static_cast(xmpp_component); + auto& biboumi_component = dynamic_cast(xmpp_component); XmlSubNode x(command_node, "jabber:x:data:x"); x["type"] = "form"; @@ -578,7 +578,7 @@ void DisconnectUserFromServerStep2(XmppComponent& xmpp_component, AdhocSession& // Send a data form to let the user choose which server to disconnect the // user from command_node.delete_all_children(); - auto& biboumi_component = static_cast(xmpp_component); + auto& biboumi_component = dynamic_cast(xmpp_component); XmlSubNode x(command_node, "jabber:x:data:x"); x["type"] = "form"; @@ -643,7 +643,7 @@ void DisconnectUserFromServerStep3(XmppComponent& xmpp_component, AdhocSession& } } - auto& biboumi_component = static_cast(xmpp_component); + auto& biboumi_component = dynamic_cast(xmpp_component); Bridge* bridge = biboumi_component.find_user_bridge(jid_to_disconnect); auto& clients = bridge->get_irc_clients(); @@ -671,7 +671,7 @@ void DisconnectUserFromServerStep3(XmppComponent& xmpp_component, AdhocSession& void GetIrcConnectionInfoStep1(XmppComponent& component, AdhocSession& session, XmlNode& command_node) { - BiboumiComponent& biboumi_component = static_cast(component); + auto& biboumi_component = dynamic_cast(component); const Jid owner(session.get_owner_jid()); const Jid target(session.get_target_jid()); diff --git a/src/xmpp/biboumi_component.cpp b/src/xmpp/biboumi_component.cpp index 6dc8ce9..df96d62 100644 --- a/src/xmpp/biboumi_component.cpp +++ b/src/xmpp/biboumi_component.cpp @@ -422,7 +422,6 @@ void BiboumiComponent::handle_iq(const Stanza& stanza) } else if (iid.type == Iid::Type::Channel) { - log_debug("type_channel"); if (node.empty()) { this->send_irc_channel_disco_info(id, from, to_str); @@ -763,7 +762,6 @@ void BiboumiComponent::send_irc_channel_muc_traffic_info(const std::string& id, void BiboumiComponent::send_irc_channel_disco_info(const std::string& id, const std::string& jid_to, const std::string& jid_from) { - log_debug("jid_from: ", jid_from); Jid from(jid_from); Iid iid(from.local, {}); Stanza iq("iq"); diff --git a/src/xmpp/jid.cpp b/src/xmpp/jid.cpp index 0751387..ba8d70b 100644 --- a/src/xmpp/jid.cpp +++ b/src/xmpp/jid.cpp @@ -68,8 +68,7 @@ std::string jidprep(const std::string& original) // Using getaddrinfo, check if the domain part is a valid IPv4 (then use // it as is), or IPv6 (surround it with []), or a domain name (run // nameprep) - struct addrinfo hints; - memset(&hints, 0, sizeof(hints)); + struct addrinfo hints{}; hints.ai_flags = AI_NUMERICHOST; hints.ai_family = AF_UNSPEC; diff --git a/src/xmpp/xmpp_component.cpp b/src/xmpp/xmpp_component.cpp index 1453b18..6829cef 100644 --- a/src/xmpp/xmpp_component.cpp +++ b/src/xmpp/xmpp_component.cpp @@ -39,14 +39,14 @@ static std::set kickable_errors{ "malformed-error" }; -XmppComponent::XmppComponent(std::shared_ptr& poller, const std::string& hostname, const std::string& secret): +XmppComponent::XmppComponent(std::shared_ptr& poller, std::string hostname, std::string secret): TCPClientSocketHandler(poller), ever_auth(false), first_connection_try(true), - secret(secret), + secret(std::move(secret)), authenticated(false), doc_open(false), - served_hostname(hostname), + served_hostname(std::move(hostname)), stanza_handlers{}, adhoc_commands_handler(*this) { @@ -429,7 +429,7 @@ 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, 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) { Stanza presence("presence"); { diff --git a/src/xmpp/xmpp_component.hpp b/src/xmpp/xmpp_component.hpp index d808fd5..250f0a8 100644 --- a/src/xmpp/xmpp_component.hpp +++ b/src/xmpp/xmpp_component.hpp @@ -43,7 +43,7 @@ class XmppComponent: public TCPClientSocketHandler { public: - explicit XmppComponent(std::shared_ptr& poller, const std::string& hostname, const std::string& secret); + explicit XmppComponent(std::shared_ptr& poller, std::string hostname, std::string secret); virtual ~XmppComponent() = default; XmppComponent(const XmppComponent&) = delete; @@ -91,7 +91,7 @@ public: * stanza, and explanation being a short human-readable sentence * describing the error. */ - void send_stream_error(const std::string& message, const std::string& explanation); + void send_stream_error(const std::string& name, const std::string& explanation); /** * Send error stanza, described in http://xmpp.org/rfcs/rfc6120.html#stanzas-error */ @@ -143,7 +143,7 @@ public: /** * Send an unavailable presence for this nick */ - void send_muc_leave(const std::string& muc_name, 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); /** * Indicate that a participant changed his nick */ -- cgit v1.2.3