Lines Matching refs:prop

55 hal_property_free (HalProperty *prop)  in hal_property_free()  argument
58 g_free (prop->key); in hal_property_free()
60 if (prop->type == HAL_PROPERTY_TYPE_STRING) { in hal_property_free()
61 g_free (prop->v.str_value); in hal_property_free()
62 } else if (prop->type == HAL_PROPERTY_TYPE_STRLIST) { in hal_property_free()
64 for (i = prop->v.strlist_value; i != NULL; i = g_slist_next (i)) { in hal_property_free()
67 g_slist_free (prop->v.strlist_value); in hal_property_free()
70 g_free (prop); in hal_property_free()
76 HalProperty *prop; in hal_property_new_string() local
80 prop = g_new0 (HalProperty, 1); in hal_property_new_string()
82 prop->type = HAL_PROPERTY_TYPE_STRING; in hal_property_new_string()
83 prop->key = g_strdup (key); in hal_property_new_string()
84 prop->v.str_value = g_strdup (value != NULL ? value : ""); in hal_property_new_string()
86 while (!g_utf8_validate (prop->v.str_value, -1, in hal_property_new_string()
94 key, prop->v.str_value)); in hal_property_new_string()
97 return prop; in hal_property_new_string()
103 HalProperty *prop; in hal_property_new_int() local
105 prop = g_new0 (HalProperty, 1); in hal_property_new_int()
107 prop->type = HAL_PROPERTY_TYPE_INT32; in hal_property_new_int()
108 prop->key = g_strdup (key); in hal_property_new_int()
109 prop->v.int_value = value; in hal_property_new_int()
111 return prop; in hal_property_new_int()
117 HalProperty *prop; in hal_property_new_uint64() local
119 prop = g_new0 (HalProperty, 1); in hal_property_new_uint64()
121 prop->type = HAL_PROPERTY_TYPE_UINT64; in hal_property_new_uint64()
122 prop->key = g_strdup (key); in hal_property_new_uint64()
123 prop->v.uint64_value = value; in hal_property_new_uint64()
125 return prop; in hal_property_new_uint64()
131 HalProperty *prop; in hal_property_new_bool() local
133 prop = g_new0 (HalProperty, 1); in hal_property_new_bool()
135 prop->type = HAL_PROPERTY_TYPE_BOOLEAN; in hal_property_new_bool()
136 prop->key = g_strdup (key); in hal_property_new_bool()
137 prop->v.bool_value = value; in hal_property_new_bool()
139 return prop; in hal_property_new_bool()
145 HalProperty *prop; in hal_property_new_double() local
147 prop = g_new0 (HalProperty, 1); in hal_property_new_double()
149 prop->type = HAL_PROPERTY_TYPE_DOUBLE; in hal_property_new_double()
150 prop->key = g_strdup (key); in hal_property_new_double()
151 prop->v.double_value = value; in hal_property_new_double()
153 return prop; in hal_property_new_double()
157 hal_property_get_key (HalProperty *prop) in hal_property_get_key() argument
159 g_return_val_if_fail (prop != NULL, NULL); in hal_property_get_key()
161 return prop->key; in hal_property_get_key()
165 hal_property_get_type (HalProperty *prop) in hal_property_get_type() argument
167 g_return_val_if_fail (prop != NULL, HAL_PROPERTY_TYPE_INVALID); in hal_property_get_type()
169 return prop->type; in hal_property_get_type()
173 hal_property_get_string (HalProperty *prop) in hal_property_get_string() argument
175 g_return_val_if_fail (prop != NULL, NULL); in hal_property_get_string()
176 g_return_val_if_fail (prop->type == HAL_PROPERTY_TYPE_STRING, NULL); in hal_property_get_string()
178 return prop->v.str_value; in hal_property_get_string()
182 hal_property_get_int (HalProperty *prop) in hal_property_get_int() argument
184 g_return_val_if_fail (prop != NULL, -1); in hal_property_get_int()
185 g_return_val_if_fail (prop->type == HAL_PROPERTY_TYPE_INT32, -1); in hal_property_get_int()
187 return prop->v.int_value; in hal_property_get_int()
191 hal_property_get_uint64 (HalProperty *prop) in hal_property_get_uint64() argument
193 g_return_val_if_fail (prop != NULL, -1); in hal_property_get_uint64()
194 g_return_val_if_fail (prop->type == HAL_PROPERTY_TYPE_UINT64, -1); in hal_property_get_uint64()
196 return prop->v.uint64_value; in hal_property_get_uint64()
200 hal_property_get_bool (HalProperty *prop) in hal_property_get_bool() argument
202 g_return_val_if_fail (prop != NULL, FALSE); in hal_property_get_bool()
203 g_return_val_if_fail (prop->type == HAL_PROPERTY_TYPE_BOOLEAN, FALSE); in hal_property_get_bool()
205 return prop->v.bool_value; in hal_property_get_bool()
209 hal_property_to_string (HalProperty *prop) in hal_property_to_string() argument
211 g_return_val_if_fail (prop != NULL, NULL); in hal_property_to_string()
213 switch (prop->type) { in hal_property_to_string()
215 return g_strdup (prop->v.str_value); in hal_property_to_string()
217 return g_strdup_printf ("%d", prop->v.int_value); in hal_property_to_string()
219 return g_strdup_printf ("%llu", (long long unsigned int) prop->v.uint64_value); in hal_property_to_string()
222 return g_strdup (prop->v.bool_value ? "true" : "false"); in hal_property_to_string()
224 return g_strdup_printf ("%f", prop->v.double_value); in hal_property_to_string()
233 for (iter = hal_property_get_strlist (prop); in hal_property_to_string()
258 hal_property_get_double (HalProperty *prop) in hal_property_get_double() argument
260 g_return_val_if_fail (prop != NULL, -1.0); in hal_property_get_double()
261 g_return_val_if_fail (prop->type == HAL_PROPERTY_TYPE_DOUBLE, -1.0); in hal_property_get_double()
263 return prop->v.double_value; in hal_property_get_double()
267 hal_property_set_string (HalProperty *prop, const char *value) in hal_property_set_string() argument
272 g_return_if_fail (prop != NULL); in hal_property_set_string()
273 g_return_if_fail (prop->type == HAL_PROPERTY_TYPE_STRING || in hal_property_set_string()
274 prop->type == HAL_PROPERTY_TYPE_INVALID); in hal_property_set_string()
276 prop->type = HAL_PROPERTY_TYPE_STRING; in hal_property_set_string()
277 if (prop->v.str_value != NULL) in hal_property_set_string()
278 g_free (prop->v.str_value); in hal_property_set_string()
279 prop->v.str_value = g_strdup (value); in hal_property_set_string()
281 while (!g_utf8_validate (prop->v.str_value, -1, in hal_property_set_string()
289 prop->key, value)); in hal_property_set_string()
294 hal_property_set_int (HalProperty *prop, dbus_int32_t value) in hal_property_set_int() argument
296 g_return_if_fail (prop != NULL); in hal_property_set_int()
297 g_return_if_fail (prop->type == HAL_PROPERTY_TYPE_INT32 || in hal_property_set_int()
298 prop->type == HAL_PROPERTY_TYPE_INVALID); in hal_property_set_int()
300 prop->type = HAL_PROPERTY_TYPE_INT32; in hal_property_set_int()
301 prop->v.int_value = value; in hal_property_set_int()
305 hal_property_set_uint64 (HalProperty *prop, dbus_uint64_t value) in hal_property_set_uint64() argument
307 g_return_if_fail (prop != NULL); in hal_property_set_uint64()
308 g_return_if_fail (prop->type == HAL_PROPERTY_TYPE_UINT64 || in hal_property_set_uint64()
309 prop->type == HAL_PROPERTY_TYPE_INVALID); in hal_property_set_uint64()
311 prop->type = HAL_PROPERTY_TYPE_UINT64; in hal_property_set_uint64()
312 prop->v.uint64_value = value; in hal_property_set_uint64()
316 hal_property_set_bool (HalProperty *prop, dbus_bool_t value) in hal_property_set_bool() argument
318 g_return_if_fail (prop != NULL); in hal_property_set_bool()
319 g_return_if_fail (prop->type == HAL_PROPERTY_TYPE_BOOLEAN || in hal_property_set_bool()
320 prop->type == HAL_PROPERTY_TYPE_INVALID); in hal_property_set_bool()
322 prop->type = HAL_PROPERTY_TYPE_BOOLEAN; in hal_property_set_bool()
323 prop->v.bool_value = value; in hal_property_set_bool()
327 hal_property_set_double (HalProperty *prop, double value) in hal_property_set_double() argument
329 g_return_if_fail (prop != NULL); in hal_property_set_double()
330 g_return_if_fail (prop->type == HAL_PROPERTY_TYPE_DOUBLE || in hal_property_set_double()
331 prop->type == HAL_PROPERTY_TYPE_INVALID); in hal_property_set_double()
333 prop->type = HAL_PROPERTY_TYPE_DOUBLE; in hal_property_set_double()
334 prop->v.double_value = value; in hal_property_set_double()
338 hal_property_set_attribute (HalProperty *prop, in hal_property_set_attribute() argument
342 g_return_if_fail (prop != NULL); in hal_property_set_attribute()
346 prop->readonly = val; in hal_property_set_attribute()
349 prop->persistence = val; in hal_property_set_attribute()
352 prop->callout = val; in hal_property_set_attribute()
358 hal_property_get_attribute (HalProperty *prop, in hal_property_get_attribute() argument
361 g_return_val_if_fail (prop != NULL, -1); in hal_property_get_attribute()
365 return prop->readonly; in hal_property_get_attribute()
367 return prop->persistence; in hal_property_get_attribute()
369 return prop->callout; in hal_property_get_attribute()
378 HalProperty *prop; in hal_property_new_strlist() local
380 prop = g_new0 (HalProperty, 1); in hal_property_new_strlist()
382 prop->type = HAL_PROPERTY_TYPE_STRLIST; in hal_property_new_strlist()
383 prop->key = g_strdup (key); in hal_property_new_strlist()
384 prop->v.strlist_value = NULL; in hal_property_new_strlist()
386 return prop; in hal_property_new_strlist()
390 hal_property_get_strlist (HalProperty *prop) in hal_property_get_strlist() argument
392 g_return_val_if_fail (prop != NULL, NULL); in hal_property_get_strlist()
393 g_return_val_if_fail (prop->type == HAL_PROPERTY_TYPE_STRLIST, NULL); in hal_property_get_strlist()
395 return prop->v.strlist_value; in hal_property_get_strlist()
399 hal_property_strlist_append (HalProperty *prop, const char *value) in hal_property_strlist_append() argument
401 g_return_val_if_fail (prop != NULL, FALSE); in hal_property_strlist_append()
402 g_return_val_if_fail (prop->type == HAL_PROPERTY_TYPE_STRLIST, FALSE); in hal_property_strlist_append()
404 prop->v.strlist_value = g_slist_append (prop->v.strlist_value, g_strdup (value)); in hal_property_strlist_append()
410 hal_property_strlist_prepend (HalProperty *prop, const char *value) in hal_property_strlist_prepend() argument
412 g_return_val_if_fail (prop != NULL, FALSE); in hal_property_strlist_prepend()
413 g_return_val_if_fail (prop->type == HAL_PROPERTY_TYPE_STRLIST, FALSE); in hal_property_strlist_prepend()
415 prop->v.strlist_value = g_slist_prepend (prop->v.strlist_value, g_strdup (value)); in hal_property_strlist_prepend()
421 hal_property_strlist_remove_elem (HalProperty *prop, guint index) in hal_property_strlist_remove_elem() argument
425 g_return_val_if_fail (prop != NULL, FALSE); in hal_property_strlist_remove_elem()
426 g_return_val_if_fail (prop->type == HAL_PROPERTY_TYPE_STRLIST, FALSE); in hal_property_strlist_remove_elem()
428 if (prop->v.strlist_value == NULL) in hal_property_strlist_remove_elem()
431 elem = g_slist_nth (prop->v.strlist_value, index); in hal_property_strlist_remove_elem()
436 prop->v.strlist_value = g_slist_delete_link (prop->v.strlist_value, elem); in hal_property_strlist_remove_elem()
442 hal_property_strlist_add (HalProperty *prop, const char *value) in hal_property_strlist_add() argument
446 g_return_val_if_fail (prop != NULL, FALSE); in hal_property_strlist_add()
447 g_return_val_if_fail (prop->type == HAL_PROPERTY_TYPE_STRLIST, FALSE); in hal_property_strlist_add()
449 for (elem = prop->v.strlist_value; elem != NULL; elem = g_slist_next (elem)) { in hal_property_strlist_add()
455 return hal_property_strlist_append (prop, value); in hal_property_strlist_add()
459 hal_property_strlist_remove (HalProperty *prop, const char *value) in hal_property_strlist_remove() argument
464 g_return_val_if_fail (prop != NULL, FALSE); in hal_property_strlist_remove()
465 g_return_val_if_fail (prop->type == HAL_PROPERTY_TYPE_STRLIST, FALSE); in hal_property_strlist_remove()
467 for (elem = prop->v.strlist_value, i = 0; elem != NULL; elem = g_slist_next (elem), i++) { in hal_property_strlist_remove()
469 return hal_property_strlist_remove_elem (prop, i); in hal_property_strlist_remove()
477 hal_property_strlist_clear (HalProperty *prop) in hal_property_strlist_clear() argument
481 g_return_val_if_fail (prop != NULL, FALSE); in hal_property_strlist_clear()
482 g_return_val_if_fail (prop->type == HAL_PROPERTY_TYPE_STRLIST, FALSE); in hal_property_strlist_clear()
484 for (elem = prop->v.strlist_value; elem != NULL; elem = g_slist_next (elem)) { in hal_property_strlist_clear()
487 g_slist_free (prop->v.strlist_value); in hal_property_strlist_clear()