summaryrefslogtreecommitdiffstats
path: root/src/Gui
diff options
context:
space:
mode:
authorJiri Moskovcak <jmoskovc@redhat.com>2009-07-28 15:23:42 +0200
committerJiri Moskovcak <jmoskovc@redhat.com>2009-07-28 15:23:42 +0200
commitc91bb0a0e321ed5eae01ae3e649895e7d57726eb (patch)
treec61673a9452eea0282e398390d30496cb2c8cfe8 /src/Gui
parent88a9c7fdaee695f15a9aeaaef177c0318896dc6a (diff)
downloadabrt-c91bb0a0e321ed5eae01ae3e649895e7d57726eb.tar.gz
abrt-c91bb0a0e321ed5eae01ae3e649895e7d57726eb.tar.xz
abrt-c91bb0a0e321ed5eae01ae3e649895e7d57726eb.zip
GUI: Added detection whether daemon is running (gui disables itself)
Diffstat (limited to 'src/Gui')
-rw-r--r--src/Gui/CCDBusBackend.py70
-rw-r--r--src/Gui/CCMainWindow.py7
2 files changed, 48 insertions, 29 deletions
diff --git a/src/Gui/CCDBusBackend.py b/src/Gui/CCDBusBackend.py
index d7801ee1..cac0ec52 100644
--- a/src/Gui/CCDBusBackend.py
+++ b/src/Gui/CCDBusBackend.py
@@ -18,6 +18,7 @@ APP_IFACE = 'com.redhat.abrt.gui'
class DBusManager(gobject.GObject):
""" Class to provide communication with daemon over dbus """
# and later with policyKit
+ bus = None
uniq_name = None
pending_jobs = []
def __init__(self):
@@ -68,29 +69,15 @@ class DBusManager(gobject.GObject):
gobject.signal_new ("update", self ,gobject.SIGNAL_RUN_FIRST,gobject.TYPE_NONE,(gobject.TYPE_PYOBJECT,))
# signal emited to show gui if user try to run it again
gobject.signal_new ("show", self ,gobject.SIGNAL_RUN_FIRST,gobject.TYPE_NONE,())
+ # signal emited to show gui if user try to run it again
+ gobject.signal_new ("daemon-state-changed", self ,gobject.SIGNAL_RUN_FIRST,gobject.TYPE_NONE,(gobject.TYPE_PYOBJECT,))
# export the app dbus interface
if session:
session.request_name(APP_NAME)
- iface = DBusInterface(self)
-
- self.proxy = None
- self.proxy = self.connect_to_daemon()
- if self.proxy:
- self.cc = dbus.Interface(self.proxy, dbus_interface=CC_IFACE)
- #intr = dbus.Interface(proxy, dbus_interface='org.freedesktop.DBus.Introspectable')
- # new crash notify
- self.proxy.connect_to_signal("Crash",self.crash_cb,dbus_interface=CC_IFACE)
- # BT extracting complete
- self.acconnection = self.proxy.connect_to_signal("AnalyzeComplete",self.analyze_complete_cb,dbus_interface=CC_IFACE)
- # Catch Errors
- self.acconnection = self.proxy.connect_to_signal("Error",self.error_handler_cb,dbus_interface=CC_IFACE)
- # watch for updates
- self.acconnection = self.proxy.connect_to_signal("Update",self.update_cb,dbus_interface=CC_IFACE)
- # watch for job-done signals
- self.acconnection = self.proxy.connect_to_signal("JobDone",self.jobdone_cb,dbus_interface=CC_IFACE)
- else:
- raise Exception("Please check if abrt daemon is running.")
+ iface = DBusInterface(self)
+
+ self.connect_to_daemon()
# disconnect callback
def disconnected(*args):
@@ -127,18 +114,43 @@ class DBusManager(gobject.GObject):
# FIXME - rewrite with CCReport class
# self.emit("analyze-complete", dump)
pass
-
+
+ def owner_changed_cb(self,name, old_owner, new_owner):
+ if(name == CC_NAME and new_owner):
+ self.proxy = self.connect_to_daemon()
+ self.emit("daemon-state-changed", "up")
+ if(name == CC_NAME and not(new_owner)):
+ self.proxy = None
+ self.emit("daemon-state-changed", "down")
+
+
def connect_to_daemon(self):
- bus = dbus.SystemBus()
- self.uniq_name = bus.get_unique_name()
- if not bus:
+ if not self.bus:
+ self.bus = dbus.SystemBus()
+ self.bus.add_signal_receiver(self.owner_changed_cb,"NameOwnerChanged", dbus_interface="org.freedesktop.DBus")
+ #self.uniq_name = bus.get_unique_name()
+ if not self.bus:
raise Exception("Can't connect to dbus")
- try:
- if bus.name_has_owner(CC_NAME):
- return bus.get_object(CC_IFACE, CC_PATH)
- return None
- except Exception, e:
- raise Exception(e.message + "\nCannot create a proxy object!")
+ if self.bus.name_has_owner(CC_NAME):
+ self.proxy = self.bus.get_object(CC_IFACE, CC_PATH)
+ else:
+ raise Exception("Please check if abrt daemon is running.")
+
+ if self.proxy:
+ self.cc = dbus.Interface(self.proxy, dbus_interface=CC_IFACE)
+ #intr = dbus.Interface(proxy, dbus_interface='org.freedesktop.DBus.Introspectable')
+ # new crash notify
+ self.proxy.connect_to_signal("Crash",self.crash_cb,dbus_interface=CC_IFACE)
+ # BT extracting complete
+ self.acconnection = self.proxy.connect_to_signal("AnalyzeComplete",self.analyze_complete_cb,dbus_interface=CC_IFACE)
+ # Catch Errors
+ self.acconnection = self.proxy.connect_to_signal("Error",self.error_handler_cb,dbus_interface=CC_IFACE)
+ # watch for updates
+ self.acconnection = self.proxy.connect_to_signal("Update",self.update_cb,dbus_interface=CC_IFACE)
+ # watch for job-done signals
+ self.acconnection = self.proxy.connect_to_signal("JobDone",self.jobdone_cb,dbus_interface=CC_IFACE)
+ else:
+ raise Exception("Please check if abrt daemon is running.")
def addJob(self, job_id):
self.pending_jobs.append(job_id)
diff --git a/src/Gui/CCMainWindow.py b/src/Gui/CCMainWindow.py
index fa01882c..9d9ff4d9 100644
--- a/src/Gui/CCMainWindow.py
+++ b/src/Gui/CCMainWindow.py
@@ -106,9 +106,16 @@ class MainWindow():
self.ccdaemon.connect("error", self.error_cb)
self.ccdaemon.connect("update", self.update_cb)
self.ccdaemon.connect("show", self.show_cb)
+ self.ccdaemon.connect("daemon-state-changed", self.on_daemon_state_changed_cb)
# load data
#self.load()
+ def on_daemon_state_changed_cb(self, widget, state):
+ if state == "up":
+ self.hydrate()
+ self.window.set_sensitive(True)
+ elif state == "down":
+ self.window.set_sensitive(False)
def on_miAbout_clicked(self, widget):
dialog = self.wTree.get_widget("about")