diff options
Diffstat (limited to 'core/events.cpp')
-rw-r--r-- | core/events.cpp | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/core/events.cpp b/core/events.cpp index a177756..734557e 100644 --- a/core/events.cpp +++ b/core/events.cpp @@ -36,7 +36,7 @@ void* evt_handler::Execute(void* data) return handler(data); } -bool RegisterEventHandler(int type, EVENT_HANDLER func) +int RegisterEventHandler(int type, EVENT_HANDLER func) { if(!event_handlers.empty()) { @@ -55,7 +55,7 @@ bool RegisterEventHandler(int type, EVENT_HANDLER func) event_handlers_mutex.unlock(); } logger.log(LM_DEBUG, "failed to add handler for event %d, event %d not registerd to any plugin or core", type,type); - return true; + return 1; } int RegisterEventType(int type, int specialid) { @@ -69,14 +69,14 @@ int RegisterEventType(int type, int specialid) if((*i)->get_plugin_id() == specialid) { p = *i; - logger.log(LM_DEBUG, "special id is right, plugin is in plugin list.\n"); + logger.log(LM_DEBUG, "special id %d is right, plugin \"%s\" is in plugin list.\n", specialid, toUTF8(p->get_plugininfo()->name).c_str()); break; } } plugin_list_mutex.unlock(); if(!p) { - logger.log(LM_DEBUG, "event registration for plugin: %s failed, trying to register event with wrong special id %d, right special id for this plugin is %d.\n", p->get_plugininfo()->name, specialid, p->get_plugininfo()->pluginid); + logger.log(LM_DEBUG, "event registration for plugin: \"%s\" failed, trying to register event with wrong special id %d, right special id for this plugin is %d.\n", toUTF8(p->get_plugininfo()->name).c_str(), specialid, p->get_plugininfo()->pluginid); return 1; } } @@ -93,7 +93,7 @@ int RegisterEventType(int type, int specialid) { if((*i)->getType() == type) { - logger.log(LM_DEBUG, "event registration for plugin %s failed, event already registered", p->get_plugininfo()->name); + logger.log(LM_DEBUG, "event registration for plugin \"%s\" failed, event already registered", toUTF8(p->get_plugininfo()->name).c_str()); event_handlers_mutex.unlock(); return 1; } @@ -102,10 +102,11 @@ int RegisterEventType(int type, int specialid) } event_handlers.push_back(new evt_handler(type)); p->register_event(type); + logger.log(LM_DEBUG, "event %d registration for plugin \"%s\" succesful.\n", type, toUTF8(p->get_plugininfo()->name).c_str()); return 0; } -void* ExecuteEvent(int type,void* data) +void* ExecuteEvent(int type, int pluginid, void* data) { if(!event_handlers.empty()) { @@ -113,9 +114,12 @@ void* ExecuteEvent(int type,void* data) for(std::list<evt_handler*>::iterator i = event_handlers.begin(); i != end; ++i) { if((*i)->getType() == type) + { + logger.log(LM_DEBUG, "event %d found, executing...\n", type); return (*i)->Execute(data); + } } } - event_handlers.push_back(new evt_handler(type)); -// return (void*)&event_handlers.back()->Execute; TODO: + logger.log(LM_DEBUG, "event %d not found...\n", type); + return 0; } |