hal/hald/linux2 apm.c,1.8,1.9
David Zeuthen
david at freedesktop.org
Wed Apr 13 21:26:58 PDT 2005
Update of /cvs/hal/hal/hald/linux2
In directory gabe:/tmp/cvs-serv12483/hald/linux2
Modified Files:
apm.c
Log Message:
2005-04-14 David Zeuthen <davidz at redhat.com>
Make hal handle APM nicely.
* hald/linux2/apm.c (apm_poll): New function
(battery_refresh): Hmm, APM reports -1 if battery is absent.
s/system.ac_adapter/ac_adapter/ - Patch from Bill
Nottingham <notting at redhat.com>
(apm_synthesize_hotplug_events): Add time for APM polling
Index: apm.c
===================================================================
RCS file: /cvs/hal/hal/hald/linux2/apm.c,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -d -r1.8 -r1.9
--- apm.c 17 Mar 2005 17:19:43 -0000 1.8
+++ apm.c 14 Apr 2005 04:26:56 -0000 1.9
@@ -64,6 +64,26 @@
int using_minutes;
} APMInfo;
+#define APM_POLL_INTERVAL 2000
+
+static gboolean
+apm_poll (gpointer data)
+{
+ GSList *i;
+ GSList *devices;
+
+ devices = hal_device_store_match_multiple_key_value_string (hald_get_gdl (),
+ "linux.apm_path",
+ "/proc/apm");
+ for (i = devices; i != NULL; i = g_slist_next (i)) {
+ HalDevice *d;
+ d = HAL_DEVICE (i->data);
+ apm_rescan_device (d);
+ }
+
+ return TRUE;
+}
+
static gboolean
read_from_apm (const char *apm_file, APMInfo *i)
{
@@ -120,7 +140,7 @@
read_from_apm (path, &i);
- if (i.battery_percentage == 0) {
+ if (i.battery_percentage <= 0) {
device_property_atomic_update_begin ();
hal_device_property_remove (d, "battery.is_rechargeable");
hal_device_property_remove (d, "battery.rechargeable.is_charging");
@@ -129,6 +149,7 @@
hal_device_property_remove (d, "battery.charge_level.current");
hal_device_property_remove (d, "battery.charge_level.last_full");
hal_device_property_remove (d, "battery.charge_level.design");
+ hal_device_property_set_bool (d, "battery.present", FALSE);
device_property_atomic_update_end ();
} else {
device_property_atomic_update_begin ();
@@ -171,8 +192,8 @@
return FALSE;
hal_device_property_set_string (d, "info.product", "AC Adapter");
- hal_device_property_set_string (d, "info.category", "system.ac_adapter");
- hal_device_add_capability (d, "system.ac_adapter");
+ hal_device_property_set_string (d, "info.category", "ac_adapter");
+ hal_device_add_capability (d, "ac_adapter");
read_from_apm(path, &i);
@@ -230,6 +251,10 @@
hotplug_event->apm.apm_type = APM_TYPE_AC_ADAPTER;
hotplug_event_enqueue (hotplug_event);
+ g_timeout_add (APM_POLL_INTERVAL,
+ apm_poll,
+ NULL);
+
out:
return ret;
}
More information about the hal-commit
mailing list