Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: PAPPL Scan API Bridging v1.4.x (To be rebased after review) #371

Draft
wants to merge 31 commits into
base: v1.4.x
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
7190a0b
Update scanner header files
Kappuccino111 Mar 9, 2024
f621099
Add eof lines
Kappuccino111 Mar 9, 2024
05bc963
Update Scanner header files and Makefile
Kappuccino111 Mar 21, 2024
9cf9ebb
Merge branch 'michaelrsweet:v1.4.x' into v1.4.x
Kappuccino111 Mar 21, 2024
f050217
Update indents
Kappuccino111 Mar 21, 2024
8c6e185
Update scanner header files
Kappuccino111 Mar 22, 2024
e24d9e3
Add scanner object to job struct
Kappuccino111 Mar 22, 2024
deb4baf
Update info about scanner objects in base.h
Kappuccino111 Mar 22, 2024
317300f
Scanner accessor functions
Kappuccino111 Mar 22, 2024
8176b4f
Makefile changes
Kappuccino111 Mar 22, 2024
4e5ef68
Update indents
Kappuccino111 Mar 22, 2024
b3bb2fb
Merge branch 'michaelrsweet:v1.4.x' into v1.4.x
Kappuccino111 Mar 22, 2024
f25ba5e
Merge branch 'michaelrsweet:v1.4.x' into v1.4.x
Kappuccino111 May 29, 2024
d84e01f
Merge branch 'michaelrsweet:v1.4.x' into v1.4.x
Kappuccino111 Jul 4, 2024
4078698
Update: Implement scanner-driver.c for PAPPL
Kappuccino111 Jul 4, 2024
363a7fc
Update Scanner.h to closely follow specifications
Kappuccino111 Jul 7, 2024
6776268
Update scanner-private.h
Kappuccino111 Jul 7, 2024
7dd8e3b
Update scanner-accessors.c with Proper System Call
Kappuccino111 Jul 7, 2024
63025bf
Update Readme and Build
Kappuccino111 Jul 7, 2024
8507fb9
Finalise scanner-driver.c
Kappuccino111 Jul 7, 2024
64f7aa4
Finalise scanner-webif.c
Kappuccino111 Jul 12, 2024
3579da6
Finalise scanner.c
Kappuccino111 Jul 12, 2024
12f7014
Merge branch 'michaelrsweet:v1.4.x' into v1.4.x
Kappuccino111 Nov 1, 2024
92dcfe0
Minor changes to the log and scanner files
Kappuccino111 Nov 2, 2024
ea4cd3c
Add support for scanning dnssd services
Kappuccino111 Nov 2, 2024
3da7f2c
Add job-scan.c
Kappuccino111 Nov 2, 2024
128769a
Add system related scanner function
Kappuccino111 Nov 3, 2024
a34e612
Addition of mainloop functions for Scan API
Kappuccino111 Nov 3, 2024
980c312
Add mainloop support, implementing basic scan API
Kappuccino111 Nov 3, 2024
a1231d0
Add eSCL functions for scan settings and XML parsing
Kappuccino111 Nov 3, 2024
b87ee5f
Add Dummy Driver Files for testing
Kappuccino111 Nov 3, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions BUILD.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,13 @@ CentOS 8/Fedora 23+/RHEL 8:

sudo dnf groupinstall 'Development Tools'
sudo dnf install avahi-devel cups-devel libjpeg-turbo-devel \
libpng-devel libssl-devel libusbx-devel pam-devel zlib-devel
libpng-devel libssl-devel libusbx-devel pam-devel zlib-devel libxml2 libxml2-dev

Debian/Raspbian/Ubuntu:

sudo apt-get install build-essential libavahi-client-dev libcups2-dev \
libcupsimage2-dev libjpeg-dev libpam-dev libpng-dev libssl-dev \
libusb-1.0-0-dev zlib1g-dev
libusb-1.0-0-dev zlib1g-dev libxml2 libxml2-dev

macOS (after installing Xcode from the AppStore):

Expand All @@ -43,6 +43,7 @@ macOS (after installing Xcode from the AppStore):
brew install libpng
brew install libusb
brew install openssl@3
brew install libxml2

or download, build, and install libjpeg, libpng, libusb, and OpenSSL or LibreSSL
from source.
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ are required along with the following support libraries:
- LIBUSB (1.0 or later) for USB printing support (optional)
- PAM for authentication support (optional)
- ZLIB (1.1 or later) for compression support
- LIBXML for xml parsing support

Most development happens on Intel and Apple Silicon Macs, with testing on
various Linux distributions, Windows 10+, and a [Raspberry Pi Zero W][7] to
Expand Down Expand Up @@ -111,4 +112,3 @@ This software is based loosely on the "ippeveprinter.c" code from [CUPS][12].
[10]: https://github.com/openprinting/ps-printer-app
[11]: https://hosted.weblate.org
[12]: https://openprinting.github.io/cups

105 changes: 105 additions & 0 deletions pappl/DummyDriverFiles/ScannerCapabilities.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
- Version: 2.6
- MakeAndModel: Hewlett-Packard Photosmart C4760
- SerialNumber: CN017971874378PJ
- UUID: 96a4b400-2a9e-012f-6165-0025559efbc6f
- AdminURI: http://192.168.1.2/index.html
- IconURI: http://192.168.1.2/scanner.png

Profile name: p1
- ColorModes:
- ColorMode: BlackAndWhite1
- ColorMode: Grayscale8
- DocumentFormats:
- DocumentFormat: application/pdf
- DocumentFormat: image/jpeg
- DocumentFormatExt: application/pdf
- DocumentFormatExt: image/jpeg
- SupportedResolutions:
- DiscreteResolution:
- XResolution: 100
- YResolution: 100
- DiscreteResolution:
- XResolution: 200
- YResolution: 200
- DiscreteResolution:
- XResolution: 300
- YResolution: 300
- CcdChannels:
- CcdChannel: Red
- CcdChannel (default=true): Blue
- BinaryRenderings:
- BinaryRendering: Threshold
- BinaryRendering (default=true): Halftone

Platen:
- PlatenInputCaps:
- MinWidth: 1
- MaxWidth: 3000
- MinHeight: 1
- MaxHeight: 3600
- MaxScanRegions: 2
- SettingProfiles:
- ColorModes:
- ColorMode: RGB24
- ColorMode: Grayscale8
- ColorMode: BlackAndWhite1
- DocumentFormats:
- DocumentFormat: image/jpeg
- DocumentFormat: application/pdf
- DocumentFormatExt: image/jpeg
- DocumentFormatExt: application/pdf
- SupportedResolutions:
- ResolutionRange:
- XResolutionRange:
- Min: 75
- Max: 1200
- Normal: 300
- Step: 10
- YResolutionRange:
- Min: 75
- Max: 1200
- Normal: 300
- Step: 10
- ColorSpaces:
- ColorSpace (default=true): sRGB
- CcdChannels:
- CcdChannel: Red
- CcdChannel: Blue
- CcdChannel: Green
- CcdChannel (default=true): NTSC
- BinaryRenderings:
- BinaryRendering (default=true): Halftone
- BinaryRendering: Threshold
- MaxOpticalXResolution: 1200
- MaxOpticalYResolution: 1200
- RiskyLeftMargin: 28
- RiskyRightMargin: 30
- RiskyTopMargin: 32
- RiskyBottomMargin: 44

Adf:
- AdfSimplexInputCaps:
- MinWidth: 1
- MaxWidth: 2600
- MinHeight: 1
- MaxHeight: 3400
- SettingProfiles:
- SettingProfile ref: p1
- EdgeAutoDetection:
- SupportedEdge: BottomEdge
- MaxOpticalXResolution: 300
- MaxOpticalYResolution: 300
- RiskyLeftMargin: 28
- RiskyRightMargin: 30
- RiskyTopMargin: 32
- RiskyBottomMargin: 44
- FeederCapacity: 100
- AdfOptions:
- AdfOption: DetectPaperLoaded
- AdfOption: SelectSinglePage

StoredJobRequestSupport:
- MaxStoredJobRequests: 10
- TimeoutInSeconds: 120
- BlankPageDetection: true
- BlankPageDetectionAndRemoval: true
22 changes: 22 additions & 0 deletions pappl/DummyDriverFiles/ScannerStatus.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
- Version: 2.6
- State: Processing

Jobs:

Job Information:
- Job URI: /ScanJobs/893e6fcd-487f-4056-a8c9-a87709b85daf
- Job UUID: 893e6fcd-487f-4056-a8c9-a87709b85daf
- Age: 10
- Images Completed: 1
- Images To Transfer: 1
- Job State: Processing
- Job State Reasons: JobScanning

Job Information:
- Job URI: /ScanJobs/898d6fcd-487f-4056-a8c9-a87709b85daf
- Job UUID: 898d6fcd-487f-4056-a8c9-a87709b85daf
- Age: 220
- Images Completed: 5
- Images To Transfer: 0
- Job State: Completed
- Job State Reasons: JobCompletedSuccessfully
14 changes: 13 additions & 1 deletion pappl/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@

include ../Makedefs

CFLAGS += $(shell pkg-config --cflags libxml-2.0)
LDFLAGS += $(shell pkg-config --libs libxml-2.0)

BASEOBJS = \
client.o \
Expand All @@ -23,11 +25,13 @@ BASEOBJS = \
device-network.o \
device-usb.o \
dnssd.o \
esclops.o \
httpmon.o \
job-accessors.o \
job-filter.o \
job-ipp.o \
job-process.o \
job-scan.o \
job.o \
link.o \
loc.o \
Expand All @@ -45,6 +49,11 @@ BASEOBJS = \
printer-usb.o \
printer-webif.o \
resource.o \
scanner.o \
scanner-accessors.o\
scanner-driver.o \
scanner-escl.o \
scanner-webif.o \
snmp.o \
subscription.o \
subscription-ipp.o \
Expand Down Expand Up @@ -72,8 +81,11 @@ HEADERS = \
mainloop.h \
pappl.h \
printer.h \
scanner.h \
scanner-private.h \
subscription.h \
system.h
system.h \
system-private.h

RESOURCES = \
icon-sm.png \
Expand Down
6 changes: 6 additions & 0 deletions pappl/base.h
Original file line number Diff line number Diff line change
Expand Up @@ -102,13 +102,19 @@ typedef unsigned char pappl_dither_t[16][16];
// 16x16 dither array
typedef struct pappl_pr_driver_data_s pappl_pr_driver_data_t;
// Print driver data
typedef struct pappl_sc_driver_data_s pappl_sc_driver_data_t;
// Scanner driver data
typedef struct _pappl_job_s pappl_job_t;// Job object
typedef struct _pappl_loc_s pappl_loc_t;// Localization data
typedef struct pappl_pr_options_s pappl_pr_options_t;
// Combined print job options
typedef struct pappl_sc_options_s pappl_sc_options_t;
// Combined scan job options
typedef unsigned int pappl_preason_t; // Bitfield for IPP "printer-state-reasons" values
typedef struct _pappl_printer_s pappl_printer_t;
// Printer object
typedef struct _pappl_scanner_s pappl_scanner_t;
// Scanner object
typedef struct _pappl_subscription_s pappl_subscription_t;
// Subscription object
typedef struct _pappl_system_s pappl_system_t;
Expand Down
1 change: 1 addition & 0 deletions pappl/client-private.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ struct _pappl_client_s // Client data
char username[256]; // Authenticated username, if any
char language[256]; // Accept-Language value, if any
pappl_printer_t *printer; // Printer, if any
pappl_scanner_t *scanner; // Scanner, if any
pappl_job_t *job; // Job, if any
pappl_loc_t *loc; // Localization, if any
int num_files; // Number of temporary files
Expand Down
124 changes: 124 additions & 0 deletions pappl/client-webif.c
Original file line number Diff line number Diff line change
Expand Up @@ -899,6 +899,26 @@ papplClientHTMLPrinterFooter(pappl_client_t *client) // I - Client
}


//
// 'papplClientHTMLScannerFooter()' - Show the web interface footer for scanners.
//
// This function sends the standard web interface footer for a scanner followed
// by a trailing 0-length chunk to finish the current HTTP response. Use the
// @link papplSystemSetFooterHTML@ function to add any custom HTML needed in
// the footer.
//

void
papplClientHTMLScannerFooter(pappl_client_t *client) // I - Client
{
papplClientHTMLPuts(client,
" </div>\n"
" </div>\n"
" </div>\n");
papplClientHTMLFooter(client);
}


//
// 'papplClientHTMLPrinterHeader()' - Show the web interface header and title
// for printers.
Expand Down Expand Up @@ -1018,6 +1038,110 @@ papplClientHTMLPrinterHeader(
}


//
// 'papplClientHTMLScannerHeader()' - Show the web interface header and title
// for scanners.
//
// This function sends the standard web interface header and title for a
// scanner. If the "refresh" argument is greater than zero, the page will
// automatically reload after that many seconds.
//
// If "label" and "path_or_url" are non-`NULL` strings, an additional navigation
// link is included with the title header - this is typically used for an
// action button ("Change").
//
// Use the @link papplSystemAddLink@ function to add system-wide navigation
// links to the header. Similarly, use @link papplScannerAddLink@ to add
// scanner-specific links, which will appear in the web interface scanner if
// the system is not configured to support multiple scanners
//

// TODO : papplScannerAddLink
void
papplClientHTMLScannerHeader(
pappl_client_t *client, // I - Client
pappl_scanner_t *scanner, // I - Scanner
const char *title, // I - Title
int refresh, // I - Refresh time in seconds or 0 for none
const char *label, // I - Button label or `NULL` for none
const char *path_or_url) // I - Button path or `NULL` for none
{
const char *header; // Header text

if (!papplClientRespond(client, HTTP_STATUS_OK, NULL, "text/html", 0, 0))
return;


// Multi-queue mode not required for scanners

// Single queue mode - the function will automatically add the scanner name and localize the title...
papplClientHTMLHeader(client, title, refresh);

// Generate HTML for scanners
_papplRWLockRead(scanner);
papplClientHTMLPrintf(client,
" <div class=\"header2\">\n"
" <div class=\"row\">\n"
" <div class=\"col-12 nav\"><a class=\"btn\" href=\"%s\">%s:</a>\n", scanner->uriname, scanner->name);
_papplClientHTMLPutLinks(client, scanner->links, PAPPL_LOPTIONS_NAVIGATION);
papplClientHTMLPuts(client,
" </div>\n"
" </div>\n"
" </div>\n");
_papplRWUnlock(scanner);

// Display system version if available
if (client->system->versions[0].sversion[0])
{
papplClientHTMLPrintf(client,
" <div class=\"header2\">\n"
" <div class=\"row\">\n"
" <div class=\"col-12 nav\">\n"
" Version %s\n"
" </div>\n"
" </div>\n"
" </div>\n", client->system->versions[0].sversion);
}

papplClientHTMLPuts(client, " <div class=\"content\">\n");

if ((header = papplClientGetLocString(client, client->uri)) == client->uri)
{
size_t urilen = strlen(scanner->uriname);
// Length of scanner URI name
const char *uriptr = client->uri + urilen;
// Pointer into client URI

if (strlen(client->uri) <= urilen || !strcmp(client->uri, "/") || (header = papplClientGetLocString(client, uriptr)) == uriptr)
header = NULL;
}

if (header)
{
// Show header text
papplClientHTMLPuts(client,
" <div class=\"row\">\n"
" <div class=\"col-12\">\n");
papplClientHTMLPuts(client, header);
papplClientHTMLPuts(client,
"\n"
" </div>\n"
" </div>\n");
}

if (title)
{
papplClientHTMLPrintf(client,
" <div class=\"row\">\n"
" <div class=\"col-12\">\n"
" <h1 class=\"title\">%s", papplClientGetLocString(client, title));
if (label && path_or_url)
papplClientHTMLPrintf(client, " <a class=\"btn\" href=\"%s\">%s</a>", path_or_url, papplClientGetLocString(client, label));
papplClientHTMLPuts(client, "</h1>\n");
}
}


//
// 'papplClientHTMLPrintf()' - Send formatted text to the web browser client,
// escaping as needed.
Expand Down
2 changes: 2 additions & 0 deletions pappl/client.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ extern bool papplClientHTMLAuthorize(pappl_client_t *client) _PAPPL_PUBLIC;
extern void papplClientHTMLEscape(pappl_client_t *client, const char *s, size_t slen) _PAPPL_PUBLIC;
extern void papplClientHTMLFooter(pappl_client_t *client) _PAPPL_PUBLIC;
extern void papplClientHTMLHeader(pappl_client_t *client, const char *title, int refresh) _PAPPL_PUBLIC;
extern void papplClientHTMLScannerHeader(pappl_client_t *client, pappl_scanner_t *scanner, const char *title, int refresh, const char *label, const char *path_or_url)_PAPPL_PUBLIC;
extern void papplClientHTMLScannerFooter(pappl_client_t *client)_PAPPL_PUBLIC;
extern void papplClientHTMLPrinterFooter(pappl_client_t *client) _PAPPL_PUBLIC;
extern void papplClientHTMLPrinterHeader(pappl_client_t *client, pappl_printer_t *printer, const char *title, int refresh, const char *label, const char *path_or_url) _PAPPL_PUBLIC;
extern void papplClientHTMLPrintf(pappl_client_t *client, const char *format, ...) _PAPPL_PUBLIC _PAPPL_FORMAT(2, 3);
Expand Down
Loading
Loading