Skip to content

Define structures and methods for all printer capabilities and implement functions to create and delete printer capabilities - #95

Merged
tillkamppeter merged 20 commits into
OpenPrinting:masterfrom
Souptik-De:master
Aug 7, 2026
Merged

Define structures and methods for all printer capabilities and implement functions to create and delete printer capabilities#95
tillkamppeter merged 20 commits into
OpenPrinting:masterfrom
Souptik-De:master

Conversation

@Souptik-De

@Souptik-De Souptik-De commented Jul 17, 2026

Copy link
Copy Markdown
  • cpdbGetNewCapabilities() - creates new capabilities struct with hash tables
  • cpdbDeleteCapabilities() - frees capabilities struct and hash tables
  • cpdbDeleteCapability() - frees individual capability struct and its arrays

Update: added locale support + human-readable strings to GetAllCapabilities.

  • XML: added locale input arg; output signature changed from
    a(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.

    • 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

@Souptik-De
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)" />

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done .

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))" />

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
@tillkamppeter
tillkamppeter merged commit 6a40f2a into OpenPrinting:master Aug 7, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants