From 8baaecaddabb30ac950eb0f2198c3853c9cb3ddd Mon Sep 17 00:00:00 2001 From: Ondrej Holy Date: Fri, 13 Jul 2018 12:56:38 +0200 Subject: monitor: Make MountOpReply2 interface expansible The newly introduced MountOpReply2 interface is not expansible and future changes would mean other complications. Let's make the interface expansible thanks to a{sv} expansion argument instead of adding new and new arguments and fallbacks... --- monitor/proxy/dbus-interfaces.xml | 4 +- monitor/proxy/gproxymountoperation.c | 14 +++++-- monitor/proxy/gvfsproxyvolumemonitordaemon.c | 59 ++++++++++++++++++---------- 3 files changed, 51 insertions(+), 26 deletions(-) (limited to 'monitor') diff --git a/monitor/proxy/dbus-interfaces.xml b/monitor/proxy/dbus-interfaces.xml index 03c6caaa..bb6c17c6 100644 --- a/monitor/proxy/dbus-interfaces.xml +++ b/monitor/proxy/dbus-interfaces.xml @@ -187,9 +187,7 @@ - - - + diff --git a/monitor/proxy/gproxymountoperation.c b/monitor/proxy/gproxymountoperation.c index 67fd6416..7aca6b8a 100644 --- a/monitor/proxy/gproxymountoperation.c +++ b/monitor/proxy/gproxymountoperation.c @@ -188,6 +188,7 @@ mount_operation_reply (GMountOperation *mount_operation, gboolean hidden_volume; gboolean system_volume; guint pim; + GVariantBuilder *expansion_builder; data = g_new0 (MountOpReplyData, 1); data->op_data = op_data; @@ -202,6 +203,14 @@ mount_operation_reply (GMountOperation *mount_operation, system_volume = g_mount_operation_get_is_tcrypt_system_volume (mount_operation); pim = g_mount_operation_get_pim (mount_operation); + expansion_builder = g_variant_builder_new (G_VARIANT_TYPE_VARDICT); + g_variant_builder_add (expansion_builder, "{sv}", "hidden-volume", + g_variant_new_boolean (hidden_volume)); + g_variant_builder_add (expansion_builder, "{sv}", "system-volume", + g_variant_new_boolean (system_volume)); + g_variant_builder_add (expansion_builder, "{sv}", "pim", + g_variant_new_uint32 (pim)); + if (data->user_name == NULL) data->user_name = ""; if (data->domain == NULL) @@ -224,12 +233,11 @@ mount_operation_reply (GMountOperation *mount_operation, data->password_save, data->choice, data->anonymous, - hidden_volume, - system_volume, - pim, + g_variant_new ("a{sv}", expansion_builder), NULL, (GAsyncReadyCallback) mount_op_reply2_cb, data); + g_variant_builder_unref (expansion_builder); g_object_unref (proxy); } diff --git a/monitor/proxy/gvfsproxyvolumemonitordaemon.c b/monitor/proxy/gvfsproxyvolumemonitordaemon.c index 7a3d01bc..a1cd91a3 100644 --- a/monitor/proxy/gvfsproxyvolumemonitordaemon.c +++ b/monitor/proxy/gvfsproxyvolumemonitordaemon.c @@ -1089,9 +1089,7 @@ handle_mount_op_reply2 (GVfsRemoteVolumeMonitor *object, gint arg_password_save, gint arg_choice, gboolean arg_anonymous, - gboolean arg_hidden_volume, - gboolean arg_system_volume, - guint arg_pim, + GVariant *expansion, gpointer user_data) { char *decoded_password; @@ -1099,6 +1097,9 @@ handle_mount_op_reply2 (GVfsRemoteVolumeMonitor *object, GList *l; GMountOperation *mount_operation; const gchar *sender; + GVariantIter *iter_expansion; + GVariant *value; + const gchar *key; print_debug ("in handle_mount_op_reply2"); @@ -1140,9 +1141,20 @@ handle_mount_op_reply2 (GVfsRemoteVolumeMonitor *object, g_mount_operation_set_password_save (mount_operation, arg_password_save); g_mount_operation_set_choice (mount_operation, arg_choice); g_mount_operation_set_anonymous (mount_operation, arg_anonymous); - g_mount_operation_set_is_tcrypt_hidden_volume (mount_operation, arg_hidden_volume); - g_mount_operation_set_is_tcrypt_system_volume (mount_operation, arg_system_volume); - g_mount_operation_set_pim (mount_operation, arg_pim); + + g_variant_get (expansion, "a{sv}", &iter_expansion); + while (g_variant_iter_loop (iter_expansion, "{sv}", &key, &value)) + { + if (g_str_equal (key, "hidden-volume")) + g_mount_operation_set_is_tcrypt_hidden_volume (mount_operation, g_variant_get_boolean (value)); + else if (g_str_equal (key, "system-volume")) + g_mount_operation_set_is_tcrypt_system_volume (mount_operation, g_variant_get_boolean (value)); + else if (g_str_equal (key, "pim")) + g_mount_operation_set_pim (mount_operation, g_variant_get_uint32 (value)); + else + g_warning ("Unsupported GMountOperation option: %s\n", key); + } + g_variant_iter_free (iter_expansion); g_mount_operation_reply (mount_operation, arg_result); @@ -1170,20 +1182,27 @@ handle_mount_op_reply (GVfsRemoteVolumeMonitor *object, gboolean arg_anonymous, gpointer user_data) { - return handle_mount_op_reply2 (object, - invocation, - arg_mount_op_id, - arg_result, - arg_user_name, - arg_domain, - arg_encoded_password, - arg_password_save, - arg_choice, - arg_anonymous, - FALSE, - FALSE, - 0, - user_data); + GVariantBuilder *expansion_builder; + gboolean ret; + + expansion_builder = g_variant_builder_new (G_VARIANT_TYPE_VARDICT); + + ret = handle_mount_op_reply2 (object, + invocation, + arg_mount_op_id, + arg_result, + arg_user_name, + arg_domain, + arg_encoded_password, + arg_password_save, + arg_choice, + arg_anonymous, + g_variant_new ("a{sv}", expansion_builder), + user_data); + + g_variant_builder_unref (expansion_builder); + + return ret; } /* ---------------------------------------------------------------------------------------------------- */ -- cgit v1.2.1