summaryrefslogtreecommitdiff
path: root/src/xmpp/biboumi_component.cpp
diff options
context:
space:
mode:
authorlouiz’ <louiz@louiz.org>2016-09-29 20:53:40 +0200
committerlouiz’ <louiz@louiz.org>2016-09-29 20:53:40 +0200
commitee4cf5dc2d3eaa43794a8ac736a6409e08082882 (patch)
treecc463fcacd4b5ebf06f67de2a5cad44c78c8542c /src/xmpp/biboumi_component.cpp
parent363a0bf02cf20592b2f9f034de1c5f54c8922b82 (diff)
downloadbiboumi-ee4cf5dc2d3eaa43794a8ac736a6409e08082882.tar.gz
biboumi-ee4cf5dc2d3eaa43794a8ac736a6409e08082882.tar.bz2
biboumi-ee4cf5dc2d3eaa43794a8ac736a6409e08082882.tar.xz
biboumi-ee4cf5dc2d3eaa43794a8ac736a6409e08082882.zip
Add AdhocCommandHandlers::add_command to simplify the usage of this class
And make things a little bit clearer
Diffstat (limited to 'src/xmpp/biboumi_component.cpp')
-rw-r--r--src/xmpp/biboumi_component.cpp31
1 files changed, 10 insertions, 21 deletions
diff --git a/src/xmpp/biboumi_component.cpp b/src/xmpp/biboumi_component.cpp
index c810ce3..2b4ff18 100644
--- a/src/xmpp/biboumi_component.cpp
+++ b/src/xmpp/biboumi_component.cpp
@@ -56,35 +56,24 @@ BiboumiComponent::BiboumiComponent(std::shared_ptr<Poller> poller, const std::st
this->stanza_handlers.emplace("iq",
std::bind(&BiboumiComponent::handle_iq, this,std::placeholders::_1));
- this->adhoc_commands_handler.get_commands() = {
- {"ping", AdhocCommand({&PingStep1}, "Do a ping", false)},
- {"hello", AdhocCommand({&HelloStep1, &HelloStep2}, "Receive a custom greeting", false)},
- {"disconnect-user", AdhocCommand({&DisconnectUserStep1, &DisconnectUserStep2}, "Disconnect selected users from the gateway", true)},
- {"disconnect-from-irc-servers", AdhocCommand({&DisconnectUserFromServerStep1, &DisconnectUserFromServerStep2, &DisconnectUserFromServerStep3}, "Disconnect from the selected IRC servers", false)},
- {"reload", AdhocCommand({&Reload}, "Reload biboumi’s configuration", true)}
- };
+ this->adhoc_commands_handler.add_command("ping", {{&PingStep1}, "Do a ping", false});
+ this->adhoc_commands_handler.add_command("hello", {{&HelloStep1, &HelloStep2}, "Receive a custom greeting", false});
+ this->adhoc_commands_handler.add_command("disconnect-user", {{&DisconnectUserStep1, &DisconnectUserStep2}, "Disconnect selected users from the gateway", true});
+ this->adhoc_commands_handler.add_command("hello", {{&HelloStep1, &HelloStep2}, "Receive a custom greeting", false});
+ this->adhoc_commands_handler.add_command("reload", {{&Reload}, "Reload biboumi’s configuration", true});
#ifdef USE_DATABASE
AdhocCommand configure_server_command({&ConfigureIrcServerStep1, &ConfigureIrcServerStep2}, "Configure a few settings for that IRC server", false);
AdhocCommand configure_global_command({&ConfigureGlobalStep1, &ConfigureGlobalStep2}, "Configure a few settings", false);
+
if (!Config::get("fixed_irc_server", "").empty())
- this->adhoc_commands_handler.get_commands().emplace(std::make_pair("configure",
- configure_server_command));
+ this->adhoc_commands_handler.add_command("configure", configure_server_command);
else
- this->adhoc_commands_handler.get_commands().emplace(std::make_pair("configure",
- configure_global_command));
-#endif
+ this->adhoc_commands_handler.add_command("configure", configure_global_command);
- this->irc_server_adhoc_commands_handler.get_commands() = {
-#ifdef USE_DATABASE
- {"configure", configure_server_command},
-#endif
- };
- this->irc_channel_adhoc_commands_handler.get_commands() = {
-#ifdef USE_DATABASE
- {"configure", AdhocCommand({&ConfigureIrcChannelStep1, &ConfigureIrcChannelStep2}, "Configure a few settings for that IRC channel", false)},
+ this->irc_server_adhoc_commands_handler.add_command("configure", configure_server_command);
+ this->irc_channel_adhoc_commands_handler.add_command("configure", {{&ConfigureIrcChannelStep1, &ConfigureIrcChannelStep2}, "Configure a few settings for that IRC channel", false});
#endif
- };
}
void BiboumiComponent::shutdown()