5
* Ewen Cheslack-Postava <echeslack@gmail.com>
6
* Larry Ewing <lewing@novell.com>
7
* Stephane Delcroix <stephane@delcroix.org>
9
* Copyright (c) 2005-2009 Novell, Inc.
11
* This is open source software. See COPYING for details.
14
using System.Runtime.InteropServices;
19
public class Camera : GPObject
21
[DllImport ("libgphoto2.so")]
22
internal static extern ErrorCode gp_camera_new (out IntPtr handle);
23
[DllImport ("libgphoto2.so")]
24
internal static extern ErrorCode gp_camera_unref (HandleRef camera);
26
public Camera () : base (gp_camera_unref)
29
Error.CheckError (gp_camera_new (out native));
30
this.handle = new HandleRef (this, native);
33
#region Preparing initilization
34
[DllImport ("libgphoto2.so")]
35
internal static extern ErrorCode gp_camera_set_abilities (HandleRef camera, CameraAbilities abilities);
37
[DllImport ("libgphoto2.so")]
38
internal unsafe static extern ErrorCode gp_camera_get_abilities (HandleRef camera, out CameraAbilities abilities);
40
public CameraAbilities Abilities {
42
CameraAbilities abilities;
43
Error.CheckError (gp_camera_get_abilities(this.Handle, out abilities));
46
set { Error.CheckError (gp_camera_set_abilities(this.Handle, value)); }
49
[DllImport ("libgphoto2.so")]
50
internal unsafe static extern ErrorCode gp_camera_set_port_info (HandleRef camera, PortInfo info);
52
[DllImport ("libgphoto2.so")]
53
internal static extern ErrorCode gp_camera_get_port_info (HandleRef camera, out PortInfo info);
55
public PortInfo PortInfo {
58
Error.CheckError (gp_camera_get_port_info (this.Handle, out portinfo));
61
set { Error.CheckError (gp_camera_set_port_info (this.Handle, value)); }
65
#region Speed, do not use, camera driver pick the optimal one
66
[DllImport ("libgphoto2.so")]
67
internal static extern ErrorCode gp_camera_get_port_speed (HandleRef camera);
69
[DllImport ("libgphoto2.so")]
70
internal static extern ErrorCode gp_camera_set_port_speed (HandleRef camera, int speed);
72
public int PortSpeed {
73
get { return Error.CheckError (gp_camera_get_port_speed (this.Handle)); }
74
set { Error.CheckError (gp_camera_set_port_speed (this.Handle, value)); }
78
#region Initialization
79
[DllImport ("libgphoto2.so")]
80
internal static extern ErrorCode gp_camera_init (HandleRef camera, HandleRef context);
82
public void Init (Context context)
84
Error.CheckError (gp_camera_init (Handle, context.Handle));
87
[DllImport ("libgphoto2.so")]
88
internal static extern ErrorCode gp_camera_exit (HandleRef camera, HandleRef context);
90
public void Exit (Context context)
92
Error.CheckError (gp_camera_exit (Handle, context.Handle));
96
#region Operations on camera
97
[DllImport ("libgphoto2.so")]
98
internal static extern ErrorCode gp_camera_get_summary (HandleRef camera, out CameraText summary, HandleRef context);
100
public CameraText GetSummary (Context context)
103
Error.CheckError (Camera.gp_camera_get_summary(this.Handle, out summary, context.Handle));
108
[DllImport ("libgphoto2.so")]
109
internal static extern ErrorCode gp_camera_get_about (HandleRef camera, out CameraText about, HandleRef context);
111
public CameraText GetAbout (Context context)
114
Error.CheckError (gp_camera_get_about(this.Handle, out about, context.Handle));
119
[DllImport ("libgphoto2.so")]
120
internal static extern ErrorCode gp_camera_get_manual (HandleRef camera, out CameraText manual, HandleRef context);
122
public CameraText GetManual (Context context)
127
Error.CheckError (gp_camera_get_manual(this.Handle, out manual, context.Handle));
132
[DllImport ("libgphoto2.so")]
133
internal static extern ErrorCode gp_camera_capture (HandleRef camera, CameraCaptureType type, out CameraFilePath path, HandleRef context);
135
public CameraFilePath Capture (CameraCaptureType type, Context context)
138
Error.CheckError (gp_camera_capture (this.Handle, type, out path, context.Handle));
143
[DllImport ("libgphoto2.so")]
144
internal unsafe static extern ErrorCode gp_camera_capture_preview (HandleRef camera, HandleRef file, HandleRef context);
146
public void CapturePreview (CameraFile dest, Context context)
148
Error.CheckError (gp_camera_capture_preview (this.Handle, dest.Handle, context.Handle));
152
#region Operations on folders
153
[DllImport ("libgphoto2.so")]
154
internal static extern ErrorCode gp_camera_folder_list_files (HandleRef camera, [MarshalAs(UnmanagedType.LPTStr)] string folder, HandleRef list, HandleRef context);
156
public CameraList ListFiles (string folder, Context context)
158
CameraList file_list = new CameraList ();
159
Error.CheckError (gp_camera_folder_list_files(this.Handle, folder, file_list.Handle, context.Handle));
164
[DllImport ("libgphoto2.so")]
165
internal static extern ErrorCode gp_camera_folder_list_folders (HandleRef camera, [MarshalAs(UnmanagedType.LPTStr)] string folder, HandleRef list, HandleRef context);
167
public CameraList ListFolders (string folder, Context context)
169
CameraList file_list = new CameraList();
170
Error.CheckError (gp_camera_folder_list_folders (this.Handle, folder, file_list.Handle, context.Handle));
175
[DllImport ("libgphoto2.so")]
176
internal static extern ErrorCode gp_camera_folder_delete_all (HandleRef camera, [MarshalAs(UnmanagedType.LPTStr)] string folder, HandleRef context);
178
public void DeleteAll (string folder, Context context)
180
Error.CheckError (gp_camera_folder_delete_all (this.Handle, folder, context.Handle));
183
[DllImport ("libgphoto2.so")]
184
internal static extern ErrorCode gp_camera_folder_make_dir (HandleRef camera, [MarshalAs(UnmanagedType.LPTStr)] string folder, [MarshalAs(UnmanagedType.LPTStr)] string name, HandleRef context);
186
public void MakeDirectory (string folder, string name, Context context)
188
Error.CheckError (gp_camera_folder_make_dir (this.Handle, folder, name, context.Handle));
191
[DllImport ("libgphoto2.so")]
192
internal static extern ErrorCode gp_camera_folder_remove_dir (HandleRef camera, [MarshalAs(UnmanagedType.LPTStr)] string folder, [MarshalAs(UnmanagedType.LPTStr)] string name, HandleRef context);
194
public void RemoveDirectory (string folder, string name, Context context)
196
Error.CheckError (gp_camera_folder_remove_dir(this.Handle, folder, name, context.Handle));
199
[DllImport ("libgphoto2.so")]
200
internal unsafe static extern ErrorCode gp_camera_folder_put_file (HandleRef camera, [MarshalAs(UnmanagedType.LPTStr)] string folder, HandleRef file, HandleRef context);
202
public void PutFile (string folder, CameraFile file, Context context)
204
Error.CheckError (gp_camera_folder_put_file(this.Handle, folder, file.Handle, context.Handle));
208
#region Operations on files
209
[DllImport ("libgphoto2.so")]
210
internal static extern ErrorCode gp_camera_file_get (HandleRef camera, [MarshalAs(UnmanagedType.LPTStr)] string folder, [MarshalAs(UnmanagedType.LPTStr)] string file, CameraFileType type, HandleRef camera_file, HandleRef context);
212
public void GetFile (string folder, string name, CameraFileType type, CameraFile camera_file, Context context)
214
Error.CheckError (gp_camera_file_get(this.Handle, folder, name, type, camera_file.Handle, context.Handle));
217
[DllImport ("libgphoto2.so")]
218
internal static extern ErrorCode gp_camera_file_delete (HandleRef camera, [MarshalAs(UnmanagedType.LPTStr)] string folder, [MarshalAs(UnmanagedType.LPTStr)] string file, HandleRef context);
220
public void DeleteFile (string folder, string name, Context context)
222
Error.CheckError (gp_camera_file_delete(this.Handle, folder, name, context.Handle));
226
[DllImport ("libgphoto2.so")]
227
internal static extern ErrorCode gp_camera_file_get_info (HandleRef camera, [MarshalAs(UnmanagedType.LPTStr)] string folder, [MarshalAs(UnmanagedType.LPTStr)] string file, out CameraFileInfo info, HandleRef context);
229
public CameraFileInfo GetFileInfo (string folder, string name, Context context)
231
CameraFileInfo fileinfo;
232
Error.CheckError (gp_camera_file_get_info(this.Handle, folder, name, out fileinfo, context.Handle));
237
[DllImport ("libgphoto2.so")]
238
internal static extern ErrorCode gp_camera_file_set_info (HandleRef camera, string folder, string file, CameraFileInfo info, HandleRef context);
240
public void SetFileInfo (string folder, string name, CameraFileInfo fileinfo, Context context)
242
Error.CheckError (gp_camera_file_set_info(this.Handle, folder, name, fileinfo, context.Handle));