diff options
author | Marek Kasik <mkasik@redhat.com> | 2010-02-18 18:22:38 +0100 |
---|---|---|
committer | Vincent Untz <vuntz@novell.com> | 2010-02-19 14:59:15 +0100 |
commit | 6ec80887768e2d61b5d5c26c2a2269716c86eff9 (patch) | |
tree | e9e63439fa50a736f5540470c5291597cb09320e | |
parent | e6984fdf7d3d6fda79f4839b245fcca98fff8ebb (diff) |
Add JobCancelPurge method
This method is similar to JobCancel, but takes one additional parameter,
"purge". This controls purging of history and document of all jobs.
JobCancel is marked as deprecated, but is still available for
compatibility.
https://bugzilla.redhat.com/show_bug.cgi?id=548756
-rw-r--r-- | src/cups-pk-helper-mechanism.c | 11 | ||||
-rw-r--r-- | src/cups-pk-helper-mechanism.h | 6 | ||||
-rw-r--r-- | src/cups-pk-helper-mechanism.xml | 8 | ||||
-rw-r--r-- | src/cups.c | 20 | ||||
-rw-r--r-- | src/cups.h | 1 |
5 files changed, 41 insertions, 5 deletions
diff --git a/src/cups-pk-helper-mechanism.c b/src/cups-pk-helper-mechanism.c index 8485c6c..7026635 100644 --- a/src/cups-pk-helper-mechanism.c +++ b/src/cups-pk-helper-mechanism.c @@ -1024,6 +1024,15 @@ cph_mechanism_job_cancel (CphMechanism *mechanism, int id, DBusGMethodInvocation *context) { + return cph_mechanism_job_cancel_purge (mechanism, id, FALSE, context); +} + +gboolean +cph_mechanism_job_cancel_purge (CphMechanism *mechanism, + int id, + gboolean purge, + DBusGMethodInvocation *context) +{ CphJobStatus job_status; gboolean ret; char *user_name; @@ -1053,7 +1062,7 @@ cph_mechanism_job_cancel (CphMechanism *mechanism, return FALSE; } - ret = cph_cups_job_cancel (mechanism->priv->cups, id, user_name); + ret = cph_cups_job_cancel (mechanism->priv->cups, id, purge, user_name); _cph_mechanism_return_error (mechanism, context, !ret); g_free (user_name); diff --git a/src/cups-pk-helper-mechanism.h b/src/cups-pk-helper-mechanism.h index 03e579f..ab0d572 100644 --- a/src/cups-pk-helper-mechanism.h +++ b/src/cups-pk-helper-mechanism.h @@ -234,6 +234,12 @@ cph_mechanism_job_cancel (CphMechanism *mechanism, DBusGMethodInvocation *context); gboolean +cph_mechanism_job_cancel_purge (CphMechanism *mechanism, + int id, + gboolean purge, + DBusGMethodInvocation *context); + +gboolean cph_mechanism_job_restart (CphMechanism *mechanism, int id, DBusGMethodInvocation *context); diff --git a/src/cups-pk-helper-mechanism.xml b/src/cups-pk-helper-mechanism.xml index b911ff1..b26c340 100644 --- a/src/cups-pk-helper-mechanism.xml +++ b/src/cups-pk-helper-mechanism.xml @@ -196,12 +196,20 @@ <!-- Methods for jobs --> + <!-- JobCancel is deprecated; JobCancelPurge should be used instead --> <method name="JobCancel"> <annotation name="org.freedesktop.DBus.GLib.Async" value=""/> <arg name="jobid" direction="in" type="i"/> <arg name="error" direction="out" type="s"/> </method> + <method name="JobCancelPurge"> + <annotation name="org.freedesktop.DBus.GLib.Async" value=""/> + <arg name="jobid" direction="in" type="i"/> + <arg name="purge" direction="in" type="b"/> + <arg name="error" direction="out" type="s"/> + </method> + <method name="JobRestart"> <annotation name="org.freedesktop.DBus.GLib.Async" value=""/> <arg name="jobid" direction="in" type="i"/> @@ -2066,8 +2066,11 @@ out: gboolean cph_cups_job_cancel (CphCups *cups, int job_id, + gboolean purge_job, const char *user_name) { + ipp_t *request; + g_return_val_if_fail (CPH_IS_CUPS (cups), FALSE); if (!_cph_cups_is_job_id_valid (cups, job_id)) @@ -2075,10 +2078,19 @@ cph_cups_job_cancel (CphCups *cups, /* we don't check if the user name is valid or not because it comes * from getpwuid(), and not dbus */ - return _cph_cups_send_new_simple_job_request (cups, IPP_CANCEL_JOB, - job_id, - user_name, - CPH_RESOURCE_JOBS); + request = ippNewRequest (IPP_CANCEL_JOB); + _cph_cups_add_job_uri (request, job_id); + + if (user_name != NULL) + ippAddString (request, IPP_TAG_OPERATION, IPP_TAG_NAME, + "requesting-user-name", NULL, user_name); + +#if (CUPS_VERSION_MAJOR == 1 && CUPS_VERSION_MINOR >= 4) || CUPS_VERSION_MAJOR > 1 + if (purge_job) + ippAddBoolean (request, IPP_TAG_OPERATION, "purge-job", 1); +#endif + + return _cph_cups_send_request (cups, request, CPH_RESOURCE_JOBS); } gboolean @@ -173,6 +173,7 @@ gboolean cph_cups_printer_class_set_option_default (CphCups *cups, gboolean cph_cups_job_cancel (CphCups *cups, int job_id, + gboolean purge_job, const char *user_name); gboolean cph_cups_job_restart (CphCups *cups, |