pkgsrc-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[pkgsrc/trunk]: pkgsrc/sysutils/hal hald-netbsd: mark the system type as 'lap...



details:   https://anonhg.NetBSD.org/pkgsrc/rev/fd4103ac1ae1
branches:  trunk
changeset: 550730:fd4103ac1ae1
user:      jmcneill <jmcneill%pkgsrc.org@localhost>
date:      Thu Nov 27 14:17:10 2008 +0000

description:
hald-netbsd: mark the system type as 'laptop' if acpibat0 is found, and
don't continually send notifications while charging and discharging.
Bump PKGREVISION.

diffstat:

 sysutils/hal/Makefile                         |   4 +-
 sysutils/hal/files/hald-netbsd/devinfo_misc.c |  12 ++++----
 sysutils/hal/files/hald-netbsd/drvctl.c       |  36 ++++++++++++++++++++++++++-
 sysutils/hal/files/hald-netbsd/drvctl.h       |   1 +
 sysutils/hal/files/hald-netbsd/envsys.c       |  32 ++++++++++++++++++-----
 5 files changed, 69 insertions(+), 16 deletions(-)

diffs (190 lines):

diff -r 5e015d6d7efd -r fd4103ac1ae1 sysutils/hal/Makefile
--- a/sysutils/hal/Makefile     Thu Nov 27 13:28:05 2008 +0000
+++ b/sysutils/hal/Makefile     Thu Nov 27 14:17:10 2008 +0000
@@ -1,8 +1,8 @@
-# $NetBSD: Makefile,v 1.11 2008/11/27 12:24:02 jmcneill Exp $
+# $NetBSD: Makefile,v 1.12 2008/11/27 14:17:10 jmcneill Exp $
 #
 
 DISTNAME=              hal-0.5.11
-PKGREVISION=           7
+PKGREVISION=           8
 CATEGORIES=            sysutils
 MASTER_SITES=          http://hal.freedesktop.org/releases/
 EXTRACT_SUFX=          .tar.bz2
diff -r 5e015d6d7efd -r fd4103ac1ae1 sysutils/hal/files/hald-netbsd/devinfo_misc.c
--- a/sysutils/hal/files/hald-netbsd/devinfo_misc.c     Thu Nov 27 13:28:05 2008 +0000
+++ b/sysutils/hal/files/hald-netbsd/devinfo_misc.c     Thu Nov 27 14:17:10 2008 +0000
@@ -27,6 +27,7 @@
 #include "../device_info.h"
 #include "../util.h"
 #include "devinfo_misc.h"
+#include "drvctl.h"
 
 static HalDevice *devinfo_computer_add(HalDevice *, const char *, char *, char *);
 static HalDevice *devinfo_cpu_add(HalDevice *, const char *, char *,char *);
@@ -97,6 +98,11 @@
                hal_device_property_set_bool (d, "power_management.can_hibernate", FALSE);
        }
 
+       if (drvctl_find_device ("acpibat0", NULL) == TRUE)
+               hal_device_property_set_string (d, "system.formfactor", "laptop");
+       else
+               hal_device_property_set_string (d, "system.formfactor", "desktop");     /* XXX */
+
        devinfo_add_enqueue (d, devnode, &devinfo_default_handler);
 
        return d;
@@ -127,7 +133,6 @@
 static void
 devinfo_default_apply_quirks(HalDevice *d, const char *devnode)
 {
-       HalDevice *computer = hal_device_store_match_key_value_string (hald_get_gdl (), "info.udi", "/org/freedesktop/Hal/devices/computer");
 
 /* acpiacad(4) */
        if (strncmp (devnode, "acpiacad", 8) == 0) {
@@ -139,11 +144,6 @@
                HAL_INFO (("%s: applying acpibat quirks"));
                hal_device_add_capability (d, "battery");
                hal_device_property_set_string (d, "battery.type", "primary");
-
-               if (computer) {
-                       HAL_INFO (("%s: applying acpibat computer quirks"));
-                       hal_device_property_set_string (computer, "system.formfactor", "laptop");
-               }
        }
 
 }
diff -r 5e015d6d7efd -r fd4103ac1ae1 sysutils/hal/files/hald-netbsd/drvctl.c
--- a/sysutils/hal/files/hald-netbsd/drvctl.c   Thu Nov 27 13:28:05 2008 +0000
+++ b/sysutils/hal/files/hald-netbsd/drvctl.c   Thu Nov 27 14:17:10 2008 +0000
@@ -99,7 +99,6 @@
 
        HAL_INFO (("DRVGETEVENT event=%s device=%s", event, device));
 
-
        if (strcmp (event, "device-attach") == 0) {
                drvctl_dev_add (device);
        } else {
@@ -182,6 +181,41 @@
                HAL_WARNING (("DRVLISTDEV/3 expected %d children, got %d", children, laa->l_childname));
 }
 
+gboolean
+drvctl_find_device(const gchar *devnode, prop_dictionary_t *properties)
+{
+       prop_dictionary_t command_dict;
+       prop_dictionary_t args_dict;
+       prop_dictionary_t results_dict;
+       int err;
+          
+       command_dict = prop_dictionary_create ();
+       args_dict = prop_dictionary_create ();
+               
+       prop_dictionary_set_cstring_nocopy (command_dict, "drvctl-command", "get-properties");
+       prop_dictionary_set_cstring_nocopy (args_dict, "device-name", devnode);  
+       prop_dictionary_set (command_dict, "drvctl-arguments", args_dict);
+       prop_object_release (args_dict);
+
+       err = prop_dictionary_sendrecv_ioctl (command_dict, drvctl_fd,
+                                             DRVCTLCOMMAND, &results_dict);
+       prop_object_release (command_dict);
+       if (err)
+               return FALSE;
+
+       if (prop_dictionary_get_int8 (results_dict, "drvctl-error", &err) == false || err != 0) {
+               prop_object_release (results_dict);
+               return FALSE;
+       }
+
+       if (properties)
+               *properties = prop_dictionary_get (results_dict, "drvctl-result-data");
+
+       prop_object_release (results_dict);
+
+       return TRUE;
+}
+
 static gboolean
 drvctl_find_device_with_child(const gchar *curnode, const gchar *devnode,
     char *parent)
diff -r 5e015d6d7efd -r fd4103ac1ae1 sysutils/hal/files/hald-netbsd/drvctl.h
--- a/sysutils/hal/files/hald-netbsd/drvctl.h   Thu Nov 27 13:28:05 2008 +0000
+++ b/sysutils/hal/files/hald-netbsd/drvctl.h   Thu Nov 27 14:17:10 2008 +0000
@@ -19,5 +19,6 @@
 void drvctl_fini(void);
 int drvctl_list(const gchar *devnode, struct devlistargs *laa);
 gboolean drvctl_find_parent(const gchar *devnode, char *parent);
+gboolean drvctl_find_device(const gchar *devnode, prop_dictionary_t *properties);
 
 #endif /* DRVCTL_H */
diff -r 5e015d6d7efd -r fd4103ac1ae1 sysutils/hal/files/hald-netbsd/envsys.c
--- a/sysutils/hal/files/hald-netbsd/envsys.c   Thu Nov 27 13:28:05 2008 +0000
+++ b/sysutils/hal/files/hald-netbsd/envsys.c   Thu Nov 27 14:17:10 2008 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: envsys.c,v 1.2 2008/11/27 12:24:02 jmcneill Exp $ */
+/* $NetBSD: envsys.c,v 1.3 2008/11/27 14:17:11 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2008 Jared D. McNeill <jmcneill%invisible.ca@localhost>
@@ -62,6 +62,12 @@
 static void envsys_acadapter_handler(HalDevice *d, prop_array_t properties);
 static void envsys_battery_handler(HalDevice *d, prop_array_t properties);
 
+enum battery_state {
+       CHARGING,
+       DISCHARGING,
+       NORMAL
+};
+
 static struct envsys_devmap {
        const char *capability;
        void (*handler)(HalDevice *d, prop_array_t properties);
@@ -170,12 +176,11 @@
 {
        prop_object_iterator_t iter;
        prop_dictionary_t prop;
+       enum battery_state battstate = NORMAL;
 
        device_property_atomic_update_begin ();
 
        hal_device_property_set_bool (d, "battery.is_rechargeable", TRUE);
-       hal_device_property_set_bool (d, "battery.rechargeable.is_charging", FALSE);
-       hal_device_property_set_bool (d, "battery.rechargeable.is_discharging", FALSE);
 
        iter = prop_array_iterator (properties);
        while ((prop = (prop_dictionary_t)prop_object_iterator_next (iter)) != NULL) {
@@ -206,16 +211,29 @@
                                hal_device_property_set_int (d, "battery.charge_level.percentage", 0);
                }
                else if (strcmp (descr, "charge rate") == 0) {
-                       hal_device_property_set_bool (d, "battery.rechargeable.is_charging", TRUE);
-                       hal_device_property_set_bool (d, "battery.rechargeable.is_discharging", FALSE);
+                       battstate = CHARGING;
                        hal_device_property_set_int (d, "battery.charge_level.rate", intval / 3600);
                } else if (strcmp (descr, "discharge rate") == 0) {
-                       hal_device_property_set_bool (d, "battery.rechargeable.is_charging", FALSE);
-                       hal_device_property_set_bool (d, "battery.rechargeable.is_discharging", TRUE);
+                       battstate = DISCHARGING;
                        hal_device_property_set_int (d, "battery.charge_level.rate", intval / 3600);
                }
        }
 
+       switch (battstate) {
+       case NORMAL:
+               hal_device_property_set_bool (d, "battery.rechargeable.is_charging", FALSE);
+               hal_device_property_set_bool (d, "battery.rechargeable.is_discharging", FALSE);
+               break;
+       case CHARGING:
+               hal_device_property_set_bool (d, "battery.rechargeable.is_charging", TRUE);
+               hal_device_property_set_bool (d, "battery.rechargeable.is_discharging", FALSE);
+               break;
+       case DISCHARGING:
+               hal_device_property_set_bool (d, "battery.rechargeable.is_charging", FALSE);
+               hal_device_property_set_bool (d, "battery.rechargeable.is_discharging", TRUE);
+               break;
+       }
+
        device_property_atomic_update_end ();
 
        prop_object_iterator_release (iter);



Home | Main Index | Thread Index | Old Index