hal: Branch 'master'

Holger Macht homac at kemper.freedesktop.org
Thu Feb 7 09:53:50 PST 2008


 doc/spec/hal-spec-interfaces.xml         |   36 +++++++++++++++++++++++++++++++
 fdi/policy/10osvendor/10-dockstation.fdi |   13 +++++++++++
 fdi/policy/10osvendor/Makefile.am        |    3 +-
 hald/linux/device.c                      |   24 ++++++++++++++++++++
 policy/hal-dockstation.policy            |   18 +++++++++++++++
 tools/Makefile.am                        |    1 
 tools/hal-dockstation-undock             |    6 +++++
 tools/linux/Makefile.am                  |    1 
 tools/linux/hal-dockstation-undock-linux |   11 +++++++++
 9 files changed, 112 insertions(+), 1 deletion(-)

New commits:
commit 3831b5b4076d0a1dcfa7bfec5e67b6e727d69c92
Author: Holger Macht <holger at homac.de>
Date:   Thu Feb 7 18:54:17 2008 +0100

    new interface org.freedesktop.Hal.Device.DockStation
    
    Change the platform_add method to an add 'info.docked' property to all
    dock devices. Also add a platform_refresh method to update the status.
    
    New interface org.freedesktop.Hal.Device.DockStation interface with method
    'Undock' and add corresponding script hal-dockstation-undock(-linux).
    
    Update the specification for the interface
    org.freedesktop.Hal.Device.Dockstation with method 'Undock'.
    
    Add hal-dockstation.policy file with privilege
    org.freedesktop.hal.dockstation.undock

diff --git a/doc/spec/hal-spec-interfaces.xml b/doc/spec/hal-spec-interfaces.xml
index ab1308b..e8f2a08 100644
--- a/doc/spec/hal-spec-interfaces.xml
+++ b/doc/spec/hal-spec-interfaces.xml
@@ -933,6 +933,42 @@ $ dbus-send --system --print-reply --dest=org.freedesktop.Hal \
     </para>
   </sect1>
 
+  <sect1 id="interface-dockstation">
+    <title>org.freedesktop.Hal.Device.DockStation interface</title>
+    <para>
+      This interface provides a mechanism to deal with dock stations.
+    </para>
+
+    <informaltable>
+      <tgroup cols="2">
+        <thead>
+          <row>
+            <entry>Method</entry>
+            <entry>Returns</entry>
+            <entry>Parameters</entry>
+            <entry>Throws</entry>
+            <entry>Description</entry>
+          </row>
+        </thead>
+        <tbody>
+          <row>
+            <entry>Undock</entry>
+            <entry>Int</entry>
+            <entry>Void</entry>
+            <entry>DockStation.NotDocked</entry>
+            <entry>
+	      Undock the system from a dock station
+            </entry>
+          </row>
+        </tbody>
+      </tgroup>
+    </informaltable>
+
+    <para>
+      This interface does not emit any signals.
+    </para>
+  </sect1>
+
   <sect1 id="interface-device-laptop-panel">
     <title>org.freedesktop.Hal.Device.LaptopPanel interface</title>
     <para>
diff --git a/fdi/policy/10osvendor/10-dockstation.fdi b/fdi/policy/10osvendor/10-dockstation.fdi
new file mode 100644
index 0000000..eb4d4ed
--- /dev/null
+++ b/fdi/policy/10osvendor/10-dockstation.fdi
@@ -0,0 +1,13 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<deviceinfo version="0.2">
+ <device>
+  <match key="info.udi" contains="/org/freedesktop/Hal/devices/platform_dock_">
+   <append key="info.interfaces" type="strlist">org.freedesktop.Hal.Device.DockStation</append>
+      <append key="org.freedesktop.Hal.Device.DockStation.method_names" type="strlist">Undock</append>
+      <append key="org.freedesktop.Hal.Device.DockStation.method_signatures" type="strlist"></append>
+      <append key="org.freedesktop.Hal.Device.DockStation.method_argnames" type="strlist"></append>
+      <append key="org.freedesktop.Hal.Device.DockStation.method_execpaths" type="strlist">hal-dockstation-undock</append>
+    </match>
+  </device>
+</deviceinfo>
diff --git a/fdi/policy/10osvendor/Makefile.am b/fdi/policy/10osvendor/Makefile.am
index 5c05347..f9c7579 100644
--- a/fdi/policy/10osvendor/Makefile.am
+++ b/fdi/policy/10osvendor/Makefile.am
@@ -9,7 +9,8 @@ dist_fdi_DATA = 			\
 	10-laptop-panel-mgmt-policy.fdi	\
 	15-storage-luks.fdi		\
 	20-storage-methods.fdi		\
-	30-wol.fdi
+	30-wol.fdi			\
+	10-dockstation.fdi
 
 if BUILD_KEYMAPS
 dist_fdi_DATA += 10-keymap.fdi
diff --git a/hald/linux/device.c b/hald/linux/device.c
index 007b759..43629f7 100644
--- a/hald/linux/device.c
+++ b/hald/linux/device.c
@@ -1978,6 +1978,13 @@ platform_add (const gchar *sysfs_path, const gchar *device_file, HalDevice *pare
 	g_snprintf (buf, sizeof (buf), "Platform Device (%s)", hal_device_property_get_string (d, "platform.id"));
 	hal_device_property_set_string (d, "info.product", buf);
 
+	if (strncmp (dev_id, "dock", 4) == 0) {
+		int docked;
+
+		hal_util_get_int_from_file (sysfs_path, "docked", &docked, 0);
+		hal_device_property_set_bool (d, "info.docked", docked);
+	}
+
 	return d;
 }
 
@@ -1993,7 +2000,23 @@ platform_compute_udi (HalDevice *d)
 	hal_device_property_set_string (d, "info.udi", udi);
 
 	return TRUE;
+}
+
+static gboolean
+platform_refresh (HalDevice *d)
+{
+	const gchar *id, *sysfs_path;
+	int docked;
+
+	id = hal_device_property_get_string (d, "platform.id");
+	if (strncmp (id, "dock", 4) != 0)
+		return TRUE;
 
+	sysfs_path = hal_device_property_get_string(d, "linux.sysfs_path");
+	hal_util_get_int_from_file (sysfs_path, "docked", &docked, 0);
+	hal_device_property_set_bool (d, "info.docked", docked);
+
+	return TRUE;
 }
 
 /*--------------------------------------------------------------------------------------------------------------*/
@@ -3665,6 +3688,7 @@ static DevHandler dev_handler_pnp = {
 static DevHandler dev_handler_platform = {
 	.subsystem   = "platform",
 	.add         = platform_add,
+	.refresh     = platform_refresh,
 	.compute_udi = platform_compute_udi,
 	.remove      = dev_remove
 };
diff --git a/policy/hal-dockstation.policy b/policy/hal-dockstation.policy
new file mode 100644
index 0000000..7d5add7
--- /dev/null
+++ b/policy/hal-dockstation.policy
@@ -0,0 +1,18 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE policyconfig PUBLIC
+ "-//freedesktop//DTD PolicyKit Policy Configuration 1.0//EN"
+ "http://www.freedesktop.org/standards/PolicyKit/1.0/policyconfig.dtd">
+
+<policyconfig>
+
+ <action id="org.freedesktop.hal.dockstation.undock">
+    <description>Undock a docking station</description>
+    <message>System policy prevents undocking</message>
+    <defaults>
+      <allow_inactive>no</allow_inactive>
+      <allow_active>yes</allow_active>
+    </defaults>
+  </action>
+
+</policyconfig>
+
diff --git a/tools/Makefile.am b/tools/Makefile.am
index 7119566..c5576b7 100644
--- a/tools/Makefile.am
+++ b/tools/Makefile.am
@@ -170,6 +170,7 @@ script_SCRIPTS =				\
 	hal-system-wol-supported		\
 	hal-system-wol-enabled			\
 	hal-system-wol-enable			\
+	hal-dockstation-undock			\
 	hal-functions
 
 EXTRA_DIST=$(man_MANS) $(MAN_IN_FILES) gen-libgphoto-hal-fdi $(script_SCRIPTS)
diff --git a/tools/hal-dockstation-undock b/tools/hal-dockstation-undock
new file mode 100644
index 0000000..102cbf2
--- /dev/null
+++ b/tools/hal-dockstation-undock
@@ -0,0 +1,6 @@
+#!/bin/sh
+
+. hal-functions
+
+hal_check_priv org.freedesktop.hal.dockstation.undock
+hal_exec_backend
diff --git a/tools/linux/Makefile.am b/tools/linux/Makefile.am
index a3553b0..426078d 100644
--- a/tools/linux/Makefile.am
+++ b/tools/linux/Makefile.am
@@ -38,6 +38,7 @@ script_SCRIPTS =					\
 	hal-system-power-set-power-save-linux		\
 	hal-system-killswitch-get-power-linux		\
 	hal-system-killswitch-set-power-linux		\
+	hal-dockstation-undock-linux			\
 	hal-system-wol-linux
 
 EXTRA_DIST = 90-hal.rules $(script_SCRIPTS)
diff --git a/tools/linux/hal-dockstation-undock-linux b/tools/linux/hal-dockstation-undock-linux
new file mode 100644
index 0000000..a29f43a
--- /dev/null
+++ b/tools/linux/hal-dockstation-undock-linux
@@ -0,0 +1,11 @@
+#!/bin/sh
+
+DOCKED=`cat $HAL_PROP_LINUX_SYSFS_PATH/docked`
+if [ "$DOCKED" = "0" ]; then
+ 	echo "org.freedesktop.Hal.Device.DockStation.NotDocked"
+	exit 1
+fi
+
+RET=`echo 1 > $HAL_PROP_LINUX_SYSFS_PATH/undock`
+
+exit $RET


More information about the hal-commit mailing list