diff options
author | Santiago Collazo <scollazo@activitycentral.com> | 2013-03-13 10:40:11 (GMT) |
---|---|---|
committer | Santiago Collazo <scollazo@activitycentral.com> | 2013-03-13 10:40:11 (GMT) |
commit | 87d55a069c93a2553b10bf742f379b404027afe4 (patch) | |
tree | 29783d4182b5aee160f0f9e30a1797beb24117bb | |
parent | 609d1e191b755a5d81a60bfca5eb760ae5e442d0 (diff) | |
parent | c604372047af85164833a6b754534ba42c3a6893 (diff) |
Merge remote-tracking branch 'ajay/0.97.7-as-base' into devel
-rw-r--r-- | src/sugar3/activity/activity.py | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/src/sugar3/activity/activity.py b/src/sugar3/activity/activity.py index b97f9b3..5541b4f 100644 --- a/src/sugar3/activity/activity.py +++ b/src/sugar3/activity/activity.py @@ -94,6 +94,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' gconf_client = GConf.Client.get_default() @@ -791,6 +793,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) @@ -800,6 +814,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) @@ -828,6 +844,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) @@ -942,6 +960,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): |