Closed tangyanli closed 1 year ago
You need to look for the "smi55357-device-uri" attribute. PAPPL isn't CUPS.
I use below sample code to acquire all the attributes by the request "IPP_OP_GET_PRINTER_ATTRIBUTES". But I cannot find the "smi55357-device-uri" attribute. Did I do something wrong ?
http = httpConnect2("/run/legacy-printer-app.sock", 0, NULL, AF_UNSPEC, cupsEncryption(), 1, 30000, NULL);
if (http != NULL)
{
request = ippNewRequest(IPP_OP_GET_PRINTER_ATTRIBUTES);
if (request)
{
_papplMainloopAddPrinterURI(request, printer_name, resource, sizeof(resource));
if ((response = cupsDoRequest(http, request, "/ipp/system")) != NULL)
{
//Output response->attrs
ippDelete(response);
}
}
httpClose(http);
}
You need to send the request to the proper endpoint for the printer, e.g, "/ipp/print/FOO" for a printer called "FOO".
Sending it to /ipp/system will fail because you are talking to the System object, not to the Printer object that has the attribute you are looking for.
Michael, I attached a TXT file in the last message which contained all the printer’s attributes, but there is no "smi55357-device-uri". Can you check it again?
The attributes you got were not for a printer, since you targeted the system.
As your suggestion, I updated the sample code. And the result is as before: except "smi55357-device-uri", other attributes can be obtained (e.g "printer-id", "printer-name" or "printer-make-and-model")
static const char* requested[] = {
"smi55357-device-uri",
"printer-id",
"printer-name",
"printer-make-and-model"
};
http = httpConnect2("/run/legacy-printer-app.sock", 0, NULL, AF_UNSPEC, cupsEncryption(), 1, 30000, NULL);
if (http != NULL)
{
request = ippNewRequest(IPP_OP_GET_PRINTER_ATTRIBUTES);
if (request)
{
ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_URI, "printer-uri", NULL, "/ipp/print/FOO");
ippAddStrings(request, IPP_TAG_OPERATION, IPP_TAG_KEYWORD, "requested-attributes", (int)(sizeof(requested) / sizeof(requested[0])), NULL, requested);
if ((response = cupsDoRequest(http, request, "/ipp/print")) != NULL)
{
// Output attributes
ippDelete(response);
}
}
httpClose(http);
}
}
I did some investigation, if the below code is added in the function papplPrinterCreate()
, then the "smi55357-device-uri" can be obtained by above sample code.
// printer-name
ippAddString(printer->attrs, IPP_TAG_PRINTER, IPP_TAG_NAME, "printer-name", NULL, printer_name);
// smi55357-device-uri
ippAddString(printer->attrs, IPP_TAG_PRINTER, IPP_TAG_URI, "smi55357-device-uri", NULL, device_uri); ★ add
OK, I double-checked and it looks like the device URI and driver name are not being added to the printer attributes. Fix coming up...
[master 5b98e35] Add smi55357-device-uri/driver Printer Status attributes.
[v1.4.x b5063bd] Add smi55357-device-uri/driver Printer Status attributes.
Is your feature request related to a problem? Please describe. For CUPS, I can acquire the printer's "device-uri" attribute by the request "IPP_OP_CUPS_GET_PRINTERS". For pappl, I cannot acquire the printer's "device-uri" attribute.
Describe the solution you'd like Can the pappl return the "device-uri" attribute by the request "IPP_OP_GET_PRINTER_ATTRIBUTES"?
Describe alternatives you've considered If it is impossible, please close this issue directly. I will consider maintaining the operation callback through the
papplSystemSetOperationCallback