summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLutz Mueller <lutz@users.sourceforge.net>2001-10-23 18:00:18 +0000
committerLutz Mueller <lutz@users.sourceforge.net>2001-10-23 18:00:18 +0000
commita3364e4b63ac684e7d6da5ef355fcd620bef4805 (patch)
treec27f27002c9fd32c282c8563b8b18f9bb5c24685
parent46555f851436764f203d2307711d4ca6900cdcb0 (diff)
downloadlibgphoto2-a3364e4b63ac684e7d6da5ef355fcd620bef4805.tar.gz
2001-10-23 Lutz M�ller <urc8@rz.uni-karlsruhe.de>
* libgphoto2/gphoto2-core.[c,h]: Removed. All functions redirected to gphoto2-abilities-list. Caching of this list should be done in the frontend. * frontends/command-line/main.c: Don't use gp_autodetect, use gp_abilities_list_detect instead. * libgphoto2/setting.c: Move some initialization stuff from gphoto2-core to here. git-svn-id: https://svn.code.sf.net/p/gphoto/code/trunk/libgphoto2@2705 67ed7778-7388-44ab-90cf-0a291f65f57c
-rw-r--r--ChangeLog9
-rw-r--r--camlibs/konica/library.c1
-rw-r--r--frontends/command-line/main.c17
-rw-r--r--include/gphoto2.h1
-rw-r--r--libgphoto2/Makefile.am2
-rw-r--r--libgphoto2/gphoto2-abilities-list.c1
-rw-r--r--libgphoto2/gphoto2-camera.c84
-rw-r--r--libgphoto2/gphoto2-core.c133
-rw-r--r--libgphoto2/gphoto2-core.h43
-rw-r--r--libgphoto2/gphoto2-filesys.c1
-rw-r--r--libgphoto2/jpeg.c1
-rw-r--r--libgphoto2/setting.c19
12 files changed, 60 insertions, 252 deletions
diff --git a/ChangeLog b/ChangeLog
index 7aba6f03a..dc53810a9 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,14 @@
2001-10-23 Lutz Müller <urc8@rz.uni-karlsruhe.de>
+ * libgphoto2/gphoto2-core.[c,h]: Removed. All functions redirected
+ to gphoto2-abilities-list. Caching of this list should be done
+ in the frontend.
+ * frontends/command-line/main.c: Don't use gp_autodetect.
+ * libgphoto2/setting.c: Move some initialization stuff from
+ gphoto2-core to here.
+
+2001-10-23 Lutz Müller <urc8@rz.uni-karlsruhe.de>
+
* camlibs: Remove every reference to gp_camera_result_as_string
including camera->functions->result_as_string. It was mostly
unused anyways.
diff --git a/camlibs/konica/library.c b/camlibs/konica/library.c
index f6204fed7..39d63ad90 100644
--- a/camlibs/konica/library.c
+++ b/camlibs/konica/library.c
@@ -27,7 +27,6 @@
#include <time.h>
#include <gphoto2-library.h>
-#include <gphoto2-core.h>
#include <gphoto2-debug.h>
#include <gphoto2-port-log.h>
diff --git a/frontends/command-line/main.c b/frontends/command-line/main.c
index dfe5e9b6f..10ee2678f 100644
--- a/frontends/command-line/main.c
+++ b/frontends/command-line/main.c
@@ -244,24 +244,23 @@ OPTION_CALLBACK(use_stdout_size) {
OPTION_CALLBACK (auto_detect)
{
int x, count;
- CameraList* list;
+ CameraList list;
+ CameraAbilitiesList *al;
const char *name, *value;
- CHECK_RESULT (gp_list_new (&list));
- CHECK_RESULT (gp_autodetect (list));
- CHECK_RESULT (count = gp_list_count (list));
+ gp_abilities_list_new (&al);
+ gp_abilities_list_load (al);
+ gp_abilities_list_detect (al, &list);
+ CHECK_RESULT (count = gp_list_count (&list));
printf("%-30s %-16s\n", "Model", "Port");
printf("----------------------------------------------------------\n");
for (x = 0; x < count; x++) {
- CHECK_RESULT (gp_list_get_name (list, x, &name));
- CHECK_RESULT (gp_list_get_value (list, x, &value));
+ CHECK_RESULT (gp_list_get_name (&list, x, &name));
+ CHECK_RESULT (gp_list_get_value (&list, x, &value));
printf("%-30s %-16s\n", name, value);
}
- /* We don't need to check for error here. */
- gp_list_free (list);
-
return GP_OK;
}
diff --git a/include/gphoto2.h b/include/gphoto2.h
index 7de63c8ae..39edb100c 100644
--- a/include/gphoto2.h
+++ b/include/gphoto2.h
@@ -33,7 +33,6 @@ extern "C" {
#include <gphoto2-port.h>
#include <gphoto2-camera.h>
-#include <gphoto2-core.h>
#include <gphoto2-debug.h>
#include <gphoto2-file.h>
#include <gphoto2-filesys.h>
diff --git a/libgphoto2/Makefile.am b/libgphoto2/Makefile.am
index d575f5a75..e80223385 100644
--- a/libgphoto2/Makefile.am
+++ b/libgphoto2/Makefile.am
@@ -10,7 +10,6 @@ libgphoto2_la_SOURCES = \
gphoto2-abilities-list.c\
bayer.c bayer.h \
gphoto2-camera.c \
- gphoto2-core.c \
gphoto2-debug.c \
exif.c exif.h \
gphoto2-file.c \
@@ -29,7 +28,6 @@ libgphoto2include_HEADERS = \
gphoto2-abilities.h \
gphoto2-abilities-list.h\
gphoto2-camera.h \
- gphoto2-core.h \
gphoto2-debug.h \
gphoto2-file.h \
gphoto2-filesys.h \
diff --git a/libgphoto2/gphoto2-abilities-list.c b/libgphoto2/gphoto2-abilities-list.c
index 903cca490..9f7ab3d1a 100644
--- a/libgphoto2/gphoto2-abilities-list.c
+++ b/libgphoto2/gphoto2-abilities-list.c
@@ -25,7 +25,6 @@
#include <stdio.h>
#include <string.h>
-#include "gphoto2-core.h"
#include "gphoto2-result.h"
#include "gphoto2-port-log.h"
#include "gphoto2-library.h"
diff --git a/libgphoto2/gphoto2-camera.c b/libgphoto2/gphoto2-camera.c
index affdc3096..f864ec5d1 100644
--- a/libgphoto2/gphoto2-camera.c
+++ b/libgphoto2/gphoto2-camera.c
@@ -30,7 +30,6 @@
#include <stdio.h>
#include "gphoto2-result.h"
-#include "gphoto2-core.h"
#include "gphoto2-library.h"
#include "gphoto2-port-core.h"
#include "gphoto2-port-log.h"
@@ -106,12 +105,6 @@ gp_camera_new (Camera **camera)
CHECK_NULL (camera);
- /*
- * Be nice to frontend-writers and call some core function to make
- * sure libgphoto2 is initialized...
- */
- CHECK_RESULT (gp_camera_count ());
-
*camera = malloc (sizeof (Camera));
if (!*camera)
return (GP_ERROR_NO_MEMORY);
@@ -143,33 +136,6 @@ gp_camera_new (Camera **camera)
return(GP_OK);
}
-/* DEPRECATED */
-int gp_camera_set_model (Camera *, const char *);
-int
-gp_camera_set_model (Camera *camera, const char *model)
-{
- CameraAbilities abilities;
-
- CHECK_NULL (camera && model);
-
- CHECK_RESULT (gp_camera_abilities_by_name (model, &abilities));
- CHECK_RESULT (gp_camera_set_abilities (camera, abilities));
-
- return (GP_OK);
-}
-
-/* DEPRECATED */
-int gp_camera_get_model (Camera *, const char **);
-int
-gp_camera_get_model (Camera *camera, const char **model)
-{
- CHECK_NULL (camera && model);
-
- *model = camera->pc->a.model;
-
- return (GP_OK);
-}
-
/**
* gp_camera_set_abilities:
* @camera: a #Camera
@@ -724,40 +690,50 @@ gp_camera_init (Camera *camera)
*/
if (strcasecmp (camera->pc->a.model, "Directory Browse") &&
!strcmp ("", camera->pc->a.model)) {
+ CameraAbilitiesList *al;
+ int m;
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));
+ gp_abilities_list_new (&al);
+ gp_abilities_list_load (al);
+ gp_abilities_list_detect (al, &list);
if (!gp_list_count (&list)) {
- gp_log (GP_LOG_ERROR, "gphoto2-camera", _("Could not "
- "detect any camera"));
+ gp_abilities_list_free (al);
+ gp_camera_set_error (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));
+ gp_list_get_name (&list, 0, &model);
+ m = gp_abilities_list_lookup_model (al, model);
+ gp_abilities_list_get_abilities (al, m, &a);
+ gp_abilities_list_free (al);
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 (strcasecmp (camera->pc->a.model, "Directory Browse")) {
+
+ /* 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. */
diff --git a/libgphoto2/gphoto2-core.c b/libgphoto2/gphoto2-core.c
deleted file mode 100644
index a3a838f66..000000000
--- a/libgphoto2/gphoto2-core.c
+++ /dev/null
@@ -1,133 +0,0 @@
-/* gphoto2-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 <config.h>
-#include "gphoto2-core.h"
-
-#include <stdlib.h>
-#include <stdarg.h>
-#include <stdio.h>
-
-#include "gphoto2-abilities.h"
-#include "gphoto2-setting.h"
-#include "gphoto2-result.h"
-#include "gphoto2-abilities-list.h"
-#include "gphoto2-camera.h"
-#include "gphoto2-debug.h"
-
-#define CHECK_NULL(r) {if (!(r)) return (GP_ERROR_BAD_PARAMETERS);}
-#define CHECK_RESULT(result) {int r = (result); if (r < 0) return (r);}
-#define CHECK_INIT {if (!gal) CHECK_RESULT (gp_init ());}
-
-/* Camera List */
-CameraAbilitiesList *gal = NULL;
-
-static int
-gp_init (void)
-{
- char buf[1024];
- int count;
-
- gp_debug_printf (GP_DEBUG_LOW, "core", "Initializing GPhoto...");
-
- /* Check if we are already initialized */
- if (gal)
- return (GP_OK);
-
- /* Make sure the directories are created */
- gp_debug_printf (GP_DEBUG_LOW, "core", "Creating $HOME/.gphoto");
-#ifdef WIN32
- GetWindowsDirectory (buf, 1024);
- strcat (buf, "\\gphoto");
-#else
- sprintf (buf, "%s/.gphoto", getenv ("HOME"));
-#endif
- (void)GP_SYSTEM_MKDIR (buf);
-
- /* Load settings */
- gp_debug_printf (GP_DEBUG_LOW, "core", "Trying to load settings...");
- load_settings();
-
- /* What cameras do we support? */
- CHECK_RESULT (gp_abilities_list_new (&gal));
- CHECK_RESULT (gp_abilities_list_load (gal));
-
- gp_debug_printf (GP_DEBUG_LOW, "core", "Following cameras were found:");
- CHECK_RESULT (count = gp_abilities_list_count (gal));
- if (count)
- gp_abilities_list_dump_libs (gal);
- else
- gp_debug_printf (GP_DEBUG_LOW, "core","\tNone");
-
- return (GP_OK);
-}
-
-int
-gp_exit (void)
-{
- CHECK_RESULT (gp_abilities_list_free (gal));
- gal = NULL;
-
- return (GP_OK);
-}
-
-int
-gp_autodetect (CameraList *list)
-{
- CHECK_INIT;
-
- return (gp_abilities_list_detect (gal, list));
-}
-
-int
-gp_camera_count (void)
-{
- CHECK_INIT;
-
- return (gp_abilities_list_count (gal));
-}
-
-int
-gp_camera_name (int camera_number, const char **camera_name)
-{
- CHECK_INIT;
-
- return (gp_abilities_list_get_model (gal, camera_number, camera_name));
-}
-
-int
-gp_camera_abilities (int camera_number, CameraAbilities *abilities)
-{
- CHECK_INIT;
-
- return (gp_abilities_list_get_abilities (gal, camera_number,abilities));
-}
-
-int
-gp_camera_abilities_by_name (const char *camera_name,
- CameraAbilities *abilities)
-{
- int x;
-
- CHECK_INIT;
-
- CHECK_RESULT (x = gp_abilities_list_lookup_model (gal, camera_name));
- return (gp_camera_abilities (x, abilities));
-}
diff --git a/libgphoto2/gphoto2-core.h b/libgphoto2/gphoto2-core.h
deleted file mode 100644
index f183580fe..000000000
--- a/libgphoto2/gphoto2-core.h
+++ /dev/null
@@ -1,43 +0,0 @@
-/* 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.
- */
-
-#ifndef __GPHOTO2_CORE_H__
-#define __GPHOTO2_CORE_H__
-
-#include <gphoto2-list.h>
-#include <gphoto2-abilities.h>
-
-/* Initialization is done automatically. */
-int gp_exit (void);
-
-int gp_autodetect (CameraList *list);
-
-/* Retrieve the number of available cameras */
-int gp_camera_count (void);
-
-/* Retrieve the name of a particular camera */
-int gp_camera_name (int camera_number, const char **camera_name);
-
-/* Retreive abilities for a given camera */
-int gp_camera_abilities (int camera_number, CameraAbilities *abilities);
-int gp_camera_abilities_by_name (const char *camera_name,
- CameraAbilities *abilities);
-
-#endif /* __GPHOTO2_CORE_H__ */
diff --git a/libgphoto2/gphoto2-filesys.c b/libgphoto2/gphoto2-filesys.c
index 0eec8a373..e9c40ed4c 100644
--- a/libgphoto2/gphoto2-filesys.c
+++ b/libgphoto2/gphoto2-filesys.c
@@ -27,7 +27,6 @@
#include <string.h>
#include <stdio.h>
-#include "gphoto2-core.h"
#include "gphoto2-result.h"
#include "gphoto2-file.h"
#include "gphoto2-port-log.h"
diff --git a/libgphoto2/jpeg.c b/libgphoto2/jpeg.c
index f18ebf114..8708f1e5a 100644
--- a/libgphoto2/jpeg.c
+++ b/libgphoto2/jpeg.c
@@ -21,7 +21,6 @@
#include <stdlib.h>
#include <string.h>
#include <gphoto2-library.h>
-#include <gphoto2-core.h>
#include "jpeg.h"
// call example:nullpictureabort(picture,"Picture");
diff --git a/libgphoto2/setting.c b/libgphoto2/setting.c
index 25c142b21..549c529c9 100644
--- a/libgphoto2/setting.c
+++ b/libgphoto2/setting.c
@@ -25,8 +25,8 @@
#include <string.h>
#include "gphoto2-result.h"
-#include "gphoto2-core.h"
#include "gphoto2-debug.h"
+#include "gphoto2-port.h"
typedef struct {
/* key = value settings */
@@ -50,11 +50,8 @@ int gp_setting_get (char *id, char *key, char *value)
CHECK_NULL (id && key);
- /*
- * Be nice to frontend writers and make sure libgphoto2 is
- * initialized
- */
- CHECK_RESULT (gp_camera_count ());
+ if (!glob_setting_count)
+ load_settings ();
for (x=0; x<glob_setting_count; x++) {
if ((strcmp(glob_setting[x].id, id)==0) &&
@@ -133,6 +130,16 @@ int load_settings (void)
FILE *f;
char buf[1024], *id, *key, *value;
+ /* Make sure the directories are created */
+ gp_debug_printf (GP_DEBUG_LOW, "core", "Creating $HOME/.gphoto");
+#ifdef WIN32
+ GetWindowsDirectory (buf, 1024);
+ strcat (buf, "\\gphoto");
+#else
+ sprintf (buf, "%s/.gphoto", getenv ("HOME"));
+#endif
+ (void)GP_SYSTEM_MKDIR (buf);
+
glob_setting_count = 0;
#ifdef WIN32
GetWindowsDirectory(buf, 1024);