summaryrefslogtreecommitdiff
path: root/camlibs/sierra/library.h
blob: 015fe92e42e337e6278b33b7aee9ee10dcd4fffe (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
/* library.h
 *
 * Copyright © 2001 Lutz Müller <lutz@users.sf.net>
 *
 * 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 __LIBRARY_H__
#define __LIBRARY_H__

#include <gphoto2/gphoto2-camera.h>

#define TIMEOUT	   2000

#define CHECK_STOP(camera,result)				\
{								\
	int res = (result);					\
								\
	if (res < 0) {						\
		GP_DEBUG ("Operation failed (%i)!", res);	\
		camera_stop (camera, context);			\
		return (res);					\
	}							\
}

#define CHECK_STOP_FREE(camera,result)				\
{								\
	int res = (result);					\
								\
	if (res < 0) {						\
		GP_DEBUG ("Operation failed (%i)!", res);	\
		camera_stop (camera, context);			\
		free (camera->pl);				\
		camera->pl = NULL;				\
		return (res);					\
	}							\
}

#define CHECK_FREE(camera,result)				\
{								\
	int res = (result);					\
								\
	if (res < 0) {						\
		GP_DEBUG ("Operation failed (%i)!", res);	\
		free (camera->pl);				\
		camera->pl = NULL;				\
		return (res);					\
	}							\
}

typedef enum _SierraAction SierraAction;
enum _SierraAction {
	SIERRA_ACTION_DELETE_LAST_PIC = 0x00,
	SIERRA_ACTION_DELETE_ALL = 0x01,
	SIERRA_ACTION_CAPTURE    = 0x02,
	SIERRA_ACTION_END        = 0x04,
	SIERRA_ACTION_PREVIEW    = 0x05,
	SIERRA_ACTION_TESTING    = 0x06,
	SIERRA_ACTION_DELETE     = 0x07,
	SIERRA_ACTION_LCD_MODE   = 0x08,
	SIERRA_ACTION_PROT_STATE = 0x09,
	SIERRA_ACTION_UPLOAD     = 0x0b,
	SIERRA_ACTION_LCD_TEST   = 0x0c,
};

typedef enum {
	SIERRA_LOCKED_NO  = 0x00,
	SIERRA_LOCKED_YES = 0x01
} SierraLocked;

typedef struct _SierraPicInfo SierraPicInfo;
struct _SierraPicInfo {
	unsigned int size_file;
	unsigned int size_preview;
	unsigned int size_audio;
	unsigned int resolution;
	SierraLocked locked;
	unsigned int date;
	unsigned int animation_type;
};
int sierra_get_pic_info (Camera *camera, unsigned int n,
			 SierraPicInfo *pic_info, GPContext *context);
int sierra_set_locked (Camera *camera, unsigned int n, SierraLocked locked,
		       GPContext *context);

/* Communications functions */
typedef enum _SierraSpeed SierraSpeed;
enum _SierraSpeed {
	SIERRA_SPEED_9600   = 1,
	SIERRA_SPEED_19200  = 2,
	SIERRA_SPEED_38400  = 3,
	SIERRA_SPEED_57600  = 4,
	SIERRA_SPEED_115200 = 5
};
int sierra_set_speed		  (Camera *camera, SierraSpeed speed,
				   GPContext *context);
int sierra_end_session		  (Camera *camera, GPContext *context);
int sierra_init			  (Camera *camera, GPContext *context);
int sierra_get_memory_left        (Camera *camera, int *memory,
				   GPContext *context);
int sierra_check_battery_capacity (Camera *camera, GPContext *context);
int sierra_sub_action		  (Camera *camera, SierraAction action,
				  int sub_action, GPContext *context);
int sierra_set_int_register 	  (Camera *camera, int reg, int value,
				   GPContext *context);
int sierra_get_int_register 	  (Camera *camera, int reg, int *value,
				   GPContext *context);
int sierra_set_string_register	  (Camera *camera, int reg, const char *s,
				   long int length, GPContext *context);
int sierra_get_string_register	  (Camera *camera, int reg, int file_number,
				   CameraFile *file,
				   unsigned char *b, unsigned int *b_len,
				   GPContext *context);
int sierra_delete		  (Camera *camera, int picture_number,
				   GPContext *context);
int sierra_delete_all             (Camera *camera, GPContext *context);
int sierra_capture		  (Camera *camera, CameraCaptureType type, 
				   CameraFilePath *filepath,
				   GPContext *context);
int sierra_capture_preview 	  (Camera *camera, CameraFile *file,
				   GPContext *context);
int sierra_change_folder          (Camera *camera, const char *folder,
				   GPContext *context);
int sierra_get_size		  (Camera *camera, int reg, unsigned int n,
				   int *value, GPContext *context);
int camera_start		  (Camera *camera, GPContext *context);
int camera_stop			  (Camera *camera, GPContext *context);

/* Filesystem functions */
int sierra_list_files         (Camera *camera, const char *folder, CameraList *list, GPContext *context);
int sierra_list_folders       (Camera *camera, const char *folder, CameraList *list, GPContext *context);
int sierra_get_picture_folder (Camera *camera, char **folder);
int sierra_upload_file        (Camera *camera, CameraFile *file,
			       GPContext *context);

/* Camera desc functions in sierra-desc.c */
int camera_set_config_cam_desc	  (Camera *camera, CameraWidget *window, 
				   GPContext *context);
int camera_get_config_cam_desc	  (Camera *camera, CameraWidget **window, 
				   GPContext *context);
#endif /* __LIBRARY_H__ */