diff -Nur hal/hald/linux/osspec.c hal.new/hald/linux/osspec.c --- hal/hald/linux/osspec.c 2007-04-03 17:38:50.000000000 +0100 +++ hal.new/hald/linux/osspec.c 2007-08-29 18:08:24.000000000 +0100 @@ -722,6 +722,15 @@ decode_dmi (d); } +static void +computer_probing_pmi_helper_done (HalDevice *d, guint32 exit_type, + gint return_code, gchar **error, + gpointer data1, gpointer data2) +{ + HAL_INFO (("In computer_probing_pmi_helper_done")); + decode_dmi (d); +} + void osspec_probe (void) { @@ -774,6 +783,9 @@ if (g_file_test ("/usr/bin/pm-is-supported", G_FILE_TEST_IS_EXECUTABLE)) { hald_runner_run (root, "hal-system-power-pm-is-supported", NULL, HAL_HELPER_TIMEOUT, computer_probing_pm_is_supported_helper_done, NULL, NULL); + } else if (g_file_test ("/usr/sbin/pmi", G_FILE_TEST_IS_EXECUTABLE)) { + hald_runner_run (root, "hal-system-power-pmi", NULL, HAL_HELPER_TIMEOUT, + computer_probing_pmi_helper_done, NULL, NULL); } else { decode_dmi (root); } diff -Nur hal/tools/Makefile.am hal.new/tools/Makefile.am --- hal/tools/Makefile.am 2007-05-02 04:57:02.000000000 +0100 +++ hal.new/tools/Makefile.am 2007-08-29 18:09:01.000000000 +0100 @@ -72,7 +72,8 @@ hal-storage-closetray \ hal-storage-cleanup-mountpoint \ hal-storage-cleanup-all-mountpoints \ - hal-system-power-pm-is-supported + hal-system-power-pm-is-supported \ + hal-system-power-pmi if HAVE_PMU libexec_PROGRAMS += \ @@ -94,6 +95,9 @@ hal_system_power_pm_is_supported_SOURCES = hal-system-power-pm-is-supported.c hal_system_power_pm_is_supported_LDADD = @GLIB_LIBS@ @DBUS_LIBS@ $(top_builddir)/libhal/libhal.la +hal_system_power_pmi_SOURCES = hal-system-power-pmi.c +hal_system_power_pmi_LDADD = @GLIB_LIBS@ @DBUS_LIBS@ $(top_builddir)/libhal/libhal.la + hal_storage_mount_SOURCES = hal-storage-mount.c hal-storage-shared.c hal-storage-shared.h hal_storage_mount_LDADD = @GLIB_LIBS@ @POLKIT_LIBS@ @DBUS_LIBS@ $(top_builddir)/libhal/libhal.la $(top_builddir)/libhal-storage/libhal-storage.la diff -Nur hal/tools/Makefile.in hal.new/tools/Makefile.in --- hal/tools/Makefile.in 2007-06-12 19:27:25.000000000 +0100 +++ hal.new/tools/Makefile.in 2007-08-29 18:09:27.000000000 +0100 @@ -46,8 +46,9 @@ hal-storage-closetray$(EXEEXT) \ hal-storage-cleanup-mountpoint$(EXEEXT) \ hal-storage-cleanup-all-mountpoints$(EXEEXT) \ - hal-system-power-pm-is-supported$(EXEEXT) $(am__EXEEXT_1) \ - $(am__EXEEXT_2) $(am__EXEEXT_3) + hal-system-power-pm-is-supported$(EXEEXT) \ + hal-system-power-pmi$(EXEEXT) $(am__EXEEXT_1) $(am__EXEEXT_2) \ + $(am__EXEEXT_3) @HAVE_PMU_TRUE@am__append_4 = \ @HAVE_PMU_TRUE@ hal-system-power-pmu @@ -150,6 +151,9 @@ $(am_hal_system_power_pm_is_supported_OBJECTS) hal_system_power_pm_is_supported_DEPENDENCIES = \ $(top_builddir)/libhal/libhal.la +am_hal_system_power_pmi_OBJECTS = hal-system-power-pmi.$(OBJEXT) +hal_system_power_pmi_OBJECTS = $(am_hal_system_power_pmi_OBJECTS) +hal_system_power_pmi_DEPENDENCIES = $(top_builddir)/libhal/libhal.la am__hal_system_power_pmu_SOURCES_DIST = hal-system-power-pmu.c @HAVE_PMU_TRUE@am_hal_system_power_pmu_OBJECTS = \ @HAVE_PMU_TRUE@ hal-system-power-pmu.$(OBJEXT) @@ -196,6 +200,7 @@ $(hal_storage_closetray_SOURCES) $(hal_storage_eject_SOURCES) \ $(hal_storage_mount_SOURCES) $(hal_storage_unmount_SOURCES) \ $(hal_system_power_pm_is_supported_SOURCES) \ + $(hal_system_power_pmi_SOURCES) \ $(hal_system_power_pmu_SOURCES) $(hal_system_sonypic_SOURCES) \ $(lshal_SOURCES) $(umount_hal_SOURCES) DIST_SOURCES = $(am__hal_acl_tool_SOURCES_DIST) $(hal_device_SOURCES) \ @@ -209,6 +214,7 @@ $(hal_storage_closetray_SOURCES) $(hal_storage_eject_SOURCES) \ $(hal_storage_mount_SOURCES) $(hal_storage_unmount_SOURCES) \ $(hal_system_power_pm_is_supported_SOURCES) \ + $(hal_system_power_pmi_SOURCES) \ $(am__hal_system_power_pmu_SOURCES_DIST) \ $(am__hal_system_sonypic_SOURCES_DIST) $(lshal_SOURCES) \ $(am__umount_hal_SOURCES_DIST) @@ -456,6 +462,8 @@ @HAVE_ACLMGMT_TRUE@hal_acl_tool_LDADD = @GLIB_LIBS@ $(top_builddir)/libhal/libhal.la hal_system_power_pm_is_supported_SOURCES = hal-system-power-pm-is-supported.c hal_system_power_pm_is_supported_LDADD = @GLIB_LIBS@ @DBUS_LIBS@ $(top_builddir)/libhal/libhal.la +hal_system_power_pmi_SOURCES = hal-system-power-pmi.c +hal_system_power_pmi_LDADD = @GLIB_LIBS@ @DBUS_LIBS@ $(top_builddir)/libhal/libhal.la hal_storage_mount_SOURCES = hal-storage-mount.c hal-storage-shared.c hal-storage-shared.h hal_storage_mount_LDADD = @GLIB_LIBS@ @POLKIT_LIBS@ @DBUS_LIBS@ $(top_builddir)/libhal/libhal.la $(top_builddir)/libhal-storage/libhal-storage.la hal_storage_unmount_SOURCES = hal-storage-unmount.c hal-storage-shared.c hal-storage-shared.h @@ -657,6 +665,9 @@ hal-system-power-pm-is-supported$(EXEEXT): $(hal_system_power_pm_is_supported_OBJECTS) $(hal_system_power_pm_is_supported_DEPENDENCIES) @rm -f hal-system-power-pm-is-supported$(EXEEXT) $(LINK) $(hal_system_power_pm_is_supported_OBJECTS) $(hal_system_power_pm_is_supported_LDADD) $(LIBS) +hal-system-power-pmi$(EXEEXT): $(hal_system_power_pmi_OBJECTS) $(hal_system_power_pmi_DEPENDENCIES) + @rm -f hal-system-power-pmi$(EXEEXT) + $(LINK) $(hal_system_power_pmi_OBJECTS) $(hal_system_power_pmi_LDADD) $(LIBS) hal-system-power-pmu$(EXEEXT): $(hal_system_power_pmu_OBJECTS) $(hal_system_power_pmu_DEPENDENCIES) @rm -f hal-system-power-pmu$(EXEEXT) $(LINK) $(hal_system_power_pmu_OBJECTS) $(hal_system_power_pmu_LDADD) $(LIBS) @@ -708,6 +719,7 @@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/hal-storage-shared.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/hal-storage-unmount.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/hal-system-power-pm-is-supported.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/hal-system-power-pmi.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/hal-system-power-pmu.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/hal-system-sonypic.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/hal_find_by_capability.Po@am__quote@ diff -Nur hal/tools/hal-system-power-pmi.c hal.new/tools/hal-system-power-pmi.c --- hal/tools/hal-system-power-pmi.c 1970-01-01 01:00:00.000000000 +0100 +++ hal.new/tools/hal-system-power-pmi.c 2007-08-29 18:08:24.000000000 +0100 @@ -0,0 +1,85 @@ +/*************************************************************************** + * hal-system-power-pmi.c: Query powermanagement-interface for suspend + * + * Copyright (C) 2006 David Zeuthen, + * Copyright (C) 2007 Canonical Ltd. + * (by Colin Watson ) + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * + **************************************************************************/ + + +#ifdef HAVE_CONFIG_H +# include +#endif + +#include +#include +#include +#include + +#include +#include + +int +main (int argc, char *argv[]) +{ + int ret; + char *udi; + DBusError error; + LibHalContext *hal_ctx = NULL; + LibHalChangeSet *cs; + gboolean can_suspend = FALSE; + gboolean can_hibernate = FALSE; + int exit_status; + + ret = 1; + + udi = getenv ("HAL_PROP_INFO_UDI"); + if (udi == NULL) + goto out; + + dbus_error_init (&error); + if ((hal_ctx = libhal_ctx_init_direct (&error)) == NULL) { + printf ("Cannot connect to hald\n"); + if (dbus_error_is_set (&error)) { + dbus_error_free (&error); + } + goto out; + } + + cs = libhal_device_new_changeset (udi); + if (cs == NULL) { + printf ("Cannot initialize changeset\n"); + goto out; + } + + g_spawn_command_line_sync ("/usr/sbin/pmi query suspend", NULL, NULL, &exit_status, NULL); + can_suspend = (exit_status == 0); + g_spawn_command_line_sync ("/usr/sbin/pmi query hibernate", NULL, NULL, &exit_status, NULL); + can_hibernate = (exit_status == 0); + + libhal_changeset_set_property_bool (cs, "power_management.can_suspend", can_suspend); + libhal_changeset_set_property_bool (cs, "power_management.can_suspend_hybrid", FALSE); + libhal_changeset_set_property_bool (cs, "power_management.can_hibernate", can_hibernate); + + libhal_device_commit_changeset (hal_ctx, cs, &error); + libhal_device_free_changeset (cs); + + ret = 0; +out: + return ret; +}