Add capability management functions and integrate with D-Bus interface - #67
Draft
Souptik-De wants to merge 44 commits into
Draft
Add capability management functions and integrate with D-Bus interface#67Souptik-De wants to merge 44 commits into
Souptik-De wants to merge 44 commits into
Conversation
…ket and add cupsFreeOptions and g_free for failure return paths
…ups for better job creation feedback
cupsCreateDestJob() was called with a manually managed http_t* from cupsConnectDest(). This creates a TCP connection to the printer queue where Local peer credential auth is impossible and Kerberos is unavailable, causing a 401 Unauthorized when the CUPS policy requires authentication. Fix by using CUPS_HTTP_DEFAULT for all CUPS job I/O. This causes the CUPS library to connect to cupsd via the Unix domain socket, where the kernel automatically vouches for the caller's UID via peer credentials (SO_PEERCRED), satisfying the authenticated policy without a password. Also fix a thread safety bug: cupsStartDestDocument was called on the main thread but cupsWriteRequestData and cupsFinishDestDocument were called on the worker thread using the same http_t*. Since CUPS_HTTP_DEFAULT is per-thread (stored in _cups_globals_t), all three calls must be on the same thread. Move cupsStartDestDocument and cupsCopyDestInfo into the worker thread alongside the data transfer calls.
Remove p->http from PrinterCUPS and replace ensure_printer_connection() with ensure_dest_info() which only manages p->dinfo. All CUPS API calls now use CUPS_HTTP_DEFAULT, letting the library manage its own per-thread Unix domain socket connection to cupsd. Also fix a memory leak in cups_get_Resolution which never freed its dinfo or closed its http_t.
…ive print thread count
…et/print_fd signatures for thread management
… anf fix use of memory after free
… in function on_printer_state_changed
…in BackendObj and more null checks
…er instead of wget release
…IPP extraction backend_helper.h: Add CPDB_CAP_UNKNOWN to CapabilityType; expand Capability struct with human_readable_name, group_name, human_readable_group, human_readable_choices; add locale param to get_all_capabilities(). backend_helper.c: - Fix extract_ipp_attribute(): add IPP_TAG_BOOLEAN case using ippGetBoolean() — was falling through to ippGetString() which returns NULL for boolean attributes, breaking both get_all_options() and get_all_capabilities() for boolean options. - get_all_capabilities(): accept locale; populate human-readable fields via get_option_translation/get_choice_translation/ cpdbGetGroupTranslation2 with raw-string fallback. Also store group_name directly instead of computing it only in pack_capability. - pack_capability(): update to a(sssisia(ss)ii) tuple (10 fields). - free_capabilities(): free all new fields. print_backend_cups.c: Update on_handle_get_all_capabilities handler signature to include locale; pass locale to get_all_capabilities(); update GVariantBuilder type string.
Three new wrapper functions (get_option_translation_with_fallback, get_choice_translation_with_fallback, get_group_translation_with_fallback) retry with locale 'en' when the requested locale returns NULL or the raw keyword (no real translation found). Used in get_all_capabilities() to ensure human-readable strings always have an English fallback before falling back to raw IPP keywords. The underlying get_option_translation, get_choice_translation, and cpdbGetGroupTranslation2 are unchanged.
Remove get_option_translation_with_fallback, get_choice_translation_with_fallback, get_group_translation_with_fallback from backend_helper.c/h. Restore get_all_capabilities() to call plain get_option_translation/get_choice_translation/cpdbGetGroupTranslation2 with no retry logic (those calls just pass locale through). The English-fallback retry mechanism is now entirely in cpdb-libs (cpdb-frontend.c: cpdbGetOptionTranslation, cpdbGetChoiceTranslation, cpdbGetGroupTranslation, cpdbGetAllTranslations, cpdbGetAllCapabilities), requiring ZERO backend-side changes — works against any backend.
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.
Also updated build.yml and codeql.yml to use git clone cpdb-libs instead of wget the last release
Update: locale + human-readable strings for GetAllCapabilities.
IPP_TAG_BOOLEAN and fell through to ippGetString(), which returns
NULL for boolean-tagged IPP values — real boolean options were
coming back as "NA" instead of their actual value. Fixed.