bigboard r7328 - trunk/bigboard



Author: otaylor
Date: Tue May  6 21:29:01 2008
New Revision: 7328
URL: http://svn.gnome.org/viewvc/bigboard?rev=7328&view=rev

Log:
If install_application() is called before we finish registering
 our endpoint with the desktop data engine, wait until we are
 registered before actually calling InstallApplication() on the
 proxy.


Modified:
   trunk/bigboard/global_mugshot.py

Modified: trunk/bigboard/global_mugshot.py
==============================================================================
--- trunk/bigboard/global_mugshot.py	(original)
+++ trunk/bigboard/global_mugshot.py	Tue May  6 21:29:01 2008
@@ -28,6 +28,8 @@
         self._logger.debug("connecting to session bus")            
         session_bus = dbus.SessionBus()
         bus_proxy = session_bus.get_object('org.freedesktop.DBus', '/org/freedesktop/DBus')
+        self.__registration_pending = False
+        self.__on_registration = []
         self.__bus_proxy = bus_proxy.connect_to_signal("NameOwnerChanged",
                                                        self.__on_dbus_name_owner_changed)
         self.__create_proxy()
@@ -46,6 +48,7 @@
              bus = dbus.SessionBus()
              self._logger.debug("creating proxy for %s" % globals.bus_name)
              self.__mugshot_dbus_proxy = bus.get_object(globals.bus_name, '/com/dumbhippo/client')
+             self.__registration_pending = True
              self.__mugshot_dbus_proxy.RegisterEndpoint(reply_handler=self.__on_register_endpoint, error_handler=self.__on_dbus_error)
             
          except dbus.DBusException, e:
@@ -72,17 +75,32 @@
     @log_except(_logger)
     def __on_register_endpoint(self, id):
         self.__endpoint_id = id
+        self.__registration_pending = False
+        handlers = self.__on_registration
+        self.__on_registration = []
+        for f in handlers:
+            f()
 
     @log_except(_logger)
     def __on_dbus_error(self, err):
         # TODO - could schedule a "reboot" of this class here to reload
         # information
         self._logger.error("D-BUS error: %s", err)
-    
+        self.__registration_pending = False
+        self.__on_registration = []
+
     def install_application(self, id, package_names, desktop_names):
         self._logger.debug("requesting install of app id %s", id)
-        self.__mugshot_dbus_proxy.InstallApplication(self.__endpoint_id, id, package_names, desktop_names)
 
+        def install_it():
+            self.__mugshot_dbus_proxy.InstallApplication(self.__endpoint_id, id, package_names, desktop_names)
+            
+        if self.__endpoint_id != None:
+            install_it()
+        elif self.__registration_pending:
+            self.__on_registration.append(install_it)
+        else:
+            self._logger.warn("Not connected to desktop data engine: can't install package")
 
 mugshot_inst = None
 def get_mugshot():



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