M louloulibs/xmpp/adhoc_command.cpp => louloulibs/xmpp/adhoc_command.cpp +6 -8
@@ 20,7 20,7 @@ bool AdhocCommand::is_admin_only() const
return this->admin_only;
}
-void PingStep1(XmppComponent*, AdhocSession&, XmlNode& command_node)
+void PingStep1(XmppComponent&, AdhocSession&, XmlNode& command_node)
{
XmlNode note("note");
note["type"] = "info";
@@ 28,7 28,7 @@ void PingStep1(XmppComponent*, AdhocSession&, XmlNode& command_node)
command_node.add_child(std::move(note));
}
-void HelloStep1(XmppComponent*, AdhocSession&, XmlNode& command_node)
+void HelloStep1(XmppComponent&, AdhocSession&, XmlNode& command_node)
{
XmlNode x("jabber:x:data:x");
x["type"] = "form";
@@ 48,11 48,10 @@ void HelloStep1(XmppComponent*, AdhocSession&, XmlNode& command_node)
command_node.add_child(std::move(x));
}
-void HelloStep2(XmppComponent*, AdhocSession& session, XmlNode& command_node)
+void HelloStep2(XmppComponent&, AdhocSession& session, XmlNode& command_node)
{
// Find out if the name was provided in the form.
- const XmlNode* x = command_node.get_child("x", "jabber:x:data");
- if (x)
+ if (const XmlNode* x = command_node.get_child("x", "jabber:x:data"))
{
const XmlNode* name_field = nullptr;
for (const XmlNode* field: x->get_children("field", "jabber:x:data"))
@@ 63,8 62,7 @@ void HelloStep2(XmppComponent*, AdhocSession& session, XmlNode& command_node)
}
if (name_field)
{
- const XmlNode* value = name_field->get_child("value", "jabber:x:data");
- if (value)
+ if (const XmlNode* value = name_field->get_child("value", "jabber:x:data"))
{
XmlNode note("note");
note["type"] = "info";
@@ 84,7 82,7 @@ void HelloStep2(XmppComponent*, AdhocSession& session, XmlNode& command_node)
session.terminate();
}
-void Reload(XmppComponent*, AdhocSession&, XmlNode& command_node)
+void Reload(XmppComponent&, AdhocSession&, XmlNode& command_node)
{
::reload_process();
command_node.delete_all_children();
M louloulibs/xmpp/adhoc_command.hpp => louloulibs/xmpp/adhoc_command.hpp +4 -4
@@ 35,9 35,9 @@ private:
const bool admin_only;
};
-void PingStep1(XmppComponent*, AdhocSession& session, XmlNode& command_node);
-void HelloStep1(XmppComponent*, AdhocSession& session, XmlNode& command_node);
-void HelloStep2(XmppComponent*, AdhocSession& session, XmlNode& command_node);
-void Reload(XmppComponent*, AdhocSession& session, XmlNode& command_node);
+void PingStep1(XmppComponent&, AdhocSession& session, XmlNode& command_node);
+void HelloStep1(XmppComponent&, AdhocSession& session, XmlNode& command_node);
+void HelloStep2(XmppComponent&, AdhocSession& session, XmlNode& command_node);
+void Reload(XmppComponent&, AdhocSession& session, XmlNode& command_node);
#endif // ADHOC_COMMAND_HPP
M louloulibs/xmpp/adhoc_commands_handler.hpp => louloulibs/xmpp/adhoc_commands_handler.hpp +3 -4
@@ 16,7 16,7 @@
class AdhocCommandsHandler
{
public:
- explicit AdhocCommandsHandler(XmppComponent* xmpp_component):
+ explicit AdhocCommandsHandler(XmppComponent& xmpp_component):
xmpp_component(xmpp_component),
commands{}
{ }
@@ 50,10 50,9 @@ public:
void remove_session(const std::string& session_id, const std::string& initiator_jid);
private:
/**
- * A pointer to the XmppComponent, to access to basically anything in the
- * gateway.
+ * To access basically anything in the gateway.
*/
- XmppComponent* xmpp_component;
+ XmppComponent& xmpp_component;
/**
* The list of all available commands.
*/
M louloulibs/xmpp/adhoc_session.hpp => louloulibs/xmpp/adhoc_session.hpp +1 -1
@@ 17,7 17,7 @@ class AdhocSession;
* XmlNode and modifies it accordingly (inserting for example an <error/>
* node, or a data form…).
*/
-using AdhocStep = std::function<void(XmppComponent*, AdhocSession&, XmlNode&)>;
+using AdhocStep = std::function<void(XmppComponent&, AdhocSession&, XmlNode&)>;
class AdhocSession
{
M louloulibs/xmpp/xmpp_component.cpp => louloulibs/xmpp/xmpp_component.cpp +1 -1
@@ 45,7 45,7 @@ XmppComponent::XmppComponent(std::shared_ptr<Poller> poller, const std::string&
doc_open(false),
served_hostname(hostname),
stanza_handlers{},
- adhoc_commands_handler(this)
+ adhoc_commands_handler(*this)
{
this->parser.add_stream_open_callback(std::bind(&XmppComponent::on_remote_stream_open, this,
std::placeholders::_1));
M src/xmpp/biboumi_adhoc_commands.cpp => src/xmpp/biboumi_adhoc_commands.cpp +17 -17
@@ 17,9 17,9 @@
using namespace std::string_literals;
-void DisconnectUserStep1(XmppComponent* xmpp_component, AdhocSession&, XmlNode& command_node)
+void DisconnectUserStep1(XmppComponent& xmpp_component, AdhocSession&, XmlNode& command_node)
{
- auto biboumi_component = static_cast<BiboumiComponent*>(xmpp_component);
+ auto& biboumi_component = static_cast<BiboumiComponent&>(xmpp_component);
XmlNode x("jabber:x:data:x");
x["type"] = "form";
@@ 35,7 35,7 @@ void DisconnectUserStep1(XmppComponent* xmpp_component, AdhocSession&, XmlNode&
jids_field["label"] = "The JIDs to disconnect";
XmlNode required("required");
jids_field.add_child(std::move(required));
- for (Bridge* bridge: biboumi_component->get_bridges())
+ for (Bridge* bridge: biboumi_component.get_bridges())
{
XmlNode option("option");
option["label"] = bridge->get_jid();
@@ 57,9 57,9 @@ void DisconnectUserStep1(XmppComponent* xmpp_component, AdhocSession&, XmlNode&
command_node.add_child(std::move(x));
}
-void DisconnectUserStep2(XmppComponent* xmpp_component, AdhocSession& session, XmlNode& command_node)
+void DisconnectUserStep2(XmppComponent& xmpp_component, AdhocSession& session, XmlNode& command_node)
{
- auto biboumi_component = static_cast<BiboumiComponent*>(xmpp_component);
+ auto& biboumi_component = static_cast<BiboumiComponent&>(xmpp_component);
// Find out if the jids, and the quit message are provided in the form.
std::string quit_message;
@@ 84,7 84,7 @@ void DisconnectUserStep2(XmppComponent* xmpp_component, AdhocSession& session, X
std::size_t num = 0;
for (const XmlNode* value: jids_field->get_children("value", "jabber:x:data"))
{
- Bridge* bridge = biboumi_component->find_user_bridge(value->get_inner());
+ Bridge* bridge = biboumi_component.find_user_bridge(value->get_inner());
if (bridge)
{
bridge->shutdown(quit_message);
@@ 114,7 114,7 @@ void DisconnectUserStep2(XmppComponent* xmpp_component, AdhocSession& session, X
}
#ifdef USE_DATABASE
-void ConfigureIrcServerStep1(XmppComponent*, AdhocSession& session, XmlNode& command_node)
+void ConfigureIrcServerStep1(XmppComponent&, AdhocSession& session, XmlNode& command_node)
{
const Jid owner(session.get_owner_jid());
const Jid target(session.get_target_jid());
@@ 236,7 236,7 @@ void ConfigureIrcServerStep1(XmppComponent*, AdhocSession& session, XmlNode& com
command_node.add_child(std::move(x));
}
-void ConfigureIrcServerStep2(XmppComponent*, AdhocSession& session, XmlNode& command_node)
+void ConfigureIrcServerStep2(XmppComponent&, AdhocSession& session, XmlNode& command_node)
{
const XmlNode* x = command_node.get_child("x", "jabber:x:data");
if (x)
@@ 314,7 314,7 @@ void ConfigureIrcServerStep2(XmppComponent*, AdhocSession& session, XmlNode& com
}
#endif // USE_DATABASE
-void DisconnectUserFromServerStep1(XmppComponent* xmpp_component, AdhocSession& session, XmlNode& command_node)
+void DisconnectUserFromServerStep1(XmppComponent& xmpp_component, AdhocSession& session, XmlNode& command_node)
{
const Jid owner(session.get_owner_jid());
if (owner.bare() != Config::get("admin", ""))
@@ 325,7 325,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 = static_cast<BiboumiComponent&>(xmpp_component);
XmlNode x("jabber:x:data:x");
x["type"] = "form";
@@ 341,7 341,7 @@ void DisconnectUserFromServerStep1(XmppComponent* xmpp_component, AdhocSession&
jids_field["label"] = "The JID to disconnect";
XmlNode required("required");
jids_field.add_child(std::move(required));
- for (Bridge* bridge: biboumi_component->get_bridges())
+ for (Bridge* bridge: biboumi_component.get_bridges())
{
XmlNode option("option");
option["label"] = bridge->get_jid();
@@ 355,7 355,7 @@ void DisconnectUserFromServerStep1(XmppComponent* xmpp_component, AdhocSession&
}
}
-void DisconnectUserFromServerStep2(XmppComponent* xmpp_component, AdhocSession& session, XmlNode& command_node)
+void DisconnectUserFromServerStep2(XmppComponent& xmpp_component, AdhocSession& session, XmlNode& command_node)
{
// If no JID is contained in the command node, it means we skipped the
// previous stage, and the jid to disconnect is the executor's jid
@@ 377,7 377,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 = static_cast<BiboumiComponent&>(xmpp_component);
XmlNode x("jabber:x:data:x");
x["type"] = "form";
@@ 393,7 393,7 @@ void DisconnectUserFromServerStep2(XmppComponent* xmpp_component, AdhocSession&
jids_field["label"] = "The servers to disconnect from";
XmlNode required("required");
jids_field.add_child(std::move(required));
- Bridge* bridge = biboumi_component->find_user_bridge(jid_to_disconnect);
+ Bridge* bridge = biboumi_component.find_user_bridge(jid_to_disconnect);
if (!bridge || bridge->get_irc_clients().empty())
{
@@ 428,7 428,7 @@ void DisconnectUserFromServerStep2(XmppComponent* xmpp_component, AdhocSession&
command_node.add_child(std::move(x));
}
-void DisconnectUserFromServerStep3(XmppComponent* xmpp_component, AdhocSession& session, XmlNode& command_node)
+void DisconnectUserFromServerStep3(XmppComponent& xmpp_component, AdhocSession& session, XmlNode& command_node)
{
const auto it = session.vars.find("jid");
if (it == session.vars.end())
@@ 453,8 453,8 @@ void DisconnectUserFromServerStep3(XmppComponent* xmpp_component, AdhocSession&
}
}
- auto biboumi_component = static_cast<BiboumiComponent*>(xmpp_component);
- Bridge* bridge = biboumi_component->find_user_bridge(jid_to_disconnect);
+ auto& biboumi_component = static_cast<BiboumiComponent&>(xmpp_component);
+ Bridge* bridge = biboumi_component.find_user_bridge(jid_to_disconnect);
auto& clients = bridge->get_irc_clients();
std::size_t number = 0;
M src/xmpp/biboumi_adhoc_commands.hpp => src/xmpp/biboumi_adhoc_commands.hpp +7 -7
@@ 7,14 7,14 @@
class XmppComponent;
-void DisconnectUserStep1(XmppComponent*, AdhocSession& session, XmlNode& command_node);
-void DisconnectUserStep2(XmppComponent*, AdhocSession& session, XmlNode& command_node);
+void DisconnectUserStep1(XmppComponent&, AdhocSession& session, XmlNode& command_node);
+void DisconnectUserStep2(XmppComponent&, AdhocSession& session, XmlNode& command_node);
-void ConfigureIrcServerStep1(XmppComponent*, AdhocSession& session, XmlNode& command_node);
-void ConfigureIrcServerStep2(XmppComponent*, AdhocSession& session, XmlNode& command_node);
+void ConfigureIrcServerStep1(XmppComponent&, AdhocSession& session, XmlNode& command_node);
+void ConfigureIrcServerStep2(XmppComponent&, AdhocSession& session, XmlNode& command_node);
-void DisconnectUserFromServerStep1(XmppComponent*, AdhocSession& session, XmlNode& command_node);
-void DisconnectUserFromServerStep2(XmppComponent*, AdhocSession& session, XmlNode& command_node);
-void DisconnectUserFromServerStep3(XmppComponent*, AdhocSession& session, XmlNode& command_node);
+void DisconnectUserFromServerStep1(XmppComponent&, AdhocSession& session, XmlNode& command_node);
+void DisconnectUserFromServerStep2(XmppComponent&, AdhocSession& session, XmlNode& command_node);
+void DisconnectUserFromServerStep3(XmppComponent&, AdhocSession& session, XmlNode& command_node);
#endif /* BIBOUMI_ADHOC_COMMANDS_HPP_INCLUDED */
M src/xmpp/biboumi_component.cpp => src/xmpp/biboumi_component.cpp +1 -1
@@ 43,7 43,7 @@ static std::set<std::string> kickable_errors{
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_server_adhoc_commands_handler(*this)
{
this->stanza_handlers.emplace("presence",
std::bind(&BiboumiComponent::handle_presence, this,std::placeholders::_1));