kopia lustrzana https://gitlab.com/sane-project/backends
Various minor bug fixes found by tstbackend
rodzic
6617f9d129
commit
8565da657b
|
@ -1026,6 +1026,17 @@ sane_control_option (SANE_Handle handle, SANE_Int option,
|
||||||
switch (action)
|
switch (action)
|
||||||
{
|
{
|
||||||
case SANE_ACTION_SET_VALUE:
|
case SANE_ACTION_SET_VALUE:
|
||||||
|
|
||||||
|
/* Can't set disabled options */
|
||||||
|
if (!SANE_OPTION_IS_ACTIVE (sod[option].cap))
|
||||||
|
{
|
||||||
|
return (SANE_STATUS_INVAL);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* initialize info to zero - we'll OR in various values later */
|
||||||
|
if (info)
|
||||||
|
*info = 0;
|
||||||
|
|
||||||
status = sanei_constrain_value (sod + option, value, &myinfo);
|
status = sanei_constrain_value (sod + option, value, &myinfo);
|
||||||
if (status != SANE_STATUS_GOOD)
|
if (status != SANE_STATUS_GOOD)
|
||||||
{
|
{
|
||||||
|
@ -1036,7 +1047,11 @@ sane_control_option (SANE_Handle handle, SANE_Int option,
|
||||||
switch (option)
|
switch (option)
|
||||||
{
|
{
|
||||||
case DC240_OPT_IMAGE_NUMBER:
|
case DC240_OPT_IMAGE_NUMBER:
|
||||||
Camera.current_picture_number = *(SANE_Word *) value;
|
if (*(SANE_Word *) value <= Camera.pic_taken)
|
||||||
|
Camera.current_picture_number = *(SANE_Word *) value;
|
||||||
|
else
|
||||||
|
Camera.current_picture_number = Camera.pic_taken;
|
||||||
|
|
||||||
myinfo |= SANE_INFO_RELOAD_PARAMS;
|
myinfo |= SANE_INFO_RELOAD_PARAMS;
|
||||||
|
|
||||||
/* get the image's resolution, unless the camera has no
|
/* get the image's resolution, unless the camera has no
|
||||||
|
@ -1051,6 +1066,8 @@ sane_control_option (SANE_Handle handle, SANE_Int option,
|
||||||
|
|
||||||
case DC240_OPT_THUMBS:
|
case DC240_OPT_THUMBS:
|
||||||
dc240_opt_thumbnails = !!*(SANE_Word *) value;
|
dc240_opt_thumbnails = !!*(SANE_Word *) value;
|
||||||
|
|
||||||
|
/* Thumbnail forces an image size change: */
|
||||||
myinfo |= SANE_INFO_RELOAD_PARAMS;
|
myinfo |= SANE_INFO_RELOAD_PARAMS;
|
||||||
|
|
||||||
if (Camera.pic_taken != 0)
|
if (Camera.pic_taken != 0)
|
||||||
|
@ -1061,7 +1078,19 @@ sane_control_option (SANE_Handle handle, SANE_Int option,
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case DC240_OPT_SNAP:
|
case DC240_OPT_SNAP:
|
||||||
dc240_opt_snap = !!*(SANE_Word *) value;
|
switch ( *(SANE_Bool *) value ) {
|
||||||
|
case SANE_TRUE:
|
||||||
|
dc240_opt_snap = SANE_TRUE;
|
||||||
|
break;
|
||||||
|
case SANE_FALSE:
|
||||||
|
dc240_opt_snap = SANE_FALSE;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
return SANE_STATUS_INVAL;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Snap forces new image size and changes image range */
|
||||||
|
|
||||||
myinfo |= SANE_INFO_RELOAD_PARAMS | SANE_INFO_RELOAD_OPTIONS;
|
myinfo |= SANE_INFO_RELOAD_PARAMS | SANE_INFO_RELOAD_OPTIONS;
|
||||||
/* if we are snapping a new one */
|
/* if we are snapping a new one */
|
||||||
if (dc240_opt_snap)
|
if (dc240_opt_snap)
|
||||||
|
@ -1103,7 +1132,7 @@ sane_control_option (SANE_Handle handle, SANE_Int option,
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case DC240_OPT_FOLDER:
|
case DC240_OPT_FOLDER:
|
||||||
printf ("FIXME set folder not implemented yet\n");
|
DBG (1, "FIXME set folder not implemented yet\n");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case DC240_OPT_DEFAULT:
|
case DC240_OPT_DEFAULT:
|
||||||
|
@ -1144,6 +1173,12 @@ sane_control_option (SANE_Handle handle, SANE_Int option,
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SANE_ACTION_GET_VALUE:
|
case SANE_ACTION_GET_VALUE:
|
||||||
|
/* Can't return status for disabled options */
|
||||||
|
if (!SANE_OPTION_IS_ACTIVE (sod[option].cap))
|
||||||
|
{
|
||||||
|
return (SANE_STATUS_INVAL);
|
||||||
|
}
|
||||||
|
|
||||||
switch (option)
|
switch (option)
|
||||||
{
|
{
|
||||||
case 0:
|
case 0:
|
||||||
|
@ -1191,7 +1226,7 @@ sane_control_option (SANE_Handle handle, SANE_Int option,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (info)
|
if (info && action == SANE_ACTION_SET_VALUE)
|
||||||
{
|
{
|
||||||
*info = myinfo;
|
*info = myinfo;
|
||||||
myinfo = 0;
|
myinfo = 0;
|
||||||
|
@ -1426,6 +1461,11 @@ sane_read (SANE_Handle UNUSEDARG handle, SANE_Byte * data,
|
||||||
SANE_Int lines = 0;
|
SANE_Int lines = 0;
|
||||||
SANE_Char filename_buf[256];
|
SANE_Char filename_buf[256];
|
||||||
|
|
||||||
|
if ( Camera.scanning == SANE_FALSE )
|
||||||
|
{
|
||||||
|
return SANE_STATUS_INVAL;
|
||||||
|
}
|
||||||
|
|
||||||
/* If there is anything in the buffer, satisfy the read from there */
|
/* If there is anything in the buffer, satisfy the read from there */
|
||||||
if (linebuffer_size && linebuffer_index < linebuffer_size)
|
if (linebuffer_size && linebuffer_index < linebuffer_size)
|
||||||
{
|
{
|
||||||
|
@ -1520,7 +1560,23 @@ SANE_Status
|
||||||
sane_set_io_mode (SANE_Handle UNUSEDARG handle, SANE_Bool
|
sane_set_io_mode (SANE_Handle UNUSEDARG handle, SANE_Bool
|
||||||
UNUSEDARG non_blocking)
|
UNUSEDARG non_blocking)
|
||||||
{
|
{
|
||||||
return SANE_STATUS_UNSUPPORTED;
|
/* sane_set_io_mode() is only valid during a scan */
|
||||||
|
if (Camera.scanning)
|
||||||
|
{
|
||||||
|
if ( non_blocking == SANE_FALSE )
|
||||||
|
{
|
||||||
|
return SANE_STATUS_GOOD;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return SANE_STATUS_UNSUPPORTED;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
/* We aren't currently scanning */
|
||||||
|
return SANE_STATUS_INVAL;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
SANE_Status
|
SANE_Status
|
||||||
|
|
|
@ -1092,7 +1092,16 @@ sane_control_option (SANE_Handle handle, SANE_Int option,
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case GPHOTO2_OPT_SNAP:
|
case GPHOTO2_OPT_SNAP:
|
||||||
gphoto2_opt_snap = !!*(SANE_Word *) value;
|
switch ( *(SANE_Bool *) value ) {
|
||||||
|
case SANE_TRUE:
|
||||||
|
gphoto2_opt_snap = SANE_TRUE;
|
||||||
|
break;
|
||||||
|
case SANE_FALSE:
|
||||||
|
gphoto2_opt_snap = SANE_FALSE;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
return SANE_STATUS_INVAL;
|
||||||
|
}
|
||||||
|
|
||||||
/* Snap forces new image size and changes image range */
|
/* Snap forces new image size and changes image range */
|
||||||
|
|
||||||
|
@ -1143,7 +1152,7 @@ sane_control_option (SANE_Handle handle, SANE_Int option,
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case GPHOTO2_OPT_FOLDER:
|
case GPHOTO2_OPT_FOLDER:
|
||||||
printf ("FIXME set folder not implemented yet\n");
|
DBG (1, "FIXME set folder not implemented yet\n");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case GPHOTO2_OPT_DEFAULT:
|
case GPHOTO2_OPT_DEFAULT:
|
||||||
|
@ -1404,7 +1413,7 @@ sane_start (SANE_Handle handle)
|
||||||
CHECK_RET (gp_file_get_mime_type (data_file, &mime_type));
|
CHECK_RET (gp_file_get_mime_type (data_file, &mime_type));
|
||||||
if (strcmp (GP_MIME_JPEG, mime_type) != 0)
|
if (strcmp (GP_MIME_JPEG, mime_type) != 0)
|
||||||
{
|
{
|
||||||
DBG (0, "FIXME - Only jpeg files currently supported\n");
|
DBG (0, "FIXME - Only jpeg files currently supported, can't do %s for file %s/%s\n",mime_type, cmdbuf, filename );
|
||||||
return SANE_STATUS_INVAL;
|
return SANE_STATUS_INVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1443,6 +1452,11 @@ SANE_Status
|
||||||
sane_read (SANE_Handle UNUSEDARG handle, SANE_Byte * data,
|
sane_read (SANE_Handle UNUSEDARG handle, SANE_Byte * data,
|
||||||
SANE_Int max_length, SANE_Int * length)
|
SANE_Int max_length, SANE_Int * length)
|
||||||
{
|
{
|
||||||
|
if ( Cam_data.scanning == SANE_FALSE )
|
||||||
|
{
|
||||||
|
return SANE_STATUS_INVAL;
|
||||||
|
}
|
||||||
|
|
||||||
/* If there is anything in the buffer, satisfy the read from there */
|
/* If there is anything in the buffer, satisfy the read from there */
|
||||||
if (linebuffer_size && linebuffer_index < linebuffer_size)
|
if (linebuffer_size && linebuffer_index < linebuffer_size)
|
||||||
{
|
{
|
||||||
|
@ -1506,7 +1520,23 @@ SANE_Status
|
||||||
sane_set_io_mode (SANE_Handle UNUSEDARG handle, SANE_Bool
|
sane_set_io_mode (SANE_Handle UNUSEDARG handle, SANE_Bool
|
||||||
UNUSEDARG non_blocking)
|
UNUSEDARG non_blocking)
|
||||||
{
|
{
|
||||||
return SANE_STATUS_UNSUPPORTED;
|
/* sane_set_io_mode() is only valid during a scan */
|
||||||
|
if (Cam_data.scanning)
|
||||||
|
{
|
||||||
|
if ( non_blocking == SANE_FALSE )
|
||||||
|
{
|
||||||
|
return SANE_STATUS_GOOD;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return SANE_STATUS_UNSUPPORTED;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
/* We aren't currently scanning */
|
||||||
|
return SANE_STATUS_INVAL;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -1924,4 +1954,6 @@ converter_init (void)
|
||||||
parms.pixels_per_line = cinfo.output_width;
|
parms.pixels_per_line = cinfo.output_width;
|
||||||
parms.lines = cinfo.output_height;
|
parms.lines = cinfo.output_height;
|
||||||
|
|
||||||
|
linebuffer_size=0;
|
||||||
|
linebuffer_index=0;
|
||||||
}
|
}
|
||||||
|
|
Ładowanie…
Reference in New Issue