[gnome-control-center] user-accounts: Update the realmd dbus interface to latest



commit 973adfa43b953fd52063404224952b4c55ea98b6
Author: Stef Walter <stefw gnome org>
Date:   Thu Jun 14 17:10:31 2012 +0200

    user-accounts: Update the realmd dbus interface to latest
    
    The changes in the realmd dbus interface are futureproofing to
    support cancellation.
    
    In addition during this time of interface flux, check the
    daemon version number to make sure we can talk to it.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=678105

 .../user-accounts/data/org.freedesktop.realmd.xml  |   23 ++++++++
 panels/user-accounts/um-account-dialog.c           |    2 +-
 panels/user-accounts/um-realm-manager.c            |   55 ++++++++++++++++++-
 3 files changed, 76 insertions(+), 4 deletions(-)
---
diff --git a/panels/user-accounts/data/org.freedesktop.realmd.xml b/panels/user-accounts/data/org.freedesktop.realmd.xml
index e508489..92b8861 100644
--- a/panels/user-accounts/data/org.freedesktop.realmd.xml
+++ b/panels/user-accounts/data/org.freedesktop.realmd.xml
@@ -13,6 +13,16 @@
 	<interface name="org.freedesktop.realmd.Provider">
 
 		<!--
+		 * The name of the provider
+		-->
+		<property name="Name" type="s" access="read"/>
+
+		<!--
+		 * A version number for the provider
+		-->
+		<property name="Version" type="s" access="read"/>
+
+		<!--
 		 * A list of known, enrolled or discovered realms.
 		 * Each realm is a DBus object and is represeted by a:
 		 *   s: DBus bus name of the realm
@@ -29,6 +39,8 @@
 			<!-- The input string -->
 			<arg name="string" type="s" direction="in"/>
 
+			<arg name="operation_id" type="s" direction="in"/>
+
 			<!-- Returned match relevance -->
 			<arg name="relevance" type="i" direction="out"/>
 
@@ -47,6 +59,7 @@
 	<interface name="org.freedesktop.realmd.Diagnostics">
 		<signal name="Diagnostics">
 			<arg name="data" type="s"/>
+			<arg name="operation_id" type="s"/>
 		</signal>
 	</interface>
 
@@ -66,6 +79,11 @@
 		<property name="Domain" type="s" access="read"/>
 
 		<!--
+		 * The server software, for information only. eg: active-directory
+		-->
+		<property name="Details" type="a{ss}" access="read"/>
+
+		<!--
 		 * The suggested Administrator login name for this realm
 		-->
 		<property name="SuggestedAdministrator" type="s" access="read"/>
@@ -83,6 +101,7 @@
 			<arg name="principal" type="s" direction="in"/>
 			<arg name="password" type="s" direction="in"/>
 			<arg name="options" type="a{sv}" direction="in"/>
+			<arg name="operation_id" type="s" direction="in"/>
 		</method>
 
 		<!--
@@ -95,6 +114,7 @@
 				<annotation name="org.gtk.GDBus.C.ForceGVariant" value="yup"/>
 			</arg>
 			<arg name="options" type="a{sv}" direction="in"/>
+			<arg name="operation_id" type="s" direction="in"/>
 		</method>
 
 		<!--
@@ -105,6 +125,7 @@
 			<arg name="principal" type="s" direction="in"/>
 			<arg name="password" type="s" direction="in"/>
 			<arg name="options" type="a{sv}" direction="in"/>
+			<arg name="operation_id" type="s" direction="in"/>
 		</method>
 
 		<!--
@@ -117,6 +138,7 @@
 				<annotation name="org.gtk.GDBus.C.ForceGVariant" value="yup"/>
 			</arg>
 			<arg name="options" type="a{sv}" direction="in"/>
+			<arg name="operation_id" type="s" direction="in"/>
 		</method>
 
 		<!--
@@ -139,6 +161,7 @@
 		<method name="ChangePermittedLogins">
 			<arg name="add" type="as" direction="in"/>
 			<arg name="remove" type="as" direction="in"/>
+			<arg name="operation_id" type="s" direction="in"/>
 		</method>
 
 	</interface>
diff --git a/panels/user-accounts/um-account-dialog.c b/panels/user-accounts/um-account-dialog.c
index df8781d..985bb10 100644
--- a/panels/user-accounts/um-account-dialog.c
+++ b/panels/user-accounts/um-account-dialog.c
@@ -421,7 +421,7 @@ enterprise_permit_user_login (UmAccountDialog *self)
         remove[0] = NULL;
 
         um_realm_kerberos_call_change_permitted_logins (self->selected_realm,
-                                                        add, remove,
+                                                        add, remove, "",
                                                         self->cancellable,
                                                         on_permit_user_login,
                                                         g_object_ref (self));
diff --git a/panels/user-accounts/um-realm-manager.c b/panels/user-accounts/um-realm-manager.c
index f4f9740..c2e7359 100644
--- a/panels/user-accounts/um-realm-manager.c
+++ b/panels/user-accounts/um-realm-manager.c
@@ -282,14 +282,47 @@ on_realm_diagnostics (GDBusConnection *connection,
                       gpointer user_data)
 {
         const gchar *message;
+        const gchar *unused;
 
-        if (g_variant_is_of_type (parameters, G_VARIANT_TYPE ("(s)"))) {
+        if (g_variant_is_of_type (parameters, G_VARIANT_TYPE ("(ss)"))) {
                 /* Data is already formatted appropriately for stderr */
-                g_variant_get (parameters, "(&s)", &message);
+                g_variant_get (parameters, "(&s&s)", &message, &unused);
                 g_printerr ("%s", message);
         }
 }
 
+static gboolean
+number_at_least (const gchar *number,
+                 guint minimum)
+{
+        gchar *end;
+
+        if (strtol (number, &end, 10) < (long)minimum)
+                return FALSE;
+        if (!end || *end != '\0')
+                return FALSE;
+        return TRUE;
+}
+
+static gboolean
+version_compare (const char *version,
+                 guint req_major,
+                 guint req_minor)
+{
+        gboolean match = FALSE;
+        gchar **parts;
+
+        parts = g_strsplit (version, ".", 2);
+
+        if (parts[0] && parts[1]) {
+                match = number_at_least (parts[0], req_major) &&
+                        number_at_least (parts[1], req_minor);
+        }
+
+        g_strfreev (parts);
+        return match;
+}
+
 static void
 on_realm_manager_async_init (GObject *source,
                              GAsyncResult *result,
@@ -298,6 +331,7 @@ on_realm_manager_async_init (GObject *source,
         GSimpleAsyncResult *async = G_SIMPLE_ASYNC_RESULT (user_data);
         UmRealmManager *self;
         GError *error = NULL;
+        const gchar *version;
         GDBusProxy *proxy;
         GObject *object;
         guint sig;
@@ -306,6 +340,20 @@ on_realm_manager_async_init (GObject *source,
 
         if (error != NULL)
                 g_simple_async_result_take_error (async, error);
+
+        /* This is temporary until the dbus interface stabilizes */
+        if (object) {
+                version = um_realm_provider_get_version (UM_REALM_PROVIDER (object));
+                if (!version_compare (version, 0, 2)) {
+                        /* No need to bother translators with this temporary message */
+                        g_simple_async_result_set_error (async, UM_REALM_ERROR,
+                                                         UM_REALM_ERROR_GENERIC,
+                                                         "Unsupported version of realmd: %s", version);
+                        g_object_unref (object);
+                        object = NULL;
+                }
+        }
+
         if (object != NULL) {
                 proxy = G_DBUS_PROXY (object);
                 sig = g_dbus_connection_signal_subscribe (g_dbus_proxy_get_connection (proxy),
@@ -450,7 +498,7 @@ um_realm_manager_discover (UmRealmManager *self,
         discover->cancellable = cancellable ? g_object_ref (cancellable) : NULL;
         g_simple_async_result_set_op_res_gpointer (res, discover, discover_closure_free);
 
-        um_realm_provider_call_discover (UM_REALM_PROVIDER (self), input, cancellable,
+        um_realm_provider_call_discover (UM_REALM_PROVIDER (self), input, "", cancellable,
                                          on_provider_discover, g_object_ref (res));
 
         g_object_unref (res);
@@ -516,6 +564,7 @@ um_realm_join (UmRealmKerberos *realm,
         um_realm_kerberos_call_enroll_with_credential_cache (realm,
                                                              g_variant_ref_sink (creds),
                                                              g_variant_ref_sink (options),
+                                                             "",
                                                              cancellable,
                                                              callback,
                                                              user_data);



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