From bb3d18289e752db9dff5f7e60e5368f46bdd1a8a Mon Sep 17 00:00:00 2001 From: Marcus Meissner Date: Mon, 16 Feb 2009 08:09:49 +0000 Subject: Batch commit from weekend work: - removed "type" from CameraFile handling: - all put_file functions and hooks get "type" as argument now - added type to the set_file_info_noop call - started removal of "name" from CameraFile - generate new filename from original filename + camerafile type + mimetype - new gp_camera_autodetect() helper function - adapted all drivers. git-svn-id: https://svn.code.sf.net/p/gphoto/code/trunk/libgphoto2@11818 67ed7778-7388-44ab-90cf-0a291f65f57c --- libgphoto2/gphoto2-camera.c | 71 ++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 70 insertions(+), 1 deletion(-) (limited to 'libgphoto2/gphoto2-camera.c') diff --git a/libgphoto2/gphoto2-camera.c b/libgphoto2/gphoto2-camera.c index a4ecb69f9..5d4835367 100644 --- a/libgphoto2/gphoto2-camera.c +++ b/libgphoto2/gphoto2-camera.c @@ -625,6 +625,69 @@ gp_camera_free (Camera *camera) return (GP_OK); } +/** + * Autodetect all detectable camera + * + * @param list a #CameraList that receives the autodetected cameras + * @param context a #GPContext + * @return a gphoto2 error code + * + * This camera will autodetected all cameras that can be autodetected. + * This will for instance detect all USB cameras. + * + * CameraList *list; + * gp_list_new (&list); + * gp_camera_autodetect (list, context); + * ... done! ... + */ +int +gp_camera_autodetect (CameraList *list, GPContext *context) +{ + CameraAbilitiesList *al; + GPPortInfoList *il; + int ret, i; + CameraList *xlist = NULL; + + ret = gp_list_new (&xlist); + if (ret < GP_OK) goto out; + if (!il) { + /* Load all the port drivers we have... */ + ret = gp_port_info_list_new (&il); + if (ret < GP_OK) goto out; + ret = gp_port_info_list_load (il); + if (ret < 0) goto out; + ret = gp_port_info_list_count (il); + if (ret < 0) goto out; + } + /* Load all the camera drivers we have... */ + ret = gp_abilities_list_new (&al); + if (ret < GP_OK) goto out; + ret = gp_abilities_list_load (al, context); + if (ret < GP_OK) goto out; + + /* ... and autodetect the currently attached cameras. */ + ret = gp_abilities_list_detect (al, il, xlist, context); + if (ret < GP_OK) goto out; + + /* Filter out the "usb:" entry */ + ret = gp_list_count (xlist); + if (ret < GP_OK) goto out; + for (i=0;ifunctions->capture_preview ( camera, file, context), context); + gp_file_get_name_by_type (file, "capture_preview", GP_FILE_TYPE_NORMAL, &xname); + /* FIXME: Marcus ... will go away, just keep compatible now. */ + gp_file_set_name (file, xname); + free (xname); CAMERA_UNUSED (camera, context); return (GP_OK); @@ -1147,6 +1215,7 @@ gp_camera_folder_delete_all (Camera *camera, const char *folder, int gp_camera_folder_put_file (Camera *camera, const char *folder, const char *filename, + CameraFileType type, CameraFile *file, GPContext *context) { gp_log (GP_LOG_DEBUG, "gphoto2-camera", "Uploading file into '%s'...", @@ -1156,7 +1225,7 @@ gp_camera_folder_put_file (Camera *camera, CHECK_INIT (camera, context); CHECK_RESULT_OPEN_CLOSE (camera, gp_filesystem_put_file (camera->fs, - folder, filename, file, context), context); + folder, filename, type, file, context), context); CAMERA_UNUSED (camera, context); return (GP_OK); -- cgit v1.2.1