diff options
| author | Denys Vlasenko <vda.linux@googlemail.com> | 2009-08-26 14:21:42 +0200 |
|---|---|---|
| committer | Denys Vlasenko <vda.linux@googlemail.com> | 2009-08-26 14:21:42 +0200 |
| commit | fcd811fdd17adb171478957e31401598dedce166 (patch) | |
| tree | 14d6a745d822450e436e0fb4c531f987022f4302 /src/Daemon | |
| parent | 2da98808e7484e69f14b19a1039ded34a954f64e (diff) | |
| download | abrt-fcd811fdd17adb171478957e31401598dedce166.tar.gz abrt-fcd811fdd17adb171478957e31401598dedce166.tar.xz abrt-fcd811fdd17adb171478957e31401598dedce166.zip | |
make some CrashWatcher member functions static; simplify CObserver class
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'src/Daemon')
| -rw-r--r-- | src/Daemon/CommLayerServer.cpp | 14 | ||||
| -rw-r--r-- | src/Daemon/CommLayerServer.h | 8 | ||||
| -rw-r--r-- | src/Daemon/CommLayerServerDBus.cpp | 21 | ||||
| -rw-r--r-- | src/Daemon/CommLayerServerSocket.cpp | 9 | ||||
| -rw-r--r-- | src/Daemon/CrashWatcher.cpp | 30 | ||||
| -rw-r--r-- | src/Daemon/CrashWatcher.h | 30 |
6 files changed, 64 insertions, 48 deletions
diff --git a/src/Daemon/CommLayerServer.cpp b/src/Daemon/CommLayerServer.cpp index 328986e7..1ba1a3c0 100644 --- a/src/Daemon/CommLayerServer.cpp +++ b/src/Daemon/CommLayerServer.cpp @@ -1,5 +1,5 @@ #include "CommLayerServer.h" -#include <iostream> +#include "CrashWatcher.h" CCommLayerServer::CCommLayerServer() { @@ -9,16 +9,16 @@ CCommLayerServer::~CCommLayerServer() { } -void CCommLayerServer::Attach(CObserver *pObs) +void CCommLayerServer::Attach(CCrashWatcher *pCW) { - m_pObserver = pObs; + m_pCrashWatcher = pCW; } -void CCommLayerServer::Detach(CObserver *pObs) +void CCommLayerServer::Detach(CCrashWatcher *pCW) { - m_pObserver = NULL; + m_pCrashWatcher = NULL; } void CCommLayerServer::Notify(const std::string& pMessage) { - if(m_pObserver) - m_pObserver->Status(pMessage); + if (m_pCrashWatcher) + m_pCrashWatcher->Status(pMessage); } diff --git a/src/Daemon/CommLayerServer.h b/src/Daemon/CommLayerServer.h index 76af62b2..6d9270d4 100644 --- a/src/Daemon/CommLayerServer.h +++ b/src/Daemon/CommLayerServer.h @@ -9,16 +9,18 @@ #include "Observer.h" #include "CrashTypes.h" +class CCrashWatcher; + class CCommLayerServer { protected: - CObserver *m_pObserver; + CCrashWatcher *m_pCrashWatcher; public: CCommLayerServer(); virtual ~CCommLayerServer(); /* observer */ - void Attach(CObserver *pObs); - void Detach(CObserver *pObs); + void Attach(CCrashWatcher *pCW); + void Detach(CCrashWatcher *pCW); void Notify(const std::string& pMessage); virtual vector_crash_infos_t GetCrashInfos(const std::string& pSender) = 0; diff --git a/src/Daemon/CommLayerServerDBus.cpp b/src/Daemon/CommLayerServerDBus.cpp index 0c1ef679..70ae9e9c 100644 --- a/src/Daemon/CommLayerServerDBus.cpp +++ b/src/Daemon/CommLayerServerDBus.cpp @@ -1,6 +1,7 @@ #include <iostream> #include "abrtlib.h" #include "ABRTException.h" +#include "CrashWatcher.h" #include "CommLayerServerDBus.h" void attach_dbus_dispatcher_to_glib_main_context() @@ -71,7 +72,7 @@ vector_crash_infos_t CCommLayerServerDBus::GetCrashInfos(const std::string &pSen { vector_crash_infos_t crashInfos; unsigned long unix_uid = m_pConn->sender_unix_uid(pSender.c_str()); - crashInfos = m_pObserver->GetCrashInfos(to_string(unix_uid)); + crashInfos = m_pCrashWatcher->GetCrashInfos(to_string(unix_uid)); return crashInfos; } @@ -93,7 +94,7 @@ uint64_t CCommLayerServerDBus::CreateReport_t(const std::string &pUUID,const std { unsigned long unix_uid = m_pConn->sender_unix_uid(pSender.c_str()); map_crash_report_t crashReport; - uint64_t job_id = m_pObserver->CreateReport_t(pUUID, to_string(unix_uid), pSender); + uint64_t job_id = m_pCrashWatcher->CreateReport_t(pUUID, to_string(unix_uid), pSender); return job_id; } @@ -113,7 +114,7 @@ report_status_t CCommLayerServerDBus::Report(const map_crash_report_t& pReport, { report_status_t rs; unsigned long unix_uid = m_pConn->sender_unix_uid(pSender.c_str()); - rs = m_pObserver->Report(pReport, to_string(unix_uid)); + rs = m_pCrashWatcher->Report(pReport, to_string(unix_uid)); return rs; } @@ -132,7 +133,7 @@ DBus::Message CCommLayerServerDBus::_DeleteDebugDump_stub(const DBus::CallMessag bool CCommLayerServerDBus::DeleteDebugDump(const std::string& pUUID, const std::string& pSender) { unsigned long unix_uid = m_pConn->sender_unix_uid(pSender.c_str()); - m_pObserver->DeleteDebugDump(pUUID,to_string(unix_uid)); + m_pCrashWatcher->DeleteDebugDump(pUUID,to_string(unix_uid)); return true; } @@ -151,7 +152,7 @@ map_crash_report_t CCommLayerServerDBus::GetJobResult(uint64_t pJobID, const std { unsigned long unix_uid = m_pConn->sender_unix_uid(pSender.c_str()); map_crash_report_t crashReport; - crashReport = m_pObserver->GetJobResult(pJobID,to_string(unix_uid)); + crashReport = m_pCrashWatcher->GetJobResult(pJobID,to_string(unix_uid)); return crashReport; } @@ -166,7 +167,7 @@ DBus::Message CCommLayerServerDBus::_GetPluginsInfo_stub(const DBus::CallMessage } vector_map_string_string_t CCommLayerServerDBus::GetPluginsInfo() { - return m_pObserver->GetPluginsInfo(); + return m_pCrashWatcher->GetPluginsInfo(); } DBus::Message CCommLayerServerDBus::_GetPluginSettings_stub(const DBus::CallMessage &call) @@ -185,7 +186,7 @@ DBus::Message CCommLayerServerDBus::_GetPluginSettings_stub(const DBus::CallMess map_plugin_settings_t CCommLayerServerDBus::GetPluginSettings(const std::string& pName, const std::string& pSender) { unsigned long unix_uid = m_pConn->sender_unix_uid(pSender.c_str()); - return m_pObserver->GetPluginSettings(pName, to_string(unix_uid)); + return m_pCrashWatcher->GetPluginSettings(pName, to_string(unix_uid)); } DBus::Message CCommLayerServerDBus::_SetPluginSettings_stub(const DBus::CallMessage &call) @@ -202,7 +203,7 @@ DBus::Message CCommLayerServerDBus::_SetPluginSettings_stub(const DBus::CallMess void CCommLayerServerDBus::SetPluginSettings(const std::string& pName, const std::string& pSender, const map_plugin_settings_t& pSettings) { unsigned long unix_uid = m_pConn->sender_unix_uid(pSender.c_str()); - return m_pObserver->SetPluginSettings(pName, to_string(unix_uid), pSettings); + return m_pCrashWatcher->SetPluginSettings(pName, to_string(unix_uid), pSettings); } DBus::Message CCommLayerServerDBus::_RegisterPlugin_stub(const DBus::CallMessage &call) @@ -218,7 +219,7 @@ DBus::Message CCommLayerServerDBus::_RegisterPlugin_stub(const DBus::CallMessage } void CCommLayerServerDBus::RegisterPlugin(const std::string& pName) { - return m_pObserver->RegisterPlugin(pName); + return m_pCrashWatcher->RegisterPlugin(pName); } DBus::Message CCommLayerServerDBus::_UnRegisterPlugin_stub(const DBus::CallMessage &call) @@ -232,7 +233,7 @@ DBus::Message CCommLayerServerDBus::_UnRegisterPlugin_stub(const DBus::CallMessa } void CCommLayerServerDBus::UnRegisterPlugin(const std::string& pName) { - return m_pObserver->UnRegisterPlugin(pName); + return m_pCrashWatcher->UnRegisterPlugin(pName); } diff --git a/src/Daemon/CommLayerServerSocket.cpp b/src/Daemon/CommLayerServerSocket.cpp index 1b540686..5a4f00b1 100644 --- a/src/Daemon/CommLayerServerSocket.cpp +++ b/src/Daemon/CommLayerServerSocket.cpp @@ -6,6 +6,7 @@ #include "CommLayerInner.h" #include "ABRTException.h" #include "CrashTypesSocket.h" +#include "CrashWatcher.h" #include "CommLayerServerSocket.h" void CCommLayerServerSocket::Send(const std::string& pData, GIOChannel *pDestination) @@ -206,7 +207,7 @@ CCommLayerServerSocket::~CCommLayerServerSocket() vector_crash_infos_t CCommLayerServerSocket::GetCrashInfos(const std::string &pSender) { vector_crash_infos_t crashInfos; - crashInfos = m_pObserver->GetCrashInfos(pSender); + crashInfos = m_pCrashWatcher->GetCrashInfos(pSender); return crashInfos; } @@ -214,20 +215,20 @@ vector_crash_infos_t CCommLayerServerSocket::GetCrashInfos(const std::string &pS //map_crash_report_t CCommLayerServerSocket::CreateReport(const std::string &pUUID,const std::string &pSender) //{ // map_crash_report_t crashReport; -// crashReport = m_pObserver->CreateReport(pUUID, pSender); +// crashReport = m_pCrashWatcher->CreateReport(pUUID, pSender); // return crashReport; //} report_status_t CCommLayerServerSocket::Report(const map_crash_report_t& pReport, const std::string& pSender) { report_status_t rs; - rs = m_pObserver->Report(pReport, pSender); + rs = m_pCrashWatcher->Report(pReport, pSender); return rs; } bool CCommLayerServerSocket::DeleteDebugDump(const std::string& pUUID, const std::string& pSender) { - m_pObserver->DeleteDebugDump(pUUID, pSender); + m_pCrashWatcher->DeleteDebugDump(pUUID, pSender); return true; } diff --git a/src/Daemon/CrashWatcher.cpp b/src/Daemon/CrashWatcher.cpp index 01629f0b..41f0fa78 100644 --- a/src/Daemon/CrashWatcher.cpp +++ b/src/Daemon/CrashWatcher.cpp @@ -75,15 +75,15 @@ vector_crash_infos_t CCrashWatcher::GetCrashInfos(const std::string &pUID) retval.push_back(info); break; case MW_ERROR: - Warning("Can not find debug dump directory for UUID: " + UUIDsUIDs[ii].first + ", deleting from database"); - Status("Can not find debug dump directory for UUID: " + UUIDsUIDs[ii].first + ", deleting from database"); + g_cw->Warning("Can not find debug dump directory for UUID: " + UUIDsUIDs[ii].first + ", deleting from database"); + g_cw->Status("Can not find debug dump directory for UUID: " + UUIDsUIDs[ii].first + ", deleting from database"); DeleteCrashInfo(UUIDsUIDs[ii].first, UUIDsUIDs[ii].second); break; case MW_FILE_ERROR: { std::string debugDumpDir; - Warning("Can not open file in debug dump directory for UUID: " + UUIDsUIDs[ii].first + ", deleting "); - Status("Can not open file in debug dump directory for UUID: " + UUIDsUIDs[ii].first + ", deleting "); + g_cw->Warning("Can not open file in debug dump directory for UUID: " + UUIDsUIDs[ii].first + ", deleting "); + g_cw->Status("Can not open file in debug dump directory for UUID: " + UUIDsUIDs[ii].first + ", deleting "); debugDumpDir = DeleteCrashInfo(UUIDsUIDs[ii].first, UUIDsUIDs[ii].second); DeleteDebugDumpDir(debugDumpDir); } @@ -99,8 +99,8 @@ vector_crash_infos_t CCrashWatcher::GetCrashInfos(const std::string &pUID) { throw e; } - Warning(e.what()); - Status(e.what()); + g_cw->Warning(e.what()); + g_cw->Status(e.what()); } //retval = GetCrashInfos(pUID); @@ -210,8 +210,8 @@ report_status_t CCrashWatcher::Report(const map_crash_report_t& pReport, const s { throw e; } - Warning(e.what()); - Status(e.what()); + g_cw->Warning(e.what()); + g_cw->Status(e.what()); return rs; } return rs; @@ -231,8 +231,8 @@ bool CCrashWatcher::DeleteDebugDump(const std::string& pUUID, const std::string& { throw e; } - Warning(e.what()); - Status(e.what()); + g_cw->Warning(e.what()); + g_cw->Status(e.what()); return false; } return true; @@ -259,7 +259,7 @@ vector_map_string_string_t CCrashWatcher::GetPluginsInfo() { throw e; } - Warning(e.what()); + g_cw->Warning(e.what()); } // TODO: is it right? I added it just to disable a warning... // but maybe returning empty map is wrong here? @@ -278,7 +278,7 @@ map_plugin_settings_t CCrashWatcher::GetPluginSettings(const std::string& pName, { throw e; } - Warning(e.what()); + g_cw->Warning(e.what()); } // TODO: is it right? I added it just to disable a warning... // but maybe returning empty map is wrong here? @@ -297,7 +297,7 @@ void CCrashWatcher::RegisterPlugin(const std::string& pName) { throw e; } - Warning(e.what()); + g_cw->Warning(e.what()); } } @@ -313,7 +313,7 @@ void CCrashWatcher::UnRegisterPlugin(const std::string& pName) { throw e; } - Warning(e.what()); + g_cw->Warning(e.what()); } } @@ -329,6 +329,6 @@ void CCrashWatcher::SetPluginSettings(const std::string& pName, const std::strin { throw e; } - Warning(e.what()); + g_cw->Warning(e.what()); } } diff --git a/src/Daemon/CrashWatcher.h b/src/Daemon/CrashWatcher.h index ce82fc50..e4fb626a 100644 --- a/src/Daemon/CrashWatcher.h +++ b/src/Daemon/CrashWatcher.h @@ -53,17 +53,29 @@ class CCrashWatcher virtual void Status(const std::string& pMessage, const std::string& pDest="0"); virtual void Debug(const std::string& pMessage); virtual void Warning(const std::string& pMessage); - virtual vector_crash_infos_t GetCrashInfos(const std::string &pUID); + + /* New methods */ +static + vector_crash_infos_t GetCrashInfos(const std::string &pUID); +static uint64_t CreateReport_t(const std::string &pUUID,const std::string &pUID, const std::string &pSender); - virtual report_status_t Report(const map_crash_report_t& pReport, const std::string &pUID); - virtual bool DeleteDebugDump(const std::string& pUUID, const std::string& pUID); - virtual map_crash_report_t GetJobResult(uint64_t pJobID, const std::string& pSender); +static + report_status_t Report(const map_crash_report_t& pReport, const std::string &pUID); +static + bool DeleteDebugDump(const std::string& pUUID, const std::string& pUID); +static + map_crash_report_t GetJobResult(uint64_t pJobID, const std::string& pSender); /* plugins related */ - virtual vector_map_string_string_t GetPluginsInfo(); - virtual map_plugin_settings_t GetPluginSettings(const std::string& pName, const std::string& pUID); - virtual void SetPluginSettings(const std::string& pName, const std::string& pUID, const map_plugin_settings_t& pSettings); - virtual void RegisterPlugin(const std::string& pName); - virtual void UnRegisterPlugin(const std::string& pName); +static + vector_map_string_string_t GetPluginsInfo(); +static + map_plugin_settings_t GetPluginSettings(const std::string& pName, const std::string& pUID); +static + void SetPluginSettings(const std::string& pName, const std::string& pUID, const map_plugin_settings_t& pSettings); +static + void RegisterPlugin(const std::string& pName); +static + void UnRegisterPlugin(const std::string& pName); }; #endif /*CRASHWATCHER_H_*/ |
