summaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorDavid Zeuthen <davidz@redhat.com>2007-03-24 13:59:13 -0400
committerDavid Zeuthen <davidz@redhat.com>2007-03-24 13:59:13 -0400
commit0499ff730d61ac8e2991a8089ebc96dd10f95e43 (patch)
tree0db435a0731ba74124f6700b34f8d3c6a966d8a4 /examples
parentda2f627fa4683728346df492b302697406bc9ac8 (diff)
add named mandatory locking API
This provides a mechanism for clients to acquire (and release) named locks on device objects. More than one client can hold a named lock on a device, this is by design. If a client disconnects from the bus, it locks will be removed. The rationale for this new API is to allow clients to lock out other clients of service on given device objects; this is applicable for - installers (inhibit mount requests) - partitioning/formatting tools (inhibit mount requests) - multi-seat power management (inhibit suspend/hibernate etc. requests from idle (e.g. the user is idle) active (e.g. it is in the foreground on some seat) sessions that wants to suspend due to user preferences.) The next series of patches will make the various mechanisms use this API by defining well-known locks.
Diffstat (limited to 'examples')
-rwxr-xr-xexamples/mandatory-locking-test.py20
1 files changed, 20 insertions, 0 deletions
diff --git a/examples/mandatory-locking-test.py b/examples/mandatory-locking-test.py
new file mode 100755
index 00000000..d863814f
--- /dev/null
+++ b/examples/mandatory-locking-test.py
@@ -0,0 +1,20 @@
+#!/usr/bin/python
+
+
+import dbus
+import sys
+import time
+import os
+
+bus = dbus.Bus(dbus.Bus.TYPE_SYSTEM)
+device = dbus.Interface(bus.get_object("org.freedesktop.Hal",
+ "/org/freedesktop/Hal/devices/computer"),
+# "/org/freedesktop/Hal/devices/volume_label_EOS_DIGITAL"),
+ "org.freedesktop.Hal.Device")
+
+device.AcquireMandatoryLock("foo")
+device.AcquireMandatoryLock("foo2")
+time.sleep(2)
+device.ReleaseMandatoryLock("foo2")
+#device.ReleaseMandatoryLock("foo")
+time.sleep(2)