Define structures and methods for all printer capabilities and implement functions to create and delete printer capabilities - #95
Merged
Conversation
This workflow runs CodeQL analysis on pushes and pull requests to the master branch, and it is scheduled to run weekly.
…tFd D-Bus method)
…utes for socket fallback case
… printer capabilities * cpdbGetNewCapabilities() - creates new capabilities struct with hash tables * cpdbDeleteCapabilities() - frees capabilities struct and hash tables * cpdbDeleteCapability() - frees individual capability struct and its arrays
Souptik-De
marked this pull request as ready for review
July 17, 2026 19:30
…ability type definitions making New frontend + old backend compatible
…apability type enum D-Bus XML: Add locale input arg to GetAllCapabilities; change output signature from a(ssisia(s)ii) to a(sssisia(ss)ii) — inserts human-readable name after option name, human-readable group after group name, and changes supported-values array from a(s) to a(ss) (value + human-readable label pair per choice). cpdb-frontend.h: Replace #define constants with cpdb_capability_type_t enum; expand cpdb_capability_s with human_readable_name, human_readable_group, human_readable_choices fields; add locale param to cpdbGetAllCapabilities(). cpdb-frontend.c: Thread locale through to D-Bus call; update cpdbUnpackCapabilities for new (sssisia(ss)ii) variant format; update cpdbDeleteCapability to free new fields; populate human-readable fields in options_to_capabilities() fallback path.
All translation-fallback logic is now in cpdb-frontend.c, requiring ZERO backend-side changes. Four paths covered: - cpdbGetOptionTranslation: if backend returns the raw option_name, retry D-Bus call with locale 'en' - cpdbGetChoiceTranslation: same pattern using choice_name - cpdbGetGroupTranslation: same pattern using group_name - cpdbGetAllTranslations: fetch English table, patch entries where value == raw key suffix and English differs - cpdbGetAllCapabilities: second GetAllCapabilities D-Bus call with 'en', patch untranslated human_readable_name/group/choices from the English result No new public API, no ABI changes, no backend opt-in needed.
| <arg name="printer_id" direction="in" type="s" /> | ||
| <arg name="locale" direction="in" type="s" /> | ||
| <arg name="num_capabilities" direction="out" type="i" /> | ||
| <arg name="capabilities" direction="out" type="a(sssisia(ss)ii)" /> |
Member
There was a problem hiding this comment.
It needs to have 4 "s" in the beginning:
a(ssssisia(ss)ii)
as we have: option name, human-readable name, group name, human-readable group, type, ... which are 4 string values in the beginning.
| pairs, range lower bound, range upper bound | ||
| (only meaningful for type=range)--> | ||
| <arg name="num_media" direction="out" type="i" /> | ||
| <arg name="media" direction="out" type="a(siiia(iiii))" /> |
Member
There was a problem hiding this comment.
Please add a comment with the meaning of the fields here, like you did for the capabilities.
Also, media also have human-readable names AFAIK, so there would be 2 "s" needed.
Author
There was a problem hiding this comment.
This has been resolved already , as I messaged you privately in telegram . let me know if there is any issue
…an_readable_name to media - Fix capabilities D-Bus signature: a(sssisia(ss)ii) -> a(ssssisia(ss)ii) (was missing human_readable_group as 4th leading string) - Change comment to match the 4-string field order - Add separate cpdb_capability_media_t struct with human_readable_name field so GetAllCapabilities media entries carry a display name while GetAllOptions' cpdb_media_t stays unchanged - Update cpdbUnpackCapabilities to parse a(ssiiia(iiii)) format - Wire cpdbDeleteCapabilityMedia into cpdbGetNewCapabilities hash table - Extend English-fallback retry to also patch media human readable names
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Update: added locale support + human-readable strings to GetAllCapabilities.
XML: added
localeinput arg; output signature changed froma(ssisia(s)ii) to a(sssisia(ss)ii) to carry human-readable option
name, human-readable group, and (value, label) pairs per choice.
cpdb-frontend.h/.c: struct and cpdbGetAllCapabilities() updated to
match; fallback path (old backend, no GetAllCapabilities support)
populates human-readable fields with raw strings since no
translation is available there.
retry D-Bus call with locale 'en'
cpdbGetChoiceTranslation: same pattern using choice_name
cpdbGetGroupTranslation: same pattern using group_name
cpdbGetAllTranslations: fetch English table, patch entries where
value == raw key suffix and English differs
cpdbGetAllCapabilities: second GetAllCapabilities D-Bus call with
'en', patch untranslated human_readable_name/group/choices from
the English result