[cups.development] How to attach a different ppd toexistingprinter using CUPS API
Michael Sweet
msweet at apple.com
Fri Dec 9 14:18:38 PST 2011
On Dec 9, 2011, at 1:22 PM, Azuri wrote:
> Model is actually the whole path to ppd file along with the name. What you mean by dropping ppd-name? removing the whole line of code?
> ippAddString(request, IPP_TAG_PRINTER, IPP_TAG_NAME, "ppd-name", NULL, model);
Yes, drop this line.
> If so how will understand which ppd to attach
You are actually attaching the file to the request in the cupsDoFileRequest call.
(and you can't pass arbitrary paths to PPD files in the ppd-name attribute anyways...)
>
>> Drop the ppd-name attribute if you are attaching the content of the model file.
>>
>> On Dec 9, 2011, at 11:43 AM, Azuri wrote:
>>
>>> I am using following code
>>>
>>> ipp_t *request; /* IPP Request */
>>> char uri_dev[HTTP_MAX_URI];
>>> http_t *http;
>>> http = httpConnectEncrypt(cupsServer(), ippPort(), cupsEncryption());
>>> request = ippNewRequest(CUPS_ADD_MODIFY_PRINTER);
>>> ipp_t *response_ppd;
>>>
>>> httpAssembleURIf(HTTP_URI_CODING_ALL, uri_dev, sizeof(uri_dev), "ipp", NULL,
>>> "localhost", 0, "/printers/%s", printerDefaultName);
>>> ipp_status_t status;
>>> ippAddString(request, IPP_TAG_PRINTER, IPP_TAG_NAME, "printer-name", NULL, printerDefaultName);
>>> ippAddString(request, IPP_TAG_PRINTER, IPP_TAG_NAME, "device-uri", NULL, uri_dev);
>>> ippAddString(request, IPP_TAG_PRINTER, IPP_TAG_NAME, "ppd-name", NULL, model);
>>> ippAddBoolean(request, IPP_TAG_PRINTER,"printer-is-accepting-jobs", 1);
>>> ippAddInteger(request, IPP_TAG_PRINTER, IPP_TAG_ENUM, "printer-state", IPP_PRINTER_IDLE);
>>> /*ippDelete(cupsDoRequest(http, request, "/admin"));
>>> status = cupsLastError();
>>>
>>> if (status > IPP_OK_CONFLICT)
>>> {
>>> _cupsLangPrintf(stderr, "lpadmin: %s\n", cupsLastErrorString());
>>> }
>>> return;*/
>>>
>>> response_ppd = cupsDoFileRequest(http, request, "/admin/", model);
>>>
>>>
>>> #if 0
>>>
>>> if ((response_ppd = cupsDoRequest(http, request_ppd, "/admin/")) == NULL)
>>> {
>>> //_cupsLangPrintf(stderr, "lpadmin: %s\n", cupsLastErrorString());
>>> NSAlert *alert = [[[NSAlert alloc]init]autorelease];
>>> [alert setMessageText:[NSString stringWithFormat:@"Error occured while attaching ppd. Printer could not be added."]];
>>> [alert runModal];
>>>
>>> return;
>>> }
>>> else if (response_ppd->request.status.status_code > IPP_OK_CONFLICT)
>>> {
>>> //_cupsLangPrintf(stderr, "lpadmin: %s\n", cupsLastErrorString());
>>> NSAlert *alert = [[[NSAlert alloc]init]autorelease];
>>> [alert setMessageText:[NSString stringWithFormat:@"Error occured while attaching ppd. Printer could not be added."]];
>>> [alert runModal];
>>>
>>> ippDelete(response_ppd);
>>>
>>> return;
>>> }
>>> else
>>> {
>>> ippDelete(response_ppd);
>>> }
>>> #endif
>>>
>>>
>>> if (http)
>>> {
>>> httpClose(http);
>>> }
>>>
>>>
>>>
>>>
>>>
>>>
>>>> Not surprisingly, the same code you use to add the printer with a generic PPD file will work to add a different generic PPD file - the CUPS-Add-Modify-Printer operation will add a new printer or modify an existing printer...
>>>>
>>>> On Dec 9, 2011, at 11:23 AM, Azuri wrote:
>>>>
>>>>> Say I have added printer using cups API and attached generic ppd file.
>>>>> Now I want to attach generic2.ppd file instead of generic.ppd file for the same printer using CUPS. how do i do that. Can you please share the code snippet.
>>>>>
>>>>> Thanks,
>>>>> Azuri
>>>>> _______________________________________________
>>>>> cups-dev mailing list
>>>>> cups-dev at easysw.com
>>>>> http://lists.easysw.com/mailman/listinfo/cups-dev
>>>>
>>>> _________________________________________________________
>>>> Michael Sweet, Senior Printing System Engineer, PWG Chair
>>>>
>>>
>>> _______________________________________________
>>> cups-dev mailing list
>>> cups-dev at easysw.com
>>> http://lists.easysw.com/mailman/listinfo/cups-dev
>>
>> _________________________________________________________
>> Michael Sweet, Senior Printing System Engineer, PWG Chair
>>
>
> _______________________________________________
> cups-dev mailing list
> cups-dev at easysw.com
> http://lists.easysw.com/mailman/listinfo/cups-dev
_________________________________________________________
Michael Sweet, Senior Printing System Engineer, PWG Chair
More information about the cups
mailing list