OpenPrinting / cups

OpenPrinting CUPS Sources
https://openprinting.github.io/cups
Apache License 2.0
1.01k stars 182 forks source link

job-presets-supported attribute is not supported in cups #778

Closed Ankit3002 closed 4 months ago

Ankit3002 commented 1 year ago

I have developed code in pappl to introduce presets support, which involves predefined templates for printing defaults. These presets are included in the job-presets-supported attribute of client->response . However, when I send a get_printer_attributes request to CUPS, the response does not contain the job-presets-supported attribute.

To Reproduce Steps to reproduce the behavior:

  1. Visit 'https://github.com/Ankit3002/pappl' and build the pappl code from there.
  2. Proceed to 'https://github.com/Ankit3002/cpdb-backend-cups/' and build the code from that repository.
  3. Build the code from 'https://github.com/OpenPrinting/cpdb-libs'.
  4. Launch a terminal and execute the command sudo legacy-printer-app server , then open another terminal and run /usr/local/lib/print-backends/cups .
  5. Open localhost:8000 and create preset for a printer .
  6. In another terminal, execute the command cpdb-text-frontend and send a get-all-options request.

Expected behavior

  1. In the terminal where we have run the command /usr/local/lib/print-backends/cups we will be able to see all the attributes . But job-presets-supported is not listed over there .

System Information:

zdohnal commented 1 year ago

Hi @Ankit3002 ,

I've checked Get-Printer-attributes operation code and the mentioned attribute should be contained in the operation response, so there might an issue in how you create the preset.

Are you able to debug running cups via gdb and give here the printed contents of the attribute? It should be stored somewhere in the printer structure, under attrs->attrs pointer.

Additionally it would be great if you enabled debug logging in CUPS, try creating the preset via the printer app, put the logs into a file with .txt suffix and upload it here.

Ankit3002 commented 10 months ago

@zdohnal When I directly connect with the pappl then i am able to fetch the preset attribute .

I used the below snippet

` http_t other = p->http; const char server_path = "/run/legacy-printer-app.sock";

http = httpConnect2(server_path, 0,  NULL, AF_UNSPEC, HTTP_ENCRYPTION_IF_REQUESTED, 1, 30000, NULL );

request = ippNewRequest(IPP_OP_GET_PRINTER_ATTRIBUTES);

ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_URI, "printer-uri", NULL, printer_uri);

ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_NAME, "requesting-user-name", NULL, cupsUser());

ipp_t * supported = cupsDoRequest(http , request ,resource);

ipp_attribute_t *attr;

for (attr = ippFirstAttribute(supported); attr; attr = ippNextAttribute(supported)) 
{
    const char *name = ippGetName(attr);
    if(!strcmp(name , "job-presets-supported"))
    {
        printf("Yes i got the job-preset-supported\n");
        return attr;
    }

}`

there i am able to get the job-preset-supported attribute, but when I use the below snippet which directly connects with cups to fetch the attributes there i won't be able to fetch the job-preset-supported attribute.

` ensure_printer_connection(p); ipp_t *request_d = ippNewRequest(IPP_OP_GET_PRINTER_ATTRIBUTES);

const char *uri = cupsGetOption("printer-uri-supported", 
                                p->dest->num_options,
                                p->dest->options);

ippAddString(request_d, IPP_TAG_OPERATION, IPP_TAG_URI,
             "printer-uri", NULL, uri);

ipp_t *response = cupsDoRequest(p->http, request_d, "/");
ipp_attribute_t *traverse;
for(traverse = ippFirstAttribute(response); traverse ; traverse = ippNextAttribute(response))
{
    char * name_ = ippGetName(traverse);
    printf("Obtained Attribute ::  %s\n", name_);
}`
zdohnal commented 10 months ago

Ok, my bad - I read IPP Preset PWG document (https://ftp.pwg.org/pub/pwg/ipp/registrations/reg-ipppreset-20171214.pdf - I don't know why I can't find it on PWG web pages), so I see now CUPS is missing one requirement:

- including “job-presets-supported” and “job-triggers-supported” in its “printer-settable-attributes-supported” Printer Description attribute [RFC3380]

and we don't show '-supported' attributes during operations Get-Printer-Supported-Values and Set-Printer-Attributes - only several printer- related attrs like info or location are supported.

@michaelrsweet is there any catch which I should be wary of when adding this support to cupsd? What I see here the following steps have to be implemented:

michaelrsweet commented 10 months ago

@zdohnal The registration is actually replaced by the new PWG 5100.13-2023: IPP Driver Replacement Extensions v2.0 (NODRIVER).

WRT including "job-presets-supported" and "job-triggers-supported" in "printer-settable-attributes-supported", that isn't part of the published, approved spec and honestly there is no reason to try supporting it. Get-Printer-Supported-Values doesn't return all of the xxx-supported attributes because not all of the attributes are settable.

So right now just focus on reporting the presets.

michaelrsweet commented 4 months ago

[master 3584de335] Add job-presets-supported to CUPS shared printers (Issue #778)