gvfs r1176 - in trunk: . daemon hal
- From: alexl svn gnome org
- To: svn-commits-list gnome org
- Subject: gvfs r1176 - in trunk: . daemon hal
- Date: Thu, 24 Jan 2008 14:34:43 +0000 (GMT)
Author: alexl
Date: Thu Jan 24 14:34:43 2008
New Revision: 1176
URL: http://svn.gnome.org/viewvc/gvfs?rev=1176&view=rev
Log:
2008-01-24 Alexander Larsson <alexl redhat com>
* daemon/gvfsdaemon.c:
Indentation fix
* hal/ghaldrive.[ch]:
* hal/hal-device.c:
* hal/ghalvolume.c:
* hal/ghalmount.c:
Clean up coding style
* hal/ghalvolumemonitor.[ch]:
Clean up coding style
Don't show drives if we're ignoring all their
volumes (and there are volumes)
* hal/hal-pool.c:
Clean up coding style
Actually look at cap_only.
Free private dbus_connection on error
Modified:
trunk/ChangeLog
trunk/daemon/gvfsdaemon.c
trunk/hal/ghaldrive.c
trunk/hal/ghaldrive.h
trunk/hal/ghalmount.c
trunk/hal/ghalvolume.c
trunk/hal/ghalvolumemonitor.c
trunk/hal/ghalvolumemonitor.h
trunk/hal/hal-device.c
trunk/hal/hal-pool.c
Modified: trunk/daemon/gvfsdaemon.c
==============================================================================
--- trunk/daemon/gvfsdaemon.c (original)
+++ trunk/daemon/gvfsdaemon.c Thu Jan 24 14:34:43 2008
@@ -325,7 +325,7 @@
g_mutex_lock (daemon->lock);
daemon->job_sources = g_list_remove (daemon->job_sources,
- job_source);
+ job_source);
g_signal_handlers_disconnect_by_func (job_source,
(GCallback)job_source_new_job_callback,
Modified: trunk/hal/ghaldrive.c
==============================================================================
--- trunk/hal/ghaldrive.c (original)
+++ trunk/hal/ghaldrive.c Thu Jan 24 14:34:43 2008
@@ -170,15 +170,18 @@
if (hal_device_get_property_bool (d, "storage.cdrom.bdre"))
second = _("Blu-ray-RE");
- if (second != NULL) {
- /* translators: This wis something like "CD-ROM/DVD Drive" or
- "CD-RW/Blue-ray Drive" depending on the properties of the drive */
- s = g_strdup_printf (_("%s/%s Drive"), first, second);
- } else {
- /* translators: This wis something like "CD-ROM Drive" or "CD-RW Drive
- depending on the properties of the drive */
- s = g_strdup_printf (_("%s Drive"), first);
- }
+ if (second != NULL)
+ {
+ /* translators: This wis something like "CD-ROM/DVD Drive" or
+ "CD-RW/Blue-ray Drive" depending on the properties of the drive */
+ s = g_strdup_printf (_("%s/%s Drive"), first, second);
+ }
+ else
+ {
+ /* translators: This wis something like "CD-ROM Drive" or "CD-RW Drive
+ depending on the properties of the drive */
+ s = g_strdup_printf (_("%s Drive"), first);
+ }
}
else if (strcmp (drive_type, "floppy") == 0)
s = g_strdup (_("Floppy Drive"));
@@ -357,8 +360,8 @@
GHalDrive *
g_hal_drive_new (GVolumeMonitor *volume_monitor,
- HalDevice *device,
- HalPool *pool)
+ HalDevice *device,
+ HalPool *pool)
{
GHalDrive *drive;
Modified: trunk/hal/ghaldrive.h
==============================================================================
--- trunk/hal/ghaldrive.h (original)
+++ trunk/hal/ghaldrive.h Thu Jan 24 14:34:43 2008
@@ -46,22 +46,17 @@
GType g_hal_drive_get_type (void) G_GNUC_CONST;
void g_hal_drive_register (GIOModule *module);
-GHalDrive *g_hal_drive_new (GVolumeMonitor *volume_monitor,
- HalDevice *device,
- HalPool *pool);
-
-gboolean g_hal_drive_has_udi (GHalDrive *drive,
- const char *udi);
-
-void g_hal_drive_set_volume (GHalDrive *drive,
- GHalVolume *volume);
-
-void g_hal_drive_unset_volume (GHalDrive *drive,
- GHalVolume *volume);
-
-void g_hal_drive_disconnected (GHalDrive *drive);
-
-char *_drive_get_icon (HalDevice *d);
+GHalDrive *g_hal_drive_new (GVolumeMonitor *volume_monitor,
+ HalDevice *device,
+ HalPool *pool);
+gboolean g_hal_drive_has_udi (GHalDrive *drive,
+ const char *udi);
+void g_hal_drive_set_volume (GHalDrive *drive,
+ GHalVolume *volume);
+void g_hal_drive_unset_volume (GHalDrive *drive,
+ GHalVolume *volume);
+void g_hal_drive_disconnected (GHalDrive *drive);
+char * _drive_get_icon (HalDevice *d);
G_END_DECLS
Modified: trunk/hal/ghalmount.c
==============================================================================
--- trunk/hal/ghalmount.c (original)
+++ trunk/hal/ghalmount.c Thu Jan 24 14:34:43 2008
@@ -126,29 +126,29 @@
}
const static struct {
- const char *disc_type;
- const char *icon_name;
- char *ui_name;
- char *ui_name_blank;
+ const char *disc_type;
+ const char *icon_name;
+ char *ui_name;
+ char *ui_name_blank;
} disc_data[] = {
- {"cd_rom", "media-optical-cd-rom", N_("CD-ROM Disc"), N_("Blank CD-ROM Disc")},
- {"cd_r", "media-optical-cd-r", N_("CD-R Disc"), N_("Blank CD-R Disc")},
- {"cd_rw", "media-optical-cd-rw", N_("CD-RW Disc"), N_("Blank CD-RW Disc")},
- {"dvd_rom", "media-optical-dvd-rom", N_("DVD-ROM Disc"), N_("Blank DVD-ROM Disc")},
- {"dvd_ram", "media-optical-dvd-ram", N_("DVD-RAM Disc"), N_("Blank DVD-RAM Disc")},
- {"dvd_r", "media-optical-dvd-r", N_("DVD-ROM Disc"), N_("Blank DVD-ROM Disc")},
- {"dvd_rw", "media-optical-dvd-rw", N_("DVD-RW Disc"), N_("Blank DVD-RW Disc")},
- {"dvd_plus_r", "media-optical-dvd-r-plus", N_("DVD+R Disc"), N_("Blank DVD+R Disc")},
- {"dvd_plus_rw", "media-optical-dvd-rw-plus", N_("DVD+RW Disc"), N_("Blank DVD+RW Disc")},
- {"dvd_plus_r_dl", "media-optical-dvd-dl-r-plus", N_("DVD+R DL Disc"), N_("Blank DVD+R DL Disc")},
- {"bd_rom", "media-optical-bd-rom", N_("Blu-Ray Disc"), N_("Blank Blu-Ray Disc")},
- {"bd_r", "media-optical-bd-r", N_("Blu-Ray R Disc"), N_("Blank Blu-Ray R Disc")},
- {"bd_re", "media-optical-bd-re", N_("Blu-Ray RW Disc"), N_("Blank Blu-Ray RW Disc")},
- {"hddvd_rom", "media-optical-hddvd-rom", N_("HD DVD Disc"), N_("Blank HD DVD Disc")},
- {"hddvd_r", "media-optical-hddvd-r", N_("HD DVD-R Disc"), N_("Blank HD DVD-R Disc")},
- {"hddvd_rw", "media-optical-hddvd-rw", N_("HD DVD-RW Disc"), N_("Blank HD DVD-RW Disc")},
- {"mo", "media-optical-mo", N_("MO Disc"), N_("Blank MO Disc")},
- {NULL, "media-optical", N_("Disc"), N_("Blank Disc")},
+ {"cd_rom", "media-optical-cd-rom", N_("CD-ROM Disc"), N_("Blank CD-ROM Disc")},
+ {"cd_r", "media-optical-cd-r", N_("CD-R Disc"), N_("Blank CD-R Disc")},
+ {"cd_rw", "media-optical-cd-rw", N_("CD-RW Disc"), N_("Blank CD-RW Disc")},
+ {"dvd_rom", "media-optical-dvd-rom", N_("DVD-ROM Disc"), N_("Blank DVD-ROM Disc")},
+ {"dvd_ram", "media-optical-dvd-ram", N_("DVD-RAM Disc"), N_("Blank DVD-RAM Disc")},
+ {"dvd_r", "media-optical-dvd-r", N_("DVD-ROM Disc"), N_("Blank DVD-ROM Disc")},
+ {"dvd_rw", "media-optical-dvd-rw", N_("DVD-RW Disc"), N_("Blank DVD-RW Disc")},
+ {"dvd_plus_r", "media-optical-dvd-r-plus", N_("DVD+R Disc"), N_("Blank DVD+R Disc")},
+ {"dvd_plus_rw", "media-optical-dvd-rw-plus", N_("DVD+RW Disc"), N_("Blank DVD+RW Disc")},
+ {"dvd_plus_r_dl", "media-optical-dvd-dl-r-plus", N_("DVD+R DL Disc"), N_("Blank DVD+R DL Disc")},
+ {"bd_rom", "media-optical-bd-rom", N_("Blu-Ray Disc"), N_("Blank Blu-Ray Disc")},
+ {"bd_r", "media-optical-bd-r", N_("Blu-Ray R Disc"), N_("Blank Blu-Ray R Disc")},
+ {"bd_re", "media-optical-bd-re", N_("Blu-Ray RW Disc"), N_("Blank Blu-Ray RW Disc")},
+ {"hddvd_rom", "media-optical-hddvd-rom", N_("HD DVD Disc"), N_("Blank HD DVD Disc")},
+ {"hddvd_r", "media-optical-hddvd-r", N_("HD DVD-R Disc"), N_("Blank HD DVD-R Disc")},
+ {"hddvd_rw", "media-optical-hddvd-rw", N_("HD DVD-RW Disc"), N_("Blank HD DVD-RW Disc")},
+ {"mo", "media-optical-mo", N_("MO Disc"), N_("Blank MO Disc")},
+ {NULL, "media-optical", N_("Disc"), N_("Blank Disc")},
};
static const char *
@@ -246,22 +246,24 @@
volume_disc_is_blank = hal_device_get_property_bool (volume, "volume.disc.is_blank");
volume_disc_type = hal_device_get_property_string (volume, "volume.disc.type");
- //g_warning ("drive_type='%s'", drive_type);
- //g_warning ("drive_bus='%s'", drive_bus);
- //g_warning ("drive_uses_removable_media=%d", drive_uses_removable_media);
-
- if (strcmp (drive_type, "disk") == 0) {
- if (strcmp (drive_bus, "ide") == 0)
- icon_name = "drive-harddisk-ata";
- else if (strcmp (drive_bus, "scsi") == 0)
- icon_name = "drive-harddisk-scsi";
- else if (strcmp (drive_bus, "ieee1394") == 0)
- icon_name = "drive-harddisk-ieee1394";
- else if (strcmp (drive_bus, "usb") == 0)
- icon_name = "drive-harddisk-usb";
- else
- icon_name = "drive-harddisk";
- } else if (strcmp (drive_type, "cdrom") == 0)
+ /*g_warning ("drive_type='%s'", drive_type); */
+ /*g_warning ("drive_bus='%s'", drive_bus); */
+ /*g_warning ("drive_uses_removable_media=%d", drive_uses_removable_media); */
+
+ if (strcmp (drive_type, "disk") == 0)
+ {
+ if (strcmp (drive_bus, "ide") == 0)
+ icon_name = "drive-harddisk-ata";
+ else if (strcmp (drive_bus, "scsi") == 0)
+ icon_name = "drive-harddisk-scsi";
+ else if (strcmp (drive_bus, "ieee1394") == 0)
+ icon_name = "drive-harddisk-ieee1394";
+ else if (strcmp (drive_bus, "usb") == 0)
+ icon_name = "drive-harddisk-usb";
+ else
+ icon_name = "drive-harddisk";
+ }
+ else if (strcmp (drive_type, "cdrom") == 0)
icon_name = g_strdup (get_disc_icon (volume_disc_type));
else if (strcmp (drive_type, "floppy") == 0)
icon_name = "media-floppy";
@@ -279,20 +281,22 @@
icon_name = "drive-harddisk";
- if (volume_fs_label != NULL && strlen (volume_fs_label) > 0) {
+ if (volume_fs_label != NULL && strlen (volume_fs_label) > 0)
name = g_strdup (volume_fs_label);
- } else if (volume_is_disc) {
- if (volume_disc_has_audio) {
- if (volume_disc_has_data)
- name = g_strdup (_("Mixed Audio/Data Disc"));
+ else if (volume_is_disc)
+ {
+ if (volume_disc_has_audio)
+ {
+ if (volume_disc_has_data)
+ name = g_strdup (_("Mixed Audio/Data Disc"));
+ else
+ name = g_strdup (_("Audio Disc"));
+ }
else
- name = g_strdup (_("Audio Disc"));
- } else {
- name = g_strdup (get_disc_name (volume_disc_type, volume_disc_is_blank));
+ name = g_strdup (get_disc_name (volume_disc_type, volume_disc_is_blank));
}
- } else {
+ else
name = format_size_for_display (volume_size);
- }
if (m->override_name != NULL)
{
@@ -300,18 +304,12 @@
g_free (name);
}
else
- {
- m->name = name;
- }
+ m->name = name;
if (m->override_icon != NULL)
- {
- m->icon = g_object_ref (m->override_icon);
- }
+ m->icon = g_object_ref (m->override_icon);
else
- {
- m->icon = g_themed_icon_new_with_default_fallbacks (icon_name);
- }
+ m->icon = g_themed_icon_new_with_default_fallbacks (icon_name);
}
@@ -351,7 +349,7 @@
{
GHalMount *hal_mount = G_HAL_MOUNT (user_data);
- //g_warning ("mounthal modifying %s (property %s changed)", hal_mount->device_path, key);
+ /*g_warning ("mounthal modifying %s (property %s changed)", hal_mount->device_path, key); */
update_from_hal (hal_mount, TRUE);
}
@@ -369,18 +367,12 @@
if (strlen (fs_uuid) == 0)
{
if (strlen (fs_label) == 0)
- {
- mount->uuid = NULL;
- }
+ mount->uuid = NULL;
else
- {
- mount->uuid = g_strdup (fs_label);
- }
+ mount->uuid = g_strdup (fs_label);
}
else
- {
- mount->uuid = g_strdup (fs_uuid);
- }
+ mount->uuid = g_strdup (fs_uuid);
}
@@ -402,13 +394,13 @@
if (storage_udi == NULL)
goto fail;
- //g_warning ("storage_udi = %s", storage_udi);
+ /* g_warning ("storage_udi = %s", storage_udi); */
drive_device = hal_pool_get_device_by_udi (pool, storage_udi);
if (drive_device == NULL)
goto fail;
- //g_warning ("drive_device = %p", drive_device);
+ /* g_warning ("drive_device = %p", drive_device); */
mount = g_object_new (G_TYPE_HAL_MOUNT, NULL);
mount->volume_monitor = volume_monitor;
@@ -497,22 +489,22 @@
"volume",
"block.device",
mount->device_path);
- //g_warning ("device = %p for %s", device, mount->device_path);
+ /* g_warning ("device = %p for %s", device, mount->device_path); */
if (device != NULL)
{
- //g_warning ("udi = %s", hal_device_get_udi (device));
-
+ /* g_warning ("udi = %s", hal_device_get_udi (device)); */
+
storage_udi = hal_device_get_property_string (device, "block.storage_device");
if (storage_udi == NULL)
goto not_hal;
- //g_warning ("storage_udi = %s", storage_udi);
+ /* g_warning ("storage_udi = %s", storage_udi); */
drive_device = hal_pool_get_device_by_udi (pool, storage_udi);
if (drive_device == NULL)
goto not_hal;
- //g_warning ("drive_device = %p", drive_device);
+ /* g_warning ("drive_device = %p", drive_device); */
mount->device = g_object_ref (device);
mount->drive_device = g_object_ref (drive_device);
@@ -791,18 +783,19 @@
NULL, /* standard_input */
NULL, /* standard_output */
&(data->error_fd),
- &error)) {
- GSimpleAsyncResult *simple;
- simple = g_simple_async_result_new_from_error (data->object,
- data->callback,
- data->user_data,
- error);
- g_simple_async_result_complete (simple);
- g_object_unref (simple);
- g_error_free (error);
- g_free (data);
- return;
- }
+ &error))
+ {
+ GSimpleAsyncResult *simple;
+ simple = g_simple_async_result_new_from_error (data->object,
+ data->callback,
+ data->user_data,
+ error);
+ g_simple_async_result_complete (simple);
+ g_object_unref (simple);
+ g_error_free (error);
+ g_free (data);
+ return;
+ }
data->error_string = g_string_new ("");
data->error_channel = g_io_channel_unix_new (data->error_fd);
data->error_channel_source_id = g_io_add_watch (data->error_channel, G_IO_IN, unmount_read_error, data);
@@ -822,9 +815,7 @@
gboolean using_legacy = FALSE;
if (hal_mount->device != NULL)
- {
- argv[4] = hal_mount->device_path;
- }
+ argv[4] = hal_mount->device_path;
else
{
using_legacy = TRUE;
Modified: trunk/hal/ghalvolume.c
==============================================================================
--- trunk/hal/ghalvolume.c (original)
+++ trunk/hal/ghalvolume.c Thu Jan 24 14:34:43 2008
@@ -130,29 +130,29 @@
}
const static struct {
- const char *disc_type;
- const char *icon_name;
- char *ui_name;
- char *ui_name_blank;
+ const char *disc_type;
+ const char *icon_name;
+ char *ui_name;
+ char *ui_name_blank;
} disc_data[] = {
- {"cd_rom", "media-optical-cd-rom", N_("CD-ROM Disc"), N_("Blank CD-ROM Disc")},
- {"cd_r", "media-optical-cd-r", N_("CD-R Disc"), N_("Blank CD-R Disc")},
- {"cd_rw", "media-optical-cd-rw", N_("CD-RW Disc"), N_("Blank CD-RW Disc")},
- {"dvd_rom", "media-optical-dvd-rom", N_("DVD-ROM Disc"), N_("Blank DVD-ROM Disc")},
- {"dvd_ram", "media-optical-dvd-ram", N_("DVD-RAM Disc"), N_("Blank DVD-RAM Disc")},
- {"dvd_r", "media-optical-dvd-r", N_("DVD-ROM Disc"), N_("Blank DVD-ROM Disc")},
- {"dvd_rw", "media-optical-dvd-rw", N_("DVD-RW Disc"), N_("Blank DVD-RW Disc")},
- {"dvd_plus_r", "media-optical-dvd-r-plus", N_("DVD+R Disc"), N_("Blank DVD+R Disc")},
- {"dvd_plus_rw", "media-optical-dvd-rw-plus", N_("DVD+RW Disc"), N_("Blank DVD+RW Disc")},
- {"dvd_plus_r_dl", "media-optical-dvd-dl-r-plus", N_("DVD+R DL Disc"), N_("Blank DVD+R DL Disc")},
- {"bd_rom", "media-optical-bd-rom", N_("Blu-Ray Disc"), N_("Blank Blu-Ray Disc")},
- {"bd_r", "media-optical-bd-r", N_("Blu-Ray R Disc"), N_("Blank Blu-Ray R Disc")},
- {"bd_re", "media-optical-bd-re", N_("Blu-Ray RW Disc"), N_("Blank Blu-Ray RW Disc")},
- {"hddvd_rom", "media-optical-hddvd-rom", N_("HD DVD Disc"), N_("Blank HD DVD Disc")},
- {"hddvd_r", "media-optical-hddvd-r", N_("HD DVD-R Disc"), N_("Blank HD DVD-R Disc")},
- {"hddvd_rw", "media-optical-hddvd-rw", N_("HD DVD-RW Disc"), N_("Blank HD DVD-RW Disc")},
- {"mo", "media-optical-mo", N_("MO Disc"), N_("Blank MO Disc")},
- {NULL, "media-optical", N_("Disc"), N_("Blank Disc")},
+ {"cd_rom", "media-optical-cd-rom", N_("CD-ROM Disc"), N_("Blank CD-ROM Disc")},
+ {"cd_r", "media-optical-cd-r", N_("CD-R Disc"), N_("Blank CD-R Disc")},
+ {"cd_rw", "media-optical-cd-rw", N_("CD-RW Disc"), N_("Blank CD-RW Disc")},
+ {"dvd_rom", "media-optical-dvd-rom", N_("DVD-ROM Disc"), N_("Blank DVD-ROM Disc")},
+ {"dvd_ram", "media-optical-dvd-ram", N_("DVD-RAM Disc"), N_("Blank DVD-RAM Disc")},
+ {"dvd_r", "media-optical-dvd-r", N_("DVD-ROM Disc"), N_("Blank DVD-ROM Disc")},
+ {"dvd_rw", "media-optical-dvd-rw", N_("DVD-RW Disc"), N_("Blank DVD-RW Disc")},
+ {"dvd_plus_r", "media-optical-dvd-r-plus", N_("DVD+R Disc"), N_("Blank DVD+R Disc")},
+ {"dvd_plus_rw", "media-optical-dvd-rw-plus", N_("DVD+RW Disc"), N_("Blank DVD+RW Disc")},
+ {"dvd_plus_r_dl", "media-optical-dvd-dl-r-plus", N_("DVD+R DL Disc"), N_("Blank DVD+R DL Disc")},
+ {"bd_rom", "media-optical-bd-rom", N_("Blu-Ray Disc"), N_("Blank Blu-Ray Disc")},
+ {"bd_r", "media-optical-bd-r", N_("Blu-Ray R Disc"), N_("Blank Blu-Ray R Disc")},
+ {"bd_re", "media-optical-bd-re", N_("Blu-Ray RW Disc"), N_("Blank Blu-Ray RW Disc")},
+ {"hddvd_rom", "media-optical-hddvd-rom", N_("HD DVD Disc"), N_("Blank HD DVD Disc")},
+ {"hddvd_r", "media-optical-hddvd-r", N_("HD DVD-R Disc"), N_("Blank HD DVD-R Disc")},
+ {"hddvd_rw", "media-optical-hddvd-rw", N_("HD DVD-RW Disc"), N_("Blank HD DVD-RW Disc")},
+ {"mo", "media-optical-mo", N_("MO Disc"), N_("Blank MO Disc")},
+ {NULL, "media-optical", N_("Disc"), N_("Blank Disc")},
};
static const char *
@@ -239,33 +239,38 @@
volume_fstype = hal_device_get_property_string (volume, "volume.fstype");
if (volume_is_disc && volume_disc_has_audio && mv->foreign_mount_root != NULL)
- {
- name = g_strdup (_("Audio Disc"));
- }
+ name = g_strdup (_("Audio Disc"));
else
{
- if (strcmp (volume_fsusage, "crypto") == 0 && strcmp (volume_fstype, "crypto_LUKS") == 0) {
- size = format_size_for_display (volume_size);
- name = g_strdup_printf (_("%s Encrypted Data"), size);
- g_free (size);
- } else {
- if (volume_fs_label != NULL && strlen (volume_fs_label) > 0) {
- name = g_strdup (volume_fs_label);
- } else if (volume_is_disc) {
- if (volume_disc_has_audio) {
- if (volume_disc_has_data)
- name = g_strdup (_("Mixed Audio/Data Disc"));
- else
- name = g_strdup (_("Audio Disc"));
- } else {
- name = g_strdup (get_disc_name (volume_disc_type, volume_disc_is_blank));
- }
- } else {
+ if (strcmp (volume_fsusage, "crypto") == 0 && strcmp (volume_fstype, "crypto_LUKS") == 0)
+ {
size = format_size_for_display (volume_size);
- name = g_strdup_printf (_("%s Media"), size);
+ name = g_strdup_printf (_("%s Encrypted Data"), size);
g_free (size);
}
- }
+ else
+ {
+ if (volume_fs_label != NULL && strlen (volume_fs_label) > 0)
+ name = g_strdup (volume_fs_label);
+ else if (volume_is_disc)
+ {
+ if (volume_disc_has_audio)
+ {
+ if (volume_disc_has_data)
+ name = g_strdup (_("Mixed Audio/Data Disc"));
+ else
+ name = g_strdup (_("Audio Disc"));
+ }
+ else
+ name = g_strdup (get_disc_name (volume_disc_type, volume_disc_is_blank));
+ }
+ else
+ {
+ size = format_size_for_display (volume_size);
+ name = g_strdup_printf (_("%s Media"), size);
+ g_free (size);
+ }
+ }
}
mv->name = name;
@@ -339,7 +344,7 @@
else
do_update_from_hal (mv);
#else
- do_update_from_hal (mv);
+ do_update_from_hal (mv);
#endif
if (emit_changed)
@@ -392,18 +397,12 @@
if (strlen (fs_uuid) == 0)
{
if (strlen (fs_label) == 0)
- {
- volume->uuid = NULL;
- }
+ volume->uuid = NULL;
else
- {
- volume->uuid = g_strdup (fs_label);
- }
+ volume->uuid = g_strdup (fs_label);
}
else
- {
- volume->uuid = g_strdup (fs_uuid);
- }
+ volume->uuid = g_strdup (fs_uuid);
}
GHalVolume *
@@ -772,18 +771,19 @@
NULL, /* child_setup */
NULL, /* user_data for child_setup */
&child_pid,
- &error)) {
- GSimpleAsyncResult *simple;
- simple = g_simple_async_result_new_from_error (data->object,
- data->callback,
- data->user_data,
- error);
- g_simple_async_result_complete (simple);
- g_object_unref (simple);
- g_error_free (error);
- g_free (data);
- return;
- }
+ &error))
+ {
+ GSimpleAsyncResult *simple;
+ simple = g_simple_async_result_new_from_error (data->object,
+ data->callback,
+ data->user_data,
+ error);
+ g_simple_async_result_complete (simple);
+ g_object_unref (simple);
+ g_error_free (error);
+ g_free (data);
+ return;
+ }
g_child_watch_add (child_pid, spawn_cb, data);
}
@@ -853,13 +853,9 @@
GHalVolume *hal_volume = G_HAL_VOLUME (volume);
if (hal_volume->foreign_mount_root != NULL)
- {
- return g_file_mount_enclosing_volume_finish (hal_volume->foreign_mount_root, result, error);
- }
- else
- {
- return TRUE;
- }
+ return g_file_mount_enclosing_volume_finish (hal_volume->foreign_mount_root, result, error);
+
+ return TRUE;
}
typedef struct {
@@ -908,9 +904,7 @@
GHalVolume *hal_volume = G_HAL_VOLUME (volume);
if (hal_volume->drive != NULL)
- {
- return g_drive_eject_finish (G_DRIVE (hal_volume->drive), result, error);
- }
+ return g_drive_eject_finish (G_DRIVE (hal_volume->drive), result, error);
return TRUE;
}
Modified: trunk/hal/ghalvolumemonitor.c
==============================================================================
--- trunk/hal/ghalvolumemonitor.c (original)
+++ trunk/hal/ghalvolumemonitor.c Thu Jan 24 14:34:43 2008
@@ -80,6 +80,7 @@
static void hal_changed (HalPool *pool,
HalDevice *device,
gpointer user_data);
+static void update_all (GHalVolumeMonitor *monitor);
static void update_drives (GHalVolumeMonitor *monitor);
static void update_volumes (GHalVolumeMonitor *monitor);
static void update_mounts (GHalVolumeMonitor *monitor);
@@ -212,14 +213,14 @@
{
volume = l->data;
if (g_hal_volume_has_uuid (volume, uuid))
- goto found;
+ goto found;
}
for (l = monitor->disc_volumes; l != NULL; l = l->next)
{
volume = l->data;
if (g_hal_volume_has_uuid (volume, uuid))
- goto found;
+ goto found;
}
return NULL;
@@ -244,14 +245,14 @@
{
mount = l->data;
if (g_hal_mount_has_uuid (mount, uuid))
- goto found;
+ goto found;
}
for (l = monitor->disc_mounts; l != NULL; l = l->next)
{
mount = l->data;
if (g_hal_mount_has_uuid (mount, uuid))
- goto found;
+ goto found;
}
return NULL;
@@ -283,9 +284,7 @@
volume_monitor = G_HAL_VOLUME_MONITOR (g_hal_volume_monitor_new ());
}
else
- {
- volume_monitor = g_object_ref (the_volume_monitor);
- }
+ volume_monitor = g_object_ref (the_volume_monitor);
/* creation of the volume monitor might actually fail */
if (volume_monitor != NULL)
@@ -315,11 +314,7 @@
{
GHalVolumeMonitor *monitor = G_HAL_VOLUME_MONITOR (user_data);
- update_drives (monitor);
- update_volumes (monitor);
- update_mounts (monitor);
- update_discs (monitor);
- update_cameras (monitor);
+ update_all (monitor);
}
static void
@@ -328,21 +323,13 @@
{
GHalVolumeMonitor *monitor = G_HAL_VOLUME_MONITOR (user_data);
- update_drives (monitor);
- update_volumes (monitor);
- update_mounts (monitor);
- update_discs (monitor);
- update_cameras (monitor);
+ update_all (monitor);
}
void
g_hal_volume_monitor_force_update (GHalVolumeMonitor *monitor)
{
- update_drives (monitor);
- update_volumes (monitor);
- update_mounts (monitor);
- update_discs (monitor);
- update_cameras (monitor);
+ update_all (monitor);
}
static void
@@ -354,11 +341,7 @@
/*g_warning ("hal changed");*/
- update_drives (monitor);
- update_volumes (monitor);
- update_mounts (monitor);
- update_discs (monitor);
- update_cameras (monitor);
+ update_all (monitor);
}
static GObject *
@@ -409,11 +392,7 @@
"device_removed", G_CALLBACK (hal_changed),
monitor);
- update_drives (monitor);
- update_volumes (monitor);
- update_mounts (monitor);
- update_discs (monitor);
- update_cameras (monitor);
+ update_all (monitor);
the_volume_monitor = monitor;
@@ -458,6 +437,7 @@
for (l = the_volume_monitor->disc_volumes; l != NULL; l = l->next)
{
GHalVolume *volume = l->data;
+
if (g_hal_volume_has_foreign_mount_root (volume, mount_root))
{
g_hal_volume_adopt_foreign_mount (volume, mount);
@@ -465,7 +445,7 @@
break;
}
}
-
+
g_object_unref (mount_root);
return ret;
}
@@ -554,7 +534,7 @@
GHalVolume *
g_hal_volume_monitor_lookup_volume_for_mount_path (GHalVolumeMonitor *monitor,
- const char *mount_path)
+ const char *mount_path)
{
GList *l;
@@ -645,7 +625,7 @@
for (l = monitor->disc_mounts; l != NULL; l = l->next)
{
GHalMount *mount = l->data;
-
+
if (g_hal_mount_has_udi (mount, udi))
return mount;
}
@@ -694,7 +674,7 @@
}
static gboolean
-_should_volume_be_ignored (HalPool *pool, HalDevice *d)
+should_volume_be_ignored (HalPool *pool, HalDevice *d)
{
gboolean volume_ignore;
const char *volume_fsusage;
@@ -739,15 +719,72 @@
return FALSE;
}
+static gboolean
+should_drive_be_ignored (HalPool *pool, HalDevice *d)
+{
+ GList *volumes, *l;
+ const char *drive_udi;
+ gboolean all_volumes_ignored, got_volumes;
+
+ drive_udi = hal_device_get_udi (d);
+ g_print ("should_drive_be_ignored %s\n", drive_udi);
+
+ volumes = hal_pool_find_by_capability (pool, "volume");
+
+ all_volumes_ignored = TRUE;
+ got_volumes = FALSE;
+ for (l = volumes; l != NULL; l = l->next)
+ {
+ HalDevice *volume_dev = l->data;
+ g_print ("volume udi: %s\n", hal_device_get_udi (volume_dev));
+ if (strcmp (drive_udi, hal_device_get_property_string (volume_dev, "block.storage_device")) == 0)
+ {
+ got_volumes = TRUE;
+ if (!should_volume_be_ignored (pool, volume_dev))
+ {
+ all_volumes_ignored = FALSE;
+ break;
+ }
+ }
+ }
+
+ g_print ("got_volumes: %d, all_ignored: %d\n",
+ got_volumes, all_volumes_ignored);
+
+ return got_volumes && all_volumes_ignored;
+}
+
+static void
+update_all (GHalVolumeMonitor *monitor)
+{
+ update_drives (monitor);
+ update_volumes (monitor);
+ update_mounts (monitor);
+ update_discs (monitor);
+ update_cameras (monitor);
+}
+
static void
update_drives (GHalVolumeMonitor *monitor)
{
GList *new_drive_devices;
GList *removed, *added;
- GList *l;
+ GList *l, *ll;
GHalDrive *drive;
new_drive_devices = hal_pool_find_by_capability (monitor->pool, "storage");
+
+ /* remove devices we want to ignore - we do it here so we get to reevaluate
+ * on the next update whether they should still be ignored
+ */
+ for (l = new_drive_devices; l != NULL; l = ll)
+ {
+ HalDevice *d = l->data;
+ ll = l->next;
+ if (should_drive_be_ignored (monitor->pool, d))
+ new_drive_devices = g_list_delete_link (new_drive_devices, l);
+ }
+
g_list_foreach (new_drive_devices, (GFunc) g_object_ref, NULL);
new_drive_devices = g_list_sort (new_drive_devices, (GCompareFunc) hal_device_compare);
@@ -810,9 +847,9 @@
*/
for (l = new_volume_devices; l != NULL; l = ll)
{
- ll = l->next;
HalDevice *d = l->data;
- if (_should_volume_be_ignored (monitor->pool, d))
+ ll = l->next;
+ if (should_volume_be_ignored (monitor->pool, d))
new_volume_devices = g_list_delete_link (new_volume_devices, l);
}
@@ -847,7 +884,7 @@
if (volume == NULL)
{
drive = find_drive_by_udi (monitor, hal_device_get_property_string (d, "block.storage_device"));
-
+
/*g_warning ("hal adding vol %s (drive %p)", hal_device_get_property_string (d, "block.device"), drive);*/
volume = g_hal_volume_new (G_VOLUME_MONITOR (monitor), d, monitor->pool, NULL, TRUE, drive);
if (volume != NULL)
@@ -907,9 +944,8 @@
device_path = g_unix_mount_get_device_path (mount_entry);
mount_path = g_unix_mount_get_mount_path (mount_entry);
volume = g_hal_volume_monitor_lookup_volume_for_device_path (monitor, device_path);
- if (volume == NULL) {
+ if (volume == NULL)
volume = g_hal_volume_monitor_lookup_volume_for_mount_path (monitor, mount_path);
- }
/*g_warning ("hal adding mount %s (vol %p)", g_unix_mount_get_device_path (mount_entry), volume);*/
mount = g_hal_mount_new (G_VOLUME_MONITOR (monitor), mount_entry, monitor->pool, volume);
@@ -936,7 +972,7 @@
GList *l, *ll;
GHalDrive *drive;
GHalVolume *volume;
- GHalMount *mount = NULL;
+ GHalMount *mount;
const char *udi;
const char *drive_udi;
@@ -950,8 +986,8 @@
new_optical_disc_devices = hal_pool_find_by_capability (monitor->pool, "volume.disc");
for (l = new_optical_disc_devices; l != NULL; l = ll)
{
- ll = l->next;
HalDevice *d = l->data;
+ ll = l->next;
if (! (hal_device_get_property_bool (d, "volume.disc.is_blank") ||
hal_device_get_property_bool (d, "volume.disc.has_audio")))
{
@@ -1006,23 +1042,23 @@
drive = find_drive_by_udi (monitor, drive_udi);
if (drive != NULL)
{
+ mount = NULL;
if (hal_device_get_property_bool (d, "volume.disc.is_blank"))
{
- /* burn:/// is not mountable ... */
volume = g_hal_volume_new (G_VOLUME_MONITOR (monitor), d, monitor->pool, NULL, FALSE, drive);
if (volume != NULL)
{
- GFile *file;
- file = g_file_new_for_uri ("burn:///");
+ GFile *root;
+ root = g_file_new_for_uri ("burn:///");
mount = g_hal_mount_new_for_hal_device (G_VOLUME_MONITOR (monitor),
d,
- file,
+ root,
NULL,
NULL,
TRUE,
monitor->pool,
volume);
- g_object_unref (file);
+ g_object_unref (root);
}
}
else
@@ -1077,8 +1113,8 @@
new_camera_devices = hal_pool_find_by_capability (monitor->pool, "camera");
for (l = new_camera_devices; l != NULL; l = ll)
{
- ll = l->next;
HalDevice *d = l->data;
+ ll = l->next;
/*g_warning ("got %s", hal_device_get_udi (d));*/
if (! hal_device_get_property_bool (d, "camera.libgphoto2.support"))
{
Modified: trunk/hal/ghalvolumemonitor.h
==============================================================================
--- trunk/hal/ghalvolumemonitor.h (original)
+++ trunk/hal/ghalvolumemonitor.h Thu Jan 24 14:34:43 2008
@@ -57,13 +57,14 @@
GType g_hal_volume_monitor_get_type (void) G_GNUC_CONST;
-GVolumeMonitor *g_hal_volume_monitor_new (void);
+GVolumeMonitor *g_hal_volume_monitor_new (void);
GHalVolume *g_hal_volume_monitor_lookup_volume_for_mount_path (GHalVolumeMonitor *monitor,
- const char *mount_path);
+ const char *mount_path);
-void g_hal_volume_monitor_force_update (GHalVolumeMonitor *monitor);
+void g_hal_volume_monitor_force_update (GHalVolumeMonitor *monitor);
+
+void g_hal_volume_monitor_register (GIOModule *module);
-void g_hal_volume_monitor_register (GIOModule *module);
G_END_DECLS
Modified: trunk/hal/hal-device.c
==============================================================================
--- trunk/hal/hal-device.c (original)
+++ trunk/hal/hal-device.c Thu Jan 24 14:34:43 2008
@@ -97,6 +97,7 @@
hal_device_get_property_string (HalDevice *device, const char *key)
{
const char *ret;
+
ret = libhal_ps_get_string (device->priv->properties, key);
if (ret != NULL)
return ret;
@@ -134,6 +135,7 @@
{
static char * empty[1] = {NULL};
char **ret;
+
ret = (char **) libhal_ps_get_strlist (device->priv->properties, key);
if (ret != NULL)
return (char **) ret;
@@ -153,12 +155,14 @@
caps = hal_device_get_property_strlist (device, "info.capabilities");
if (caps == NULL)
goto out;
+
for (n = 0; caps[n] != NULL; n++)
{
- if (g_ascii_strcasecmp (caps[n], capability) == 0) {
- ret = TRUE;
- break;
- }
+ if (g_ascii_strcasecmp (caps[n], capability) == 0)
+ {
+ ret = TRUE;
+ break;
+ }
}
out:
@@ -175,7 +179,8 @@
ret = FALSE;
ifs = hal_device_get_property_strlist (device, "info.interfaces");
if (ifs == NULL)
- goto out;
+ goto out;
+
for (n = 0; ifs[n] != NULL; n++)
{
if (g_ascii_strcasecmp (ifs[n], interface) == 0)
@@ -186,7 +191,7 @@
}
out:
- return ret;
+ return ret;
}
gboolean
@@ -200,14 +205,16 @@
goto out;
libhal_psi_init (&it, device->priv->properties);
+
while (libhal_psi_has_more (&it))
{
- char *pkey;
- pkey = libhal_psi_get_key (&it);
- if (pkey != NULL && g_ascii_strcasecmp (pkey, key) == 0) {
- ret = TRUE;
- break;
- }
+ char *pkey = libhal_psi_get_key (&it);
+
+ if (pkey != NULL && g_ascii_strcasecmp (pkey, key) == 0)
+ {
+ ret = TRUE;
+ break;
+ }
libhal_psi_next (&it);
}
Modified: trunk/hal/hal-pool.c
==============================================================================
--- trunk/hal/hal-pool.c (original)
+++ trunk/hal/hal-pool.c Thu Jan 24 14:34:43 2008
@@ -139,17 +139,12 @@
{
unsigned int n;
- if (pool->priv->cap_only)
- return TRUE;
-
- for (n = 0; pool->priv->cap_only[n] != NULL; n++)
+ for (n = 0; pool->priv->cap_only != NULL && pool->priv->cap_only[n] != NULL; n++)
{
if (hal_device_has_capability (device, pool->priv->cap_only[n]))
- {
- return TRUE;
- }
+ return TRUE;
}
-
+
return FALSE;
}
@@ -159,14 +154,12 @@
gboolean emit_signal)
{
HalDevice *device;
- device = hal_device_new_from_udi (pool->priv->hal_ctx, udi);
+ device = hal_device_new_from_udi (pool->priv->hal_ctx, udi);
if (device != NULL)
{
if (!has_cap_only (pool, device))
- {
- g_object_unref (device);
- }
+ g_object_unref (device);
else
{
g_hash_table_insert (pool->priv->devices, g_strdup (udi), device);
@@ -184,14 +177,12 @@
gboolean emit_signal)
{
HalDevice *device;
- device = hal_device_new_from_udi_and_properties (pool->priv->hal_ctx, udi, properties);
+ device = hal_device_new_from_udi_and_properties (pool->priv->hal_ctx, udi, properties);
if (device != NULL)
{
if (!has_cap_only (pool, device))
- {
- g_object_unref (device);
- }
+ g_object_unref (device);
else
{
g_hash_table_insert (pool->priv->devices, g_strdup (udi), device);
@@ -314,6 +305,8 @@
hal_ctx = libhal_ctx_new ();
if (hal_ctx == NULL)
{
+ dbus_connection_close (dbus_connection);
+ dbus_connection_unref (dbus_connection);
goto out;
}
@@ -322,6 +315,8 @@
if (!libhal_ctx_init (hal_ctx, &error))
{
+ dbus_connection_close (dbus_connection);
+ dbus_connection_unref (dbus_connection);
dbus_error_free (&error);
goto out;
}
@@ -357,7 +352,7 @@
NULL))
{
for (i = 0; i < num_devices; i++)
- hal_pool_add_device_by_udi_and_properties (pool, devices[i], properties[i], FALSE);
+ hal_pool_add_device_by_udi_and_properties (pool, devices[i], properties[i], FALSE);
/* _add_device_by_udi_and_properties steals the given parameters */
free (devices);
free (properties);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]