summaryrefslogtreecommitdiff
path: root/src/cups-pk-helper-mechanism.c
diff options
context:
space:
mode:
authorVincent Untz <vuntz@novell.com>2008-11-20 15:36:10 +0100
committerVincent Untz <vuntz@novell.com>2008-11-20 15:36:10 +0100
commitb2e1a3ad0952c62f7dda257544fab61d7c53eedf (patch)
treeb366fc5ef249e1361739f77edb6f6fea7a351de4 /src/cups-pk-helper-mechanism.c
parent32652bcef3548370a165f9657ed5fee7759a1dec (diff)
Add ServerGetSettings/ServerSetSettings
Diffstat (limited to 'src/cups-pk-helper-mechanism.c')
-rw-r--r--src/cups-pk-helper-mechanism.c52
1 files changed, 52 insertions, 0 deletions
diff --git a/src/cups-pk-helper-mechanism.c b/src/cups-pk-helper-mechanism.c
index c86fc20..5cca42c 100644
--- a/src/cups-pk-helper-mechanism.c
+++ b/src/cups-pk-helper-mechanism.c
@@ -375,6 +375,22 @@ _cph_mechanism_return_error (CphMechanism *mechanism,
dbus_g_method_return (context, error);
}
+static void
+_cph_mechanism_return_error_and_value (CphMechanism *mechanism,
+ DBusGMethodInvocation *context,
+ gboolean failed,
+ gpointer value)
+{
+ const char *error;
+
+ if (failed)
+ error = cph_cups_last_status_to_string (mechanism->priv->cups);
+ else
+ error = "";
+
+ dbus_g_method_return (context, error, value);
+}
+
/* exported methods */
gboolean
@@ -726,3 +742,39 @@ cph_mechanism_printer_set_accept_jobs (CphMechanism *mechanism,
return TRUE;
}
+
+gboolean
+cph_mechanism_server_get_settings (CphMechanism *mechanism,
+ DBusGMethodInvocation *context)
+{
+ GHashTable *settings;
+
+ reset_killtimer (mechanism);
+
+ if (!_check_polkit_for_action (mechanism, context, "printeraddremove"))
+ return FALSE;
+
+ settings = cph_cups_server_get_settings (mechanism->priv->cups);
+ _cph_mechanism_return_error_and_value (mechanism, context,
+ settings == NULL, settings);
+
+ return TRUE;
+}
+
+gboolean
+cph_mechanism_server_set_settings (CphMechanism *mechanism,
+ GHashTable *settings,
+ DBusGMethodInvocation *context)
+{
+ gboolean ret;
+
+ reset_killtimer (mechanism);
+
+ if (!_check_polkit_for_action (mechanism, context, "printeraddremove"))
+ return FALSE;
+
+ ret = cph_cups_server_set_settings (mechanism->priv->cups, settings);
+ _cph_mechanism_return_error (mechanism, context, !ret);
+
+ return TRUE;
+}