[PATCH] Process coldplug events as well



Make sure to process the devices that are already plugged in
when the volume monitor starts, otherwise they'll need to be
plugged out and plugged in again.
---
 monitor/afc/afc-volume-monitor.c |   11 +++++++++++
 1 files changed, 11 insertions(+), 0 deletions(-)

diff --git a/monitor/afc/afc-volume-monitor.c b/monitor/afc/afc-volume-monitor.c
index 7687b67..0c2fda5 100644
--- a/monitor/afc/afc-volume-monitor.c
+++ b/monitor/afc/afc-volume-monitor.c
@@ -145,6 +145,8 @@ static GObject *g_vfs_afc_volume_monitor_constructor(GType type, guint ncps,
 {
     DBusError err;
     GVfsAfcVolumeMonitor *self;
+    int num_devices;
+    char **udis;
 
     /* Boilerplate code to chain from parent. */
     self = G_VFS_AFC_VOLUME_MONITOR((*G_OBJECT_CLASS(
@@ -175,6 +177,14 @@ static GObject *g_vfs_afc_volume_monitor_constructor(GType type, guint ncps,
 
     self->volumes = NULL;
 
+    udis = libhal_find_device_by_capability (self->ctx, "afc", &num_devices, NULL);
+    if (udis != NULL) {
+      guint i;
+      for (i = 0; i < num_devices; i++)
+        g_vfs_afc_monitor_device_added (self->ctx, udis[i]);
+      libhal_free_string_array (udis);
+    }
+
     fprintf(stderr, "Volume monitor alive\n");
 
     return G_OBJECT(self);
@@ -286,6 +296,7 @@ static void g_vfs_afc_volume_monitor_class_init(GVfsAfcVolumeMonitorClass *
 
 static void g_vfs_afc_volume_monitor_init(GVfsAfcVolumeMonitor *self)
 {
+
 }
 
 GVolumeMonitor *g_vfs_afc_volume_monitor_new(void)
-- 
1.6.2.5


--=-L5CFtjgByoQ19yk1oszb--



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]