-
-
Notifications
You must be signed in to change notification settings - Fork 48
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
List raw sockets during printers
subcommand if available
#340
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1162,6 +1162,11 @@ _papplMainloopShowPrinters( | |
ipp_t *request, // IPP request | ||
*response; // IPP response | ||
ipp_attribute_t *attr; // Current attribute | ||
ipp_tag_t value_tag; // Value tag of IPP attribute | ||
const char *printer_name, // Printer name | ||
*printer_uri, // Printer URI | ||
*attr_name, // Attribute name | ||
*socket_uri; // Socket URI | ||
|
||
|
||
(void)num_options; | ||
|
@@ -1177,8 +1182,46 @@ _papplMainloopShowPrinters( | |
|
||
response = cupsDoRequest(http, request, "/ipp/system"); | ||
|
||
for (attr = ippFindAttribute(response, "printer-name", IPP_TAG_NAME); attr; attr = ippFindNextAttribute(response, "printer-name", IPP_TAG_NAME)) | ||
puts(ippGetString(attr, 0, NULL)); | ||
for (attr = ippGetFirstAttribute(response); attr; attr = ippGetNextAttribute(response)) | ||
{ | ||
while (attr != NULL && ippGetGroupTag(attr) != IPP_TAG_PRINTER) | ||
attr = ippGetNextAttribute(response); | ||
|
||
if (attr == NULL) | ||
break; | ||
|
||
value_tag = IPP_TAG_CUPS_INVALID; | ||
printer_name = NULL; | ||
printer_uri = NULL; | ||
attr_name = NULL; | ||
socket_uri = NULL; | ||
|
||
for (; attr && ippGetGroupTag(attr) == IPP_TAG_PRINTER; attr = ippGetNextAttribute(response)) | ||
{ | ||
value_tag = ippGetValueTag(attr); | ||
|
||
if (value_tag != IPP_TAG_NAME && | ||
value_tag != IPP_TAG_URI) | ||
continue; | ||
|
||
attr_name = ippGetName(attr); | ||
|
||
if (value_tag == IPP_TAG_NAME && !strcmp(attr_name, "printer-name")) | ||
printer_name = ippGetString(attr, 0, NULL); | ||
|
||
if (value_tag == IPP_TAG_URI && !strcmp(attr_name, "smi55357-printer-socket-uri-supported")) | ||
socket_uri = ippGetString(attr, 0, NULL); | ||
|
||
if (value_tag == IPP_TAG_URI && !strcmp(attr_name, "printer-uri-supported")) | ||
printer_uri = ippGetString(attr, 0, NULL); | ||
} | ||
|
||
if (printer_name && printer_uri) | ||
printf("%s - printer - %s\n", printer_name, printer_uri); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not keen on the format here - better to display the raw URL separately, e.g.:
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Also, any text would need to be localized, so the above format avoids that particular issue... |
||
|
||
if (printer_name && socket_uri) | ||
printf("%s - raw socket - %s\n", printer_name, socket_uri); | ||
} | ||
|
||
ippDelete(response); | ||
httpClose(http); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -626,6 +626,17 @@ _papplPrinterCopyAttributesNoLock( | |
ippAddStrings(client->response, IPP_TAG_PRINTER, IPP_CONST_TAG(IPP_TAG_KEYWORD), "uri-authentication-supported", 2, NULL, uri_authentication_none); | ||
} | ||
} | ||
|
||
if (printer->raw_active) | ||
{ | ||
if (!ra || cupsArrayFind(ra, "smi55357-printer-socket-uri-supported")) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. How about "smi55357-socket-uri-configured"? You need to configure for raw printing support and we don't need to have "printer" in the name. |
||
{ | ||
char socket_uri[1024]; // Buffer for socket URI | ||
|
||
httpAssembleURI(HTTP_URI_CODING_ALL, socket_uri, sizeof(socket_uri), "socket", NULL, client->host_field, 9099 + printer->printer_id, NULL); | ||
ippAddString(client->response, IPP_TAG_PRINTER, IPP_TAG_URI, "smi55357-printer-socket-uri-supported", NULL, socket_uri); | ||
} | ||
} | ||
} | ||
|
||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think you need to initialize a default
attr_name
orvalue_tag
value. And printer-uri-supported is multi-valued so we might as well show all of the values.