hal/libhal libhal.c,1.37,1.38 libhal.h,1.22,1.23
David Zeuthen
david at freedesktop.org
Wed Feb 16 10:39:58 PST 2005
- Previous message: hal/hald device.c, 1.12, 1.13 device_info.c, 1.21, 1.22 hald_dbus.c,
1.21, 1.22 hald_test.c, 1.2, 1.3 hald_test_libhal.c, 1.2,
1.3 property.c, 1.10, 1.11 property.h, 1.6, 1.7 util.c, 1.3, 1.4
- Next message: hal/tools lshal.c,1.10,1.11
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
Update of /cvs/hal/hal/libhal
In directory gabe:/tmp/cvs-serv27614/libhal
Modified Files:
libhal.c libhal.h
Log Message:
2005-02-16 David Zeuthen <davidz at redhat.com>
* tools/device-manager/DeviceManager.py:
(DeviceManager.update_tab_advanced): Make this work for string lists
* tools/lshal.c (main): Various cleanups
* libhal/libhal.c (libhal_property_fill_value_from_variant): Make
this one static. Make sure to recurse into string array otherwise
it won't work at all
(libhal_get_string_array_from_iter): Make this static. Take
num_elems pointer
(libhal_property_set_get_num_elems): New function
(libhal_get_all_devices): Pass num_devices to
libhal_get_string_array_from_iter
(libhal_ctx_shutdown): Remove match and filter function
(libhal_ctx_free): Implement this one; free our context
* libhal/libhal.h: Add prototype for libhal_property_set_get_num_elems
* hald/hald_test_libhal.c (check_libhal): Add tests for the property
set functions as they were failing (see changes above)
* hald/Makefile.am (hald_test_SOURCES): Remove callout.[ch] as they
are now gone
Index: libhal.c
===================================================================
RCS file: /cvs/hal/hal/libhal/libhal.c,v
retrieving revision 1.37
retrieving revision 1.38
diff -u -d -r1.37 -r1.38
--- libhal.c 14 Feb 2005 18:20:05 -0000 1.37
+++ libhal.c 16 Feb 2005 18:39:56 -0000 1.38
@@ -53,10 +53,9 @@
# define N_(String) (String)
#endif
-char **libhal_get_string_array_from_iter (DBusMessageIter *iter);
+static char **libhal_get_string_array_from_iter (DBusMessageIter *iter, int *num_elements);
-dbus_bool_t libhal_property_fill_value_from_variant (LibHalProperty *p,
- DBusMessageIter *var_iter);
+static dbus_bool_t libhal_property_fill_value_from_variant (LibHalProperty *p, DBusMessageIter *var_iter);
@@ -89,10 +88,11 @@
/** Creates a NULL terminated array of strings from a dbus message iterator.
*
* @param iter The message iterator to extract the strings from
+ * @param num_elements Pointer to an integer where to store number of elements (can be NULL)
* @return Pointer to the string array
*/
-char **
-libhal_get_string_array_from_iter (DBusMessageIter *iter)
+static char **
+libhal_get_string_array_from_iter (DBusMessageIter *iter, int *num_elements)
{
int count;
char **buffer;
@@ -132,6 +132,8 @@
}
buffer[count] = NULL;
+ if (num_elements != NULL)
+ *num_elements = count;
return buffer;
oom:
@@ -243,15 +245,17 @@
* @param p The property to fill in
* @param var_iter Varient iterator to extract the value from
*/
-dbus_bool_t
+static dbus_bool_t
libhal_property_fill_value_from_variant (LibHalProperty *p, DBusMessageIter *var_iter)
{
+ DBusMessageIter iter_array;
switch (p->type) {
case DBUS_TYPE_ARRAY:
if (dbus_message_iter_get_element_type (var_iter) != DBUS_TYPE_STRING)
return FALSE;
- p->strlist_value = libhal_get_string_array_from_iter (var_iter);
+ dbus_message_iter_recurse (var_iter, &iter_array);
+ p->strlist_value = libhal_get_string_array_from_iter (&iter_array, NULL);
p->type = LIBHAL_PROPERTY_TYPE_STRLIST;
@@ -414,6 +418,7 @@
dbus_message_iter_recurse (&dict_entry_iter, &var_iter);
+
p->type = dbus_message_iter_get_arg_type (&var_iter);
result->num_properties++;
@@ -464,6 +469,20 @@
free (set);
}
+unsigned int
+libhal_property_set_get_num_elems (LibHalPropertySet *set)
+{
+ unsigned int num_elems;
+ LibHalProperty *p;
+
+ num_elems = 0;
+ for (p = set->properties_head; p != NULL; p = p->next)
+ num_elems++;
+
+ return num_elems;
+}
+
+
/** Initialize a property set iterator.
*
* @param iter Iterator object
@@ -912,7 +931,7 @@
dbus_message_iter_recurse (&reply_iter, &iter_array);
- hal_device_names = libhal_get_string_array_from_iter (&iter_array);
+ hal_device_names = libhal_get_string_array_from_iter (&iter_array, num_devices);
dbus_message_unref (reply);
dbus_message_unref (message);
@@ -1022,7 +1041,7 @@
dbus_message_iter_recurse (&reply_iter, &iter_array);
- our_strings = libhal_get_string_array_from_iter (&iter_array);
+ our_strings = libhal_get_string_array_from_iter (&iter_array, NULL);
dbus_message_unref (reply);
dbus_message_unref (message);
@@ -2373,7 +2392,7 @@
dbus_message_iter_recurse (&reply_iter, &iter_array);
- hal_device_names = libhal_get_string_array_from_iter (&iter_array);
+ hal_device_names = libhal_get_string_array_from_iter (&iter_array, num_devices);
dbus_message_unref (reply);
dbus_message_unref (message);
@@ -2505,7 +2524,7 @@
dbus_message_iter_recurse (&reply_iter, &iter_array);
- hal_device_names = libhal_get_string_array_from_iter (&iter_array);
+ hal_device_names = libhal_get_string_array_from_iter (&iter_array, num_devices);
dbus_message_unref (reply);
dbus_message_unref (message);
@@ -2670,14 +2689,33 @@
dbus_bool_t
libhal_ctx_shutdown (LibHalContext *ctx, DBusError *error)
{
- /* TODO */
+ DBusError myerror;
+
+ dbus_error_init (&myerror);
+ dbus_bus_add_match (ctx->connection,
+ "type='signal',"
+ "interface='org.freedesktop.Hal.Manager',"
+ "sender='org.freedesktop.Hal',"
+ "path='/org/freedesktop/Hal/Manager'", &myerror);
+ if (dbus_error_is_set (&myerror)) {
+ fprintf (stderr, "%s %d : Error unsubscribing to signals, error=%s\n",
+ __FILE__, __LINE__, error->message);
+ /** @todo clean up */
+ }
+
+ /* TODO: remove other matches */
+
+ dbus_connection_remove_filter (ctx->connection, filter_func, ctx);
+
+ ctx->is_initialized = FALSE;
+
return TRUE;
}
dbus_bool_t
libhal_ctx_free (LibHalContext *ctx)
{
- /* TODO */
+ free (ctx);
return TRUE;
}
Index: libhal.h
===================================================================
RCS file: /cvs/hal/hal/libhal/libhal.h,v
retrieving revision 1.22
retrieving revision 1.23
diff -u -d -r1.22 -r1.23
--- libhal.h 14 Feb 2005 18:20:05 -0000 1.22
+++ libhal.h 16 Feb 2005 18:39:56 -0000 1.23
@@ -278,6 +278,8 @@
void libhal_free_property_set (LibHalPropertySet *set);
+unsigned int libhal_property_set_get_num_elems (LibHalPropertySet *set);
+
/** Iterator for inspecting all properties */
struct LibHalPropertySetIterator_s {
LibHalPropertySet *set; /**< Property set we are iterating over */
- Previous message: hal/hald device.c, 1.12, 1.13 device_info.c, 1.21, 1.22 hald_dbus.c,
1.21, 1.22 hald_test.c, 1.2, 1.3 hald_test_libhal.c, 1.2,
1.3 property.c, 1.10, 1.11 property.h, 1.6, 1.7 util.c, 1.3, 1.4
- Next message: hal/tools lshal.c,1.10,1.11
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
More information about the hal-commit
mailing list