Blob Blame History Raw
--- cups-pk-helper-0.0.4/src/cups-pk-helper-mechanism.c.invalid-job	2010-02-23 13:21:27.000000000 +0100
+++ cups-pk-helper-0.0.4/src/cups-pk-helper-mechanism.c	2010-02-23 13:33:08.000000000 +0100
@@ -439,8 +439,11 @@ _cph_mechanism_return_error (CphMechanis
 {
         const char *error;
 
-        if (failed)
+        if (failed) {
                 error = cph_cups_last_status_to_string (mechanism->priv->cups);
+                if (!error || error[0] == '\0')
+                        error = "Unknown error";
+        }
         else
                 error = "";
 
@@ -455,8 +458,11 @@ _cph_mechanism_return_error_and_value (C
 {
         const char *error;
 
-        if (failed)
+        if (failed) {
                 error = cph_cups_last_status_to_string (mechanism->priv->cups);
+                if (!error || error[0] == '\0')
+                        error = "Unknown error";
+        }
         else
                 error = "";
 
@@ -996,18 +1002,25 @@ cph_mechanism_job_cancel (CphMechanism  
                 case CPH_JOB_STATUS_OWNED_BY_USER: {
                         if (!_check_polkit_for_action_v (mechanism, context,
                                                          "job-edit",
-                                                         NULL))
+                                                         NULL)) {
+                                g_free (user_name);
                                 return FALSE;
+                        }
                         break;
                 }
                 case CPH_JOB_STATUS_NOT_OWNED_BY_USER: {
                         if (!_check_polkit_for_action (mechanism, context,
-                                                       "job-not-owned-edit"))
+                                                       "job-not-owned-edit")) {
+                                g_free (user_name);
                                 return FALSE;
+                        }
                         break;
                 }
-                case CPH_JOB_STATUS_INVALID:
+                case CPH_JOB_STATUS_INVALID: {
+                        _cph_mechanism_return_error (mechanism, context, TRUE);
+                        g_free (user_name);
                         return FALSE;
+                }
         }
 
         ret = cph_cups_job_cancel (mechanism->priv->cups, id, user_name);
@@ -1037,18 +1050,25 @@ cph_mechanism_job_restart (CphMechanism 
                 case CPH_JOB_STATUS_OWNED_BY_USER: {
                         if (!_check_polkit_for_action_v (mechanism, context,
                                                          "job-edit",
-                                                         NULL))
+                                                         NULL)) {
+                                g_free (user_name);
                                 return FALSE;
+                        }
                         break;
                 }
                 case CPH_JOB_STATUS_NOT_OWNED_BY_USER: {
                         if (!_check_polkit_for_action (mechanism, context,
-                                                       "job-not-owned-edit"))
+                                                       "job-not-owned-edit")) {
+                                g_free (user_name);
                                 return FALSE;
+                        }
                         break;
                 }
-                case CPH_JOB_STATUS_INVALID:
+                case CPH_JOB_STATUS_INVALID: {
+                        _cph_mechanism_return_error (mechanism, context, TRUE);
+                        g_free (user_name);
                         return FALSE;
+                }
         }
 
         ret = cph_cups_job_restart (mechanism->priv->cups, id, user_name);
@@ -1079,18 +1099,25 @@ cph_mechanism_job_set_hold_until (CphMec
                 case CPH_JOB_STATUS_OWNED_BY_USER: {
                         if (!_check_polkit_for_action_v (mechanism, context,
                                                          "job-edit",
-                                                         NULL))
+                                                         NULL)) {
+                                g_free (user_name);
                                 return FALSE;
+                        }
                         break;
                 }
                 case CPH_JOB_STATUS_NOT_OWNED_BY_USER: {
                         if (!_check_polkit_for_action (mechanism, context,
-                                                       "job-not-owned-edit"))
+                                                       "job-not-owned-edit")) {
+                                g_free (user_name);
                                 return FALSE;
+                        }
                         break;
                 }
-                case CPH_JOB_STATUS_INVALID:
+                case CPH_JOB_STATUS_INVALID: {
+                        _cph_mechanism_return_error (mechanism, context, TRUE);
+                        g_free (user_name);
                         return FALSE;
+                }
         }
 
         ret = cph_cups_job_set_hold_until (mechanism->priv->cups, id, job_hold_until, user_name);