PolicyKit: Branch 'master'

David Zeuthen david at kemper.freedesktop.org
Thu Feb 28 09:33:11 PST 2008


 src/polkit-dbus/polkit-simple.c |   34 +++++++++++++++++++++++++++++++++-
 src/polkit-dbus/polkit-simple.h |    1 +
 2 files changed, 34 insertions(+), 1 deletion(-)

New commits:
commit d6d484216780acedf1545354464753528808bb09
Author: David Zeuthen <davidz at redhat.com>
Date:   Thu Feb 28 12:28:39 2008 -0500

    also add polkit_dbus_error_parse_from_strings() function
    
    This is useful when using D-Bus bindings, such as dbus-glib, that
    don't expose the DBusError object directly.

diff --git a/src/polkit-dbus/polkit-simple.c b/src/polkit-dbus/polkit-simple.c
index d815046..d7059d2 100644
--- a/src/polkit-dbus/polkit-simple.c
+++ b/src/polkit-dbus/polkit-simple.c
@@ -527,6 +527,38 @@ out:
         return ret;
 }
 
+/**
+ * polkit_dbus_error_parse_from_strings:
+ * @error_name: name of D-Bus error
+ * @error_message: name of D-Bus error
+ * @action: return location for #PolKitAction object
+ * @result: return location for #PolKitResult variable
+ *
+ * Like polkit_dbus_error_parse(), only it takes the name and message
+ * instead of a #DBusError. This is useful when usings D-Bus bindings
+ * (such as dbus-glib) that don't expose the #DBusError object
+ * directly.
+ *
+ * This function is in <literal>libpolkit-dbus</literal>.
+ *
+ * Returns: See polkit_dbus_error_parse().
+ *
+ * Since: 0.8
+ */
+polkit_bool_t
+polkit_dbus_error_parse_from_strings (const char *error_name, 
+                                      const char *error_message, 
+                                      PolKitAction **action, 
+                                      PolKitResult *result)
+{
+        DBusError error;
+
+        dbus_error_init (&error);
+        dbus_set_error_const (&error, error_name, error_message);
+
+        return polkit_dbus_error_parse (&error, action, result);
+}
+
 #ifdef POLKIT_BUILD_TESTS
 
 static polkit_bool_t
@@ -546,7 +578,7 @@ _run_test (void)
                                 PolKitAction *a2;
                                 PolKitResult r2;
 
-                                if (polkit_dbus_error_parse (&error, &a2, &r2)) {
+                                if (polkit_dbus_error_parse_from_strings (error.name, error.message, &a2, &r2)) {
                                         kit_assert (polkit_action_equal (a, a2));
                                         kit_assert (r == r2);
                                         polkit_action_unref (a2);
diff --git a/src/polkit-dbus/polkit-simple.h b/src/polkit-dbus/polkit-simple.h
index 0aff3d4..3c59314 100644
--- a/src/polkit-dbus/polkit-simple.h
+++ b/src/polkit-dbus/polkit-simple.h
@@ -45,6 +45,7 @@ polkit_bool_t   polkit_auth_obtain (const char *action_id, polkit_uint32_t xid,
 
 polkit_bool_t  polkit_dbus_error_generate              (PolKitAction *action, PolKitResult result, DBusError *error);
 polkit_bool_t  polkit_dbus_error_parse                 (DBusError *error, PolKitAction **action, PolKitResult *result);
+polkit_bool_t  polkit_dbus_error_parse_from_strings    (const char *error_name, const char *error_message, PolKitAction **action, PolKitResult *result);
 
 POLKIT_END_DECLS
 


More information about the hal-commit mailing list