summaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
Diffstat (limited to 'core')
-rw-r--r--core/events.cpp20
-rw-r--r--core/events.h3
-rw-r--r--core/main.cpp2
-rw-r--r--core/services.cpp4
-rw-r--r--core/services.h2
5 files changed, 18 insertions, 13 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;
}
diff --git a/core/events.h b/core/events.h
index 17b2497..c5e1dc4 100644
--- a/core/events.h
+++ b/core/events.h
@@ -16,8 +16,9 @@
#ifndef EVENTS_H_INCLUDED
#define EVENTS_H_INCLUDED
-bool RegisterEventHandler(int, EVENT_HANDLER);
+int RegisterEventHandler(int, EVENT_HANDLER);
int RegisterEventType(int, int);
+void* ExecuteEvent(int type, int pluginid, void* data);
class evt_handler{
public:
diff --git a/core/main.cpp b/core/main.cpp
index 73e88f3..29d2bd1 100644
--- a/core/main.cpp
+++ b/core/main.cpp
@@ -28,7 +28,7 @@ int current_plugin_id = 13;
bool halt_requested = false;
-PLUGINLINK pluglink = {&CreateServiceFunction, &CallService, &ServiceExists, &RegisterEventHandler, &RegisterEventType};
+PLUGINLINK pluglink = {&CreateServiceFunction, &CallService, &ServiceExists, &RegisterEventHandler, &RegisterEventType, &ExecuteEvent};
int on_exit()
{
diff --git a/core/services.cpp b/core/services.cpp
index 3344ca4..903ee1a 100644
--- a/core/services.cpp
+++ b/core/services.cpp
@@ -20,7 +20,7 @@
extern std::list<service*> services;
extern boost::mutex service_list_mutex;
-bool ServiceExists(const char *name);
+int ServiceExists(const char *name);
void CreateServiceFunction(const char* name, SERVICE svc)
{
if(!ServiceExists(name))
@@ -45,7 +45,7 @@ void* CallService(const char *name,void* data)
}
return 0;
}
-bool ServiceExists(const char *name)
+int ServiceExists(const char *name)
{
service_list_mutex.lock();
if(!services.empty())
diff --git a/core/services.h b/core/services.h
index 61d111b..15da2f3 100644
--- a/core/services.h
+++ b/core/services.h
@@ -33,7 +33,7 @@ private:
void CreateServiceFunction(const char* name, SERVICE svc);
void* CallService(const char *,void*);
-bool ServiceExists(const char *);
+int ServiceExists(const char *);
#endif // SERVICES_H_INCLUDED