#include "admins_impl.h"
#include "tariffs_impl.h"
#include "users_impl.h"
+#include "services_impl.h"
+#include "corps_impl.h"
//-----------------------------------------------------------------------------
PLUGIN_RUNNER::PLUGIN_RUNNER(const std::string & pFileName,
ADMINS_IMPL * a,
TARIFFS_IMPL * t,
USERS_IMPL * u,
+ SERVICES_IMPL * svc,
+ CORPORATIONS_IMPL * crp,
TRAFFCOUNTER * tc,
STORE * st,
const SETTINGS_IMPL * s)
admins(a),
tariffs(t),
users(u),
+ services(svc),
+ corps(crp),
store(st),
traffCnt(tc),
stgSettings(s),
admins(rvalue.admins),
tariffs(rvalue.tariffs),
users(rvalue.users),
+ services(rvalue.services),
+ corps(rvalue.corps),
store(rvalue.store),
traffCnt(rvalue.traffCnt),
stgSettings(rvalue.stgSettings),
admins = rvalue.admins;
tariffs = rvalue.tariffs;
users = rvalue.users;
+services = rvalue.services;
+corps = rvalue.corps;
store = rvalue.store;
traffCnt = rvalue.traffCnt;
stgSettings = rvalue.stgSettings;
if (!isPluginLoaded)
{
errorStr = "Plugin '" + pluginFileName + "' is not loaded yet!";
- printfd(__FILE__, "PLUGIN_LOADER::GetPlugin() - %s\n", errorStr.c_str());
+ printfd(__FILE__, "PLUGIN_RUNNER::GetPlugin() - %s\n", errorStr.c_str());
return NULL;
}
if (!plugin)
{
errorStr = "Plugin '" + pluginFileName + "' was not created!";
- printfd(__FILE__, "PLUGIN_LOADER::Start() - %s\n", errorStr.c_str());
+ printfd(__FILE__, "PLUGIN_RUNNER::Start() - %s\n", errorStr.c_str());
return -1;
}
plugin->SetTariffs(tariffs);
plugin->SetAdmins(admins);
plugin->SetUsers(users);
+plugin->SetServices(services);
+plugin->SetCorporations(corps);
plugin->SetTraffcounter(traffCnt);
plugin->SetStore(store);
plugin->SetStgSettings(stgSettings);
if (!isPluginLoaded)
{
errorStr = "Plugin '" + pluginFileName + "' was not loaded yet!";
- printfd(__FILE__, "PLUGIN_LOADER::Stop() - %s\n", errorStr.c_str());
+ printfd(__FILE__, "PLUGIN_RUNNER::Stop() - %s\n", errorStr.c_str());
return -1;
}
if (!plugin)
{
errorStr = "Plugin '" + pluginFileName + "' was not created!";
- printfd(__FILE__, "PLUGIN_LOADER::Stop() - %s\n", errorStr.c_str());
+ printfd(__FILE__, "PLUGIN_RUNNER::Stop() - %s\n", errorStr.c_str());
return -1;
}
-plugin->Stop();
-
-return 0;
+return plugin->Stop();
}
//-----------------------------------------------------------------------------
int PLUGIN_RUNNER::Reload()
if (!isPluginLoaded)
{
errorStr = "Plugin '" + pluginFileName + "' was not loaded yet!";
- printfd(__FILE__, "PLUGIN_LOADER::Reload() - %s\n", errorStr.c_str());
+ printfd(__FILE__, "PLUGIN_RUNNER::Reload() - %s\n", errorStr.c_str());
return -1;
}
if (!plugin)
{
errorStr = "Plugin '" + pluginFileName + "' was not created!";
- printfd(__FILE__, "PLUGIN_LOADER::Reload() - %s\n", errorStr.c_str());
+ printfd(__FILE__, "PLUGIN_RUNNER::Reload() - %s\n", errorStr.c_str());
return -1;
}
if (!isPluginLoaded)
{
errorStr = "Plugin '" + pluginFileName + "' was not loaded yet!";
- printfd(__FILE__, "PLUGIN_LOADER::IsRunning() - %s\n", errorStr.c_str());
+ printfd(__FILE__, "PLUGIN_RUNNER::IsRunning() - %s\n", errorStr.c_str());
return false;
}
if (!plugin)
{
errorStr = "Plugin '" + pluginFileName + "' was not created!";
- printfd(__FILE__, "PLUGIN_LOADER::IsRunning() - %s\n", errorStr.c_str());
+ printfd(__FILE__, "PLUGIN_RUNNER::IsRunning() - %s\n", errorStr.c_str());
return false;
}
if (isPluginLoaded)
{
errorStr = "Plugin '" + pluginFileName + "' was already loaded!";
- printfd(__FILE__, "PLUGIN_LOADER::Load() - %s\n", errorStr.c_str());
+ printfd(__FILE__, "PLUGIN_RUNNER::Load() - %s\n", errorStr.c_str());
return -1;
}
if (pluginFileName.empty())
{
errorStr = "Empty plugin file name!";
- printfd(__FILE__, "PLUGIN_LOADER::Load() - %s\n", errorStr.c_str());
+ printfd(__FILE__, "PLUGIN_RUNNER::Load() - %s\n", errorStr.c_str());
return -1;
}
if (!libHandle)
{
- errorStr = "Error loading plugin '"
- + pluginFileName + "': '" + dlerror() + "'";
- printfd(__FILE__, "PLUGIN_LOADER::Load() - %s\n", errorStr.c_str());
+ errorStr = "Error loading plugin '" + pluginFileName + "': '" + dlerror() + "'";
+ printfd(__FILE__, "PLUGIN_RUNNER::Load() - %s\n", errorStr.c_str());
return -1;
}
GetPlugin = (PLUGIN * (*)())dlsym(libHandle, "GetPlugin");
if (!GetPlugin)
{
- errorStr = std::string("GetPlugin() not found. ") + dlerror();
- printfd(__FILE__, "PLUGIN_LOADER::Load() - %s\n", errorStr.c_str());
+ errorStr = "Plugin '" + pluginFileName + "' does not have GetPlugin() function. " + dlerror();
+ printfd(__FILE__, "PLUGIN_RUNNER::Load() - %s\n", errorStr.c_str());
return -1;
}
plugin = GetPlugin();
if (!plugin)
{
- errorStr = "Plugin was not created!";
- printfd(__FILE__, "PLUGIN_LOADER::Load() - %s\n", errorStr.c_str());
+ errorStr = "Failed to create an instance of plugin '" + pluginFileName + "'.";
+ printfd(__FILE__, "PLUGIN_RUNNER::Load() - %s\n", errorStr.c_str());
return -1;
}
plugin->SetSettings(modSettings);
if (plugin->ParseSettings())
{
- errorStr = plugin->GetStrError();
- printfd(__FILE__, "PLUGIN_LOADER::Load() - Failed to parse settings. Plugin reports: '%s'\n", errorStr.c_str());
+ errorStr = "Plugin '" + pluginFileName + "' is unable to parse settings. " + plugin->GetStrError();
+ printfd(__FILE__, "PLUGIN_RUNNER::Load() - %s\n", errorStr.c_str());
return -1;
}
{
if (dlclose(libHandle))
{
- errorStr = "Failed to unload plugin '";
- errorStr += pluginFileName + "': ";
- errorStr += dlerror();
- printfd(__FILE__, "PLUGIN_LOADER::Unload() - %s", errorStr.c_str());
+ errorStr = "Failed to unload plugin '" + pluginFileName + "': " + dlerror();
+ printfd(__FILE__, "PLUGIN_RUNNER::Unload() - %s", errorStr.c_str());
return -1;
}
plugin = NULL;