summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/CommLayer/CommLayerClientDBus.cpp3
-rw-r--r--lib/CommLayer/CommLayerServer.h2
-rw-r--r--lib/CommLayer/CommLayerServerDBus.cpp6
-rw-r--r--lib/CommLayer/CommLayerServerDBus.h2
-rw-r--r--lib/CommLayer/DBusClientProxy.h57
-rw-r--r--lib/CommLayer/DBusServerProxy.h3
-rw-r--r--lib/CommLayer/Observer.h8
7 files changed, 64 insertions, 17 deletions
diff --git a/lib/CommLayer/CommLayerClientDBus.cpp b/lib/CommLayer/CommLayerClientDBus.cpp
index 6f4e4b51..77983463 100644
--- a/lib/CommLayer/CommLayerClientDBus.cpp
+++ b/lib/CommLayer/CommLayerClientDBus.cpp
@@ -1,6 +1,7 @@
#include "CommLayerClientDBus.h"
CCommLayerClientDBus::CCommLayerClientDBus(DBus::Connection &connection, const char *path, const char *name)
-: DBus::ObjectProxy(connection, path, name)
+: CDBusClient_proxy(connection),
+ DBus::ObjectProxy(connection, path, name)
{
}
CCommLayerClientDBus::~CCommLayerClientDBus()
diff --git a/lib/CommLayer/CommLayerServer.h b/lib/CommLayer/CommLayerServer.h
index b9174d1a..b67b5966 100644
--- a/lib/CommLayer/CommLayerServer.h
+++ b/lib/CommLayer/CommLayerServer.h
@@ -47,7 +47,7 @@ class CCommLayerServer{
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 JobDone(uint64_t pJobID) {};
+ virtual void JobDone(const std::string &pDest, uint64_t pJobID) {};
};
#endif //COMMLAYERSERVER_H_
diff --git a/lib/CommLayer/CommLayerServerDBus.cpp b/lib/CommLayer/CommLayerServerDBus.cpp
index d3e00c1f..ad3c2db7 100644
--- a/lib/CommLayer/CommLayerServerDBus.cpp
+++ b/lib/CommLayer/CommLayerServerDBus.cpp
@@ -53,7 +53,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));
+ uint64_t job_id = m_pObserver->CreateReport_t(pUUID, to_string(unix_uid), pSender);
return job_id;
}
@@ -99,7 +99,7 @@ void CCommLayerServerDBus::Update(const std::string& pDest, const std::string& p
CDBusServer_adaptor::Update(pDest, pMessage);
}
-void CCommLayerServerDBus::JobDone(uint64_t pJobID)
+void CCommLayerServerDBus::JobDone(const std::string &pDest, uint64_t pJobID)
{
- CDBusServer_adaptor::JobDone(pJobID);
+ CDBusServer_adaptor::JobDone(pDest, pJobID);
}
diff --git a/lib/CommLayer/CommLayerServerDBus.h b/lib/CommLayer/CommLayerServerDBus.h
index 17b7fdc6..df5d93d5 100644
--- a/lib/CommLayer/CommLayerServerDBus.h
+++ b/lib/CommLayer/CommLayerServerDBus.h
@@ -31,6 +31,6 @@ class CCommLayerServerDBus
virtual void AnalyzeComplete(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(uint64_t pJobID);
+ virtual void JobDone(const std::string &pDest, uint64_t pJobID);
};
diff --git a/lib/CommLayer/DBusClientProxy.h b/lib/CommLayer/DBusClientProxy.h
index 4065307b..52ba75d5 100644
--- a/lib/CommLayer/DBusClientProxy.h
+++ b/lib/CommLayer/DBusClientProxy.h
@@ -112,13 +112,30 @@ public:
class CDBusClient_proxy
: public DBus::InterfaceProxy
{
+private:
+ bool m_bJobDone;
+ uint64_t m_iPendingJobID;
+ GMainLoop *gloop;
+ std::string m_sConnName;
public:
+
CDBusClient_proxy()
: DBus::InterfaceProxy(CC_DBUS_IFACE)
{
+ connect_signal(CDBusClient_proxy, Crash, _Crash_stub);
+ connect_signal(CDBusClient_proxy, JobDone, _JobDone_stub);
+ m_sConnName = "";
+ }
+
+ CDBusClient_proxy(::DBus::Connection &pConnection)
+ : DBus::InterfaceProxy(CC_DBUS_IFACE)
+ {
+ gloop = g_main_loop_new(NULL, false);
//# define connect_signal(interface, signal, callback)
connect_signal(CDBusClient_proxy, Crash, _Crash_stub);
+ connect_signal(CDBusClient_proxy, JobDone, _JobDone_stub);
+ m_sConnName = pConnection.unique_name();
}
public:
@@ -168,6 +185,7 @@ public:
map_crash_report_t CreateReport(const std::string& pUUID)
{
+ m_bJobDone = false;
DBus::CallMessage call;
DBus::MessageIter wi = call.writer();
@@ -176,10 +194,10 @@ public:
call.member("CreateReport");
DBus::Message ret = invoke_method(call);
DBus::MessageIter ri = ret.reader();
-
- map_crash_report_t argout;
- ri >> argout;
- return argout;
+ ri >> m_iPendingJobID;
+ //FIXME: what if the report is created before we start the loop? (we miss the signal and get stuck in the loop)
+ g_main_loop_run(gloop);
+ return GetJobResult(m_iPendingJobID);
};
void Report(map_crash_report_t pReport)
@@ -194,12 +212,27 @@ public:
DBus::MessageIter ri = ret.reader();
}
+ map_crash_report_t GetJobResult(uint64_t pJobID)
+ {
+ DBus::CallMessage call;
+
+ DBus::MessageIter wi = call.writer();
+
+ wi << pJobID;
+ call.member("GetJobResult");
+ DBus::Message ret = invoke_method(call);
+ DBus::MessageIter ri = ret.reader();
+ map_crash_report_t argout;
+ ri >> argout;
+ return argout;
+ }
+
public:
/* signal handlers for this interface
*/
- virtual void Crash(std::string& value) = 0;
-
+ virtual void Crash(std::string& value){}
+
private:
/* unmarshalers (to unpack the DBus message before calling the actual signal handler)
@@ -211,4 +244,16 @@ private:
std::string value; ri >> value;
Crash(value);
}
+
+ void _JobDone_stub(const ::DBus::SignalMessage &sig)
+ {
+ DBus::MessageIter ri = sig.reader();
+ std::string dest;
+ ri >> dest;
+ if(m_sConnName == dest)
+ {
+ ri >> m_iPendingJobID;
+ g_main_loop_quit(gloop);
+ }
+ }
};
diff --git a/lib/CommLayer/DBusServerProxy.h b/lib/CommLayer/DBusServerProxy.h
index b55172be..1b8159b6 100644
--- a/lib/CommLayer/DBusServerProxy.h
+++ b/lib/CommLayer/DBusServerProxy.h
@@ -118,10 +118,11 @@ public:
}
- void JobDone(uint64_t job_id)
+ void 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);
}
diff --git a/lib/CommLayer/Observer.h b/lib/CommLayer/Observer.h
index 9b476f1f..880a7923 100644
--- a/lib/CommLayer/Observer.h
+++ b/lib/CommLayer/Observer.h
@@ -9,13 +9,13 @@ class CObserver {
public:
//CObserver();
virtual ~CObserver() {}
- virtual void Status(const std::string& pMessage) = 0;
- virtual void Debug(const std::string& pMessage) = 0;
- virtual void Warning(const std::string& pMessage) = 0;
+ 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;
/* 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 &pSender){std::cout << "DEFAULT OBSERVER";return 0;};
+ virtual uint64_t CreateReport_t(const std::string &pUUID,const std::string &pUID, const std::string &pSender){std::cout << "DEFAULT OBSERVER";return 0;};
virtual bool Report(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;