public inbox for git-commits@fedoraproject.org
help / color / mirror / Atom feed
* [rpms/pappl-retrofit] f43: Implement prPrintFile() for raw printing (INFRASERV-1240)
@ 2026-10-02 11:33 pdancak
0 siblings, 0 replies; only message in thread
From: pdancak @ 2026-10-02 11:33 UTC (permalink / raw)
To: git-commits
A new commit has been pushed.
Repo : rpms/pappl-retrofit
Branch : f43
Commit : 4f2bedf34fd5b3c97f692c25b45f6c7dad85941c
Author : pdancak <pdancak@redhat.com>
Date : 2026-09-24T12:06:40+02:00
Stats : +272/-1 in 2 file(s)
URL : https://src.fedoraproject.org/rpms/pappl-retrofit/c/4f2bedf34fd5b3c97f692c25b45f6c7dad85941c?branch=f43
Log:
Implement prPrintFile() for raw printing (INFRASERV-1240)
Backport upstream fix from OpenPrinting/pappl-retrofit#58 which implements
the prPrintFile() function for raw printing and sets it as the printfile_cb
callback instead of NULL. This fixes the error 'Driver supports raw printing
but hasn't set a print file callback' that prevents printer installation
with newer pappl versions.
Resolves: INFRASERV-1240
Co-authored-by: Cursor <cursoragent@cursor.com>
---
diff --git a/0001-Implement-prPrintFile-for-raw-printing.patch b/0001-Implement-prPrintFile-for-raw-printing.patch
new file mode 100644
index 0000000..d1d957c
--- /dev/null
+++ b/0001-Implement-prPrintFile-for-raw-printing.patch
@@ -0,0 +1,264 @@
+From 1626b338fc8b92a99c2c1a483ac39c739d71b305 Mon Sep 17 00:00:00 2001
+From: Zdenek Dohnal <zdohnal@redhat.com>
+Date: Wed, 10 Sep 2026 12:16:32 +0200
+Subject: [PATCH] Implement prPrintFile() for raw printing
+
+Implement new public function for raw printing, so all retrofitting
+printer application can use it.
+
+Fixes OpenPrinting/pappl-retrofit#41
+
+Upstream: https://github.com/OpenPrinting/pappl-retrofit/pull/58
+---
+ pappl-retrofit/pappl-retrofit.c | 2 +-
+ pappl-retrofit/pappl-retrofit.h | 2 +
+ pappl-retrofit/print-job.c | 208 +++++++++++++++++++++++++++++++
+ 3 files changed, 211 insertions(+), 1 deletion(-)
+
+diff --git a/pappl-retrofit/pappl-retrofit.c b/pappl-retrofit/pappl-retrofit.c
+index 386fede..f14bb8c 100644
+--- a/pappl-retrofit/pappl-retrofit.c
++++ b/pappl-retrofit/pappl-retrofit.c
+@@ -1364,7 +1364,7 @@ _prDriverSetup(
+ driver_data->identify_default = PAPPL_IDENTIFY_ACTIONS_SOUND;
+ driver_data->identify_supported = PAPPL_IDENTIFY_ACTIONS_DISPLAY |
+ PAPPL_IDENTIFY_ACTIONS_SOUND;
+- driver_data->printfile_cb = NULL;
++ driver_data->printfile_cb = prPrintFile;
+ driver_data->rendjob_cb = NULL;
+ driver_data->rendpage_cb = NULL;
+ driver_data->rstartjob_cb = NULL;
+diff --git a/pappl-retrofit/pappl-retrofit.h b/pappl-retrofit/pappl-retrofit.h
+index 9246935..d97fdcf 100644
+--- a/pappl-retrofit/pappl-retrofit.h
++++ b/pappl-retrofit/pappl-retrofit.h
+@@ -274,6 +274,8 @@ extern bool prPSRasterStartPage(pappl_job_t *job, pappl_pr_options_t *options,
+ extern bool prPSRasterWriteLine(pappl_job_t *job, pappl_pr_options_t *options,
+ pappl_device_t *device, unsigned y,
+ const unsigned char *pixels);
++extern bool prPrintFile(pappl_job_t *job, pappl_pr_options_t *options,
++ pappl_device_t *device);
+ extern void prSetupAddPPDFilesPage(void *data);
+ extern void prSetupDeviceSettingsPage(pappl_printer_t *printer,
+ void *data);
+diff --git a/pappl-retrofit/print-job.c b/pappl-retrofit/print-job.c
+index 466d9d3..0074c0e 100644
+--- a/pappl-retrofit/print-job.c
++++ b/pappl-retrofit/print-job.c
+@@ -1522,6 +1522,214 @@ _prPrintFilterFunction(int inputfd, // I - File descriptor input
+ }
+
+
++//
++// 'prPrintFile()' - Print a raw file by passing it directly to
++// the device without filtering. Used as the
++// printfile_cb callback for PAPPL's raw print
++// path when the job format matches the driver's
++// native format.
++//
++
++bool // O - `true` on success, `false` on failure
++prPrintFile(
++ pappl_job_t *job, // I - Job
++ pappl_pr_options_t *options, // I - Job options
++ pappl_device_t *device) // I - Output device
++{
++ int fd; // Input file descriptor
++ ssize_t bytes; // Bytes read/written
++ char buffer[65536]; // Read/write buffer
++ pappl_printer_t *printer = NULL; // Printer
++ pappl_pr_driver_data_t driver_data, // Driver data
++ *ret_data = NULL; // Return data pointer
++ pr_driver_extension_t *extension; // Driver extension data
++ pr_printer_app_global_data_t *global_data; // Global data
++ const char *device_uri; // Printer device URI
++ pr_cups_device_data_t *device_data = NULL; // CUPS backend device data
++ cf_filter_data_t *filter_data = NULL; // Filter data for CUPS backend
++ char filename[2048]; // Debug copy file name
++ int debug_fd = -1; // File descriptor for debug copy
++ bool ret = true; // Return value
++
++
++ (void)options;
++
++ if (!job || !device)
++ return (false);
++
++ if ((printer = papplJobGetPrinter(job)) == NULL)
++ return (false);
++
++ if ((ret_data = papplPrinterGetDriverData(printer, &driver_data)) == NULL)
++ return (false);
++
++ extension = (pr_driver_extension_t *)driver_data.extension;
++
++ if (!extension || !extension->global_data)
++ return (false);
++
++ global_data = extension->global_data;
++
++ if ((device_uri = papplPrinterGetDeviceURI(printer)) == NULL)
++ return (false);
++
++ //
++ // Connect filter_data to CUPS backend if using cups: device URI
++ //
++
++ if (global_data->config && global_data->config->components & PR_COPTIONS_CUPS_BACKENDS &&
++ strncmp(device_uri, "cups:", 5) == 0)
++ {
++ filter_data = (cf_filter_data_t *)calloc(1, sizeof(cf_filter_data_t));
++
++ if (!filter_data)
++ {
++ papplLogJob(job, PAPPL_LOGLEVEL_ERROR, "Unable to allocate memory");
++ return (false);
++ }
++
++ filter_data->back_pipe[0] = -1;
++ filter_data->back_pipe[1] = -1;
++ filter_data->side_pipe[0] = -1;
++ filter_data->side_pipe[1] = -1;
++ filter_data->logfunc = _prJobLog;
++ filter_data->logdata = job;
++ filter_data->iscanceledfunc = _prJobIsCanceled;
++ filter_data->iscanceleddata = job;
++
++ if (cfFilterOpenBackAndSidePipes(filter_data))
++ {
++ free(filter_data);
++
++ papplLogJob(job, PAPPL_LOGLEVEL_ERROR, "Couldn't open side and back channels to the backend");
++ return (false);
++ }
++
++ if ((device_data = (pr_cups_device_data_t *)papplDeviceGetData(device)) == NULL)
++ {
++ cfFilterCloseBackAndSidePipes(filter_data);
++ free(filter_data);
++
++ papplLogJob(job, PAPPL_LOGLEVEL_ERROR, "No device data found");
++ return (false);
++ }
++ else
++ device_data->filter_data = filter_data;
++ }
++
++ //
++ // Update printer status
++ //
++
++ _prUpdateStatus(printer, device);
++
++ //
++ // Clean up old debug copies and open a new one if in debug mode
++ //
++
++ _prCleanDebugCopies(global_data);
++
++ if (papplSystemGetLogLevel(global_data->system) == PAPPL_LOGLEVEL_DEBUG)
++ {
++ snprintf(filename, sizeof(filename), "%s/debug-jobdata-%s-%d.prn",
++ global_data->spool_dir, papplPrinterGetName(printer),
++ papplJobGetID(job));
++ papplLogJob(job, PAPPL_LOGLEVEL_DEBUG,
++ "Creating debug copy: %s", filename);
++ debug_fd = open(filename, O_CREAT | O_WRONLY, S_IRUSR | S_IWUSR);
++ }
++
++ //
++ // Open the raw job file
++ //
++
++ papplJobSetImpressions(job, 1);
++
++ if ((fd = open(papplJobGetDocumentFilename(job, 1), O_RDONLY)) < 0)
++ {
++ papplLogJob(job, PAPPL_LOGLEVEL_ERROR,
++ "Unable to open print file '%s': %s",
++ papplJobGetDocumentFilename(job, 1), strerror(errno));
++ ret = false;
++ goto cleanup;
++ }
++
++ //
++ // Copy raw data to the device
++ //
++
++ while ((bytes = read(fd, buffer, sizeof(buffer))) > 0)
++ {
++ if (debug_fd >= 0)
++ {
++ if (write(debug_fd, buffer, (size_t)bytes) != bytes)
++ {
++ papplLogJob(job, PAPPL_LOGLEVEL_WARN,
++ "Debug copy: Unable to write %d bytes, "
++ "stopping debug copy, continuing job.",
++ (int)bytes);
++ close(debug_fd);
++ debug_fd = -1;
++ }
++ }
++
++ if (papplDeviceWrite(device, buffer, (size_t)bytes) < 0)
++ {
++ papplLogJob(job, PAPPL_LOGLEVEL_ERROR,
++ "Unable to send %d bytes to printer.",
++ (int)bytes);
++ close(fd);
++ ret = false;
++ goto cleanup;
++ }
++ }
++ close(fd);
++
++ if (bytes < 0)
++ {
++ papplLogJob(job, PAPPL_LOGLEVEL_ERROR,
++ "Unable to read print file: %s", strerror(errno));
++ ret = false;
++ goto cleanup;
++ }
++
++ papplDeviceFlush(device);
++
++ papplJobSetImpressionsCompleted(job, 1);
++
++ //
++ // Clean up
++ //
++
++cleanup:
++
++ if (debug_fd >= 0)
++ close(debug_fd);
++
++ //
++ // Update printer status
++ //
++
++ _prUpdateStatus(printer, device);
++
++ //
++ // Stop CUPS backend and disconnect filter_data
++ //
++
++ if (device_data && filter_data)
++ {
++ papplLogJob(job, PAPPL_LOGLEVEL_DEBUG,
++ "Shutting down CUPS backend");
++ _prCUPSDevStopBackend(device);
++ device_data->filter_data = NULL;
++ cfFilterCloseBackAndSidePipes(filter_data);
++ free(filter_data);
++ }
++
++ return (ret);
++}
++
++
+ //
+ // '_prRasterPrepareJob()' - Create job data record to carry through
+ // all the raster printing callbacks from
+--
+2.49.0
diff --git a/pappl-retrofit.spec b/pappl-retrofit.spec
index b25a125..e76016c 100644
--- a/pappl-retrofit.spec
+++ b/pappl-retrofit.spec
@@ -13,7 +13,7 @@
Name: pappl-retrofit
Version: 1.0b2
-Release: 12%{?dist}
+Release: 13%{?dist}
# the CUPS exception text is the same as LLVM exception, so using that name with
# agreement from legal team
# https://lists.fedoraproject.org/archives/list/legal@lists.fedoraproject.org/message/A7GFSD6M3GYGSI32L2FC5KB22DUAEQI3/
@@ -42,6 +42,9 @@ Patch007: 0001-Protect-_prASCII-from-negative-lengths.patch
Patch008: 0001-Fix-potential-memory-leaks.patch
# https://github.com/OpenPrinting/pappl-retrofit/pull/31
Patch009: 0001-Fix-memory-leaks-from-compiled_re_list.patch
+# https://github.com/OpenPrinting/pappl-retrofit/pull/58
+# Implement prPrintFile() for raw printing (INFRASERV-1240)
+Patch010: 0001-Implement-prPrintFile-for-raw-printing.patch
# for autogen.sh - generating configure scripts
@@ -196,6 +199,10 @@ make check
%{_mandir}/man1/legacy-printer-app.1.gz
%changelog
+* Thu Sep 24 2026 Petr Dancak <pdancak@redhat.com> - 1.0b2-13
+- Implement prPrintFile() for raw printing (INFRASERV-1240)
+- Upstream: https://github.com/OpenPrinting/pappl-retrofit/pull/58
+
* Thu Jul 16 2026 Fedora Release Engineering <releng@fedoraproject.org> - 1.0b2-12
- Rebuilt for https://fedoraproject.org/wiki/Fedora_45_Mass_Rebuild
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2026-10-02 11:33 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-10-02 11:33 [rpms/pappl-retrofit] f43: Implement prPrintFile() for raw printing (INFRASERV-1240) pdancak
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox