From 6add86d17a430db932bc0dc9af44da5dcb327fec Mon Sep 17 00:00:00 2001 From: Gluzskiy Alexandr Date: Sat, 30 Oct 2010 21:19:05 +0300 Subject: service usage example --- plugins/example/main.cpp | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'plugins/example') diff --git a/plugins/example/main.cpp b/plugins/example/main.cpp index 4ca212c..bd1f65b 100644 --- a/plugins/example/main.cpp +++ b/plugins/example/main.cpp @@ -5,8 +5,11 @@ #include //this is necessary, PLUGININFO structure, other related to load/unload plugin code + PLUGINLINK *pluginLink; +#define CallService(service, param) pluginLink->CallService(service,param) + class wxPluginForEvilCore: public wxApp //this is like on default wxwidgets application { virtual bool OnInit(); @@ -17,7 +20,14 @@ PLUGINLINK *pluginLink; bool wxPluginForEvilCore::OnInit() { wxMessageBox(_T("I am a plugin example") ,_T("Info"), wxOK | wxICON_INFORMATION); - return true; + int *core_version = (int*)CallService("EC/GetVersionInt", NULL); //using service implemented somewhere (in core, in plugins, in other place), NULL is data required for service + if(core_version) + { + wxChar msg[32]; + wxSnprintf(msg, 31, _T("Core version is %d."), core_version); + wxMessageBox(msg, _T("Info"), wxOK | wxICON_INFORMATION); + } + return true; } #ifdef _WIN32 @@ -69,7 +79,7 @@ extern "C" int on_modules_loaded() //load main code from here, all services from #ifdef _WIN32 wxEntry(GetModuleHandle(NULL),NULL,NULL,SW_SHOW); #else - int i = 0; + int i = 1; char **params = (char**)malloc(2); params[0] = (char*)malloc(2); strcpy(params[0], ""); -- cgit v1.2.3