summaryrefslogtreecommitdiff
path: root/louloulibs/xmpp
diff options
context:
space:
mode:
authorFlorent Le Coz <louiz@louiz.org>2015-12-21 21:15:03 +0100
committerFlorent Le Coz <louiz@louiz.org>2015-12-23 11:05:54 +0100
commit9714d02018904b0c207a3f4d7de0be1a6a22774b (patch)
tree2357be6e7e2399e057aa3c3b8ded7286a96dc6ee /louloulibs/xmpp
parent7e2427148e9023483f266cd3ac4e167d50320796 (diff)
downloadbiboumi-9714d02018904b0c207a3f4d7de0be1a6a22774b.tar.gz
biboumi-9714d02018904b0c207a3f4d7de0be1a6a22774b.tar.bz2
biboumi-9714d02018904b0c207a3f4d7de0be1a6a22774b.tar.xz
biboumi-9714d02018904b0c207a3f4d7de0be1a6a22774b.zip
Also store a reference instead of a pointer, in AdhocCommandsHandler
Diffstat (limited to 'louloulibs/xmpp')
-rw-r--r--louloulibs/xmpp/adhoc_command.cpp14
-rw-r--r--louloulibs/xmpp/adhoc_command.hpp8
-rw-r--r--louloulibs/xmpp/adhoc_commands_handler.hpp7
-rw-r--r--louloulibs/xmpp/adhoc_session.hpp2
-rw-r--r--louloulibs/xmpp/xmpp_component.cpp2
5 files changed, 15 insertions, 18 deletions
diff --git a/louloulibs/xmpp/adhoc_command.cpp b/louloulibs/xmpp/adhoc_command.cpp
index b8b07c6..8a8bcff 100644
--- a/louloulibs/xmpp/adhoc_command.cpp
+++ b/louloulibs/xmpp/adhoc_command.cpp
@@ -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();
diff --git a/louloulibs/xmpp/adhoc_command.hpp b/louloulibs/xmpp/adhoc_command.hpp
index 1ff2bcf..a2e033a 100644
--- a/louloulibs/xmpp/adhoc_command.hpp
+++ b/louloulibs/xmpp/adhoc_command.hpp
@@ -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
diff --git a/louloulibs/xmpp/adhoc_commands_handler.hpp b/louloulibs/xmpp/adhoc_commands_handler.hpp
index cf9ca17..0614b2f 100644
--- a/louloulibs/xmpp/adhoc_commands_handler.hpp
+++ b/louloulibs/xmpp/adhoc_commands_handler.hpp
@@ -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.
*/
diff --git a/louloulibs/xmpp/adhoc_session.hpp b/louloulibs/xmpp/adhoc_session.hpp
index 7f07dc1..e98b6a8 100644
--- a/louloulibs/xmpp/adhoc_session.hpp
+++ b/louloulibs/xmpp/adhoc_session.hpp
@@ -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
{
diff --git a/louloulibs/xmpp/xmpp_component.cpp b/louloulibs/xmpp/xmpp_component.cpp
index ce9552f..a82892d 100644
--- a/louloulibs/xmpp/xmpp_component.cpp
+++ b/louloulibs/xmpp/xmpp_component.cpp
@@ -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));