ipp_hold_job is not holding the job,but showing hold state in queue

akbar akbarbasha at tataelxsi.co.in
Tue Jul 20 04:32:29 PDT 2010


Hi to every one,

I am a mac developer ,I am working in Snow leopard mchine configured with lpd printer.
There is a need to hold the job and read the total number of pages etc whenever giving from our application,
FYI ,User can give print from any application even from the print icon of any application also(direct print).


I  wrote the following code,it was perfectly worked for leopard machine.



	user = cupsUser();

	request = ippNew();


	/* Set up the request */
	request->request.op.operation_id =  IPP_HOLD_JOB;
	request->request.op.request_id = 1;
	language = cupsLangDefault();

	ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_CHARSET,
				 "attributes-charset", NULL, cupsLangEncoding(language));

	ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_LANGUAGE,
				 "attributes-natural-language", NULL, language->language);



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

	ippAddInteger(request, IPP_TAG_OPERATION, IPP_TAG_INTEGER, "job-id",
				  jobId);

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


	//if ((which_jobs = cgiGetVariable("which_jobs")) != NULL)
	ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_KEYWORD,
				 "which-jobs", NULL, which_jobs);

	ippAddStrings(request, IPP_TAG_OPERATION, IPP_TAG_KEYWORD,
				  "requested-attributes",
				  sizeof(def_attrs) / sizeof(def_attrs[0]), NULL,
				  def_attrs);




	if ((response = cupsDoRequest(http, request, "/admin/")) == NULL)
		ipp_status = cupsLastError();
	else
		ipp_status = response->request.status.status_code;

	if (ipp_status == IPP_NOT_FOUND)
	{
		/*
		 * Job has gone away and/or the server has no job history...
		 */

		ippDelete(response);

		ipp_status = IPP_OK;
		//	break;
	}

	if (ipp_status > IPP_OK_CONFLICT)
	{
		if (ipp_status != IPP_SERVICE_UNAVAILABLE &&
			ipp_status != IPP_PRINTER_BUSY)
		{
			if (response)
				ippDelete(response);

			fprintf(stderr, "ERROR: Unable to get hold job !\n",
					ippErrorString(ipp_status));
			//		break;
		}
	}

	if (response)
		ippDelete(response);

I put this code in a daemon , whenever print job arrives to the queue , this code will hold the job in queue.

The above code worked perfectly for leopard.But when I am trying the same in Snow leopard,when I gave print from some application ,I can notice that print job is printing to the printer still the daemon is running fine,But immediately I opened and checked the print queue,print queue is showing hold status of my recently given print job .I tried printing other documents also ,same thing happened.

FYI ,I cannot release the job which are held in the queue(because resume icon is in disabled mode , Delete icon is enabled state).

I assume that this problem is because of print job is printing fastly,so that I cannot see it also.

One more thing I have noticed that I cannot see the print jobs in the queue when  they are printing to printer.

To see print jobs , I have to pause the printer.

Can any body guide me what I am missing to hold job or What to do to pass the print jobs through the queue(Can I slow the print jobs programmatically so that I can see them in queue while printing).


Thanks and regards,
Akbar










More information about the cups-devel mailing list