rpms/cups-pk-helper/F-12 cups-pk-helper-job-status.patch, NONE, 1.1 cups-pk-helper.spec, 1.16, 1.17

Marek Kašík mkasik at fedoraproject.org
Tue Feb 23 11:50:48 UTC 2010


Author: mkasik

Update of /cvs/pkgs/rpms/cups-pk-helper/F-12
In directory cvs1.fedora.phx.redhat.com:/tmp/cvs-serv23208

Modified Files:
	cups-pk-helper.spec 
Added Files:
	cups-pk-helper-job-status.patch 
Log Message:
* Tue Feb 23 2010 Marek Kasik <mkasik at redhat.com> - 0.0.4-11
- Make cph_cups_job_get_status() efficient
- Resolves: #548771


cups-pk-helper-job-status.patch:
 cups.c |   35 +++++++++++++++++++++++++----------
 1 file changed, 25 insertions(+), 10 deletions(-)

--- NEW FILE cups-pk-helper-job-status.patch ---
--- cups-pk-helper-0.0.4/src/cups.c.job-status	2010-02-23 12:11:17.000000000 +0100
+++ cups-pk-helper-0.0.4/src/cups.c	2010-02-23 12:35:29.000000000 +0100
@@ -1787,19 +1787,34 @@ cph_cups_job_get_status (CphCups    *cup
                          int         job_id,
                          const char *user)
 {
-        CphJobStatus  status = CPH_JOB_STATUS_INVALID;
-        cups_job_t   *jobs;
-        int           num_jobs;
-        int           i;
+        const char * const  attrs[1] = { "job-originating-user-name" };
+        ipp_t              *request;
+        const char         *resource_char;
+        ipp_t              *reply;
+        ipp_attribute_t    *attr;
+        CphJobStatus        status = CPH_JOB_STATUS_INVALID;
 
         g_return_val_if_fail (CPH_IS_CUPS (cups), CPH_JOB_STATUS_INVALID);
 
-        num_jobs = cupsGetJobs2 (cups->priv->connection, &jobs, NULL, 0, 0);
+        if (!_cph_cups_is_job_id_valid (cups, job_id))
+                return CPH_JOB_STATUS_INVALID;
+
+        request = ippNewRequest (IPP_GET_JOB_ATTRIBUTES);
+        _cph_cups_add_job_uri (request, job_id);
+        ippAddStrings (request, IPP_TAG_OPERATION, IPP_TAG_KEYWORD,
+                       "requested-attributes", 1, NULL, attrs);
+
+        resource_char = _cph_cups_get_resource (CPH_RESOURCE_ROOT);
+        reply = cupsDoRequest (cups->priv->connection,
+                               request, resource_char);
 
-        for (i = 0; i < num_jobs; i++) {
-                if (jobs[i].id == job_id) {
-                        if (user != NULL &&
-                            g_strcmp0 (jobs[i].user, user) == 0)
+        if (!reply || reply->request.status.status_code > IPP_OK_CONFLICT)
+                return CPH_JOB_STATUS_INVALID;
+
+        for (attr = reply->attrs; attr; attr = attr->next) {
+                if (attr->name &&
+                    strcmp (attr->name, "job-originating-user-name") == 0) {
+                        if (g_strcmp0 (attr->values[0].string.text, user) == 0)
                                 status = CPH_JOB_STATUS_OWNED_BY_USER;
                         else
                                 status = CPH_JOB_STATUS_NOT_OWNED_BY_USER;
@@ -1807,7 +1822,7 @@ cph_cups_job_get_status (CphCups    *cup
                 }
         }
 
-        cupsFreeJobs (num_jobs, jobs);
+        ippDelete (reply);
 
         return status;
 }


Index: cups-pk-helper.spec
===================================================================
RCS file: /cvs/pkgs/rpms/cups-pk-helper/F-12/cups-pk-helper.spec,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -p -r1.16 -r1.17
--- cups-pk-helper.spec	10 Dec 2009 17:20:08 -0000	1.16
+++ cups-pk-helper.spec	23 Feb 2010 11:50:47 -0000	1.17
@@ -1,6 +1,6 @@
 Name:           cups-pk-helper
 Version:        0.0.4
-Release:        10%{?dist}
+Release:        11%{?dist}
 Summary:        A helper that makes system-config-printer use PolicyKit
 
 Group:          System Environment/Base
@@ -15,6 +15,7 @@ Patch3:         edit_job.patch
 Patch4:         cups-pk-helper-ppd-name.patch
 Patch5:         allow_authentication.patch
 Patch6:         cups-pk-helper-add-printer-ppd-optional.patch
+Patch7:         cups-pk-helper-job-status.patch
 
 BuildRoot:      %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
 
@@ -51,6 +52,7 @@ interfaces available under control of Po
 %patch4 -p1 -b .ppd-name
 %patch5 -p1 -b .allow_auth
 %patch6 -p1 -b .ppd
+%patch7 -p1 -b .job-status
 
 %build
 # Patch0 modifies configure.ac
@@ -80,6 +82,10 @@ rm -rf $RPM_BUILD_ROOT
 
 
 %changelog
+* Tue Feb 23 2010 Marek Kasik <mkasik at redhat.com> - 0.0.4-11
+- Make cph_cups_job_get_status() efficient
+- Resolves: #548771
+
 * Thu Dec 10 2009 Marek Kasik <mkasik at redhat.com> - 0.0.4-10
 - Fix adding of printers without specification of ppd-name.
 - Patch by Tim Waugh.



More information about the scm-commits mailing list