summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGiovanni Campagna <gcampagna@src.gnome.org>2013-06-02 20:08:17 +0200
committerGiovanni Campagna <gcampagna@src.gnome.org>2013-06-13 21:04:42 +0200
commit97a4246ba7f620ee348711b21cba8a1b67e8a056 (patch)
tree30d19a9047232dacfbfbfbb683b7afc17def7cc3
parentbf50158cb58d1d22d6ece145d1eabd790b30798f (diff)
downloadgvfs-97a4246ba7f620ee348711b21cba8a1b67e8a056.tar.gz
GProxyVolume: extend the protocol so the volume monitor can force a call to Mount
Some volume monitors, like gnome-online-accounts, want their mount implementation to be called even though the volume has an activation root. Allow them to advertise so using the expansion fields of the volume DBus representation. https://bugzilla.gnome.org/show_bug.cgi?id=696279
-rw-r--r--monitor/proxy/gproxyvolume.c20
-rw-r--r--monitor/proxy/gvfsproxyvolumemonitordaemon.c13
-rw-r--r--monitor/proxy/gvfsproxyvolumemonitordaemon.h2
3 files changed, 28 insertions, 7 deletions
diff --git a/monitor/proxy/gproxyvolume.c b/monitor/proxy/gproxyvolume.c
index a3d41a18..f0cfa116 100644
--- a/monitor/proxy/gproxyvolume.c
+++ b/monitor/proxy/gproxyvolume.c
@@ -62,6 +62,7 @@ struct _GProxyVolume {
gboolean can_mount;
gboolean should_automount;
+ gboolean always_call_mount;
GProxyShadowMount *shadow_mount;
@@ -356,7 +357,7 @@ update_shadow_mount_in_idle (GProxyVolume *volume)
* a{sv} expansion
*/
-#define VOLUME_STRUCT_TYPE "(&s&s&s&s&s&sbb&s&sa{ss}&sa{sv})"
+#define VOLUME_STRUCT_TYPE "(&s&s&s&s&s&sbb&s&sa{ss}&s@a{sv})"
void g_proxy_volume_update (GProxyVolume *volume,
GVariant *iter)
@@ -374,7 +375,7 @@ void g_proxy_volume_update (GProxyVolume *volume,
GHashTable *identifiers;
const gchar *sort_key;
GVariantIter *iter_identifiers;
- GVariantIter *iter_expansion;
+ GVariant *expansion;
sort_key = NULL;
g_variant_get (iter, VOLUME_STRUCT_TYPE,
@@ -385,7 +386,7 @@ void g_proxy_volume_update (GProxyVolume *volume,
&drive_id, &mount_id,
&iter_identifiers,
&sort_key,
- &iter_expansion);
+ &expansion);
identifiers = _get_identifiers (iter_identifiers);
@@ -439,14 +440,20 @@ void g_proxy_volume_update (GProxyVolume *volume,
volume->identifiers = identifiers != NULL ? g_hash_table_ref (identifiers) : NULL;
volume->sort_key = g_strdup (sort_key);
- /* TODO: decode expansion, once used */
+ if (volume->activation_uri)
+ {
+ if (!g_variant_lookup (expansion, "always-call-mount", "b", &volume->always_call_mount))
+ volume->always_call_mount = FALSE;
+ }
+ else
+ volume->always_call_mount = FALSE;
/* this calls into the union monitor; do it in idle to avoid locking issues */
update_shadow_mount_in_idle (volume);
out:
g_variant_iter_free (iter_identifiers);
- g_variant_iter_free (iter_expansion);
+ g_variant_unref (expansion);
g_hash_table_unref (identifiers);
}
@@ -876,7 +883,8 @@ g_proxy_volume_mount (GVolume *volume,
GProxyVolume *proxy_volume = G_PROXY_VOLUME (volume);
G_LOCK (proxy_volume);
- if (proxy_volume->activation_uri != NULL)
+ if (proxy_volume->activation_uri != NULL &&
+ !proxy_volume->always_call_mount)
{
ForeignMountOp *data;
GFile *root;
diff --git a/monitor/proxy/gvfsproxyvolumemonitordaemon.c b/monitor/proxy/gvfsproxyvolumemonitordaemon.c
index 8e65d9fc..0201cf23 100644
--- a/monitor/proxy/gvfsproxyvolumemonitordaemon.c
+++ b/monitor/proxy/gvfsproxyvolumemonitordaemon.c
@@ -41,6 +41,7 @@ static const char *the_dbus_name = NULL;
static GList *outstanding_ops = NULL;
static GList *outstanding_mount_op_objects = NULL;
static GHashTable *unique_names_being_watched = NULL;
+static gboolean always_call_mount = FALSE;
static GVfsRemoteVolumeMonitor *monitor_daemon = NULL;
@@ -760,8 +761,12 @@ volume_to_dbus (GVolume *volume)
g_free (id_value);
}
- expansion_builder = g_variant_builder_new (G_VARIANT_TYPE_VARDICT);
/* left for future expansion without ABI breaks */
+ expansion_builder = g_variant_builder_new (G_VARIANT_TYPE_VARDICT);
+
+ if (always_call_mount)
+ g_variant_builder_add (expansion_builder, "{sv}",
+ "always-call-mount", g_variant_new_boolean (TRUE));
result = g_variant_new (VOLUME_STRUCT_TYPE,
id,
@@ -2012,3 +2017,9 @@ g_vfs_proxy_volume_monitor_daemon_main (int argc,
return 0;
}
+
+void
+g_vfs_proxy_volume_monitor_daemon_set_always_call_mount (gboolean value)
+{
+ always_call_mount = value;
+}
diff --git a/monitor/proxy/gvfsproxyvolumemonitordaemon.h b/monitor/proxy/gvfsproxyvolumemonitordaemon.h
index 3aed1539..77895dd2 100644
--- a/monitor/proxy/gvfsproxyvolumemonitordaemon.h
+++ b/monitor/proxy/gvfsproxyvolumemonitordaemon.h
@@ -32,4 +32,6 @@ int g_vfs_proxy_volume_monitor_daemon_main (int argc,
const char *dbus_name,
GType volume_monitor_type);
+void g_vfs_proxy_volume_monitor_daemon_set_always_call_mount (gboolean always_call_mount);
+
#endif