-
-
Notifications
You must be signed in to change notification settings - Fork 50
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
base: v1.4.x
Are you sure you want to change the base?
Conversation
This commit introduces a new file scanner-driver.c that contains the implementation of functions related to the scanner driver. Signed-off-by: Akarshan Kapoor <[email protected]>
This commit updates Scanner.h to closely follow the Mopria Scan specifications. We should now have a very detailed implementaion of scanner.h that closely follows the structure of printer.h while also following the Mopria Scan specifications. Signed-off-by: Akarshan Kapoor <[email protected]>
This commit adds some basic features to closely follow the printer-private.h file. The updated scanner-private.h should be the final version of this file (for now). Signed-off-by: Akarshan Kapoor <[email protected]>
- Implemented scanner-specific event handling and introduced new events for scanner operations. - Added `scanner-escl.c` for eSCL-specific scanner state management. - Modified `job-process.c`, `job.c`, `printer-accessors.c`, and `scanner-accessors.c` to integrate scanner event functions. - Updated `system-subscription.c` to support scanner events and added `papplSystemAddScannerEvent`. - Enhanced `system-private.h` and `subscription.h` with new scanner event types and callback definitions. - Included necessary changes in `Makefile` and other system-related files for compatibility. Signed-off-by: Akarshan Kapoor <[email protected]>
This commit updates the Readme and Build files to include libxml2 as a dependency. Signed-off-by: Akarshan Kapoor <[email protected]>
This commit finalises the scanner-driver.c file. It includes all the functions as required for working with scanner-drivers and closely in line with the printer-driver.c file. Signed-off-by: Akarshan Kapoor <[email protected]>
This commit finalises the scanner-webif.c file. It closely follows all aspects of the printer-webif.c file, but also follows the scan specific requirements. This commit finalizes the implementation of the scanner web interface functions, including the following features: - Added `_papplScannerWebConfig()` to show and handle scanner configuration settings. - Implemented `_papplScannerWebConfigFinalize()` to save changes to the scanner configuration. - Developed `_papplScannerWebDefaults()` to display and update default scanning settings. Signed-off-by: Akarshan Kapoor <[email protected]>
This commit finalises the scanner.c file. It is closely in reference to the printer.c file, while also covering the necessary details of eSCL Scanning. Signed-off-by: Akarshan Kapoor <[email protected]>
Add a few comments and also add scanner_logging function to the log file. Signed-off-by: Akarshan Kapoor <[email protected]>
This commits primarily adds functions for registration and unregistration of DNSSD related to scanners. Signed-off-by: Akarshan Kapoor <[email protected]>
This commit creates a new file job-scan.c with various functions to handle scanning jobs. The file is added to the Makefile and the job.h and job-private.h header file are updated to include the new functions. Signed-off-by: Akarshan Kapoor <[email protected]>
#endif // HAVE_MDNSRESPONDER | ||
|
||
// Build formats string | ||
for (i = 0, count = 0, ptr = formats; scanner->driver_data.document_formats_supported[i] && i < PAPPL_MAX_FORMATS; i++) |
Check failure
Code scanning / CodeQL
Array offset used before range check High
range check
if (i > 0) | ||
*ptr++ = ','; | ||
if (scanner->driver_data.input_sources_supported[i] == PAPPL_FLATBED) | ||
ptr += snprintf(ptr, sizeof(sources) - (size_t)(ptr - sources), "platen"); |
Check failure
Code scanning / CodeQL
Potentially overflowing call to snprintf High
size argument
if (scanner->driver_data.input_sources_supported[i] == PAPPL_FLATBED) | ||
ptr += snprintf(ptr, sizeof(sources) - (size_t)(ptr - sources), "platen"); | ||
else if (scanner->driver_data.input_sources_supported[i] == PAPPL_ADF) | ||
ptr += snprintf(ptr, sizeof(sources) - (size_t)(ptr - sources), "adf"); |
Check failure
Code scanning / CodeQL
Potentially overflowing call to snprintf High
size argument
} | ||
|
||
// Build color spaces string | ||
for (i = 0, count = 0, ptr = colorspaces; scanner->driver_data.color_spaces_supported[i] && i < PAPPL_MAX_COLOR_SPACES; i++) |
Check failure
Code scanning / CodeQL
Array offset used before range check High
range check
{ | ||
if (i > 0) | ||
*ptr++ = ','; | ||
ptr += snprintf(ptr, sizeof(intents) - (size_t)(ptr - intents), "%s", scanner->driver_data.mandatory_intents[i]); |
Check failure
Code scanning / CodeQL
Potentially overflowing call to snprintf High
size argument
switch (scanner->driver_data.color_modes_supported[i]) | ||
{ | ||
case PAPPL_BLACKANDWHITE1: | ||
ptr += snprintf(ptr, sizeof(color_modes) - (size_t)(ptr - color_modes), "BlackAndWhite1"); |
Check failure
Code scanning / CodeQL
Potentially overflowing call to snprintf High
size argument
ptr += snprintf(ptr, sizeof(color_modes) - (size_t)(ptr - color_modes), "BlackAndWhite1"); | ||
break; | ||
case PAPPL_GRAYSCALE8: | ||
ptr += snprintf(ptr, sizeof(color_modes) - (size_t)(ptr - color_modes), "Grayscale8"); |
Check failure
Code scanning / CodeQL
Potentially overflowing call to snprintf High
size argument
ptr += snprintf(ptr, sizeof(color_modes) - (size_t)(ptr - color_modes), "Grayscale8"); | ||
break; | ||
case PAPPL_RGB24: | ||
ptr += snprintf(ptr, sizeof(color_modes) - (size_t)(ptr - color_modes), "RGB24"); |
Check failure
Code scanning / CodeQL
Potentially overflowing call to snprintf High
size argument
|
||
// Scan intent - Validate against supported intents | ||
intent_supported = false; | ||
for (i = 0; scanner->driver_data.mandatory_intents[i] && i < 5; i++) |
Check failure
Code scanning / CodeQL
Array offset used before range check High
range check
job->state = IPP_JSTATE_COMPLETED; | ||
|
||
// Ensure job->state is within the bounds of job_states array | ||
if ((job->state - IPP_JSTATE_PENDING) >= 0 && |
Check warning
Code scanning / CodeQL
Unsigned comparison to zero Warning
Signed-off-by: Akarshan Kapoor <[email protected]>
Signed-off-by: Akarshan Kapoor <[email protected]>
Signed-off-by: Akarshan Kapoor <[email protected]>
Signed-off-by: Akarshan Kapoor <[email protected]>
char *contentRegionUnits = getString(&scanSettings, "ContentRegionUnits", contentRegionUnitsPattern); | ||
|
||
char *widthPattern = "<pwg:Width>([^<]*)</pwg:Width>"; | ||
double width = getNumber(&scanSettings, "Width", widthPattern); |
Check notice
Code scanning / CodeQL
Unused local variable Note
double width = getNumber(&scanSettings, "Width", widthPattern); | ||
|
||
char *xOffsetPattern = "<pwg:XOffset>([^<]*)</pwg:XOffset>"; | ||
double xOffset = getNumber(&scanSettings, "XOffset", xOffsetPattern); |
Check notice
Code scanning / CodeQL
Unused local variable Note
double xOffset = getNumber(&scanSettings, "XOffset", xOffsetPattern); | ||
|
||
char *yOffsetPattern = "<pwg:YOffset>([^<]*)</pwg:YOffset>"; | ||
double yOffset = getNumber(&scanSettings, "YOffset", yOffsetPattern); |
Check notice
Code scanning / CodeQL
Unused local variable Note
free(inputSource); | ||
free(colorMode); | ||
free(blankPageDetection); | ||
free(scanSettings.xml); |
Check failure
Code scanning / CodeQL
Missing return statement Error
Signed-off-by: Akarshan Kapoor <[email protected]>
OK, I still need to do a more in-depth code review, but I'd prefer that you use Mini-XML for any of the XML support instead of libxml2, mainly because libxml2 is about twice the size of PAPPL itself and is nowhere near as fast as Mini-XML. |
@michaelrsweet okay, I will consider that. The XML libraries are primarily for parsing the XML side of eSCL requests, so I will have to probably make some library specific changes. I will review the mxml library documentation and get back to you. |
Opening the work completed for the Scan API in v1.4.x directly. Rebasing will be the final step after the base review and testing are completed. The rebasing process should not take long.