[nanny] Dbus client class now is tolerant to daemon restarts



commit 0d9170cdd184c0a360df4c8abfb29b1efe9511a8
Author: Roberto Majadas <roberto majadas openshine com>
Date:   Fri Mar 5 11:16:38 2010 +0100

    Dbus client class now is tolerant to daemon restarts

 client/common/src/DBusClient.py |   20 ++++++++++++++++++++
 1 files changed, 20 insertions(+), 0 deletions(-)
---
diff --git a/client/common/src/DBusClient.py b/client/common/src/DBusClient.py
index 2cdb6c2..e11ca90 100644
--- a/client/common/src/DBusClient.py
+++ b/client/common/src/DBusClient.py
@@ -98,10 +98,30 @@ class DBusClient(gobject.GObject):
 
             self.nanny_notification.connect_to_signal ('UserNotification', self.__on_user_notification_cb)
 
+            self.dbus.watch_name_owner(NANNY_URI, self.__name_owner_changed_cb)
+
             return True
         except:
             return False
 
+    def __name_owner_changed_cb(self, owner):
+        if owner == None or owner == "" :
+            print "Nanny is not in the house !"
+        else:
+            print "Reconnecting to new nanny server instance"
+            self.nanny_obj = self.dbus.get_object (NANNY_URI,
+                                                   NANNY_PATH)
+            self.nanny_admin = dbus.Interface(self.nanny_obj,
+                                              NANNY_URI)
+            self.nanny_wcf = dbus.Interface(self.nanny_obj,
+                                              NANNY_WCF)
+
+            self.nanny_notification = dbus.Interface(self.nanny_obj,
+                                              NANNY_NOTIFICATION_URI)
+
+            self.nanny_notification.connect_to_signal ('UserNotification', self.__on_user_notification_cb)
+
+
     def list_users(self):
         return self.nanny_admin.ListUsers ()
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]