hold jobs by default (Cups conf or Java)

pieterjandeboeck at yahoo.co.uk pieterjandeboeck at yahoo.co.uk
Wed Jul 28 02:36:47 PDT 2004

Hey Tarik

Yes, i ve been on that for a while, let me help you speed things up.
Assuming you can insert objective-c code in your Java (???) Otherwise there must be equivalent source code out there.

> download the cups source code for your OS. place the folder somewhere relevant to your development. You can find this folder here:


Alternatively, since cups is already running on your system. The files are located at location: /etc/cups . This is a root level directory. don't know about the other operating systems but on OSX it is hidden. (you cannot "search" for it.) On OS X you can open the finder and Press #G to goto a particular directory directly. There must be an equivalent on all systems.

Include all the header files in /cups-58 and /cups-58/cups . On other operating systems this is most likely another number

    #import "cups-58/config.h"
    #import "cups-58/cups/cups.h"
    //#import "cups-58/cups/cups_C.h"
    #import "cups-58/cups/debug.h"
    #import "cups-58/cups/http.h"
    #import "cups-58/cups/http-private.h"
    #import "cups-58/cups/ipp.h"
    #import "cups-58/cups/language.h"
    #import "cups-58/cups/md5.h"
    #import "cups-58/cups/ppd.h"
    #import "cups-58/cups/string.h"

(In c++ that's probably #include <""> instead)

Once you get that running, create a method with this code in it:

	* Build an IPP_HOLD_JOB request, which requires the following
	* attributes:
	*    attributes-charset
	*    attributes-natural-language
	*    job-uri
	*    requesting-user-name

request = ippNew();

request->request.op.operation_id = IPP_HOLD_JOB;
request->request.op.request_id   = 1;

language = cupsLangDefault();

        	     "attributes-charset", NULL,

        	     "attributes-natural-language", NULL, language->language);

slprintf(uri, sizeof(uri) - 1, "ipp://localhost/jobs/%d", pjob->sysjob);

ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_URI, "job-uri", NULL, uri);

ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_NAME, "requesting-user-name",
        	     NULL, pjob->user);

	* Do the request and get back a response...

        ret = 1;

	if ((response = cupsDoRequest(http, request, "/jobs")) != NULL)
	  if (response->request.status.status_code >= IPP_OK_CONFLICT)
		DEBUG(0,("Unable to hold job %d - %s\n", pjob->sysjob,
	  	ret = 0;


pjob->sysjob with the job ID to be replaced. (integer number)
     ->user  is the user of this request: you could get that with the method: -cupsUser();

lastly: you ll get error messages: in /etc/cups/cupsd.conf
set the

LogLevel Info


LogLevel Debug2

for full logging, so you can see exactly what the error was. you can look up these IPP error constant meanings on the internet.

If I got anything wrong, im sure michael will correct me :) Sorry i couldn't give you java specific code.


Tarik Benabid wrote:
> Hi,
> I'm developping a java application, and I have to check jobs, make some works and after allow printing or not.
> outside the solution of backend.
> * are there any Cups configuration, to hold jobs by default.
> * how can I use HOLD_NEW_JOBS in cups/scripting/java/.../IPPDefs.java

More information about the cups mailing list