From 0499ff730d61ac8e2991a8089ebc96dd10f95e43 Mon Sep 17 00:00:00 2001 From: David Zeuthen Date: Sat, 24 Mar 2007 13:59:13 -0400 Subject: 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. --- examples/mandatory-locking-test.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100755 examples/mandatory-locking-test.py (limited to 'examples') 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) -- cgit v1.2.3