diff options
author | Jiri Moskovcak <jmoskovc@redhat.com> | 2009-06-16 13:09:16 +0200 |
---|---|---|
committer | Jiri Moskovcak <jmoskovc@redhat.com> | 2009-06-16 13:09:16 +0200 |
commit | 9e12ec978211369530186fc72aa862b1f40243ef (patch) | |
tree | 434d8adce4b8061b0aab12972dc23a7499f02e35 /src/Applet/Applet.cpp | |
parent | 721faaf700483202c31fa6529888f948d86676d4 (diff) | |
download | abrt-9e12ec978211369530186fc72aa862b1f40243ef.tar.gz abrt-9e12ec978211369530186fc72aa862b1f40243ef.tar.xz abrt-9e12ec978211369530186fc72aa862b1f40243ef.zip |
Allow only one instance of applet
Diffstat (limited to 'src/Applet/Applet.cpp')
-rw-r--r-- | src/Applet/Applet.cpp | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/src/Applet/Applet.cpp b/src/Applet/Applet.cpp index 0f957ceb..b3ea05b9 100644 --- a/src/Applet/Applet.cpp +++ b/src/Applet/Applet.cpp @@ -19,9 +19,11 @@ #include "CCApplet.h" #include <iostream> +#include <dbus/dbus-shared.h> //@@global applet object CApplet *applet; + static void crash_notify_cb(const char* progname) { @@ -45,12 +47,26 @@ int main(int argc, char **argv) /* 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")) + { + //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"); + } + DBus::Connection conn = DBus::Connection::SystemBus(); //CDBusClient client(conn, CC_DBUS_PATH, CC_DBUS_NAME); applet = new CApplet(conn, CC_DBUS_PATH, CC_DBUS_NAME); applet->ConnectCrashHandler(crash_notify_cb); gtk_main(); + gtk_main(); gdk_threads_leave(); return 0; } |