Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
louiz’
biboumi
Commits
7115aa3b
Commit
7115aa3b
authored
Feb 24, 2015
by
louiz’
Browse files
Add a reload add-hoc command
parent
9837f611
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
41 additions
and
7 deletions
+41
-7
CHANGELOG
CHANGELOG
+1
-0
src/main.cpp
src/main.cpp
+2
-6
src/utils/reload.cpp
src/utils/reload.cpp
+13
-0
src/utils/reload.hpp
src/utils/reload.hpp
+10
-0
src/xmpp/adhoc_command.cpp
src/xmpp/adhoc_command.cpp
+12
-0
src/xmpp/adhoc_command.hpp
src/xmpp/adhoc_command.hpp
+1
-0
src/xmpp/adhoc_commands_handler.cpp
src/xmpp/adhoc_commands_handler.cpp
+2
-1
No files found.
CHANGELOG
View file @
7115aa3b
...
...
@@ -11,6 +11,7 @@ Version 2.0
instead of immediately. This avoid hogging resources for nothing
- Asynchronously resolve domain names by optionally using the DNS
library c-ares.
- Add a reload add-hoc command, to reload biboumi's configuration
Version 1.1 2014-16-07
...
...
src/main.cpp
View file @
7115aa3b
...
...
@@ -3,6 +3,7 @@
#include <network/poller.hpp>
#include <config/config.hpp>
#include <logger/logger.hpp>
#include <utils/reload.hpp>
#include <iostream>
#include <memory>
...
...
@@ -123,13 +124,8 @@ int main(int ac, char** av)
}
if
(
reload
)
{
// Closing the config will just force it to be reopened the next time
// a configuration option is needed
log_info
(
"Signal received, reloading the config..."
);
Config
::
close
();
// Destroy the logger instance, to be recreated the next time a log
// line needs to be written
Logger
::
instance
().
reset
();
::
reload_process
();
reload
.
store
(
false
);
}
// Reconnect to the XMPP server if this was not intended. This may have
...
...
src/utils/reload.cpp
0 → 100644
View file @
7115aa3b
#include <config/config.hpp>
#include <logger/logger.hpp>
void
reload_process
()
{
// Closing the config will just force it to be reopened the next time
// a configuration option is needed
Config
::
close
();
// Destroy the logger instance, to be recreated the next time a log
// line needs to be written
Logger
::
instance
().
reset
();
log_debug
(
"Configuration and logger reloaded."
);
}
src/utils/reload.hpp
0 → 100644
View file @
7115aa3b
#ifndef RELOAD_HPP_INCLUDED
#define RELOAD_HPP_INCLUDED
/**
* Reload the server's configuration, and close the logger (so that it
* closes its files etc, to take into account the new configuration)
*/
void
reload_process
();
#endif
/* RELOAD_HPP_INCLUDED */
src/xmpp/adhoc_command.cpp
View file @
7115aa3b
...
...
@@ -3,6 +3,8 @@
#include <bridge/bridge.hpp>
#include <utils/reload.hpp>
using
namespace
std
::
string_literals
;
AdhocCommand
::
AdhocCommand
(
std
::
vector
<
AdhocStep
>&&
callbacks
,
const
std
::
string
&
name
,
const
bool
admin_only
)
:
...
...
@@ -198,3 +200,13 @@ void DisconnectUserStep2(XmppComponent* xmpp_component, AdhocSession& session, X
session
.
terminate
();
}
void
Reload
(
XmppComponent
*
,
AdhocSession
&
session
,
XmlNode
&
command_node
)
{
::
reload_process
();
command_node
.
delete_all_children
();
XmlNode
note
(
"note"
);
note
[
"type"
]
=
"info"
;
note
.
set_inner
(
"Configuration reloaded."
);
note
.
close
();
command_node
.
add_child
(
std
::
move
(
note
));
}
src/xmpp/adhoc_command.hpp
View file @
7115aa3b
...
...
@@ -40,5 +40,6 @@ void HelloStep1(XmppComponent*, AdhocSession& session, XmlNode& command_node);
void
HelloStep2
(
XmppComponent
*
,
AdhocSession
&
session
,
XmlNode
&
command_node
);
void
DisconnectUserStep1
(
XmppComponent
*
,
AdhocSession
&
session
,
XmlNode
&
command_node
);
void
DisconnectUserStep2
(
XmppComponent
*
,
AdhocSession
&
session
,
XmlNode
&
command_node
);
void
Reload
(
XmppComponent
*
,
AdhocSession
&
session
,
XmlNode
&
command_node
);
#endif // ADHOC_COMMAND_HPP
src/xmpp/adhoc_commands_handler.cpp
View file @
7115aa3b
...
...
@@ -15,7 +15,8 @@ AdhocCommandsHandler::AdhocCommandsHandler(XmppComponent* xmpp_component):
commands
{
{
"ping"
,
AdhocCommand
({
&
PingStep1
},
"Do a ping"
,
false
)},
{
"hello"
,
AdhocCommand
({
&
HelloStep1
,
&
HelloStep2
},
"Receive a custom greeting"
,
false
)},
{
"disconnect-user"
,
AdhocCommand
({
&
DisconnectUserStep1
,
&
DisconnectUserStep2
},
"Disconnect a user from the gateway"
,
true
)}
{
"disconnect-user"
,
AdhocCommand
({
&
DisconnectUserStep1
,
&
DisconnectUserStep2
},
"Disconnect a user from the gateway"
,
true
)},
{
"reload"
,
AdhocCommand
({
&
Reload
},
"Reload biboumi’s configuration"
,
true
)}
}
{
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment