summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/bridge/bridge.cpp33
-rw-r--r--src/bridge/bridge.hpp14
-rw-r--r--src/bridge/colors.hpp2
-rw-r--r--src/config/config.cpp2
-rw-r--r--src/config/config.hpp2
-rw-r--r--src/database/database.cpp2
-rw-r--r--src/database/database.hpp2
-rw-r--r--src/irc/irc_client.cpp6
-rw-r--r--src/irc/irc_client.hpp2
-rw-r--r--src/irc/irc_message.cpp6
-rw-r--r--src/irc/irc_user.cpp2
-rw-r--r--src/irc/irc_user.hpp2
-rw-r--r--src/network/resolver.cpp13
-rw-r--r--src/utils/encoding.hpp2
-rw-r--r--src/utils/time.cpp2
-rw-r--r--src/xmpp/adhoc_command.hpp2
-rw-r--r--src/xmpp/adhoc_session.cpp2
-rw-r--r--src/xmpp/biboumi_adhoc_commands.cpp14
-rw-r--r--src/xmpp/biboumi_component.cpp2
-rw-r--r--src/xmpp/jid.cpp3
-rw-r--r--src/xmpp/xmpp_component.cpp8
-rw-r--r--src/xmpp/xmpp_component.hpp6
22 files changed, 63 insertions, 66 deletions
diff --git a/src/bridge/bridge.cpp b/src/bridge/bridge.cpp
index 4632c23..0d6ade3 100644
--- a/src/bridge/bridge.cpp
+++ b/src/bridge/bridge.cpp
@@ -1,4 +1,5 @@
#include <bridge/bridge.hpp>
+#include <utility>
#include <xmpp/biboumi_component.hpp>
#include <network/poller.hpp>
#include <utils/empty_if_fixed_server.hpp>
@@ -29,8 +30,8 @@ static std::string in_encoding_for(const Bridge& bridge, const Iid& iid)
#endif
}
-Bridge::Bridge(const std::string& user_jid, BiboumiComponent& xmpp, std::shared_ptr<Poller>& poller):
- user_jid(user_jid),
+Bridge::Bridge(std::string user_jid, BiboumiComponent& xmpp, std::shared_ptr<Poller>& poller):
+ user_jid(std::move(user_jid)),
xmpp(xmpp),
poller(poller)
{
@@ -59,10 +60,10 @@ static std::tuple<std::string, std::string> get_role_affiliation_from_irc_mode(c
void Bridge::shutdown(const std::string& exit_message)
{
- for (auto it = this->irc_clients.begin(); it != this->irc_clients.end(); ++it)
+ for (auto& pair: this->irc_clients)
{
- it->second->send_quit_command(exit_message);
- it->second->leave_dummy_channel(exit_message, {});
+ pair.second->send_quit_command(exit_message);
+ pair.second->leave_dummy_channel(exit_message, {});
}
}
@@ -168,7 +169,7 @@ IrcClient* Bridge::find_irc_client(const std::string& hostname) const
bool Bridge::join_irc_channel(const Iid& iid, const std::string& nickname, const std::string& password,
const std::string& resource)
{
- const auto hostname = iid.get_server();
+ const auto& hostname = iid.get_server();
this->cancel_linger_timer(hostname);
IrcClient* irc = this->make_irc_client(hostname, nickname);
this->add_resource_to_server(hostname, resource);
@@ -439,7 +440,7 @@ void Bridge::leave_irc_channel(Iid&& iid, const std::string& status_message, con
#endif
if (channel->joined && !channel->parting && !persistent)
{
- const auto chan_name = iid.get_local();
+ const auto& chan_name = iid.get_local();
if (chan_name.empty())
irc->leave_dummy_channel(status_message, resource);
else
@@ -447,7 +448,7 @@ void Bridge::leave_irc_channel(Iid&& iid, const std::string& status_message, con
}
else
{
- this->send_muc_leave(std::move(iid), std::move(nick), "", true, resource);
+ this->send_muc_leave(iid, std::move(nick), "", true, resource);
}
// Since there are no resources left in that channel, we don't
// want to receive private messages using this room's JID
@@ -456,7 +457,7 @@ void Bridge::leave_irc_channel(Iid&& iid, const std::string& status_message, con
else
{
if (channel)
- this->send_muc_leave(std::move(iid), std::move(nick),
+ this->send_muc_leave(iid, std::move(nick),
"Biboumi note: "s + std::to_string(resources - 1) + " resources are still in this channel.",
true, resource);
this->remove_resource_from_chan(key, resource);
@@ -870,16 +871,16 @@ void Bridge::send_presence_error(const Iid& iid, const std::string& nick,
this->xmpp.send_presence_error(std::to_string(iid), nick, this->user_jid, type, condition, error_code, text);
}
-void Bridge::send_muc_leave(Iid&& iid, std::string&& nick, const std::string& message, const bool self,
+void Bridge::send_muc_leave(const Iid &iid, std::string&& nick, const std::string& message, const bool self,
const std::string& resource)
{
if (!resource.empty())
- this->xmpp.send_muc_leave(std::to_string(iid), std::move(nick), this->make_xmpp_body(message),
+ this->xmpp.send_muc_leave(std::to_string(iid), nick, this->make_xmpp_body(message),
this->user_jid + "/" + resource, self);
else
{
for (const auto &res: this->resources_in_chan[iid.to_tuple()])
- this->xmpp.send_muc_leave(std::to_string(iid), std::move(nick), this->make_xmpp_body(message),
+ this->xmpp.send_muc_leave(std::to_string(iid), nick, this->make_xmpp_body(message),
this->user_jid + "/" + res, self);
if (self)
this->remove_all_resources_from_chan(iid.to_tuple());
@@ -1157,9 +1158,9 @@ bool Bridge::is_resource_in_chan(const Bridge::ChannelKey& channel, const std::s
return false;
}
-void Bridge::remove_all_resources_from_chan(const Bridge::ChannelKey& channel_key)
+void Bridge::remove_all_resources_from_chan(const Bridge::ChannelKey& channel)
{
- this->resources_in_chan.erase(channel_key);
+ this->resources_in_chan.erase(channel);
}
void Bridge::add_resource_to_server(const Bridge::IrcHostname& irc_hostname, const std::string& resource)
@@ -1191,9 +1192,9 @@ bool Bridge::is_resource_in_server(const Bridge::IrcHostname& irc_hostname, cons
return false;
}
-std::size_t Bridge::number_of_resources_in_chan(const Bridge::ChannelKey& channel_key) const
+std::size_t Bridge::number_of_resources_in_chan(const Bridge::ChannelKey& channel) const
{
- auto it = this->resources_in_chan.find(channel_key);
+ auto it = this->resources_in_chan.find(channel);
if (it == this->resources_in_chan.end())
return 0;
return it->second.size();
diff --git a/src/bridge/bridge.hpp b/src/bridge/bridge.hpp
index 03eb716..53d2136 100644
--- a/src/bridge/bridge.hpp
+++ b/src/bridge/bridge.hpp
@@ -38,7 +38,7 @@ using irc_responder_callback_t = std::function<bool(const std::string& irc_hostn
class Bridge
{
public:
- explicit Bridge(const std::string& user_jid, BiboumiComponent& xmpp, std::shared_ptr<Poller>& poller);
+ explicit Bridge(std::string user_jid, BiboumiComponent& xmpp, std::shared_ptr<Poller>& poller);
~Bridge() = default;
Bridge(const Bridge&) = delete;
@@ -169,7 +169,7 @@ public:
/**
* Send an unavailable presence from this participant
*/
- void send_muc_leave(Iid&& iid, std::string&& nick, const std::string& message, const bool self, const std::string& resource="");
+ void send_muc_leave(const Iid& iid, std::string&& nick, const std::string& message, const bool self, 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
@@ -309,11 +309,11 @@ private:
/**
* Manage which resource is in which channel
*/
- void add_resource_to_chan(const ChannelKey& channel_key, const std::string& resource);
- void remove_resource_from_chan(const ChannelKey& channel_key, const std::string& resource);
- bool is_resource_in_chan(const ChannelKey& channel_key, const std::string& resource) const;
- void remove_all_resources_from_chan(const ChannelKey& channel_key);
- std::size_t number_of_resources_in_chan(const ChannelKey& channel_key) const;
+ void add_resource_to_chan(const ChannelKey& channel, const std::string& resource);
+ void remove_resource_from_chan(const ChannelKey& channel, const std::string& resource);
+ bool is_resource_in_chan(const ChannelKey& channel, const std::string& resource) const;
+ void remove_all_resources_from_chan(const ChannelKey& channel);
+ std::size_t number_of_resources_in_chan(const ChannelKey& channel) const;
void add_resource_to_server(const IrcHostname& irc_hostname, const std::string& resource);
void remove_resource_from_server(const IrcHostname& irc_hostname, const std::string& resource);
diff --git a/src/bridge/colors.hpp b/src/bridge/colors.hpp
index e2c8a87..dceed74 100644
--- a/src/bridge/colors.hpp
+++ b/src/bridge/colors.hpp
@@ -51,6 +51,6 @@ static const char irc_format_char[] = {
* Returns the body cleaned from any IRC formatting (but without any xhtml),
* and the body as XHTML-IM
*/
-Xmpp::body irc_format_to_xhtmlim(const std::string& str);
+Xmpp::body irc_format_to_xhtmlim(const std::string& s);
diff --git a/src/config/config.cpp b/src/config/config.cpp
index 24a1c87..0db5751 100644
--- a/src/config/config.cpp
+++ b/src/config/config.cpp
@@ -37,7 +37,7 @@ void Config::set(const std::string& option, const std::string& value, bool save)
}
}
-void Config::connect(t_config_changed_callback callback)
+void Config::connect(const t_config_changed_callback& callback)
{
Config::callbacks.push_back(callback);
}
diff --git a/src/config/config.hpp b/src/config/config.hpp
index 4e01281..2ba38cc 100644
--- a/src/config/config.hpp
+++ b/src/config/config.hpp
@@ -54,7 +54,7 @@ public:
* configuration change occurs (when set() is called, or when the initial
* conf is read)
*/
- static void connect(t_config_changed_callback);
+ static void connect(const t_config_changed_callback&);
/**
* Destroy the instance, forcing it to be recreated (with potentially
* different parameters) the next time it’s needed.
diff --git a/src/database/database.cpp b/src/database/database.cpp
index cb0c78f..71b0c37 100644
--- a/src/database/database.cpp
+++ b/src/database/database.cpp
@@ -20,7 +20,7 @@ void Database::open(const std::string& filename, const std::string& db_type)
"database="s + filename);
if (new_db->needsUpgrade())
new_db->upgrade();
- Database::db.reset(new_db.release());
+ Database::db = std::move(new_db);
} catch (const litesql::DatabaseError& e) {
log_error("Failed to open database ", filename, ". ", e.what());
throw;
diff --git a/src/database/database.hpp b/src/database/database.hpp
index 6823574..1665a9a 100644
--- a/src/database/database.hpp
+++ b/src/database/database.hpp
@@ -49,7 +49,7 @@ public:
const std::string& server,
const std::string& channel);
static std::vector<db::MucLogLine> get_muc_logs(const std::string& owner, const std::string& chan_name, const std::string& server,
- int limit=-1, const std::string& before="", const std::string& after="");
+ int limit=-1, const std::string& start="", const std::string& end="");
static void store_muc_message(const std::string& owner, const Iid& iid,
time_point date, const std::string& body, const std::string& nick);
diff --git a/src/irc/irc_client.cpp b/src/irc/irc_client.cpp
index 00eab6f..48b105d 100644
--- a/src/irc/irc_client.cpp
+++ b/src/irc/irc_client.cpp
@@ -888,7 +888,7 @@ void IrcClient::on_part(const IrcMessage& message)
// channel pointer is now invalid
channel = nullptr;
}
- this->bridge.send_muc_leave(std::move(iid), std::move(nick), std::move(txt), self);
+ this->bridge.send_muc_leave(iid, std::move(nick), std::move(txt), self);
}
}
@@ -906,7 +906,7 @@ void IrcClient::on_error(const IrcMessage& message)
if (!channel->joined)
continue;
std::string own_nick = channel->get_self()->nick;
- this->bridge.send_muc_leave(std::move(iid), std::move(own_nick), leave_message, true);
+ this->bridge.send_muc_leave(iid, std::move(own_nick), leave_message, true);
}
this->channels.clear();
this->send_gateway_message("ERROR: "s + leave_message);
@@ -930,7 +930,7 @@ void IrcClient::on_quit(const IrcMessage& message)
iid.set_local(chan_name);
iid.set_server(this->hostname);
iid.type = Iid::Type::Channel;
- this->bridge.send_muc_leave(std::move(iid), std::move(nick), txt, false);
+ this->bridge.send_muc_leave(iid, std::move(nick), txt, false);
}
}
}
diff --git a/src/irc/irc_client.hpp b/src/irc/irc_client.hpp
index 435dce6..8119201 100644
--- a/src/irc/irc_client.hpp
+++ b/src/irc/irc_client.hpp
@@ -52,7 +52,7 @@ public:
/**
* Close the connection, remove us from the poller
*/
- void on_connection_close(const std::string& error) override final;
+ void on_connection_close(const std::string& error_msg) override final;
/**
* Parse the data we have received so far and try to get one or more
* complete messages from it.
diff --git a/src/irc/irc_message.cpp b/src/irc/irc_message.cpp
index 966a47c..14fdb0e 100644
--- a/src/irc/irc_message.cpp
+++ b/src/irc/irc_message.cpp
@@ -8,12 +8,12 @@ IrcMessage::IrcMessage(std::string&& line)
// optional prefix
if (line[0] == ':')
{
- pos = line.find(" ");
+ pos = line.find(' ');
this->prefix = line.substr(1, pos - 1);
line = line.substr(pos + 1, std::string::npos);
}
// command
- pos = line.find(" ");
+ pos = line.find(' ');
this->command = line.substr(0, pos);
line = line.substr(pos + 1, std::string::npos);
// arguments
@@ -24,7 +24,7 @@ IrcMessage::IrcMessage(std::string&& line)
this->arguments.emplace_back(line.substr(1, std::string::npos));
break ;
}
- pos = line.find(" ");
+ pos = line.find(' ');
this->arguments.emplace_back(line.substr(0, pos));
line = line.substr(pos + 1, std::string::npos);
} while (pos != std::string::npos);
diff --git a/src/irc/irc_user.cpp b/src/irc/irc_user.cpp
index 9fa3612..139015e 100644
--- a/src/irc/irc_user.cpp
+++ b/src/irc/irc_user.cpp
@@ -21,7 +21,7 @@ IrcUser::IrcUser(const std::string& name,
name_begin++;
}
- const std::string::size_type sep = name.find("!", name_begin);
+ const std::string::size_type sep = name.find('!', name_begin);
if (sep == std::string::npos)
this->nick = name.substr(name_begin);
else
diff --git a/src/irc/irc_user.hpp b/src/irc/irc_user.hpp
index c84030e..a4291d4 100644
--- a/src/irc/irc_user.hpp
+++ b/src/irc/irc_user.hpp
@@ -23,7 +23,7 @@ public:
void add_mode(const char mode);
void remove_mode(const char mode);
- char get_most_significant_mode(const std::vector<char>& sorted_user_modes) const;
+ char get_most_significant_mode(const std::vector<char>& modes) const;
std::string nick;
std::string host;
diff --git a/src/network/resolver.cpp b/src/network/resolver.cpp
index db7fb32..ef54ba2 100644
--- a/src/network/resolver.cpp
+++ b/src/network/resolver.cpp
@@ -1,7 +1,7 @@
#include <network/dns_handler.hpp>
#include <utils/timed_events.hpp>
#include <network/resolver.hpp>
-#include <string.h>
+#include <cstring>
#include <arpa/inet.h>
#include <netinet/in.h>
#ifdef UDNS_FOUND
@@ -41,8 +41,8 @@ Resolver::Resolver():
void Resolver::resolve(const std::string& hostname, const std::string& port,
SuccessCallbackType success_cb, ErrorCallbackType error_cb)
{
- this->error_cb = error_cb;
- this->success_cb = success_cb;
+ this->error_cb = std::move(error_cb);
+ this->success_cb = std::move(success_cb);
#ifdef UDNS_FOUND
this->port = port;
#endif
@@ -52,8 +52,7 @@ void Resolver::resolve(const std::string& hostname, const std::string& port,
int Resolver::call_getaddrinfo(const char *name, const char* port, int flags)
{
- struct addrinfo hints;
- memset(&hints, 0, sizeof(struct addrinfo));
+ struct addrinfo hints{};
hints.ai_flags = flags;
hints.ai_family = AF_UNSPEC;
hints.ai_socktype = SOCK_STREAM;
@@ -111,7 +110,7 @@ void Resolver::start_resolving(const std::string& hostname, const std::string& p
// And finally, we try a DNS resolution
auto hostname6_resolved = [](dns_ctx*, dns_rr_a6* result, void* data)
{
- Resolver* resolver = static_cast<Resolver*>(data);
+ auto resolver = static_cast<Resolver*>(data);
resolver->on_hostname6_resolved(result);
resolver->after_resolved();
std::free(result);
@@ -119,7 +118,7 @@ void Resolver::start_resolving(const std::string& hostname, const std::string& p
auto hostname4_resolved = [](dns_ctx*, dns_rr_a4* result, void* data)
{
- Resolver* resolver = static_cast<Resolver*>(data);
+ auto resolver = static_cast<Resolver*>(data);
resolver->on_hostname4_resolved(result);
resolver->after_resolved();
std::free(result);
diff --git a/src/utils/encoding.hpp b/src/utils/encoding.hpp
index 586edd8..b707a0c 100644
--- a/src/utils/encoding.hpp
+++ b/src/utils/encoding.hpp
@@ -28,7 +28,7 @@ namespace utils
* Convert the given string (encoded is "encoding") into valid utf-8.
* If some decoding fails, insert an utf-8 placeholder character instead.
*/
- std::string convert_to_utf8(const std::string& str, const char* encoding);
+ std::string convert_to_utf8(const std::string& str, const char* charset);
}
namespace xep0106
diff --git a/src/utils/time.cpp b/src/utils/time.cpp
index 8fa3fcd..88b3de3 100644
--- a/src/utils/time.cpp
+++ b/src/utils/time.cpp
@@ -1,5 +1,5 @@
#include <utils/time.hpp>
-#include <time.h>
+#include <ctime>
#include <sstream>
#include <iomanip>
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<AdhocStep>&& callback, const std::string& name, const bool admin_only);
+ AdhocCommand(std::vector<AdhocStep>&& 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 <xmpp/adhoc_session.hpp>
#include <xmpp/adhoc_command.hpp>
-#include <assert.h>
+#include <cassert>
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<BiboumiComponent&>(xmpp_component);
+ auto& biboumi_component = dynamic_cast<BiboumiComponent&>(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<BiboumiComponent&>(xmpp_component);
+ auto& biboumi_component = dynamic_cast<BiboumiComponent&>(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<BiboumiComponent&>(xmpp_component);
+ auto& biboumi_component = dynamic_cast<BiboumiComponent&>(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<BiboumiComponent&>(xmpp_component);
+ auto& biboumi_component = dynamic_cast<BiboumiComponent&>(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<BiboumiComponent&>(xmpp_component);
+ auto& biboumi_component = dynamic_cast<BiboumiComponent&>(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<BiboumiComponent&>(xmpp_component);
+ auto& biboumi_component = dynamic_cast<BiboumiComponent&>(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<BiboumiComponent&>(component);
+ auto& biboumi_component = dynamic_cast<BiboumiComponent&>(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<std::string> kickable_errors{
"malformed-error"
};
-XmppComponent::XmppComponent(std::shared_ptr<Poller>& poller, const std::string& hostname, const std::string& secret):
+XmppComponent::XmppComponent(std::shared_ptr<Poller>& 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>& poller, const std::string& hostname, const std::string& secret);
+ explicit XmppComponent(std::shared_ptr<Poller>& 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
*/