summaryrefslogtreecommitdiffstats
path: root/lib/CommLayer/DBusClientProxy.h
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2009-08-06 14:00:32 +0200
committerDenys Vlasenko <vda.linux@googlemail.com>2009-08-06 14:00:32 +0200
commitd2c414f198bfd96329f8b3706bfd72820b34bd6c (patch)
treea2cc984f4ae38437c60c9cb5ff2ad058973ac0cb /lib/CommLayer/DBusClientProxy.h
parent2712136a385253a711a7b1a00222cd117bcbb830 (diff)
downloadabrt-d2c414f198bfd96329f8b3706bfd72820b34bd6c.tar.gz
abrt-d2c414f198bfd96329f8b3706bfd72820b34bd6c.tar.xz
abrt-d2c414f198bfd96329f8b3706bfd72820b34bd6c.zip
move huge inlines out of DBusClientProxy.h to DBusClientProxy.cpp
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'lib/CommLayer/DBusClientProxy.h')
-rw-r--r--lib/CommLayer/DBusClientProxy.h205
1 files changed, 27 insertions, 178 deletions
diff --git a/lib/CommLayer/DBusClientProxy.h b/lib/CommLayer/DBusClientProxy.h
index 0293b0a..5b5c1fd 100644
--- a/lib/CommLayer/DBusClientProxy.h
+++ b/lib/CommLayer/DBusClientProxy.h
@@ -16,11 +16,13 @@
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
+#ifndef DBUSCLIENTPROXY_H_
+#define DBUSCLIENTPROXY_H_
#include <dbus-c++/dbus.h>
#include <dbus-c++/glib-integration.h>
#include "DBusCommon.h"
-#include <iostream>
+
#define ABRT_NOT_RUNNING 0
#define ABRT_RUNNING 1
@@ -29,69 +31,25 @@ namespace freedesktop {
namespace DBus {
class DaemonWatcher_proxy
- : public ::DBus::InterfaceProxy
+: public ::DBus::InterfaceProxy
{
private:
void *m_pStateChangeHandler_cb_data;
void (*m_pStateChangeHandler)(bool running, void* data);
-public:
- DaemonWatcher_proxy()
- : ::DBus::InterfaceProxy("org.freedesktop.DBus")
- {
- m_pStateChangeHandler_cb_data = NULL;
- m_pStateChangeHandler = NULL;
- connect_signal(DaemonWatcher_proxy, NameOwnerChanged , _DaemonStateChanged);
- }
+public:
+ DaemonWatcher_proxy();
+ void ConnectStateChangeHandler(void (*pStateChangeHandler)(bool running, void* data), void *cb_data);
- void ConnectStateChangeHandler(void (*pStateChangeHandler)(bool running, void* data), void *cb_data)
- {
- m_pStateChangeHandler_cb_data = cb_data;
- m_pStateChangeHandler = pStateChangeHandler;
- }
private:
-
/* unmarshalers (to unpack the DBus message before calling the actual signal handler)
*/
- void _DaemonStateChanged(const ::DBus::SignalMessage &sig)
- {
- ::DBus::MessageIter ri = sig.reader();
- std::string name;
- std::string old_owner;
- std::string new_owner;
- ri >> name;
- ri >> old_owner;
- ri >> new_owner;
- if(name.compare("com.redhat.abrt") == 0)
- {
- if(new_owner.length() > 0)
- {
- if(m_pStateChangeHandler)
- {
- m_pStateChangeHandler(true,m_pStateChangeHandler_cb_data);
- }
- else
- {
- std::cout << "Daemon appeared!" << std::endl;
- }
- }
- if(new_owner.length() == 0)
- {
- if(m_pStateChangeHandler)
- {
- m_pStateChangeHandler(false, m_pStateChangeHandler_cb_data);
- }
- else
- {
- std::cout << "Daemon dissapeared!" << std::endl;
- }
- }
- }
- }
+ void _DaemonStateChanged(const ::DBus::SignalMessage &sig);
};
} } }
+
class DaemonWatcher
: public org::freedesktop::DBus::DaemonWatcher_proxy,
public DBus::IntrospectableProxy,
@@ -99,161 +57,52 @@ class DaemonWatcher
{
public:
- DaemonWatcher(DBus::Connection &connection, const char *path, const char *name)
- : ::DBus::ObjectProxy(connection, path, name)
- {
- }
- ~DaemonWatcher()
- {
- std::cout << "~DaemonWatcher" << std::endl;
- }
+ DaemonWatcher(DBus::Connection &connection, const char *path, const char *name);
+ ~DaemonWatcher();
};
class CDBusClient_proxy
- : public DBus::InterfaceProxy
+: 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:
+ CDBusClient_proxy();
+ CDBusClient_proxy(::DBus::Connection &pConnection);
+public:
/* methods exported by this interface,
* this functions will invoke the corresponding methods on the remote objects
*/
- /*
-
+ /*
<
<m_sUUID;m_sUID;m_sCount;m_sExecutable;m_sPackage>
<m_sUUID;m_sUID;m_sCount;m_sExecutable;m_sPackage>
<m_sUUID;m_sUID;m_sCount;m_sExecutable;m_sPackage>
...
>
- */
- vector_crash_infos_t GetCrashInfos()
- {
- DBus::CallMessage call;
- DBus::MessageIter wi = call.writer();
-
- call.member("GetCrashInfos");
- DBus::Message ret = invoke_method(call);
- DBus::MessageIter ri = ret.reader();
-
- vector_crash_infos_t argout;
- ri >> argout;
- return argout;
- }
-
- bool DeleteDebugDump(const std::string& pUUID)
- {
- DBus::CallMessage call;
-
- DBus::MessageIter wi = call.writer();
-
- wi << pUUID;
- call.member("DeleteDebugDump");
- DBus::Message ret = invoke_method(call);
- DBus::MessageIter ri = ret.reader();
-
- bool argout;
- ri >> argout;
- return argout;
- }
-
- map_crash_report_t CreateReport(const std::string& pUUID)
- {
- m_bJobDone = false;
- DBus::CallMessage call;
-
- DBus::MessageIter wi = call.writer();
-
- wi << pUUID;
- call.member("CreateReport");
- DBus::Message ret = invoke_method(call);
- DBus::MessageIter ri = ret.reader();
- 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)
- {
- DBus::CallMessage call;
-
- DBus::MessageIter wi = call.writer();
-
- wi << pReport;
- call.member("Report");
- DBus::Message ret = invoke_method(call);
- 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;
- }
+ */
+ 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);
+ map_crash_report_t GetJobResult(uint64_t pJobID);
public:
-
/* signal handlers for this interface
*/
- virtual void Crash(std::string& value){}
+ virtual void Crash(std::string& value);
private:
-
/* unmarshalers (to unpack the DBus message before calling the actual signal handler)
*/
- void _Crash_stub(const ::DBus::SignalMessage &sig)
- {
- DBus::MessageIter ri = sig.reader();
-
- 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);
- }
- }
+ void _Crash_stub(const ::DBus::SignalMessage &sig);
+ void _JobDone_stub(const ::DBus::SignalMessage &sig);
};
+
+#endif