kopia lustrzana https://gitlab.com/sane-project/backends
Cosmetic cleanup, and support for cameras that don't support image
capture or file deletion.DEVEL_2_0_BRANCH-1
rodzic
9be08d236c
commit
6a924e4c1d
|
@ -1,8 +1,8 @@
|
||||||
/* Please note! This is extremely alpha code, and is really intended as
|
/* Please note! This is extremely alpha code, and is really intended as
|
||||||
* a "proof of concept" since I don't yet know whether it's going to
|
* a "proof of concept" since I don't yet know whether it's going to
|
||||||
* to be practical and/or possible to implement a the complete backend.
|
* to be practical and/or possible to implement a the complete backend.
|
||||||
* It's also been tested with only one camera model, the Kodak DC240,
|
* It's also been tested with only cameras I have access to: the Kodak DC240
|
||||||
* which happens to be the only camera I have. I'm very interested
|
* and the Directory Browse "camera." I'm very interested
|
||||||
* in learning what it would take to support more cameras. In
|
* in learning what it would take to support more cameras. In
|
||||||
* particular, the current incarnation will only support cameras
|
* particular, the current incarnation will only support cameras
|
||||||
* that directly generate jpeg files.
|
* that directly generate jpeg files.
|
||||||
|
@ -406,7 +406,7 @@ init_gphoto2 (void)
|
||||||
CHECK_RET (gp_port_info_list_load (il));
|
CHECK_RET (gp_port_info_list_load (il));
|
||||||
|
|
||||||
|
|
||||||
if ( strcmp (Cam_data.port, "Browse") != 0 )
|
if (strcmp (Cam_data.port, "Browse") != 0)
|
||||||
{
|
{
|
||||||
port = gp_port_info_list_lookup_path (il, Cam_data.port);
|
port = gp_port_info_list_lookup_path (il, Cam_data.port);
|
||||||
CHECK_RET (gp_port_info_list_get_info (il, port, &info));
|
CHECK_RET (gp_port_info_list_get_info (il, port, &info));
|
||||||
|
@ -429,7 +429,8 @@ init_gphoto2 (void)
|
||||||
* the port, and that seems to confuse the camera. Holding
|
* the port, and that seems to confuse the camera. Holding
|
||||||
* the port open seems to fix it.
|
* the port open seems to fix it.
|
||||||
*/
|
*/
|
||||||
if ( (hack_fd=open(Cam_data.port+7,O_RDONLY)) < 0 ) {
|
if ((hack_fd = open (Cam_data.port + 7, O_RDONLY)) < 0)
|
||||||
|
{
|
||||||
return SANE_STATUS_INVAL;
|
return SANE_STATUS_INVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -449,6 +450,18 @@ init_gphoto2 (void)
|
||||||
sod[GPHOTO2_OPT_SNAP].cap |= SANE_CAP_INACTIVE;
|
sod[GPHOTO2_OPT_SNAP].cap |= SANE_CAP_INACTIVE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!(abilities.operations & GP_OPERATION_CAPTURE_PREVIEW))
|
||||||
|
{
|
||||||
|
DBG (20, "Camera does not support image preview\n");
|
||||||
|
sod[GPHOTO2_OPT_THUMBS].cap |= SANE_CAP_INACTIVE;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!(abilities.file_operations & GP_FILE_OPERATION_DELETE))
|
||||||
|
{
|
||||||
|
DBG (20, "Camera does not support image deletion\n");
|
||||||
|
sod[GPHOTO2_OPT_ERASE].cap |= SANE_CAP_INACTIVE;
|
||||||
|
}
|
||||||
|
|
||||||
for (n = 0; abilities.speed[n]; n++)
|
for (n = 0; abilities.speed[n]; n++)
|
||||||
{
|
{
|
||||||
if (abilities.speed[n] == Cam_data.speed)
|
if (abilities.speed[n] == Cam_data.speed)
|
||||||
|
@ -494,7 +507,7 @@ close_gphoto2 (void)
|
||||||
DBG (1, "close_gphoto2: error: could not close device\n");
|
DBG (1, "close_gphoto2: error: could not close device\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
close(hack_fd);
|
close (hack_fd);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -520,11 +533,12 @@ get_info (void)
|
||||||
image_range.max = Cam_data.pic_taken;
|
image_range.max = Cam_data.pic_taken;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( SubDirs )
|
if (SubDirs)
|
||||||
{
|
{
|
||||||
n = read_dir (TopFolder, 0);
|
n = read_dir (TopFolder, 0);
|
||||||
}
|
}
|
||||||
else {
|
else
|
||||||
|
{
|
||||||
n = 1;
|
n = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -544,7 +558,7 @@ get_info (void)
|
||||||
folder_list =
|
folder_list =
|
||||||
(SANE_String *) malloc ((n + 1) * sizeof (SANE_String_Const *));
|
(SANE_String *) malloc ((n + 1) * sizeof (SANE_String_Const *));
|
||||||
|
|
||||||
if ( SubDirs )
|
if (SubDirs)
|
||||||
{
|
{
|
||||||
for (n = 0; n < gp_list_count (dir_list); n++)
|
for (n = 0; n < gp_list_count (dir_list); n++)
|
||||||
{
|
{
|
||||||
|
@ -562,7 +576,7 @@ get_info (void)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
n=0;
|
n = 0;
|
||||||
folder_list[n++] = "N/A";
|
folder_list[n++] = "N/A";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -587,8 +601,16 @@ erase (void)
|
||||||
{
|
{
|
||||||
SANE_String_Const filename;
|
SANE_String_Const filename;
|
||||||
|
|
||||||
|
if (SubDirs)
|
||||||
|
{
|
||||||
sprintf (cmdbuf, "%s/%s", (char *) TopFolder,
|
sprintf (cmdbuf, "%s/%s", (char *) TopFolder,
|
||||||
(const char *) folder_list[current_folder]);
|
(const char *) folder_list[current_folder]);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
strcpy (cmdbuf, TopFolder);
|
||||||
|
}
|
||||||
|
|
||||||
CHECK_RET (gp_list_get_name
|
CHECK_RET (gp_list_get_name
|
||||||
(dir_list, Cam_data.current_picture_number - 1, &filename));
|
(dir_list, Cam_data.current_picture_number - 1, &filename));
|
||||||
|
|
||||||
|
@ -627,7 +649,8 @@ sane_init (SANE_Int * version_code, SANE_Auth_Callback UNUSEDARG authorize)
|
||||||
|
|
||||||
DBG_INIT ();
|
DBG_INIT ();
|
||||||
|
|
||||||
DBG (1, "GPHOTO2 Backend $Id$\n");
|
DBG (1,
|
||||||
|
"GPHOTO2 Backend $Id$\n");
|
||||||
|
|
||||||
if (getenv ("GP_DEBUG"))
|
if (getenv ("GP_DEBUG"))
|
||||||
{
|
{
|
||||||
|
@ -736,7 +759,7 @@ sane_init (SANE_Int * version_code, SANE_Auth_Callback UNUSEDARG authorize)
|
||||||
* in the config file.
|
* in the config file.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if ( strcmp(Cam_data.camera_name, "Directory Browse") == 0 )
|
if (strcmp (Cam_data.camera_name, "Directory Browse") == 0)
|
||||||
{
|
{
|
||||||
Cam_data.port = "Browse";
|
Cam_data.port = "Browse";
|
||||||
}
|
}
|
||||||
|
@ -770,7 +793,7 @@ sane_init (SANE_Int * version_code, SANE_Auth_Callback UNUSEDARG authorize)
|
||||||
else if (strncmp (dev_name, "topfolder=", 10) == 0)
|
else if (strncmp (dev_name, "topfolder=", 10) == 0)
|
||||||
{
|
{
|
||||||
/* Make sure TopFolder is non-null */
|
/* Make sure TopFolder is non-null */
|
||||||
if ( strlen(dev_name) > 10 )
|
if (strlen (dev_name) > 10)
|
||||||
{
|
{
|
||||||
TopFolder = strdup (&dev_name[10]);
|
TopFolder = strdup (&dev_name[10]);
|
||||||
DBG (20, "Config file topfolder=%s\n", TopFolder);
|
DBG (20, "Config file topfolder=%s\n", TopFolder);
|
||||||
|
@ -779,7 +802,7 @@ sane_init (SANE_Int * version_code, SANE_Auth_Callback UNUSEDARG authorize)
|
||||||
else if (strncmp (dev_name, "subdirs=", 8) == 0)
|
else if (strncmp (dev_name, "subdirs=", 8) == 0)
|
||||||
{
|
{
|
||||||
SubDirs = atoi (&dev_name[8]);
|
SubDirs = atoi (&dev_name[8]);
|
||||||
if ( SubDirs == 0 )
|
if (SubDirs == 0)
|
||||||
{
|
{
|
||||||
sod[GPHOTO2_OPT_FOLDER].cap |= SANE_CAP_INACTIVE;
|
sod[GPHOTO2_OPT_FOLDER].cap |= SANE_CAP_INACTIVE;
|
||||||
}
|
}
|
||||||
|
@ -789,7 +812,7 @@ sane_init (SANE_Int * version_code, SANE_Auth_Callback UNUSEDARG authorize)
|
||||||
fclose (fp);
|
fclose (fp);
|
||||||
}
|
}
|
||||||
|
|
||||||
dev[0].name=strdup(Cam_data.port);
|
dev[0].name = strdup (Cam_data.port);
|
||||||
|
|
||||||
DBG (3, "sane_init: about to init_gphoto2\n");
|
DBG (3, "sane_init: about to init_gphoto2\n");
|
||||||
|
|
||||||
|
@ -1319,14 +1342,14 @@ sane_start (SANE_Handle handle)
|
||||||
|
|
||||||
CHECK_RET (gp_file_new (&data_file));
|
CHECK_RET (gp_file_new (&data_file));
|
||||||
|
|
||||||
if ( SubDirs )
|
if (SubDirs)
|
||||||
{
|
{
|
||||||
sprintf (cmdbuf, "%s/%s", (char *) TopFolder,
|
sprintf (cmdbuf, "%s/%s", (char *) TopFolder,
|
||||||
(const char *) folder_list[current_folder]);
|
(const char *) folder_list[current_folder]);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
strcpy(cmdbuf,TopFolder);
|
strcpy (cmdbuf, TopFolder);
|
||||||
}
|
}
|
||||||
|
|
||||||
CHECK_RET (gp_list_get_name
|
CHECK_RET (gp_list_get_name
|
||||||
|
@ -1356,8 +1379,9 @@ sane_start (SANE_Handle handle)
|
||||||
{
|
{
|
||||||
linebuffer = malloc (parms.bytes_per_line);
|
linebuffer = malloc (parms.bytes_per_line);
|
||||||
}
|
}
|
||||||
else {
|
else
|
||||||
free(linebuffer);
|
{
|
||||||
|
free (linebuffer);
|
||||||
linebuffer = malloc (parms.bytes_per_line);
|
linebuffer = malloc (parms.bytes_per_line);
|
||||||
}
|
}
|
||||||
if (linebuffer == NULL)
|
if (linebuffer == NULL)
|
||||||
|
@ -1396,7 +1420,7 @@ sane_read (SANE_Handle UNUSEDARG handle, SANE_Byte * data,
|
||||||
{
|
{
|
||||||
SANE_Status retval;
|
SANE_Status retval;
|
||||||
|
|
||||||
*length=0;
|
*length = 0;
|
||||||
retval = converter_do_scan_complete_cleanup ();
|
retval = converter_do_scan_complete_cleanup ();
|
||||||
|
|
||||||
if (retval != SANE_STATUS_GOOD)
|
if (retval != SANE_STATUS_GOOD)
|
||||||
|
@ -1475,7 +1499,7 @@ get_pictures_info (void)
|
||||||
}
|
}
|
||||||
|
|
||||||
strcpy (path, TopFolder);
|
strcpy (path, TopFolder);
|
||||||
if ( SubDirs )
|
if (SubDirs)
|
||||||
{
|
{
|
||||||
if (folder_list[current_folder] != NULL)
|
if (folder_list[current_folder] != NULL)
|
||||||
{
|
{
|
||||||
|
@ -1690,8 +1714,16 @@ converter_do_scan_complete_cleanup (void)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if (SubDirs)
|
||||||
|
{
|
||||||
sprintf (cmdbuf, "%s/%s", (char *) TopFolder,
|
sprintf (cmdbuf, "%s/%s", (char *) TopFolder,
|
||||||
(const char *) folder_list[current_folder]);
|
(const char *) folder_list[current_folder]);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
strcpy (cmdbuf, TopFolder);
|
||||||
|
}
|
||||||
|
|
||||||
CHECK_RET (gp_list_get_name
|
CHECK_RET (gp_list_get_name
|
||||||
(dir_list, Cam_data.current_picture_number - 1, &filename));
|
(dir_list, Cam_data.current_picture_number - 1, &filename));
|
||||||
|
|
||||||
|
|
Ładowanie…
Reference in New Issue