From 8f5bce99e4b9af8bb1d4a1fe07a2f8458ae011d5 Mon Sep 17 00:00:00 2001 From: Lutz Mueller Date: Mon, 22 Oct 2001 06:29:29 +0000 Subject: [PATCH] =?UTF-8?q?2001-10-22=20Lutz=20M=EF=BF=BDller=20?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * libgphoto2/gphoto2-camera.c: Autodetect also in case of camera->port != NULL. * frontends/command-line/main.c: Only call gp_camera_set_abilities if a model has been specified. Same with gp_camera_set_port_path. git-svn-id: https://svn.code.sf.net/p/gphoto/code/trunk/libgphoto2@2682 67ed7778-7388-44ab-90cf-0a291f65f57c --- ChangeLog | 7 ++++ frontends/command-line/main.c | 19 ++++++++-- libgphoto2/gphoto2-camera.c | 65 +++++++++++++++++------------------ 3 files changed, 55 insertions(+), 36 deletions(-) diff --git a/ChangeLog b/ChangeLog index 5c8eaab5c..25706381e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2001-10-22 Lutz Müller + + * libgphoto2/gphoto2-camera.c: Autodetect also in case of + camera->port != NULL. + * frontends/command-line/main.c: Only call gp_camera_set_abilities + if a model has been specified. Same with gp_camera_set_port_path. + 2001-10-22 Fredrik * camlibs/canon/psa50.c: diff --git a/frontends/command-line/main.c b/frontends/command-line/main.c index b169db5d7..51ad3bd21 100644 --- a/frontends/command-line/main.c +++ b/frontends/command-line/main.c @@ -917,7 +917,9 @@ OPTION_CALLBACK (about) static int set_globals (void) { + CameraAbilitiesList *al; CameraAbilities abilities; + int model; /* takes all the settings and sets up the gphoto lib */ @@ -925,9 +927,20 @@ set_globals (void) cli_debug_print ("Setting globals..."); CHECK_RESULT (gp_camera_new (&glob_camera)); - CHECK_RESULT (gp_camera_abilities_by_name (glob_model, &abilities)); - CHECK_RESULT (gp_camera_set_abilities (glob_camera, abilities)); - if (strcmp (glob_model, "Directory Browse")) + + /* Only set the model if the user specified one */ + if (strcmp ("", glob_model)) { + CHECK_RESULT (gp_abilities_list_new (&al)); + CHECK_RESULT (gp_abilities_list_load (al)); + model = gp_abilities_list_lookup_model (al, glob_model); + CHECK_RESULT (model); + CHECK_RESULT (gp_abilities_list_get_abilities (al, model, + &abilities)); + CHECK_RESULT (gp_camera_set_abilities (glob_camera, abilities)); + } + + /* Only set the port if the user specified one */ + if (strcmp (glob_model, "Directory Browse") && strcmp ("", glob_port)) CHECK_RESULT (gp_camera_set_port_path (glob_camera, glob_port)); /* diff --git a/libgphoto2/gphoto2-camera.c b/libgphoto2/gphoto2-camera.c index f0a318b14..39107ca56 100644 --- a/libgphoto2/gphoto2-camera.c +++ b/libgphoto2/gphoto2-camera.c @@ -716,46 +716,45 @@ gp_camera_init (Camera *camera) camera->pc->a.model); /* - * If the port or the model hasn't been indicated, try to + * If the model hasn't been indicated, try to * figure it out (USB only). Beware of "Directory Browse". */ - if (strcasecmp (camera->pc->a.model, "Directory Browse")) { - if (!camera->port || !strcmp ("", camera->pc->a.model)) { + if (strcasecmp (camera->pc->a.model, "Directory Browse") && + !strcmp ("", camera->pc->a.model)) { - gp_log (GP_LOG_DEBUG, "gphoto2-camera", "Neither " - "port nor model set. Trying auto-detection" - "..."); + gp_log (GP_LOG_DEBUG, "gphoto2-camera", "Neither " + "port nor model set. Trying auto-detection..."); - /* Call auto-detect and choose the first camera */ - CRS (camera, gp_autodetect (&list)); - if (!gp_list_count (&list)) - return (GP_ERROR_MODEL_NOT_FOUND); - - CRS (camera, gp_list_get_name (&list, 0, &model)); - CRS (camera, gp_camera_abilities_by_name (model, &a)); - CRS (camera, gp_camera_set_abilities (camera, a)); - CRS (camera, gp_camera_set_model (camera, model)); - CRS (camera, gp_list_get_value (&list, 0, &port)); - CRS (camera, gp_camera_set_port_path (camera, port)); + /* Call auto-detect and choose the first camera */ + CRS (camera, gp_autodetect (&list)); + if (!gp_list_count (&list)) { + gp_log (GP_LOG_ERROR, "gphoto2-camera", _("Could not " + "detect any camera")); + return (GP_ERROR_MODEL_NOT_FOUND); } + + CRS (camera, gp_list_get_name (&list, 0, &model)); + CRS (camera, gp_camera_abilities_by_name (model, &a)); + CRS (camera, gp_camera_set_abilities (camera, a)); + CRS (camera, gp_list_get_value (&list, 0, &port)); + CRS (camera, gp_camera_set_port_path (camera, port)); + } - /* If we don't have a port at this point, return error */ - if (!camera->port) { - gp_camera_status (camera, ""); - return (GP_ERROR_UNKNOWN_PORT); - } - - /* In case of USB, find the device */ - switch (camera->port->type) { - case GP_PORT_USB: - CRS (camera, gp_port_usb_find_device (camera->port, - camera->pc->a.usb_vendor, - camera->pc->a.usb_product)); - break; - default: - break; - } + /* If we don't have a port at this point, return error */ + if (!camera->port) { + gp_camera_status (camera, ""); + return (GP_ERROR_UNKNOWN_PORT); + } + /* In case of USB, find the device */ + switch (camera->port->type) { + case GP_PORT_USB: + CRS (camera, gp_port_usb_find_device (camera->port, + camera->pc->a.usb_vendor, + camera->pc->a.usb_product)); + break; + default: + break; } /* Load the library. */