Commit 80f2becd authored by Gabriel Margiani's avatar Gabriel Margiani

Don't try to call empty event handler path.

parent 08fd8065
......@@ -22,30 +22,38 @@
#include "eventhook.h"
p3::eventHook::eventHook(config& c, phonebook& p) :
p3::eventHook::eventHook(config& c, phonebook& p) :
conf(c),
book(p),
command(conf.get_string("hook:command"))
{
if (command == "none") {
command = "";
}
signal(SIGCHLD, SIG_IGN);
}
std::list<p3::eventHook::callback_type>::iterator p3::eventHook::register_callback(callback_type c) {
std::list<p3::eventHook::callback_type>::iterator p3::eventHook::register_callback(const callback_type& c) {
return callbacks.insert(callbacks.end(), c);
}
void p3::eventHook::unregister_callback(std::list<p3::eventHook::callback_type>::iterator id) {
void p3::eventHook::unregister_callback(const std::list<p3::eventHook::callback_type>::iterator& id) {
callbacks.erase(id);
}
void p3::eventHook::run_call_hook(std::string event, int cid, std::string nr, std::string data) {
void p3::eventHook::run_call_hook(const std::string& event, int cid, const std::string& nr, const std::string& data) {
run_hook(event, std::to_string(cid), book.address_by_nr(nr), data);
}
void p3::eventHook::run_hook(std::string event, const std::string& a2, const std::string& a3, const std::string& a4) {
void p3::eventHook::run_hook(const std::string& event, const std::string& a2, const std::string& a3, const std::string& a4) {
for (auto c : callbacks) {
c(event, a2, a3, a4);
}
if (command.empty()) {
return;
}
int pid = fork();
if (pid == 0) {
execl(
......
......@@ -59,11 +59,11 @@ namespace p3 {
explicit eventHook(config& c, phonebook& p);
void run_hook(std::string event, const std::string& a2 = "", const std::string& a3 = "", const std::string& a4 = "");
void run_call_hook(std::string event, int call_id = 0, std::string nr = "", std::string data = "");
void run_hook(const std::string& event, const std::string& a2 = "", const std::string& a3 = "", const std::string& a4 = "");
void run_call_hook(const std::string& event, int call_id = 0, const std::string& nr = "", const std::string& data = "");
std::list<callback_type>::iterator register_callback(callback_type callback);
void unregister_callback(std::list<callback_type>::iterator id);
std::list<callback_type>::iterator register_callback(const callback_type& callback);
void unregister_callback(const std::list<callback_type>::iterator& id);
};
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment