From 50ddf71f4070e004214bdef185521f76789ae624 Mon Sep 17 00:00:00 2001 From: Ajay Garg Date: Wed, 13 Mar 2013 10:10:01 +0000 Subject: sdxo#3218: Integrating the missing patch. Signed-off-by: Ajay Garg --- diff --git a/src/sugar/activity/activity.py b/src/sugar/activity/activity.py index 87f53c7..53c2aa3 100644 --- a/src/sugar/activity/activity.py +++ b/src/sugar/activity/activity.py @@ -97,6 +97,8 @@ J_DBUS_SERVICE = 'org.laptop.Journal' J_DBUS_PATH = '/org/laptop/Journal' J_DBUS_INTERFACE = 'org.laptop.Journal' +POWERD_INHIBIT_DIR = '/var/run/powerd-inhibit-suspend' + CONN_INTERFACE_ACTIVITY_PROPERTIES = 'org.laptop.Telepathy.ActivityProperties' @@ -754,6 +756,18 @@ class Activity(Window, gtk.Container): else: self._jobject.metadata['share-scope'] = SCOPE_NEIGHBORHOOD + def _inhibit_suspend(self): + if not os.path.exists(POWERD_INHIBIT_DIR): + return + + path = os.path.join(POWERD_INHIBIT_DIR, str(os.getpid())) + try: + fd = open(path, 'w') + except IOError: + logging.error("Inhibit Suspend: Could not create file %s", path) + else: + fd.close() + def __joined_cb(self, activity, success, err): """Callback when join has finished""" logging.debug('Activity.__joined_cb %r', success) @@ -763,6 +777,8 @@ class Activity(Window, gtk.Container): logging.debug('Failed to join activity: %s', err) return + self._inhibit_suspend() + self.reveal() self.emit('joined') self.__privacy_changed_cb(self.shared_activity, None) @@ -791,6 +807,8 @@ class Activity(Window, gtk.Container): activity.props.name = self._jobject.metadata['title'] + self._inhibit_suspend() + self.shared_activity = activity self.shared_activity.connect('notify::private', self.__privacy_changed_cb) @@ -905,6 +923,11 @@ class Activity(Window, gtk.Container): # Make the exported object inaccessible dbus.service.Object.remove_from_connection(self._bus) + if os.path.exists(POWERD_INHIBIT_DIR): + path = os.path.join(POWERD_INHIBIT_DIR, str(os.getpid())) + if os.path.exists(path): + os.unlink(path) + self._session.unregister(self) def close(self, skip_save=False): -- cgit v0.9.1