1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
|
From 74a60d1485781b2c9219c1ed8ac0c21f277748d6 Mon Sep 17 00:00:00 2001
From: Anish Mangal <anish@activitycentral.com>
Date: Mon, 6 Feb 2012 13:25:44 -0200
Subject: [PATCH 33/33] olpc#10363: Inhitbit suspend when sharing, joining and
inviting (private share)
Organization: Sugar Labs Foundation
In dextrose, and as the bug history of olpc#10363 and au#1049 suggests,
power management kicking in doesnt work well with activities that are
collaborating.
This patch inhibits the ability to suspend when sharing, joining and
inviting to a private share.
Signed-off-by: Anish Mangal <anish@activitycentral.com>
---
src/sugar/activity/activity.py | 22 ++++++++++++++++++++++
1 files changed, 22 insertions(+), 0 deletions(-)
diff --git a/src/sugar/activity/activity.py b/src/sugar/activity/activity.py
index 4938caf..bfdc747 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'
@@ -713,6 +715,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)
@@ -722,6 +736,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)
@@ -750,6 +766,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)
@@ -866,6 +884,10 @@ class Activity(Window, gtk.Container):
self._session.unregister(self)
+ if os.path.exists(POWERD_INHIBIT_DIR):
+ path = os.path.join(POWERD_INHIBIT_DIR, str(os.getpid()))
+ os.unlink(path)
+
def close(self, skip_save=False):
"""Request that the activity be stopped and saved to the Journal
--
1.7.4.4
|