Debian Codegraph @

camlibs/toshiba/pdrm11/library.c

raw
1 /* library.c -- copied from the template
2 *
3 * Copyright 2003 David Hogue <[email protected]>
4 *
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2 of the License, or (at your option) any later version.
9 *
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
14 *
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the
17 * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18 * Boston, MA 02110-1301 USA
19 */
20
21 #include "config.h"
22 #include "pdrm11.h"
23
24 #include <stdint.h>
25 #include <string.h>
26
27 #include <gphoto2/gphoto2.h>
28
29 #include "libgphoto2/i18n.h"
30
31
32 #define GP_MODULE "Toshiba"
33
34 int
35 camera_id (CameraText *id)
36 {
37 strcpy(id->text, "toshiba-pdrm11");
38
39 return (GP_OK);
40 }
41
42
43 int
44 camera_abilities (CameraAbilitiesList *list)
45 {
46 CameraAbilities a;
47
48 memset(&a, 0, sizeof(a));
49 strcpy(a.model, "Toshiba:PDR-M11");
50 a.status = GP_DRIVER_STATUS_TESTING;
51 a.port = GP_PORT_USB;
52 a.speed[0] = 0;
53 a.usb_vendor = 0x1132;
54 a.usb_product = 0x4337;
55 a.operations = GP_OPERATION_NONE;
56 a.file_operations = GP_FILE_OPERATION_DELETE |
57 GP_FILE_OPERATION_PREVIEW;
58 a.folder_operations = GP_FOLDER_OPERATION_NONE;
59
60 gp_abilities_list_append(list, a);
61
62 return (GP_OK);
63 }
64
65
66 static int
67 camera_exit (Camera *camera, GPContext *context)
68 {
69 return (GP_OK);
70 }
71
72
73 static int
74 get_file_func (CameraFilesystem *fs, const char *folder, const char *filename,
75 CameraFileType type, CameraFile *file, void *data,
76 GPContext *context)
77 {
78 int picNum;
79 Camera *camera = data;
80
81 switch(type){
82 case GP_FILE_TYPE_PREVIEW:
83 case GP_FILE_TYPE_NORMAL:
84 picNum = gp_filesystem_number(fs, folder, filename, context) + 1;
85 return pdrm11_get_file (fs, filename, type, file, camera->port, picNum);
86 default:
87 return GP_ERROR_NOT_SUPPORTED;
88 }
89 }
90
91
92 static int
93 delete_file_func (CameraFilesystem *fs, const char *folder,
94 const char *filename, void *data, GPContext *context)
95 {
96 int picNum;
97 Camera *camera = data;
98
99 picNum = gp_filesystem_number(fs, folder, filename, context) + 1;
100 return pdrm11_delete_file(camera->port, picNum);
101 }
102
103
104 static int
105 camera_about (Camera *camera, CameraText *about, GPContext *context)
106 {
107 strcpy (about->text, _("Toshiba\n"
108 "David Hogue <[email protected]>\n"
109 "Toshiba pdr-m11 driver.\n"));
110
111 return (GP_OK);
112 }
113
114 static int
115 file_list_func (CameraFilesystem *fs, const char *folder, CameraList *list,
116 void *data, GPContext *context)
117 {
118 Camera *camera = data;
119
120 return pdrm11_get_filenames(camera->port, list);
121 }
122
123 static CameraFilesystemFuncs fsfuncs = {
124 .file_list_func = file_list_func,
125 .get_file_func = get_file_func,
126 .del_file_func = delete_file_func
127 };
128
129 int
130 camera_init (Camera *camera, GPContext *context)
131 {
132 /* First, set up all the function pointers */
133 camera->functions->exit = camera_exit;
134 camera->functions->about = camera_about;
135 /* Now, tell the filesystem where to get lists, files and info */
136 gp_filesystem_set_funcs (camera->fs, &fsfuncs, camera);
137 return pdrm11_init(camera->port);
138 }