PolicyKit: Branch 'master'

David Zeuthen david at kemper.freedesktop.org
Tue May 19 09:11:33 PDT 2009


 docs/polkit/polkit-1-docs.xml                   |    1 
 docs/polkit/polkit-1-sections.txt               |   17 ++++++++
 docs/polkit/polkit-1.types                      |    1 
 src/polkit/Makefile.am                          |    4 +
 src/polkit/polkit.h                             |    1 
 src/polkit/polkitauthority.c                    |   17 +++++---
 src/polkit/polkitauthority.h                    |    4 -
 src/polkit/polkitauthorizationresult.c          |   29 ++++++++++---
 src/polkit/polkitauthorizationresult.h          |    4 -
 src/polkit/polkitprivate.h                      |    4 +
 src/polkit/polkittypes.h                        |    3 +
 src/polkitagent/polkitagentlistener.c           |   10 +++-
 src/polkitagent/polkitagentlistener.h           |    4 -
 src/polkitbackend/polkitbackendactionlookup.c   |   18 ++++----
 src/polkitbackend/polkitbackendactionlookup.h   |   50 ++++++++++++------------
 src/polkitbackend/polkitbackendauthority.c      |    8 +--
 src/polkitbackend/polkitbackendauthority.h      |    4 -
 src/polkitbackend/polkitbackendlocalauthority.c |   30 ++++++++------
 src/programs/pkexec-action-lookup.c             |   34 +++++++---------
 src/programs/pkexec.c                           |   16 ++++---
 20 files changed, 157 insertions(+), 102 deletions(-)

New commits:
commit 028e1aa51e4df5655f7cf57824dcc5f20823e19f
Author: David Zeuthen <davidz at redhat.com>
Date:   Tue May 19 12:08:12 2009 -0400

    Use an object, not a GHashTable when passing details around
    
    This is because bindable GObject APIs should never return or accept a
    GHashTable, see http://bugzilla.gnome.org/show_bug.cgi?id=581686#c6
    for details.

diff --git a/docs/polkit/polkit-1-docs.xml b/docs/polkit/polkit-1-docs.xml
index 452c5a7..0f0a103 100644
--- a/docs/polkit/polkit-1-docs.xml
+++ b/docs/polkit/polkit-1-docs.xml
@@ -66,6 +66,7 @@
     <title>Core API Reference</title>
     <xi:include href="xml/polkitauthority.xml"/>
     <xi:include href="xml/polkitauthorizationresult.xml"/>
+    <xi:include href="xml/polkitdetails.xml"/>
     <xi:include href="xml/polkiterror.xml"/>
     <xi:include href="xml/polkitactiondescription.xml"/>
     <xi:include href="xml/polkitauthoritymanager.xml"/>
diff --git a/docs/polkit/polkit-1-sections.txt b/docs/polkit/polkit-1-sections.txt
index 2e56a30..42da5d3 100644
--- a/docs/polkit/polkit-1-sections.txt
+++ b/docs/polkit/polkit-1-sections.txt
@@ -269,3 +269,20 @@ polkit_error_quark
 polkit_error_get_type
 </SECTION>
 
+<SECTION>
+<FILE>polkitdetails</FILE>
+PolkitDetails
+polkit_details_new
+polkit_details_lookup
+polkit_details_insert
+polkit_details_get_keys
+<SUBSECTION Standard>
+PolkitDetailsClass
+POLKIT_DETAILS
+POLKIT_IS_DETAILS
+POLKIT_TYPE_DETAILS
+polkit_details_get_type
+POLKIT_DETAILS_CLASS
+POLKIT_IS_DETAILS_CLASS
+POLKIT_DETAILS_GET_CLASS
+</SECTION>
diff --git a/docs/polkit/polkit-1.types b/docs/polkit/polkit-1.types
index c47d206..41a5b79 100644
--- a/docs/polkit/polkit-1.types
+++ b/docs/polkit/polkit-1.types
@@ -3,6 +3,7 @@ polkit_authority_manager_get_type
 
 polkit_authorization_get_type
 polkit_action_description_get_type
+polkit_details_get_type
 
 polkit_check_authorization_flags_get_type
 polkit_implicit_authorization_get_type
diff --git a/src/polkit/Makefile.am b/src/polkit/Makefile.am
index 7bd8acf..0b06e5f 100644
--- a/src/polkit/Makefile.am
+++ b/src/polkit/Makefile.am
@@ -45,6 +45,7 @@ libpolkit_gobject_1include_HEADERS =                        				\
         polkitprivate.h									\
         polkittypes.h									\
 	polkitactiondescription.h							\
+	polkitdetails.h									\
 	polkitauthority.h								\
 	polkitauthoritymanager.h							\
 	polkiterror.h									\
@@ -63,9 +64,10 @@ libpolkit_gobject_1include_HEADERS =                        				\
 
 libpolkit_gobject_1_la_SOURCES =                                   			\
 	$(BUILT_SOURCES)								\
-	$(polkit_built_sources)							\
+	$(polkit_built_sources)								\
         polkit.h									\
 	polkitactiondescription.c		polkitactiondescription.h		\
+	polkitdetails.c				polkitdetails.h				\
 	polkitauthority.c			polkitauthority.h			\
 	polkitauthoritymanager.c		polkitauthoritymanager.h		\
 	polkiterror.c				polkiterror.h				\
diff --git a/src/polkit/polkit.h b/src/polkit/polkit.h
index 6baccb5..29b27c5 100644
--- a/src/polkit/polkit.h
+++ b/src/polkit/polkit.h
@@ -39,6 +39,7 @@
 #include <polkit/polkitauthority.h>
 #include <polkit/polkitauthoritymanager.h>
 #include <polkit/polkitauthorization.h>
+#include <polkit/polkitdetails.h>
 
 #undef _POLKIT_INSIDE_POLKIT_H
 
diff --git a/src/polkit/polkitauthority.c b/src/polkit/polkitauthority.c
index 82c9d91..0ca8fd9 100644
--- a/src/polkit/polkitauthority.c
+++ b/src/polkit/polkitauthority.c
@@ -330,7 +330,7 @@ static guint
 polkit_authority_check_authorization_async (PolkitAuthority               *authority,
                                             PolkitSubject                 *subject,
                                             const gchar                   *action_id,
-                                            GHashTable                    *details,
+                                            PolkitDetails                 *details,
                                             PolkitCheckAuthorizationFlags  flags,
                                             GCancellable                  *cancellable,
                                             GAsyncReadyCallback            callback,
@@ -360,13 +360,18 @@ polkit_authority_check_authorization_async (PolkitAuthority               *autho
                                         G_TYPE_STRING, NULL);
   if (details != NULL)
     {
+      GHashTable *hash;
       GHashTableIter iter;
       const gchar *key;
       const gchar *value;
 
-      g_hash_table_iter_init (&iter, details);
-      while (g_hash_table_iter_next (&iter, (gpointer) &key, (gpointer) &value))
-        egg_dbus_hash_map_insert (real_details, key, value);
+      hash = polkit_details_get_hash (details);
+      if (hash != NULL)
+        {
+          g_hash_table_iter_init (&iter, hash);
+          while (g_hash_table_iter_next (&iter, (gpointer) &key, (gpointer) &value))
+            egg_dbus_hash_map_insert (real_details, key, value);
+        }
     }
 
   call_id = _polkit_authority_check_authorization (authority->real,
@@ -407,7 +412,7 @@ void
 polkit_authority_check_authorization (PolkitAuthority               *authority,
                                       PolkitSubject                 *subject,
                                       const gchar                   *action_id,
-                                      GHashTable                    *details,
+                                      PolkitDetails                 *details,
                                       PolkitCheckAuthorizationFlags  flags,
                                       GCancellable                  *cancellable,
                                       GAsyncReadyCallback            callback,
@@ -535,7 +540,7 @@ PolkitAuthorizationResult *
 polkit_authority_check_authorization_sync (PolkitAuthority               *authority,
                                            PolkitSubject                 *subject,
                                            const gchar                   *action_id,
-                                           GHashTable                    *details,
+                                           PolkitDetails                 *details,
                                            PolkitCheckAuthorizationFlags  flags,
                                            GCancellable                  *cancellable,
                                            GError                       **error)
diff --git a/src/polkit/polkitauthority.h b/src/polkit/polkitauthority.h
index 642c400..e9df6d0 100644
--- a/src/polkit/polkitauthority.h
+++ b/src/polkit/polkitauthority.h
@@ -65,7 +65,7 @@ GList                     *polkit_authority_enumerate_groups_sync (PolkitAuthori
 PolkitAuthorizationResult *polkit_authority_check_authorization_sync (PolkitAuthority               *authority,
                                                                       PolkitSubject                 *subject,
                                                                       const gchar                   *action_id,
-                                                                      GHashTable                    *details,
+                                                                      PolkitDetails                 *details,
                                                                       PolkitCheckAuthorizationFlags  flags,
                                                                       GCancellable                  *cancellable,
                                                                       GError                       **error);
@@ -103,7 +103,7 @@ GList *                    polkit_authority_enumerate_actions_finish (PolkitAuth
 void                       polkit_authority_check_authorization (PolkitAuthority               *authority,
                                                                  PolkitSubject                 *subject,
                                                                  const gchar                   *action_id,
-                                                                 GHashTable                    *details,
+                                                                 PolkitDetails                 *details,
                                                                  PolkitCheckAuthorizationFlags  flags,
                                                                  GCancellable                  *cancellable,
                                                                  GAsyncReadyCallback            callback,
diff --git a/src/polkit/polkitauthorizationresult.c b/src/polkit/polkitauthorizationresult.c
index 314c39f..e9961c0 100644
--- a/src/polkit/polkitauthorizationresult.c
+++ b/src/polkit/polkitauthorizationresult.c
@@ -40,6 +40,8 @@ struct _PolkitAuthorizationResult
   GObject parent_instance;
 
   _PolkitAuthorizationResult *real;
+
+  PolkitDetails *details;
 };
 
 struct _PolkitAuthorizationResultClass
@@ -62,6 +64,8 @@ polkit_authorization_result_finalize (GObject *object)
   authorization_result = POLKIT_AUTHORIZATION_RESULT (object);
 
   g_object_unref (authorization_result->real);
+  if (authorization_result->details != NULL)
+    g_object_unref (authorization_result->details);
 
   if (G_OBJECT_CLASS (polkit_authorization_result_parent_class)->finalize != NULL)
     G_OBJECT_CLASS (polkit_authorization_result_parent_class)->finalize (object);
@@ -108,7 +112,7 @@ polkit_authorization_result_get_real (PolkitAuthorizationResult  *authorization_
 PolkitAuthorizationResult *
 polkit_authorization_result_new (gboolean                   is_authorized,
                                  gboolean                   is_challenge,
-                                 GHashTable                *details)
+                                 PolkitDetails             *details)
 {
   PolkitAuthorizationResult *authorization_result;
   _PolkitAuthorizationResult *real;
@@ -117,13 +121,18 @@ polkit_authorization_result_new (gboolean                   is_authorized,
   real_details = egg_dbus_hash_map_new (G_TYPE_STRING, g_free, G_TYPE_STRING, g_free);
   if (details != NULL)
     {
+      GHashTable *hash;
       GHashTableIter iter;
       gpointer key, value;
 
-      g_hash_table_iter_init (&iter, details);
-      while (g_hash_table_iter_next (&iter, &key, &value))
+      hash = polkit_details_get_hash (details);
+      if (hash != NULL)
         {
-          egg_dbus_hash_map_insert (real_details, g_strdup (key), g_strdup (value));
+          g_hash_table_iter_init (&iter, hash);
+          while (g_hash_table_iter_next (&iter, &key, &value))
+            {
+              egg_dbus_hash_map_insert (real_details, g_strdup (key), g_strdup (value));
+            }
         }
     }
 
@@ -173,14 +182,18 @@ polkit_authorization_result_get_is_challenge (PolkitAuthorizationResult *result)
  *
  * Returns:
  **/
-GHashTable *
+PolkitDetails *
 polkit_authorization_result_get_details (PolkitAuthorizationResult *result)
 {
   EggDBusHashMap *real_details;
 
+  if (result->details != NULL)
+    goto out;
+
   real_details = _polkit_authorization_result_get_details (result->real);
   if (real_details != NULL)
-    return real_details->data;
-  else
-    return NULL;
+    result->details = result->details = polkit_details_new_for_hash (real_details->data);
+
+ out:
+  return result->details;
 }
diff --git a/src/polkit/polkitauthorizationresult.h b/src/polkit/polkitauthorizationresult.h
index 69bec13..40db4f6 100644
--- a/src/polkit/polkitauthorizationresult.h
+++ b/src/polkit/polkitauthorizationresult.h
@@ -46,10 +46,10 @@ typedef struct _PolkitAuthorizationResultClass PolkitAuthorizationResultClass;
 GType                      polkit_authorization_result_get_type          (void) G_GNUC_CONST;
 PolkitAuthorizationResult *polkit_authorization_result_new               (gboolean                   is_authorized,
                                                                           gboolean                   is_challenge,
-                                                                          GHashTable                *details);
+                                                                          PolkitDetails             *details);
 gboolean                   polkit_authorization_result_get_is_authorized (PolkitAuthorizationResult *result);
 gboolean                   polkit_authorization_result_get_is_challenge  (PolkitAuthorizationResult *result);
-GHashTable                *polkit_authorization_result_get_details       (PolkitAuthorizationResult *result);
+PolkitDetails             *polkit_authorization_result_get_details       (PolkitAuthorizationResult *result);
 
 /* ---------------------------------------------------------------------------------------------------- */
 
diff --git a/src/polkit/polkitprivate.h b/src/polkit/polkitprivate.h
index 64954f0..5a8b951 100644
--- a/src/polkit/polkitprivate.h
+++ b/src/polkit/polkitprivate.h
@@ -50,4 +50,8 @@ _PolkitAuthorization *polkit_authorization_get_real     (PolkitAuthorization  *a
 PolkitAuthorizationResult  *polkit_authorization_result_new_for_real (_PolkitAuthorizationResult *real);
 _PolkitAuthorizationResult *polkit_authorization_result_get_real (PolkitAuthorizationResult *authorization_result);
 
+
+PolkitDetails *polkit_details_new_for_hash (GHashTable *hash);
+GHashTable *polkit_details_get_hash (PolkitDetails *details);
+
 #endif /* __POLKIT_PRIVATE_H */
diff --git a/src/polkit/polkittypes.h b/src/polkit/polkittypes.h
index 47e1f21..4344262 100644
--- a/src/polkit/polkittypes.h
+++ b/src/polkit/polkittypes.h
@@ -58,4 +58,7 @@ typedef struct _PolkitAuthorization PolkitAuthorization;
 struct _PolkitAuthorizationResult;
 typedef struct _PolkitAuthorizationResult PolkitAuthorizationResult;
 
+struct _PolkitDetails;
+typedef struct _PolkitDetails PolkitDetails;
+
 #endif /* __POLKIT_TYPES_H */
diff --git a/src/polkitagent/polkitagentlistener.c b/src/polkitagent/polkitagentlistener.c
index fb59b68..0251ed4 100644
--- a/src/polkitagent/polkitagentlistener.c
+++ b/src/polkitagent/polkitagentlistener.c
@@ -371,6 +371,7 @@ handle_begin_authentication (_PolkitAuthenticationAgent *instance,
   GList *list;
   guint n;
   GCancellable *cancellable;
+  PolkitDetails *_details;
 
   list = NULL;
   for (n = 0; n < identities->size; n++)
@@ -391,11 +392,13 @@ handle_begin_authentication (_PolkitAuthenticationAgent *instance,
 
   g_hash_table_insert (server->cookie_to_pending_auth, (gpointer) cookie, data);
 
+  _details = polkit_details_new_for_hash (details->data);
+
   polkit_agent_listener_initiate_authentication (server->listener,
                                                  action_id,
                                                  message,
                                                  icon_name,
-                                                 details->data,
+                                                 _details,
                                                  cookie,
                                                  list,
                                                  data->cancellable,
@@ -403,6 +406,7 @@ handle_begin_authentication (_PolkitAuthenticationAgent *instance,
                                                  data);
 
   g_list_free (list);
+  g_object_unref (_details);
 }
 
 static void
@@ -456,7 +460,7 @@ polkit_agent_listener_class_init (PolkitAgentListenerClass *klass)
  * @action_id: The action to authenticate for.
  * @message: The message to present to the user.
  * @icon_name: A themed icon name representing the action or %NULL.
- * @details: A set of key/value string pairs describing the action.
+ * @details: Details describing the action.
  * @cookie: The cookie for the authentication request.
  * @identities: A list of #PolkitIdentity objects that the user can choose to authenticate as.
  * @cancellable: A #GCancellable.
@@ -479,7 +483,7 @@ polkit_agent_listener_initiate_authentication (PolkitAgentListener  *listener,
                                                const gchar          *action_id,
                                                const gchar          *message,
                                                const gchar          *icon_name,
-                                               GHashTable           *details,
+                                               PolkitDetails        *details,
                                                const gchar          *cookie,
                                                GList                *identities,
                                                GCancellable         *cancellable,
diff --git a/src/polkitagent/polkitagentlistener.h b/src/polkitagent/polkitagentlistener.h
index 9324b92..0f0b295 100644
--- a/src/polkitagent/polkitagentlistener.h
+++ b/src/polkitagent/polkitagentlistener.h
@@ -69,7 +69,7 @@ struct _PolkitAgentListenerClass
                                               const gchar          *action_id,
                                               const gchar          *message,
                                               const gchar          *icon_name,
-                                              GHashTable           *details,
+                                              PolkitDetails        *details,
                                               const gchar          *cookie,
                                               GList                *identities,
                                               GCancellable         *cancellable,
@@ -97,7 +97,7 @@ void      polkit_agent_listener_initiate_authentication         (PolkitAgentList
                                                                  const gchar          *action_id,
                                                                  const gchar          *message,
                                                                  const gchar          *icon_name,
-                                                                 GHashTable           *details,
+                                                                 PolkitDetails        *details,
                                                                  const gchar          *cookie,
                                                                  GList                *identities,
                                                                  GCancellable         *cancellable,
diff --git a/src/polkitbackend/polkitbackendactionlookup.c b/src/polkitbackend/polkitbackendactionlookup.c
index 64c43a9..dcc972a 100644
--- a/src/polkitbackend/polkitbackendactionlookup.c
+++ b/src/polkitbackend/polkitbackendactionlookup.c
@@ -49,10 +49,10 @@
  * e.g. messages that include more information than just the action
  * name.
  *
- * Code implementing this interface <emphasis>cannot</emphasis>
- * block or do any IO when methods are invoked. If information is
- * needed to format the message or details, prepare it in advance and
- * pass it as part of the @details hash table when doing the
+ * Code implementing this interface <emphasis>cannot</emphasis> block
+ * or do any IO when methods are invoked. If information is needed to
+ * format the message or details, prepare it in advance and pass it as
+ * part of the @details object when doing the
  * polkit_authority_check_authorization() call. Then the code in this
  * interface can use that information to return localized data.
  *
@@ -112,7 +112,7 @@ polkit_backend_action_lookup_get_type (void)
 gchar *
 polkit_backend_action_lookup_get_message (PolkitBackendActionLookup *lookup,
                                           const gchar               *action_id,
-                                          GHashTable                *details,
+                                          PolkitDetails             *details,
                                           PolkitActionDescription   *action_description)
 {
   PolkitBackendActionLookupIface *iface = POLKIT_BACKEND_ACTION_LOOKUP_GET_IFACE (lookup);
@@ -138,7 +138,7 @@ polkit_backend_action_lookup_get_message (PolkitBackendActionLookup *lookup,
 gchar *
 polkit_backend_action_lookup_get_icon_name (PolkitBackendActionLookup *lookup,
                                             const gchar               *action_id,
-                                            GHashTable                *details,
+                                            PolkitDetails             *details,
                                             PolkitActionDescription   *action_description)
 {
   PolkitBackendActionLookupIface *iface = POLKIT_BACKEND_ACTION_LOOKUP_GET_IFACE (lookup);
@@ -159,12 +159,12 @@ polkit_backend_action_lookup_get_icon_name (PolkitBackendActionLookup *lookup,
  * Computes localized details to show in an authentication dialog for
  * @action_id and @details.
  *
- * Returns: A #GHashTable with localized details or %NULL. Caller must free the result.
+ * Returns: A #PolkitDetails object with localized details or %NULL. Caller must free the result.
  **/
-GHashTable *
+PolkitDetails *
 polkit_backend_action_lookup_get_details (PolkitBackendActionLookup *lookup,
                                           const gchar               *action_id,
-                                          GHashTable                *details,
+                                          PolkitDetails             *details,
                                           PolkitActionDescription   *action_description)
 {
   PolkitBackendActionLookupIface *iface = POLKIT_BACKEND_ACTION_LOOKUP_GET_IFACE (lookup);
diff --git a/src/polkitbackend/polkitbackendactionlookup.h b/src/polkitbackend/polkitbackendactionlookup.h
index bb93c17..8389a55 100644
--- a/src/polkitbackend/polkitbackendactionlookup.h
+++ b/src/polkitbackend/polkitbackendactionlookup.h
@@ -70,35 +70,35 @@ struct _PolkitBackendActionLookupIface
   /*< public >*/
   /* VTable */
 
-  gchar *        (*get_message)   (PolkitBackendActionLookup *lookup,
-                                   const gchar               *action_id,
-                                   GHashTable                *details,
-                                   PolkitActionDescription   *action_description);
+  gchar *           (*get_message)   (PolkitBackendActionLookup *lookup,
+                                      const gchar               *action_id,
+                                      PolkitDetails             *details,
+                                      PolkitActionDescription   *action_description);
 
-  gchar *        (*get_icon_name) (PolkitBackendActionLookup *lookup,
-                                   const gchar               *action_id,
-                                   GHashTable                *details,
-                                   PolkitActionDescription   *action_description);
+  gchar *           (*get_icon_name) (PolkitBackendActionLookup *lookup,
+                                      const gchar               *action_id,
+                                      PolkitDetails             *details,
+                                      PolkitActionDescription   *action_description);
 
-  GHashTable *   (*get_details)   (PolkitBackendActionLookup *lookup,
-                                   const gchar               *action_id,
-                                   GHashTable                *details,
-                                   PolkitActionDescription   *action_description);
+  PolkitDetails *   (*get_details)   (PolkitBackendActionLookup *lookup,
+                                      const gchar               *action_id,
+                                      PolkitDetails             *details,
+                                      PolkitActionDescription   *action_description);
 };
 
-GType       polkit_backend_action_lookup_get_type    (void) G_GNUC_CONST;
-gchar      *polkit_backend_action_lookup_get_message   (PolkitBackendActionLookup *lookup,
-                                                        const gchar               *action_id,
-                                                        GHashTable                *details,
-                                                        PolkitActionDescription   *action_description);
-gchar      *polkit_backend_action_lookup_get_icon_name (PolkitBackendActionLookup *lookup,
-                                                        const gchar               *action_id,
-                                                        GHashTable                *details,
-                                                        PolkitActionDescription   *action_description);
-GHashTable *polkit_backend_action_lookup_get_details   (PolkitBackendActionLookup *lookup,
-                                                        const gchar               *action_id,
-                                                        GHashTable                *details,
-                                                        PolkitActionDescription   *action_description);
+GType          polkit_backend_action_lookup_get_type      (void) G_GNUC_CONST;
+gchar         *polkit_backend_action_lookup_get_message   (PolkitBackendActionLookup *lookup,
+                                                           const gchar               *action_id,
+                                                           PolkitDetails             *details,
+                                                           PolkitActionDescription   *action_description);
+gchar         *polkit_backend_action_lookup_get_icon_name (PolkitBackendActionLookup *lookup,
+                                                           const gchar               *action_id,
+                                                           PolkitDetails             *details,
+                                                           PolkitActionDescription   *action_description);
+PolkitDetails *polkit_backend_action_lookup_get_details   (PolkitBackendActionLookup *lookup,
+                                                           const gchar               *action_id,
+                                                           PolkitDetails             *details,
+                                                           PolkitActionDescription   *action_description);
 
 G_END_DECLS
 
diff --git a/src/polkitbackend/polkitbackendauthority.c b/src/polkitbackend/polkitbackendauthority.c
index e0f3a8e..63f252d 100644
--- a/src/polkitbackend/polkitbackendauthority.c
+++ b/src/polkitbackend/polkitbackendauthority.c
@@ -222,7 +222,7 @@ polkit_backend_authority_check_authorization (PolkitBackendAuthority        *aut
                                               PolkitSubject                 *caller,
                                               PolkitSubject                 *subject,
                                               const gchar                   *action_id,
-                                              GHashTable                    *details,
+                                              PolkitDetails                 *details,
                                               PolkitCheckAuthorizationFlags  flags,
                                               GCancellable                  *cancellable,
                                               GAsyncReadyCallback            callback,
@@ -830,14 +830,14 @@ authority_handle_check_authorization (_PolkitAuthority               *instance,
   PolkitSubject *subject;
   PolkitSubject *caller;
   GCancellable *cancellable;
-  GHashTable *details;
+  PolkitDetails *details;
 
   caller_name = egg_dbus_method_invocation_get_caller (method_invocation);
   caller = polkit_system_bus_name_new (caller_name);
 
   subject = polkit_subject_new_for_real (real_subject);
 
-  details = real_details->data;
+  details = polkit_details_new_for_hash (real_details->data);
 
   g_object_set_data_full (G_OBJECT (method_invocation), "caller", caller, (GDestroyNotify) g_object_unref);
   g_object_set_data_full (G_OBJECT (method_invocation), "subject", subject, (GDestroyNotify) g_object_unref);
@@ -881,7 +881,7 @@ authority_handle_check_authorization (_PolkitAuthority               *instance,
                                                 check_auth_cb,
                                                 method_invocation);
  out:
-  ;
+  g_object_unref (details);
 }
 
 static void
diff --git a/src/polkitbackend/polkitbackendauthority.h b/src/polkitbackend/polkitbackendauthority.h
index 9b4acfe..1077aad 100644
--- a/src/polkitbackend/polkitbackendauthority.h
+++ b/src/polkitbackend/polkitbackendauthority.h
@@ -123,7 +123,7 @@ struct _PolkitBackendAuthorityClass
                                PolkitSubject                 *caller,
                                PolkitSubject                 *subject,
                                const gchar                   *action_id,
-                               GHashTable                    *details,
+                               PolkitDetails                 *details,
                                PolkitCheckAuthorizationFlags  flags,
                                GCancellable                  *cancellable,
                                GAsyncReadyCallback            callback,
@@ -221,7 +221,7 @@ void     polkit_backend_authority_check_authorization       (PolkitBackendAuthor
                                                              PolkitSubject                 *caller,
                                                              PolkitSubject                 *subject,
                                                              const gchar                   *action_id,
-                                                             GHashTable                    *details,
+                                                             PolkitDetails                 *details,
                                                              PolkitCheckAuthorizationFlags  flags,
                                                              GCancellable                  *cancellable,
                                                              GAsyncReadyCallback            callback,
diff --git a/src/polkitbackend/polkitbackendlocalauthority.c b/src/polkitbackend/polkitbackendlocalauthority.c
index 98e5dd6..4c98aa6 100644
--- a/src/polkitbackend/polkitbackendlocalauthority.c
+++ b/src/polkitbackend/polkitbackendlocalauthority.c
@@ -94,7 +94,7 @@ static void                authentication_agent_initiate_challenge (Authenticati
                                                                     PolkitIdentity              *user_of_subject,
                                                                     PolkitBackendLocalAuthority *authority,
                                                                     const gchar                 *action_id,
-                                                                    GHashTable                  *details,
+                                                                    PolkitDetails               *details,
                                                                     PolkitSubject               *caller,
                                                                     PolkitImplicitAuthorization  implicit_authorization,
                                                                     GCancellable                *cancellable,
@@ -167,7 +167,7 @@ static void polkit_backend_local_authority_check_authorization (PolkitBackendAut
                                                                 PolkitSubject                 *caller,
                                                                 PolkitSubject                 *subject,
                                                                 const gchar                   *action_id,
-                                                                GHashTable                    *details,
+                                                                PolkitDetails                 *details,
                                                                 PolkitCheckAuthorizationFlags  flags,
                                                                 GCancellable                  *cancellable,
                                                                 GAsyncReadyCallback            callback,
@@ -540,7 +540,7 @@ polkit_backend_local_authority_check_authorization (PolkitBackendAuthority
                                                     PolkitSubject                  *caller,
                                                     PolkitSubject                  *subject,
                                                     const gchar                    *action_id,
-                                                    GHashTable                     *details,
+                                                    PolkitDetails                  *details,
                                                     PolkitCheckAuthorizationFlags   flags,
                                                     GCancellable                   *cancellable,
                                                     GAsyncReadyCallback             callback,
@@ -1546,7 +1546,7 @@ get_localized_data_for_challenge (PolkitBackendLocalAuthority *authority,
                                   PolkitSubject               *subject,
                                   PolkitIdentity              *user_of_subject,
                                   const gchar                 *action_id,
-                                  GHashTable                  *details,
+                                  PolkitDetails               *details,
                                   const gchar                 *locale,
                                   gchar                      **out_localized_message,
                                   gchar                      **out_localized_icon_name,
@@ -1554,14 +1554,11 @@ get_localized_data_for_challenge (PolkitBackendLocalAuthority *authority,
 {
   PolkitBackendLocalAuthorityPrivate *priv;
   PolkitActionDescription *action_desc;
-  GHashTableIter iter;
-  const gchar *key;
-  const gchar *value;
   GList *action_lookup_list;
   GList *l;
   gchar *message;
   gchar *icon_name;
-  GHashTable *localized_details;
+  PolkitDetails *localized_details;
 
   priv = POLKIT_BACKEND_LOCAL_AUTHORITY_GET_PRIVATE (authority);
 
@@ -1639,10 +1636,19 @@ get_localized_data_for_challenge (PolkitBackendLocalAuthority *authority,
 
   if (localized_details != NULL)
     {
-      g_hash_table_iter_init (&iter, localized_details);
-      while (g_hash_table_iter_next (&iter, (gpointer) &key, (gpointer) &value))
+      GHashTable *hash;
+      GHashTableIter iter;
+      const gchar *key;
+      const gchar *value;
+
+      hash = polkit_details_get_hash (localized_details);
+      if (hash != NULL)
         {
-          egg_dbus_hash_map_insert (*out_localized_details, key, value);
+          g_hash_table_iter_init (&iter, hash);
+          while (g_hash_table_iter_next (&iter, (gpointer) &key, (gpointer) &value))
+            {
+              egg_dbus_hash_map_insert (*out_localized_details, key, value);
+            }
         }
     }
 
@@ -1663,7 +1669,7 @@ authentication_agent_initiate_challenge (AuthenticationAgent         *agent,
                                          PolkitIdentity              *user_of_subject,
                                          PolkitBackendLocalAuthority *authority,
                                          const gchar                 *action_id,
-                                         GHashTable                  *details,
+                                         PolkitDetails               *details,
                                          PolkitSubject               *caller,
                                          PolkitImplicitAuthorization  implicit_authorization,
                                          GCancellable                *cancellable,
diff --git a/src/programs/pkexec-action-lookup.c b/src/programs/pkexec-action-lookup.c
index 4095c13..75ef8a9 100644
--- a/src/programs/pkexec-action-lookup.c
+++ b/src/programs/pkexec-action-lookup.c
@@ -84,7 +84,7 @@ polkit_exec_action_lookup_class_init (PolkitExecActionLookupClass *klass)
 static gchar *
 polkit_exec_action_lookup_get_message   (PolkitBackendActionLookup *lookup,
                                          const gchar               *action_id,
-                                         GHashTable                *details,
+                                         PolkitDetails             *details,
                                          PolkitActionDescription   *action_description)
 {
   gchar *ret;
@@ -96,11 +96,11 @@ polkit_exec_action_lookup_get_message   (PolkitBackendActionLookup *lookup,
   if (g_strcmp0 (action_id, "org.freedesktop.policykit.exec") != 0)
     goto out;
 
-  s = g_hash_table_lookup (details, "program");
+  s = polkit_details_lookup (details, "program");
   if (s == NULL)
     goto out;
 
-  s2 = g_hash_table_lookup (details, "uid");
+  s2 = polkit_details_lookup (details, "uid");
   if (s2 == NULL)
     goto out;
 
@@ -122,7 +122,7 @@ polkit_exec_action_lookup_get_message   (PolkitBackendActionLookup *lookup,
 static gchar *
 polkit_exec_action_lookup_get_icon_name (PolkitBackendActionLookup *lookup,
                                          const gchar               *action_id,
-                                         GHashTable                *details,
+                                         PolkitDetails             *details,
                                          PolkitActionDescription   *action_description)
 {
   gchar *ret;
@@ -134,15 +134,15 @@ polkit_exec_action_lookup_get_icon_name (PolkitBackendActionLookup *lookup,
   return ret;
 }
 
-static GHashTable *
+static PolkitDetails *
 polkit_exec_action_lookup_get_details   (PolkitBackendActionLookup *lookup,
-                                          const gchar               *action_id,
-                                          GHashTable                *details,
-                                          PolkitActionDescription   *action_desc)
+                                         const gchar               *action_id,
+                                         PolkitDetails             *details,
+                                         PolkitActionDescription   *action_desc)
 {
   const gchar *s;
   const gchar *s2;
-  GHashTable *ret;
+  PolkitDetails *ret;
 
   ret = NULL;
 
@@ -151,25 +151,21 @@ polkit_exec_action_lookup_get_details   (PolkitBackendActionLookup *lookup,
          polkit_action_description_get_annotation (action_desc, "org.freedesktop.policykit.exec.path") != NULL)))
     goto out;
 
-  ret = g_hash_table_new_full (g_str_hash, g_str_equal, NULL, g_free);
+  ret = polkit_details_new ();
 
-  s = g_hash_table_lookup (details, "command-line");
+  s = polkit_details_lookup (details, "command-line");
   if (s != NULL)
     {
-      g_hash_table_insert (ret,
-                           _("Command"),
-                           g_strdup (s));
+      polkit_details_insert (ret, _("Command"), s);
     }
 
-  s = g_hash_table_lookup (details, "user");
-  s2 = g_hash_table_lookup (details, "uid");
+  s = polkit_details_lookup (details, "user");
+  s2 = polkit_details_lookup (details, "uid");
   if (s != NULL)
     {
       if (g_strcmp0 (s2, "0") == 0)
         s = _("Super User (root)");
-      g_hash_table_insert (ret,
-                           _("Run As"),
-                           g_strdup (s));
+      polkit_details_insert (ret, _("Run As"), s);
     }
 
  out:
diff --git a/src/programs/pkexec.c b/src/programs/pkexec.c
index 86f70a5..10329dd 100644
--- a/src/programs/pkexec.c
+++ b/src/programs/pkexec.c
@@ -115,7 +115,7 @@ main (int argc, char *argv[])
   PolkitAuthority *authority;
   PolkitAuthorizationResult *result;
   PolkitSubject *subject;
-  GHashTable *details;
+  PolkitDetails *details;
   GError *error;
   gchar *action_id;
   gchar *command_line;
@@ -319,14 +319,16 @@ main (int argc, char *argv[])
   authority = polkit_authority_get ();
   subject = polkit_unix_process_new (pid_of_caller);
 
-  details = g_hash_table_new_full (g_str_hash, g_str_equal, NULL, g_free);
+  details = polkit_details_new ();
 
-  g_hash_table_insert (details, "command-line", g_strdup (command_line));
+  polkit_details_insert (details, "command-line", command_line);
   s = g_strdup_printf ("%s (%s)", pw->pw_gecos, pw->pw_name);
-  g_hash_table_insert (details, "user", s);
+  polkit_details_insert (details, "user", s);
+  g_free (s);
   s = g_strdup_printf ("%d", (gint) pw->pw_uid);
-  g_hash_table_insert (details, "uid", s);
-  g_hash_table_insert (details, "program", g_strdup (path));
+  polkit_details_insert (details, "uid", s);
+  g_free (s);
+  polkit_details_insert (details, "program", path);
 
   action_id = find_action_for_path (authority, path);
   g_assert (action_id != NULL);
@@ -450,7 +452,7 @@ main (int argc, char *argv[])
   g_free (action_id);
 
   if (details != NULL)
-    g_hash_table_unref (details);
+    g_object_unref (details);
 
   if (subject != NULL)
     g_object_unref (subject);


More information about the hal-commit mailing list