~singpolyma/biboumi

f0bc6c83a8eb548d0a3edbf7c16a6922bfd24ba5 — louiz’ 5 years ago cd92baa
Pass the shared_ptr by reference, to avoid useless copies
M louloulibs/network/dns_handler.cpp => louloulibs/network/dns_handler.cpp +1 -1
@@ 17,7 17,7 @@ using namespace std::string_literals;

std::unique_ptr<DNSSocketHandler> DNSHandler::socket_handler{};

DNSHandler::DNSHandler(std::shared_ptr<Poller> poller)
DNSHandler::DNSHandler(std::shared_ptr<Poller>& poller)
{
  dns_init(nullptr, 0);
  const auto socket = dns_open(nullptr);

M louloulibs/network/dns_handler.hpp => louloulibs/network/dns_handler.hpp +1 -1
@@ 14,7 14,7 @@ class Poller;
class DNSHandler
{
public:
  explicit DNSHandler(std::shared_ptr<Poller> poller);
  explicit DNSHandler(std::shared_ptr<Poller>& poller);
  ~DNSHandler() = default;

  DNSHandler(const DNSHandler&) = delete;

M louloulibs/network/dns_socket_handler.cpp => louloulibs/network/dns_socket_handler.cpp +1 -1
@@ 7,7 7,7 @@

#include <udns.h>

DNSSocketHandler::DNSSocketHandler(std::shared_ptr<Poller> poller,
DNSSocketHandler::DNSSocketHandler(std::shared_ptr<Poller>& poller,
                                   const socket_t socket):
  SocketHandler(poller, socket)
{

M louloulibs/network/dns_socket_handler.hpp => louloulibs/network/dns_socket_handler.hpp +1 -1
@@ 12,7 12,7 @@
class DNSSocketHandler: public SocketHandler
{
public:
  explicit DNSSocketHandler(std::shared_ptr<Poller> poller, const socket_t socket);
  explicit DNSSocketHandler(std::shared_ptr<Poller>& poller, const socket_t socket);
  ~DNSSocketHandler();
  DNSSocketHandler(const DNSSocketHandler&) = delete;
  DNSSocketHandler(DNSSocketHandler&&) = delete;

M louloulibs/network/socket_handler.hpp => louloulibs/network/socket_handler.hpp +1 -1
@@ 10,7 10,7 @@ using socket_t = int;
class SocketHandler
{
public:
  explicit SocketHandler(std::shared_ptr<Poller> poller, const socket_t socket):
  explicit SocketHandler(std::shared_ptr<Poller>& poller, const socket_t socket):
    poller(poller),
    socket(socket)
  {}

M louloulibs/network/tcp_client_socket_handler.cpp => louloulibs/network/tcp_client_socket_handler.cpp +1 -1
@@ 11,7 11,7 @@

using namespace std::string_literals;

TCPClientSocketHandler::TCPClientSocketHandler(std::shared_ptr<Poller> poller):
TCPClientSocketHandler::TCPClientSocketHandler(std::shared_ptr<Poller>& poller):
   TCPSocketHandler(poller),
   hostname_resolution_failed(false),
   connected(false),

M louloulibs/network/tcp_client_socket_handler.hpp => louloulibs/network/tcp_client_socket_handler.hpp +1 -1
@@ 5,7 5,7 @@
class TCPClientSocketHandler: public TCPSocketHandler
{
 public:
  TCPClientSocketHandler(std::shared_ptr<Poller> poller);
  TCPClientSocketHandler(std::shared_ptr<Poller>& poller);
  ~TCPClientSocketHandler();
  /**
   * Connect to the remote server, and call on_connected() if this

M louloulibs/network/tcp_server_socket.hpp => louloulibs/network/tcp_server_socket.hpp +1 -1
@@ 18,7 18,7 @@ template <typename RemoteSocketType>
class TcpSocketServer: public SocketHandler
{
 public:
  TcpSocketServer(std::shared_ptr<Poller> poller, const uint16_t port):
  TcpSocketServer(std::shared_ptr<Poller>& poller, const uint16_t port):
      SocketHandler(poller, -1)
  {
    if ((this->socket = ::socket(AF_INET6, SOCK_STREAM, 0)) == -1)

M louloulibs/network/tcp_socket_handler.cpp => louloulibs/network/tcp_socket_handler.cpp +1 -1
@@ 44,7 44,7 @@ using namespace std::chrono_literals;

namespace ph = std::placeholders;

TCPSocketHandler::TCPSocketHandler(std::shared_ptr<Poller> poller):
TCPSocketHandler::TCPSocketHandler(std::shared_ptr<Poller>& poller):
  SocketHandler(poller, -1),
  use_tls(false)
#ifdef BOTAN_FOUND

M louloulibs/network/tcp_socket_handler.hpp => louloulibs/network/tcp_socket_handler.hpp +1 -1
@@ 60,7 60,7 @@ class TCPSocketHandler: public SocketHandler
protected:
  ~TCPSocketHandler();
public:
  explicit TCPSocketHandler(std::shared_ptr<Poller> poller);
  explicit TCPSocketHandler(std::shared_ptr<Poller>& poller);
  TCPSocketHandler(const TCPSocketHandler&) = delete;
  TCPSocketHandler(TCPSocketHandler&&) = delete;
  TCPSocketHandler& operator=(const TCPSocketHandler&) = delete;

M louloulibs/xmpp/xmpp_component.cpp => louloulibs/xmpp/xmpp_component.cpp +1 -1
@@ 39,7 39,7 @@ 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, const std::string& hostname, const std::string& secret):
  TCPClientSocketHandler(poller),
  ever_auth(false),
  first_connection_try(true),

M louloulibs/xmpp/xmpp_component.hpp => louloulibs/xmpp/xmpp_component.hpp +1 -1
@@ 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, const std::string& hostname, const std::string& secret);
  virtual ~XmppComponent() = default;

  XmppComponent(const XmppComponent&) = delete;

M src/bridge/bridge.cpp => src/bridge/bridge.cpp +1 -1
@@ 29,7 29,7 @@ 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):
Bridge::Bridge(const std::string& user_jid, BiboumiComponent& xmpp, std::shared_ptr<Poller>& poller):
  user_jid(user_jid),
  xmpp(xmpp),
  poller(poller)

M src/bridge/bridge.hpp => src/bridge/bridge.hpp +1 -1
@@ 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(const std::string& user_jid, BiboumiComponent& xmpp, std::shared_ptr<Poller>& poller);
  ~Bridge() = default;

  Bridge(const Bridge&) = delete;

M src/identd/identd_server.hpp => src/identd/identd_server.hpp +1 -1
@@ 10,7 10,7 @@ class BiboumiComponent;
class IdentdServer: public TcpSocketServer<IdentdSocket>
{
 public:
  IdentdServer(const BiboumiComponent& biboumi_component, std::shared_ptr<Poller> poller, const uint16_t port):
  IdentdServer(const BiboumiComponent& biboumi_component, std::shared_ptr<Poller>& poller, const uint16_t port):
      TcpSocketServer<IdentdSocket>(poller, port),
      biboumi_component(biboumi_component)
  {}

M src/identd/identd_socket.cpp => src/identd/identd_socket.cpp +1 -1
@@ 8,7 8,7 @@

#include <logger/logger.hpp>

IdentdSocket::IdentdSocket(std::shared_ptr<Poller> poller, const socket_t socket, TcpSocketServer<IdentdSocket>& server):
IdentdSocket::IdentdSocket(std::shared_ptr<Poller>& poller, const socket_t socket, TcpSocketServer<IdentdSocket>& server):
  TCPSocketHandler(poller),
  server(dynamic_cast<IdentdServer&>(server))
{

M src/identd/identd_socket.hpp => src/identd/identd_socket.hpp +1 -1
@@ 17,7 17,7 @@ class TcpSocketServer;
class IdentdSocket: public TCPSocketHandler
{
 public:
  IdentdSocket(std::shared_ptr<Poller> poller, const socket_t socket, TcpSocketServer<IdentdSocket>& server);
  IdentdSocket(std::shared_ptr<Poller>& poller, const socket_t socket, TcpSocketServer<IdentdSocket>& server);
  ~IdentdSocket() = default;
  std::string generate_answer(const BiboumiComponent& biboumi, uint16_t local, uint16_t remote);


M src/irc/irc_client.cpp => src/irc/irc_client.cpp +1 -1
@@ 128,7 128,7 @@ static const std::unordered_map<std::string,
  {"502", {&IrcClient::on_generic_error, {2, 0}}},
};

IrcClient::IrcClient(std::shared_ptr<Poller> poller, const std::string& hostname,
IrcClient::IrcClient(std::shared_ptr<Poller>& poller, const std::string& hostname,
                     const std::string& nickname, const std::string& username,
                     const std::string& realname, const std::string& user_hostname,
                     Bridge& bridge):

M src/irc/irc_client.hpp => src/irc/irc_client.hpp +1 -1
@@ 26,7 26,7 @@ class Bridge;
class IrcClient: public TCPClientSocketHandler
{
public:
  explicit IrcClient(std::shared_ptr<Poller> poller, const std::string& hostname,
  explicit IrcClient(std::shared_ptr<Poller>& poller, const std::string& hostname,
                     const std::string& nickname, const std::string& username,
                     const std::string& realname, const std::string& user_hostname,
                     Bridge& bridge);

M src/xmpp/biboumi_component.cpp => src/xmpp/biboumi_component.cpp +1 -1
@@ 44,7 44,7 @@ static std::set<std::string> kickable_errors{
    };


BiboumiComponent::BiboumiComponent(std::shared_ptr<Poller> poller, const std::string& hostname, const std::string& secret):
BiboumiComponent::BiboumiComponent(std::shared_ptr<Poller>& poller, const std::string& hostname, const std::string& secret):
  XmppComponent(poller, hostname, secret),
  irc_server_adhoc_commands_handler(*this),
  irc_channel_adhoc_commands_handler(*this)

M src/xmpp/biboumi_component.hpp => src/xmpp/biboumi_component.hpp +1 -1
@@ 27,7 27,7 @@ using iq_responder_callback_t = std::function<void(Bridge* bridge, const Stanza&
class BiboumiComponent: public XmppComponent
{
public:
  explicit BiboumiComponent(std::shared_ptr<Poller> poller, const std::string& hostname, const std::string& secret);
  explicit BiboumiComponent(std::shared_ptr<Poller>& poller, const std::string& hostname, const std::string& secret);
  ~BiboumiComponent() = default;

  BiboumiComponent(const BiboumiComponent&) = delete;