diff options
author | Denys Vlasenko <vda.linux@googlemail.com> | 2009-09-18 15:07:11 +0200 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2009-09-18 15:07:11 +0200 |
commit | 43fe926f20bd427e96a22081deace10752bb4533 (patch) | |
tree | 64a3a9950ad659ad3ff193df2916d05e31fa085c /src/Applet | |
parent | 73c3f5fba688d9359dbf79f70b8759aee2857e41 (diff) | |
download | abrt-43fe926f20bd427e96a22081deace10752bb4533.tar.gz abrt-43fe926f20bd427e96a22081deace10752bb4533.tar.xz abrt-43fe926f20bd427e96a22081deace10752bb4533.zip |
abrt-applet: remove dbus-c++ glue. -50k of code
text data bss dec hex filename
70529 2144 1528 74201 121d9 abrt.t0/UNPACKED/usr/bin/abrt-applet
22116 1688 376 24180 5e74 abrt.t1/UNPACKED/usr/bin/abrt-applet
Also, we do not use dbus-c++ anymore, which is 200k of code
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'src/Applet')
-rw-r--r-- | src/Applet/Applet.cpp | 249 | ||||
-rw-r--r-- | src/Applet/CCApplet.cpp | 102 | ||||
-rw-r--r-- | src/Applet/CCApplet.h | 22 | ||||
-rw-r--r-- | src/Applet/DBusClientProxy.cpp | 252 | ||||
-rw-r--r-- | src/Applet/DBusClientProxy.h | 109 | ||||
-rw-r--r-- | src/Applet/Makefile.am | 9 |
6 files changed, 221 insertions, 522 deletions
diff --git a/src/Applet/Applet.cpp b/src/Applet/Applet.cpp index cf58c7da..a75a1425 100644 --- a/src/Applet/Applet.cpp +++ b/src/Applet/Applet.cpp @@ -17,95 +17,256 @@ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ -#include "CCApplet.h" #include <iostream> #include <dbus/dbus-shared.h> - +#include <dbus/dbus-glib.h> +#include <dbus/dbus-glib-lowlevel.h> #if HAVE_CONFIG_H #include <config.h> #endif - #if HAVE_LOCALE_H #include <locale.h> #endif - #if ENABLE_NLS #include <libintl.h> #define _(S) gettext(S) #else #define _(S) (S) #endif +#include "abrtlib.h" +#include "abrt_dbus.h" +#include "DBusCommon.h" +#include "CCApplet.h" + -//@@global applet object -CApplet *applet; +static CApplet* applet; -static void -crash_notify_cb(const char* progname) + +static void Crash(DBusMessage* signal) { - const char *message = _("A crash in package %s has been detected!"); -#ifdef DEBUG - std::cerr << "Application " << progname << " has crashed!" << std::endl; -#endif - //applet->AddEvent(uid, std::string(progname)); + int r; + DBusMessageIter in_iter; + if (!dbus_message_iter_init(signal, &in_iter)) + { + /* signal has no parameters */ + error_msg("dbus signal %s: parameter type mismatch", __func__); + return; + } + const char* progname; + r = load_val(&in_iter, progname); + if (r != ABRT_DBUS_MORE_FIELDS) + { + error_msg("dbus signal %s: parameter type mismatch", __func__); + return; + } + const char* uid_str; + r = load_val(&in_iter, uid_str); + if (r != ABRT_DBUS_LAST_FIELD) + { + error_msg("dbus signal %s: parameter type mismatch", __func__); + return; + } + + //if (m_pSessionDBus->has_name("com.redhat.abrt.gui")) + // return; + uid_t uid_num = atoi(uid_str); + + if (uid_num != getuid()) + return; + + const char* message = _("A crash in package %s has been detected"); + //applet->AddEvent(uid, progname); applet->SetIconTooltip(message, progname); applet->ShowIcon(); applet->CrashNotify(message, progname); } -static void -quota_exceed_cb(const char* str) +static void QuotaExceed(DBusMessage* signal) { + int r; + DBusMessageIter in_iter; + if (!dbus_message_iter_init(signal, &in_iter)) + { + /* signal has no parameters */ + error_msg("dbus signal %s: parameter type mismatch", __func__); + return; + } + const char* str; + r = load_val(&in_iter, str); + if (r != ABRT_DBUS_LAST_FIELD) + { + error_msg("dbus signal %s: parameter type mismatch", __func__); + return; + } + + //if (m_pSessionDBus->has_name("com.redhat.abrt.gui")) + // return; applet->ShowIcon(); applet->CrashNotify("%s", str); } -int main(int argc, char **argv) +static void NameOwnerChanged(DBusMessage* signal) +{ + int r; + DBusMessageIter in_iter; + if (!dbus_message_iter_init(signal, &in_iter)) + { + /* signal has no parameters */ + error_msg("dbus signal %s: parameter type mismatch", __func__); + return; + } + const char* name; + r = load_val(&in_iter, name); + if (r != ABRT_DBUS_MORE_FIELDS) + { + error_msg("dbus signal %s: parameter type mismatch", __func__); + return; + } + + /* We are only interested in (dis)appearances of our daemon */ + if (strcmp(name, "com.redhat.abrt") != 0) + return; + + const char* old_owner; + r = load_val(&in_iter, old_owner); + if (r != ABRT_DBUS_MORE_FIELDS) + { + error_msg("dbus signal %s: parameter type mismatch", __func__); + return; + } + const char* new_owner; + r = load_val(&in_iter, new_owner); + if (r != ABRT_DBUS_LAST_FIELD) + { + error_msg("dbus signal %s: parameter type mismatch", __func__); + return; + } + + if (new_owner[0]) + applet->Enable(_("ABRT service has been started")); + else + applet->Disable(_("ABRT service is not running")); +} + +static DBusHandlerResult handle_message(DBusConnection* conn, DBusMessage* msg, void* user_data) +{ + const char* member = dbus_message_get_member(msg); + log("%s(member:'%s')", __func__, member); + + int type = dbus_message_get_type(msg); + if (type != DBUS_MESSAGE_TYPE_SIGNAL) + { + log("The message is not a signal. ignoring"); + return DBUS_HANDLER_RESULT_HANDLED; + } + + if (strcmp(member, "NameOwnerChanged") == 0) + NameOwnerChanged(msg); + else if (strcmp(member, "Crash") == 0) + Crash(msg); + else if (strcmp(member, "QuotaExceed") == 0) + QuotaExceed(msg); + + return DBUS_HANDLER_RESULT_HANDLED; +} + +//TODO: move to abrt_dbus.cpp +static void die_if_dbus_error(bool error_flag, DBusError* err, const char* msg) { - setlocale(LC_ALL,""); + if (dbus_error_is_set(err)) + { + error_msg("dbus error: %s", err->message); + /*dbus_error_free(&err); - why bother, we will exit in a microsecond */ + error_flag = true; + } + if (!error_flag) + return; + error_msg_and_die("%s", msg); +} +int main(int argc, char** argv) +{ + /* I18n */ + setlocale(LC_ALL, ""); #if ENABLE_NLS bindtextdomain(PACKAGE, LOCALEDIR); textdomain(PACKAGE); #endif - /* need to be thread safe */ + /* Need to be thread safe */ g_thread_init(NULL); gdk_threads_init(); gdk_threads_enter(); - gtk_init(&argc,&argv); - /* prevent zombies when we spawn abrt-gui */ - signal(SIGCHLD, SIG_IGN); - /* move to the DBusClient::connect */ - DBus::Glib::BusDispatcher dispatcher; - /* this should bind the dispatcher with mainloop */ - dispatcher.attach(NULL); - DBus::default_dispatcher = &dispatcher; - DBus::Connection session = DBus::Connection::SessionBus(); - //FIXME: possible race, but the dbus-c++ API won't let us check return value of request_name :( - if(session.has_name("com.redhat.abrt.applet")) + /* Parse options */ + int opt; + while ((opt = getopt(argc, argv, "dv")) != -1) { - //applet is already running - std::cerr << _("Applet is already running.") << std::endl; - return -1; - } - else - { - //applet is not running, so claim the name on the session bus - session.request_name("com.redhat.abrt.applet"); + switch (opt) + { + case 'v': + g_verbose++; + break; + default: + error_msg_and_die( + "Usage: abrt-applet [-v]\n" + "\nOptions:" + "\n\t-v\tVerbose" + ); + } } + gtk_init(&argc, &argv); + + /* Prevent zombies when we spawn abrt-gui */ + signal(SIGCHLD, SIG_IGN); + + /* Initialize our (dbus_abrt) machinery: hook _system_ dbus to glib main loop. + * (session bus is left to be handled by libnotify, see below) */ + DBusError err; + dbus_error_init(&err); + DBusConnection* system_conn = dbus_bus_get(DBUS_BUS_SYSTEM, &err); + die_if_dbus_error(system_conn == NULL, &err, "Can't connect to system dbus"); + attach_dbus_conn_to_glib_main_loop(system_conn); + if (!dbus_connection_add_filter(system_conn, handle_message, NULL, NULL)) + error_msg_and_die("Can't add dbus filter"); + /* which messages do we want to be fed to handle_message()? */ + //signal sender=org.freedesktop.DBus -> path=/org/freedesktop/DBus; interface=org.freedesktop.DBus; member=NameOwnerChanged + // string "com.redhat.abrt" + // string "" + // string ":1.70" + dbus_bus_add_match(system_conn, "type='signal',member='NameOwnerChanged'", &err); + die_if_dbus_error(false, &err, "Can't add dbus match"); + //signal sender=:1.73 -> path=/com/redhat/abrt; interface=com.redhat.abrt; member=Crash + // string "coreutils-7.2-3.fc11" + // string "0" + dbus_bus_add_match(system_conn, "type='signal',path='/com/redhat/abrt'", &err); + die_if_dbus_error(false, &err, "Can't add dbus match"); - DBus::Connection conn = DBus::Connection::SystemBus(); - applet = new CApplet(conn, session, CC_DBUS_PATH, CC_DBUS_NAME); - applet->ConnectCrashHandler(crash_notify_cb); - applet->ConnectQuotaExceedHandler(quota_exceed_cb); - if(!conn.has_name(CC_DBUS_NAME)) + /* Initialize GUI stuff. + * Note: inside CApplet ctor, libnotify hooks session dbus + * to glib main loop */ + applet = new CApplet; + /* dbus_abrt cannot handle more than one bus, and we don't really need to. + * The only thing we want to do is to announce ourself on session dbus */ + DBusConnection* session_conn = dbus_bus_get(DBUS_BUS_SESSION, &err); + die_if_dbus_error(session_conn == NULL, &err, "Can't connect to session dbus"); + int r = dbus_bus_request_name(session_conn, + "com.redhat.abrt.applet", + /* flags */ DBUS_NAME_FLAG_DO_NOT_QUEUE, &err); + die_if_dbus_error(r != DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER, &err, + "Problem connecting to dbus, or applet is already running"); + + /* Show disabled icon if daemon is not running */ + if (!dbus_bus_name_has_owner(system_conn, CC_DBUS_NAME, &err)) { - std::cout << _("ABRT service is not running") << std::endl; - applet->Disable(_("ABRT service is not running")); + const char* msg = _("ABRT service is not running"); + puts(msg); + applet->Disable(msg); } + /* Enter main loop */ gtk_main(); + gdk_threads_leave(); delete applet; return 0; diff --git a/src/Applet/CCApplet.cpp b/src/Applet/CCApplet.cpp index 7b1a7f1b..3bd0dbca 100644 --- a/src/Applet/CCApplet.cpp +++ b/src/Applet/CCApplet.cpp @@ -17,31 +17,23 @@ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ -#include "abrtlib.h" -#include "CCApplet.h" #include <iostream> #include <cstdarg> #include <sstream> #include <cstdio> -#include <unistd.h> - - - #if HAVE_CONFIG_H #include <config.h> #endif - #if ENABLE_NLS #include <libintl.h> #define _(S) gettext(S) #else #define _(S) (S) #endif +#include "abrtlib.h" +#include "CCApplet.h" - -static const char *DBUS_SERVICE_NAME = "org.freedesktop.DBus"; -static const char *DBUS_SERVICE_PATH = "/org/freedesktop/DBus"; const gchar *CApplet::menu_xml = "<?xml version=\"1.0\"?>\ <interface>\ @@ -118,12 +110,8 @@ You should have received a copy of the GNU General Public License along with thi </object>\ </interface>"; -CApplet::CApplet(DBus::Connection &system, DBus::Connection &session, const char *path, const char *name) -: DBus::ObjectProxy(system, path, name) +CApplet::CApplet() { - m_pSessionDBus = &session; - m_pDaemonWatcher = new DaemonWatcher(system, DBUS_SERVICE_PATH, DBUS_SERVICE_NAME); - m_pDaemonWatcher->ConnectStateChangeHandler(DaemonStateChange_cb, this); m_pStatusIcon = gtk_status_icon_new_from_stock(GTK_STOCK_DIALOG_WARNING); m_bDaemonRunning = true; notify_init("ABRT"); @@ -153,87 +141,17 @@ CApplet::CApplet(DBus::Connection &system, DBus::Connection &session, const char m_pAboutDialog = gtk_builder_get_object(m_pBuilder, "aboutdialog"); m_pmiAbout = gtk_builder_get_object(m_pBuilder, "miAbout"); { - g_signal_connect(m_pmiAbout,"activate",G_CALLBACK(CApplet::onAbout_cb),m_pAboutDialog); + g_signal_connect(m_pmiAbout, "activate", G_CALLBACK(CApplet::onAbout_cb),m_pAboutDialog); } } else { - fprintf(stderr,_("Can't create menu from the description, popup won't be available!\n")); + fprintf(stderr, _("Can't create menu from the description, popup won't be available!\n")); } } CApplet::~CApplet() { - delete m_pDaemonWatcher; -} - -/* dbus related */ -void CApplet::Crash(const std::string& progname, const std::string& uid ) -{ - if (m_pSessionDBus->has_name("com.redhat.abrt.gui")) - { - return; - } - else - { - if (m_pCrashHandler) - { - std::istringstream input_string(uid); - uid_t num; - input_string >> num; - - if (num == getuid()) - m_pCrashHandler(progname.c_str()); - } - else - { - std::cout << _("This is default handler, you should register your own with ConnectCrashHandler") << std::endl; - std::cout.flush(); - } - } -} - -void CApplet::QuotaExceed(const char* str) -{ - if (m_pSessionDBus->has_name("com.redhat.abrt.gui")) - { - return; - } - else - { - if(m_pQuotaExceedHandler) - { - m_pQuotaExceedHandler(str); - } - else - { - std::cout << _("This is default handler, you should register your own with ConnectQuotaExceedHandler") << std::endl; - std::cout.flush(); - } - } -} - -void CApplet::DaemonStateChange_cb(bool running, void* data) -{ - CApplet *applet = (CApplet *)data; - if (!running) - { - applet->Disable(_("ABRT service is not running")); - } - else - { - applet->Enable(_("ABRT service has been started")); - } -} - -void CApplet::ConnectCrashHandler(void (*pCrashHandler)(const char *progname)) -{ - m_pCrashHandler = pCrashHandler; -} - -void CApplet::ConnectQuotaExceedHandler(void (*pQuotaExceedHandler)(const char *progname)) -{ - m_pQuotaExceedHandler = pQuotaExceedHandler; } void CApplet::SetIconTooltip(const char *format, ...) @@ -251,10 +169,8 @@ void CApplet::SetIconTooltip(const char *format, ...) gtk_status_icon_set_tooltip_text(m_pStatusIcon, buf); free(buf); } - else - { - gtk_status_icon_set_tooltip_text(m_pStatusIcon, _("Out of memory")); - } + /* else: out of memory. Let's not do anything, + * or else it may only get worse */ } void CApplet::CrashNotify(const char *format, ...) @@ -270,7 +186,7 @@ void CApplet::CrashNotify(const char *format, ...) va_end(args); notify_notification_update(m_pNotification, _("Warning"), buf, NULL); - if (gtk_status_icon_is_embedded (m_pStatusIcon)) + if (gtk_status_icon_is_embedded(m_pStatusIcon)) notify_notification_show(m_pNotification, &err); if (err != NULL) g_print(err->message); @@ -313,7 +229,7 @@ void CApplet::ShowIcon() { gtk_status_icon_set_visible(m_pStatusIcon, true); //Active wait for icon to be REALLY visible in status area - //while(!gtk_status_icon_is_embedded (m_pStatusIcon)); + //while(!gtk_status_icon_is_embedded(m_pStatusIcon)) continue; } void CApplet::onHide_cb(GtkMenuItem *menuitem, gpointer applet) diff --git a/src/Applet/CCApplet.h b/src/Applet/CCApplet.h index 6c020e16..285511aa 100644 --- a/src/Applet/CCApplet.h +++ b/src/Applet/CCApplet.h @@ -23,13 +23,9 @@ #include <gtk/gtk.h> #include <map> #include <string> -#include <DBusClientProxy.h> #include <libnotify/notify.h> class CApplet -: public CDBusClient_proxy, - public DBus::IntrospectableProxy, - public DBus::ObjectProxy { private: static const gchar *menu_xml; @@ -44,11 +40,10 @@ class CApplet NotifyNotification *m_pNotification; std::map<int, std::string> m_mapEvents; - DaemonWatcher *m_pDaemonWatcher; bool m_bDaemonRunning; - DBus::Connection *m_pSessionDBus; + public: - CApplet(DBus::Connection &system, DBus::Connection &session, const char *path, const char *name); + CApplet(); ~CApplet(); void ShowIcon(); void HideIcon(); @@ -64,9 +59,6 @@ class CApplet // map:: int AddEvent(int pUUID, const std::string& pProgname); int RemoveEvent(int pUUID); - void ConnectCrashHandler(void (*pCrashHandler)(const char *progname)); - void ConnectQuotaExceedHandler(void (*pQuotaExeedHandler)(const char *str)); - static void DaemonStateChange_cb(bool running, void* data); protected: //@@TODO applet menus @@ -77,14 +69,6 @@ class CApplet gpointer user_data); static void onHide_cb(GtkMenuItem *menuitem, gpointer applet); static void onAbout_cb(GtkMenuItem *menuitem, gpointer applet); - private: - /* dbus stuff */ - void Crash(const std::string& progname, const std::string& uid); - void QuotaExceed(const char* str); - - /* the real signal handler called to handle the signal */ - void (*m_pCrashHandler)(const char *progname); - void (*m_pQuotaExceedHandler)(const char *str); }; -#endif /*CC_APPLET_H_*/ +#endif diff --git a/src/Applet/DBusClientProxy.cpp b/src/Applet/DBusClientProxy.cpp deleted file mode 100644 index afa89fc4..00000000 --- a/src/Applet/DBusClientProxy.cpp +++ /dev/null @@ -1,252 +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 "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); - connect_signal(CDBusClient_proxy, QuotaExceed, _QuotaExceed_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); - connect_signal(CDBusClient_proxy, QuotaExceed, _QuotaExceed_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(const 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(const std::string& progname, const std::string& uid) -{ -} - -void CDBusClient_proxy::QuotaExceed(const char* str) -{ -} -/* 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 progname; ri >> progname; - std::string uid; ri >> uid; - Crash(progname, uid); -} - -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); - } -} - -void CDBusClient_proxy::_QuotaExceed_stub(const ::DBus::SignalMessage &sig) -{ - DBus::MessageIter ri = sig.reader(); - std::string str; - ri >> str; - QuotaExceed(str.c_str()); -} diff --git a/src/Applet/DBusClientProxy.h b/src/Applet/DBusClientProxy.h deleted file mode 100644 index 8cf51551..00000000 --- a/src/Applet/DBusClientProxy.h +++ /dev/null @@ -1,109 +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 DBUSCLIENTPROXY_H_ -#define DBUSCLIENTPROXY_H_ - -#include <dbus-c++/dbus.h> -#include <dbus-c++/glib-integration.h> -#include "DBusCommon.h" - -#define ABRT_NOT_RUNNING 0 -#define ABRT_RUNNING 1 - -namespace org { -namespace freedesktop { -namespace DBus { - -class DaemonWatcher_proxy -: public ::DBus::InterfaceProxy -{ -private: - void *m_pStateChangeHandler_cb_data; - void (*m_pStateChangeHandler)(bool running, void* data); - -public: - DaemonWatcher_proxy(); - void ConnectStateChangeHandler(void (*pStateChangeHandler)(bool running, void* data), void *cb_data); - -private: - /* unmarshalers (to unpack the DBus message before calling the actual signal handler) - */ - void _DaemonStateChanged(const ::DBus::SignalMessage &sig); -}; - -} } } - - -class DaemonWatcher -: public org::freedesktop::DBus::DaemonWatcher_proxy, - public DBus::IntrospectableProxy, - public DBus::ObjectProxy -{ -public: - - DaemonWatcher(DBus::Connection &connection, const char *path, const char *name); - ~DaemonWatcher(); -}; - - -class CDBusClient_proxy -: public DBus::InterfaceProxy -{ -private: - bool m_bJobDone; - uint64_t m_iPendingJobID; - GMainLoop *gloop; - std::string m_sConnName; - -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(); - bool DeleteDebugDump(const std::string& pUUID); - map_crash_report_t CreateReport(const std::string& pUUID); - void Report(const map_crash_report_t& pReport); - map_crash_report_t GetJobResult(uint64_t pJobID); - -public: - /* signal handlers for this interface - */ - virtual void Crash(const std::string& progname, const std::string& uid); - virtual void QuotaExceed(const char* str); -private: - /* unmarshalers (to unpack the DBus message before calling the actual signal handler) - */ - void _Crash_stub(const ::DBus::SignalMessage &sig); - void _JobDone_stub(const ::DBus::SignalMessage &sig); - void _QuotaExceed_stub(const ::DBus::SignalMessage &sig); -}; - -#endif diff --git a/src/Applet/Makefile.am b/src/Applet/Makefile.am index 67c17766..d0980440 100644 --- a/src/Applet/Makefile.am +++ b/src/Applet/Makefile.am @@ -2,8 +2,7 @@ bin_PROGRAMS = abrt-applet abrt_applet_SOURCES = \ Applet.cpp \ - CCApplet.h CCApplet.cpp \ - DBusClientProxy.h DBusClientProxy.cpp + CCApplet.h CCApplet.cpp abrt_applet_CPPFLAGS = \ -Wall -Werror \ -I$(srcdir)/../../inc \ @@ -17,15 +16,15 @@ abrt_applet_CPPFLAGS = \ -DPLUGINS_LIB_DIR=\"$(PLUGINS_LIB_DIR)\" \ -DPLUGINS_CONF_DIR=\"$(PLUGINS_CONF_DIR)\" \ $(GTK_CFLAGS) \ - $(DBUSCPP_CFLAGS) \ + $(DBUS_CFLAGS) \ -D_GNU_SOURCE # $(LIBNOTIFY_CFLAGS) -# $(DBUS_CFLAGS) # $(DBUS_GLIB_CFLAGS) abrt_applet_LDADD = \ + ../../lib/Utils/libABRTUtils.la \ -lglib-2.0 \ -lgthread-2.0 \ - $(DBUSCPP_LIBS) \ + $(DBUS_LIBS) \ $(LIBNOTIFY_LIBS) # ../../lib/Utils/libABRTUtils.la # $(DL_LIBS) |