persistent property store - first try

Joe Shaw joeshaw at novell.com
Fri Jun 11 10:44:52 PDT 2004


Hi,

On Fri, 2004-06-11 at 17:21 +0200, Kay Sievers wrote:
> Hmm, should we convert:
>   hal_device_property_set_persistence(d, "info.test", TRUE)
> 
> to a generic method, so we may use it for other possible attributes too?
> Something like this:
>   hal_device_property_set_attribute(d, "info.test", HAL_PROP_ATTR_CALLOUT, FALSE)
>   hal_device_property_set_attribute(d, "info.test", HAL_PROP_ATTR_PERSISTENCE, TRUE)
> 
> Or if we have bits only:
>   hal_device_property_set_attribute(d, "info.test", HAL_PROP_ATTR_CALLOUT |)
>                                                     HAL_PROP_ATTR_PERSISTENCE)

It's probably a good idea to add this at the same time, but I don't have
a strong feeling about whether it should be two separate functions or a
bitfield.

> @@ -728,8 +735,10 @@
>  
>  	prop = hal_device_property_find (device, key);
>  
> -	if (prop == NULL)
> -		return FALSE;
> +	g_return_val_if_fail (prop != NULL, FALSE);
> +
> +	if (hal_property_get_persistence (prop))
> +		hal_pstore_delete_property (hald_get_pstore_sys (), device, prop); 
>  
>  	device->properties = g_slist_remove (device->properties, prop);

I'm not totally sure this is the right thing.  Generally
g_return_if_fail() is used to check for programmer errors like passing
in a NULL value or an object of a wrong class, etc.  If things fail
it'll print a nasty glib warning at runtime.  It doesn't seem harmful to
me if a key which doesn't exist is passed into the remove function.
 
> @@ -741,6 +750,28 @@
>  	return TRUE;
>  }
>  
> +gboolean
> +hal_device_property_set_persistence (HalDevice *device,
> +				     const char *key,
> +				     gboolean persistence)
> +{
> +	HalProperty *prop;
> +
> +	prop = hal_device_property_find (device, key);
> +
> +	g_return_val_if_fail (prop != NULL, FALSE);

Ditto here.

Joe


_______________________________________________
hal mailing list
hal at freedesktop.org
http://freedesktop.org/mailman/listinfo/hal



More information about the Hal mailing list