diff options
author | Gluzskiy Alexandr <sss123next@list.ru> | 2011-03-18 00:12:17 +0200 |
---|---|---|
committer | Gluzskiy Alexandr <sss123next@list.ru> | 2011-03-18 00:12:17 +0200 |
commit | 4bcc86b7413f5ce76a1ceac92aa566a9bf13d685 (patch) | |
tree | 323cd03aaea1f5ff69cce4236b66f1130e9452b9 /plugins/example | |
parent | f4a5bae0c010e3c20d6420c9de2bb74182b26b6e (diff) |
service usage example in plugin example
modified: api/ec_pluginapi.h
modified: core/services.cpp
modified: core/services.h
modified: plugins/example/main.cpp
Diffstat (limited to 'plugins/example')
-rw-r--r-- | plugins/example/main.cpp | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/plugins/example/main.cpp b/plugins/example/main.cpp index 00fde1e..b5af37f 100644 --- a/plugins/example/main.cpp +++ b/plugins/example/main.cpp @@ -25,6 +25,12 @@ EVENT_HANDLER our_handler(void* data) //this is event handler fuction return (void*(*)(void*))data; //just return data which we obtaned } +SERVICE our_service(void *data) //this is a service function +{ + wxMessageBox(_T("Our test service are working )"), _T("Info"), wxOK | wxICON_INFORMATION); + return 0; +} + bool wxPluginForEvilCore::OnInit() { wxMessageBox(_T("I am a plugin example") ,_T("Info"), wxOK | wxICON_INFORMATION); @@ -76,6 +82,23 @@ bool wxPluginForEvilCore::OnInit() free(str); //should be freed wxMessageBox(msg, _T("Info"), wxOK | wxICON_INFORMATION); } + //register our service in core + { + if(!pluginLink->CreateServiceFunction("ExamplePlugin/TestService", (void* (*)(void*))our_service)) + { + wxChar msg[64]; + wxSnprintf(msg, 63, _T("we have succesfuly registered service \"ExamplePlugin/TestService\"")); + wxMessageBox(msg, _T("Info"), wxOK | wxICON_INFORMATION); + } + else + { + wxChar msg[128]; + wxSnprintf(msg, 127, _T("we have failed to register service \"ExamplePlugin/TestService\"")); + wxMessageBox(msg, _T("Info"), wxOK | wxICON_INFORMATION); + } + } + if(pluginLink->ServiceExists("ExamplePlugin/TestService")) //check if service which we want to call exists + CallService("ExamplePlugin/TestService", 0); //call service return true; } |