From 5bf3512df0529960ed4980251825b49a12eff894 Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Tue, 25 Aug 2009 12:57:46 +0200 Subject: pass map_crash_report_t by const reference, not by value Signed-off-by: Denys Vlasenko --- lib/CommLayer/DBusClientProxy.cpp | 2 +- lib/CommLayer/DBusClientProxy.h | 2 +- lib/CommLayer/Observer.h | 2 +- src/CLI/ABRTSocket.cpp | 2 +- src/CLI/ABRTSocket.h | 2 +- src/Daemon/CommLayerServer.h | 8 ++++---- src/Daemon/CommLayerServerDBus.cpp | 4 ++-- src/Daemon/CommLayerServerDBus.h | 4 ++-- src/Daemon/CommLayerServerSocket.cpp | 4 ++-- src/Daemon/CommLayerServerSocket.h | 8 ++++---- src/Daemon/CrashWatcher.cpp | 2 +- src/Daemon/CrashWatcher.h | 2 +- src/Daemon/DBusServerProxy.cpp | 11 +++++++---- src/Daemon/DBusServerProxy.h | 12 ++++++------ 14 files changed, 34 insertions(+), 31 deletions(-) diff --git a/lib/CommLayer/DBusClientProxy.cpp b/lib/CommLayer/DBusClientProxy.cpp index 59f9f5d5..2cc00a5a 100644 --- a/lib/CommLayer/DBusClientProxy.cpp +++ b/lib/CommLayer/DBusClientProxy.cpp @@ -180,7 +180,7 @@ map_crash_report_t CDBusClient_proxy::CreateReport(const std::string& pUUID) return GetJobResult(m_iPendingJobID); }; -void CDBusClient_proxy::Report(map_crash_report_t pReport) +void CDBusClient_proxy::Report(const map_crash_report_t& pReport) { DBus::CallMessage call; diff --git a/lib/CommLayer/DBusClientProxy.h b/lib/CommLayer/DBusClientProxy.h index 5b5c1fde..22dfcf16 100644 --- a/lib/CommLayer/DBusClientProxy.h +++ b/lib/CommLayer/DBusClientProxy.h @@ -90,7 +90,7 @@ public: vector_crash_infos_t GetCrashInfos(); bool DeleteDebugDump(const std::string& pUUID); map_crash_report_t CreateReport(const std::string& pUUID); - void Report(map_crash_report_t pReport); + void Report(const map_crash_report_t& pReport); map_crash_report_t GetJobResult(uint64_t pJobID); public: diff --git a/lib/CommLayer/Observer.h b/lib/CommLayer/Observer.h index 02b51ce2..5df05247 100644 --- a/lib/CommLayer/Observer.h +++ b/lib/CommLayer/Observer.h @@ -22,7 +22,7 @@ class CObserver { std::cout << "DEFAULT OBSERVER"; return 0; } - virtual report_status_t Report(map_crash_report_t pReport, const std::string &pSender) = 0; + virtual report_status_t Report(const map_crash_report_t& pReport, const std::string &pSender) = 0; virtual bool DeleteDebugDump(const std::string& pUUID, const std::string& pSender) = 0; virtual map_crash_report_t GetJobResult(uint64_t pJobID, const std::string &pSender) = 0; virtual vector_map_string_string_t GetPluginsInfo() = 0; diff --git a/src/CLI/ABRTSocket.cpp b/src/CLI/ABRTSocket.cpp index a699bbdb..1f90f63a 100644 --- a/src/CLI/ABRTSocket.cpp +++ b/src/CLI/ABRTSocket.cpp @@ -117,7 +117,7 @@ map_crash_report_t CABRTSocket::CreateReport(const std::string &pUUID) return string_to_crash_report(message); } -void CABRTSocket::Report(map_crash_report_t pReport) +void CABRTSocket::Report(const map_crash_report_t& pReport) { std::string message = MESSAGE_REPORT + crash_report_to_string(pReport); Send(message); diff --git a/src/CLI/ABRTSocket.h b/src/CLI/ABRTSocket.h index 6e8a7775..d476411c 100644 --- a/src/CLI/ABRTSocket.h +++ b/src/CLI/ABRTSocket.h @@ -22,7 +22,7 @@ class CABRTSocket vector_crash_infos_t GetCrashInfos(); map_crash_report_t CreateReport(const std::string& pUUID); - void Report(map_crash_report_t pReport); + void Report(const map_crash_report_t& pReport); void DeleteDebugDump(const std::string& pUUID); }; diff --git a/src/Daemon/CommLayerServer.h b/src/Daemon/CommLayerServer.h index af79511a..38dbac9b 100644 --- a/src/Daemon/CommLayerServer.h +++ b/src/Daemon/CommLayerServer.h @@ -31,15 +31,15 @@ class CCommLayerServer { void Detach(CObserver *pObs); void Notify(const std::string& pMessage); - virtual vector_crash_infos_t GetCrashInfos(const std::string &pSender) = 0; - virtual map_crash_report_t CreateReport(const std::string &pUUID,const std::string &pSender) = 0; - virtual report_status_t Report(map_crash_report_t pReport,const std::string &pSender) = 0; + virtual vector_crash_infos_t GetCrashInfos(const std::string& pSender) = 0; + virtual map_crash_report_t CreateReport(const std::string &pUUID, const std::string& pSender) = 0; + virtual report_status_t Report(const map_crash_report_t& pReport, const std::string& pSender) = 0; virtual bool DeleteDebugDump(const std::string& pUUID, const std::string& pSender) = 0; public: /* just stubs to be called when not implemented in specific comm layer */ virtual void Crash(const std::string& arg1) {} - virtual void AnalyzeComplete(map_crash_report_t arg1) {} + virtual void AnalyzeComplete(const map_crash_report_t& arg1) {} virtual void Error(const std::string& arg1) {} virtual void Update(const std::string& pDest, const std::string& pMessage) {}; virtual void Warning(const std::string& pDest, const std::string& pMessage) {}; diff --git a/src/Daemon/CommLayerServerDBus.cpp b/src/Daemon/CommLayerServerDBus.cpp index f0a9149b..48087396 100644 --- a/src/Daemon/CommLayerServerDBus.cpp +++ b/src/Daemon/CommLayerServerDBus.cpp @@ -64,7 +64,7 @@ uint64_t CCommLayerServerDBus::CreateReport_t(const std::string &pUUID,const std return job_id; } -report_status_t CCommLayerServerDBus::Report(map_crash_report_t pReport,const std::string &pSender) +report_status_t CCommLayerServerDBus::Report(const map_crash_report_t& pReport, const std::string &pSender) { report_status_t rs; unsigned long unix_uid = m_pConn->sender_unix_uid(pSender.c_str()); @@ -92,7 +92,7 @@ void CCommLayerServerDBus::Crash(const std::string& arg) CDBusServer_adaptor::Crash(arg); } -void CCommLayerServerDBus::AnalyzeComplete(map_crash_report_t arg1) +void CCommLayerServerDBus::AnalyzeComplete(const map_crash_report_t& arg1) { CDBusServer_adaptor::AnalyzeComplete(arg1); } diff --git a/src/Daemon/CommLayerServerDBus.h b/src/Daemon/CommLayerServerDBus.h index ad245061..c335b6f2 100644 --- a/src/Daemon/CommLayerServerDBus.h +++ b/src/Daemon/CommLayerServerDBus.h @@ -26,7 +26,7 @@ class CCommLayerServerDBus return retval; } virtual uint64_t CreateReport_t(const std::string& pUUID, const std::string& pSender); - virtual report_status_t Report(map_crash_report_t pReport,const std::string& pSender); + virtual report_status_t Report(const map_crash_report_t& pReport, const std::string& pSender); virtual bool DeleteDebugDump(const std::string& pUUID, const std::string& pSender); virtual map_crash_report_t GetJobResult(uint64_t pJobID, const std::string& pSender); virtual vector_map_string_string_t GetPluginsInfo(); @@ -36,7 +36,7 @@ class CCommLayerServerDBus void UnRegisterPlugin(const std::string& pName); virtual void Crash(const std::string& arg1); - virtual void AnalyzeComplete(map_crash_report_t arg1); + virtual void AnalyzeComplete(const map_crash_report_t& arg1); virtual void Error(const std::string& arg1); virtual void Update(const std::string& pDest, const std::string& pMessage); virtual void JobDone(const std::string& pDest, uint64_t pJobID); diff --git a/src/Daemon/CommLayerServerSocket.cpp b/src/Daemon/CommLayerServerSocket.cpp index f5466d43..8347ad7a 100644 --- a/src/Daemon/CommLayerServerSocket.cpp +++ b/src/Daemon/CommLayerServerSocket.cpp @@ -219,7 +219,7 @@ map_crash_report_t CCommLayerServerSocket::CreateReport(const std::string &pUUID return crashReport; } -report_status_t CCommLayerServerSocket::Report(map_crash_report_t pReport, const std::string& pSender) +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); @@ -237,7 +237,7 @@ void CCommLayerServerSocket::Crash(const std::string& arg1) //Send("(CRASH)New Crash Detected: " + arg1); } -void CCommLayerServerSocket::AnalyzeComplete(map_crash_report_t arg1) +void CCommLayerServerSocket::AnalyzeComplete(const map_crash_report_t& arg1) { //Send("(ANALYZE_COMPLETE)Analyze Complete."); } diff --git a/src/Daemon/CommLayerServerSocket.h b/src/Daemon/CommLayerServerSocket.h index 2dc9a7ae..31496334 100644 --- a/src/Daemon/CommLayerServerSocket.h +++ b/src/Daemon/CommLayerServerSocket.h @@ -26,12 +26,12 @@ class CCommLayerServerSocket : public CCommLayerServer CCommLayerServerSocket(); virtual ~CCommLayerServerSocket(); - virtual vector_crash_infos_t GetCrashInfos(const std::string &pSender); - virtual map_crash_report_t CreateReport(const std::string &pUUID,const std::string &pSender); - virtual report_status_t Report(map_crash_report_t pReport, const std::string& pSender); + virtual vector_crash_infos_t GetCrashInfos(const std::string& pSender); + virtual map_crash_report_t CreateReport(const std::string& pUUID, const std::string& pSender); + virtual report_status_t Report(const map_crash_report_t& pReport, const std::string& pSender); virtual bool DeleteDebugDump(const std::string& pUUID, const std::string& pSender); virtual void Crash(const std::string& arg1); - virtual void AnalyzeComplete(map_crash_report_t arg1); + virtual void AnalyzeComplete(const map_crash_report_t& arg1); virtual void Error(const std::string& arg1); }; diff --git a/src/Daemon/CrashWatcher.cpp b/src/Daemon/CrashWatcher.cpp index 89e9fe9a..5a6463a7 100644 --- a/src/Daemon/CrashWatcher.cpp +++ b/src/Daemon/CrashWatcher.cpp @@ -192,7 +192,7 @@ uint64_t CCrashWatcher::CreateReport_t(const std::string &pUUID,const std::strin return 0; } -report_status_t CCrashWatcher::Report(map_crash_report_t pReport, const std::string& pUID) +report_status_t CCrashWatcher::Report(const map_crash_report_t& pReport, const std::string& pUID) { //#define FIELD(X) crashReport.m_s##X = pReport[#X]; //crashReport.m_sUUID = pReport["UUID"]; diff --git a/src/Daemon/CrashWatcher.h b/src/Daemon/CrashWatcher.h index ae600abb..78cd706b 100644 --- a/src/Daemon/CrashWatcher.h +++ b/src/Daemon/CrashWatcher.h @@ -64,7 +64,7 @@ class CCrashWatcher return retval; } uint64_t CreateReport_t(const std::string &pUUID,const std::string &pUID, const std::string &pSender); - virtual report_status_t Report(map_crash_report_t pReport, const std::string &pUID); + 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); /* plugins related */ diff --git a/src/Daemon/DBusServerProxy.cpp b/src/Daemon/DBusServerProxy.cpp index 5730fd52..237a06a0 100644 --- a/src/Daemon/DBusServerProxy.cpp +++ b/src/Daemon/DBusServerProxy.cpp @@ -92,7 +92,7 @@ void CDBusServer_adaptor::Crash(const std::string& arg1) } /* Notify the clients that creating a report has finished */ -void CDBusServer_adaptor::AnalyzeComplete(map_crash_report_t arg1) +void CDBusServer_adaptor::AnalyzeComplete(const map_crash_report_t& arg1) { ::DBus::SignalMessage sig("AnalyzeComplete"); ::DBus::MessageIter wi = sig.writer(); @@ -153,7 +153,8 @@ DBus::Message CDBusServer_adaptor::_CreateReport_stub(const DBus::CallMessage &c { DBus::MessageIter ri = call.reader(); - std::string argin1; ri >> argin1; + std::string argin1; + ri >> argin1; uint64_t argout1 = CreateReport_t(argin1, call.sender()); if(sizeof (uint64_t) != 8) abort (); //map_crash_report_t argout1 = CreateReport(argin1,call.sender()); @@ -167,7 +168,8 @@ DBus::Message CDBusServer_adaptor::_Report_stub(const DBus::CallMessage &call) { DBus::MessageIter ri = call.reader(); - map_crash_report_t argin1; ri >> argin1; + map_crash_report_t argin1; + ri >> argin1; report_status_t argout1 = Report(argin1, call.sender()); DBus::ReturnMessage reply(call); DBus::MessageIter wi = reply.writer(); @@ -179,7 +181,8 @@ DBus::Message CDBusServer_adaptor::_DeleteDebugDump_stub(const DBus::CallMessage { DBus::MessageIter ri = call.reader(); - std::string argin1; ri >> argin1; + std::string argin1; + ri >> argin1; bool argout1 = DeleteDebugDump(argin1, call.sender()); DBus::ReturnMessage reply(call); DBus::MessageIter wi = reply.writer(); diff --git a/src/Daemon/DBusServerProxy.h b/src/Daemon/DBusServerProxy.h index 20538412..91d1b1f9 100644 --- a/src/Daemon/DBusServerProxy.h +++ b/src/Daemon/DBusServerProxy.h @@ -43,10 +43,10 @@ public: * you will have to implement them in your ObjectAdaptor */ - virtual vector_crash_infos_t GetCrashInfos(const std::string &pDBusSender) = 0; - virtual map_crash_report_t CreateReport(const std::string &pUUID, const std::string &pDBusSender) = 0; - virtual uint64_t CreateReport_t(const std::string &pUUID, const std::string &pDBusSender) = 0; - virtual report_status_t Report(map_crash_report_t pReport, const std::string &pDBusSender) = 0; + virtual vector_crash_infos_t GetCrashInfos(const std::string& pDBusSender) = 0; + virtual map_crash_report_t CreateReport(const std::string& pUUID, const std::string& pDBusSender) = 0; + virtual uint64_t CreateReport_t(const std::string& pUUID, const std::string& pDBusSender) = 0; + virtual report_status_t Report(const map_crash_report_t& pReport, const std::string& pDBusSender) = 0; virtual bool DeleteDebugDump(const std::string& pUUID, const std::string& pDBusSender) = 0; virtual map_crash_report_t GetJobResult(uint64_t pJobID, const std::string& pDBusSender) = 0; virtual vector_map_string_string_t GetPluginsInfo() = 0; @@ -61,8 +61,8 @@ public: /* Notify the clients (UI) about a new crash */ void Crash(const std::string& arg1); /* Notify the clients that creating a report has finished */ - void AnalyzeComplete(map_crash_report_t arg1); - void JobDone(const std::string &pDest, uint64_t job_id); + void AnalyzeComplete(const map_crash_report_t& arg1); + void JobDone(const std::string& pDest, uint64_t job_id); void Error(const std::string& arg1); void Update(const std::string pDest, const std::string& pMessage); void Warning(const std::string& arg1); -- cgit From 3008b32dd0f78b0b2c09e05a7b47080c7cb75d38 Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Tue, 25 Aug 2009 14:00:22 +0200 Subject: remove CreateReport() method from server machinery; add comments about DBus Signed-off-by: Denys Vlasenko --- lib/CommLayer/Observer.h | 1 - src/Daemon/CommLayerServer.h | 5 +- src/Daemon/CommLayerServerDBus.cpp | 68 ++++++++++++---------- src/Daemon/CommLayerServerDBus.h | 16 +++--- src/Daemon/CommLayerServerSocket.cpp | 22 +++---- src/Daemon/CommLayerServerSocket.h | 1 - src/Daemon/CrashWatcher.h | 9 --- src/Daemon/DBusServerProxy.cpp | 2 +- src/Daemon/DBusServerProxy.h | 107 ++++++++++++++++++----------------- 9 files changed, 117 insertions(+), 114 deletions(-) diff --git a/lib/CommLayer/Observer.h b/lib/CommLayer/Observer.h index 5df05247..755ae524 100644 --- a/lib/CommLayer/Observer.h +++ b/lib/CommLayer/Observer.h @@ -16,7 +16,6 @@ class CObserver { virtual void Warning(const std::string& pMessage, const std::string& pDest="0") = 0; /* this should be implemented in daemon */ virtual vector_crash_infos_t GetCrashInfos(const std::string &pSender) = 0; - virtual map_crash_report_t CreateReport(const std::string &pUUID,const std::string &pSender) = 0; virtual uint64_t CreateReport_t(const std::string &pUUID,const std::string &pUID, const std::string &pSender) { std::cout << "DEFAULT OBSERVER"; diff --git a/src/Daemon/CommLayerServer.h b/src/Daemon/CommLayerServer.h index 38dbac9b..afc9ecf3 100644 --- a/src/Daemon/CommLayerServer.h +++ b/src/Daemon/CommLayerServer.h @@ -26,18 +26,17 @@ class CCommLayerServer { public: CCommLayerServer(); virtual ~CCommLayerServer(); + /* observer */ void Attach(CObserver *pObs); void Detach(CObserver *pObs); void Notify(const std::string& pMessage); virtual vector_crash_infos_t GetCrashInfos(const std::string& pSender) = 0; - virtual map_crash_report_t CreateReport(const std::string &pUUID, const std::string& pSender) = 0; virtual report_status_t Report(const map_crash_report_t& pReport, const std::string& pSender) = 0; virtual bool DeleteDebugDump(const std::string& pUUID, const std::string& pSender) = 0; - public: - /* just stubs to be called when not implemented in specific comm layer */ + /* just stubs to be called when not implemented in specific comm layer */ virtual void Crash(const std::string& arg1) {} virtual void AnalyzeComplete(const map_crash_report_t& arg1) {} virtual void Error(const std::string& arg1) {} diff --git a/src/Daemon/CommLayerServerDBus.cpp b/src/Daemon/CommLayerServerDBus.cpp index 48087396..7796bac6 100644 --- a/src/Daemon/CommLayerServerDBus.cpp +++ b/src/Daemon/CommLayerServerDBus.cpp @@ -18,8 +18,8 @@ DBus::Connection *CCommLayerServerDBus::init_dbus(CCommLayerServerDBus *self) } CCommLayerServerDBus::CCommLayerServerDBus() -: CCommLayerServer(), - DBus::ObjectAdaptor(*init_dbus(this), CC_DBUS_PATH) +: + DBus::ObjectAdaptor(*init_dbus(this), CC_DBUS_PATH) { try { @@ -39,6 +39,11 @@ CCommLayerServerDBus::~CCommLayerServerDBus() { } + +/* + * DBus call handlers + */ + vector_crash_infos_t CCommLayerServerDBus::GetCrashInfos(const std::string &pSender) { vector_crash_infos_t crashInfos; @@ -87,63 +92,68 @@ map_crash_report_t CCommLayerServerDBus::GetJobResult(uint64_t pJobID, const std return crashReport; } -void CCommLayerServerDBus::Crash(const std::string& arg) +vector_map_string_string_t CCommLayerServerDBus::GetPluginsInfo() { - CDBusServer_adaptor::Crash(arg); + //FIXME: simplify? + vector_map_string_string_t plugins_info; + plugins_info = m_pObserver->GetPluginsInfo(); + return plugins_info; } -void CCommLayerServerDBus::AnalyzeComplete(const map_crash_report_t& arg1) +map_plugin_settings_t CCommLayerServerDBus::GetPluginSettings(const std::string& pName, const std::string& pSender) { - CDBusServer_adaptor::AnalyzeComplete(arg1); + unsigned long unix_uid = m_pConn->sender_unix_uid(pSender.c_str()); + return m_pObserver->GetPluginSettings(pName, to_string(unix_uid)); } -void CCommLayerServerDBus::Error(const std::string& arg1) +void CCommLayerServerDBus::SetPluginSettings(const std::string& pName, const std::string& pSender, const map_plugin_settings_t& pSettings) { - CDBusServer_adaptor::Error(arg1); + unsigned long unix_uid = m_pConn->sender_unix_uid(pSender.c_str()); + return m_pObserver->SetPluginSettings(pName, to_string(unix_uid), pSettings); } -void CCommLayerServerDBus::Update(const std::string& pDest, const std::string& pMessage) +void CCommLayerServerDBus::RegisterPlugin(const std::string& pName) { - CDBusServer_adaptor::Update(pDest, pMessage); + return m_pObserver->RegisterPlugin(pName); } -void CCommLayerServerDBus::JobDone(const std::string &pDest, uint64_t pJobID) +void CCommLayerServerDBus::UnRegisterPlugin(const std::string& pName) { - CDBusServer_adaptor::JobDone(pDest, pJobID); + return m_pObserver->UnRegisterPlugin(pName); } -void CCommLayerServerDBus::Warning(const std::string& pDest, const std::string& pMessage) + +/* + * DBus signal emitters + */ + +void CCommLayerServerDBus::Crash(const std::string& arg) { - CDBusServer_adaptor::Warning(pMessage); + CDBusServer_adaptor::Crash(arg); } -vector_map_string_string_t CCommLayerServerDBus::GetPluginsInfo() +void CCommLayerServerDBus::AnalyzeComplete(const map_crash_report_t& arg1) { - //FIXME: simplify? - vector_map_string_string_t plugins_info; - plugins_info = m_pObserver->GetPluginsInfo(); - return plugins_info; + CDBusServer_adaptor::AnalyzeComplete(arg1); } -map_plugin_settings_t CCommLayerServerDBus::GetPluginSettings(const std::string& pName, const std::string& pSender) +void CCommLayerServerDBus::Error(const std::string& arg1) { - unsigned long unix_uid = m_pConn->sender_unix_uid(pSender.c_str()); - return m_pObserver->GetPluginSettings(pName, to_string(unix_uid)); + CDBusServer_adaptor::Error(arg1); } -void CCommLayerServerDBus::RegisterPlugin(const std::string& pName) +void CCommLayerServerDBus::Update(const std::string& pDest, const std::string& pMessage) { - return m_pObserver->RegisterPlugin(pName); + CDBusServer_adaptor::Update(pDest, pMessage); } -void CCommLayerServerDBus::UnRegisterPlugin(const std::string& pName) +void CCommLayerServerDBus::JobDone(const std::string &pDest, uint64_t pJobID) { - return m_pObserver->UnRegisterPlugin(pName); + CDBusServer_adaptor::JobDone(pDest, pJobID); } -void CCommLayerServerDBus::SetPluginSettings(const std::string& pName, const std::string& pSender, const map_plugin_settings_t& pSettings) +void CCommLayerServerDBus::Warning(const std::string& pDest, const std::string& pMessage) { - unsigned long unix_uid = m_pConn->sender_unix_uid(pSender.c_str()); - return m_pObserver->SetPluginSettings(pName, to_string(unix_uid), pSettings); + CDBusServer_adaptor::Warning(pMessage); } diff --git a/src/Daemon/CommLayerServerDBus.h b/src/Daemon/CommLayerServerDBus.h index c335b6f2..18e71f90 100644 --- a/src/Daemon/CommLayerServerDBus.h +++ b/src/Daemon/CommLayerServerDBus.h @@ -18,23 +18,21 @@ class CCommLayerServerDBus CCommLayerServerDBus(); virtual ~CCommLayerServerDBus(); + /* DBus call handlers */ virtual vector_crash_infos_t GetCrashInfos(const std::string& pSender); - /*FIXME: fix CLI and remove this stub*/ - virtual map_crash_report_t CreateReport(const std::string& pUUID, const std::string& pSender) - { - map_crash_report_t retval; - return retval; - } virtual uint64_t CreateReport_t(const std::string& pUUID, const std::string& pSender); virtual report_status_t Report(const map_crash_report_t& pReport, const std::string& pSender); virtual bool DeleteDebugDump(const std::string& pUUID, const std::string& pSender); virtual map_crash_report_t GetJobResult(uint64_t pJobID, const std::string& pSender); virtual vector_map_string_string_t GetPluginsInfo(); virtual map_plugin_settings_t GetPluginSettings(const std::string& pName, const std::string& pSender); - void SetPluginSettings(const std::string& pName, const std::string& pSender, const map_plugin_settings_t& pSettings); - void RegisterPlugin(const std::string& pName); - void UnRegisterPlugin(const std::string& pName); + virtual void SetPluginSettings(const std::string& pName, const std::string& pSender, const map_plugin_settings_t& pSettings); + virtual void RegisterPlugin(const std::string& pName); + virtual void UnRegisterPlugin(const std::string& pName); + /* Double duty: */ + /* (1) implement CCommLayerServer's virtuals */ + /* (2) propagate values to CDBusServer_adaptor::() in order to send a DBus signal */ virtual void Crash(const std::string& arg1); virtual void AnalyzeComplete(const map_crash_report_t& arg1); virtual void Error(const std::string& arg1); diff --git a/src/Daemon/CommLayerServerSocket.cpp b/src/Daemon/CommLayerServerSocket.cpp index 8347ad7a..734c5a18 100644 --- a/src/Daemon/CommLayerServerSocket.cpp +++ b/src/Daemon/CommLayerServerSocket.cpp @@ -148,10 +148,11 @@ void CCommLayerServerSocket::ProcessMessage(const std::string& pMessage, GIOChan } else if (!strncmp(pMessage.c_str(), MESSAGE_CREATE_REPORT, sizeof(MESSAGE_CREATE_REPORT) - 1)) { - std::string UUID = pMessage.substr(sizeof(MESSAGE_CREATE_REPORT) - 1); - map_crash_report_t crashReport = CreateReport(UUID, UID); - std::string message = MESSAGE_CREATE_REPORT + crash_report_to_string(crashReport); - Send(message, pSource); +// std::string UUID = pMessage.substr(sizeof(MESSAGE_CREATE_REPORT) - 1); +// map_crash_report_t crashReport = CreateReport(UUID, UID); +//use CreateReport_t instead of CreateReport? +// std::string message = MESSAGE_CREATE_REPORT + crash_report_to_string(crashReport); +// Send(message, pSource); } else if (!strncmp(pMessage.c_str(), MESSAGE_DELETE_DEBUG_DUMP, sizeof(MESSAGE_DELETE_DEBUG_DUMP) - 1)) { @@ -212,12 +213,13 @@ vector_crash_infos_t CCommLayerServerSocket::GetCrashInfos(const std::string &pS return crashInfos; } -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); - return crashReport; -} +//reimplement as CreateReport_t(...)? +//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); +// return crashReport; +//} report_status_t CCommLayerServerSocket::Report(const map_crash_report_t& pReport, const std::string& pSender) { diff --git a/src/Daemon/CommLayerServerSocket.h b/src/Daemon/CommLayerServerSocket.h index 31496334..e0b7478e 100644 --- a/src/Daemon/CommLayerServerSocket.h +++ b/src/Daemon/CommLayerServerSocket.h @@ -27,7 +27,6 @@ class CCommLayerServerSocket : public CCommLayerServer virtual ~CCommLayerServerSocket(); virtual vector_crash_infos_t GetCrashInfos(const std::string& pSender); - virtual map_crash_report_t CreateReport(const std::string& pUUID, const std::string& pSender); virtual report_status_t Report(const map_crash_report_t& pReport, const std::string& pSender); virtual bool DeleteDebugDump(const std::string& pUUID, const std::string& pSender); diff --git a/src/Daemon/CrashWatcher.h b/src/Daemon/CrashWatcher.h index 78cd706b..975dd9c0 100644 --- a/src/Daemon/CrashWatcher.h +++ b/src/Daemon/CrashWatcher.h @@ -42,9 +42,6 @@ class CCrashWatcher -//: public CDBusServer_adaptor, -// public DBus::IntrospectableAdaptor, -// public DBus::ObjectAdaptor, : public CObserver { public: @@ -57,12 +54,6 @@ class CCrashWatcher virtual void Debug(const std::string& pMessage, const std::string& pDest="0"); virtual void Warning(const std::string& pMessage, const std::string& pDest="0"); virtual vector_crash_infos_t GetCrashInfos(const std::string &pUID); - /*FIXME: fix CLI and remove this stub*/ - virtual map_crash_report_t CreateReport(const std::string &pUUID,const std::string &pUID) - { - map_crash_report_t retval; - return retval; - } 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); diff --git a/src/Daemon/DBusServerProxy.cpp b/src/Daemon/DBusServerProxy.cpp index 237a06a0..5aade653 100644 --- a/src/Daemon/DBusServerProxy.cpp +++ b/src/Daemon/DBusServerProxy.cpp @@ -156,7 +156,7 @@ DBus::Message CDBusServer_adaptor::_CreateReport_stub(const DBus::CallMessage &c std::string argin1; ri >> argin1; uint64_t argout1 = CreateReport_t(argin1, call.sender()); - if(sizeof (uint64_t) != 8) abort (); + if (sizeof (uint64_t) != 8) abort (); //map_crash_report_t argout1 = CreateReport(argin1,call.sender()); DBus::ReturnMessage reply(call); DBus::MessageIter wi = reply.writer(); diff --git a/src/Daemon/DBusServerProxy.h b/src/Daemon/DBusServerProxy.h index 91d1b1f9..3c2cff21 100644 --- a/src/Daemon/DBusServerProxy.h +++ b/src/Daemon/DBusServerProxy.h @@ -23,63 +23,68 @@ #include #include "DBusCommon.h" +/* + * This class server two roles: + * + * - when a DBus call arrives (detected in glib main loop), + * a corresponding unmarshaler is called. It unpacks DBus::CallMessage + * and calls virtual interface method function. Derived classes are expected + * to override interface methods so that they perform desired functions. + * + * - it can be used to emit DBus messages (signals) simply by calling + * appropriate (non-virtual) member, which packs arguments into + * a DBus message and sends it. + */ class CDBusServer_adaptor : public DBus::InterfaceAdaptor { -public: - CDBusServer_adaptor(); -/* reveal Interface introspection when we stabilize the API */ -/* - DBus::IntrospectedInterface *const introspect() const; -*/ - -public: - /* properties exposed by this interface, use - * property() and property(value) to get and set a particular property - */ - -public: - /* methods exported by this interface, - * you will have to implement them in your ObjectAdaptor - */ + public: + CDBusServer_adaptor(); + /* reveal Interface introspection when we stabilize the API */ + /* + DBus::IntrospectedInterface *const introspect() const; + */ - virtual vector_crash_infos_t GetCrashInfos(const std::string& pDBusSender) = 0; - virtual map_crash_report_t CreateReport(const std::string& pUUID, const std::string& pDBusSender) = 0; - virtual uint64_t CreateReport_t(const std::string& pUUID, const std::string& pDBusSender) = 0; - virtual report_status_t Report(const map_crash_report_t& pReport, const std::string& pDBusSender) = 0; - virtual bool DeleteDebugDump(const std::string& pUUID, const std::string& pDBusSender) = 0; - virtual map_crash_report_t GetJobResult(uint64_t pJobID, const std::string& pDBusSender) = 0; - virtual vector_map_string_string_t GetPluginsInfo() = 0; - virtual map_plugin_settings_t GetPluginSettings(const std::string& pName, const std::string& pDBusSender) = 0; - virtual void SetPluginSettings(const std::string& pName, const std::string& pSender, const map_plugin_settings_t& pSettings) = 0; - virtual void RegisterPlugin(const std::string& pName) = 0; - virtual void UnRegisterPlugin(const std::string& pName) = 0; + public: + /* properties exposed by this interface, use + * property() and property(value) to get and set a particular property + */ -public: - /* signal emitters for this interface - */ - /* Notify the clients (UI) about a new crash */ - void Crash(const std::string& arg1); - /* Notify the clients that creating a report has finished */ - void AnalyzeComplete(const map_crash_report_t& arg1); - void JobDone(const std::string& pDest, uint64_t job_id); - void Error(const std::string& arg1); - void Update(const std::string pDest, const std::string& pMessage); - void Warning(const std::string& arg1); + private: + /* Unmarshalers (unpack the message and call the interface method) */ + DBus::Message _GetCrashInfos_stub(const DBus::CallMessage &call); + DBus::Message _CreateReport_stub(const DBus::CallMessage &call); + DBus::Message _Report_stub(const DBus::CallMessage &call); + DBus::Message _DeleteDebugDump_stub(const DBus::CallMessage &call); + DBus::Message _GetJobResult_stub(const DBus::CallMessage &call); + DBus::Message _GetPluginsInfo_stub(const DBus::CallMessage &call); + DBus::Message _GetPluginSettings_stub(const DBus::CallMessage &call); + DBus::Message _RegisterPlugin_stub(const DBus::CallMessage &call); + DBus::Message _UnRegisterPlugin_stub(const DBus::CallMessage &call); + DBus::Message _SetPluginSettings_stub(const DBus::CallMessage &call); + public: + /* Interface methods */ + virtual vector_crash_infos_t GetCrashInfos(const std::string& pDBusSender) = 0; + virtual uint64_t CreateReport_t(const std::string& pUUID, const std::string& pDBusSender) = 0; + virtual report_status_t Report(const map_crash_report_t& pReport, const std::string& pDBusSender) = 0; + virtual bool DeleteDebugDump(const std::string& pUUID, const std::string& pDBusSender) = 0; + virtual map_crash_report_t GetJobResult(uint64_t pJobID, const std::string& pDBusSender) = 0; + virtual vector_map_string_string_t GetPluginsInfo() = 0; + virtual map_plugin_settings_t GetPluginSettings(const std::string& pName, const std::string& pDBusSender) = 0; + virtual void SetPluginSettings(const std::string& pName, const std::string& pSender, const map_plugin_settings_t& pSettings) = 0; + virtual void RegisterPlugin(const std::string& pName) = 0; + virtual void UnRegisterPlugin(const std::string& pName) = 0; -private: - /* unmarshalers (to unpack the DBus message before calling the actual interface method) - */ - DBus::Message _GetCrashInfos_stub(const DBus::CallMessage &call); - DBus::Message _CreateReport_stub(const DBus::CallMessage &call); - DBus::Message _Report_stub(const DBus::CallMessage &call); - DBus::Message _DeleteDebugDump_stub(const DBus::CallMessage &call); - DBus::Message _GetJobResult_stub(const DBus::CallMessage &call); - DBus::Message _GetPluginsInfo_stub(const DBus::CallMessage &call); - DBus::Message _GetPluginSettings_stub(const DBus::CallMessage &call); - DBus::Message _RegisterPlugin_stub(const DBus::CallMessage &call); - DBus::Message _UnRegisterPlugin_stub(const DBus::CallMessage &call); - DBus::Message _SetPluginSettings_stub(const DBus::CallMessage &call); + public: + /* Signal emitters for this interface */ + /* Notify the clients (UI) about a new crash */ + void Crash(const std::string& arg1); + /* Notify the clients that creating a report has finished */ + void AnalyzeComplete(const map_crash_report_t& arg1); + void JobDone(const std::string& pDest, uint64_t job_id); + void Error(const std::string& arg1); + void Update(const std::string pDest, const std::string& pMessage); + void Warning(const std::string& arg1); }; #endif -- cgit From 8f9a5b76761885e908df60af1d0a9d3146b7689c Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Tue, 25 Aug 2009 15:25:56 +0200 Subject: move to_string() helper to abrtlib.h Signed-off-by: Denys Vlasenko --- inc/abrtlib.h | 15 ++++++++++++++- src/Daemon/CommLayerServer.h | 11 ----------- 2 files changed, 14 insertions(+), 12 deletions(-) diff --git a/inc/abrtlib.h b/inc/abrtlib.h index 5cde2cb9..1cac10c0 100644 --- a/inc/abrtlib.h +++ b/inc/abrtlib.h @@ -38,6 +38,8 @@ #include /* C++ bits */ #include +#include +#include /* Some libc's forget to declare these, do it ourself */ extern char **environ; @@ -106,7 +108,6 @@ void xstat(const char *name, struct stat *stat_buf); void xmove_fd(int from, int to); char* xasprintf(const char *format, ...); -std::string ssprintf(const char *format, ...); int xopen(const char *pathname, int flags); int xopen3(const char *pathname, int flags, int mode); @@ -116,6 +117,18 @@ off_t copyfd_eof(int src_fd, int dst_fd); off_t copyfd_size(int src_fd, int dst_fd, off_t size); void copyfd_exact_size(int src_fd, int dst_fd, off_t size); +/* C++ style stuff */ + +std::string ssprintf(const char *format, ...); std::string get_home_dir(int uid); +template +std::string +to_string( T x ) +{ + std::ostringstream o; + o << x; + return o.str(); +} + #endif diff --git a/src/Daemon/CommLayerServer.h b/src/Daemon/CommLayerServer.h index afc9ecf3..b8ed7e14 100644 --- a/src/Daemon/CommLayerServer.h +++ b/src/Daemon/CommLayerServer.h @@ -9,17 +9,6 @@ #include "Observer.h" #include "CrashTypes.h" -/* just a helper function */ -template< class T > -std::string -to_string( T x ) -{ - std::ostringstream o; - o << x; - return o.str(); -} - - class CCommLayerServer { protected: CObserver *m_pObserver; -- cgit From febce6de166c50a55eb0cba05cff385a9ca4a917 Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Tue, 25 Aug 2009 15:29:36 +0200 Subject: nuke unused variable Signed-off-by: Denys Vlasenko --- lib/Plugins/Mailx.cpp | 5 ----- 1 file changed, 5 deletions(-) diff --git a/lib/Plugins/Mailx.cpp b/lib/Plugins/Mailx.cpp index 9ba6a630..977499ec 100644 --- a/lib/Plugins/Mailx.cpp +++ b/lib/Plugins/Mailx.cpp @@ -64,11 +64,9 @@ void CMailx::AddMailxArg(const std::string& pArg) } } - void CMailx::ExecMailx(uid_t uid, const std::string& pText) { int pipein[2]; - char buff[1024]; pid_t child; struct passwd* pw = getpwuid(uid); @@ -107,7 +105,6 @@ void CMailx::ExecMailx(uid_t uid, const std::string& pText) wait(NULL); /* why? */ } - void CMailx::SendEmail(const std::string& pSubject, const std::string& pText, const std::string& pUID) { comm_layer_inner_status("Sending an email..."); @@ -120,10 +117,8 @@ void CMailx::SendEmail(const std::string& pSubject, const std::string& pText, co AddMailxArg(""); ExecMailx(atoi(pUID.c_str()), pText); - } - std::string CMailx::Report(const map_crash_report_t& pCrashReport, const std::string& pArgs) { comm_layer_inner_status("Creating a report..."); -- cgit From facd7083bc1c5f097b7d6795780670644ccfbb1f Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Tue, 25 Aug 2009 15:31:42 +0200 Subject: eliminate one-use class CDBusServer_adaptor Signed-off-by: Denys Vlasenko --- lib/CommLayer/Observer.h | 4 +- src/Daemon/CommLayerServer.h | 2 +- src/Daemon/CommLayerServerDBus.cpp | 177 ++++++++++++++++++++++--- src/Daemon/CommLayerServerDBus.h | 34 +++-- src/Daemon/CrashWatcher.cpp | 6 +- src/Daemon/CrashWatcher.h | 6 +- src/Daemon/DBusServerProxy.cpp | 261 ------------------------------------- src/Daemon/DBusServerProxy.h | 90 ------------- src/Daemon/Makefile.am | 1 - 9 files changed, 191 insertions(+), 390 deletions(-) delete mode 100644 src/Daemon/DBusServerProxy.cpp delete mode 100644 src/Daemon/DBusServerProxy.h diff --git a/lib/CommLayer/Observer.h b/lib/CommLayer/Observer.h index 755ae524..1fb820a2 100644 --- a/lib/CommLayer/Observer.h +++ b/lib/CommLayer/Observer.h @@ -12,8 +12,8 @@ class CObserver { //CObserver(); virtual ~CObserver() {} virtual void Status(const std::string& pMessage, const std::string& pDest="0") = 0; - virtual void Debug(const std::string& pMessage, const std::string& pDest="0") = 0; - virtual void Warning(const std::string& pMessage, const std::string& pDest="0") = 0; + virtual void Debug(const std::string& pMessage) = 0; + virtual void Warning(const std::string& pMessage) = 0; /* this should be implemented in daemon */ virtual vector_crash_infos_t GetCrashInfos(const std::string &pSender) = 0; virtual uint64_t CreateReport_t(const std::string &pUUID,const std::string &pUID, const std::string &pSender) diff --git a/src/Daemon/CommLayerServer.h b/src/Daemon/CommLayerServer.h index b8ed7e14..76af62b2 100644 --- a/src/Daemon/CommLayerServer.h +++ b/src/Daemon/CommLayerServer.h @@ -30,7 +30,7 @@ class CCommLayerServer { virtual void AnalyzeComplete(const map_crash_report_t& arg1) {} virtual void Error(const std::string& arg1) {} virtual void Update(const std::string& pDest, const std::string& pMessage) {}; - virtual void Warning(const std::string& pDest, const std::string& pMessage) {}; + virtual void Warning(const std::string& pMessage) {}; virtual void JobDone(const std::string &pDest, uint64_t pJobID) {}; }; diff --git a/src/Daemon/CommLayerServerDBus.cpp b/src/Daemon/CommLayerServerDBus.cpp index 7796bac6..db78cd38 100644 --- a/src/Daemon/CommLayerServerDBus.cpp +++ b/src/Daemon/CommLayerServerDBus.cpp @@ -19,6 +19,7 @@ DBus::Connection *CCommLayerServerDBus::init_dbus(CCommLayerServerDBus *self) CCommLayerServerDBus::CCommLayerServerDBus() : + DBus::InterfaceAdaptor(CC_DBUS_IFACE), DBus::ObjectAdaptor(*init_dbus(this), CC_DBUS_PATH) { try @@ -33,6 +34,16 @@ CCommLayerServerDBus::CCommLayerServerDBus() + " * you have reloaded the dbus\n"+ + "Original exception was:\n " + err.what()); } + register_method(CCommLayerServerDBus, GetCrashInfos, _GetCrashInfos_stub); + register_method(CCommLayerServerDBus, CreateReport, _CreateReport_stub); + register_method(CCommLayerServerDBus, Report, _Report_stub); + register_method(CCommLayerServerDBus, DeleteDebugDump, _DeleteDebugDump_stub); + register_method(CCommLayerServerDBus, GetJobResult, _GetJobResult_stub); + register_method(CCommLayerServerDBus, GetPluginsInfo, _GetPluginsInfo_stub); + register_method(CCommLayerServerDBus, GetPluginSettings, _GetPluginSettings_stub); + register_method(CCommLayerServerDBus, SetPluginSettings, _SetPluginSettings_stub); + register_method(CCommLayerServerDBus, RegisterPlugin, _RegisterPlugin_stub); + register_method(CCommLayerServerDBus, UnRegisterPlugin, _UnRegisterPlugin_stub); } CCommLayerServerDBus::~CCommLayerServerDBus() @@ -44,6 +55,18 @@ CCommLayerServerDBus::~CCommLayerServerDBus() * DBus call handlers */ +/* unmarshaler (non-virtual private function) */ +DBus::Message CCommLayerServerDBus::_GetCrashInfos_stub(const DBus::CallMessage &call) +{ + DBus::MessageIter ri = call.reader(); + //FIXME: @@@REMOVE!! + vector_crash_infos_t argout1 = GetCrashInfos(call.sender()); + DBus::ReturnMessage reply(call); + DBus::MessageIter wi = reply.writer(); + wi << argout1; + return reply; +} +/* handler (public function) */ vector_crash_infos_t CCommLayerServerDBus::GetCrashInfos(const std::string &pSender) { vector_crash_infos_t crashInfos; @@ -51,16 +74,21 @@ vector_crash_infos_t CCommLayerServerDBus::GetCrashInfos(const std::string &pSen crashInfos = m_pObserver->GetCrashInfos(to_string(unix_uid)); return crashInfos; } -//FIXME: fix CLI and remove this -/* -map_crash_report_t CCommLayerServerDBus::CreateReport(const std::string &pUUID,const std::string &pSender) + +DBus::Message CCommLayerServerDBus::_CreateReport_stub(const DBus::CallMessage &call) { - unsigned long unix_uid = m_pConn->sender_unix_uid(pSender.c_str()); - map_crash_report_t crashReport; - crashReport = m_pObserver->CreateReport(pUUID, to_string(unix_uid)); - return crashReport; + DBus::MessageIter ri = call.reader(); + + std::string argin1; + ri >> argin1; + uint64_t argout1 = CreateReport_t(argin1, call.sender()); + if (sizeof (uint64_t) != 8) abort (); + //map_crash_report_t argout1 = CreateReport(argin1,call.sender()); + DBus::ReturnMessage reply(call); + DBus::MessageIter wi = reply.writer(); + wi << argout1; + return reply; } -*/ uint64_t CCommLayerServerDBus::CreateReport_t(const std::string &pUUID,const std::string &pSender) { unsigned long unix_uid = m_pConn->sender_unix_uid(pSender.c_str()); @@ -69,6 +97,18 @@ uint64_t CCommLayerServerDBus::CreateReport_t(const std::string &pUUID,const std return job_id; } +DBus::Message CCommLayerServerDBus::_Report_stub(const DBus::CallMessage &call) +{ + DBus::MessageIter ri = call.reader(); + + map_crash_report_t argin1; + ri >> argin1; + report_status_t argout1 = Report(argin1, call.sender()); + DBus::ReturnMessage reply(call); + DBus::MessageIter wi = reply.writer(); + wi << argout1; + return reply; +} report_status_t CCommLayerServerDBus::Report(const map_crash_report_t& pReport, const std::string &pSender) { report_status_t rs; @@ -77,6 +117,18 @@ report_status_t CCommLayerServerDBus::Report(const map_crash_report_t& pReport, return rs; } +DBus::Message CCommLayerServerDBus::_DeleteDebugDump_stub(const DBus::CallMessage &call) +{ + DBus::MessageIter ri = call.reader(); + + std::string argin1; + ri >> argin1; + bool argout1 = DeleteDebugDump(argin1, call.sender()); + DBus::ReturnMessage reply(call); + DBus::MessageIter wi = reply.writer(); + wi << argout1; + return reply; +} bool CCommLayerServerDBus::DeleteDebugDump(const std::string& pUUID, const std::string& pSender) { unsigned long unix_uid = m_pConn->sender_unix_uid(pSender.c_str()); @@ -84,6 +136,17 @@ bool CCommLayerServerDBus::DeleteDebugDump(const std::string& pUUID, const std:: return true; } +DBus::Message CCommLayerServerDBus::_GetJobResult_stub(const DBus::CallMessage &call) +{ + DBus::MessageIter ri = call.reader(); + uint64_t job_id; + ri >> job_id; + map_crash_report_t report = GetJobResult(job_id, call.sender()); + DBus::ReturnMessage reply(call); + DBus::MessageIter wi = reply.writer(); + wi << report; + return reply; +} map_crash_report_t CCommLayerServerDBus::GetJobResult(uint64_t pJobID, const std::string& pSender) { unsigned long unix_uid = m_pConn->sender_unix_uid(pSender.c_str()); @@ -92,6 +155,15 @@ map_crash_report_t CCommLayerServerDBus::GetJobResult(uint64_t pJobID, const std return crashReport; } +DBus::Message CCommLayerServerDBus::_GetPluginsInfo_stub(const DBus::CallMessage &call) +{ + vector_map_string_string_t plugins_info; + plugins_info = GetPluginsInfo(); + DBus::ReturnMessage reply(call); + DBus::MessageIter wi = reply.writer(); + wi << plugins_info; + return reply; +} vector_map_string_string_t CCommLayerServerDBus::GetPluginsInfo() { //FIXME: simplify? @@ -100,23 +172,67 @@ vector_map_string_string_t CCommLayerServerDBus::GetPluginsInfo() return plugins_info; } +DBus::Message CCommLayerServerDBus::_GetPluginSettings_stub(const DBus::CallMessage &call) +{ + DBus::MessageIter ri = call.reader(); + std::string PluginName; + std::string uid; + ri >> PluginName; + map_plugin_settings_t plugin_settings; + plugin_settings = GetPluginSettings(PluginName, call.sender()); + DBus::ReturnMessage reply(call); + DBus::MessageIter wi = reply.writer(); + wi << plugin_settings; + return reply; +} 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)); } +DBus::Message CCommLayerServerDBus::_SetPluginSettings_stub(const DBus::CallMessage &call) +{ + DBus::MessageIter ri = call.reader(); + std::string PluginName; + map_plugin_settings_t plugin_settings; + ri >> PluginName; + ri >> plugin_settings; + SetPluginSettings(PluginName, call.sender(), plugin_settings); + DBus::ReturnMessage reply(call); + return reply; +} 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); } +DBus::Message CCommLayerServerDBus::_RegisterPlugin_stub(const DBus::CallMessage &call) +{ + DBus::MessageIter ri = call.reader(); + std::string PluginName; + ri >> PluginName; + RegisterPlugin(PluginName); + DBus::ReturnMessage reply(call); + //DBus::MessageIter wi = reply.writer(); + //wi << plugin_settings; + return reply; +} void CCommLayerServerDBus::RegisterPlugin(const std::string& pName) { return m_pObserver->RegisterPlugin(pName); } +DBus::Message CCommLayerServerDBus::_UnRegisterPlugin_stub(const DBus::CallMessage &call) +{ + DBus::MessageIter ri = call.reader(); + std::string PluginName; + ri >> PluginName; + UnRegisterPlugin(PluginName); + DBus::ReturnMessage reply(call); + return reply; +} void CCommLayerServerDBus::UnRegisterPlugin(const std::string& pName) { return m_pObserver->UnRegisterPlugin(pName); @@ -127,33 +243,54 @@ void CCommLayerServerDBus::UnRegisterPlugin(const std::string& pName) * DBus signal emitters */ -void CCommLayerServerDBus::Crash(const std::string& arg) +/* Notify the clients (UI) about a new crash */ +void CCommLayerServerDBus::Crash(const std::string& arg1) { - CDBusServer_adaptor::Crash(arg); + ::DBus::SignalMessage sig("Crash"); + ::DBus::MessageIter wi = sig.writer(); + wi << arg1; + emit_signal(sig); } +/* Notify the clients that creating a report has finished */ void CCommLayerServerDBus::AnalyzeComplete(const map_crash_report_t& arg1) { - CDBusServer_adaptor::AnalyzeComplete(arg1); + ::DBus::SignalMessage sig("AnalyzeComplete"); + ::DBus::MessageIter wi = sig.writer(); + wi << arg1; + emit_signal(sig); } -void CCommLayerServerDBus::Error(const std::string& arg1) +void CCommLayerServerDBus::JobDone(const std::string &pDest, uint64_t job_id) { - CDBusServer_adaptor::Error(arg1); + ::DBus::SignalMessage sig("JobDone"); + ::DBus::MessageIter wi = sig.writer(); + wi << pDest; + wi << job_id; + emit_signal(sig); } -void CCommLayerServerDBus::Update(const std::string& pDest, const std::string& pMessage) +void CCommLayerServerDBus::Error(const std::string& arg1) { - CDBusServer_adaptor::Update(pDest, pMessage); + ::DBus::SignalMessage sig("Error"); + ::DBus::MessageIter wi = sig.writer(); + wi << arg1; + emit_signal(sig); } -void CCommLayerServerDBus::JobDone(const std::string &pDest, uint64_t pJobID) +void CCommLayerServerDBus::Update(const std::string& pDest, const std::string& pMessage) { - CDBusServer_adaptor::JobDone(pDest, pJobID); + ::DBus::SignalMessage sig("Update"); + ::DBus::MessageIter wi = sig.writer(); + wi << pDest; + wi << pMessage; + emit_signal(sig); } -void CCommLayerServerDBus::Warning(const std::string& pDest, const std::string& pMessage) +void CCommLayerServerDBus::Warning(const std::string& arg1) { - CDBusServer_adaptor::Warning(pMessage); + ::DBus::SignalMessage sig("Warning"); + ::DBus::MessageIter wi = sig.writer(); + wi << arg1; + emit_signal(sig); } - diff --git a/src/Daemon/CommLayerServerDBus.h b/src/Daemon/CommLayerServerDBus.h index 18e71f90..bbc0c3d1 100644 --- a/src/Daemon/CommLayerServerDBus.h +++ b/src/Daemon/CommLayerServerDBus.h @@ -1,24 +1,39 @@ -#include "CommLayerServer.h" +#ifndef COMMLAYERSERVERDBUS_H_ +#define COMMLAYERSERVERDBUS_H_ #include #include -#include "DBusServerProxy.h" -#include +#include "CommLayerServer.h" class CCommLayerServerDBus : public CCommLayerServer, - public CDBusServer_adaptor, - public DBus::IntrospectableAdaptor, + public DBus::InterfaceAdaptor, +// public DBus::IntrospectableAdaptor, public DBus::ObjectAdaptor { private: DBus::Connection *m_pConn; static DBus::Connection *init_dbus(CCommLayerServerDBus *self); + public: CCommLayerServerDBus(); virtual ~CCommLayerServerDBus(); /* DBus call handlers */ + private: + /* unmarshalers */ + DBus::Message _GetCrashInfos_stub(const DBus::CallMessage &call); + DBus::Message _CreateReport_stub(const DBus::CallMessage &call); + DBus::Message _Report_stub(const DBus::CallMessage &call); + DBus::Message _DeleteDebugDump_stub(const DBus::CallMessage &call); + DBus::Message _GetJobResult_stub(const DBus::CallMessage &call); + DBus::Message _GetPluginsInfo_stub(const DBus::CallMessage &call); + DBus::Message _GetPluginSettings_stub(const DBus::CallMessage &call); + DBus::Message _SetPluginSettings_stub(const DBus::CallMessage &call); + DBus::Message _RegisterPlugin_stub(const DBus::CallMessage &call); + DBus::Message _UnRegisterPlugin_stub(const DBus::CallMessage &call); + public: + /* handlers */ virtual vector_crash_infos_t GetCrashInfos(const std::string& pSender); virtual uint64_t CreateReport_t(const std::string& pUUID, const std::string& pSender); virtual report_status_t Report(const map_crash_report_t& pReport, const std::string& pSender); @@ -30,15 +45,14 @@ class CCommLayerServerDBus virtual void RegisterPlugin(const std::string& pName); virtual void UnRegisterPlugin(const std::string& pName); - /* Double duty: */ - /* (1) implement CCommLayerServer's virtuals */ - /* (2) propagate values to CDBusServer_adaptor::() in order to send a DBus signal */ + /* DBus signal senders */ + public: virtual void Crash(const std::string& arg1); virtual void AnalyzeComplete(const map_crash_report_t& arg1); virtual void Error(const std::string& arg1); virtual void Update(const std::string& pDest, const std::string& pMessage); virtual void JobDone(const std::string& pDest, uint64_t pJobID); - virtual void Warning(const std::string& pDest, const std::string& pMessage); + virtual void Warning(const std::string& pMessage); }; /* @@ -46,3 +60,5 @@ class CCommLayerServerDBus * (otherwise "new DBus::Connection(DBus::Connection::SystemBus())" fails) */ void attach_dbus_dispatcher_to_glib_main_context(); + +#endif diff --git a/src/Daemon/CrashWatcher.cpp b/src/Daemon/CrashWatcher.cpp index 5a6463a7..f0593c1c 100644 --- a/src/Daemon/CrashWatcher.cpp +++ b/src/Daemon/CrashWatcher.cpp @@ -30,14 +30,14 @@ void CCrashWatcher::Status(const std::string& pMessage, const std::string& pDest g_pCommLayer->Update(pDest, pMessage); } -void CCrashWatcher::Warning(const std::string& pMessage, const std::string& pDest) +void CCrashWatcher::Warning(const std::string& pMessage) { std::cerr << "Warning: " + pMessage << std::endl; if (g_pCommLayer != NULL) - g_pCommLayer->Warning(pDest, pMessage); + g_pCommLayer->Warning(pMessage); } -void CCrashWatcher::Debug(const std::string& pMessage, const std::string& pDest) +void CCrashWatcher::Debug(const std::string& pMessage) { //some logic to add logging levels? std::cout << "Debug: " + pMessage << std::endl; diff --git a/src/Daemon/CrashWatcher.h b/src/Daemon/CrashWatcher.h index 975dd9c0..ac12911b 100644 --- a/src/Daemon/CrashWatcher.h +++ b/src/Daemon/CrashWatcher.h @@ -50,9 +50,9 @@ class CCrashWatcher public: /* Observer methods */ - virtual void Status(const std::string& pMessage,const std::string& pDest="0"); - virtual void Debug(const std::string& pMessage, const std::string& pDest="0"); - virtual void Warning(const std::string& pMessage, const std::string& pDest="0"); + 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); 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); diff --git a/src/Daemon/DBusServerProxy.cpp b/src/Daemon/DBusServerProxy.cpp deleted file mode 100644 index 5aade653..00000000 --- a/src/Daemon/DBusServerProxy.cpp +++ /dev/null @@ -1,261 +0,0 @@ -/* - Copyright (C) 2009 Jiri Moskovcak (jmoskovc@redhat.com) - Copyright (C) 2009 RedHat inc. - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#include "DBusServerProxy.h" -#include - -/* public: */ - -CDBusServer_adaptor::CDBusServer_adaptor() -: DBus::InterfaceAdaptor(CC_DBUS_IFACE) -{ - register_method(CDBusServer_adaptor, GetCrashInfos, _GetCrashInfos_stub); - register_method(CDBusServer_adaptor, CreateReport, _CreateReport_stub); - register_method(CDBusServer_adaptor, Report, _Report_stub); - register_method(CDBusServer_adaptor, DeleteDebugDump, _DeleteDebugDump_stub); - register_method(CDBusServer_adaptor, GetJobResult, _GetJobResult_stub); - register_method(CDBusServer_adaptor, GetPluginsInfo, _GetPluginsInfo_stub); - register_method(CDBusServer_adaptor, GetPluginSettings, _GetPluginSettings_stub); - register_method(CDBusServer_adaptor, RegisterPlugin, _RegisterPlugin_stub); - register_method(CDBusServer_adaptor, UnRegisterPlugin, _UnRegisterPlugin_stub); - register_method(CDBusServer_adaptor, SetPluginSettings, _SetPluginSettings_stub); -} -/* reveal Interface introspection when we stabilize the API */ -/* -DBus::IntrospectedInterface *const CDBusServer_adaptor::introspect() const -{ - static DBus::IntrospectedArgument GetCrashInfos_args[] = - { - //{ "uid", "i", true}, - { "info", "a{ss}", false }, - { 0, 0, 0 } - }; - static DBus::IntrospectedArgument Crash_args[] = - { - { "package", "s", false }, - { 0, 0, 0 } - }; - static DBus::IntrospectedMethod CDBusServer_adaptor_methods[] = - { - { "GetCrashInfos", GetCrashInfos_args }, - { 0, 0 }, - { "GetCrashInfosMap", GetCrashInfos_args }, - { 0, 0 } - }; - static DBus::IntrospectedMethod CDBusServer_adaptor_signals[] = - { - { "Crash", Crash_args }, - { 0, 0 } - }; - static DBus::IntrospectedProperty CDBusServer_adaptor_properties[] = - { - { 0, 0, 0, 0 } - }; - static DBus::IntrospectedInterface CDBusServer_adaptor_interface = - { - "com.redhat.abrt", - CDBusServer_adaptor_methods, - CDBusServer_adaptor_signals, - CDBusServer_adaptor_properties - }; - return &CDBusServer_adaptor_interface; -} -*/ - -/* public: */ - -/* signal emitters for this interface */ - -/* Notify the clients (UI) about a new crash */ -void CDBusServer_adaptor::Crash(const std::string& arg1) -{ - ::DBus::SignalMessage sig("Crash"); - ::DBus::MessageIter wi = sig.writer(); - wi << arg1; - emit_signal(sig); -} - -/* Notify the clients that creating a report has finished */ -void CDBusServer_adaptor::AnalyzeComplete(const map_crash_report_t& arg1) -{ - ::DBus::SignalMessage sig("AnalyzeComplete"); - ::DBus::MessageIter wi = sig.writer(); - wi << arg1; - emit_signal(sig); -} - -void CDBusServer_adaptor::JobDone(const std::string &pDest, uint64_t job_id) -{ - ::DBus::SignalMessage sig("JobDone"); - ::DBus::MessageIter wi = sig.writer(); - wi << pDest; - wi << job_id; - emit_signal(sig); -} - -void CDBusServer_adaptor::Error(const std::string& arg1) -{ - ::DBus::SignalMessage sig("Error"); - ::DBus::MessageIter wi = sig.writer(); - wi << arg1; - emit_signal(sig); -} - -void CDBusServer_adaptor::Update(const std::string pDest, const std::string& pMessage) -{ - ::DBus::SignalMessage sig("Update"); - ::DBus::MessageIter wi = sig.writer(); - wi << pDest; - wi << pMessage; - emit_signal(sig); -} - -void CDBusServer_adaptor::Warning(const std::string& arg1) -{ - ::DBus::SignalMessage sig("Warning"); - ::DBus::MessageIter wi = sig.writer(); - wi << arg1; - emit_signal(sig); -} - -/* private: */ - -/* unmarshalers (to unpack the DBus message before calling the actual interface method) - */ -DBus::Message CDBusServer_adaptor::_GetCrashInfos_stub(const DBus::CallMessage &call) -{ - DBus::MessageIter ri = call.reader(); - //FIXME: @@@REMOVE!! - vector_crash_infos_t argout1 = GetCrashInfos(call.sender()); - DBus::ReturnMessage reply(call); - DBus::MessageIter wi = reply.writer(); - wi << argout1; - return reply; -} - -DBus::Message CDBusServer_adaptor::_CreateReport_stub(const DBus::CallMessage &call) -{ - DBus::MessageIter ri = call.reader(); - - std::string argin1; - ri >> argin1; - uint64_t argout1 = CreateReport_t(argin1, call.sender()); - if (sizeof (uint64_t) != 8) abort (); - //map_crash_report_t argout1 = CreateReport(argin1,call.sender()); - DBus::ReturnMessage reply(call); - DBus::MessageIter wi = reply.writer(); - wi << argout1; - return reply; -} - -DBus::Message CDBusServer_adaptor::_Report_stub(const DBus::CallMessage &call) -{ - DBus::MessageIter ri = call.reader(); - - map_crash_report_t argin1; - ri >> argin1; - report_status_t argout1 = Report(argin1, call.sender()); - DBus::ReturnMessage reply(call); - DBus::MessageIter wi = reply.writer(); - wi << argout1; - return reply; -} - -DBus::Message CDBusServer_adaptor::_DeleteDebugDump_stub(const DBus::CallMessage &call) -{ - DBus::MessageIter ri = call.reader(); - - std::string argin1; - ri >> argin1; - bool argout1 = DeleteDebugDump(argin1, call.sender()); - DBus::ReturnMessage reply(call); - DBus::MessageIter wi = reply.writer(); - wi << argout1; - return reply; -} - -DBus::Message CDBusServer_adaptor::_GetJobResult_stub(const DBus::CallMessage &call) -{ - DBus::MessageIter ri = call.reader(); - uint64_t job_id; - ri >> job_id; - map_crash_report_t report = GetJobResult(job_id, call.sender()); - DBus::ReturnMessage reply(call); - DBus::MessageIter wi = reply.writer(); - wi << report; - return reply; -} - -DBus::Message CDBusServer_adaptor::_GetPluginsInfo_stub(const DBus::CallMessage &call) -{ - vector_map_string_string_t plugins_info; - plugins_info = GetPluginsInfo(); - DBus::ReturnMessage reply(call); - DBus::MessageIter wi = reply.writer(); - wi << plugins_info; - return reply; -} - -DBus::Message CDBusServer_adaptor::_GetPluginSettings_stub(const DBus::CallMessage &call) -{ - DBus::MessageIter ri = call.reader(); - std::string PluginName; - std::string uid; - ri >> PluginName; - map_plugin_settings_t plugin_settings; - plugin_settings = GetPluginSettings(PluginName, call.sender()); - DBus::ReturnMessage reply(call); - DBus::MessageIter wi = reply.writer(); - wi << plugin_settings; - return reply; -} - -DBus::Message CDBusServer_adaptor::_RegisterPlugin_stub(const DBus::CallMessage &call) -{ - DBus::MessageIter ri = call.reader(); - std::string PluginName; - ri >> PluginName; - RegisterPlugin(PluginName); - DBus::ReturnMessage reply(call); - //DBus::MessageIter wi = reply.writer(); - //wi << plugin_settings; - return reply; -} - -DBus::Message CDBusServer_adaptor::_UnRegisterPlugin_stub(const DBus::CallMessage &call) -{ - DBus::MessageIter ri = call.reader(); - std::string PluginName; - ri >> PluginName; - UnRegisterPlugin(PluginName); - DBus::ReturnMessage reply(call); - return reply; -} - -DBus::Message CDBusServer_adaptor::_SetPluginSettings_stub(const DBus::CallMessage &call) -{ - DBus::MessageIter ri = call.reader(); - std::string PluginName; - map_plugin_settings_t plugin_settings; - ri >> PluginName; - ri >> plugin_settings; - SetPluginSettings(PluginName, call.sender(), plugin_settings); - DBus::ReturnMessage reply(call); - return reply; -} diff --git a/src/Daemon/DBusServerProxy.h b/src/Daemon/DBusServerProxy.h deleted file mode 100644 index 3c2cff21..00000000 --- a/src/Daemon/DBusServerProxy.h +++ /dev/null @@ -1,90 +0,0 @@ -/* - Copyright (C) 2009 Jiri Moskovcak (jmoskovc@redhat.com) - Copyright (C) 2009 RedHat inc. - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ -#ifndef DBUSSERVERPROXY_H_ -#define DBUSSERVERPROXY_H_ - -#include -#include -#include "DBusCommon.h" - -/* - * This class server two roles: - * - * - when a DBus call arrives (detected in glib main loop), - * a corresponding unmarshaler is called. It unpacks DBus::CallMessage - * and calls virtual interface method function. Derived classes are expected - * to override interface methods so that they perform desired functions. - * - * - it can be used to emit DBus messages (signals) simply by calling - * appropriate (non-virtual) member, which packs arguments into - * a DBus message and sends it. - */ -class CDBusServer_adaptor -: public DBus::InterfaceAdaptor -{ - public: - CDBusServer_adaptor(); - /* reveal Interface introspection when we stabilize the API */ - /* - DBus::IntrospectedInterface *const introspect() const; - */ - - public: - /* properties exposed by this interface, use - * property() and property(value) to get and set a particular property - */ - - private: - /* Unmarshalers (unpack the message and call the interface method) */ - DBus::Message _GetCrashInfos_stub(const DBus::CallMessage &call); - DBus::Message _CreateReport_stub(const DBus::CallMessage &call); - DBus::Message _Report_stub(const DBus::CallMessage &call); - DBus::Message _DeleteDebugDump_stub(const DBus::CallMessage &call); - DBus::Message _GetJobResult_stub(const DBus::CallMessage &call); - DBus::Message _GetPluginsInfo_stub(const DBus::CallMessage &call); - DBus::Message _GetPluginSettings_stub(const DBus::CallMessage &call); - DBus::Message _RegisterPlugin_stub(const DBus::CallMessage &call); - DBus::Message _UnRegisterPlugin_stub(const DBus::CallMessage &call); - DBus::Message _SetPluginSettings_stub(const DBus::CallMessage &call); - public: - /* Interface methods */ - virtual vector_crash_infos_t GetCrashInfos(const std::string& pDBusSender) = 0; - virtual uint64_t CreateReport_t(const std::string& pUUID, const std::string& pDBusSender) = 0; - virtual report_status_t Report(const map_crash_report_t& pReport, const std::string& pDBusSender) = 0; - virtual bool DeleteDebugDump(const std::string& pUUID, const std::string& pDBusSender) = 0; - virtual map_crash_report_t GetJobResult(uint64_t pJobID, const std::string& pDBusSender) = 0; - virtual vector_map_string_string_t GetPluginsInfo() = 0; - virtual map_plugin_settings_t GetPluginSettings(const std::string& pName, const std::string& pDBusSender) = 0; - virtual void SetPluginSettings(const std::string& pName, const std::string& pSender, const map_plugin_settings_t& pSettings) = 0; - virtual void RegisterPlugin(const std::string& pName) = 0; - virtual void UnRegisterPlugin(const std::string& pName) = 0; - - public: - /* Signal emitters for this interface */ - /* Notify the clients (UI) about a new crash */ - void Crash(const std::string& arg1); - /* Notify the clients that creating a report has finished */ - void AnalyzeComplete(const map_crash_report_t& arg1); - void JobDone(const std::string& pDest, uint64_t job_id); - void Error(const std::string& arg1); - void Update(const std::string pDest, const std::string& pMessage); - void Warning(const std::string& arg1); -}; - -#endif diff --git a/src/Daemon/Makefile.am b/src/Daemon/Makefile.am index d36650ab..af2f406e 100644 --- a/src/Daemon/Makefile.am +++ b/src/Daemon/Makefile.am @@ -1,7 +1,6 @@ sbin_PROGRAMS = abrt abrt_SOURCES = \ - DBusServerProxy.h DBusServerProxy.cpp \ ABRTPlugin.cpp ABRTPlugin.h \ PluginManager.cpp PluginManager.h \ MiddleWare.cpp MiddleWare.h \ -- cgit From e4185013d1309b80633d17b84837913ac8705438 Mon Sep 17 00:00:00 2001 From: Daniel Novotny Date: Tue, 25 Aug 2009 15:34:32 +0200 Subject: add new parameter to FileTransfer plugin --- lib/Plugins/FileTransfer.cpp | 22 +++++++++++++++++++--- lib/Plugins/abrt-FileTransfer.7 | 5 +++++ 2 files changed, 24 insertions(+), 3 deletions(-) diff --git a/lib/Plugins/FileTransfer.cpp b/lib/Plugins/FileTransfer.cpp index 981e574d..d3d09969 100644 --- a/lib/Plugins/FileTransfer.cpp +++ b/lib/Plugins/FileTransfer.cpp @@ -172,6 +172,8 @@ std::string CFileTransfer::DirBase(const std::string& pStr) void CFileTransfer::Run(const std::string& pActiveDir, const std::string& pArgs) { fstream dirlist; + std::string dirname, archivename; + char hostname[HBLEN]; comm_layer_inner_status("File Transfer: Creating a report..."); @@ -181,12 +183,26 @@ void CFileTransfer::Run(const std::string& pActiveDir, const std::string& pArgs) dirlist.open(FILETRANSFER_DIRLIST, fstream::out | fstream::app ); dirlist << pActiveDir << endl; dirlist.close(); + } else if(pArgs == "one") + { + /* just send one archive */ + gethostname(hostname,HBLEN); + archivename = std::string(hostname) + "-" + + DirBase(pActiveDir) + m_sArchiveType; + try + { + CreateArchive(archivename,pActiveDir); + SendFile(m_sURL, archivename); + } + catch (CABRTException& e) + { + comm_layer_inner_warning("CFileTransfer::Run(): Cannot create and send an archive: " + e.what()); + comm_layer_inner_status("CFileTransfer::Run(): Cannot create and send an archive: " + e.what()); + } + unlink(archivename.c_str()); } else { - std::string dirname, archivename; - - char hostname[HBLEN]; gethostname(hostname,HBLEN); diff --git a/lib/Plugins/abrt-FileTransfer.7 b/lib/Plugins/abrt-FileTransfer.7 index a04dd421..d1d3b255 100644 --- a/lib/Plugins/abrt-FileTransfer.7 +++ b/lib/Plugins/abrt-FileTransfer.7 @@ -22,6 +22,11 @@ There are two modes of invocation: \fI"store"\fP, the plugin stores a record of the occurrence of the crash in its internal list. .P +* If you use the parameter +\fI"one"\fP, the plugin will transfer this specific crash, +on which it was invoked, without storing it in the internal +list. +.P * If you use some other parameter, or no parameter at all, the plugin will iterate through the internal list and will send every recorded crash to the server specified in the \fIFileTransfer.conf\fP -- cgit