summaryrefslogtreecommitdiff
path: root/core/modules.cpp
diff options
context:
space:
mode:
authorGluzskiy Alexandr <sss123next@list.ru>2010-10-15 06:16:26 +0300
committerGluzskiy Alexandr <sss123next@list.ru>2010-10-15 06:16:26 +0300
commitbd197c2ad7e360fb8008c50f8d423072926428dd (patch)
tree3124defbcbccd7f20e170a081fe4ff12b4e6058c /core/modules.cpp
parent2760d3e7c0de77ddb969db78349ec472a20299bf (diff)
something working
Diffstat (limited to 'core/modules.cpp')
-rw-r--r--core/modules.cpp45
1 files changed, 34 insertions, 11 deletions
diff --git a/core/modules.cpp b/core/modules.cpp
index 50bb7ac..d094311 100644
--- a/core/modules.cpp
+++ b/core/modules.cpp
@@ -4,40 +4,62 @@ std::list<plugin*> plugins;
void load_modules()
{
- wxDir dir((wxChar*)"./plugins");
+ wxStandardPaths *pth = new wxStandardPaths;
+ wxString path = wxPathOnly(pth->GetExecutablePath());
+ delete pth;
+#ifdef _WIN32
+ path.append((wxChar*)_T("\\plugins"));
+#else
+ path.append((wxChar*)_T("/plugins"));
+#endif
+ wxDir dir(path);
+// wxMessageBox(path ,_("path"), wxOK | wxICON_INFORMATION);
+
if(!dir.IsOpened())
{
- wxLogDebug("Plugins directory does not exists\n");
+ wxMessageBox(_T("Plugins directory does not exists") ,_T("Error"), wxOK | wxICON_ERROR);
+ wxLogDebug(_T("Plugins directory does not exists\n"));
return;
}
wxString filename;
#ifdef _WIN32
- if(!dir.GetFirst(&filename, (wxChar*)".dll", 0))
+ if(!dir.GetFirst(&filename, _T("*.dll"), wxDIR_FILES | wxDIR_HIDDEN))
{
- wxLogDebug("Plugins directory does not contain plugins\n");
+ wxMessageBox(_T("Plugins directory does not contain plugins") ,_T("Error"), wxOK | wxICON_ERROR);
+ wxLogDebug((wxChar*)_T("Plugins directory does not contain plugins\n"));
return;
}
#else
- if(!dir.GetFirst(&filename, (wxChar*)".so", 0))
+ if(!dir.GetFirst(&filename, _T("*.so"), wxDIR_FILES | wxDIR_HIDDEN))
{
- wxLogDebug("Plugins directory does not contain plugins\n");
+ wxMessageBox(_T("Plugins directory does not contain plugins") ,_T("Error"), wxOK | wxICON_ERROR);
+ wxLogDebug(_T("Plugins directory does not contain plugins\n"));
return;
}
#endif
do
{
- wxDynamicLibrary *plug = new wxDynamicLibrary(filename);
+ wxString lib_path = path;
+#ifdef _WIN32
+ lib_path += _T("\\");
+#else
+ lib_path += _T("/");
+#endif
+ lib_path += filename;
+ wxDynamicLibrary *plug = new wxDynamicLibrary(lib_path);
+ if(!plug->IsLoaded())
+ wxMessageBox(_T("Failed to load plugin") ,_T("Error"), wxOK | wxICON_ERROR);
bool is_plugin = true;
plugin::exported_functions_s *funcs = new plugin::exported_functions_s;
- if((funcs->Load = (load)plug->GetSymbol((wxChar*)"load")) == NULL)
+ if((funcs->Load = (load)plug->GetSymbol(_T("load"))) == NULL)
is_plugin = false;
- if((funcs->OnModulesLoaded = (on_modules_loaded)plug->GetSymbol((wxChar*)"on_modules_loaded")) == NULL)
+ if((funcs->OnModulesLoaded = (on_modules_loaded)plug->GetSymbol(_T("on_modules_loaded"))) == NULL)
is_plugin = false;
- if((funcs->Unload = (unload)plug->GetSymbol((wxChar*)"unload")) == NULL)
+ if((funcs->Unload = (unload)plug->GetSymbol(_T("unload"))) == NULL)
is_plugin = false;
- if((funcs->SetPluginInfo = (set_plugin_info)plug->GetSymbol((wxChar*)"set_plugin_info")) == NULL)
+ if((funcs->SetPluginInfo = (set_plugin_info)plug->GetSymbol(_T("set_plugin_info"))) == NULL)
is_plugin = false;
if(!is_plugin)
{
@@ -47,6 +69,7 @@ void load_modules()
}
PLUGININFO *info = funcs->SetPluginInfo();
plugins.push_back(new plugin(plug, info, funcs));
+ lib_path.clear();
}
while(dir.GetNext(&filename));