[patch] addon-hid-ups.c : battery.present is mandatory for HAL
spec
David Zeuthen
david at fubar.dk
Tue May 10 11:35:55 PDT 2005
On Tue, 2005-05-10 at 19:27 +0100, Richard Hughes wrote:
> On Mon, 2005-05-09 at 21:35 +0100, Richard Hughes wrote:
> > On Mon, 2005-05-09 at 15:55 -0400, David Zeuthen wrote:
> > <snip>
> > > Anyway, it's good practice to solve the problem in a generic way even
> > > though only ACPI is using it.
> >
> > Point taken.
> > You mean create a function of the form:
> >
> > void setTimeRemaining (HalDevice *d)
> > {
> > gboolean isCharging, isDischarging;
> > int chargeRate, chargeLevel, secondsRemaining, chargeLastFull;
> >
> > {hal_device_property_get_xxx}
> > {do logic}
> > {set "battery.remaining_time"}
> > }
> >
> > and just call setTimeRemaining with the HalDevice?
> >
> > OR for a function to return the remaining time in seconds as an int and
> > then to set battery.remaining_time with the return value?
Oh, sorry, I missed this one. I would just create a function
double util_compute_time_remaining (const char *id,
double curRate,
double curLevel,
bool is_charging);
then we can always swap in another function that may do more interesting
stuff in the future.
> Another question,
>
> hal_device_property_set_int (d, "foo", 6);
> hal_device_property_set_int (d, "foo", 6);
> hal_device_property_set_int (d, "foo", 6);
> hal_device_property_set_int (d, "foo", 6);
> hal_device_property_set_int (d, "foo", 6);
>
> Will I get 5 lots of DBUS traffic, and if not there a big overhead
> anyway?
One way is to try it together with lshal --monitor :-). The answer is
that we hal_device_property_set_* refuses to send a notification if
nothing changes.
> My question is, do I need to check for (oldvalue!=newvalue) before using
> hal_device_property_set_int?
Nope.
Cheers,
David
_______________________________________________
hal mailing list
hal at lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/hal
More information about the Hal
mailing list