summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--camlibs/barbie/barbie.c14
-rw-r--r--camlibs/directory/directory.c21
-rw-r--r--camlibs/fujitsu/fujitsu.c13
-rw-r--r--frontends/command-line/main.c23
-rw-r--r--include/gphoto2-core.h11
-rw-r--r--include/gphoto2-datatypes.h11
-rw-r--r--include/gphoto2-library.h55
-rw-r--r--libgphoto2/core.c33
-rw-r--r--libgphoto2/core.h12
-rw-r--r--libgphoto2/library.c5
10 files changed, 77 insertions, 121 deletions
diff --git a/camlibs/barbie/barbie.c b/camlibs/barbie/barbie.c
index 921016547..ed029a393 100644
--- a/camlibs/barbie/barbie.c
+++ b/camlibs/barbie/barbie.c
@@ -326,19 +326,13 @@ int camera_close() {
return GP_OK;
}
-int camera_folder_count () {
+int camera_folder_list (char *folder_name, CameraFolderList *list) {
- return 1;
-}
-
-int camera_folder_name (int folder_number, char *folder_name) {
-
- strcpy(folder_name, glob_camera_model);
- return GP_OK;
+ return GP_ERROR;
}
-int camera_folder_set (int folder_number) {
+int camera_folder_set (char *folder_name) {
return GP_OK;
}
@@ -419,7 +413,7 @@ int camera_file_unlock (int file_number) {
return GP_ERROR;
}
-int camera_config_set (CameraConfig *conf) {
+int camera_config (CameraConfig *config, int config_count) {
return GP_OK;
}
diff --git a/camlibs/directory/directory.c b/camlibs/directory/directory.c
index ef77b1fd4..7b5b3b31b 100644
--- a/camlibs/directory/directory.c
+++ b/camlibs/directory/directory.c
@@ -60,8 +60,7 @@ int camera_init (CameraInit *init) {
strcpy(dir_directory, init->port_settings.directory_path);
if (strlen(dir_directory)==0) {
- gp_set_setting("dir_directory", getenv("HOME"));
- strcpy(dir_directory, getenv("HOME"));
+ strcpy(dir_directory, "/");
}
return (GP_OK);
@@ -84,27 +83,19 @@ int camera_close () {
return (GP_OK);
}
-int camera_folder_count (int *count) {
+int camera_folder_list(char *folder_name, CameraFolderList *list) {
- return (1);
-}
-
-int camera_folder_name(int folder_number, char *folder_name) {
-
- gp_get_setting("dir_directory", dir_directory);
- strcpy(folder_name, dir_directory);
-
- return (GP_OK);
+ return (GP_ERROR);
}
-int camera_folder_set(int folder_number) {
+int camera_folder_set(char *folder_name) {
DIR *dir;
struct dirent *de;
struct stat s;
char *dot, fname[1024];
- gp_get_setting("dir_directory", dir_directory);
+ strcpy(dir_directory, folder_name);
dir = opendir(dir_directory);
if (!dir) {
perror("directory: folder_set");
@@ -208,7 +199,7 @@ int camera_file_unlock (int file_number) {
return (GP_ERROR);
}
-int camera_config_set (CameraConfig *conf) {
+int camera_config (CameraConfig *config, int config_count) {
return (GP_ERROR);
}
diff --git a/camlibs/fujitsu/fujitsu.c b/camlibs/fujitsu/fujitsu.c
index ff54cff6c..a513af95b 100644
--- a/camlibs/fujitsu/fujitsu.c
+++ b/camlibs/fujitsu/fujitsu.c
@@ -92,17 +92,12 @@ int camera_close () {
return (GP_OK);
}
-int camera_folder_count (int *count) {
+int camera_folder_list(char *folder_name, CameraFolderList *list) {
- return (0);
-}
-
-int camera_folder_name(int folder_number, char *folder_name) {
-
- return (GP_OK);
+ return (GP_ERROR);
}
-int camera_folder_set(int folder_number) {
+int camera_folder_set(char *folder_name) {
return (GP_OK);
}
@@ -145,7 +140,7 @@ int camera_file_unlock (int file_number) {
return (GP_ERROR);
}
-int camera_config_set (CameraConfig *conf) {
+int camera_config (CameraConfig *config, int config_count) {
return (GP_ERROR);
}
diff --git a/frontends/command-line/main.c b/frontends/command-line/main.c
index 88a5924ac..2ef5d5f23 100644
--- a/frontends/command-line/main.c
+++ b/frontends/command-line/main.c
@@ -65,29 +65,10 @@ int main (int argc, char **argv) {
if (gp_camera_abilities(&a) == GP_ERROR)
printf("cli: (ERROR) camera_abilities error!\n");
- /* --------------------------------------- */
- /* Get the number of folders on the camera */
- /* --------------------------------------- */
- n = gp_folder_count();
- if (n == GP_ERROR)
- printf("cli: (ERROR) folder_count error!\n");
-#ifdef DEBUG
- printf("cli: Number of folders: %i\n", n);
-#endif
-
- /* ------------------------------------ */
- /* Get the names of each of the folders */
- /* ------------------------------------ */
- for (x=0; x<n; x++) {
- gp_folder_name(x, buf);
-#ifdef DEBUG
- printf("cli: Folder #%i name: %s\n", x, buf);
-#endif
- }
/* ------------------------------- */
/* Set the currently active folder */
/* ------------------------------- */
- if (gp_folder_set(0) == GP_ERROR)
+ if (gp_folder_set("/") == GP_ERROR)
printf("Can't set folder!\n");
/* ----------------------------------------- */
@@ -97,7 +78,7 @@ int main (int argc, char **argv) {
if (m == GP_ERROR)
printf("cli: (ERROR) file_count error!\n");
#ifdef DEBUG
- printf("cli: Number of files in folder #%i: %i\n", n, m);
+ printf("cli: Number of files: %i\n", n);
#endif
/* ------------------------------- */
diff --git a/include/gphoto2-core.h b/include/gphoto2-core.h
index 2bcd5b647..cc561d746 100644
--- a/include/gphoto2-core.h
+++ b/include/gphoto2-core.h
@@ -42,14 +42,11 @@
int gp_camera_close ();
/* Folder operations */
- /* Retrieve the number of folders on the camera */
- int gp_folder_count ();
-
- /* Retrieve the name of a particular folder */
- int gp_folder_name (int folder_number, char *folder_name);
+ /* Retrieve the contents of a folder */
+ int gp_folder_list(char *folder_path, CameraFolderList *list);
/* Set the current folder */
- int gp_folder_set (int folder_number);
+ int gp_folder_set (char *folder_path);
/* File operations */
/* Retrieve the number of files in the current folder */
@@ -114,7 +111,7 @@
*/
/* Send "key=value" pairs to the library, delimited by '\n' */
- int gp_config_set (char *config_settings);
+ int gp_config_set (CameraConfig *config, int config_count);
/* Miscellaneous functions */
/* Captures the current view. Basically, it takes a picture */
diff --git a/include/gphoto2-datatypes.h b/include/gphoto2-datatypes.h
index 29d46264d..d344daec6 100644
--- a/include/gphoto2-datatypes.h
+++ b/include/gphoto2-datatypes.h
@@ -111,12 +111,15 @@ typedef struct {
} CameraFile;
typedef struct {
- char name[128];
- int parent;
-} CameraFolder;
+ char name[128];
+} CameraFolderInfo;
+
+typedef struct {
+ int count;
+ CameraFolderInfo info[512];
+} CameraFolderList;
typedef struct {
char *name;
char *value;
} CameraConfig;
-
diff --git a/include/gphoto2-library.h b/include/gphoto2-library.h
index 201fbebd3..905693e98 100644
--- a/include/gphoto2-library.h
+++ b/include/gphoto2-library.h
@@ -1,52 +1,61 @@
/* All return values are either GP_OK, or a GP_ERROR variation */
-int camera_id (char *id);
+int camera_id (char *id);
/* Copies a unique library ID into 'id' */
/* This is used to uniquely identify a library so that */
/* multiple libraries can support the same camera. */
/* The id is limited to 64 characters. */
-int camera_abilities (CameraAbilities *abilities, int *count);
+int camera_abilities (CameraAbilities *abilities,
+ int *count);
/* Returns the camera abilities for all the cameras */
/* that the library supports. The value of */
/* 'count' should be set to the number of cameras the */
/* library supports. */
-int camera_init (CameraInit *init);
+int camera_init (CameraInit *init);
/* Initializes the library for use. Library uses the */
/* information in 'init' to determine what options the */
/* the user has chosen. */
-int camera_exit ();
+int camera_exit ();
/* Called when library is being closed or another */
/* camera model (possibly from the same library) has */
/* been chosen. */
-int camera_open ();
+int camera_open ();
/* Opens the camera for use. */
-int camera_close ();
+int camera_close ();
/* Closes the camera after use. */
-int camera_folder_count ();
- /* Returns the number of folders on the camera. */
+int camera_folder_list (char *folder_path,
+ CameraFolderList *folder);
+ /* Returns a list of sub-folders from the 'folder_name' */
+ /* folder. The first call should be with folder_name */
+ /* set to "/" to get a listing of all the top-level */
+ /* top-level folders. If a folder has pictures in it, */
+ /* one of the entries in the list should be "<gphotos>" */
-int camera_folder_info(int folder_number, CameraFolder *folder);
- /* Returns information about a particular folder on the */
- /* camera. */
+int camera_folder_set (char *folder_path);
-int camera_folder_set(int folder_number);
+int camera_file_count ();
-int camera_file_count ();
-int camera_file_get (int file_number, CameraFile *file);
-int camera_file_get_preview (int file_number, CameraFile *preview);
-int camera_file_delete (int file_number);
+int camera_file_get (int file_number,
+ CameraFile *file);
-int camera_file_lock (int file_number);
-int camera_file_unlock (int file_number);
+int camera_file_get_preview (int file_number,
+ CameraFile *preview);
-int camera_config_set (CameraConfig *conf);
-int camera_capture (int type);
-int camera_summary (char *summary);
-int camera_manual (char *manual);
-int camera_about (char *about);
+int camera_file_delete (int file_number);
+
+int camera_file_lock (int file_number);
+int camera_file_unlock (int file_number);
+
+int camera_config (CameraConfig *conf, int conf_count);
+
+int camera_capture (int type);
+
+int camera_summary (char *summary);
+int camera_manual (char *manual);
+int camera_about (char *about);
diff --git a/libgphoto2/core.c b/libgphoto2/core.c
index d544ee69a..67aefa5e1 100644
--- a/libgphoto2/core.c
+++ b/libgphoto2/core.c
@@ -23,10 +23,10 @@
/* Currently Selected camera/folder */
/* ------------------------------------------------ */
- /* currently selected folder number */
- int glob_folder_number;
/* currently selected camera number */
int glob_camera_number;
+ /* currently selected folder path */
+ char glob_folder_path[512];
/* Camera List */
/* ------------------------------------------------ */
@@ -69,7 +69,7 @@ int gp_init () {
glob_camera_count = 0;
glob_setting_count = 0;
glob_library_handle = NULL;
- glob_folder_number = 0;
+ strcpy(glob_folder_path, "/");
glob_camera_id_count = 0;
for(x=0; x<512; x++)
@@ -205,30 +205,19 @@ int gp_camera_close () {
return(glob_c.close());
}
-int gp_folder_count () {
+int gp_folder_list(char *folder_path, CameraFolderList *list) {
- if (glob_c.folder_count == NULL)
- return(GP_ERROR);
-
- return(glob_c.folder_count());
-}
-
-int gp_folder_name (int folder_number, char *folder_name) {
-
- if (glob_c.folder_name == NULL)
- return (GP_ERROR);
-
- return(glob_c.folder_name(folder_number, folder_name));
+ return (GP_OK);
}
-int gp_folder_set (int folder_number) {
+int gp_folder_set (char *folder_path) {
if (glob_c.folder_set == NULL)
return (GP_ERROR);
- if (glob_c.folder_set(folder_number) == GP_ERROR)
+ if (glob_c.folder_set(folder_path) == GP_ERROR)
return (GP_ERROR);
- glob_folder_number = folder_number;
+ strcpy(glob_folder_path, folder_path);
return(GP_OK);
}
@@ -285,12 +274,12 @@ int gp_config_get (char *config_dialog_filename) {
return(GP_OK);
}
-int gp_config_set (char *config_settings) {
+int gp_config_set (CameraConfig *config, int config_count) {
- if (glob_c.config_set == NULL)
+ if (glob_c.config == NULL)
return (GP_ERROR);
- return(glob_c.config_set(config_settings));
+ return(glob_c.config(config, config_count));
}
int gp_capture (int type) {
diff --git a/libgphoto2/core.h b/libgphoto2/core.h
index 3a9f561f3..36285a3db 100644
--- a/libgphoto2/core.h
+++ b/libgphoto2/core.h
@@ -19,16 +19,15 @@ typedef int (*c_init) ();
typedef int (*c_exit) ();
typedef int (*c_open) ();
typedef int (*c_close) ();
-typedef int (*c_folder_count) ();
-typedef int (*c_folder_name) (int, char*);
-typedef int (*c_folder_set) (int);
+typedef int (*c_folder_list) (char*,CameraFolderList*);
+typedef int (*c_folder_set) (char*);
typedef int (*c_file_count) ();
typedef int (*c_file_get) (int, CameraFile*);
typedef int (*c_file_get_preview)(int, CameraFile*);
typedef int (*c_file_delete) (int);
typedef int (*c_file_lock) (int);
typedef int (*c_file_unlock) (int);
-typedef int (*c_config_set) (char*);
+typedef int (*c_config) (CameraConfig*, int);
typedef int (*c_capture) (int);
typedef int (*c_summary) (char*);
typedef int (*c_manual) (char*);
@@ -43,8 +42,7 @@ typedef struct {
c_exit exit;
c_open open;
c_close close;
- c_folder_count folder_count;
- c_folder_name folder_name;
+ c_folder_list folder_list;
c_folder_set folder_set;
c_file_count file_count;
c_file_get file_get;
@@ -52,7 +50,7 @@ typedef struct {
c_file_delete file_delete;
c_file_lock file_lock;
c_file_unlock file_unlock;
- c_config_set config_set;
+ c_config config;
c_capture capture;
c_summary summary;
c_manual manual;
diff --git a/libgphoto2/library.c b/libgphoto2/library.c
index 415f536da..65cf4c402 100644
--- a/libgphoto2/library.c
+++ b/libgphoto2/library.c
@@ -51,8 +51,7 @@ int load_library (char *camera_name) {
glob_c.exit = dlsym(lh, "camera_exit");
glob_c.open = dlsym(lh, "camera_open");
glob_c.close = dlsym(lh, "camera_close");
- glob_c.folder_count = dlsym(lh, "camera_folder_count");
- glob_c.folder_name = dlsym(lh, "camera_folder_name");
+ glob_c.folder_list = dlsym(lh, "camera_folder_list");
glob_c.folder_set = dlsym(lh, "camera_folder_set");
glob_c.file_count = dlsym(lh, "camera_file_count");
glob_c.file_get = dlsym(lh, "camera_file_get");
@@ -60,7 +59,7 @@ int load_library (char *camera_name) {
glob_c.file_delete = dlsym(lh, "camera_file_delete");
glob_c.file_lock = dlsym(lh, "camera_file_lock");
glob_c.file_unlock = dlsym(lh, "camera_file_unlock");
- glob_c.config_set = dlsym(lh, "camera_config_set");
+ glob_c.config = dlsym(lh, "camera_config");
glob_c.capture = dlsym(lh, "camera_capture");
glob_c.summary = dlsym(lh, "camera_summary");
glob_c.manual = dlsym(lh, "camera_manual");