summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2009-08-25 14:00:22 +0200
committerDenys Vlasenko <vda.linux@googlemail.com>2009-08-25 14:00:22 +0200
commit3008b32dd0f78b0b2c09e05a7b47080c7cb75d38 (patch)
treef5bd107a868b4cae9016481e1cc9abdaea9409f5
parent5bf3512df0529960ed4980251825b49a12eff894 (diff)
downloadabrt-3008b32dd0f78b0b2c09e05a7b47080c7cb75d38.tar.gz
abrt-3008b32dd0f78b0b2c09e05a7b47080c7cb75d38.tar.xz
abrt-3008b32dd0f78b0b2c09e05a7b47080c7cb75d38.zip
remove CreateReport() method from server machinery; add comments about DBus
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r--lib/CommLayer/Observer.h1
-rw-r--r--src/Daemon/CommLayerServer.h5
-rw-r--r--src/Daemon/CommLayerServerDBus.cpp68
-rw-r--r--src/Daemon/CommLayerServerDBus.h16
-rw-r--r--src/Daemon/CommLayerServerSocket.cpp22
-rw-r--r--src/Daemon/CommLayerServerSocket.h1
-rw-r--r--src/Daemon/CrashWatcher.h9
-rw-r--r--src/Daemon/DBusServerProxy.cpp2
-rw-r--r--src/Daemon/DBusServerProxy.h107
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::<same_name>() 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 <dbus-c++/glib-integration.h>
#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