libgphoto2 (libgphoto2): libgphoto2/gphoto2-filesys.h Source File

Main Page | Data Structures | Directories | File List | Data Fields | Globals | Related Pages

# gphoto2-filesys.h

    00001 /* gphoto2-filesys.h
    00002  *
    00003  * Copyright © 2000 Scott Fritzinger
    00004  *
    00005  * Contributions:
    00006  *      Lutz Müller <lutz@users.sf.net> (2001)
    00007  *
    00008  * This library is free software; you can redistribute it and/or
    00009  * modify it under the terms of the GNU Lesser General Public
    00010  * License as published by the Free Software Foundation; either
    00011  * version 2 of the License, or (at your option) any later version.
    00012  *
    00013  * This library is distributed in the hope that it will be useful,
    00014  * but WITHOUT ANY WARRANTY; without even the implied warranty of
    00015  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    00016  * Lesser General Public License for more details.
    00017  *
    00018  * You should have received a copy of the GNU Lesser General Public
    00019  * License along with this library; if not, write to the
    00020  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
    00021  * Boston, MA 02111-1307, USA.
    00022  */
    00023
    00024 #ifndef __GPHOTO2_FILESYS_H__
    00025 #define __GPHOTO2_FILESYS_H__
    00026
    00027 #include <time.h>
    00028
    00029 #include <gphoto2-context.h>
    00030 #include <gphoto2-list.h>
    00031 #include <gphoto2-file.h>
    00032
    00033 #ifdef __cplusplus
    00034 extern "C" {
    00035 #endif /* __cplusplus */
    00036
    00037 typedef enum {
    00038         GP_FILE_INFO_NONE            = 0,
    00039         GP_FILE_INFO_TYPE            = 1 << 0,
    00040         GP_FILE_INFO_NAME            = 1 << 1,
    00041         GP_FILE_INFO_SIZE            = 1 << 2,
    00042         GP_FILE_INFO_WIDTH           = 1 << 3,
    00043         GP_FILE_INFO_HEIGHT          = 1 << 4,
    00044         GP_FILE_INFO_PERMISSIONS     = 1 << 5,
    00045         GP_FILE_INFO_STATUS          = 1 << 6,
    00046         GP_FILE_INFO_MTIME           = 1 << 7,
    00047         GP_FILE_INFO_ALL             = 0xFF
    00048 } CameraFileInfoFields;
    00049
    00050 typedef enum {
    00051         GP_FILE_PERM_NONE       = 0,
    00052         GP_FILE_PERM_READ       = 1 << 0,
    00053         GP_FILE_PERM_DELETE     = 1 << 1,
    00054         GP_FILE_PERM_ALL        = 0xFF
    00055 } CameraFilePermissions;
    00056
    00057 typedef enum {
    00058         GP_FILE_STATUS_NOT_DOWNLOADED,
    00059         GP_FILE_STATUS_DOWNLOADED
    00060 } CameraFileStatus;
    00061
    00062 typedef struct _CameraFileInfoFile CameraFileInfoFile;
    00063 struct _CameraFileInfoFile {
    00064         CameraFileInfoFields fields;
    00065         CameraFileStatus status;
    00066         unsigned long size;
    00067         char type[64];
    00068
    00069         unsigned int width, height;
    00070         char name[64];
    00071         CameraFilePermissions permissions;
    00072         time_t mtime;
    00073 };
    00074
    00075 typedef struct _CameraFileInfoPreview CameraFileInfoPreview;
    00076 struct _CameraFileInfoPreview {
    00077         CameraFileInfoFields fields;
    00078         CameraFileStatus status;
    00079         unsigned long size;
    00080         char type[64];
    00081
    00082         unsigned int width, height;
    00083 };
    00084
    00085 typedef struct _CameraFileInfoAudio CameraFileInfoAudio;
    00086 struct _CameraFileInfoAudio {
    00087         CameraFileInfoFields fields;
    00088         CameraFileStatus status;
    00089         unsigned long size;
    00090         char type[64];
    00091 };
    00092
    00093 typedef struct _CameraFileInfo CameraFileInfo;
    00094 struct _CameraFileInfo {
    00095         CameraFileInfoPreview preview;
    00096         CameraFileInfoFile    file;
    00097         CameraFileInfoAudio   audio;
    00098 };
    00099
    00100 /* You don't really want to know what's inside, do you? */
    00101 typedef struct _CameraFilesystem CameraFilesystem;
    00102
    00103 int gp_filesystem_new    (CameraFilesystem **fs);
    00104 int gp_filesystem_free   (CameraFilesystem *fs);
    00105
    00106 /* Manual editing */
    00107 int gp_filesystem_append           (CameraFilesystem *fs, const char *folder,
    00108                                     const char *filename, GPContext *context);
    00109 int gp_filesystem_set_info_noop    (CameraFilesystem *fs, const char *folder,
    00110                                     CameraFileInfo info, GPContext *context);
    00111 int gp_filesystem_set_file_noop    (CameraFilesystem *fs, const char *folder,
    00112                                     CameraFile *file, GPContext *context);
    00113 int gp_filesystem_delete_file_noop (CameraFilesystem *fs, const char *folder,
    00114                                     const char *filename, GPContext *context);
    00115 int gp_filesystem_reset            (CameraFilesystem *fs);
    00116
    00117 /* Information retrieval */
    00118 int gp_filesystem_count        (CameraFilesystem *fs, const char *folder,
    00119                                 GPContext *context);
    00120 int gp_filesystem_name         (CameraFilesystem *fs, const char *folder,
    00121                                 int filenumber, const char **filename,
    00122                                 GPContext *context);
    00123 int gp_filesystem_get_folder   (CameraFilesystem *fs, const char *filename,
    00124                                 const char **folder, GPContext *context);
    00125 int gp_filesystem_number       (CameraFilesystem *fs, const char *folder,
    00126                                 const char *filename, GPContext *context);
    00127
    00128 /* Listings */
    00129 typedef int (*CameraFilesystemListFunc) (CameraFilesystem *fs,
    00130                                          const char *folder, CameraList *list,
    00131                                          void *data, GPContext *context);
    00132 int gp_filesystem_set_list_funcs (CameraFilesystem *fs,
    00133                                   CameraFilesystemListFunc file_list_func,
    00134                                   CameraFilesystemListFunc folder_list_func,
    00135                                   void *data);
    00136 int gp_filesystem_list_files     (CameraFilesystem *fs, const char *folder,
    00137                                   CameraList *list, GPContext *context);
    00138 int gp_filesystem_list_folders   (CameraFilesystem *fs, const char *folder,
    00139                                   CameraList *list, GPContext *context);
    00140
    00141 /* File information */
    00142 typedef int (*CameraFilesystemSetInfoFunc) (CameraFilesystem *fs,
    00143                                             const char *folder,
    00144                                             const char *filename,
    00145                                             CameraFileInfo info, void *data,
    00146                                             GPContext *context);
    00147 typedef int (*CameraFilesystemGetInfoFunc) (CameraFilesystem *fs,
    00148                                             const char *folder,
    00149                                             const char *filename,
    00150                                             CameraFileInfo *info, void *data,
    00151                                             GPContext *context);
    00152 int gp_filesystem_set_info_funcs (CameraFilesystem *fs,
    00153                                   CameraFilesystemGetInfoFunc get_info_func,
    00154                                   CameraFilesystemSetInfoFunc set_info_func,
    00155                                   void *data);
    00156 int gp_filesystem_get_info       (CameraFilesystem *fs, const char *folder,
    00157                                   const char *filename, CameraFileInfo *info,
    00158                                   GPContext *context);
    00159 int gp_filesystem_set_info       (CameraFilesystem *fs, const char *folder,
    00160                                   const char *filename, CameraFileInfo info,
    00161                                   GPContext *context);
    00162
    00163 /* Files */
    00164 typedef int (*CameraFilesystemGetFileFunc)    (CameraFilesystem *fs,
    00165                                                const char *folder,
    00166                                                const char *filename,
    00167                                                CameraFileType type,
    00168                                                CameraFile *file, void *data,
    00169                                                GPContext *context);
    00170 typedef int (*CameraFilesystemDeleteFileFunc) (CameraFilesystem *fs,
    00171                                                const char *folder,
    00172                                                const char *filename,
    00173                                                void *data, GPContext *context);
    00174 int gp_filesystem_set_file_funcs (CameraFilesystem *fs,
    00175                                   CameraFilesystemGetFileFunc get_file_func,
    00176                                   CameraFilesystemDeleteFileFunc del_file_func,
    00177                                   void *data);
    00178 int gp_filesystem_get_file       (CameraFilesystem *fs, const char *folder,
    00179                                   const char *filename, CameraFileType type,
    00180                                   CameraFile *file, GPContext *context);
    00181 int gp_filesystem_delete_file    (CameraFilesystem *fs, const char *folder,
    00182                                   const char *filename, GPContext *context);
    00183
    00184 /* Folders */
    00185 typedef int (*CameraFilesystemPutFileFunc)   (CameraFilesystem *fs,
    00186                                               const char *folder,
    00187                                               CameraFile *file, void *data,
    00188                                               GPContext *context);
    00189 typedef int (*CameraFilesystemDeleteAllFunc) (CameraFilesystem *fs,
    00190                                               const char *folder, void *data,
    00191                                               GPContext *context);
    00192 typedef int (*CameraFilesystemDirFunc)       (CameraFilesystem *fs,
    00193                                               const char *folder,
    00194                                               const char *name, void *data,
    00195                                               GPContext *context);
    00196 int gp_filesystem_set_folder_funcs (CameraFilesystem *fs,
    00197                                   CameraFilesystemPutFileFunc put_file_func,
    00198                                   CameraFilesystemDeleteAllFunc delete_all_func,
    00199                                   CameraFilesystemDirFunc make_dir_func,
    00200                                   CameraFilesystemDirFunc remove_dir_func,
    00201                                   void *data);
    00202
    00203 typedef struct _CameraFilesystemFuncs CameraFilesystemFuncs;
    00204 struct _CameraFilesystemFuncs {
    00205         CameraFilesystemListFunc        file_list_func;
    00206         CameraFilesystemListFunc        folder_list_func;
    00207         CameraFilesystemPutFileFunc     put_file_func;
    00208         CameraFilesystemDeleteAllFunc   delete_all_func;
    00209         CameraFilesystemGetInfoFunc     get_info_func;
    00210         CameraFilesystemSetInfoFunc     set_info_func;
    00211         CameraFilesystemDirFunc         make_dir_func;
    00212         CameraFilesystemDirFunc         remove_dir_func;
    00213         CameraFilesystemGetFileFunc     get_file_func;
    00214         CameraFilesystemDeleteFileFunc  del_file_func;
    00215
    00216         /* for later use. Remove one if you add a new function */
    00217         void                            *unused[32];
    00218 };
    00219 int gp_filesystem_set_funcs     (CameraFilesystem *fs,
    00220                                  CameraFilesystemFuncs *funcs,
    00221                                  void *data);
    00222 int gp_filesystem_put_file   (CameraFilesystem *fs, const char *folder,
    00223                               CameraFile *file, GPContext *context);
    00224 int gp_filesystem_delete_all (CameraFilesystem *fs, const char *folder,
    00225                               GPContext *context);
    00226 int gp_filesystem_make_dir   (CameraFilesystem *fs, const char *folder,
    00227                               const char *name, GPContext *context);
    00228 int gp_filesystem_remove_dir (CameraFilesystem *fs, const char *folder,
    00229                               const char *name, GPContext *context);
    00230
    00231 /* For debugging */
    00232 int gp_filesystem_dump         (CameraFilesystem *fs);
    00233
    00234 #ifdef __cplusplus
    00235 }
    00236 #endif /* __cplusplus */
    00237
    00238 #endif /* __GPHOTO2_FILESYS_H__ */