]> git.stg.codes - stg.git/blobdiff - projects/stargazer/plugin_mgr.cpp
Ticket 26. The 'moduleName' variable is defined and parameter 'moduleName' added
[stg.git] / projects / stargazer / plugin_mgr.cpp
index 69c7efeb76562f2d3469474e4a78ce1ba6fa63a4..d3430c8927d3b86f6b4671ca665af4126235301e 100644 (file)
@@ -60,11 +60,12 @@ PluginManager::PluginManager(const SETTINGS_IMPL& settings,
     for (size_t i = 0; i < modSettings.size(); i++)
     {
         std::string modulePath = basePath + "/mod_" + modSettings[i].moduleName + ".so";
+        std::string moduleName = modSettings[i].moduleName;
         printfd(__FILE__, "Module: %s\n", modulePath.c_str());
         try
         {
             m_modules.push_back(
-                new PLUGIN_RUNNER(modulePath, modSettings[i], admins, tariffs,
+                new PLUGIN_RUNNER(modulePath, moduleName, modSettings[i], admins, tariffs,
                                   users, services, corporations, traffcounter,
                                   store, settings)
             );
@@ -84,9 +85,14 @@ PluginManager::PluginManager(const SETTINGS_IMPL& settings,
         {
             m_log("Failed to start module '%s': '%s'", plugin.GetVersion().c_str(),
                                                        plugin.GetStrError().c_str());
-            printfd(__FILE__, "Failed to start module '%s': '%s'", plugin.GetVersion().c_str(),
+            printfd(__FILE__, "Failed to start module '%s': '%s'\n", plugin.GetVersion().c_str(),
                                                                    plugin.GetStrError().c_str());
         }
+        else
+        {
+            m_log("Module '%s' started successfully.", plugin.GetVersion().c_str());
+            printfd(__FILE__, "Module '%s' started successfully.\n", plugin.GetVersion().c_str());
+        }
     }
 }
 
@@ -94,12 +100,26 @@ PluginManager::~PluginManager()
 {
     std::sort(m_modules.begin(), m_modules.end(), StopModCmp);
     for (size_t i = 0; i < m_modules.size(); ++i)
-        m_modules[i]->Stop();
+    {
+        PLUGIN & plugin = m_modules[i]->GetPlugin();
+        if (m_modules[i]->Stop())
+        {
+            m_log("Failed to stop module '%s': '%s'", plugin.GetVersion().c_str(),
+                                                      plugin.GetStrError().c_str());
+            printfd(__FILE__, "Failed to stop module '%s': '%s'\n", plugin.GetVersion().c_str(),
+                                                                  plugin.GetStrError().c_str());
+        }
+        else
+        {
+            m_log("Module '%s' stopped successfully.", plugin.GetVersion().c_str());
+            printfd(__FILE__, "Module '%s' stopped successfully.\n", plugin.GetVersion().c_str());
+        }
+    }
     for (size_t i = 0; i < m_modules.size(); ++i)
         delete m_modules[i];
 }
 
-void PluginManager::reload()
+void PluginManager::reload(const SETTINGS_IMPL& settings)
 {
     for (size_t i = 0; i < m_modules.size(); ++i)
     {