Index: pykota/trunk/bin/cupspykota
===================================================================
--- pykota/trunk/bin/cupspykota (revision 2624)
+++ pykota/trunk/bin/cupspykota (revision 2631)
@@ -296,4 +296,7 @@
                     self.logdebug("Seen DENY command.")
                     action = "DENY"
+                elif line == "CANCEL" :
+                    self.logdebug("Seen CANCEL command.")
+                    action = "CANCEL"
                 elif line.startswith("USERNAME=") :    
                     username = line.split("=", 1)[1].strip()
@@ -307,7 +310,10 @@
             
             # now overwrite the job's ticket if new data was supplied
-            if action :
+            if action == "DENY" :
                 self.Action = action
                 self.Reason = _("You are not allowed to print at this time.")
+            elif action == "CANCEL" :
+                self.Action = action
+                self.Reason = _("Print job cancelled.")
             if username :
                 self.UserName = username
@@ -891,5 +897,5 @@
         self.exportPhaseInfo("BEFORE")
         
-        if self.Action != "DENY" : 
+        if self.Action not in ("DENY", "CANCEL") : 
             if self.Printer.MaxJobSize and (self.softwareJobSize > self.Printer.MaxJobSize) :
                 # This printer was set to refuse jobs this large.
@@ -900,5 +906,5 @@
                 self.Reason = _("You are not allowed to print so many pages on printer %s at this time.") % self.PrinterName
             
-        if self.Action != "DENY" :
+        if self.Action not in ("DENY", "CANCEL") :
             if self.User.LimitBy == "noprint" :
                 self.printInfo(_("User %s is not allowed to print at this time.") % self.UserName, "warn")
@@ -906,5 +912,5 @@
                 self.Reason = _("Your account settings forbid you to print at this time.")
                 
-        if self.Action != "DENY" :
+        if self.Action not in ("DENY", "CANCEL") :
             # If printing is still allowed at this time, we
             # need to extract the billing code information from the database.
@@ -913,5 +919,5 @@
             self.getBillingCode()
             
-        if self.Action != "DENY" :
+        if self.Action not in ("DENY", "CANCEL") :
             # If printing is still allowed at this time, we
             # need to check if the job is a dupe or not, and what to do then.
@@ -920,5 +926,5 @@
             self.checkIfDupe()
                     
-        if self.Action != "DENY" :
+        if self.Action not in ("DENY", "CANCEL") :
             # If printing is still allowed at this time, we
             # need to check the user's print quota on the current printer.
@@ -962,4 +968,6 @@
         if self.Action == "DENY" :
             self.printInfo(_("Job denied, no accounting will be done."))
+        elif self.Action == "CANCEL" :    
+            self.printInfo(_("Job cancelled, no accounting will be done."))
         else :
             self.printInfo(_("Job accounting begins."))
@@ -990,4 +998,6 @@
         if self.Action == "DENY" :
             self.printInfo(_("Job denied, no accounting has been done."))
+        elif self.Action == "CANCEL" :    
+            self.printInfo(_("Job cancelled, no accounting has been done."))
         else :
             self.deinstallSigTermHandler()
@@ -1020,4 +1030,7 @@
                 self.JobSize = 0
                 self.printInfo(_("Job size forced to 0 because printing is denied."))
+            elif self.Action == "CANCEL" :     
+                self.JobSize = 0
+                self.printInfo(_("Job size forced to 0 because printing was cancelled."))
             else :    
                 self.UserPQuota.resetDenyBannerCounter()
@@ -1028,5 +1041,6 @@
             self.printInfo(_("Job size : %i") % self.JobSize)
             
-            if (self.Action == "PROBLEM") and (onbackenderror == "NOCHARGE") :
+            if ((self.Action == "PROBLEM") and (onbackenderror == "NOCHARGE")) or \
+                (self.Action in ("DENY", "CANCEL")) :
                 self.JobPrice = 0.0
             elif (self.User.LimitBy == "nochange") or self.Printer.PassThrough :
@@ -1048,5 +1062,6 @@
             
             if hasattr(self, "BillingCode") and self.BillingCode and self.BillingCode.Exists :
-                if (self.Action != "PROBLEM") or (onbackenderror == "CHARGE") :
+                if (self.Action in ("ALLOW", "WARN")) or \
+                   ((self.Action == "PROBLEM") and (onbackenderror == "CHARGE")) :
                     self.BillingCode.consume(self.JobSize, self.JobPrice)
                     self.printInfo(_("Billing code %s was updated.") % self.BillingCode.BillingCode)
