2001-08-18 Lutz M�ller <urc8@rz.uni-karlsruhe.de>
* README: Add notice about USB Mass Storage cameras.
* include/*:
* libgphoto2/*: Major cleanup - add licence notice to begin of each
file, remove unused files/functions, ...
* camlibs/konica/Makefile.am: There's no ChangeLog here...
* tests/test-gphoto2.c: Adjust headers
git-svn-id: https://svn.code.sf.net/p/gphoto/code/trunk/libgphoto2@2003 67ed7778-7388-44ab-90cf-0a291f65f57c
This commit is contained in:
@@ -1,3 +1,12 @@
|
||||
2001-08-18 Lutz Müller <urc8@rz.uni-karlsruhe.de>
|
||||
|
||||
* README: Add notice about USB Mass Storage cameras.
|
||||
* include/*:
|
||||
* libgphoto2/*: Major cleanup - add licence notice to begin of each
|
||||
file, remove unused files/functions, ...
|
||||
* camlibs/konica/Makefile.am: There's no ChangeLog here...
|
||||
* tests/test-gphoto2.c: Adjust headers
|
||||
|
||||
2001-08-17 Lutz Müller <urc8@rz.uni-karlsruhe.de>
|
||||
|
||||
* include/gphoto2-camera.h:
|
||||
|
||||
20
README
20
README
@@ -32,6 +32,26 @@ and availability of gphoto2. Another source of information is
|
||||
where you can access our CVS server to fetch the source code of
|
||||
gphoto2, gtkam and GnoCam (see below).
|
||||
|
||||
What is gphoto2 not?
|
||||
--------------------
|
||||
|
||||
gphoto2 can only talk to cameras the language of those it understands. That is,
|
||||
if you own a camera that speaks a language that isn't published anywhere and
|
||||
nobody has been able to figure out the meaning of the sentences, gphoto2 cannot
|
||||
communicate with those cameras.
|
||||
|
||||
Then, there are cameras supporting the so-called USB Mass Storage protocol.
|
||||
This is a protocol that has been published and lets you access any storage
|
||||
device, be it a camera or a disk connected via USB to your computer. As there
|
||||
are already drivers for this protocol out there, you don't need an additional
|
||||
program like gphoto2. As of now, the following cameras seem to support the
|
||||
USB Mass Storage protocol:
|
||||
* Minolta Dimage 7
|
||||
* Nikon Coolpix 995
|
||||
* Olympus C-200Z, C-860L, C-2040, C-3040Z
|
||||
* HP PhotoSmart 315, 618, 912
|
||||
Again, those cameras cannot be accessed through gphoto2.
|
||||
|
||||
Requirements
|
||||
------------
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@ camlib_LTLIBRARIES = libgphoto2_konica.la
|
||||
|
||||
CFLAGS = @CFLAGS@ `glib-config --cflags`
|
||||
LDFLAGS = @LDFLAGS@ `glib-config --libs`
|
||||
EXTRA_DIST = ChangeLog EXPERTS
|
||||
EXTRA_DIST = EXPERTS
|
||||
|
||||
INCLUDES =\
|
||||
-I$(top_srcdir)/include\
|
||||
|
||||
@@ -1,16 +1,17 @@
|
||||
## Process this file with automake to generate a GNU Makefile
|
||||
|
||||
gphotoheaddir = $(prefix)/include/gphoto2
|
||||
gphotohead_HEADERS= \
|
||||
gphoto2.h \
|
||||
gphoto2-camera.h \
|
||||
gphoto2-core.h \
|
||||
gphoto2-datatypes.h \
|
||||
gphoto2-file.h \
|
||||
gphoto2-filesys.h \
|
||||
gphoto2-frontend.h \
|
||||
gphoto2-library.h \
|
||||
gphoto2-lists.h \
|
||||
gphoto2-settings.h \
|
||||
gphotohead_HEADERS= \
|
||||
gphoto2.h \
|
||||
gphoto2-abilities.h \
|
||||
gphoto2-abilities-list.h \
|
||||
gphoto2-camera.h \
|
||||
gphoto2-core.h \
|
||||
gphoto2-file.h \
|
||||
gphoto2-filesys.h \
|
||||
gphoto2-frontend.h \
|
||||
gphoto2-library.h \
|
||||
gphoto2-list.h \
|
||||
gphoto2-setting.h \
|
||||
gphoto2-widget.h
|
||||
|
||||
|
||||
37
include/gphoto2-abilities-list.h
Normal file
37
include/gphoto2-abilities-list.h
Normal file
@@ -0,0 +1,37 @@
|
||||
/* gphoto2-abilities-list.h
|
||||
*
|
||||
* Copyright (C) 2000 Scott Fritzinger
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the
|
||||
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#ifndef __GPHOTO2_ABILITIES_LIST_H__
|
||||
#define __GPHOTO2_ABILITIES_LIST_H__
|
||||
|
||||
#include <gphoto2-abilities.h>
|
||||
|
||||
typedef struct {
|
||||
int count;
|
||||
CameraAbilities **abilities;
|
||||
} CameraAbilitiesList;
|
||||
|
||||
CameraAbilitiesList* gp_abilities_list_new (void);
|
||||
|
||||
int gp_abilities_list_free (CameraAbilitiesList *list);
|
||||
int gp_abilities_list_dump (CameraAbilitiesList *list);
|
||||
int gp_abilities_list_append (CameraAbilitiesList *list, CameraAbilities *);
|
||||
|
||||
#endif /* __GPHOTO2_ABILITIES_LIST_H__ */
|
||||
81
include/gphoto2-abilities.h
Normal file
81
include/gphoto2-abilities.h
Normal file
@@ -0,0 +1,81 @@
|
||||
/* gphoto2-abilities.h
|
||||
*
|
||||
* Copyright (C) 2000 Scott Fritzinger
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the
|
||||
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#ifndef __GPHOTO2_ABILITIES_H__
|
||||
#define __GPHOTO2_ABILITIES_H__
|
||||
|
||||
#include <gphoto2-port.h>
|
||||
|
||||
#define SERIAL_SUPPORTED(p) (p & (1 << 0))
|
||||
#define PARALLEL_SUPPORTED(p) (p & (1 << 1))
|
||||
#define USB_SUPPORTED(p) (p & (1 << 2))
|
||||
#define IEEE1394_SUPPORTED(p) (p & (1 << 3))
|
||||
#define NETWORK_SUPPORTED(p) (p & (1 << 4))
|
||||
|
||||
typedef gp_port_type CameraPortType; /* GP_PORT_SERIAL, GP_PORT_USB, etc. */
|
||||
|
||||
typedef enum {
|
||||
GP_OPERATION_NONE = 0,
|
||||
GP_OPERATION_CAPTURE_IMAGE = 1 << 0,
|
||||
GP_OPERATION_CAPTURE_VIDEO = 1 << 1,
|
||||
GP_OPERATION_CAPTURE_AUDIO = 1 << 2,
|
||||
GP_OPERATION_CAPTURE_PREVIEW = 1 << 3,
|
||||
GP_OPERATION_CONFIG = 1 << 4
|
||||
} CameraOperation;
|
||||
|
||||
typedef enum {
|
||||
GP_FILE_OPERATION_NONE = 0,
|
||||
GP_FILE_OPERATION_DELETE = 1 << 1,
|
||||
GP_FILE_OPERATION_CONFIG = 1 << 2,
|
||||
GP_FILE_OPERATION_PREVIEW = 1 << 3
|
||||
} CameraFileOperation;
|
||||
|
||||
typedef enum {
|
||||
GP_FOLDER_OPERATION_NONE = 0,
|
||||
GP_FOLDER_OPERATION_DELETE_ALL = 1 << 0,
|
||||
GP_FOLDER_OPERATION_PUT_FILE = 1 << 1,
|
||||
GP_FOLDER_OPERATION_CONFIG = 1 << 2
|
||||
} CameraFolderOperation;
|
||||
|
||||
typedef struct {
|
||||
char model [128];
|
||||
|
||||
/* Supported ports and speeds (latter terminated with a value of 0) */
|
||||
CameraPortType port;
|
||||
int speed [64];
|
||||
|
||||
/* Supported operations */
|
||||
CameraOperation operations;
|
||||
CameraFileOperation file_operations;
|
||||
CameraFolderOperation folder_operations;
|
||||
|
||||
int usb_vendor, usb_product;
|
||||
|
||||
/* For core use */
|
||||
char library [1024];
|
||||
char id [1024];
|
||||
} CameraAbilities;
|
||||
|
||||
CameraAbilities *gp_abilities_new (void);
|
||||
int gp_abilities_free (CameraAbilities *abilities);
|
||||
int gp_abilities_dump (CameraAbilities *abilities);
|
||||
int gp_abilities_clear (CameraAbilities *abilities);
|
||||
|
||||
#endif /* __GPHOTO2_ABILITIES_H__ */
|
||||
@@ -21,9 +21,16 @@
|
||||
#ifndef __GPHOTO2_CAMERA_H__
|
||||
#define __GPHOTO2_CAMERA_H__
|
||||
|
||||
typedef struct _Camera Camera;
|
||||
|
||||
#include <gphoto2-port.h>
|
||||
|
||||
#include <gphoto2-widget.h>
|
||||
#include <gphoto2-lists.h>
|
||||
#include <gphoto2-list.h>
|
||||
#include <gphoto2-file.h>
|
||||
#include <gphoto2-abilities.h>
|
||||
#include <gphoto2-abilities-list.h>
|
||||
#include <gphoto2-result.h>
|
||||
|
||||
typedef struct {
|
||||
char text [32 * 1024];
|
||||
@@ -66,17 +73,92 @@ typedef struct {
|
||||
CameraFileInfoStruct file;
|
||||
} CameraFileInfo;
|
||||
|
||||
typedef struct _Camera Camera;
|
||||
typedef int (*c_id) (CameraText *);
|
||||
typedef int (*c_abilities) (CameraAbilitiesList *);
|
||||
typedef int (*c_init) (Camera*);
|
||||
typedef int (*c_exit) (Camera*);
|
||||
typedef int (*c_get_config) (Camera*, CameraWidget**);
|
||||
typedef int (*c_set_config) (Camera*, CameraWidget*);
|
||||
typedef int (*c_capture) (Camera*, int, CameraFilePath*);
|
||||
typedef int (*c_capture_preview) (Camera*, CameraFile*);
|
||||
typedef int (*c_summary) (Camera*, CameraText*);
|
||||
typedef int (*c_manual) (Camera*, CameraText*);
|
||||
typedef int (*c_about) (Camera*, CameraText*);
|
||||
|
||||
/* Retrieve the number of available cameras */
|
||||
int gp_camera_count ();
|
||||
typedef int (*c_folder_list_folders) (Camera*, const char*, CameraList*);
|
||||
typedef int (*c_folder_list_files) (Camera*, const char*, CameraList*);
|
||||
typedef int (*c_folder_get_config) (Camera*, const char*, CameraWidget**);
|
||||
typedef int (*c_folder_set_config) (Camera*, const char*, CameraWidget*);
|
||||
typedef int (*c_folder_put_file) (Camera*, const char*, CameraFile*);
|
||||
typedef int (*c_folder_delete_all) (Camera*, const char*);
|
||||
|
||||
/* Retrieve the name of a particular camera */
|
||||
int gp_camera_name (int camera_number, char *camera_name);
|
||||
typedef int (*c_file_get_info) (Camera*, const char*,
|
||||
const char*, CameraFileInfo*);
|
||||
typedef int (*c_file_set_info) (Camera*, const char*,
|
||||
const char*, CameraFileInfo*);
|
||||
typedef int (*c_file_get_config) (Camera*, const char*,
|
||||
const char*, CameraWidget**);
|
||||
typedef int (*c_file_set_config) (Camera*, const char*,
|
||||
const char*, CameraWidget*);
|
||||
typedef int (*c_file_get) (Camera*, const char*,
|
||||
const char*, CameraFile*);
|
||||
typedef int (*c_file_get_preview) (Camera*, const char*,
|
||||
const char*, CameraFile*);
|
||||
typedef int (*c_file_delete) (Camera*, const char*, const char*);
|
||||
|
||||
/* Retreive abilities for a given camera */
|
||||
int gp_camera_abilities (int camera_number, CameraAbilities *abilities);
|
||||
int gp_camera_abilities_by_name (char *camera_name, CameraAbilities *abilities);
|
||||
typedef char *(*c_result_as_string) (Camera*, int);
|
||||
|
||||
|
||||
typedef struct {
|
||||
c_id id;
|
||||
c_abilities abilities;
|
||||
c_init init;
|
||||
c_exit exit;
|
||||
c_get_config get_config;
|
||||
c_set_config set_config;
|
||||
c_capture capture;
|
||||
c_capture_preview capture_preview;
|
||||
c_summary summary;
|
||||
c_manual manual;
|
||||
c_about about;
|
||||
|
||||
c_folder_list_folders folder_list_folders;
|
||||
c_folder_list_files folder_list_files;
|
||||
c_folder_get_config folder_get_config;
|
||||
c_folder_set_config folder_set_config;
|
||||
c_folder_put_file folder_put_file;
|
||||
c_folder_delete_all folder_delete_all;
|
||||
|
||||
c_file_get_info file_get_info;
|
||||
c_file_set_info file_set_info;
|
||||
c_file_get_config file_get_config;
|
||||
c_file_set_config file_set_config;
|
||||
c_file_get_preview file_get_preview;
|
||||
c_file_get file_get;
|
||||
c_file_delete file_delete;
|
||||
|
||||
c_result_as_string result_as_string;
|
||||
} CameraFunctions;
|
||||
|
||||
typedef gp_port_info CameraPortInfo;
|
||||
|
||||
struct _Camera {
|
||||
char model[128];
|
||||
|
||||
CameraPortInfo *port;
|
||||
|
||||
int ref_count;
|
||||
|
||||
void *library_handle;
|
||||
|
||||
CameraAbilities *abilities;
|
||||
CameraFunctions *functions;
|
||||
|
||||
void *camlib_data;
|
||||
void *frontend_data;
|
||||
|
||||
int session;
|
||||
};
|
||||
|
||||
/* Create a new camera device */
|
||||
int gp_camera_new (Camera **camera);
|
||||
|
||||
@@ -1,13 +1,45 @@
|
||||
int gp_init(int debug);
|
||||
int gp_is_initialized(void);
|
||||
int gp_exit();
|
||||
/* gphoto2-core.h
|
||||
*
|
||||
* Copyright (C) 2000 Scott Fritzinger
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the
|
||||
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
void gp_debug_printf(int level, char *id, char *format, ...);
|
||||
#ifndef __GPHOTO2_CORE_H__
|
||||
#define __GPHOTO2_CORE_H__
|
||||
|
||||
int gp_autodetect (CameraList *list);
|
||||
#include <gphoto2-list.h>
|
||||
#include <gphoto2-abilities.h>
|
||||
|
||||
int gp_frontend_register(CameraStatus status, CameraProgress progress,
|
||||
CameraMessage message, CameraConfirm confirm,
|
||||
CameraPrompt prompt);
|
||||
int gp_init (int debug);
|
||||
int gp_is_initialized (void);
|
||||
int gp_exit (void);
|
||||
|
||||
char *gp_result_as_string (int result);
|
||||
void gp_debug_printf (int level, char *id, char *format, ...);
|
||||
|
||||
int gp_autodetect (CameraList *list);
|
||||
|
||||
/* Retrieve the number of available cameras */
|
||||
int gp_camera_count ();
|
||||
|
||||
/* Retrieve the name of a particular camera */
|
||||
int gp_camera_name (int camera_number, char *camera_name);
|
||||
|
||||
/* Retreive abilities for a given camera */
|
||||
int gp_camera_abilities (int camera_number, CameraAbilities *abilities);
|
||||
int gp_camera_abilities_by_name (char *camera_name, CameraAbilities *abilities);
|
||||
|
||||
#endif /* __GPHOTO2_CORE_H__ */
|
||||
|
||||
@@ -1,243 +0,0 @@
|
||||
#include <gphoto2-lists.h>
|
||||
#include <gphoto2-widget.h>
|
||||
#include <gphoto2-camera.h>
|
||||
|
||||
/* Constants
|
||||
---------------------------------------------------------------- */
|
||||
|
||||
/* Return values.
|
||||
Return values below -999 (starting with -1000) are defined by the
|
||||
individual camera library.
|
||||
|
||||
Don't forget to add the corresponding error descriptions in
|
||||
libgphoto2/core.c. */
|
||||
|
||||
#define GP_ERROR_BAD_PARAMETERS -100 /* for checking function-param. */
|
||||
#define GP_ERROR_IO -101 /* IO problem */
|
||||
#define GP_ERROR_CORRUPTED_DATA -102 /* Corrupted data */
|
||||
#define GP_ERROR_FILE_EXISTS -103 /* File exists */
|
||||
#define GP_ERROR_NO_MEMORY -104 /* Insufficient memory */
|
||||
#define GP_ERROR_MODEL_NOT_FOUND -105 /* Model not found */
|
||||
#define GP_ERROR_NOT_SUPPORTED -106 /* Some op. is unsupported */
|
||||
#define GP_ERROR_DIRECTORY_NOT_FOUND -107 /* Directory not found */
|
||||
#define GP_ERROR_FILE_NOT_FOUND -108 /* File not found */
|
||||
#define GP_ERROR_DIRECTORY_EXISTS -109 /* Directory exists */
|
||||
#define GP_ERROR_NO_CAMERA_FOUND -110 /* No cameras auto-detected */
|
||||
|
||||
/* Macros
|
||||
---------------------------------------------------------------- */
|
||||
|
||||
/* Determining what kind of port a camera supports.
|
||||
For use on CameraAbilities -> port */
|
||||
#define SERIAL_SUPPORTED(p) (p & (1 << 0))
|
||||
#define PARALLEL_SUPPORTED(p) (p & (1 << 1))
|
||||
#define USB_SUPPORTED(p) (p & (1 << 2))
|
||||
#define IEEE1394_SUPPORTED(p) (p & (1 << 3))
|
||||
#define NETWORK_SUPPORTED(p) (p & (1 << 4))
|
||||
|
||||
/* Enumerations
|
||||
---------------------------------------------------------------- */
|
||||
|
||||
/* Physical Connection Types */
|
||||
typedef gp_port_type CameraPortType;
|
||||
/* GP_PORT_SERIAL, GP_PORT_USB, GP_PORT_PARALLEL,
|
||||
GP_PORT_IEEE1394, GP_PORT_NETWORK */
|
||||
|
||||
/* Capture Type */
|
||||
typedef enum {
|
||||
GP_OPERATION_NONE = 0,
|
||||
GP_OPERATION_CAPTURE_IMAGE = 1 << 0,
|
||||
GP_OPERATION_CAPTURE_VIDEO = 1 << 1,
|
||||
GP_OPERATION_CAPTURE_AUDIO = 1 << 2,
|
||||
GP_OPERATION_CAPTURE_PREVIEW = 1 << 3,
|
||||
GP_OPERATION_CONFIG = 1 << 4
|
||||
} CameraOperation;
|
||||
|
||||
/* File operations */
|
||||
typedef enum {
|
||||
GP_FILE_OPERATION_NONE = 0,
|
||||
GP_FILE_OPERATION_DELETE = 1 << 1,
|
||||
GP_FILE_OPERATION_CONFIG = 1 << 2,
|
||||
GP_FILE_OPERATION_PREVIEW = 1 << 3
|
||||
} CameraFileOperation;
|
||||
|
||||
/* Folder operations */
|
||||
typedef enum {
|
||||
GP_FOLDER_OPERATION_NONE = 0,
|
||||
GP_FOLDER_OPERATION_DELETE_ALL = 1 << 0,
|
||||
GP_FOLDER_OPERATION_PUT_FILE = 1 << 1,
|
||||
GP_FOLDER_OPERATION_CONFIG = 1 << 2
|
||||
} CameraFolderOperation;
|
||||
|
||||
/* Window prompt return values */
|
||||
typedef enum {
|
||||
GP_PROMPT_CANCEL = -1,
|
||||
GP_PROMPT_OK = 0
|
||||
} CameraPromptValue;
|
||||
|
||||
/* Confirm return values */
|
||||
typedef enum {
|
||||
GP_CONFIRM_YES,
|
||||
GP_CONFIRM_YESTOALL,
|
||||
GP_CONFIRM_NO,
|
||||
GP_CONFIRM_NOTOALL
|
||||
} CameraConfirmValue;
|
||||
|
||||
/* Structures
|
||||
---------------------------------------------------------------- */
|
||||
|
||||
/* Camera capture choice */
|
||||
typedef struct {
|
||||
int type;
|
||||
/* One of the GP_CAPTURE_* types */
|
||||
char name[128];
|
||||
/* A string describing this resolution/setting */
|
||||
|
||||
int duration;
|
||||
/* The duration of this capture event */
|
||||
/* Not needed in abilities */
|
||||
} CameraCaptureSetting;
|
||||
|
||||
struct Camera;
|
||||
|
||||
/* Port information/settings */
|
||||
#define CameraPortInfo gp_port_info
|
||||
|
||||
/* Functions supported by the cameras */
|
||||
|
||||
struct _CameraAbilities {
|
||||
char model[128];
|
||||
/* Name of the camera model */
|
||||
|
||||
int port;
|
||||
/* Supported transports for this camera. */
|
||||
/* This is an OR of 1 or more GP_PORT_* types. */
|
||||
|
||||
int speed[64];
|
||||
/* Supported serial baud rates, terminated with */
|
||||
/* a value of 0. */
|
||||
|
||||
CameraOperation operations;
|
||||
/* What operations the camera supports. This is */
|
||||
/* an OR of 1 or more GP_OPERATION_* types */
|
||||
|
||||
CameraFileOperation file_operations;
|
||||
/* What file operations the camera supports. */
|
||||
/* This is an OR of 1 or more */
|
||||
/* GP_FILE_OPERATION_* types */
|
||||
|
||||
CameraFolderOperation folder_operations;
|
||||
/* What folder operations the camera supports. */
|
||||
/* This is an OR of 1 or more */
|
||||
/* GP_FOLDER_OPERATION_* types */
|
||||
|
||||
int usb_vendor;
|
||||
int usb_product;
|
||||
/* Vendor and product id's for USB cameras */
|
||||
|
||||
/* Don't touch below. for core use */
|
||||
char library[1024];
|
||||
char id[64];
|
||||
|
||||
};
|
||||
|
||||
struct _CameraAbilitiesList {
|
||||
int count;
|
||||
CameraAbilities **abilities;
|
||||
};
|
||||
|
||||
/* Camera function pointers */
|
||||
typedef int (*c_id) (CameraText *);
|
||||
typedef int (*c_abilities) (CameraAbilitiesList *);
|
||||
typedef int (*c_init) (Camera*);
|
||||
typedef int (*c_exit) (Camera*);
|
||||
typedef int (*c_get_config) (Camera*, CameraWidget**);
|
||||
typedef int (*c_set_config) (Camera*, CameraWidget*);
|
||||
typedef int (*c_capture) (Camera*, int, CameraFilePath*);
|
||||
typedef int (*c_capture_preview) (Camera*, CameraFile*);
|
||||
typedef int (*c_summary) (Camera*, CameraText*);
|
||||
typedef int (*c_manual) (Camera*, CameraText*);
|
||||
typedef int (*c_about) (Camera*, CameraText*);
|
||||
|
||||
typedef int (*c_folder_list_folders) (Camera*, const char*, CameraList*);
|
||||
typedef int (*c_folder_list_files) (Camera*, const char*, CameraList*);
|
||||
typedef int (*c_folder_get_config) (Camera*, const char*, CameraWidget**);
|
||||
typedef int (*c_folder_set_config) (Camera*, const char*, CameraWidget*);
|
||||
typedef int (*c_folder_put_file) (Camera*, const char*, CameraFile*);
|
||||
typedef int (*c_folder_delete_all) (Camera*, const char*);
|
||||
|
||||
typedef int (*c_file_get_info) (Camera*, const char*,
|
||||
const char*, CameraFileInfo*);
|
||||
typedef int (*c_file_set_info) (Camera*, const char*,
|
||||
const char*, CameraFileInfo*);
|
||||
typedef int (*c_file_get_config) (Camera*, const char*,
|
||||
const char*, CameraWidget**);
|
||||
typedef int (*c_file_set_config) (Camera*, const char*,
|
||||
const char*, CameraWidget*);
|
||||
typedef int (*c_file_get) (Camera*, const char*,
|
||||
const char*, CameraFile*);
|
||||
typedef int (*c_file_get_preview) (Camera*, const char*,
|
||||
const char*, CameraFile*);
|
||||
typedef int (*c_file_delete) (Camera*, const char*, const char*);
|
||||
|
||||
typedef char *(*c_result_as_string) (Camera*, int);
|
||||
|
||||
/* Function pointers to the current library functions */
|
||||
typedef struct {
|
||||
c_id id;
|
||||
c_abilities abilities;
|
||||
c_init init;
|
||||
c_exit exit;
|
||||
c_get_config get_config;
|
||||
c_set_config set_config;
|
||||
c_capture capture;
|
||||
c_capture_preview capture_preview;
|
||||
c_summary summary;
|
||||
c_manual manual;
|
||||
c_about about;
|
||||
|
||||
c_folder_list_folders folder_list_folders;
|
||||
c_folder_list_files folder_list_files;
|
||||
c_folder_get_config folder_get_config;
|
||||
c_folder_set_config folder_set_config;
|
||||
c_folder_put_file folder_put_file;
|
||||
c_folder_delete_all folder_delete_all;
|
||||
|
||||
c_file_get_info file_get_info;
|
||||
c_file_set_info file_set_info;
|
||||
c_file_get_config file_get_config;
|
||||
c_file_set_config file_set_config;
|
||||
c_file_get_preview file_get_preview;
|
||||
c_file_get file_get;
|
||||
c_file_delete file_delete;
|
||||
|
||||
c_result_as_string result_as_string;
|
||||
} CameraFunctions;
|
||||
|
||||
struct _Camera {
|
||||
char model[128];
|
||||
|
||||
CameraPortInfo *port;
|
||||
|
||||
int ref_count;
|
||||
|
||||
void *library_handle;
|
||||
|
||||
CameraAbilities *abilities;
|
||||
CameraFunctions *functions;
|
||||
|
||||
void *camlib_data;
|
||||
void *frontend_data;
|
||||
|
||||
int session;
|
||||
};
|
||||
|
||||
|
||||
/* Function Pointers
|
||||
---------------------------------------------------------------- */
|
||||
|
||||
typedef int (*CameraStatus) (Camera*, char*);
|
||||
typedef int (*CameraMessage) (Camera*, char*);
|
||||
typedef int (*CameraConfirm) (Camera*, char*);
|
||||
typedef int (*CameraProgress) (Camera*, CameraFile*, float);
|
||||
typedef int (*CameraPrompt) (Camera*, CameraWidget*);
|
||||
@@ -20,10 +20,10 @@
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#ifndef __GPHOTO2_FILESYSTEM_H__
|
||||
#define __GPHOTO2_FILESYSTEM_H__
|
||||
#ifndef __GPHOTO2_FILESYS_H__
|
||||
#define __GPHOTO2_FILESYS_H__
|
||||
|
||||
#include <gphoto2-lists.h>
|
||||
#include <gphoto2-list.h>
|
||||
|
||||
/* You don't really want to know what's inside, do you? */
|
||||
typedef struct _CameraFilesystem CameraFilesystem;
|
||||
@@ -54,4 +54,4 @@ int gp_filesystem_list_folders (CameraFilesystem *fs, const char *folder,
|
||||
CameraList *list);
|
||||
int gp_filesystem_dump (CameraFilesystem *fs);
|
||||
|
||||
#endif /* __GPHOTO2_FILESYSTEM_H__ */
|
||||
#endif /* __GPHOTO2_FILESYS_H__ */
|
||||
|
||||
@@ -1,12 +1,56 @@
|
||||
/* Header file for gPhoto2
|
||||
/* gphoto2-frontend.h
|
||||
*
|
||||
* Copyright (C) 2000 Scott Fritzinger
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the
|
||||
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
Author: Scott Fritzinger <scottf@unr.edu>
|
||||
#ifndef __GPHOTO2_FRONTEND_H__
|
||||
#define __GPHOTO2_FRONTEND_H__
|
||||
|
||||
This library is covered by the LGPL.
|
||||
*/
|
||||
#include <gphoto2-camera.h>
|
||||
#include <gphoto2-file.h>
|
||||
#include <gphoto2-widget.h>
|
||||
|
||||
typedef enum {
|
||||
GP_CONFIRM_YES,
|
||||
GP_CONFIRM_YESTOALL,
|
||||
GP_CONFIRM_NO,
|
||||
GP_CONFIRM_NOTOALL
|
||||
} CameraConfirmValue;
|
||||
|
||||
typedef enum {
|
||||
GP_PROMPT_CANCEL = -1,
|
||||
GP_PROMPT_OK = 0
|
||||
} CameraPromptValue;
|
||||
|
||||
typedef int (* CameraStatus) (Camera *, char *);
|
||||
typedef int (* CameraMessage) (Camera *, char *);
|
||||
typedef int (* CameraConfirm) (Camera *, char *);
|
||||
typedef int (* CameraProgress) (Camera *, CameraFile *, float);
|
||||
typedef int (* CameraPrompt) (Camera *, CameraWidget *);
|
||||
|
||||
int gp_frontend_register (CameraStatus status, CameraProgress progress,
|
||||
CameraMessage message, CameraConfirm confirm,
|
||||
CameraPrompt prompt);
|
||||
|
||||
int gp_frontend_status (Camera *camera, char *status);
|
||||
int gp_frontend_message (Camera *camera, char *message);
|
||||
int gp_frontend_confirm (Camera *camera, char *message);
|
||||
int gp_frontend_progress (Camera *camera, CameraFile *file, float percentage);
|
||||
int gp_frontend_progress (Camera *camera, CameraFile *file, float percentage);
|
||||
int gp_frontend_prompt (Camera *camera, CameraWidget *window);
|
||||
|
||||
#endif /* __GPHOTO2_FRONTEND_H__ */
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* gphoto2-lists.h: Lists of files, folders, cameras, abilities, etc.
|
||||
/* gphoto2-list.h: Lists of files, folders, cameras, etc.
|
||||
*
|
||||
* Copyright (C) 2001 Scott Fritzinger
|
||||
*
|
||||
@@ -18,8 +18,8 @@
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#ifndef __GPHOTO2_LISTS_H__
|
||||
#define __GPHOTO2_LISTS_H__
|
||||
#ifndef __GPHOTO2_LIST_H__
|
||||
#define __GPHOTO2_LIST_H__
|
||||
|
||||
typedef struct {
|
||||
char name [128];
|
||||
@@ -37,19 +37,4 @@ int gp_list_count (CameraList *list);
|
||||
int gp_list_append (CameraList *list, char *name);
|
||||
CameraListEntry* gp_list_entry (CameraList *list, int entry_number);
|
||||
|
||||
|
||||
typedef struct _CameraAbilities CameraAbilities;
|
||||
|
||||
CameraAbilities* gp_abilities_new (void);
|
||||
int gp_abilities_free (CameraAbilities *abilities);
|
||||
|
||||
|
||||
typedef struct _CameraAbilitiesList CameraAbilitiesList;
|
||||
|
||||
CameraAbilitiesList* gp_abilities_list_new (void);
|
||||
int gp_abilities_list_free (CameraAbilitiesList *list);
|
||||
int gp_abilities_list_dump (CameraAbilitiesList *list);
|
||||
int gp_abilities_list_append (CameraAbilitiesList *list,
|
||||
CameraAbilities *abilities);
|
||||
|
||||
#endif /* __GPHOTO2_LISTS_H__ */
|
||||
#endif /* __GPHOTO2_LIST_H__ */
|
||||
41
include/gphoto2-result.h
Normal file
41
include/gphoto2-result.h
Normal file
@@ -0,0 +1,41 @@
|
||||
/* gphoto2-result.h
|
||||
*
|
||||
* Copyright (C) 2000 Scott Fritzinger
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the
|
||||
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#ifndef __GPHOTO2_RESULT_H__
|
||||
#define __GPHOTO2_RESULT_H__
|
||||
|
||||
/* Additional error codes are defined here */
|
||||
#include <gphoto2-port.h>
|
||||
|
||||
#define GP_ERROR_BAD_PARAMETERS -100 /* for checking function-param. */
|
||||
#define GP_ERROR_IO -101 /* IO problem */
|
||||
#define GP_ERROR_CORRUPTED_DATA -102 /* Corrupted data */
|
||||
#define GP_ERROR_FILE_EXISTS -103 /* File exists */
|
||||
#define GP_ERROR_NO_MEMORY -104 /* Insufficient memory */
|
||||
#define GP_ERROR_MODEL_NOT_FOUND -105 /* Model not found */
|
||||
#define GP_ERROR_NOT_SUPPORTED -106 /* Some op. is unsupported */
|
||||
#define GP_ERROR_DIRECTORY_NOT_FOUND -107 /* Directory not found */
|
||||
#define GP_ERROR_FILE_NOT_FOUND -108 /* File not found */
|
||||
#define GP_ERROR_DIRECTORY_EXISTS -109 /* Directory exists */
|
||||
#define GP_ERROR_NO_CAMERA_FOUND -110 /* No cameras auto-detected */
|
||||
|
||||
char *gp_result_as_string (int result);
|
||||
|
||||
#endif /* __GPHOTO2_RESULT_H__ */
|
||||
29
include/gphoto2-setting.h
Normal file
29
include/gphoto2-setting.h
Normal file
@@ -0,0 +1,29 @@
|
||||
/* gphoto2-setting.h
|
||||
*
|
||||
* Copyright (C) 2000 Scott Fritzinger
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the
|
||||
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#ifndef __GPHOTO2_SETTING_H__
|
||||
#define __GPHOTO2_SETTING_H__
|
||||
|
||||
int load_settings (void);
|
||||
|
||||
int gp_setting_set (char *id, char *key, char *value);
|
||||
int gp_setting_get (char *id, char *key, char *value);
|
||||
|
||||
#endif /* __GPHOTO2_SETTING_H__ */
|
||||
@@ -1,2 +0,0 @@
|
||||
int gp_setting_set (char *id, char *key, char *value);
|
||||
int gp_setting_get (char *id, char *key, char *value);
|
||||
@@ -21,15 +21,14 @@ extern "C" {
|
||||
#endif
|
||||
|
||||
#include <gphoto2-port.h>
|
||||
#include <gphoto2-datatypes.h>
|
||||
#include <gphoto2-camera.h>
|
||||
#include <gphoto2-core.h>
|
||||
#include <gphoto2-file.h>
|
||||
#include <gphoto2-filesys.h>
|
||||
#include <gphoto2-frontend.h>
|
||||
#include <gphoto2-library.h>
|
||||
#include <gphoto2-lists.h>
|
||||
#include <gphoto2-settings.h>
|
||||
#include <gphoto2-list.h>
|
||||
#include <gphoto2-setting.h>
|
||||
#include <gphoto2-widget.h>
|
||||
|
||||
|
||||
|
||||
@@ -6,19 +6,18 @@ CFLAGS= @CFLAGS@ \
|
||||
-DDOCDIR=\"$(prefix)/doc/gphoto2\"
|
||||
|
||||
libgphoto2_la_LDFLAGS = -version-info 0:0:0
|
||||
libgphoto2_la_SOURCES = \
|
||||
camera.c \
|
||||
core.c core.h \
|
||||
exif.c exif.h \
|
||||
file.c \
|
||||
filesys.c \
|
||||
frontend.c \
|
||||
globals.h \
|
||||
library.c library.h \
|
||||
lists.c \
|
||||
port.c \
|
||||
settings.c settings.h \
|
||||
util.c util.h \
|
||||
libgphoto2_la_SOURCES = \
|
||||
abilities.c \
|
||||
abilities-list.c \
|
||||
camera.c \
|
||||
core.c \
|
||||
exif.c exif.h \
|
||||
file.c \
|
||||
filesys.c \
|
||||
frontend.c \
|
||||
list.c \
|
||||
result.c \
|
||||
setting.c \
|
||||
widget.c
|
||||
|
||||
pkgconfigdir = $(libdir)/pkgconfig
|
||||
|
||||
83
libgphoto2/abilities-list.c
Normal file
83
libgphoto2/abilities-list.c
Normal file
@@ -0,0 +1,83 @@
|
||||
/* abilities-list.c
|
||||
*
|
||||
* Copyright (C) 2000 Scott Fritzinger
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the
|
||||
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#include "gphoto2-abilities-list.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "gphoto2-core.h"
|
||||
#include "gphoto2-result.h"
|
||||
|
||||
CameraAbilitiesList *gp_abilities_list_new ()
|
||||
{
|
||||
CameraAbilitiesList *list;
|
||||
|
||||
list = malloc (sizeof (CameraAbilitiesList));
|
||||
if (!list)
|
||||
return (NULL);
|
||||
|
||||
list->count = 0;
|
||||
list->abilities = NULL;
|
||||
|
||||
return (list);
|
||||
}
|
||||
|
||||
int gp_abilities_list_free (CameraAbilitiesList *list)
|
||||
{
|
||||
int x;
|
||||
|
||||
/* TODO: OS/2 Port crashes here... maybe compiler setting */
|
||||
|
||||
for (x = 0; x < list->count; x++)
|
||||
free (list->abilities [x]);
|
||||
free (list);
|
||||
|
||||
return (GP_OK);
|
||||
}
|
||||
|
||||
int gp_abilities_list_dump (CameraAbilitiesList *list)
|
||||
{
|
||||
int x;
|
||||
|
||||
for (x = 0; x < list->count; x++) {
|
||||
gp_debug_printf (GP_DEBUG_LOW, "core", "Camera #%i:", x);
|
||||
gp_abilities_dump (list->abilities[x]);
|
||||
}
|
||||
|
||||
return (GP_OK);
|
||||
}
|
||||
|
||||
int gp_abilities_list_append (CameraAbilitiesList *list,
|
||||
CameraAbilities *abilities)
|
||||
{
|
||||
if (!list->abilities)
|
||||
list->abilities = malloc (sizeof (CameraAbilities*));
|
||||
else
|
||||
list->abilities = realloc (list->abilities,
|
||||
sizeof (CameraAbilities*) * (list->count + 1));
|
||||
|
||||
if (!list->abilities)
|
||||
return (GP_ERROR_NO_MEMORY);
|
||||
|
||||
list->abilities [list->count] = abilities;
|
||||
list->count++;
|
||||
|
||||
return (GP_OK);
|
||||
}
|
||||
@@ -1,12 +1,54 @@
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
/* abilities.c
|
||||
*
|
||||
* Copyright (C) 2000 Scott Fritzinger
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the
|
||||
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#include "gphoto2-abilities.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <gphoto2.h>
|
||||
|
||||
#include "util.h"
|
||||
#include "gphoto2-result.h"
|
||||
#include "gphoto2-core.h"
|
||||
|
||||
int gp_abilities_dump (CameraAbilities *abilities) {
|
||||
CameraAbilities *
|
||||
gp_abilities_new (void)
|
||||
{
|
||||
CameraAbilities *abilities;
|
||||
|
||||
abilities = malloc (sizeof (CameraAbilities));
|
||||
if (!abilities)
|
||||
return (NULL);
|
||||
|
||||
return (abilities);
|
||||
}
|
||||
|
||||
int
|
||||
gp_abilities_free (CameraAbilities *abilities)
|
||||
{
|
||||
if (!abilities)
|
||||
return (GP_ERROR_BAD_PARAMETERS);
|
||||
|
||||
free (abilities);
|
||||
return (GP_OK);
|
||||
}
|
||||
|
||||
int gp_abilities_dump (CameraAbilities *abilities)
|
||||
{
|
||||
int x=0;
|
||||
|
||||
gp_debug_printf(GP_DEBUG_LOW, "core", "Abilities for camera : %s",
|
||||
@@ -51,10 +93,10 @@ int gp_abilities_dump (CameraAbilities *abilities) {
|
||||
return (GP_OK);
|
||||
}
|
||||
|
||||
int gp_abilities_clear (CameraAbilities *abilities) {
|
||||
|
||||
int gp_abilities_clear (CameraAbilities *abilities)
|
||||
{
|
||||
strcpy(abilities->model, "");
|
||||
abilities->port = 0;
|
||||
abilities->port = GP_PORT_NONE;
|
||||
abilities->speed[0] = 0;
|
||||
abilities->operations = GP_OPERATION_NONE;
|
||||
abilities->file_operations = GP_FILE_OPERATION_NONE;
|
||||
@@ -1,11 +1,33 @@
|
||||
/* camera.c
|
||||
*
|
||||
* Copyright (C) 2000 Scott Fritzinger
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the
|
||||
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#include "gphoto2-camera.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <gphoto2.h>
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "gphoto2-result.h"
|
||||
#include "gphoto2-frontend.h"
|
||||
#include "gphoto2-core.h"
|
||||
|
||||
#include <config.h>
|
||||
#endif
|
||||
|
||||
#ifdef ENABLE_NLS
|
||||
# include <libintl.h>
|
||||
# undef _
|
||||
@@ -20,61 +42,14 @@
|
||||
# define N_(String) (String)
|
||||
#endif
|
||||
|
||||
#include "globals.h"
|
||||
#include "library.h"
|
||||
#include "settings.h"
|
||||
#include "util.h"
|
||||
static int glob_session_camera = 0;
|
||||
|
||||
int gp_camera_exit (Camera *camera);
|
||||
|
||||
int gp_camera_count ()
|
||||
{
|
||||
return (glob_abilities_list->count);
|
||||
}
|
||||
|
||||
int gp_camera_name (int camera_number, char *camera_name)
|
||||
{
|
||||
if (glob_abilities_list == NULL)
|
||||
return (GP_ERROR_MODEL_NOT_FOUND);
|
||||
|
||||
if (camera_number > glob_abilities_list->count)
|
||||
return (GP_ERROR_MODEL_NOT_FOUND);
|
||||
|
||||
strcpy (camera_name,
|
||||
glob_abilities_list->abilities[camera_number]->model);
|
||||
return (GP_OK);
|
||||
}
|
||||
|
||||
int gp_camera_abilities (int camera_number, CameraAbilities *abilities)
|
||||
{
|
||||
memcpy (abilities, glob_abilities_list->abilities[camera_number],
|
||||
sizeof(CameraAbilities));
|
||||
|
||||
if (glob_debug)
|
||||
gp_abilities_dump (abilities);
|
||||
|
||||
return (GP_OK);
|
||||
}
|
||||
|
||||
|
||||
int gp_camera_abilities_by_name (char *camera_name, CameraAbilities *abilities)
|
||||
{
|
||||
|
||||
int x;
|
||||
|
||||
for (x = 0; x < glob_abilities_list->count; x++) {
|
||||
if (strcmp (glob_abilities_list->abilities[x]->model,
|
||||
camera_name) == 0)
|
||||
return (gp_camera_abilities(x, abilities));
|
||||
}
|
||||
|
||||
return (GP_ERROR_MODEL_NOT_FOUND);
|
||||
}
|
||||
|
||||
int gp_camera_new (Camera **camera)
|
||||
{
|
||||
|
||||
*camera = (Camera*)malloc(sizeof(Camera));
|
||||
*camera = malloc (sizeof (Camera));
|
||||
if (!*camera)
|
||||
return (GP_ERROR_NO_MEMORY);
|
||||
|
||||
@@ -246,27 +221,24 @@ int gp_camera_init (Camera *camera)
|
||||
}
|
||||
|
||||
/* Fill in camera abilities. */
|
||||
gp_debug_printf (GP_DEBUG_LOW, "core",
|
||||
"Looking up abilities for model %s...", camera->model);
|
||||
for (x = 0; x < glob_abilities_list->count; x++) {
|
||||
if (strcmp (glob_abilities_list->abilities[x]->model,
|
||||
camera->model) == 0)
|
||||
break;
|
||||
}
|
||||
if (x == glob_abilities_list->count)
|
||||
return GP_ERROR_MODEL_NOT_FOUND;
|
||||
camera->abilities->file_operations =
|
||||
glob_abilities_list->abilities[x]->file_operations;
|
||||
camera->abilities->folder_operations =
|
||||
glob_abilities_list->abilities[x]->folder_operations;
|
||||
camera->abilities->operations =
|
||||
glob_abilities_list->abilities[x]->operations;
|
||||
result = gp_camera_abilities_by_name (camera->model, camera->abilities);
|
||||
if (result != GP_OK)
|
||||
return (result);
|
||||
|
||||
/* Load the library. */
|
||||
gp_debug_printf (GP_DEBUG_LOW, "core", "Loading library %s...",
|
||||
glob_abilities_list->abilities[x]->library);
|
||||
if ((result = load_library(camera)) != GP_OK)
|
||||
return (result);
|
||||
gp_debug_printf (GP_DEBUG_LOW, "core", "Loading library...");
|
||||
camera->library_handle = GP_SYSTEM_DLOPEN (camera->abilities->library);
|
||||
if (!camera->library_handle) {
|
||||
gp_camera_free (camera);
|
||||
return (GP_ERROR);
|
||||
}
|
||||
|
||||
camera->functions->id = GP_SYSTEM_DLSYM (camera->library_handle,
|
||||
"camera_id");
|
||||
camera->functions->abilities = GP_SYSTEM_DLSYM (camera->library_handle,
|
||||
"camera_abilities");
|
||||
camera->functions->init = GP_SYSTEM_DLSYM (camera->library_handle,
|
||||
"camera_init");
|
||||
|
||||
return (camera->functions->init (camera));
|
||||
}
|
||||
@@ -384,7 +356,8 @@ int gp_camera_exit (Camera *camera)
|
||||
return (GP_ERROR_NOT_SUPPORTED);
|
||||
|
||||
ret = camera->functions->exit (camera);
|
||||
close_library (camera);
|
||||
|
||||
GP_SYSTEM_DLCLOSE (camera->library_handle);
|
||||
|
||||
return (ret);
|
||||
}
|
||||
|
||||
@@ -1,31 +1,34 @@
|
||||
/* core.c
|
||||
*
|
||||
* Copyright (C) 2000 Scott Fritzinger
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the
|
||||
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#include "gphoto2-core.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdarg.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include <gphoto2.h>
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include <config.h>
|
||||
#endif
|
||||
|
||||
#ifdef ENABLE_NLS
|
||||
# include <libintl.h>
|
||||
# undef _
|
||||
# define _(String) dgettext (PACKAGE, String)
|
||||
# ifdef gettext_noop
|
||||
# define N_(String) gettext_noop (String)
|
||||
# else
|
||||
# define N_(String) (String)
|
||||
# endif
|
||||
#else
|
||||
# define _(String) (String)
|
||||
# define N_(String) (String)
|
||||
#endif
|
||||
|
||||
#include "core.h"
|
||||
#include "library.h"
|
||||
#include "settings.h"
|
||||
#include "util.h"
|
||||
#include <gphoto2-abilities.h>
|
||||
#include <gphoto2-setting.h>
|
||||
#include <gphoto2-result.h>
|
||||
#include <gphoto2-abilities-list.h>
|
||||
#include <gphoto2-camera.h>
|
||||
|
||||
/* Debug level */
|
||||
int glob_debug = 0;
|
||||
@@ -33,37 +36,137 @@ int glob_debug = 0;
|
||||
/* Camera List */
|
||||
CameraAbilitiesList *glob_abilities_list;
|
||||
|
||||
/* Currently loaded settings */
|
||||
int glob_setting_count = 0;
|
||||
Setting glob_setting[512];
|
||||
|
||||
/* Sessions */
|
||||
int glob_session_camera = 0;
|
||||
int glob_session_file = 0;
|
||||
|
||||
/* Front-end function pointers */
|
||||
CameraStatus gp_fe_status = NULL;
|
||||
CameraProgress gp_fe_progress = NULL;
|
||||
CameraMessage gp_fe_message = NULL;
|
||||
CameraConfirm gp_fe_confirm = NULL;
|
||||
CameraPrompt gp_fe_prompt = NULL;
|
||||
|
||||
static char *result_string[] = {
|
||||
/* GP_ERROR_BAD_PARAMETERS -100 */ N_("Bad parameters"),
|
||||
/* GP_ERROR_IO -101 */ N_("I/O problem"),
|
||||
/* GP_ERROR_CORRUPTED_DATA -102 */ N_("Corrupted data"),
|
||||
/* GP_ERROR_FILE_EXISTS -103 */ N_("File exists"),
|
||||
/* GP_ERROR_NO_MEMORY -104 */ N_("Insufficient memory"),
|
||||
/* GP_ERROR_MODEL_NOT_FOUND -105 */ N_("Unknown model"),
|
||||
/* GP_ERROR_NOT_SUPPORTED -106 */ N_("Unsupported operation"),
|
||||
/* GP_ERROR_DIRECTORY_NOT_FOUND -107 */ N_("Directory not found"),
|
||||
/* GP_ERROR_FILE_NOT_FOUND -108 */ N_("File not found"),
|
||||
/* GP_ERROR_DIRECTORY_EXISTS -109 */ N_("Directory exists"),
|
||||
/* GP_ERROR_NO_CAMERA_FOUND -110 */ N_("No cameras were detected")
|
||||
};
|
||||
|
||||
static int have_initted = 0;
|
||||
|
||||
int is_library(char *library_filename)
|
||||
{
|
||||
int ret = GP_OK;
|
||||
void *lh;
|
||||
c_id id;
|
||||
|
||||
if ((lh = GP_SYSTEM_DLOPEN(library_filename)) == NULL)
|
||||
return (GP_ERROR);
|
||||
id = (c_id)GP_SYSTEM_DLSYM(lh, "camera_id");
|
||||
if (!id)
|
||||
ret = GP_ERROR;
|
||||
GP_SYSTEM_DLCLOSE(lh);
|
||||
|
||||
return (ret);
|
||||
}
|
||||
|
||||
/* Returns the number of cameras added to the CameraChoice list */
|
||||
/* 0 implies an error occurred */
|
||||
int load_camera_list(char *library_filename)
|
||||
{
|
||||
CameraText id;
|
||||
void *lh;
|
||||
c_abilities load_camera_abilities;
|
||||
c_id load_camera_id;
|
||||
int x, old_count;
|
||||
|
||||
/* try to open the library */
|
||||
if ((lh = GP_SYSTEM_DLOPEN(library_filename))==NULL) {
|
||||
if (glob_debug)
|
||||
perror("core:\tload_camera_list");
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* check to see if this library has been loaded */
|
||||
load_camera_id = (c_id)GP_SYSTEM_DLSYM(lh, "camera_id");
|
||||
load_camera_id(&id);
|
||||
gp_debug_printf(GP_DEBUG_LOW, "core", "\t library id: %s", id.text);
|
||||
|
||||
for (x=0; x<glob_abilities_list->count; x++) {
|
||||
if (strcmp(glob_abilities_list->abilities[x]->id, id.text)==0) {
|
||||
GP_SYSTEM_DLCLOSE(lh);
|
||||
return (GP_ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
/* load in the camera_abilities function */
|
||||
load_camera_abilities = (c_abilities)GP_SYSTEM_DLSYM(lh, "camera_abilities");
|
||||
old_count = glob_abilities_list->count;
|
||||
|
||||
if (load_camera_abilities(glob_abilities_list) != GP_OK) {
|
||||
GP_SYSTEM_DLCLOSE(lh);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Copy in the core-specific information */
|
||||
for (x=old_count; x<glob_abilities_list->count; x++) {
|
||||
strcpy(glob_abilities_list->abilities[x]->id, id.text);
|
||||
strcpy(glob_abilities_list->abilities[x]->library, library_filename);
|
||||
}
|
||||
|
||||
GP_SYSTEM_DLCLOSE(lh);
|
||||
|
||||
return x;
|
||||
}
|
||||
|
||||
int load_cameras_search(char *directory)
|
||||
{
|
||||
GP_SYSTEM_DIR d;
|
||||
GP_SYSTEM_DIRENT de;
|
||||
char buf[1024];
|
||||
|
||||
gp_debug_printf(GP_DEBUG_LOW, "core","Trying to load camera libraries in:");
|
||||
gp_debug_printf(GP_DEBUG_LOW, "core","\t%s", directory);
|
||||
|
||||
/* Look for available camera libraries */
|
||||
d = GP_SYSTEM_OPENDIR(directory);
|
||||
if (!d) {
|
||||
gp_debug_printf(GP_DEBUG_LOW, "core", "couldn't open %s", directory);
|
||||
return GP_ERROR_DIRECTORY_NOT_FOUND;
|
||||
}
|
||||
|
||||
do {
|
||||
/* Read each entry */
|
||||
de = GP_SYSTEM_READDIR(d);
|
||||
if (de) {
|
||||
sprintf(buf, "%s%c%s", directory, GP_SYSTEM_DIR_DELIM, GP_SYSTEM_FILENAME(de));
|
||||
gp_debug_printf(GP_DEBUG_LOW, "core", "\tis %s a library? ", buf);
|
||||
/* try to open the library */
|
||||
if (is_library(buf) == GP_OK) {
|
||||
gp_debug_printf(GP_DEBUG_LOW, "core", "yes");
|
||||
load_camera_list(buf);
|
||||
} else {
|
||||
gp_debug_printf(GP_DEBUG_LOW, "core", "no. reason: %s", GP_SYSTEM_DLERROR());
|
||||
}
|
||||
}
|
||||
} while (de);
|
||||
|
||||
return (GP_OK);
|
||||
}
|
||||
|
||||
int load_cameras() {
|
||||
|
||||
int x, y, z;
|
||||
CameraAbilities *t;
|
||||
|
||||
/* Where should we search for camera libraries? */
|
||||
|
||||
/* The installed camera library directory */
|
||||
load_cameras_search(CAMLIBS);
|
||||
|
||||
/* Current directory */
|
||||
/* load_cameras_search("."); */
|
||||
|
||||
/* Sort the camera list */
|
||||
for (x=0; x<glob_abilities_list->count-1; x++) {
|
||||
for (y=x+1; y<glob_abilities_list->count; y++) {
|
||||
z = strcmp(glob_abilities_list->abilities[x]->model,
|
||||
glob_abilities_list->abilities[y]->model);
|
||||
if (z > 0) {
|
||||
t = glob_abilities_list->abilities[x];
|
||||
glob_abilities_list->abilities[x] = glob_abilities_list->abilities[y];
|
||||
glob_abilities_list->abilities[y] = t;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return GP_OK;
|
||||
}
|
||||
|
||||
int gp_init (int debug)
|
||||
{
|
||||
char buf[1024];
|
||||
@@ -79,7 +182,6 @@ int gp_init (int debug)
|
||||
|
||||
/* Initialize the globals */
|
||||
glob_abilities_list = gp_abilities_list_new();
|
||||
glob_setting_count = 0;
|
||||
|
||||
/* Make sure the directories are created */
|
||||
gp_debug_printf (GP_DEBUG_LOW, "core", "Creating $HOME/.gphoto");
|
||||
@@ -176,38 +278,44 @@ void gp_debug_printf (int level, char *id, char *format, ...)
|
||||
}
|
||||
}
|
||||
|
||||
int gp_frontend_register (CameraStatus status, CameraProgress progress,
|
||||
CameraMessage message, CameraConfirm confirm,
|
||||
CameraPrompt prompt)
|
||||
int gp_camera_count ()
|
||||
{
|
||||
gp_fe_status = status;
|
||||
gp_fe_progress = progress;
|
||||
gp_fe_message = message;
|
||||
gp_fe_confirm = confirm;
|
||||
gp_fe_prompt = prompt;
|
||||
|
||||
return (GP_OK);
|
||||
return (glob_abilities_list->count);
|
||||
}
|
||||
|
||||
char *gp_result_as_string (int result)
|
||||
int gp_camera_name (int camera_number, char *camera_name)
|
||||
{
|
||||
/* Really an error? */
|
||||
if (result > 0)
|
||||
return _("Unknown error");
|
||||
if (glob_abilities_list == NULL)
|
||||
return (GP_ERROR_MODEL_NOT_FOUND);
|
||||
|
||||
/* IOlib error? Pass through. */
|
||||
if ((result <= 0) && (result >= -99))
|
||||
return gp_port_result_as_string(result);
|
||||
if (camera_number > glob_abilities_list->count)
|
||||
return (GP_ERROR_MODEL_NOT_FOUND);
|
||||
|
||||
/* Camlib error? You should have called gp_camera_result_as_string... */
|
||||
if (result <= -1000)
|
||||
return _("Unknown camera library error");
|
||||
|
||||
/* Do we have an error description? */
|
||||
if ((-result - 100) < (int) (sizeof (result_string) /
|
||||
sizeof (*result_string)))
|
||||
return _(result_string[-result - 100]);
|
||||
|
||||
return _("Unknown error");
|
||||
strcpy (camera_name,
|
||||
glob_abilities_list->abilities[camera_number]->model);
|
||||
return (GP_OK);
|
||||
}
|
||||
|
||||
int gp_camera_abilities (int camera_number, CameraAbilities *abilities)
|
||||
{
|
||||
memcpy (abilities, glob_abilities_list->abilities[camera_number],
|
||||
sizeof(CameraAbilities));
|
||||
|
||||
if (glob_debug)
|
||||
gp_abilities_dump (abilities);
|
||||
|
||||
return (GP_OK);
|
||||
}
|
||||
|
||||
int gp_camera_abilities_by_name (char *camera_name, CameraAbilities *abilities)
|
||||
{
|
||||
int x;
|
||||
|
||||
for (x = 0; x < glob_abilities_list->count; x++) {
|
||||
if (strcmp (glob_abilities_list->abilities[x]->model,
|
||||
camera_name) == 0)
|
||||
return (gp_camera_abilities(x, abilities));
|
||||
}
|
||||
|
||||
return (GP_ERROR_MODEL_NOT_FOUND);
|
||||
}
|
||||
|
||||
@@ -1,42 +1,65 @@
|
||||
/* file.c
|
||||
*
|
||||
* Copyright (C) 2000 Scott Fritzinger
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the
|
||||
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#include "gphoto2-file.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <gphoto2.h>
|
||||
|
||||
#include "globals.h"
|
||||
#include "gphoto2-result.h"
|
||||
|
||||
CameraFile* gp_file_new () {
|
||||
static int glob_session_file = 0;
|
||||
|
||||
CameraFile* gp_file_new ()
|
||||
{
|
||||
CameraFile *file;
|
||||
|
||||
file = (CameraFile*)malloc(sizeof(CameraFile));
|
||||
strcpy(file->type, "unknown/unknown");
|
||||
strcpy(file->name, "");
|
||||
file = malloc (sizeof (CameraFile));
|
||||
strcpy (file->type, "unknown/unknown");
|
||||
strcpy (file->name, "");
|
||||
file->data = NULL;
|
||||
file->size = 0;
|
||||
file->bytes_read = 0;
|
||||
file->session = glob_session_file++;
|
||||
file->ref_count = 1;
|
||||
|
||||
return(file);
|
||||
return (file);
|
||||
}
|
||||
|
||||
int gp_file_free (CameraFile *file) {
|
||||
|
||||
gp_file_clean(file);
|
||||
free(file);
|
||||
return(GP_OK);
|
||||
int gp_file_free (CameraFile *file)
|
||||
{
|
||||
gp_file_clean (file);
|
||||
free (file);
|
||||
return (GP_OK);
|
||||
}
|
||||
|
||||
int gp_file_ref (CameraFile *file) {
|
||||
|
||||
int gp_file_ref (CameraFile *file)
|
||||
{
|
||||
file->ref_count += 1;
|
||||
|
||||
return (GP_OK);
|
||||
}
|
||||
|
||||
int gp_file_unref (CameraFile *file) {
|
||||
|
||||
int gp_file_unref (CameraFile *file)
|
||||
{
|
||||
if (file == NULL)
|
||||
return GP_ERROR_BAD_PARAMETERS;
|
||||
|
||||
@@ -48,13 +71,13 @@ int gp_file_unref (CameraFile *file) {
|
||||
return (GP_OK);
|
||||
}
|
||||
|
||||
int gp_file_session (CameraFile *file) {
|
||||
|
||||
int gp_file_session (CameraFile *file)
|
||||
{
|
||||
return (file->session);
|
||||
}
|
||||
|
||||
int gp_file_append (CameraFile *file, char *data, int size) {
|
||||
|
||||
int gp_file_append (CameraFile *file, char *data, int size)
|
||||
{
|
||||
char *t;
|
||||
|
||||
if (size < 0)
|
||||
@@ -76,8 +99,8 @@ int gp_file_append (CameraFile *file, char *data, int size) {
|
||||
return (GP_OK);
|
||||
}
|
||||
|
||||
int gp_file_get_last_chunk (CameraFile *file, char **data, int *size) {
|
||||
|
||||
int gp_file_get_last_chunk (CameraFile *file, char **data, int *size)
|
||||
{
|
||||
if (file->bytes_read == 0) {
|
||||
/* chunk_add was never called. return safely. */
|
||||
*data = NULL;
|
||||
@@ -93,8 +116,8 @@ int gp_file_get_last_chunk (CameraFile *file, char **data, int *size) {
|
||||
return (GP_OK);
|
||||
}
|
||||
|
||||
int gp_file_save (CameraFile *file, char *filename) {
|
||||
|
||||
int gp_file_save (CameraFile *file, char *filename)
|
||||
{
|
||||
FILE *fp;
|
||||
|
||||
if ((fp = fopen(filename, "wb"))==NULL)
|
||||
@@ -181,12 +204,12 @@ int gp_file_open (CameraFile *file, char *filename) {
|
||||
return (GP_OK);
|
||||
}
|
||||
|
||||
int gp_file_clean (CameraFile *file) {
|
||||
|
||||
/*
|
||||
frees a CameraFile's components, not the CameraFile itself.
|
||||
this is used to prep a CameraFile struct to be filled.
|
||||
*/
|
||||
int gp_file_clean (CameraFile *file)
|
||||
{
|
||||
/*
|
||||
* Frees a CameraFile's components, not the CameraFile itself.
|
||||
* This is used to prep a CameraFile struct to be filled.
|
||||
*/
|
||||
if (file->data != NULL)
|
||||
free(file->data);
|
||||
strcpy(file->name, "");
|
||||
|
||||
@@ -1,13 +1,46 @@
|
||||
#include <gphoto2.h>
|
||||
/* frontend.c
|
||||
*
|
||||
* Copyright (C) 2000 Scott Fritzinger
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the
|
||||
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include <config.h>
|
||||
#endif
|
||||
#include "gphoto2-frontend.h"
|
||||
|
||||
#include "globals.h"
|
||||
#include "library.h"
|
||||
#include "settings.h"
|
||||
#include "util.h"
|
||||
#include "gphoto2-result.h"
|
||||
|
||||
/* Front-end function pointers */
|
||||
CameraStatus gp_fe_status = NULL;
|
||||
CameraProgress gp_fe_progress = NULL;
|
||||
CameraMessage gp_fe_message = NULL;
|
||||
CameraConfirm gp_fe_confirm = NULL;
|
||||
CameraPrompt gp_fe_prompt = NULL;
|
||||
|
||||
int gp_frontend_register (CameraStatus status, CameraProgress progress,
|
||||
CameraMessage message, CameraConfirm confirm,
|
||||
CameraPrompt prompt)
|
||||
{
|
||||
gp_fe_status = status;
|
||||
gp_fe_progress = progress;
|
||||
gp_fe_message = message;
|
||||
gp_fe_confirm = confirm;
|
||||
gp_fe_prompt = prompt;
|
||||
|
||||
return (GP_OK);
|
||||
}
|
||||
|
||||
int gp_frontend_status (Camera *camera, char *status)
|
||||
{
|
||||
|
||||
@@ -1,178 +0,0 @@
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
#include <gphoto2.h>
|
||||
|
||||
#include "globals.h"
|
||||
#include "library.h"
|
||||
#include "util.h"
|
||||
|
||||
int is_library(char *library_filename)
|
||||
{
|
||||
int ret = GP_OK;
|
||||
void *lh;
|
||||
c_id id;
|
||||
|
||||
if ((lh = GP_SYSTEM_DLOPEN(library_filename)) == NULL)
|
||||
return (GP_ERROR);
|
||||
id = (c_id)GP_SYSTEM_DLSYM(lh, "camera_id");
|
||||
if (!id)
|
||||
ret = GP_ERROR;
|
||||
GP_SYSTEM_DLCLOSE(lh);
|
||||
|
||||
return (ret);
|
||||
}
|
||||
|
||||
int load_library(Camera *camera)
|
||||
{
|
||||
void *lh;
|
||||
int x;
|
||||
|
||||
for (x=0; x<glob_abilities_list->count; x++) {
|
||||
if (strcmp(glob_abilities_list->abilities[x]->model, camera->model)==0) {
|
||||
if ((lh = GP_SYSTEM_DLOPEN(glob_abilities_list->abilities[x]->library))==NULL) {
|
||||
if (glob_debug)
|
||||
perror("core:\tload_library");
|
||||
return (GP_ERROR);
|
||||
}
|
||||
|
||||
camera->library_handle = lh;
|
||||
camera->functions->id = (c_id)GP_SYSTEM_DLSYM(lh, "camera_id");
|
||||
camera->functions->abilities = (c_abilities)GP_SYSTEM_DLSYM(lh, "camera_abilities");
|
||||
camera->functions->init = (c_init)GP_SYSTEM_DLSYM(lh, "camera_init");
|
||||
|
||||
return GP_OK;
|
||||
}
|
||||
}
|
||||
|
||||
return GP_ERROR;
|
||||
}
|
||||
|
||||
/* Returns the number of cameras added to the CameraChoice list */
|
||||
/* 0 implies an error occurred */
|
||||
int load_camera_list(char *library_filename)
|
||||
{
|
||||
CameraText id;
|
||||
void *lh;
|
||||
c_abilities load_camera_abilities;
|
||||
c_id load_camera_id;
|
||||
int x, old_count;
|
||||
|
||||
/* try to open the library */
|
||||
if ((lh = GP_SYSTEM_DLOPEN(library_filename))==NULL) {
|
||||
if (glob_debug)
|
||||
perror("core:\tload_camera_list");
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* check to see if this library has been loaded */
|
||||
load_camera_id = (c_id)GP_SYSTEM_DLSYM(lh, "camera_id");
|
||||
load_camera_id(&id);
|
||||
gp_debug_printf(GP_DEBUG_LOW, "core", "\t library id: %s", id.text);
|
||||
|
||||
for (x=0; x<glob_abilities_list->count; x++) {
|
||||
if (strcmp(glob_abilities_list->abilities[x]->id, id.text)==0) {
|
||||
GP_SYSTEM_DLCLOSE(lh);
|
||||
return (GP_ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
/* load in the camera_abilities function */
|
||||
load_camera_abilities = (c_abilities)GP_SYSTEM_DLSYM(lh, "camera_abilities");
|
||||
old_count = glob_abilities_list->count;
|
||||
|
||||
if (load_camera_abilities(glob_abilities_list) != GP_OK) {
|
||||
GP_SYSTEM_DLCLOSE(lh);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Copy in the core-specific information */
|
||||
for (x=old_count; x<glob_abilities_list->count; x++) {
|
||||
strcpy(glob_abilities_list->abilities[x]->id, id.text);
|
||||
strcpy(glob_abilities_list->abilities[x]->library, library_filename);
|
||||
}
|
||||
|
||||
GP_SYSTEM_DLCLOSE(lh);
|
||||
|
||||
return x;
|
||||
}
|
||||
|
||||
int load_cameras_search(char *directory)
|
||||
{
|
||||
GP_SYSTEM_DIR d;
|
||||
GP_SYSTEM_DIRENT de;
|
||||
char buf[1024];
|
||||
|
||||
gp_debug_printf(GP_DEBUG_LOW, "core","Trying to load camera libraries in:");
|
||||
gp_debug_printf(GP_DEBUG_LOW, "core","\t%s", directory);
|
||||
|
||||
/* Look for available camera libraries */
|
||||
d = GP_SYSTEM_OPENDIR(directory);
|
||||
if (!d) {
|
||||
gp_debug_printf(GP_DEBUG_LOW, "core", "couldn't open %s", directory);
|
||||
return GP_ERROR_DIRECTORY_NOT_FOUND;
|
||||
}
|
||||
|
||||
do {
|
||||
/* Read each entry */
|
||||
de = GP_SYSTEM_READDIR(d);
|
||||
if (de) {
|
||||
sprintf(buf, "%s%c%s", directory, GP_SYSTEM_DIR_DELIM, GP_SYSTEM_FILENAME(de));
|
||||
gp_debug_printf(GP_DEBUG_LOW, "core", "\tis %s a library? ", buf);
|
||||
/* try to open the library */
|
||||
if (is_library(buf) == GP_OK) {
|
||||
gp_debug_printf(GP_DEBUG_LOW, "core", "yes");
|
||||
load_camera_list(buf);
|
||||
} else {
|
||||
gp_debug_printf(GP_DEBUG_LOW, "core", "no. reason: %s", GP_SYSTEM_DLERROR());
|
||||
}
|
||||
}
|
||||
} while (de);
|
||||
|
||||
return (GP_OK);
|
||||
}
|
||||
|
||||
int load_cameras() {
|
||||
|
||||
int x, y, z;
|
||||
CameraAbilities *t;
|
||||
|
||||
/* Where should we search for camera libraries? */
|
||||
|
||||
/* The installed camera library directory */
|
||||
load_cameras_search(CAMLIBS);
|
||||
|
||||
/* Current directory */
|
||||
/* load_cameras_search("."); */
|
||||
|
||||
/* Sort the camera list */
|
||||
for (x=0; x<glob_abilities_list->count-1; x++) {
|
||||
for (y=x+1; y<glob_abilities_list->count; y++) {
|
||||
z = strcmp(glob_abilities_list->abilities[x]->model,
|
||||
glob_abilities_list->abilities[y]->model);
|
||||
if (z > 0) {
|
||||
t = glob_abilities_list->abilities[x];
|
||||
glob_abilities_list->abilities[x] = glob_abilities_list->abilities[y];
|
||||
glob_abilities_list->abilities[y] = t;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* MUCH too verbose.
|
||||
if (glob_debug) {
|
||||
gp_debug_printf(GP_DEBUG_LOW, "core", "Loaded camera list");
|
||||
gp_abilities_list_dump(glob_abilities_list);
|
||||
}
|
||||
*/
|
||||
|
||||
return GP_OK;
|
||||
}
|
||||
|
||||
int close_library(Camera *camera)
|
||||
{
|
||||
GP_SYSTEM_DLCLOSE(camera->library_handle);
|
||||
|
||||
return GP_OK;
|
||||
}
|
||||
|
||||
@@ -1,4 +0,0 @@
|
||||
int load_cameras();
|
||||
int is_library (char *library_filename);
|
||||
int load_library (Camera *camera);
|
||||
int close_library (Camera *camera);
|
||||
64
libgphoto2/list.c
Normal file
64
libgphoto2/list.c
Normal file
@@ -0,0 +1,64 @@
|
||||
/* list.c
|
||||
*
|
||||
* Copyright (C) 2000 Scott Fritzinger
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the
|
||||
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#include "gphoto2-list.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "gphoto2-result.h"
|
||||
|
||||
CameraList *gp_list_new ()
|
||||
{
|
||||
CameraList *list;
|
||||
|
||||
list = (CameraList*)malloc (sizeof (CameraList));
|
||||
if (!list)
|
||||
return NULL;
|
||||
|
||||
memset (list, 0, sizeof (CameraList));
|
||||
return (list);
|
||||
}
|
||||
|
||||
int gp_list_free (CameraList *list)
|
||||
{
|
||||
if (list)
|
||||
free (list);
|
||||
return (GP_OK);
|
||||
}
|
||||
|
||||
int gp_list_append (CameraList *list, char *name)
|
||||
{
|
||||
strcpy (list->entry[list->count].name, name);
|
||||
|
||||
list->count += 1;
|
||||
|
||||
return (GP_OK);
|
||||
}
|
||||
|
||||
int gp_list_count (CameraList *list)
|
||||
{
|
||||
return (list->count);
|
||||
}
|
||||
|
||||
CameraListEntry *gp_list_entry (CameraList *list, int entrynum)
|
||||
{
|
||||
return (&list->entry [entrynum]);
|
||||
}
|
||||
@@ -1,123 +0,0 @@
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <gphoto2.h>
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include <config.h>
|
||||
#endif
|
||||
|
||||
#include "util.h"
|
||||
|
||||
CameraList *gp_list_new ()
|
||||
{
|
||||
CameraList *list;
|
||||
|
||||
list = (CameraList*)malloc (sizeof (CameraList));
|
||||
if (!list)
|
||||
return NULL;
|
||||
|
||||
memset (list, 0, sizeof (CameraList));
|
||||
return (list);
|
||||
}
|
||||
|
||||
int gp_list_free (CameraList *list)
|
||||
{
|
||||
if (list)
|
||||
free (list);
|
||||
return (GP_OK);
|
||||
}
|
||||
|
||||
int gp_list_append (CameraList *list, char *name)
|
||||
{
|
||||
strcpy (list->entry[list->count].name, name);
|
||||
|
||||
list->count += 1;
|
||||
|
||||
return (GP_OK);
|
||||
}
|
||||
|
||||
int gp_list_count (CameraList *list)
|
||||
{
|
||||
return (list->count);
|
||||
}
|
||||
|
||||
CameraListEntry *gp_list_entry (CameraList *list, int entrynum)
|
||||
{
|
||||
return (&list->entry[entrynum]);
|
||||
}
|
||||
|
||||
CameraAbilities *gp_abilities_new ()
|
||||
{
|
||||
CameraAbilities *abilities;
|
||||
|
||||
abilities = (CameraAbilities*)malloc (sizeof(CameraAbilities));
|
||||
if (!abilities)
|
||||
return (NULL);
|
||||
|
||||
return (abilities);
|
||||
}
|
||||
|
||||
int gp_abilities_free (CameraAbilities *abilities)
|
||||
{
|
||||
free (abilities);
|
||||
|
||||
return (GP_OK);
|
||||
}
|
||||
|
||||
|
||||
CameraAbilitiesList *gp_abilities_list_new ()
|
||||
{
|
||||
CameraAbilitiesList *list;
|
||||
|
||||
list = (CameraAbilitiesList*)malloc (sizeof (CameraAbilitiesList));
|
||||
if (!list)
|
||||
return (NULL);
|
||||
list->count = 0;
|
||||
list->abilities = NULL;
|
||||
|
||||
return (list);
|
||||
}
|
||||
|
||||
int gp_abilities_list_free (CameraAbilitiesList *list)
|
||||
{
|
||||
int x;
|
||||
|
||||
/* TODO: OS/2 Port crashes here... maybe compiler setting */
|
||||
|
||||
|
||||
for (x = 0; x < list->count; x++)
|
||||
free (list->abilities[x]);
|
||||
|
||||
free (list);
|
||||
return (GP_OK);
|
||||
}
|
||||
|
||||
int gp_abilities_list_dump (CameraAbilitiesList *list)
|
||||
{
|
||||
int x;
|
||||
|
||||
for (x = 0; x < list->count; x++) {
|
||||
gp_debug_printf (GP_DEBUG_LOW, "core", "Camera #%i:", x);
|
||||
gp_abilities_dump (list->abilities[x]);
|
||||
}
|
||||
|
||||
return (GP_OK);
|
||||
}
|
||||
|
||||
int gp_abilities_list_append (CameraAbilitiesList *list,
|
||||
CameraAbilities *abilities)
|
||||
{
|
||||
if (!list->abilities)
|
||||
list->abilities = (CameraAbilities**)malloc (
|
||||
sizeof (CameraAbilities*));
|
||||
else
|
||||
list->abilities = (CameraAbilities**)realloc (list->abilities,
|
||||
sizeof (CameraAbilities*) * (list->count + 1));
|
||||
if (!list->abilities)
|
||||
return (GP_ERROR_NO_MEMORY);
|
||||
|
||||
list->abilities[list->count] = abilities;
|
||||
list->count += 1;
|
||||
|
||||
return (GP_OK);
|
||||
}
|
||||
@@ -1,8 +0,0 @@
|
||||
#include <string.h>
|
||||
#include <gphoto2.h>
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include <config.h>
|
||||
#endif
|
||||
|
||||
/* deprecated with libgphoto2_port */
|
||||
73
libgphoto2/result.c
Normal file
73
libgphoto2/result.c
Normal file
@@ -0,0 +1,73 @@
|
||||
/* gphoto2-result.c
|
||||
*
|
||||
* Copyright (C) 2000 Scott Fritzinger
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the
|
||||
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#include "gphoto2-result.h"
|
||||
|
||||
#include <config.h>
|
||||
#ifdef ENABLE_NLS
|
||||
# include <libintl.h>
|
||||
# undef _
|
||||
# define _(String) dgettext (PACKAGE, String)
|
||||
# ifdef gettext_noop
|
||||
# define N_(String) gettext_noop (String)
|
||||
# else
|
||||
# define N_(String) (String)
|
||||
# endif
|
||||
#else
|
||||
# define _(String) (String)
|
||||
# define N_(String) (String)
|
||||
#endif
|
||||
|
||||
static char *result_string[] = {
|
||||
/* GP_ERROR_BAD_PARAMETERS -100 */ N_("Bad parameters"),
|
||||
/* GP_ERROR_IO -101 */ N_("I/O problem"),
|
||||
/* GP_ERROR_CORRUPTED_DATA -102 */ N_("Corrupted data"),
|
||||
/* GP_ERROR_FILE_EXISTS -103 */ N_("File exists"),
|
||||
/* GP_ERROR_NO_MEMORY -104 */ N_("Insufficient memory"),
|
||||
/* GP_ERROR_MODEL_NOT_FOUND -105 */ N_("Unknown model"),
|
||||
/* GP_ERROR_NOT_SUPPORTED -106 */ N_("Unsupported operation"),
|
||||
/* GP_ERROR_DIRECTORY_NOT_FOUND -107 */ N_("Directory not found"),
|
||||
/* GP_ERROR_FILE_NOT_FOUND -108 */ N_("File not found"),
|
||||
/* GP_ERROR_DIRECTORY_EXISTS -109 */ N_("Directory exists"),
|
||||
/* GP_ERROR_NO_CAMERA_FOUND -110 */ N_("No cameras were detected")
|
||||
};
|
||||
|
||||
char *
|
||||
gp_result_as_string (int result)
|
||||
{
|
||||
/* Really an error? */
|
||||
if (result > 0)
|
||||
return _("Unknown error");
|
||||
|
||||
/* IOlib error? Pass through. */
|
||||
if ((result <= 0) && (result >= -99))
|
||||
return gp_port_result_as_string (result);
|
||||
|
||||
/* Camlib error? You should have called gp_camera_result_as_string... */
|
||||
if (result <= -1000)
|
||||
return _("Unknown camera library error");
|
||||
|
||||
/* Do we have an error description? */
|
||||
if ((-result - 100) < (int) (sizeof (result_string) /
|
||||
sizeof (*result_string)))
|
||||
return _(result_string [-result - 100]);
|
||||
|
||||
return _("Unknown error");
|
||||
}
|
||||
@@ -1,12 +1,47 @@
|
||||
/* setting.c
|
||||
*
|
||||
* Copyright (C) 2000 Scott Fritzinger
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the
|
||||
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#include "gphoto2-setting.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <gphoto2.h>
|
||||
#include "gphoto2-result.h"
|
||||
#include "gphoto2-core.h"
|
||||
|
||||
#include "settings.h"
|
||||
#include "globals.h"
|
||||
#include "util.h"
|
||||
typedef struct {
|
||||
/* key = value settings */
|
||||
char id[256];
|
||||
char key[256];
|
||||
char value[256];
|
||||
} Setting;
|
||||
|
||||
/* Currently loaded settings */
|
||||
int glob_setting_count = 0;
|
||||
Setting glob_setting[512];
|
||||
|
||||
extern int glob_debug;
|
||||
|
||||
static int save_settings (void);
|
||||
static int dump_settings (void);
|
||||
|
||||
int gp_setting_get (char *id, char *key, char *value)
|
||||
{
|
||||
@@ -40,20 +75,20 @@ int gp_setting_set (char *id, char *key, char *value)
|
||||
if ((strcmp(glob_setting[x].id, id)==0) &&
|
||||
(strcmp(glob_setting[x].key, key)==0)) {
|
||||
strcpy(glob_setting[x].value, value);
|
||||
save_settings(glob_setting, glob_setting_count);
|
||||
save_settings ();
|
||||
return (GP_OK);
|
||||
}
|
||||
}
|
||||
strcpy(glob_setting[glob_setting_count].id, id);
|
||||
strcpy(glob_setting[glob_setting_count].key, key);
|
||||
strcpy(glob_setting[glob_setting_count++].value, value);
|
||||
save_settings(glob_setting, glob_setting_count);
|
||||
save_settings ();
|
||||
|
||||
return (GP_OK);
|
||||
}
|
||||
|
||||
int verify_settings (char *settings_file) {
|
||||
|
||||
int verify_settings (char *settings_file)
|
||||
{
|
||||
FILE *f;
|
||||
char buf[1024];
|
||||
int x, equals;
|
||||
@@ -87,8 +122,8 @@ int verify_settings (char *settings_file) {
|
||||
return (GP_OK);
|
||||
}
|
||||
|
||||
int load_settings () {
|
||||
|
||||
int load_settings (void)
|
||||
{
|
||||
FILE *f;
|
||||
char buf[1024], *id, *key, *value;
|
||||
|
||||
@@ -128,14 +163,15 @@ int load_settings () {
|
||||
}
|
||||
}
|
||||
if (glob_debug)
|
||||
dump_settings();
|
||||
dump_settings ();
|
||||
|
||||
return (GP_OK);
|
||||
}
|
||||
|
||||
|
||||
int save_settings () {
|
||||
|
||||
static int
|
||||
save_settings (void)
|
||||
{
|
||||
FILE *f;
|
||||
char buf[1024];
|
||||
int x=0;
|
||||
@@ -163,9 +199,10 @@ int save_settings () {
|
||||
return (GP_OK);
|
||||
}
|
||||
|
||||
int dump_settings () {
|
||||
|
||||
static int dump_settings (void)
|
||||
{
|
||||
int x;
|
||||
|
||||
gp_debug_printf(GP_DEBUG_LOW, "core", "All settings:");
|
||||
for (x=0; x<glob_setting_count; x++)
|
||||
gp_debug_printf(GP_DEBUG_LOW, "core", "\t (%s) \"%s\" = \"%s\"", glob_setting[x].id,
|
||||
@@ -1,3 +0,0 @@
|
||||
int save_settings ();
|
||||
int load_settings ();
|
||||
int dump_settings ();
|
||||
@@ -1,2 +0,0 @@
|
||||
int gp_abilities_dump (CameraAbilities *abilities);
|
||||
int gp_abilities_clear (CameraAbilities *abilities);
|
||||
@@ -1,4 +1,5 @@
|
||||
#include <gphoto2.h>
|
||||
#include <gphoto2-core.h>
|
||||
#include <gphoto2-camera.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#define CHECK(f) {int res = f; if (res < 0) {printf ("ERROR: %s\n", gp_result_as_string (res)); exit (1);}}
|
||||
|
||||
Reference in New Issue
Block a user