PAPPL-based Printer Applications: Option setting presets via web interface #314
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Generally, Printer Applications as emulation of driverless IPP printers only support standard IPP job attributes as user-settable options: media size/type/source, duplex, printer-resolution, print-quality, print-content-optimize, … but some drivers, like for example Gutenprint or also PostScript printers, have many options to fine-tune the printout and those cannot get individually mapped to IPP options so that the user can control them in a print dialog. Also many print dialogs, especially of phones, are limited to standard IPP attributes.
So what we want to add is to have a preset functionality in PAPPL.
I have developed code in PAPPL to introduce preset support, which involves predefined templates for printing defaults. These presets are included in the job-presets-supported attribute of client->response.
In /pappl/printer-webif.c, I created APIs for creating, editing, copying, and deleting presets.
_papplPrinterPreset(): This function shows the homepage of the presets, allowing users to create, edit, copy, and delete presets.
_papplPrinterPresetCreate(): This function displays the web page for creating presets.
_papplPrinterPresetEdit(): This function displays the web page for editing presets.
_papplPrinterPresetCopy(): This function shows the web page for copying presets.
_papplPrinterPresetDelete(): This function displays the web page to delete a particular preset.
In /pappl/system-loadsave.c, I created an API to save presets in a file (the file is stored in /var/spool/legacy-printer-app/name_of_the_file_for_particular_preset).
papplSystemSavePreset(): This API is used to store presets in files, with each printer having a unique preset file.
In /pappl/printer.h, I created the structure of a preset represented by pappl_pr_preset_data_s, which includes fields such as:
Name: A unique name given to the preset.
Id: A unique ID assigned to the preset.
Static attributes like pappl_color_mode_t color_supported: Each static attribute has a boolean field representing whether the option is selected in the preset on the web interface or not.
After that, I wrote the code to store vendor attributes.
In /pappl/printer.c:
papplPresetAdd(): This function fetches presets from the file (stored in /var/spool/legacy-printer-app/file_name.txt).
_papplSystemAddPreset(): This function adds the preset to the running printer thread.
papplPresetDelete(): This function removes the preset element from the printer's presets array.
_papplPresetDelete(): This function removes all memory and resources associated with a particular preset.
In /pappl/printer-driver.c, I wrote the code to initialize preset fields when needed, such as during operations like edit, copy, and creation of the preset.
papplPrinterAddPresetCreate(): This function adds a particular preset to the printer thread.
papplSetPresetVendor(): This function sets vendor attributes in the preset object.
papplSetPresetFromDriver(): This function sets driver attributes in the preset object.
Please let me know what further changes I will need to make.
Thank you!