2 * Support code for the Common UNIX Printing System ("CUPS")
4 * Copyright 1999-2001 by Easy Software Products
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
25 #include <cups/cups.h>
26 #include <cups/language.h>
30 * CUPS printing interface definitions...
33 static int cups_job_delete(int snum, struct printjob *pjob);
34 static int cups_job_pause(int snum, struct printjob *pjob);
35 static int cups_job_resume(int snum, struct printjob *pjob);
36 static int cups_job_submit(int snum, struct printjob *pjob);
37 static int cups_queue_get(int snum, print_queue_struct **q,
38 print_status_struct *status);
39 static int cups_queue_pause(int snum);
40 static int cups_queue_resume(int snum);
43 struct printif cups_printif =
54 extern int DEBUGLEVEL;
58 * 'cups_passwd_cb()' - The CUPS password callback...
61 const char * /* O - Password or NULL */
62 cups_passwd_cb(const char *prompt) /* I - Prompt */
65 * Always return NULL to indicate that no password is available...
75 * 'cups_printer_fn()' - Call a function for every printer known to the
80 cups_printer_fn(void (*fn)(char *, char *)) /* I - Function to call */
82 http_t *http; /* HTTP connection to server */
83 ipp_t *request, /* IPP Request */
84 *response; /* IPP Response */
85 ipp_attribute_t *attr; /* Current attribute */
86 cups_lang_t *language; /* Default language */
87 char *name, /* printer-name attribute */
88 *make_model, /* printer-make-and-model attribute */
89 *info; /* printer-info attribute */
90 static const char *requested[] =/* Requested attributes */
93 "printer-make-and-model",
98 DEBUG(5,("cups_printer_fn(%p)\n", fn));
101 * Make sure we don't ask for passwords...
104 cupsSetPasswordCB(cups_passwd_cb);
107 * Try to connect to the server...
110 if ((http = httpConnect(cupsServer(), ippPort())) == NULL)
112 DEBUG(0,("Unable to connect to CUPS server %s - %s\n",
113 cupsServer(), strerror(errno)));
118 * Build a CUPS_GET_PRINTERS request, which requires the following
122 * attributes-natural-language
123 * requested-attributes
128 request->request.op.operation_id = CUPS_GET_PRINTERS;
129 request->request.op.request_id = 1;
131 language = cupsLangDefault();
133 ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_CHARSET,
134 "attributes-charset", NULL, cupsLangEncoding(language));
136 ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_LANGUAGE,
137 "attributes-natural-language", NULL, language->language);
139 ippAddStrings(request, IPP_TAG_OPERATION, IPP_TAG_NAME,
140 "requested-attributes",
141 (sizeof(requested) / sizeof(requested[0])),
145 * Do the request and get back a response...
148 if ((response = cupsDoRequest(http, request, "/")) == NULL)
150 DEBUG(0,("Unable to get printer list - %s\n",
151 ippErrorString(cupsLastError())));
156 for (attr = response->attrs; attr != NULL;)
159 * Skip leading attributes until we hit a printer...
162 while (attr != NULL && attr->group_tag != IPP_TAG_PRINTER)
169 * Pull the needed attributes from this printer...
176 while (attr != NULL && attr->group_tag == IPP_TAG_PRINTER)
178 if (strcmp(attr->name, "printer-name") == 0 &&
179 attr->value_tag == IPP_TAG_NAME)
180 name = attr->values[0].string.text;
182 if (strcmp(attr->name, "printer-make-and-model") == 0 &&
183 attr->value_tag == IPP_TAG_TEXT)
184 make_model = attr->values[0].string.text;
186 if (strcmp(attr->name, "printer-info") == 0 &&
187 attr->value_tag == IPP_TAG_TEXT)
188 info = attr->values[0].string.text;
194 * See if we have everything needed...
200 if (info == NULL || !info[0])
201 (*fn)(name, make_model);
214 * 'cups_printername_ok()' - Provide the equivalent of pcap_printername_ok()
218 int /* O - 1 if printer name OK */
219 cups_printername_ok(char *name) /* I - Name of printer */
221 http_t *http; /* HTTP connection to server */
222 ipp_t *request, /* IPP Request */
223 *response; /* IPP Response */
224 cups_lang_t *language; /* Default language */
225 char uri[HTTP_MAX_URI]; /* printer-uri attribute */
228 DEBUG(5,("cups_printername_ok(\"%s\")\n", name));
231 * Make sure we don't ask for passwords...
234 cupsSetPasswordCB(cups_passwd_cb);
237 * Try to connect to the server...
240 if ((http = httpConnect(cupsServer(), ippPort())) == NULL)
242 DEBUG(0,("Unable to connect to CUPS server %s - %s\n",
243 cupsServer(), strerror(errno)));
248 * Build an IPP_GET_PRINTER_ATTRS request, which requires the following
252 * attributes-natural-language
253 * requested-attributes
259 request->request.op.operation_id = IPP_GET_PRINTER_ATTRIBUTES;
260 request->request.op.request_id = 1;
262 language = cupsLangDefault();
264 ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_CHARSET,
265 "attributes-charset", NULL, cupsLangEncoding(language));
267 ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_LANGUAGE,
268 "attributes-natural-language", NULL, language->language);
270 ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_NAME,
271 "requested-attributes", NULL, "printer-uri");
273 slprintf(uri, sizeof(uri) - 1, "ipp://localhost/printers/%s", name);
275 ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_URI,
276 "printer-uri", NULL, uri);
279 * Do the request and get back a response...
282 if ((response = cupsDoRequest(http, request, "/")) == NULL)
284 DEBUG(0,("Unable to get printer status for %s - %s\n", name,
285 ippErrorString(cupsLastError())));
292 if (response->request.status.status_code >= IPP_OK_CONFLICT)
294 DEBUG(0,("Unable to get printer status for %s - %s\n", name,
295 ippErrorString(response->request.status.status_code)));
308 * 'cups_job_delete()' - Delete a job.
312 cups_job_delete(int snum, struct printjob *pjob)
314 int ret; /* Return value */
315 http_t *http; /* HTTP connection to server */
316 ipp_t *request, /* IPP Request */
317 *response; /* IPP Response */
318 cups_lang_t *language; /* Default language */
319 char uri[HTTP_MAX_URI]; /* printer-uri attribute */
322 DEBUG(5,("cups_job_delete(%d, %p (%d))\n", snum, pjob, pjob->sysjob));
325 * Make sure we don't ask for passwords...
328 cupsSetPasswordCB(cups_passwd_cb);
331 * Try to connect to the server...
334 if ((http = httpConnect(cupsServer(), ippPort())) == NULL)
336 DEBUG(0,("Unable to connect to CUPS server %s - %s\n",
337 cupsServer(), strerror(errno)));
342 * Build an IPP_CANCEL_JOB request, which requires the following
346 * attributes-natural-language
348 * requesting-user-name
353 request->request.op.operation_id = IPP_CANCEL_JOB;
354 request->request.op.request_id = 1;
356 language = cupsLangDefault();
358 ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_CHARSET,
359 "attributes-charset", NULL, cupsLangEncoding(language));
361 ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_LANGUAGE,
362 "attributes-natural-language", NULL, language->language);
364 slprintf(uri, sizeof(uri) - 1, "ipp://localhost/jobs/%d", pjob->sysjob);
366 ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_URI, "job-uri", NULL, uri);
368 ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_NAME, "requesting-user-name",
372 * Do the request and get back a response...
377 if ((response = cupsDoRequest(http, request, "/jobs")) != NULL)
379 if (response->request.status.status_code >= IPP_OK_CONFLICT)
380 DEBUG(0,("Unable to cancel job %d - %s\n", pjob->sysjob,
381 ippErrorString(cupsLastError())));
388 DEBUG(0,("Unable to cancel job %d - %s\n", pjob->sysjob,
389 ippErrorString(cupsLastError())));
398 * 'cups_job_pause()' - Pause a job.
402 cups_job_pause(int snum, struct printjob *pjob)
404 int ret; /* Return value */
405 http_t *http; /* HTTP connection to server */
406 ipp_t *request, /* IPP Request */
407 *response; /* IPP Response */
408 cups_lang_t *language; /* Default language */
409 char uri[HTTP_MAX_URI]; /* printer-uri attribute */
412 DEBUG(5,("cups_job_pause(%d, %p (%d))\n", snum, pjob, pjob->sysjob));
415 * Make sure we don't ask for passwords...
418 cupsSetPasswordCB(cups_passwd_cb);
421 * Try to connect to the server...
424 if ((http = httpConnect(cupsServer(), ippPort())) == NULL)
426 DEBUG(0,("Unable to connect to CUPS server %s - %s\n",
427 cupsServer(), strerror(errno)));
432 * Build an IPP_HOLD_JOB request, which requires the following
436 * attributes-natural-language
438 * requesting-user-name
443 request->request.op.operation_id = IPP_HOLD_JOB;
444 request->request.op.request_id = 1;
446 language = cupsLangDefault();
448 ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_CHARSET,
449 "attributes-charset", NULL, cupsLangEncoding(language));
451 ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_LANGUAGE,
452 "attributes-natural-language", NULL, language->language);
454 slprintf(uri, sizeof(uri) - 1, "ipp://localhost/jobs/%d", pjob->sysjob);
456 ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_URI, "job-uri", NULL, uri);
458 ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_NAME, "requesting-user-name",
462 * Do the request and get back a response...
467 if ((response = cupsDoRequest(http, request, "/jobs")) != NULL)
469 if (response->request.status.status_code >= IPP_OK_CONFLICT)
470 DEBUG(0,("Unable to hold job %d - %s\n", pjob->sysjob,
471 ippErrorString(cupsLastError())));
478 DEBUG(0,("Unable to hold job %d - %s\n", pjob->sysjob,
479 ippErrorString(cupsLastError())));
488 * 'cups_job_resume()' - Resume a paused job.
492 cups_job_resume(int snum, struct printjob *pjob)
494 int ret; /* Return value */
495 http_t *http; /* HTTP connection to server */
496 ipp_t *request, /* IPP Request */
497 *response; /* IPP Response */
498 cups_lang_t *language; /* Default language */
499 char uri[HTTP_MAX_URI]; /* printer-uri attribute */
502 DEBUG(5,("cups_job_resume(%d, %p (%d))\n", snum, pjob, pjob->sysjob));
505 * Make sure we don't ask for passwords...
508 cupsSetPasswordCB(cups_passwd_cb);
511 * Try to connect to the server...
514 if ((http = httpConnect(cupsServer(), ippPort())) == NULL)
516 DEBUG(0,("Unable to connect to CUPS server %s - %s\n",
517 cupsServer(), strerror(errno)));
522 * Build an IPP_RELEASE_JOB request, which requires the following
526 * attributes-natural-language
528 * requesting-user-name
533 request->request.op.operation_id = IPP_RELEASE_JOB;
534 request->request.op.request_id = 1;
536 language = cupsLangDefault();
538 ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_CHARSET,
539 "attributes-charset", NULL, cupsLangEncoding(language));
541 ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_LANGUAGE,
542 "attributes-natural-language", NULL, language->language);
544 slprintf(uri, sizeof(uri) - 1, "ipp://localhost/jobs/%d", pjob->sysjob);
546 ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_URI, "job-uri", NULL, uri);
548 ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_NAME, "requesting-user-name",
552 * Do the request and get back a response...
557 if ((response = cupsDoRequest(http, request, "/jobs")) != NULL)
559 if (response->request.status.status_code >= IPP_OK_CONFLICT)
560 DEBUG(0,("Unable to release job %d - %s\n", pjob->sysjob,
561 ippErrorString(cupsLastError())));
568 DEBUG(0,("Unable to release job %d - %s\n", pjob->sysjob,
569 ippErrorString(cupsLastError())));
578 * 'cups_job_submit()' - Submit a job for printing.
582 cups_job_submit(int snum, struct printjob *pjob)
584 int ret; /* Return value */
585 http_t *http; /* HTTP connection to server */
586 ipp_t *request, /* IPP Request */
587 *response; /* IPP Response */
588 cups_lang_t *language; /* Default language */
589 char uri[HTTP_MAX_URI]; /* printer-uri attribute */
592 DEBUG(5,("cups_job_submit(%d, %p (%d))\n", snum, pjob, pjob->sysjob));
595 * Make sure we don't ask for passwords...
598 cupsSetPasswordCB(cups_passwd_cb);
601 * Try to connect to the server...
604 if ((http = httpConnect(cupsServer(), ippPort())) == NULL)
606 DEBUG(0,("Unable to connect to CUPS server %s - %s\n",
607 cupsServer(), strerror(errno)));
612 * Build an IPP_PRINT_JOB request, which requires the following
616 * attributes-natural-language
618 * requesting-user-name
624 request->request.op.operation_id = IPP_PRINT_JOB;
625 request->request.op.request_id = 1;
627 language = cupsLangDefault();
629 ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_CHARSET,
630 "attributes-charset", NULL, cupsLangEncoding(language));
632 ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_LANGUAGE,
633 "attributes-natural-language", NULL, language->language);
635 slprintf(uri, sizeof(uri) - 1, "ipp://localhost/printers/%s",
638 ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_URI,
639 "printer-uri", NULL, uri);
641 ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_NAME, "requesting-user-name",
644 ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_NAME, "job-name", NULL,
648 * Do the request and get back a response...
651 slprintf(uri, sizeof(uri) - 1, "/printers/%s", PRINTERNAME(snum));
654 if ((response = cupsDoFileRequest(http, request, uri,
655 pjob->filename)) != NULL)
657 if (response->request.status.status_code >= IPP_OK_CONFLICT)
658 DEBUG(0,("Unable to print file to %s - %s\n", PRINTERNAME(snum),
659 ippErrorString(cupsLastError())));
666 DEBUG(0,("Unable to print file to `%s' - %s\n", PRINTERNAME(snum),
667 ippErrorString(cupsLastError())));
676 * 'cups_queue_get()' - Get all the jobs in the print queue.
680 cups_queue_get(int snum, print_queue_struct **q, print_status_struct *status)
682 http_t *http; /* HTTP connection to server */
683 ipp_t *request, /* IPP Request */
684 *response; /* IPP Response */
685 ipp_attribute_t *attr; /* Current attribute */
686 cups_lang_t *language; /* Default language */
687 char uri[HTTP_MAX_URI]; /* printer-uri attribute */
688 int qcount, /* Number of active queue entries */
689 qalloc; /* Number of queue entries allocated */
690 print_queue_struct *queue, /* Queue entries */
691 *temp; /* Temporary pointer for queue */
692 const char *user_name, /* job-originating-user-name attribute */
693 *job_name; /* job-name attribute */
694 int job_id; /* job-id attribute */
695 int job_k_octets; /* job-k-octets attribute */
696 time_t job_time; /* time-at-creation attribute */
697 ipp_jstate_t job_status; /* job-status attribute */
698 int job_priority; /* job-priority attribute */
699 static const char *jattrs[] = /* Requested job attributes */
704 "job-originating-user-name",
709 static const char *pattrs[] = /* Requested printer attributes */
712 "printer-state-message"
716 DEBUG(5,("cups_queue_get(%d, %p, %p)\n", snum, q, status));
719 * Make sure we don't ask for passwords...
722 cupsSetPasswordCB(cups_passwd_cb);
725 * Try to connect to the server...
728 if ((http = httpConnect(cupsServer(), ippPort())) == NULL)
730 DEBUG(0,("Unable to connect to CUPS server %s - %s\n",
731 cupsServer(), strerror(errno)));
736 * Generate the printer URI...
739 slprintf(uri, sizeof(uri) - 1, "ipp://localhost/printers/%s",
743 * Build an IPP_GET_JOBS request, which requires the following
747 * attributes-natural-language
748 * requested-attributes
754 request->request.op.operation_id = IPP_GET_JOBS;
755 request->request.op.request_id = 1;
757 language = cupsLangDefault();
759 ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_CHARSET,
760 "attributes-charset", NULL, cupsLangEncoding(language));
762 ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_LANGUAGE,
763 "attributes-natural-language", NULL, language->language);
765 ippAddStrings(request, IPP_TAG_OPERATION, IPP_TAG_NAME,
766 "requested-attributes",
767 (sizeof(jattrs) / sizeof(jattrs[0])),
770 ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_URI,
771 "printer-uri", NULL, uri);
774 * Do the request and get back a response...
777 if ((response = cupsDoRequest(http, request, "/")) == NULL)
779 DEBUG(0,("Unable to get jobs for %s - %s\n", uri,
780 ippErrorString(cupsLastError())));
785 if (response->request.status.status_code >= IPP_OK_CONFLICT)
787 DEBUG(0,("Unable to get jobs for %s - %s\n", uri,
788 ippErrorString(response->request.status.status_code)));
796 * Process the jobs...
803 for (attr = response->attrs; attr != NULL; attr = attr->next)
806 * Skip leading attributes until we hit a job...
809 while (attr != NULL && attr->group_tag != IPP_TAG_JOB)
816 * Allocate memory as needed...
818 if (qcount >= qalloc)
823 temp = malloc(sizeof(print_queue_struct) * qalloc);
825 temp = realloc(queue, sizeof(print_queue_struct) * qalloc);
838 temp = queue + qcount;
839 memset(temp, 0, sizeof(print_queue_struct));
842 * Pull the needed attributes from this job...
847 job_status = IPP_JOB_PENDING;
853 while (attr != NULL && attr->group_tag == IPP_TAG_JOB)
855 if (attr->name == NULL)
861 if (strcmp(attr->name, "job-id") == 0 &&
862 attr->value_tag == IPP_TAG_INTEGER)
863 job_id = attr->values[0].integer;
865 if (strcmp(attr->name, "job-k-octets") == 0 &&
866 attr->value_tag == IPP_TAG_INTEGER)
867 job_k_octets = attr->values[0].integer;
869 if (strcmp(attr->name, "job-priority") == 0 &&
870 attr->value_tag == IPP_TAG_INTEGER)
871 job_priority = attr->values[0].integer;
873 if (strcmp(attr->name, "job-state") == 0 &&
874 attr->value_tag == IPP_TAG_ENUM)
875 job_status = (ipp_jstate_t)(attr->values[0].integer);
877 if (strcmp(attr->name, "time-at-creation") == 0 &&
878 attr->value_tag == IPP_TAG_INTEGER)
879 job_time = attr->values[0].integer;
881 if (strcmp(attr->name, "job-name") == 0 &&
882 attr->value_tag == IPP_TAG_NAME)
883 job_name = attr->values[0].string.text;
885 if (strcmp(attr->name, "job-originating-user-name") == 0 &&
886 attr->value_tag == IPP_TAG_NAME)
887 user_name = attr->values[0].string.text;
893 * See if we have everything needed...
896 if (user_name == NULL || job_name == NULL || job_id == 0)
905 temp->size = job_k_octets * 1024;
906 temp->status = job_status == IPP_JOB_PENDING ? LPQ_QUEUED :
907 job_status == IPP_JOB_STOPPED ? LPQ_PAUSED :
908 job_status == IPP_JOB_HELD ? LPQ_PAUSED :
910 temp->priority = job_priority;
911 temp->time = job_time;
912 strncpy(temp->user, user_name, sizeof(temp->user) - 1);
913 strncpy(temp->file, job_name, sizeof(temp->file) - 1);
924 * Build an IPP_GET_PRINTER_ATTRIBUTES request, which requires the
925 * following attributes:
928 * attributes-natural-language
929 * requested-attributes
935 request->request.op.operation_id = IPP_GET_PRINTER_ATTRIBUTES;
936 request->request.op.request_id = 1;
938 language = cupsLangDefault();
940 ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_CHARSET,
941 "attributes-charset", NULL, cupsLangEncoding(language));
943 ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_LANGUAGE,
944 "attributes-natural-language", NULL, language->language);
946 ippAddStrings(request, IPP_TAG_OPERATION, IPP_TAG_NAME,
947 "requested-attributes",
948 (sizeof(pattrs) / sizeof(pattrs[0])),
951 ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_URI,
952 "printer-uri", NULL, uri);
955 * Do the request and get back a response...
958 if ((response = cupsDoRequest(http, request, "/")) == NULL)
960 DEBUG(0,("Unable to get printer status for %s - %s\n", PRINTERNAME(snum),
961 ippErrorString(cupsLastError())));
966 if (response->request.status.status_code >= IPP_OK_CONFLICT)
968 DEBUG(0,("Unable to get printer status for %s - %s\n", PRINTERNAME(snum),
969 ippErrorString(response->request.status.status_code)));
977 * Get the current printer status and convert it to the SAMBA values.
980 if ((attr = ippFindAttribute(response, "printer-state", IPP_TAG_ENUM)) != NULL)
982 if (attr->values[0].integer == IPP_PRINTER_STOPPED)
983 status->status = LPSTAT_STOPPED;
985 status->status = LPSTAT_OK;
988 if ((attr = ippFindAttribute(response, "printer-state-message",
989 IPP_TAG_TEXT)) != NULL)
990 fstrcpy(status->message, attr->values[0].string.text);
995 * Return the job queue...
1006 * 'cups_queue_pause()' - Pause a print queue.
1010 cups_queue_pause(int snum)
1012 extern userdom_struct current_user_info;
1013 int ret; /* Return value */
1014 http_t *http; /* HTTP connection to server */
1015 ipp_t *request, /* IPP Request */
1016 *response; /* IPP Response */
1017 cups_lang_t *language; /* Default language */
1018 char uri[HTTP_MAX_URI]; /* printer-uri attribute */
1021 DEBUG(5,("cups_queue_pause(%d)\n", snum));
1024 * Make sure we don't ask for passwords...
1027 cupsSetPasswordCB(cups_passwd_cb);
1030 * Try to connect to the server...
1033 if ((http = httpConnect(cupsServer(), ippPort())) == NULL)
1035 DEBUG(0,("Unable to connect to CUPS server %s - %s\n",
1036 cupsServer(), strerror(errno)));
1041 * Build an IPP_PAUSE_PRINTER request, which requires the following
1044 * attributes-charset
1045 * attributes-natural-language
1047 * requesting-user-name
1052 request->request.op.operation_id = IPP_PAUSE_PRINTER;
1053 request->request.op.request_id = 1;
1055 language = cupsLangDefault();
1057 ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_CHARSET,
1058 "attributes-charset", NULL, cupsLangEncoding(language));
1060 ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_LANGUAGE,
1061 "attributes-natural-language", NULL, language->language);
1063 slprintf(uri, sizeof(uri) - 1, "ipp://localhost/printers/%s",
1066 ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_URI, "printer-uri", NULL, uri);
1068 ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_NAME, "requesting-user-name",
1069 NULL, current_user_info.unix_name);
1072 * Do the request and get back a response...
1077 if ((response = cupsDoRequest(http, request, "/admin")) != NULL)
1079 if (response->request.status.status_code >= IPP_OK_CONFLICT)
1080 DEBUG(0,("Unable to pause printer %s - %s\n", PRINTERNAME(snum),
1081 ippErrorString(cupsLastError())));
1085 ippDelete(response);
1088 DEBUG(0,("Unable to pause printer %s - %s\n", PRINTERNAME(snum),
1089 ippErrorString(cupsLastError())));
1098 * 'cups_queue_resume()' - Restart a print queue.
1102 cups_queue_resume(int snum)
1104 int ret; /* Return value */
1105 http_t *http; /* HTTP connection to server */
1106 ipp_t *request, /* IPP Request */
1107 *response; /* IPP Response */
1108 cups_lang_t *language; /* Default language */
1109 char uri[HTTP_MAX_URI]; /* printer-uri attribute */
1112 DEBUG(5,("cups_queue_resume(%d)\n", snum));
1115 * Make sure we don't ask for passwords...
1118 cupsSetPasswordCB(cups_passwd_cb);
1121 * Try to connect to the server...
1124 if ((http = httpConnect(cupsServer(), ippPort())) == NULL)
1126 DEBUG(0,("Unable to connect to CUPS server %s - %s\n",
1127 cupsServer(), strerror(errno)));
1132 * Build an IPP_RESUME_PRINTER request, which requires the following
1135 * attributes-charset
1136 * attributes-natural-language
1138 * requesting-user-name
1143 request->request.op.operation_id = IPP_RESUME_PRINTER;
1144 request->request.op.request_id = 1;
1146 language = cupsLangDefault();
1148 ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_CHARSET,
1149 "attributes-charset", NULL, cupsLangEncoding(language));
1151 ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_LANGUAGE,
1152 "attributes-natural-language", NULL, language->language);
1154 slprintf(uri, sizeof(uri) - 1, "ipp://localhost/printers/%s",
1157 ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_URI, "printer-uri", NULL, uri);
1159 ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_NAME, "requesting-user-name",
1163 * Do the request and get back a response...
1168 if ((response = cupsDoRequest(http, request, "/admin")) != NULL)
1170 if (response->request.status.status_code >= IPP_OK_CONFLICT)
1171 DEBUG(0,("Unable to resume printer %s - %s\n", PRINTERNAME(snum),
1172 ippErrorString(cupsLastError())));
1176 ippDelete(response);
1179 DEBUG(0,("Unable to resume printer %s - %s\n", PRINTERNAME(snum),
1180 ippErrorString(cupsLastError())));
1189 /* this keeps fussy compilers happy */
1190 void print_cups_dummy(void) {}
1191 #endif /* HAVE_LIBCUPS */