add infrastructure for CheckClaim() method
authorDavid Zeuthen <davidz@redhat.com>
Mon, 12 Jan 2009 21:54:54 +0000 (16:54 -0500)
committerDavid Zeuthen <davidz@redhat.com>
Mon, 12 Jan 2009 21:54:54 +0000 (16:54 -0500)
src/polkitbackend/polkitbackendauthority.c
src/polkitbackend/polkitbackendauthority.h
src/polkitbackend/polkitbackendlocalauthority.c
src/polkitbackend/polkitbackendserver.c

index 36d997d..97ef38a 100644 (file)
@@ -71,3 +71,15 @@ polkit_backend_authority_enumerate_groups (PolkitBackendAuthority   *authority,
 
   klass->enumerate_groups (authority, pending_call);
 }
+
+void
+polkit_backend_authority_check_claim (PolkitBackendAuthority    *authority,
+                                      PolkitAuthorizationClaim  *claim,
+                                      PolkitBackendPendingCall  *pending_call)
+{
+  PolkitBackendAuthorityClass *klass;
+
+  klass = POLKIT_BACKEND_AUTHORITY_GET_CLASS (authority);
+
+  klass->check_claim (authority, claim, pending_call);
+}
index 80e9725..3a54a4c 100644 (file)
@@ -61,6 +61,10 @@ struct _PolkitBackendAuthorityClass
   void (*enumerate_groups)  (PolkitBackendAuthority   *authority,
                              PolkitBackendPendingCall *pending_call);
 
+  void (*check_claim)       (PolkitBackendAuthority   *authority,
+                             PolkitAuthorizationClaim *claim,
+                             PolkitBackendPendingCall *pending_call);
+
   /*< private >*/
   /* Padding for future expansion */
   void (*_polkit_reserved1) (void);
@@ -75,24 +79,36 @@ struct _PolkitBackendAuthorityClass
 
 GType    polkit_backend_authority_get_type (void) G_GNUC_CONST;
 
-void     polkit_backend_authority_enumerate_actions        (PolkitBackendAuthority   *authority,
-                                                            const gchar              *locale,
-                                                            PolkitBackendPendingCall *pending_call);
+/* --- */
+
+void     polkit_backend_authority_enumerate_actions        (PolkitBackendAuthority    *authority,
+                                                            const gchar               *locale,
+                                                            PolkitBackendPendingCall  *pending_call);
+
+void     polkit_backend_authority_enumerate_users          (PolkitBackendAuthority    *authority,
+                                                            PolkitBackendPendingCall  *pending_call);
+
+void     polkit_backend_authority_enumerate_groups         (PolkitBackendAuthority    *authority,
+                                                            PolkitBackendPendingCall  *pending_call);
+
+void     polkit_backend_authority_check_claim              (PolkitBackendAuthority    *authority,
+                                                            PolkitAuthorizationClaim  *claim,
+                                                            PolkitBackendPendingCall  *pending_call);
+
+/* --- */
 
-void     polkit_backend_authority_enumerate_users          (PolkitBackendAuthority   *authority,
-                                                            PolkitBackendPendingCall *pending_call);
+void     polkit_backend_authority_enumerate_actions_finish (PolkitBackendPendingCall  *pending_call,
+                                                            GList                     *actions);
 
-void     polkit_backend_authority_enumerate_groups         (PolkitBackendAuthority   *authority,
-                                                            PolkitBackendPendingCall *pending_call);
+void     polkit_backend_authority_enumerate_users_finish   (PolkitBackendPendingCall  *pending_call,
+                                                            GList                     *users);
 
-void     polkit_backend_authority_enumerate_actions_finish (PolkitBackendPendingCall *pending_call,
-                                                            GList                    *actions);
+void     polkit_backend_authority_enumerate_groups_finish  (PolkitBackendPendingCall  *pending_call,
+                                                            GList                     *groups);
 
-void     polkit_backend_authority_enumerate_users_finish   (PolkitBackendPendingCall *pending_call,
-                                                            GList                    *users);
+void     polkit_backend_authority_check_claim_finish       (PolkitBackendPendingCall  *pending_call,
+                                                            PolkitAuthorizationResult  result);
 
-void     polkit_backend_authority_enumerate_groups_finish  (PolkitBackendPendingCall *pending_call,
-                                                            GList                    *groups);
 
 G_END_DECLS
 
index 94d0cbb..ddc69c5 100644 (file)
@@ -45,6 +45,10 @@ static void polkit_backend_local_authority_enumerate_users   (PolkitBackendAutho
 static void polkit_backend_local_authority_enumerate_groups  (PolkitBackendAuthority   *authority,
                                                               PolkitBackendPendingCall *pending_call);
 
+static void polkit_backend_local_authority_check_claim       (PolkitBackendAuthority   *authority,
+                                                              PolkitAuthorizationClaim *claim,
+                                                              PolkitBackendPendingCall *pending_call);
+
 G_DEFINE_TYPE (PolkitBackendLocalAuthority, polkit_backend_local_authority, POLKIT_BACKEND_TYPE_AUTHORITY);
 
 #define POLKIT_BACKEND_LOCAL_AUTHORITY_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), POLKIT_BACKEND_TYPE_LOCAL_AUTHORITY, PolkitBackendLocalAuthorityPrivate))
@@ -91,6 +95,7 @@ polkit_backend_local_authority_class_init (PolkitBackendLocalAuthorityClass *kla
   authority_class->enumerate_actions = polkit_backend_local_authority_enumerate_actions;
   authority_class->enumerate_users   = polkit_backend_local_authority_enumerate_users;
   authority_class->enumerate_groups  = polkit_backend_local_authority_enumerate_groups;
+  authority_class->check_claim       = polkit_backend_local_authority_check_claim;
 
   g_type_class_add_private (klass, sizeof (PolkitBackendLocalAuthorityPrivate));
 }
@@ -209,3 +214,15 @@ polkit_backend_local_authority_enumerate_groups (PolkitBackendAuthority   *autho
  out:
   ;
 }
+
+static void
+polkit_backend_local_authority_check_claim (PolkitBackendAuthority   *authority,
+                                            PolkitAuthorizationClaim *claim,
+                                            PolkitBackendPendingCall *pending_call)
+{
+  polkit_backend_pending_call_return_error (pending_call,
+                                            POLKIT_ERROR,
+                                            POLKIT_ERROR_NOT_SUPPORTED,
+                                            "Not implemented");
+}
+
index 8cc25c6..e9557a1 100644 (file)
@@ -164,6 +164,8 @@ polkit_backend_authority_enumerate_users_finish (PolkitBackendPendingCall *pendi
 
   g_list_foreach (users, (GFunc) g_object_unref, NULL);
   g_list_free (users);
+
+  g_object_unref (pending_call);
 }
 
 static void
@@ -203,6 +205,43 @@ polkit_backend_authority_enumerate_groups_finish (PolkitBackendPendingCall *pend
 
   g_list_foreach (groups, (GFunc) g_object_unref, NULL);
   g_list_free (groups);
+
+  g_object_unref (pending_call);
+}
+
+static void
+authority_handle_check_claim (_PolkitAuthority          *instance,
+                              _PolkitAuthorizationClaim *real_claim,
+                              EggDBusMethodInvocation   *method_invocation)
+{
+  PolkitBackendServer *server = POLKIT_BACKEND_SERVER (instance);
+  PolkitBackendPendingCall *pending_call;
+  PolkitAuthorizationClaim *claim;
+
+  pending_call = _polkit_backend_pending_call_new (method_invocation, server);
+
+  claim = polkit_authorization_claim_new_for_real (real_claim);
+
+  g_object_set_data_full (G_OBJECT (pending_call), "claim", claim, (GDestroyNotify) g_object_unref);
+
+  polkit_backend_authority_check_claim (server->authority, claim, pending_call);
+}
+
+void
+polkit_backend_authority_check_claim_finish (PolkitBackendPendingCall  *pending_call,
+                                             PolkitAuthorizationResult  result)
+{
+  EggDBusHashMap *attributes;
+
+  attributes = egg_dbus_hash_map_new (G_TYPE_STRING, g_free, G_TYPE_STRING, g_free);
+
+  _polkit_authority_handle_check_claim_finish (_polkit_backend_pending_call_get_method_invocation (pending_call),
+                                               result,
+                                               attributes);
+
+  g_object_unref (attributes);
+
+  g_object_unref (pending_call);
 }
 
 static void
@@ -211,4 +250,5 @@ authority_iface_init (_PolkitAuthorityIface *authority_iface)
   authority_iface->handle_enumerate_actions = authority_handle_enumerate_actions;
   authority_iface->handle_enumerate_users   = authority_handle_enumerate_users;
   authority_iface->handle_enumerate_groups  = authority_handle_enumerate_groups;
+  authority_iface->handle_check_claim       = authority_handle_check_claim;
 }