44 # define _(String) dgettext (GETTEXT_PACKAGE, String)
46 # define N_(String) gettext_noop (String)
48 # define N_(String) (String)
51 # define textdomain(String) (String)
52 # define gettext(String) (String)
53 # define dgettext(Domain,Message) (Message)
54 # define dcgettext(Domain,Message,Type) (Message)
55 # define bindtextdomain(Domain,Directory) (Domain)
56 # define _(String) (String)
57 # define N_(String) (String)
60 #define CAMERA_UNUSED(c,ctx) \
63 if (!(c)->pc->used) { \
64 if ((c)->pc->exit_requested) \
65 gp_camera_exit ((c), (ctx)); \
66 if (!(c)->pc->ref_count) \
71 #define CR(c,result,ctx) \
77 gp_context_error ((ctx), _("An error occurred " \
78 "in the io-library ('%s'): %s"), \
79 gp_port_result_as_string (r1), \
80 gp_port_get_error ((c) ? (c)->port : NULL)); \
82 CAMERA_UNUSED (c,ctx); \
116 #define CHECK_OPEN(c,ctx) \
120 if (strcmp ((c)->pc->a.model,"Directory Browse")) { \
121 r2 = gp_port_open ((c)->port); \
123 CAMERA_UNUSED (c,ctx); \
127 if ((c)->functions->pre_func) { \
128 r2 = (c)->functions->pre_func (c,ctx); \
130 CAMERA_UNUSED (c,ctx); \
136 #define CHECK_OPEN(c,ctx) \
138 if ((c)->functions->pre_func) { \
139 int r2 = (c)->functions->pre_func (c,ctx); \
141 CAMERA_UNUSED (c,ctx); \
149 #define CHECK_CLOSE(c,ctx) \
151 if (strcmp ((c)->pc->a.model,"Directory Browse")) \
152 gp_port_close ((c)->port); \
153 if ((c)->functions->post_func) { \
154 int r3 = (c)->functions->post_func (c,ctx); \
156 CAMERA_UNUSED (c,ctx); \
162 #define CHECK_CLOSE(c,ctx) \
164 if ((c)->functions->post_func) { \
165 int r3 = (c)->functions->post_func (c,ctx); \
167 CAMERA_UNUSED (c,ctx); \
174 #define CRS(c,res,ctx) \
179 CAMERA_UNUSED (c,ctx); \
184 #define CRSL(c,res,ctx,list) \
189 CAMERA_UNUSED (c,ctx); \
190 gp_list_free (list); \
195 #define CHECK_RESULT_OPEN_CLOSE(c,result,ctx) \
199 CHECK_OPEN (c,ctx); \
202 GP_LOG_E ("'%s' failed: %d", #result, r6); \
203 CHECK_CLOSE (c,ctx); \
204 CAMERA_UNUSED (c,ctx); \
207 CHECK_CLOSE (c,ctx); \
210 #define CHECK_INIT(c,ctx) \
213 return (GP_ERROR_CAMERA_BUSY); \
216 CR((c), gp_camera_init (c, ctx), ctx); \
268 GP_LOG_D (
"Exiting camera ('%s')...", camera->
pc->
a.
model);
295 if (camera->
pc->
lh) {
296 #if !defined(VALGRIND)
297 lt_dlclose (camera->
pc->
lh);
300 camera->
pc->
lh = NULL;
323 C_MEM (*camera = calloc (1,
sizeof (
Camera)));
327 if (!(*camera)->functions || !(*camera)->pc) {
332 (*camera)->pc->ref_count = 1;
370 GP_LOG_D (
"Setting abilities ('%s')...", abilities.
model);
398 C_PARAMS (camera && abilities);
409 C_PARAMS (camera && info);
432 GP_LOG_D (
"Setting port info for port '%s' at '%s'...", name, path);
462 C_PARAMS_MSG (camera->
port,
463 "You need to set a port prior trying to set the speed");
465 "You can specify a speed only with serial ports");
533 GP_LOG_E (
"gp_camera_unref on a camera with ref_count == 0 "
534 "should not happen at all");
566 GP_LOG_D (
"Freeing camera...");
572 if (camera->
port && camera->
pc && camera->
pc->
lh)
626 if (ret <
GP_OK)
goto out;
630 if (ret <
GP_OK)
goto out;
632 if (ret < 0)
goto out;
634 if (ret < 0)
goto out;
638 if (ret <
GP_OK)
goto out;
640 if (ret <
GP_OK)
goto out;
644 if (ret <
GP_OK)
goto out;
648 if (ret <
GP_OK)
goto out;
649 for (i=0;i<ret;i++) {
650 const char *name, *value;
654 if (!strcmp (
"usb:",value))
continue;
686 const char *model, *port;
690 GP_LOG_D (
"Initializing camera...");
704 if (strcasecmp (camera->
pc->
a.
model,
"Directory Browse") &&
705 !strcmp (
"", camera->
pc->
a.
model)) {
718 GP_LOG_D (
"Neither port nor model set. Trying auto-detection...");
739 if ((ptype ==
GP_PORT_USB) && strlen(ppath) && strcmp(ppath,
"usb:")) {
744 if (!strcmp (xp, ppath))
758 CRSL (camera, m, context, list);
764 CRSL (camera, p, context, list);
771 if (strcasecmp (camera->
pc->
a.
model,
"Directory Browse")) {
775 "port prior to initialization of the camera."));
794 GP_LOG_D (
"Loading '%s'...", camera->
pc->
a.
library);
797 if (!camera->
pc->
lh) {
799 "camera driver '%s' (%s)."), camera->
pc->
a.
library,
806 init_func = lt_dlsym (camera->
pc->
lh,
"camera_init");
808 lt_dlclose (camera->
pc->
lh);
810 camera->
pc->
lh = NULL;
812 "missing the 'camera_init' function."),
817 if (strcasecmp (camera->
pc->
a.
model,
"Directory Browse")) {
820 lt_dlclose (camera->
pc->
lh);
822 camera->
pc->
lh = NULL;
827 result = init_func (camera, context);
830 lt_dlclose (camera->
pc->
lh);
832 camera->
pc->
lh = NULL;
865 "not provide any configuration options."));
871 camera, window, context), context);
903 camera, name, widget, context), context);
910 gp_context_error (context,
_(
"This camera does not provide any configuration options."));
949 for (i = 0; i < nrofchoices; i++) {
967 float value, rmin, rmax, rstep;
1031 int i, nrofchildren;
1034 for (i = 0; i < nrofchildren; i++) {
1059 camera, list, context), context);
1065 gp_context_error (context,
_(
"This camera does not provide any configuration options."));
1104 C_PARAMS (camera && window);
1109 "not support setting configuration options."));
1115 window, context), context);
1145 camera, name, widget, context), context);
1152 gp_context_error (context,
_(
"This camera does not provide any configuration options."));
1233 C_PARAMS (camera && summary);
1238 "not support summaries."));
1244 summary, context), context);
1264 C_PARAMS (camera && manual);
1269 "does not provide a manual."));
1275 manual, context), context);
1296 C_PARAMS (camera && about);
1301 "not provide information about the driver."));
1307 about, context), context);
1340 type, path, context), context);
1391 C_PARAMS (camera && file);
1398 "not capture previews."));
1404 camera, file, context), context);
1450 camera, timeout, eventtype, eventdata,
1470 GP_LOG_D (
"Listing files in '%s'...", folder);
1472 C_PARAMS (camera && folder && list);
1477 folder, list, context), context);
1498 GP_LOG_D (
"Listing folders in '%s'...", folder);
1500 C_PARAMS (camera && folder && list);
1505 camera->
fs, folder, list, context), context);
1525 GP_LOG_D (
"Deleting all files in '%s'...", folder);
1527 C_PARAMS (camera && folder);
1531 folder, context), context);
1549 const char *folder,
const char *filename,
1553 GP_LOG_D (
"Uploading file into '%s'...",
1556 C_PARAMS (camera && folder && file);
1560 folder, filename, type, file, context), context);
1583 const char *mime_type;
1588 GP_LOG_D (
"Getting file info for '%s' in '%s'...", file, folder);
1590 C_PARAMS (camera && folder && file && info);
1617 cfile, context) ==
GP_OK) {
1648 C_PARAMS (camera && folder && file);
1652 folder, file, info, context), context);
1675 GP_LOG_D (
"Getting file '%s' in folder '%s'...", file, folder);
1677 C_PARAMS (camera && folder && file && camera_file);
1683 if (strlen (folder) == 0) {
1687 if (strlen (file) == 0) {
1693 folder, file, type, camera_file, context), context);
1716 uint64_t offset,
char *buf, uint64_t *size,
1719 GP_LOG_D (
"Getting file '%s' in folder '%s'...", file, folder);
1721 C_PARAMS (camera && folder && file && buf && size);
1725 if (strlen (folder) == 0) {
1729 if (strlen (file) == 0) {
1735 folder, file, type, offset, buf, size, context), context);
1755 GP_LOG_D (
"Deleting file '%s' in folder '%s'...", file, folder);
1757 C_PARAMS (camera && folder && file);
1761 camera->
fs, folder, file, context), context);
1781 C_PARAMS (camera && folder && name);
1785 folder, name, context), context);
1805 C_PARAMS (camera && folder && name);
1809 folder, name, context), context);
1841 C_PARAMS (camera && sifs && nrofsifs);
1846 camera->
fs, sifs, nrofsifs, context
1871 if (!camera || !camera->
pc)
1898 C_PARAMS (camera && camera->
pc);
1938 if (!camera || !camera->
pc)
int gp_abilities_list_lookup_model(CameraAbilitiesList *list, const char *model)
Search the list for an entry of given model name.
int gp_abilities_list_load(CameraAbilitiesList *list, GPContext *context)
Scans the system for camera drivers.
int gp_abilities_list_new(CameraAbilitiesList **list)
Allocate the memory for a new abilities list.
int gp_abilities_list_detect(CameraAbilitiesList *list, GPPortInfoList *info_list, CameraList *l, GPContext *context)
int gp_abilities_list_get_abilities(CameraAbilitiesList *list, int index, CameraAbilities *abilities)
Retrieve the camera abilities of entry with supplied index number.
int gp_abilities_list_free(CameraAbilitiesList *list)
Free the given CameraAbilitiesList object.
int gp_camera_list_config(Camera *camera, CameraList *list, GPContext *context)
int gp_camera_get_port_speed(Camera *camera)
int gp_camera_get_about(Camera *camera, CameraText *about, GPContext *context)
int gp_camera_set_config(Camera *camera, CameraWidget *window, GPContext *context)
int gp_camera_folder_delete_all(Camera *camera, const char *folder, GPContext *context)
int gp_camera_folder_list_files(Camera *camera, const char *folder, CameraList *list, GPContext *context)
int gp_camera_set_port_speed(Camera *camera, int speed)
int gp_camera_folder_remove_dir(Camera *camera, const char *folder, const char *name, GPContext *context)
int gp_camera_file_set_info(Camera *camera, const char *folder, const char *file, CameraFileInfo info, GPContext *context)
int gp_camera_file_read(Camera *camera, const char *folder, const char *file, CameraFileType type, uint64_t offset, char *buf, uint64_t *size, GPContext *context)
int gp_camera_get_abilities(Camera *camera, CameraAbilities *abilities)
#define CHECK_RESULT_OPEN_CLOSE(c, result, ctx)
int gp_camera_file_get(Camera *camera, const char *folder, const char *file, CameraFileType type, CameraFile *camera_file, GPContext *context)
int gp_camera_get_manual(Camera *camera, CameraText *manual, GPContext *context)
int gp_camera_ref(Camera *camera)
int gp_camera_file_delete(Camera *camera, const char *folder, const char *file, GPContext *context)
#define CHECK_OPEN(c, ctx)
int gp_camera_trigger_capture(Camera *camera, GPContext *context)
int gp_camera_unref(Camera *camera)
int gp_camera_start_timeout(Camera *camera, unsigned int timeout, CameraTimeoutFunc func)
int gp_camera_wait_for_event(Camera *camera, int timeout, CameraEventType *eventtype, void **eventdata, GPContext *context)
int gp_camera_folder_make_dir(Camera *camera, const char *folder, const char *name, GPContext *context)
void gp_camera_stop_timeout(Camera *camera, unsigned int id)
int gp_camera_exit(Camera *camera, GPContext *context)
int gp_camera_free(Camera *camera)
int gp_camera_get_summary(Camera *camera, CameraText *summary, GPContext *context)
int gp_camera_folder_list_folders(Camera *camera, const char *folder, CameraList *list, GPContext *context)
#define CR(c, result, ctx)
#define CRSL(c, res, ctx, list)
#define CHECK_INIT(c, ctx)
int gp_camera_set_port_info(Camera *camera, GPPortInfo info)
#define CHECK_CLOSE(c, ctx)
int gp_camera_capture(Camera *camera, CameraCaptureType type, CameraFilePath *path, GPContext *context)
int gp_camera_set_abilities(Camera *camera, CameraAbilities abilities)
Sets the camera abilities.
int gp_camera_get_port_info(Camera *camera, GPPortInfo *info)
int gp_camera_folder_put_file(Camera *camera, const char *folder, const char *filename, CameraFileType type, CameraFile *file, GPContext *context)
int gp_camera_init(Camera *camera, GPContext *context)
static void _get_widget_names(CameraWidget *widget, CameraList *list)
int gp_camera_get_single_config(Camera *camera, const char *name, CameraWidget **widget, GPContext *context)
#define CAMERA_UNUSED(c, ctx)
int gp_camera_capture_preview(Camera *camera, CameraFile *file, GPContext *context)
int gp_camera_get_storageinfo(Camera *camera, CameraStorageInformation **sifs, int *nrofsifs, GPContext *context)
Gets information on the camera attached storage.
int gp_camera_new(Camera **camera)
int gp_camera_file_get_info(Camera *camera, const char *folder, const char *file, CameraFileInfo *info, GPContext *context)
int gp_camera_set_single_config(Camera *camera, const char *name, CameraWidget *widget, GPContext *context)
int gp_camera_autodetect(CameraList *list, GPContext *context)
int gp_camera_get_config(Camera *camera, CameraWidget **window, GPContext *context)
void gp_camera_set_timeout_funcs(Camera *camera, CameraTimeoutStartFunc start_func, CameraTimeoutStopFunc stop_func, void *data)
Implement Camera object representing a camera attached to the system.
unsigned int(* CameraTimeoutStartFunc)(Camera *camera, unsigned int timeout, CameraTimeoutFunc func, void *data)
void(* CameraTimeoutStopFunc)(Camera *camera, unsigned int id, void *data)
int(* CameraTimeoutFunc)(Camera *camera, GPContext *context)
CameraEventType
Specify what event we received from the camera.
CameraCaptureType
Type of the capture to do.
void gp_context_error(GPContext *context, const char *format,...)
int gp_file_get_mime_type(CameraFile *file, const char **mime_type)
int gp_file_clean(CameraFile *file)
int gp_file_unref(CameraFile *file)
Decrease reference counter for CameraFile object.
int gp_file_set_name(CameraFile *file, const char *name)
int gp_file_get_name_by_type(CameraFile *file, const char *basename, CameraFileType type, char **newname)
int gp_file_new(CameraFile **file)
int gp_file_get_data_and_size(CameraFile *file, const char **data, unsigned long int *size)
CameraFileType
The type of view on the specified file.
int gp_filesystem_free(CameraFilesystem *fs)
Free filesystem struct.
int gp_filesystem_new(CameraFilesystem **fs)
Create a new filesystem struct.
int gp_filesystem_set_info(CameraFilesystem *fs, const char *folder, const char *filename, CameraFileInfo info, GPContext *context)
Set information about a file.
int gp_filesystem_make_dir(CameraFilesystem *fs, const char *folder, const char *name, GPContext *context)
Create a subfolder within a folder.
int gp_filesystem_delete_file(CameraFilesystem *fs, const char *folder, const char *filename, GPContext *context)
Delete a file from a folder.
int gp_filesystem_reset(CameraFilesystem *fs)
Clear the filesystem.
int gp_filesystem_delete_all(CameraFilesystem *fs, const char *folder, GPContext *context)
Delete all files in specified folder.
int gp_filesystem_get_file(CameraFilesystem *fs, const char *folder, const char *filename, CameraFileType type, CameraFile *file, GPContext *context)
Get file data from the filesystem.
int gp_filesystem_list_files(CameraFilesystem *fs, const char *folder, CameraList *list, GPContext *context)
Get the list of files in a folder.
int gp_filesystem_get_info(CameraFilesystem *fs, const char *folder, const char *filename, CameraFileInfo *info, GPContext *context)
Get information about the specified file.
int gp_filesystem_put_file(CameraFilesystem *fs, const char *folder, const char *filename, CameraFileType type, CameraFile *file, GPContext *context)
Upload a file to a folder on the device filesystem.
int gp_filesystem_list_folders(CameraFilesystem *fs, const char *folder, CameraList *list, GPContext *context)
List all subfolders within a filesystem folder.
int gp_filesystem_read_file(CameraFilesystem *fs, const char *folder, const char *filename, CameraFileType type, uint64_t offset, char *buf, uint64_t *size, GPContext *context)
Get partial file data from the filesystem.
int gp_filesystem_remove_dir(CameraFilesystem *fs, const char *folder, const char *name, GPContext *context)
Remove a subfolder from within a folder.
int gp_filesystem_get_storageinfo(CameraFilesystem *fs, CameraStorageInformation **storageinfo, int *nrofstorageinfos, GPContext *context)
Get the storage information about this filesystem.
@ GP_FILE_INFO_TYPE
The MIME type is set.
@ GP_FILE_INFO_NONE
No fields set.
@ GP_FILE_INFO_SIZE
The filesize is set.
int(* CameraLibraryInitFunc)(Camera *camera, GPContext *context)
Initializes the camera.
int gp_list_new(CameraList **list)
Creates a new CameraList.
int gp_list_reset(CameraList *list)
int gp_list_free(CameraList *list)
int gp_list_sort(CameraList *list)
int gp_list_append(CameraList *list, const char *name, const char *value)
int gp_list_get_value(CameraList *list, int index, const char **value)
int gp_list_count(CameraList *list)
int gp_list_get_name(CameraList *list, int index, const char **name)
GPPortType
The gphoto port type.
@ GP_PORT_NONE
No specific type associated.
@ GP_PORT_SERIAL
Serial port.
int gp_port_info_list_count(GPPortInfoList *list)
Number of ports in the list.
int gp_port_info_list_new(GPPortInfoList **list)
Create a new GPPortInfoList.
int gp_port_info_list_load(GPPortInfoList *list)
Load system ports.
int gp_port_info_get_type(GPPortInfo info, GPPortType *type)
Get type of a specific port entry.
int gp_port_info_list_get_info(GPPortInfoList *list, int n, GPPortInfo *info)
Get port information of specific entry.
int gp_port_info_get_path(GPPortInfo info, char **path)
Get path of a specific port entry.
int gp_port_info_get_name(GPPortInfo info, char **name)
Get name of a specific port entry.
int gp_port_info_list_free(GPPortInfoList *list)
Free a GPPortInfo list.
int gp_port_info_list_lookup_path(GPPortInfoList *list, const char *path)
Lookup a specific path in the list.
#define GP_ERROR_NO_MEMORY
Out of memory.
#define GP_OK
Everything is OK.
#define GP_ERROR_NOT_SUPPORTED
Functionality not supported.
#define GP_ERROR_BAD_PARAMETERS
Bad parameters passed.
#define GP_ERROR_LIBRARY
Error in the camera driver.
#define GP_ERROR
Generic Error.
#define GP_ERROR_UNKNOWN_PORT
Unknown libgphoto2 port passed.
int gp_port_get_info(GPPort *port, GPPortInfo *info)
Retreives information about the port.
int gp_port_set_info(GPPort *port, GPPortInfo info)
Configure a port.
int gp_port_usb_find_device_by_class(GPPort *port, int mainclass, int subclass, int protocol)
Find USB device by interface class.
int gp_port_usb_find_device(GPPort *port, int idvendor, int idproduct)
Find USB device by vendor/product.
int gp_port_new(GPPort **port)
Create new GPPort.
int gp_port_set_settings(GPPort *port, GPPortSettings settings)
Set port settings.
int gp_port_open(GPPort *port)
Open a port.
int gp_port_get_settings(GPPort *port, GPPortSettings *settings)
Get the current port settings.
int gp_port_free(GPPort *port)
Free the port structure.
int gp_port_close(GPPort *port)
Close a port.
#define GP_ERROR_FILE_NOT_FOUND
Specified file was not found.
#define GP_ERROR_DIRECTORY_NOT_FOUND
Specified directory was not found.
#define GP_ERROR_MODEL_NOT_FOUND
Specified camera model was not found.
Describes the properties of a specific camera.
char library[1024]
(Internal) library filename
int usb_vendor
USB Vendor D.
char model[128]
name of camera model
int usb_class
USB device class.
int usb_protocol
USB device protocol.
int usb_product
USB Product ID.
int usb_subclass
USB device subclass.
A structure created by the capture operation.
CameraText structure used in various functions.
CameraFileInfoFields fields
Bitmask containing the set members.
char type[64]
MIME type of the preview.
CameraFileInfoFields fields
Bitmask containing the set members.
uint64_t size
Size of the preview.
File information structure.
CameraFileInfoPreview preview
Various camera specific functions.
CameraSetSingleConfigFunc set_single_config
Called for setting a single configuration widget.
CameraGetSingleConfigFunc get_single_config
Called for requesteing a single widget.
CameraCapturePreviewFunc capture_preview
Preview viewfinder content.
CameraManualFunc manual
Give a brief manual about any specific items a user has to know, translated.
CameraWaitForEvent wait_for_event
Wait for a specific event from the camera.
CameraGetConfigFunc get_config
Called for requesting the configuration widgets.
CameraAboutFunc about
A little About text, including authors and credits.
CameraSetConfigFunc set_config
Called after a configuration was changed.
CameraSummaryFunc summary
Give a summary about the current camera status, translated.
CameraExitFunc exit
Function called on closing the camera.
CameraTriggerCaptureFunc trigger_capture
Remote control the camera to trigger capture.
CameraCaptureFunc capture
Remote control the camera to capture.
CameraListConfigFunc list_config
Called for listing the available configuration widgets.
unsigned int timeout_ids_len
unsigned char exit_requested
CameraTimeoutStartFunc timeout_start_func
CameraTimeoutStopFunc timeout_stop_func
unsigned int * timeout_ids
CameraFunctions * functions
GPPortType type
Actual type of this port.
GPPortSettingsSerial serial
Serial specific settings.