diff options
author | Jiri Moskovcak <jmoskovc@redhat.com> | 2009-08-06 16:19:07 +0200 |
---|---|---|
committer | Jiri Moskovcak <jmoskovc@redhat.com> | 2009-08-06 16:19:07 +0200 |
commit | 84348ccea878d509f838927e1bf393e5443d3ac8 (patch) | |
tree | d7dc8bdc80b18a6137f94415761ec95c1df8e005 /lib/CommLayer | |
parent | 9a3268d970142f0dfb4e3e77c66c9637bf87fbda (diff) | |
parent | 26c6665308b5a99d02308099118b23b2716dacc0 (diff) | |
download | abrt-84348ccea878d509f838927e1bf393e5443d3ac8.tar.gz abrt-84348ccea878d509f838927e1bf393e5443d3ac8.tar.xz abrt-84348ccea878d509f838927e1bf393e5443d3ac8.zip |
Merge branch 'master' of ssh://git.fedorahosted.org/git/abrt
Conflicts:
lib/CommLayer/DBusServerProxy.h
Diffstat (limited to 'lib/CommLayer')
-rw-r--r-- | lib/CommLayer/DBusClientProxy.cpp | 238 | ||||
-rw-r--r-- | lib/CommLayer/DBusClientProxy.h | 247 | ||||
-rw-r--r-- | lib/CommLayer/DBusServerProxy.cpp | 206 | ||||
-rw-r--r-- | lib/CommLayer/DBusServerProxy.h | 197 | ||||
-rw-r--r-- | lib/CommLayer/Makefile.am | 41 |
5 files changed, 539 insertions, 390 deletions
diff --git a/lib/CommLayer/DBusClientProxy.cpp b/lib/CommLayer/DBusClientProxy.cpp new file mode 100644 index 00000000..4f51172d --- /dev/null +++ b/lib/CommLayer/DBusClientProxy.cpp @@ -0,0 +1,238 @@ +/* + 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 "DBusClientProxy.h" +#include <iostream> + +namespace org { +namespace freedesktop { +namespace DBus { + +/* class DaemonWatcher_proxy */ + +/* public: */ + +DaemonWatcher_proxy::DaemonWatcher_proxy() +: ::DBus::InterfaceProxy("org.freedesktop.DBus") +{ + m_pStateChangeHandler_cb_data = NULL; + m_pStateChangeHandler = NULL; + connect_signal(DaemonWatcher_proxy, NameOwnerChanged , _DaemonStateChanged); +} + +void DaemonWatcher_proxy::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 DaemonWatcher_proxy::_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; + } + } + } +} + +} } } /* closing namespaces */ + + +/* class DaemonWatcher */ + +/* public: */ + +DaemonWatcher::DaemonWatcher(DBus::Connection &connection, const char *path, const char *name) +: ::DBus::ObjectProxy(connection, path, name) +{ +} +DaemonWatcher::~DaemonWatcher() +{ + std::cout << "~DaemonWatcher" << std::endl; +} + + +/* class CDBusClient_proxy */ + +/* public: */ + +CDBusClient_proxy::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::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(); +} + +/* 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 CDBusClient_proxy::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 CDBusClient_proxy::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 CDBusClient_proxy::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 CDBusClient_proxy::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 CDBusClient_proxy::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; +} + +/* signal handlers for this interface + */ +void CDBusClient_proxy::Crash(std::string& value) +{ +} + +/* private: */ + +/* unmarshalers (to unpack the DBus message before calling the actual signal handler) + */ +void CDBusClient_proxy::_Crash_stub(const ::DBus::SignalMessage &sig) +{ + DBus::MessageIter ri = sig.reader(); + + std::string value; ri >> value; + Crash(value); +} + +void CDBusClient_proxy::_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/DBusClientProxy.h b/lib/CommLayer/DBusClientProxy.h index 52ba75d5..5b5c1fde 100644 --- a/lib/CommLayer/DBusClientProxy.h +++ b/lib/CommLayer/DBusClientProxy.h @@ -1,26 +1,28 @@ -/* - 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. +/* + 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 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,68 +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, @@ -98,162 +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(); + */ + 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); - 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){} - -private: + 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 diff --git a/lib/CommLayer/DBusServerProxy.cpp b/lib/CommLayer/DBusServerProxy.cpp new file mode 100644 index 00000000..6bf0fbde --- /dev/null +++ b/lib/CommLayer/DBusServerProxy.cpp @@ -0,0 +1,206 @@ +/* + 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 <stdlib.h> + +/* 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); +} +/* 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(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; + bool 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; +} diff --git a/lib/CommLayer/DBusServerProxy.h b/lib/CommLayer/DBusServerProxy.h index 157a95f9..78fb28b3 100644 --- a/lib/CommLayer/DBusServerProxy.h +++ b/lib/CommLayer/DBusServerProxy.h @@ -16,83 +16,35 @@ 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 <dbus-c++/dbus.h> #include <dbus-c++/glib-integration.h> #include "DBusCommon.h" -#include <map> -#include <iostream> -#include <stdlib.h> class CDBusServer_adaptor : public DBus::InterfaceAdaptor { public: - - 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); - } + CDBusServer_adaptor(); /* reveal Interface introspection when we stabilize the API */ /* - DBus::IntrospectedInterface *const 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; - } + DBus::IntrospectedInterface *const introspect() const; */ -public: +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 */ 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 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 bool Report(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; @@ -102,130 +54,23 @@ public: /* signal emitters for this interface */ /* Notify the clients (UI) about a new crash */ - void Crash(const std::string& arg1) - { - ::DBus::SignalMessage sig("Crash"); - ::DBus::MessageIter wi = sig.writer(); - wi << arg1; - emit_signal(sig); - } + void Crash(const std::string& arg1); /* Notify the clients that creating a report has finished */ - void AnalyzeComplete(map_crash_report_t arg1) - { - ::DBus::SignalMessage sig("AnalyzeComplete"); - ::DBus::MessageIter wi = sig.writer(); - wi << arg1; - emit_signal(sig); - } - - - 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); - } - - void Error(const std::string& arg1) - { - ::DBus::SignalMessage sig("Error"); - ::DBus::MessageIter wi = sig.writer(); - wi << arg1; - emit_signal(sig); - } - - void 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 Warning(const std::string& arg1) - { - ::DBus::SignalMessage sig("Warning"); - ::DBus::MessageIter wi = sig.writer(); - wi << arg1; - emit_signal(sig); - } + void AnalyzeComplete(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 (to unpack the DBus message before calling the actual interface method) */ - DBus::Message _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 _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 _Report_stub(const DBus::CallMessage &call) - { - DBus::MessageIter ri = call.reader(); - - map_crash_report_t argin1; ri >> argin1; - bool argout1 = Report(argin1, call.sender()); - DBus::ReturnMessage reply(call); - DBus::MessageIter wi = reply.writer(); - wi << argout1; - return reply; - } - - DBus::Message _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 _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 _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 _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); }; +#endif diff --git a/lib/CommLayer/Makefile.am b/lib/CommLayer/Makefile.am index 5a1fa503..f80683b3 100644 --- a/lib/CommLayer/Makefile.am +++ b/lib/CommLayer/Makefile.am @@ -1,20 +1,31 @@ lib_LTLIBRARIES = libABRTCommLayer.la -libABRTCommLayer_la_SOURCES = CommLayerServer.h CommLayerServer.cpp \ - CommLayerServerSocket.h CommLayerServerSocket.cpp \ - CommLayerServerDBus.h CommLayerServerDBus.cpp \ - DBusServerProxy.h Observer.h DBusCommon.h \ - CommLayerInner.h CommLayerInner.cpp \ - DBusClientProxy.h CommLayerClientDBus.h CommLayerClientDBus.cpp - -libABRTCommLayer_la_LIBADD = ../../lib/MiddleWare/libABRTMiddleWare.la $(DL_LIBS) $(DBUSCPP_LIBS) + +libABRTCommLayer_la_SOURCES = \ + CommLayerServer.h CommLayerServer.cpp \ + CommLayerServerSocket.h CommLayerServerSocket.cpp \ + CommLayerServerDBus.h CommLayerServerDBus.cpp \ + DBusServerProxy.h DBusServerProxy.cpp \ + DBusClientProxy.h DBusClientProxy.cpp \ + CommLayerInner.h CommLayerInner.cpp \ + CommLayerClientDBus.h CommLayerClientDBus.cpp \ + Observer.h \ + DBusCommon.h +libABRTCommLayer_la_LIBADD = \ + ../../lib/MiddleWare/libABRTMiddleWare.la \ + $(DL_LIBS) $(DBUSCPP_LIBS) libABRTCommLayer_la_LDFLAGS = -version-info 0:1:0 -libABRTCommLayer_la_CPPFLAGS = -Wall -Werror -I$(srcdir)/../../lib/MiddleWare\ - -I$(srcdir)/../../lib/DBus -I$(srcdir)/../../inc\ - -DDEBUG_DUMPS_DIR=\"$(DEBUG_DUMPS_DIR)\" $(GLIB_CFLAGS) $(DBUSCPP_CFLAGS) \ - -DPLUGINS_LIB_DIR=\"$(PLUGINS_LIB_DIR)\" \ - -DPLUGINS_CONF_DIR=\"$(PLUGINS_CONF_DIR)\" \ - -DCONF_DIR=\"$(CONF_DIR)\" -D_GNU_SOURCE \ - -DVAR_RUN=\"$(VAR_RUN)\" +libABRTCommLayer_la_CPPFLAGS = \ + -Wall -Werror \ + -I$(srcdir)/../../inc \ + -I$(srcdir)/../../lib/MiddleWare \ + -I$(srcdir)/../../lib/DBus \ + -DDEBUG_DUMPS_DIR=\"$(DEBUG_DUMPS_DIR)\" \ + -DPLUGINS_LIB_DIR=\"$(PLUGINS_LIB_DIR)\" \ + -DPLUGINS_CONF_DIR=\"$(PLUGINS_CONF_DIR)\" \ + -DCONF_DIR=\"$(CONF_DIR)\" \ + -DVAR_RUN=\"$(VAR_RUN)\" \ + $(GLIB_CFLAGS) $(DBUSCPP_CFLAGS) \ + -D_GNU_SOURCE #check_PROGRAMS = test #test_SOURCES = test.cpp |