hal/hald callout.c, 1.9, 1.10 device.c, 1.5, 1.6 device.h, 1.4,
1.5 device_store.c, 1.19, 1.20 device_store.h, 1.11,
1.12 hald.c, 1.4, 1.5 hald_dbus.c, 1.2, 1.3 hald_marshal.list,
1.2, 1.3
Joe Shaw
joe at pdx.freedesktop.org
Mon Apr 26 13:09:00 PDT 2004
- Previous message: hal ChangeLog,1.117,1.118
- Next message: hal/hald/linux block_class_device.c, 1.15, 1.16 bus_device.c, 1.6,
1.7 class_device.c, 1.11, 1.12 common.c, 1.5, 1.6 common.h, 1.2, 1.3
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
Update of /cvs/hal/hal/hald
In directory pdx:/tmp/cvs-serv15909/hald
Modified Files:
callout.c device.c device.h device_store.c device_store.h
hald.c hald_dbus.c hald_marshal.list
Log Message:
2004-04-26 David Zeuthen <david at fubar.dk>
* hald/device.c (hal_device_print): Print out to stderr instead of
stdout.
* hald/device_store.c (hal_device_store_print): Print out the
contents of a HalDeviceStore.
* hald/linux/common.c (rename_and_merge): Check to see if the UDI
exists in the TDL and try again if it is.
2004-04-26 Joe Shaw <joe at ximian.com>
* hald/callout.c: Make pending callouts a hash table of lists, so
we can execute all the callouts for the devices in order.
(add_pending_callout, pop_pending_callout): New convenience
functions.
(wait_for_callout): If this is the last callout for a device, fire
off the callouts_finished signal on the device.
(hal_callout_device, hal_callout_capability,
hal_callout_property): Use the new convenience functions, call
process_callouts() in an idle function.
* hald/device.c: Add a "callouts_finished" signal.
* hald/hald.c (gdl_store_changed): Don't call hal_callout_device()
here anymore... we call it in the backend before we get added to
the GDL.
* hald/hald_dbus.c (manager_device_exists,
device_get_all_properties, device_get_property,
device_get_property_type, device_set_property,
device_add_capability, device_remove_property,
device_property_exists, device_query_capability,
agent_merge_properties, agent_device_matches): Search the TDL for
the provided UDI if it's not found in the GDL.
* hald/linux/block_class_device.c (detect_media): Instead of
adding the device to the GDL immediately, connect to the
callouts_finished signal and add the device then. Call
hal_callout_device() here, though.
* hald/linux/bus_device.c (bus_device_got_parent): Ditto.
* hald/linux/class_device.c (class_device_final): Ditto.
* hald/linux/common.c (device_move_from_tdl_to_gdl): Remove the
device from the TDL and add it to the GDL. Remove the signal
handler and unref the device. Used as a callback from
bus_device.c and class_device.c.
Index: callout.c
===================================================================
RCS file: /cvs/hal/hal/hald/callout.c,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -d -r1.9 -r1.10
--- a/callout.c 21 Apr 2004 21:40:45 -0000 1.9
+++ b/callout.c 26 Apr 2004 20:08:58 -0000 1.10
@@ -53,13 +53,73 @@
char **envp;
int envp_index;
int pid;
+ gboolean last_of_device;
} Callout;
static void process_callouts (void);
-static GSList *pending_callouts = NULL;
+/* Key: HalDevice Value: pointer to GSList of Callouts */
+static GHashTable *pending_callouts = NULL;
static gboolean processing_callouts = FALSE;
+static void
+add_pending_callout (HalDevice *device, Callout *callout)
+{
+ GSList **clist = NULL;
+
+ if (pending_callouts == NULL)
+ pending_callouts = g_hash_table_new (NULL, NULL);
+ else
+ clist = g_hash_table_lookup (pending_callouts, device);
+
+ if (clist == NULL) {
+ clist = g_new0 (GSList *, 1);
+ g_hash_table_insert (pending_callouts, device, clist);
+ }
+
+ *clist = g_slist_append (*clist, callout);
+}
+
+static void
+get_device (gpointer key, gpointer value, gpointer user_data)
+{
+ HalDevice **device = user_data;
+
+ if (*device == NULL)
+ *device = (HalDevice *) key;
+}
+
+static Callout *
+pop_pending_callout (gboolean *last_of_device)
+{
+ GSList **clist;
+ HalDevice *device = NULL;
+ Callout *callout;
+
+ if (pending_callouts == NULL)
+ return NULL;
+
+ /* Hmm, not sure of a better way to do this... */
+ g_hash_table_foreach (pending_callouts, get_device, &device);
+
+ clist = g_hash_table_lookup (pending_callouts, device);
+
+ if (clist == NULL)
+ return NULL;
+
+ callout = (Callout *) (*clist)->data;
+ *clist = g_slist_remove (*clist, callout);
+
+ if (*clist == NULL) {
+ g_hash_table_remove (pending_callouts, device);
+ g_free (clist);
+ *last_of_device = TRUE;
+ } else
+ *last_of_device = FALSE;
+
+ return callout;
+}
+
static gboolean
add_property_to_env (HalDevice *device, HalProperty *property,
gpointer user_data)
@@ -111,6 +171,9 @@
strerror (errno)));
}
} else {
+ if (callout->last_of_device)
+ hal_device_callouts_finished (callout->device);
+
g_free (callout->filename);
g_strfreev (callout->envp);
g_object_unref (callout->device);
@@ -126,19 +189,21 @@
process_callouts (void)
{
Callout *callout;
+ gboolean last_of_device;
char *argv[3];
GError *err = NULL;
int num_props;
- if (pending_callouts == NULL) {
+ if (pending_callouts == NULL ||
+ g_hash_table_size (pending_callouts) == 0) {
processing_callouts = FALSE;
return;
}
processing_callouts = TRUE;
- callout = (Callout *) pending_callouts->data;
- pending_callouts = g_slist_remove (pending_callouts, callout);
+ callout = pop_pending_callout (&last_of_device);
+ callout->last_of_device = last_of_device;
argv[0] = callout->filename;
@@ -185,6 +250,13 @@
g_timeout_add (250, wait_for_callout, callout);
}
+static gboolean
+process_callouts_idle (gpointer user_data)
+{
+ process_callouts ();
+ return FALSE;
+}
+
void
hal_callout_device (HalDevice *device, gboolean added)
{
@@ -235,13 +307,13 @@
callout->envp[0] = g_strdup_printf ("UDI=%s",
hal_device_get_udi (device));
- pending_callouts = g_slist_append (pending_callouts, callout);
+ add_pending_callout (callout->device, callout);
}
g_dir_close (dir);
- if (pending_callouts != NULL && !processing_callouts)
- process_callouts ();
+ if (!processing_callouts)
+ g_idle_add (process_callouts_idle, NULL);
}
void
@@ -297,13 +369,13 @@
callout->envp[1] = g_strdup_printf ("CAPABILITY=%s",
capability);
- pending_callouts = g_slist_append (pending_callouts, callout);
+ add_pending_callout (callout->device, callout);
}
g_dir_close (dir);
- if (pending_callouts != NULL && !processing_callouts)
- process_callouts ();
+ if (!processing_callouts)
+ g_idle_add (process_callouts_idle, NULL);
}
void
@@ -361,13 +433,13 @@
callout->envp[1] = g_strdup_printf ("PROPERTY=%s", key);
callout->envp[2] = g_strdup_printf ("VALUE=%s", value);
- pending_callouts = g_slist_append (pending_callouts, callout);
+ add_pending_callout (callout->device, callout);
g_free (value);
}
g_dir_close (dir);
- if (pending_callouts != NULL && !processing_callouts)
- process_callouts ();
+ if (!processing_callouts)
+ g_idle_add (process_callouts_idle, NULL);
}
Index: device.c
===================================================================
RCS file: /cvs/hal/hal/hald/device.c,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- a/device.c 20 Apr 2004 20:54:15 -0000 1.5
+++ b/device.c 26 Apr 2004 20:08:58 -0000 1.6
@@ -40,6 +40,7 @@
enum {
PROPERTY_CHANGED,
CAPABILITY_ADDED,
+ CALLOUTS_FINISHED,
LAST_SIGNAL
};
@@ -90,6 +91,16 @@
hald_marshal_VOID__STRING,
G_TYPE_NONE, 1,
G_TYPE_STRING);
+
+ signals[CALLOUTS_FINISHED] =
+ g_signal_new ("callouts_finished",
+ G_TYPE_FROM_CLASS (klass),
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (HalDeviceClass,
+ callouts_finished),
+ NULL, NULL,
+ hald_marshal_VOID__VOID,
+ G_TYPE_NONE, 0);
}
static void
@@ -735,7 +746,7 @@
{
GSList *iter;
- printf ("device udi = %s\n", hal_device_get_udi (device));
+ fprintf (stderr, "device udi = %s\n", hal_device_get_udi (device));
for (iter = device->properties; iter != NULL; iter = iter->next) {
HalProperty *p = iter->data;
@@ -747,23 +758,23 @@
switch (type) {
case DBUS_TYPE_STRING:
- printf (" %s = '%s' (string)\n", key,
+ fprintf (stderr, " %s = '%s' (string)\n", key,
hal_property_get_string (p));
break;
case DBUS_TYPE_INT32:
- printf (" %s = %d 0x%x (int)\n", key,
+ fprintf (stderr, " %s = %d 0x%x (int)\n", key,
hal_property_get_int (p),
hal_property_get_int (p));
break;
case DBUS_TYPE_DOUBLE:
- printf (" %s = %g (double)\n", key,
+ fprintf (stderr, " %s = %g (double)\n", key,
hal_property_get_double (p));
break;
case DBUS_TYPE_BOOLEAN:
- printf (" %s = %s (bool)\n", key,
+ fprintf (stderr, " %s = %s (bool)\n", key,
(hal_property_get_bool (p) ? "true" :
"false"));
break;
@@ -773,7 +784,7 @@
break;
}
}
- printf ("\n");
+ fprintf (stderr, "\n");
}
@@ -861,3 +872,10 @@
ai->timeout_id = g_timeout_add (timeout, async_wait_timeout, ai);
}
+
+void
+hal_device_callouts_finished (HalDevice *device)
+{
+ g_signal_emit (device, signals[CALLOUTS_FINISHED], 0);
+}
+
Index: device.h
===================================================================
RCS file: /cvs/hal/hal/hald/device.h,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- a/device.h 20 Apr 2004 20:54:15 -0000 1.4
+++ b/device.h 26 Apr 2004 20:08:58 -0000 1.5
@@ -54,6 +54,8 @@
void (*capability_added) (HalDevice *device,
const char *capability);
+
+ void (*callouts_finished) (HalDevice *device);
};
#define HAL_TYPE_DEVICE (hal_device_get_type ())
@@ -143,7 +145,9 @@
void hal_device_async_wait_property (HalDevice *device,
const char *key,
HalDeviceAsyncCallback callback,
- gpointer user_data,
- int timeout);
+ gpointer user_data,
+ int timeout);
+
+void hal_device_callouts_finished (HalDevice *device);
#endif /* DEVICE_H */
Index: device_store.c
===================================================================
RCS file: /cvs/hal/hal/hald/device_store.c,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -d -r1.19 -r1.20
--- a/device_store.c 3 Apr 2004 07:46:33 -0000 1.19
+++ b/device_store.c 26 Apr 2004 20:08:58 -0000 1.20
@@ -241,6 +241,30 @@
}
}
+static gboolean
+hal_device_store_print_foreach_fn (HalDeviceStore *store,
+ HalDevice *device,
+ gpointer user_data)
+{
+ fprintf (stderr, "----\n");
+ hal_device_print (device);
+ fprintf (stderr, "----\n");
+ return TRUE;
+}
+
+void
+hal_device_store_print (HalDeviceStore *store)
+{
+ fprintf (stderr, "===============================================\n");
+ fprintf (stderr, "Dumping %d devices\n",
+ g_slist_length (store->devices));
+ fprintf (stderr, "===============================================\n");
+ hal_device_store_foreach (store,
+ hal_device_store_print_foreach_fn,
+ NULL);
+ fprintf (stderr, "===============================================\n");
+}
+
HalDevice *
hal_device_store_match_key_value_string (HalDeviceStore *store,
const char *key,
@@ -424,6 +448,7 @@
G_CALLBACK (store_changed),
info);
- info->timeout_id = g_timeout_add (timeout, match_device_async_timeout,
+ info->timeout_id = g_timeout_add (timeout,
+ match_device_async_timeout,
info);
}
Index: device_store.h
===================================================================
RCS file: /cvs/hal/hal/hald/device_store.h,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -d -r1.11 -r1.12
--- a/device_store.h 3 Apr 2004 07:46:33 -0000 1.11
+++ b/device_store.h 26 Apr 2004 20:08:58 -0000 1.12
@@ -111,4 +111,7 @@
gpointer user_data,
int timeout);
+void hal_device_store_print (HalDeviceStore *store);
+
+
#endif /* DEVICE_STORE_H */
Index: hald.c
===================================================================
RCS file: /cvs/hal/hal/hald/hald.c,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- a/hald.c 21 Apr 2004 18:44:41 -0000 1.4
+++ b/hald.c 26 Apr 2004 20:08:58 -0000 1.5
@@ -75,7 +75,6 @@
if (is_added) {
manager_send_signal_device_added (device);
- hal_callout_device (device, TRUE);
} else {
manager_send_signal_device_removed (device);
hal_callout_device (device, FALSE);
Index: hald_dbus.c
===================================================================
RCS file: /cvs/hal/hal/hald/hald_dbus.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- a/hald_dbus.c 3 Apr 2004 07:46:33 -0000 1.2
+++ b/hald_dbus.c 26 Apr 2004 20:08:58 -0000 1.3
@@ -442,6 +442,9 @@
d = hal_device_store_find (hald_get_gdl (), udi);
+ if (d == NULL)
+ d = hal_device_store_find (hald_get_tdl (), udi);
+
reply = dbus_message_new_method_return (message);
dbus_message_iter_init (reply, &iter);
dbus_message_iter_append_boolean (&iter, d != NULL);
@@ -618,6 +621,9 @@
HAL_TRACE (("entering, udi=%s", udi));
d = hal_device_store_find (hald_get_gdl (), udi);
+ if (d == NULL)
+ d = hal_device_store_find (hald_get_tdl (), udi);
+
if (d == NULL) {
raise_no_such_device (connection, message, udi);
return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
@@ -677,6 +683,9 @@
HAL_TRACE (("entering, udi=%s", udi));
d = hal_device_store_find (hald_get_gdl (), udi);
+ if (d == NULL)
+ d = hal_device_store_find (hald_get_tdl (), udi);
+
if (d == NULL) {
raise_no_such_device (connection, message, udi);
return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
@@ -765,6 +774,9 @@
HAL_TRACE (("entering, udi=%s", udi));
d = hal_device_store_find (hald_get_gdl (), udi);
+ if (d == NULL)
+ d = hal_device_store_find (hald_get_tdl (), udi);
+
if (d == NULL) {
raise_no_such_device (connection, message, udi);
return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
@@ -846,6 +858,9 @@
HAL_DEBUG (("udi=%s, key=%s", udi, key));
device = hal_device_store_find (hald_get_gdl (), udi);
+ if (device == NULL)
+ device = hal_device_store_find (hald_get_tdl (), udi);
+
if (device == NULL) {
raise_no_such_device (connection, message, udi);
return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
@@ -945,6 +960,9 @@
udi = dbus_message_get_path (message);
d = hal_device_store_find (hald_get_gdl (), udi);
+ if (d == NULL)
+ d = hal_device_store_find (hald_get_tdl (), udi);
+
if (d == NULL) {
raise_no_such_device (connection, message, udi);
return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
@@ -1014,6 +1032,9 @@
udi = dbus_message_get_path (message);
d = hal_device_store_find (hald_get_gdl (), udi);
+ if (d == NULL)
+ d = hal_device_store_find (hald_get_tdl (), udi);
+
if (d == NULL) {
raise_no_such_device (connection, message, udi);
return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
@@ -1072,6 +1093,9 @@
udi = dbus_message_get_path (message);
d = hal_device_store_find (hald_get_gdl (), udi);
+ if (d == NULL)
+ d = hal_device_store_find (hald_get_tdl (), udi);
+
if (d == NULL) {
raise_no_such_device (connection, message, udi);
return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
@@ -1131,6 +1155,9 @@
udi = dbus_message_get_path (message);
d = hal_device_store_find (hald_get_gdl (), udi);
+ if (d == NULL)
+ d = hal_device_store_find (hald_get_tdl (), udi);
+
if (d == NULL) {
raise_no_such_device (connection, message, udi);
return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
@@ -1595,12 +1622,18 @@
target_udi, source_udi));
target_d = hal_device_store_find (hald_get_gdl (), target_udi);
+ if (target_d == NULL)
+ target_d = hal_device_store_find (hald_get_tdl (), target_udi);
+
if (target_d == NULL) {
raise_no_such_device (connection, message, target_udi);
return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
}
source_d = hal_device_store_find (hald_get_gdl (), source_udi);
+ if (source_d == NULL)
+ source_d = hal_device_store_find (hald_get_tdl (), source_udi);
+
if (source_d == NULL) {
raise_no_such_device (connection, message, source_udi);
return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
@@ -1669,12 +1702,18 @@
udi1, udi2, namespace));
d1 = hal_device_store_find (hald_get_gdl (), udi1);
+ if (d1 == NULL)
+ d1 = hal_device_store_find (hald_get_tdl (), udi1);
+
if (d1 == NULL) {
raise_no_such_device (connection, message, udi1);
return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
}
d2 = hal_device_store_find (hald_get_gdl (), udi2);
+ if (d2 == NULL)
+ d2 = hal_device_store_find (hald_get_tdl (), udi2);
+
if (d2 == NULL) {
raise_no_such_device (connection, message, udi2);
return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
Index: hald_marshal.list
===================================================================
RCS file: /cvs/hal/hal/hald/hald_marshal.list,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- a/hald_marshal.list 3 Apr 2004 07:46:33 -0000 1.2
+++ b/hald_marshal.list 26 Apr 2004 20:08:58 -0000 1.3
@@ -3,3 +3,4 @@
VOID:OBJECT,BOOL
VOID:OBJECT,STRING,BOOL,BOOL
VOID:OBJECT,STRING
+VOID:VOID
- Previous message: hal ChangeLog,1.117,1.118
- Next message: hal/hald/linux block_class_device.c, 1.15, 1.16 bus_device.c, 1.6,
1.7 class_device.c, 1.11, 1.12 common.c, 1.5, 1.6 common.h, 1.2, 1.3
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
More information about the hal-commit
mailing list