diff options
author | Ayan George <ayan.george@canonical.com> | 2011-06-23 13:27:06 -0400 |
---|---|---|
committer | David Zeuthen <davidz@redhat.com> | 2011-06-23 13:27:06 -0400 |
commit | 858adbac9dce63da52764b2d2157bc7782b304a5 (patch) | |
tree | d229cb56c1750f8788f2b667b9a5ae5913ed2514 | |
parent | 2d0272eb3be71f6ee3f52c55a3d608764b675fb0 (diff) |
Bug 38535 – A DeviceAutoMountHint attribute should be added to udisks
With minor changes by David Zeuthen, see the bug for details.
https://bugs.freedesktop.org/show_bug.cgi?id=38535
Signed-off-by: David Zeuthen <davidz@redhat.com>
-rw-r--r-- | data/org.freedesktop.UDisks.Device.xml | 20 | ||||
-rw-r--r-- | src/device-private.c | 12 | ||||
-rw-r--r-- | src/device-private.h | 2 | ||||
-rw-r--r-- | src/device.c | 20 |
4 files changed, 54 insertions, 0 deletions
diff --git a/data/org.freedesktop.UDisks.Device.xml b/data/org.freedesktop.UDisks.Device.xml index 991976d..cdf6176 100644 --- a/data/org.freedesktop.UDisks.Device.xml +++ b/data/org.freedesktop.UDisks.Device.xml @@ -1691,6 +1691,26 @@ </doc:para></doc:description></doc:doc> </property> + <property name="DeviceAutoMountHint" type="s" access="read"> + <doc:doc><doc:description><doc:para> + A hint to the desktop that indicates if a device should be automounted. + Possible values are: + <doc:list> + <doc:item> + <doc:term>always</doc:term> + <doc:definition>Device should always be auto-mounted.</doc:definition> + </doc:item> + <doc:item> + <doc:term>never</doc:term> + <doc:definition>Device should never be auto-mounted.</doc:definition> + </doc:item> + </doc:list> + An empty string is interpreted to mean that there is no + hint - the desktop auto-mounter should make its own + decision of whether to auto-mount the device. + </doc:para></doc:description></doc:doc> + </property> + <property name="JobInProgress" type="b" access="read"> <doc:doc><doc:description><doc:para> The job properties specify if a job initiated via the diff --git a/src/device-private.c b/src/device-private.c index 22a0d35..53196f3 100644 --- a/src/device-private.c +++ b/src/device-private.c @@ -109,6 +109,18 @@ ptr_str_array_from_strv (GStrv s) } void +device_set_device_auto_mount_hint (Device *device, + const gchar *value) +{ + if (G_UNLIKELY (g_strcmp0 (device->priv->device_auto_mount_hint, value) != 0)) + { + g_free (device->priv->device_auto_mount_hint); + device->priv->device_auto_mount_hint = g_strdup (value); + emit_changed (device, "device_auto_mount_hint"); + } +} + +void device_set_device_detection_time (Device *device, guint64 value) { diff --git a/src/device-private.h b/src/device-private.h index e519083..f331ddc 100644 --- a/src/device-private.h +++ b/src/device-private.h @@ -133,6 +133,7 @@ struct DevicePrivate gboolean device_presentation_nopolicy; char *device_presentation_name; char *device_presentation_icon_name; + char *device_auto_mount_hint; char *id_usage; char *id_type; @@ -253,6 +254,7 @@ void device_set_job_initiated_by_uid (Device *device, guint value); void device_set_job_is_cancellable (Device *device, gboolean value); void device_set_job_percentage (Device *device, gdouble value); +void device_set_device_auto_mount_hint (Device *device, const gchar *value); void device_set_device_detection_time (Device *device, guint64 value); void device_set_device_media_detection_time (Device *device, guint64 value); void device_set_device_file (Device *device, const gchar *value); diff --git a/src/device.c b/src/device.c index c4b4ab3..e39208d 100644 --- a/src/device.c +++ b/src/device.c @@ -177,6 +177,7 @@ enum PROP_0, PROP_NATIVE_PATH, + PROP_DEVICE_AUTOMOUNT_HINT, PROP_DEVICE_DETECTION_TIME, PROP_DEVICE_MEDIA_DETECTION_TIME, PROP_DEVICE_MAJOR, @@ -381,6 +382,9 @@ get_property (GObject *object, case PROP_DEVICE_FILE: g_value_set_string (value, device->priv->device_file); break; + case PROP_DEVICE_AUTOMOUNT_HINT: + g_value_set_string (value, device->priv->device_auto_mount_hint); + break; case PROP_DEVICE_FILE_PRESENTATION: if (device->priv->device_file_presentation != NULL) g_value_set_string (value, device->priv->device_file_presentation); @@ -864,6 +868,15 @@ device_class_init (DeviceClass *klass) NULL, NULL, G_PARAM_READABLE)); + + g_object_class_install_property (object_class, + PROP_DEVICE_AUTOMOUNT_HINT, + g_param_spec_string ("device-auto-mount-hint", + NULL, + NULL, + NULL, + G_PARAM_READABLE)); + g_object_class_install_property (object_class, PROP_DEVICE_DETECTION_TIME, g_param_spec_uint64 ("device-detection-time", @@ -2278,6 +2291,7 @@ update_info_presentation (Device *device) { gboolean hide; gboolean nopolicy; + const gchar *auto_mount_hint; hide = FALSE; if (g_udev_device_has_property (device->priv->d, "UDISKS_PRESENTATION_HIDE")) @@ -2294,6 +2308,12 @@ update_info_presentation (Device *device) device_set_device_presentation_icon_name (device, g_udev_device_get_property (device->priv->d, "UDISKS_PRESENTATION_ICON_NAME")); + auto_mount_hint = ""; + if (g_udev_device_has_property (device->priv->d, "UDISKS_AUTOMOUNT_HINT")) + auto_mount_hint = g_udev_device_get_property (device->priv->d, "UDISKS_AUTOMOUNT_HINT"); + + device_set_device_auto_mount_hint (device, auto_mount_hint); + return TRUE; } |