};
static int job_canceled = 0;
/* Job cancelled? */
-static char *password = NULL;
+static char username[256] = "",
+ /* Username for device URI */
+ *password = NULL;
/* Password for device URI */
static int password_tries = 0;
/* Password tries */
{
"copies-supported",
"cups-version",
- "document-format-default",
"document-format-supported",
"marker-colors",
"marker-high-levels",
const char *device_uri; /* Device URI */
char scheme[255], /* Scheme in URI */
hostname[1024], /* Hostname */
- username[255], /* Username info */
resource[1024], /* Resource info (printer name) */
addrname[256], /* Address name */
*optptr, /* Pointer to URI options */
ipp_attribute_t *job_state; /* job-state */
ipp_attribute_t *copies_sup; /* copies-supported */
ipp_attribute_t *cups_version; /* cups-version */
- ipp_attribute_t *format_dflt; /* document-format-default */
ipp_attribute_t *format_sup; /* document-format-supported */
ipp_attribute_t *media_col_sup; /* media-col-supported */
ipp_attribute_t *operations_sup; /* operations-supported */
const char *ptr = getenv("AUTH_USERNAME");
if (ptr)
+ {
+ strlcpy(username, ptr, sizeof(username));
cupsSetUser(ptr);
+ }
password = getenv("AUTH_PASSWORD");
}
fprintf(stderr, "DEBUG: Get-Printer-Attributes: %s (%s)\n",
ippErrorString(ipp_status), cupsLastErrorString());
- if (ipp_status > IPP_OK_CONFLICT)
+ if (ipp_status <= IPP_OK_CONFLICT)
+ password_tries = 0;
+ else
{
fprintf(stderr, "DEBUG: Get-Printer-Attributes returned %s.\n",
ippErrorString(ipp_status));
return (CUPS_BACKEND_STOP);
}
- else if (ipp_status == IPP_NOT_AUTHORIZED || ipp_status == IPP_FORBIDDEN)
+ else if (ipp_status == IPP_FORBIDDEN ||
+ ipp_status == IPP_AUTHENTICATION_CANCELED)
{
const char *www_auth = httpGetField(http, HTTP_FIELD_WWW_AUTHENTICATE);
/* WWW-Authenticate field value */
fprintf(stderr, "ATTR: auth-info-required=%s\n", auth_info_required);
return (CUPS_BACKEND_AUTH_REQUIRED);
}
- else
+ else if (ipp_status != IPP_NOT_AUTHORIZED)
{
_cupsLangPrintFilter(stderr, "ERROR",
_("Unable to get printer status."));
cups_version = ippFindAttribute(supported, "cups-version", IPP_TAG_TEXT);
- if ((format_dflt = ippFindAttribute(supported, "document-format-default",
- IPP_TAG_MIMETYPE)) != NULL)
- {
- fprintf(stderr, "DEBUG: document-format-default (%d values)\n",
- format_dflt->num_values);
- for (i = 0; i < format_dflt->num_values; i ++)
- fprintf(stderr, "DEBUG: [%d] = \"%s\"\n", i,
- format_dflt->values[i].string.text);
- }
-
if ((format_sup = ippFindAttribute(supported, "document-format-supported",
IPP_TAG_MIMETYPE)) != NULL)
{
if (format_sup != NULL)
{
for (i = 0; i < format_sup->num_values; i ++)
- if (!_cups_strcasecmp(final_content_type,
- format_sup->values[i].string.text))
+ if (!_cups_strcasecmp(final_content_type, format_sup->values[i].string.text))
{
document_format = final_content_type;
break;
}
- if (!document_format &&
- (!format_dflt ||
- _cups_strcasecmp(format_dflt->values[0].string.text,
- "application/octet-stream")))
+ if (!document_format)
{
for (i = 0; i < format_sup->num_values; i ++)
if (!_cups_strcasecmp("application/octet-stream",
- format_sup->values[i].string.text))
+ format_sup->values[i].string.text))
{
document_format = "application/octet-stream";
break;
_cupsLangPrintFilter(stderr, "INFO", _("The printer is busy."));
sleep(10);
}
- else if (ipp_status == IPP_NOT_AUTHORIZED || ipp_status == IPP_FORBIDDEN ||
+ else if (ipp_status == IPP_FORBIDDEN ||
ipp_status == IPP_AUTHENTICATION_CANCELED)
{
const char *www_auth = httpGetField(http, HTTP_FIELD_WWW_AUTHENTICATE);
}
else if (ipp_status == IPP_ERROR_JOB_CANCELED)
goto cleanup;
+ else if (ipp_status == IPP_NOT_AUTHORIZED)
+ continue;
else
{
/*
_cupsLangPrintFilter(stderr, "ERROR",
_("Print file was not accepted."));
- if (ipp_status == IPP_NOT_AUTHORIZED || ipp_status == IPP_FORBIDDEN)
+ if (ipp_status == IPP_FORBIDDEN ||
+ ipp_status == IPP_AUTHENTICATION_CANCELED)
{
const char *www_auth = httpGetField(http, HTTP_FIELD_WWW_AUTHENTICATE);
/* WWW-Authenticate field value */
-
+
if (!strncmp(www_auth, "Negotiate", 9))
auth_info_required = "negotiate";
else if (www_auth[0])
}
else
{
+ password_tries = 0;
monitor.job_id = job_id = job_id_attr->values[0].integer;
_cupsLangPrintFilter(stderr, "INFO",
_("Print file accepted - job ID %d."), job_id);
_("Unable to add document to print job."));
break;
}
- else if (num_files == 0 || fd < 0)
- break;
+ else
+ {
+ password_tries = 0;
+
+ if (num_files == 0 || fd < 0)
+ break;
+ }
}
}
fprintf(stderr, "DEBUG: Get-Job-Attributes: %s (%s)\n",
ippErrorString(ipp_status), cupsLastErrorString());
- if (ipp_status > IPP_OK_CONFLICT)
+ if (ipp_status <= IPP_OK_CONFLICT)
+ password_tries = 0;
+ else
{
if (ipp_status != IPP_SERVICE_UNAVAILABLE &&
ipp_status != IPP_NOT_POSSIBLE &&
fprintf(stderr, "DEBUG: Get-Printer-Attributes: %s (%s)\n",
ippErrorString(cupsLastError()), cupsLastErrorString());
+ if (cupsLastError() <= IPP_OK_CONFLICT)
+ password_tries = 0;
+
/*
* Return the printer-state value...
*/
http = _httpCreate(monitor->hostname, monitor->port, NULL, monitor->encryption,
AF_UNSPEC);
httpSetTimeout(http, 30.0, timeout_cb, NULL);
+ if (username[0])
+ cupsSetUser(username);
cupsSetPasswordCB(password_cb);
/*
fprintf(stderr, "DEBUG: %s: %s (%s)\n", ippOpString(job_op),
ippErrorString(cupsLastError()), cupsLastErrorString());
+ if (cupsLastError() <= IPP_OK_CONFLICT)
+ password_tries = 0;
+
if (job_op == IPP_GET_JOB_ATTRIBUTES)
{
if ((attr = ippFindAttribute(response, "job-state",
"multiple-document-handling", NULL, collate_str);
break;
}
+
+ if (i >= doc_handling_sup->num_values)
+ copies = 1;
}
/*
cupsEncodeOptions(request, num_options, options);
}
- if (copies > 1)
+ if (copies > 1 && copies <= pc->max_copies)
ippAddInteger(request, IPP_TAG_JOB, IPP_TAG_INTEGER, "copies", copies);
}
static const char * /* O - Password */
password_cb(const char *prompt) /* I - Prompt (not used) */
{
+ fprintf(stderr, "DEBUG: password_cb(prompt=\"%s\"), password=%p, "
+ "password_tries=%d\n", prompt, password, password_tries);
+
(void)prompt;
/*