libgphoto2.vapi 14.9 KB
Newer Older
1
/* Copyright 2016 Software Freedom Conservancy Inc.
2 3
 *
 * This software is licensed under the GNU LGPL (version 2.1 or later).
4
 * See the COPYING file in this distribution.
5 6
 */

7 8 9 10 11
[CCode (
    cprefix="GP",
    lower_case_cprefix="gp_"
)]
namespace GPhoto {
12
    [SimpleType]
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
    [CCode (
        cname="CameraAbilities",
        destroy_function="",
        cheader_filename="gphoto2/gphoto2-abilities-list.h"
    )]
    public struct CameraAbilities {
        public string model;
        public int status;
        public PortType port;
        public string speed;
        public CameraOperation operations;
        public CameraFileOperation file_operations;
        public CameraFolderOperation folder_operations;
        public int usb_vendor;
        public int usb_product;
        public int usb_class;
        public int usb_protocol;
    }
    
    [Compact]
    [CCode (
        cname="CameraAbilitiesList",
        cprefix="gp_abilities_list_",
        free_function="gp_abilities_list_free",
        cheader_filename="gphoto2/gphoto2-abilities-list.h"
    )]
    public class CameraAbilitiesList {
        [CCode (cname="gp_abilities_list_new")]
        public static Result create(out CameraAbilitiesList abilitiesList);
        public Result load(Context context);
        public Result reset();
        public Result detect(PortInfoList portList, CameraList cameraList, Context context);
        public int count();
        public int lookup_model(string model);
        public Result get_abilities(int index, out CameraAbilities abilities);
    }
    
    [Compact]
    [CCode (
        cname="Camera",
53
        ref_function="GPHOTO_REF_CAMERA",
54 55
        unref_function="gp_camera_unref",
        free_function="gp_camera_free",
56
        cheader_filename="gphoto2/gphoto2-camera.h,gphoto.h"
57 58 59 60 61 62 63
    )]
    public class Camera {
        [CCode (cname="gp_camera_new")]
        public static Result create(out Camera camera);
        public Result init(Context context);
        public Result exit(Context context);
        public Result get_port_info(out PortInfo info);
64
        public Result set_port_info(PortInfo info);
65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88
        public Result get_abilities(out CameraAbilities abilities);
        public Result set_abilities(CameraAbilities abilities);
        public Result get_storageinfo(CameraStorageInformation **sifs, out int count, Context context);
        
        // Folders
        [CCode (cname="gp_camera_folder_list_folders")]
        public Result list_folders(string folder, CameraList list, Context context);
        [CCode (cname="gp_camera_folder_list_files")]
        public Result list_files(string folder, CameraList list, Context context);
        [CCode (cname="gp_camera_folder_delete_all")]
        public Result delete_all_files(string folder, Context context);
        [CCode (cname="gp_camera_folder_put_file")]
        public Result put_file(string folder, CameraFile file, Context context);
        [CCode (cname="gp_camera_folder_make_dir")]
        public Result make_dir(string folder, string name, Context context);
        [CCode (cname="gp_camera_folder_remove_dir")]
        public Result remove_dir(string folder, string name, Context context);
        
        // Files
        [CCode (cname="gp_camera_file_get_info")]
        public Result get_file_info(string folder, string file, out CameraFileInfo info, Context context);
        [CCode (cname="gp_camera_file_set_info")]
        public Result set_file_info(string folder, string file, CameraFileInfo info, Context context);
        [CCode (cname="gp_camera_file_get")]
89
        public Result get_file(string folder, string filename, CameraFileType type, CameraFile file,
90 91 92 93 94 95 96 97 98
            Context context);
        [CCode (cname="gp_camera_file_delete")]
        public Result delete_file(string folder, string filename, Context context);
    }
    
    [Compact]
    [CCode (
        cname="CameraFile",
        cprefix="gp_file_",
99
        ref_function="GPHOTO_REF_FILE",
100 101
        unref_function="gp_file_unref",
        free_function="gp_file_free",
102
        cheader_filename="gphoto2/gphoto2-file.h,gphoto.h"
103 104 105 106
    )]
    public class CameraFile {
        [CCode (cname="gp_file_new")]
        public static Result create(out CameraFile file);
107 108
        [CCode (cname="gp_file_new_from_fd")]
        public static Result create_from_fd(out CameraFile file, int fd);
109
        public Result get_data_and_size(out uint8 *data, out ulong data_len);
110
        public Result save(string filename);
111
        public Result slurp(uint8[] data, out size_t readlen);
112 113
    }
    
114
    [SimpleType]
115 116
    [CCode (
        cname="CameraFileInfo",
117
        destroy_function="",
118 119 120 121 122 123 124 125
        cheader_filename="gphoto2/gphoto2-filesys.h"
    )]
    public struct CameraFileInfo {
        public CameraFileInfoPreview preview;
        public CameraFileInfoFile file;
        public CameraFileInfoAudio audio;
    }
    
126
    [SimpleType]
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
    [CCode (
        cname="CameraFileInfoAudio",
        cheader_filename="gphoto2/gphoto2-filesys.h"
    )]
    public struct CameraFileInfoAudio {
    }
    
    [CCode (
        cname="CameraFileInfoFields",
        cheader_filename="gphoto2/gphoto2-filesys.h",
        cprefix="GP_FILE_INFO_"
    )]
    [Flags]
    public enum CameraFileInfoFields {
        NONE,
        TYPE,
        NAME,
        SIZE,
        WIDTH,
        HEIGHT,
        PERMISSIONS,
        STATUS,
        MTIME,
        ALL
    }
    
153
    [SimpleType]
154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169
    [CCode (
        cname="CameraFileInfoFile",
        cheader_filename="gphoto2/gphoto2-filesys.h"
    )]
    public struct CameraFileInfoFile {
        public CameraFileInfoFields fields;
        public CameraFileStatus status;
        public ulong size;
        public string type;
        public uint width;
        public uint height;
        public string name;
        public CameraFilePermissions permissions;
        public time_t mtime;
    }
    
170
    [SimpleType]
171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224
    [CCode (
        cname="CameraFileInfoPreview",
        cheader_filename="gphoto2/gphoto2-filesys.h"
    )]
    public struct CameraFileInfoPreview {
        public CameraFileInfoFields fields;
        public CameraFileStatus status;
        public ulong size;
        public string type;
        public uint width;
        public uint height;
        public string name;
        public CameraFilePermissions permissions;
        public time_t mtime;
    }
    
    [CCode (
        cname="CameraFileOperation",
        cheader_filename="gphoto2/gphoto2-abilities-list.h",
        cprefix="GP_FILE_OPERATION_"
    )]
    [Flags]
    public enum CameraFileOperation {
        NONE,
        DELETE,
        PREVIEW,
        RAW,
        AUDIO,
        EXIF
    }
    
    [CCode (
        cname="CameraFilePermissions",
        cheader_filename="gphoto2/gphoto2-filesys.h",
        cprefix="GP_FILE_PERM_"
    )]
    [Flags]
    public enum CameraFilePermissions {
        NONE,
        READ,
        DELETE,
        ALL
    }
    
    [CCode (
        cname="CameraFileStatus",
        cheader_filename="gphoto2/gphoto2-filesys.h",
        cprefix="GP_FILE_STATUS_"
    )]
    public enum CameraFileStatus {
        NOT_DOWNLOADED,
        DOWNLOADED
    }
    
225 226 227 228 229 230 231 232 233 234 235 236 237 238
    [CCode (
        cname="CameraFileType",
        cheader_filename="gphoto2/gphoto2-file.h",
        cprefix="GP_FILE_TYPE_"
    )]
    public enum CameraFileType {
        PREVIEW,
        NORMAL,
        RAW,
        AUDIO,
        EXIF,
        METADATA
    }
    
239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256
    [CCode (
        cname="CameraFolderOperation",
        cheader_filename="gphoto2/gphoto2-abilities-list.h",
        cprefix="GP_FOLDER_OPERATION_"
    )]
    [Flags]
    public enum CameraFolderOperation {
        NONE,
        DELETE_ALL,
        PUT_FILE,
        MAKE_DIR,
        REMOVE_DIR
    }
    
    [Compact]
    [CCode (
        cname="CameraList",
        cprefix="gp_list_",
257
        ref_function="GPHOTO_REF_LIST",
258 259
        unref_function="gp_list_unref",
        free_function="gp_list_free",
260
        cheader_filename="gphoto2/gphoto2-list.h,gphoto.h"
261 262 263 264 265 266 267 268
    )]
    public class CameraList {
        [CCode (cname="gp_list_new")]
        public static Result create(out CameraList list);
        public int count();
        public Result append(string name, string value);
        public Result reset();
        public Result sort();
269
        public Result find_by_name(out int? index, string name);
270 271
        public Result get_name(int index, out unowned string name);
        public Result get_value(int index, out unowned string value);
272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293
        public Result set_name(int index, string name);
        public Result set_value(int index, string value);
        public Result populate(string format, int count);
    }
    
    [CCode (
        cname="CameraOperation",
        cheader_filename="gphoto2/gphoto2-abilities-list.h",
        cprefix="GP_OPERATION_"
    )]
    [Flags]
    public enum CameraOperation {
        NONE,
        CAPTURE_IMAGE,
        CAPTURE_VIDEO,
        CAPTURE_AUDIO,
        CAPTURE_PREVIEW,
        CONFIG
    }
    
    [CCode (
        cname="CameraStorageInfoFields",
294
        cheader_filename="gphoto2/gphoto2-filesys.h",
295 296 297 298 299 300 301 302 303 304 305 306 307 308 309
        cprefix="GP_STORAGEINFO_"
    )]
    [Flags]
    public enum CameraStorageInfoFields {
        BASE,
        LABEL,
        DESCRIPTION,
        ACCESS,
        STORAGETYPE,
        FILESYSTEMTYPE,
        MAXCAPACITY,
        FREESPACEKBYTES,
        FREESPACEIMAGES
    }
    
310
    [SimpleType]
311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329
    [CCode (
        cname="CameraStorageInformation",
        cheader_filename="gphoto2/gphoto2-filesys.h"
    )]
    public struct CameraStorageInformation {
        public CameraStorageInfoFields fields;
        public string basedir;
        public string label;
        public string description;
        public int type;
        public int fstype;
        public int access;
        public ulong capacitykbytes;
        public ulong freekbytes;
        public ulong freeimages;
    }
    
    [Compact]
    [CCode (
330
        ref_function="GPHOTO_REF_CONTEXT",
331
        unref_function="gp_context_unref",
332
        cheader_filename="gphoto2/gphoto2-context.h,gphoto.h"
333 334 335 336
    )]
    public class Context {
        [CCode (cname="gp_context_new")]
        public Context();
337 338 339 340 341
        public void set_idle_func(ContextIdleFunc func);
        public void set_progress_funcs(
            [CCode (delegate_target_pos=3.1)] ContextProgressStartFunc startFunc, 
            [CCode (delegate_target_pos=3.1)] ContextProgressUpdateFunc updateFunc, 
            [CCode (delegate_target_pos=3.1)] ContextProgressStopFunc stopFunc);
342 343 344
        public void set_error_func([CCode (delegate_target_pos=3.1)] ContextErrorFunc errorFunc);
        public void set_status_func([CCode (delegate_target_pos=3.1)] ContextStatusFunc statusFunc);
        public void set_message_func([CCode (delegate_target_pos=3.1)] ContextMessageFunc messageFunc);
345 346
    }
    
347 348
    public delegate void ContextIdleFunc(Context context);
    
349
    public delegate void ContextErrorFunc(Context context, string text);
350
    
351
    public delegate void ContextStatusFunc(Context context, string text);
352
    
353
    public delegate void ContextMessageFunc(Context context, string text);
354
    
355
    // TODO: Support for va_args in Vala, esp. for delegates?
356
    public delegate uint ContextProgressStartFunc(Context context, float target, string text);
357 358 359 360 361
    
    public delegate void ContextProgressUpdateFunc(Context context, uint id, float current);
    
    public delegate void ContextProgressStopFunc(Context context, uint id);
    
362 363
    [CCode (
        cheader_filename="gphoto2/gphoto2-file.h",
364
        cprefix="GP_MIME_"
365
    )]
366
    namespace MIME {
367
        public const string WAV;
368 369
        public const string RAW;
        public const string PNG;
370 371 372
        public const string PGM;
        public const string PPM;
        public const string PNM;
373 374 375
        public const string JPEG;
        public const string TIFF;
        public const string BMP;
376 377 378 379
        public const string QUICKTIME;
        public const string AVI;
        public const string CRW;
        public const string UNKNOWN;
380
        public const string EXIF;
381 382 383 384 385
        public const string MP3;
        public const string OGG;
        public const string WMA;
        public const string ASF;
        public const string MPEG;
386 387
    }
    
388
    [SimpleType]
389 390 391 392 393
    [CCode (
        destroy_function="",
        cheader_filename="gphoto2/gphoto2-port-info-list.h"
    )]
    public struct PortInfo {
394 395 396 397 398 399 400 401 402 403 404 405
        [CCode (cname="gp_port_info_get_path")]
        public int get_path(out unowned string path);
        [CCode (cname="gp_port_info_set_path")]
        public int set_path(string path);
        [CCode (cname="gp_port_info_get_name")]
        public int get_name(out unowned string name);
        [CCode (cname="gp_port_info_set_name")]
        public int set_name(string path);
        [CCode (cname="gp_port_info_get_library_filename")]
        public int get_library_filename(out unowned string lib);
        [CCode (cname="gp_port_info_set_library_filename")]
        public int set_library_filename(string lib);
406 407 408 409 410 411 412 413 414 415 416 417
    }
    
    [Compact]
    [CCode (
        free_function="gp_port_info_list_free",
        cheader_filename="gphoto2/gphoto2-port-info-list.h"
    )]
    public class PortInfoList {
        [CCode (cname="gp_port_info_list_new")]
        public static Result create(out PortInfoList list);
        public Result load();
        public int count();
418 419
        public int lookup_name(string name);
        public int lookup_path(string name);
420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478
        public Result get_info(int index, out PortInfo info);
    }
    
    [CCode (
        cheader_filename="gphoto2/gphoto2-port-info-list.h",
        cprefix="GP_PORT_"
    )]
    [Flags]
    public enum PortType {
        NONE,
        SERIAL,
        USB,
        DISK,
        PTPIP
    }
    
    [CCode (
        cname="int",
        cheader_filename="gphoto2/gphoto2-result.h,gphoto2/gphoto2-port-result.h",
        cprefix="GP_ERROR_"
    )]
    public enum Result {
        [CCode (cname="GP_OK")]
        OK,
        [CCode (cname="GP_ERROR")]
        ERROR,
        BAD_PARAMETERS,
        NO_MEMORY,
        LIBRARY,
        UNKNOWN_PORT,
        NOT_SUPPORTED,
        IO,
        FIXED_LIMIT_EXCEEDED,
        TIMEOUT,
        IO_SUPPORTED_SERIAL,
        IO_SUPPORTED_USB,
        IO_INIT,
        IO_READ,
        IO_WRITE,
        IO_UPDATE,
        IO_SERIAL_SPEED,
        IO_USB_CLEAR_HALT,
        IO_USB_FIND,
        IO_USB_CLAIM,
        IO_LOCK,
        HAL,
        CORRUPTED_DATA,
        FILE_EXISTS,
        MODEL_NOT_FOUND,
        DIRECTORY_NOT_FOUND,
        FILE_NOT_FOUND,
        DIRECTORY_EXISTS,
        CAMERA_BUSY,
        PATH_NOT_ABSOLUTE,
        CANCEL,
        CAMERA_ERROR,
        OS_FAILURE;
        
        [CCode (cname="gp_port_result_as_string")]
479
        public unowned string as_string();
480 481 482 483
        
        public string to_full_string() {
            return "%s (%d)".printf(as_string(), this);
        }
484 485 486 487 488 489 490 491 492 493 494
    }
    
    [CCode (
        cheader_filename="gphoto2/gphoto2-version.h",
        cprefix="GP_VERSION"
    )]
    public enum VersionVerbosity {
        SHORT,
        VERBOSE
    }
    
495
    public unowned string library_version(VersionVerbosity verbosity);
496 497
}