mirror of
https://github.com/samba-team/samba.git
synced 2025-03-08 04:58:40 +03:00
s3-printing: Remove obsolete and unused cups_pull_comment_location().
Signed-off-by: Günther Deschner <gd@samba.org>
This commit is contained in:
parent
da1fa20104
commit
01bc556d03
@ -1587,163 +1587,6 @@ struct printif cups_printif =
|
||||
cups_job_submit,
|
||||
};
|
||||
|
||||
bool cups_pull_comment_location(TALLOC_CTX *mem_ctx,
|
||||
const char *printername,
|
||||
char **comment,
|
||||
char **location)
|
||||
{
|
||||
TALLOC_CTX *frame = talloc_stackframe();
|
||||
http_t *http = NULL; /* HTTP connection to server */
|
||||
ipp_t *request = NULL, /* IPP Request */
|
||||
*response = NULL; /* IPP Response */
|
||||
ipp_attribute_t *attr; /* Current attribute */
|
||||
cups_lang_t *language = NULL; /* Default language */
|
||||
char uri[HTTP_MAX_URI];
|
||||
char *sharename = NULL;
|
||||
char *name = NULL;
|
||||
static const char *requested[] =/* Requested attributes */
|
||||
{
|
||||
"printer-name",
|
||||
"printer-info",
|
||||
"printer-location"
|
||||
};
|
||||
bool ret = False;
|
||||
size_t size;
|
||||
|
||||
DEBUG(5, ("pulling %s location\n", printername));
|
||||
|
||||
/*
|
||||
* Make sure we don't ask for passwords...
|
||||
*/
|
||||
|
||||
cupsSetPasswordCB(cups_passwd_cb);
|
||||
|
||||
/*
|
||||
* Try to connect to the server...
|
||||
*/
|
||||
|
||||
if ((http = cups_connect(frame)) == NULL) {
|
||||
goto out;
|
||||
}
|
||||
|
||||
request = ippNew();
|
||||
|
||||
request->request.op.operation_id = IPP_GET_PRINTER_ATTRIBUTES;
|
||||
request->request.op.request_id = 1;
|
||||
|
||||
language = cupsLangDefault();
|
||||
|
||||
ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_CHARSET,
|
||||
"attributes-charset", NULL, "utf-8");
|
||||
|
||||
ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_LANGUAGE,
|
||||
"attributes-natural-language", NULL, language->language);
|
||||
|
||||
if (!push_utf8_talloc(frame, &sharename, printername, &size)) {
|
||||
goto out;
|
||||
}
|
||||
slprintf(uri, sizeof(uri) - 1, "ipp://localhost/printers/%s",
|
||||
sharename);
|
||||
|
||||
ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_URI,
|
||||
"printer-uri", NULL, uri);
|
||||
|
||||
ippAddStrings(request, IPP_TAG_OPERATION, IPP_TAG_NAME,
|
||||
"requested-attributes",
|
||||
(sizeof(requested) / sizeof(requested[0])),
|
||||
NULL, requested);
|
||||
|
||||
/*
|
||||
* Do the request and get back a response...
|
||||
*/
|
||||
|
||||
if ((response = cupsDoRequest(http, request, "/")) == NULL) {
|
||||
DEBUG(0,("Unable to get printer attributes - %s\n",
|
||||
ippErrorString(cupsLastError())));
|
||||
goto out;
|
||||
}
|
||||
|
||||
for (attr = response->attrs; attr != NULL;) {
|
||||
/*
|
||||
* Skip leading attributes until we hit a printer...
|
||||
*/
|
||||
|
||||
while (attr != NULL && attr->group_tag != IPP_TAG_PRINTER)
|
||||
attr = attr->next;
|
||||
|
||||
if (attr == NULL)
|
||||
break;
|
||||
|
||||
/*
|
||||
* Pull the needed attributes from this printer...
|
||||
*/
|
||||
|
||||
while ( attr && (attr->group_tag == IPP_TAG_PRINTER) ) {
|
||||
if (strcmp(attr->name, "printer-name") == 0 &&
|
||||
attr->value_tag == IPP_TAG_NAME) {
|
||||
if (!pull_utf8_talloc(frame,
|
||||
&name,
|
||||
attr->values[0].string.text,
|
||||
&size)) {
|
||||
goto out;
|
||||
}
|
||||
}
|
||||
|
||||
/* Grab the comment if we don't have one */
|
||||
if ( (strcmp(attr->name, "printer-info") == 0)
|
||||
&& (attr->value_tag == IPP_TAG_TEXT))
|
||||
{
|
||||
if (!pull_utf8_talloc(mem_ctx,
|
||||
comment,
|
||||
attr->values[0].string.text,
|
||||
&size)) {
|
||||
goto out;
|
||||
}
|
||||
DEBUG(5,("cups_pull_comment_location: Using cups comment: %s\n",
|
||||
*comment));
|
||||
}
|
||||
|
||||
/* Grab the location if we don't have one */
|
||||
if ( (strcmp(attr->name, "printer-location") == 0)
|
||||
&& (attr->value_tag == IPP_TAG_TEXT))
|
||||
{
|
||||
if (!pull_utf8_talloc(mem_ctx,
|
||||
location,
|
||||
attr->values[0].string.text,
|
||||
&size)) {
|
||||
goto out;
|
||||
}
|
||||
DEBUG(5,("cups_pull_comment_location: Using cups location: %s\n",
|
||||
*location));
|
||||
}
|
||||
|
||||
attr = attr->next;
|
||||
}
|
||||
|
||||
/*
|
||||
* We have everything needed...
|
||||
*/
|
||||
|
||||
if (name != NULL)
|
||||
break;
|
||||
}
|
||||
|
||||
ret = True;
|
||||
|
||||
out:
|
||||
if (response)
|
||||
ippDelete(response);
|
||||
|
||||
if (language)
|
||||
cupsLangFree(language);
|
||||
|
||||
if (http)
|
||||
httpClose(http);
|
||||
|
||||
TALLOC_FREE(frame);
|
||||
return ret;
|
||||
}
|
||||
|
||||
#else
|
||||
/* this keeps fussy compilers happy */
|
||||
void print_cups_dummy(void);
|
||||
|
Loading…
x
Reference in New Issue
Block a user