summaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
Diffstat (limited to 'core')
-rw-r--r--core/commonheaders.h1
-rw-r--r--core/main.cpp3
-rw-r--r--core/modules.cpp45
3 files changed, 37 insertions, 12 deletions
diff --git a/core/commonheaders.h b/core/commonheaders.h
index 3ad748c..23a419f 100644
--- a/core/commonheaders.h
+++ b/core/commonheaders.h
@@ -16,6 +16,7 @@
#include <wx/dynlib.h>
#include <wx/dir.h>
#include <wx/log.h>
+#include <wx/stdpaths.h>
#include <list>
#include "../api/pluginapi.h"
diff --git a/core/main.cpp b/core/main.cpp
index b7d2204..5d324e0 100644
--- a/core/main.cpp
+++ b/core/main.cpp
@@ -7,11 +7,12 @@ public:
virtual bool OnInit();
};
-
bool EvilCore::OnInit()
{
void load_modules();
load_modules();
+ while(true)
+ sleep(10);
return 0;
}
IMPLEMENT_APP(EvilCore)
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));