diff options
author | Zdenek Prikryl <zprikryl@redhat.com> | 2009-06-10 10:04:41 +0200 |
---|---|---|
committer | Zdenek Prikryl <zprikryl@redhat.com> | 2009-06-10 10:04:41 +0200 |
commit | 9eab929557ef4228b3335f4908dd6b4acf9251dc (patch) | |
tree | 396027356582aee82eb5930253b84988219698bf | |
parent | da6687d1b76eb8f83ff10010c765e6959a20f3fe (diff) | |
download | abrt-9eab929557ef4228b3335f4908dd6b4acf9251dc.tar.gz abrt-9eab929557ef4228b3335f4908dd6b4acf9251dc.tar.xz abrt-9eab929557ef4228b3335f4908dd6b4acf9251dc.zip |
added more checks when someone wants to access a plugin
-rw-r--r-- | lib/MiddleWare/PluginManager.cpp | 38 | ||||
-rw-r--r-- | lib/MiddleWare/PluginManager.h | 1 |
2 files changed, 35 insertions, 4 deletions
diff --git a/lib/MiddleWare/PluginManager.cpp b/lib/MiddleWare/PluginManager.cpp index 48560e4d..b47d70ff 100644 --- a/lib/MiddleWare/PluginManager.cpp +++ b/lib/MiddleWare/PluginManager.cpp @@ -161,7 +161,12 @@ CAnalyzer* CPluginManager::GetAnalyzer(const std::string& pName) if (m_mapPlugins.find(pName) == m_mapPlugins.end()) { throw CABRTException(EXCEP_PLUGIN, "CPluginManager::GetAnalyzer():" - "Analyzer plugin: '"+pName+"' is not loaded."); + "Analyzer plugin: '"+pName+"' is not registered."); + } + if (m_mapABRTPlugins[pName]->GetType() != ANALYZER) + { + throw CABRTException(EXCEP_PLUGIN, "CPluginManager::GetAnalyzer():" + "Plugin: '"+pName+"' is not analyzer plugin."); } return dynamic_cast<CAnalyzer*>(m_mapPlugins[pName]); } @@ -171,7 +176,12 @@ CReporter* CPluginManager::GetReporter(const std::string& pName) if (m_mapPlugins.find(pName) == m_mapPlugins.end()) { throw CABRTException(EXCEP_PLUGIN, "CPluginManager::GetReporter():" - "Reporter plugin: '"+pName+"' is not loaded."); + "Reporter plugin: '"+pName+"' is not registered."); + } + if (m_mapABRTPlugins[pName]->GetType() != REPORTER) + { + throw CABRTException(EXCEP_PLUGIN, "CPluginManager::GetReporter():" + "Plugin: '"+pName+"' is not reporter plugin."); } return dynamic_cast<CReporter*>(m_mapPlugins[pName]); } @@ -181,7 +191,12 @@ CAction* CPluginManager::GetAction(const std::string& pName) if (m_mapPlugins.find(pName) == m_mapPlugins.end()) { throw CABRTException(EXCEP_PLUGIN, "CPluginManager::GetAction():" - "Action plugin: '"+pName+"' is not loaded."); + "Action plugin: '"+pName+"' is not registered."); + } + if (m_mapABRTPlugins[pName]->GetType() != ACTION) + { + throw CABRTException(EXCEP_PLUGIN, "CPluginManager::GetAction():" + "Plugin: '"+pName+"' is not action plugin."); } return dynamic_cast<CAction*>(m_mapPlugins[pName]); } @@ -191,8 +206,23 @@ CDatabase* CPluginManager::GetDatabase(const std::string& pName) if (m_mapPlugins.find(pName) == m_mapPlugins.end()) { throw CABRTException(EXCEP_PLUGIN, "CPluginManager::GetDatabase():" - "Database plugin: '"+pName+"' is not loaded."); + "Database plugin: '"+pName+"' is not registered."); + } + if (m_mapABRTPlugins[pName]->GetType() != DATABASE) + { + throw CABRTException(EXCEP_PLUGIN, "CPluginManager::GetDatabase():" + "Plugin: '"+pName+"' is not database plugin."); } return dynamic_cast<CDatabase*>(m_mapPlugins[pName]); } +plugin_type_t CPluginManager::GetPluginType(const std::string& pName) +{ + if (m_mapPlugins.find(pName) == m_mapPlugins.end()) + { + throw CABRTException(EXCEP_PLUGIN, "CPluginManager::GetPluginType():" + "Plugin: '"+pName+"' is not registered."); + } + return m_mapABRTPlugins[pName]->GetType(); +} + diff --git a/lib/MiddleWare/PluginManager.h b/lib/MiddleWare/PluginManager.h index 8ef59910..0da246d8 100644 --- a/lib/MiddleWare/PluginManager.h +++ b/lib/MiddleWare/PluginManager.h @@ -63,6 +63,7 @@ class CPluginManager CReporter* GetReporter(const std::string& pName); CAction* GetAction(const std::string& pName); CDatabase* GetDatabase(const std::string& pName); + plugin_type_t GetPluginType(const std::string& pName); }; |