pappl icon indicating copy to clipboard operation
pappl copied to clipboard

Callback for loading/saving extra printer data in state file

Open tillkamppeter opened this issue 3 years ago • 11 comments

Describe the solution you'd like As described in issue #90 I want to add an extra page to the printer's web interface to allow setting the "Installable Options" PPD options for PostScript printers. As these options are not job options and they influence available choices and available vendor options (in the "Printing Defaults") I do not want to add them as vendor options. The settings of these options need to be saved in the state file and loaded the next time the PostScript Printer Application gets started. Is there already a way to do this? If not, it would be great if the functions papplSystemLoadState() and papplSystemSaveState() could call callback functions to load/save extra data for each printer.

tillkamppeter avatar Nov 24 '20 14:11 tillkamppeter

@tillkamppeter OK, so if you really need to store other information, right now you just provide your own save callback and not the default one.

Installable options can be included as vendor options, which will get loaded and saved. Without an xxx-support attribute, they won't show up in the printer defaults UI or be allowed as job template attributes, but you can store text (IPP_TAG_TEXT) values in the xxx-default attributes (part of the driver attributes you initially set).

Beyond that we'd need serialization callbacks to encode/decode driver-specific data that could then be read/written by the default save/load callback functions, but I'm not sure that should be a 1.0 goal, particularly when the API and default load/save callbacks were written to ensure that you can copy and adapt them using only the public APIs...

michaelrsweet avatar Nov 24 '20 15:11 michaelrsweet

OK, the method creating vendor options and only providing xxx-default and no xxx-supported would serve for me, as I only need to save and reload the key/value pairs of the installable options.

tillkamppeter avatar Nov 24 '20 16:11 tillkamppeter

Independent of my special case of installable option settings I think it is not very useful to have as only way of customization the full replacement of the function for saving.

First, if you want to save what usually gets saved plus some extra, you had to copy the whole original function and add the lines for the some extra.

Second, you cannot replace the function for loading the state file, so you cannot load any data which got saved in addition by your custom saving function.

tillkamppeter avatar Nov 24 '20 16:11 tillkamppeter

@tillkamppeter True about the load function, and at that point you'd have to implement your own papplMainloop equivalent...

michaelrsweet avatar Nov 24 '20 16:11 michaelrsweet

I would very much appreciate a solution here soon, as without extending the savable data I cannot implement the Installable Options for PostScript printers as I cannot save their settings.

tillkamppeter avatar Dec 02 '20 11:12 tillkamppeter

@tillkamppeter see my original response. List the installable options as vendor keywords and PAPPL will load/save the choices for you. Beyond that you need to implement your own load/save functions.

michaelrsweet avatar Dec 02 '20 13:12 michaelrsweet

OK, will go the xxx-default without xxx-supported way for Installable Options. So then I think I have all what I need for the PostScript Printer Application.

tillkamppeter avatar Dec 02 '20 14:12 tillkamppeter

I have tried to follow your instructions, adding a vendor option named "installable-options" with only an "installable-options-default" IPP attribute of IPP_TAG_TEXT type and no "installable-options-supported" IPP attribute, with the intention of putting all the settings of the "Installable Options" group of the PPD file into this string as space-separated KEY=VALUE list. You told that such a vendor option will not show up on the "Printing Defaults" page. Unfortunately, it shows up: Screenshot from 2020-12-15 19-50-52 Is this a bug in PAPPL or have I to do this differently?

tillkamppeter avatar Dec 15 '20 18:12 tillkamppeter

@tillkamppeter Bug, I'll work on a fix.

michaelrsweet avatar Dec 15 '20 20:12 michaelrsweet

Tracking with issue #104.

michaelrsweet avatar Dec 15 '20 20:12 michaelrsweet

I got the "Installable Options" support for the PostScript Printer Application completely working now, using the method of a vendor option without ...-supported IPP attribute for saving the "Installable Options" settings and your call of the status callback from issue #107. Thank you very much.

tillkamppeter avatar Dec 22 '20 18:12 tillkamppeter