Debian Codegraph @

vapi/exempi-2.0.vapi

raw
1 /*
2 * exempi
3 *
4 * Original Authors of xmp.h
5 * Copyright (C) 2007-2023 Hubert Figuière
6 * Copyright 2002-2007 Adobe Systems Incorporated
7 * All rights reserved.
8 *
9 * VAPI Authors:
10 * Copyright (c) 2023-2024 Diego Iván M.E
11 *
12 * Redistribution and use in source and binary forms, with or without
13 * modification, are permitted provided that the following conditions
14 * are met:
15 *
16 * 1 Redistributions of source code must retain the above copyright
17 * notice, this list of conditions and the following disclaimer.
18 *
19 * 2 Redistributions in binary form must reproduce the above copyright
20 * notice, this list of conditions and the following disclaimer in the
21 * documentation and/or other materials provided with the
22 * distribution.
23 *
24 * 3 Neither the name of the Authors, nor the names of its
25 * contributors may be used to endorse or promote products derived
26 * from this software wit hout specific prior written permission.
27 *
28 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
29 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
30 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
31 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
32 * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
33 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
34 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
35 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
36 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
37 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
38 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
39 * OF THE POSSIBILITY OF SUCH DAMAGE.
40 */
41
42 [CCode (cheader_filename = "exempi/xmp.h")]
43 namespace Xmp {
44 [CCode (has_typedef = false)]
45 public delegate int DumpCallback<G> (G object, string contents);
46
47 [Flags]
48 [CCode (cprefix = "XMP_OPEN_", has_type_id = false)]
49 public enum OpenFileOptions {
50 NOOPTION,
51 READ,
52 FORUPDATE,
53 ONLYXMP,
54 CACHENAIL,
55 STRICTLY,
56 USESMARTHANDLER,
57 USEPACKETSCANNING,
58 LIMITSCANNING,
59 REPAIR_FILE,
60 OPTIMIZEFILELAYOUT,
61 INBACKGROUND;
62 }
63
64 [Flags]
65 [CCode (cprefix = "XMP_CLOSE_", has_type_id = false)]
66 public enum CloseFileOptions {
67 NOOPTION,
68 SAFEUPDATE;
69 }
70
71 [CCode (cprefix = "XMP_FT_")]
72 public enum FileType {
73 PDF,
74 PS,
75 EPS,
76 TIFF,
77 GIF,
78 PNG,
79 WEBP,
80 SWF,
81 FLA,
82 FLV,
83 MOV,
84 AVI,
85 CIN,
86 WAV,
87 MP3,
88 SES,
89 CEL,
90 MPEG,
91 MPEG2,
92 MPEG4,
93 MXF,
94 WMAV,
95 AIFF,
96 RED,
97 ARRI,
98 HEIF,
99 P2,
100 XDCAM_FAM,
101 XDCAM_SAM,
102 XDCAM_EX,
103 AVCHD,
104 SONY_HDV,
105 CANON_XF,
106 AVC_ULTRA,
107 HTML,
108 XML,
109 TEXT,
110 SVG,
111 PHOTOSHOP,
112 ILLUSTRATOR,
113 INDESIGN,
114 AEPROJECT,
115 AEPROJTEMPLATE,
116 AEFILTERPRESET,
117 ENCOREPROJECT,
118 PREMIERPROJECT,
119 PREMIERTITLE,
120 UCF,
121 UNKNOWN;
122
123 [CCode (cname = "xmp_files_get_format_info")]
124 public bool get_format_info (out FileFormatOptions options);
125
126 [CCode (cname = "xmp_files_check_file_format")]
127 public static FileType check_file_format (string file_path);
128 }
129
130 [Flags]
131 [CCode (cprefix = "XMP_ITER_")]
132 public enum IterOptions {
133 CLASSMASK,
134 PROPERTIES,
135 ALIASES,
136 NAMESPACES,
137 JUSTCHILDREN,
138 JUSTLEAFNODES,
139 JUSTLEAFNAME,
140 INCLUDEALIASES,
141 OMITQUALIFIERS
142 }
143
144 [Flags]
145 [CCode (cprefix = "XMP_ITER_SKIP")]
146 public enum IterSkipOptions {
147 SUBTREE,
148 SIBLINGS
149 }
150
151 [Flags]
152 [CCode (cprefix = "XMP_FMT_")]
153 public enum FileFormatOptions {
154 CAN_INJECT_XMP,
155 CAN_EXPAND,
156 CAN_REWRITE,
157 PREFERS_IN_PLACE,
158 CAN_RECONCILE,
159 ALLOWS_ONLY_XMP,
160 RETURNS_RAW_PACKET,
161 HANDLER_OWNS_FILE,
162 ALLOW_SAFE_UPDATE,
163 NEEDS_READONLY_PACKET,
164 USE_SIDECAR_XMP,
165 FOLDER_BASED_FORMAT
166 }
167
168 [Flags]
169 [CCode (cprefix = "XMP_PROP_")]
170 public enum PropsBits {
171 VALUE_IS_URI,
172 HAS_QUALIFIERS,
173 IS_QUALIFIER,
174 HAS_LANG,
175 HAS_TYPE,
176 VALUE_IS_STRUCT,
177 VALUE_IS_ARRAY,
178 ARRAY_IS_UNORDERED,
179 ARRAY_IS_ORDERED,
180 ARRAY_IS_ALT,
181 ARRAY_IS_ALTTEXT,
182 ARRAY_INSERT_BEFORE,
183 ARRAY_INSERT_AFTER,
184 IS_ALIAS,
185 HAS_ALIASES,
186 IS_INTERNAL,
187 IS_STABLE,
188 IS_DERIVED,
189
190 ARRAY_FORM_MASK,
191 COMPOSITE_MASK
192 }
193
194 [Flags]
195 [CCode (cprefix = "XMP_SERIAL_", cname = "uint32_t")]
196 public enum SerializeOptions {
197 OMITPACKETWRAPPER,
198 READONLYPACKET,
199 USECOMPACTFORMAT,
200 INCLUDETHUMBNAILPAD,
201 EXACTPACKETLENGTH,
202 WRITEALIASCOMMENTS,
203 OMITALLFORMATTING,
204 [CCode (cname = "_XMP_LITTLEENDIAN_BIT")]
205 LITTLE_ENDIAN_BIT,
206 [CCode (cname = "_XMP_UTF16_BIT")]
207 UTF16_BIT,
208 [CCode (cname = "_XMP_UTF32_BIT")]
209 UTF32_BIT,
210 ENCODINGMASK,
211 ENCODEUTF8,
212 ENCODEUTF16BIG,
213 ENCODEUTF16LITTLE,
214 ENCODEUTF32BIG,
215 ENCODEUTF32LITTLE
216 }
217
218 [CCode (has_type_id = false)]
219 public struct MetaInfo {
220 int64 offset;
221 int32 length;
222 [CCode (cname = "padSize")]
223 int32 pad_size;
224 [CCode (cname = "charForm")]
225 uint8 char_form;
226 bool writeable;
227 [CCode (cname = "hasWrapper")]
228 bool has_wrapper;
229 }
230
231 public bool init ();
232 public void terminate ();
233 public int get_error ();
234
235 [Compact (opaque = true)]
236 [CCode (cname = "struct _XmpString", lower_case_cprefix = "xmp_string_", free_function = "xmp_string_free")]
237 internal class String {
238 public size_t length {
239 [CCode (cname = "xmp_string_len")]get;
240 }
241 [CCode (cname = "xmp_string_new")]
242 public String ();
243 [CCode (cname = "xmp_string_cstr")]
244 public unowned string to_string ();
245 }
246
247 [Compact (opaque = true)]
248 [CCode (cname = "struct _Xmp", lower_case_cprefix = "xmp_", free_function = "xmp_free")]
249 public class Meta {
250 [CCode (cname = "xmp_new_empty")]
251 public Meta.empty ();
252 [CCode (cname = "xmp_new")]
253 public Meta (string buffer);
254
255 public Meta copy ();
256
257 public bool parse (string buffer);
258
259 [CCode (cname = "__vala_xmp_serialize")]
260 public bool serialize (out string buffer, SerializeOptions options, uint32 padding) {
261 String xmp_str = new String ();
262 bool retval = serialize_xmp (xmp_str, (uint32) options, padding);
263 buffer = xmp_str.to_string ();
264 return retval;
265 }
266
267 [CCode (cname = "xmp_serialize")]
268 private bool serialize_xmp (String buffer, uint32 options, uint32 padding);
269
270 [CCode (cname = "__vala_xmp_serialize_and_format")]
271 public bool serialize_and_format (out string buffer, SerializeOptions options,
272 uint32 padding, string new_line, string tab, int32 indent) {
273 String xmp_str = new String ();
274 bool retval = serialize_and_format_xmp (xmp_str, (uint32) options, padding, new_line,
275 tab, indent);
276 buffer = xmp_str.to_string ();
277 return retval;
278 }
279
280 [CCode (cname = "__vala_xmp_dump_object")]
281 public bool dump_object<G> (G object, DumpCallback<G> callback) {
282 string contents;
283 bool success = serialize_and_format (out contents, READONLYPACKET, 0, "\n", " ", 0);
284 if (!success) {
285 GLib.critical ("Failed to serialize contents");
286 return false;
287 }
288 int result = callback (object, contents);
289 return result == 0;
290 }
291
292 [CCode (cname = "xmp_serialize_and_format")]
293 private bool serialize_and_format_xmp (String buffer, uint32 options, uint32 padding, string new_line, string tab, int32 indent);
294
295 [CCode (cname = "__vala_xmp_get_property")]
296 public bool get_property (string schema, string name, out string property, out PropsBits props_bits) {
297 bool retval;
298 var xmp_str = new String ();
299 uint32 bits;
300 retval = get_property_xmp_str (schema, name, xmp_str, out bits);
301 props_bits = (PropsBits) bits;
302 property = xmp_str.to_string ();
303 return retval;
304 }
305 [CCode (cname = "xmp_get_property")]
306 private bool get_property_xmp_str (string scheme, string name, String property, out uint32 propsbits);
307
308 [CCode (cname = "__vala_xmp_get_property_date_time")]
309 public bool get_property_date_time (string schema, string name, out GLib.DateTime property, out PropsBits props_bits) {
310 string property_str;
311 bool property_exists = get_property (schema, name, out property_str, out props_bits);
312 if (property_exists) {
313 property = new GLib.DateTime.from_iso8601 (property_str, null);
314 } else {
315 property = null;
316 }
317 return property_exists;
318 }
319
320 [CCode (cname = "__vala_xmp_get_property_float")]
321 public bool get_property_float (string schema, string name, out double property, out PropsBits props_bits) {
322 bool retval;
323 uint32 bits = 0x0;
324 retval = get_property_float_xmp_str (schema, name, out property, out bits);
325 props_bits = (PropsBits) bits;
326 return retval;
327 }
328 [CCode (cname = "xmp_get_property_float")]
329 private bool get_property_float_xmp_str (string schema, string name, out double property, out uint32 propsbits);
330
331 [CCode (cname = "__vala_xmp_get_property_bool")]
332 public bool get_property_bool (string schema, string name, out bool property, out PropsBits props_bits) {
333 bool retval;
334 uint32 bits = 0x0;
335 retval = get_property_bool_xmp (schema, name, out property, out bits);
336 props_bits = (PropsBits) bits;
337 return retval;
338 }
339
340 [CCode (cname = "xmp_get_property_bool")]
341 private bool get_property_bool_xmp (string schema, string name, out bool property, out uint32 bits);
342
343 [CCode (cname = "__vala_xmp_get_property_int")]
344 public bool get_property_int (string schema, string name, out int property, out PropsBits props_bits) {
345 bool retval;
346 uint32 bits = 0x0;
347 retval = get_property_int32 (schema, name, out property, out bits);
348 props_bits = (PropsBits) bits;
349 return retval;
350 }
351
352 [CCode (cname = "xmp_get_property_int32")]
353 private bool get_property_int32 (string schema, string name, out int32 property, out uint32 bits);
354
355 [CCode (cname = "__vala_xmp_get_array_item")]
356 public bool get_array_item (string schema, string name, int32 index, out string property, out PropsBits props_bits) {
357 bool retval;
358 var xmp_str = new String ();
359 uint32 bits;
360 retval = get_array_item_xmp (schema, name, index, xmp_str, out bits);
361 props_bits = (PropsBits) bits;
362 property = xmp_str.to_string ();
363 return retval;
364 }
365 [CCode (cname = "xmp_get_array_item")]
366 private bool get_array_item_xmp (string schema, string name, int32 index, String property, out uint32 bits);
367
368 public bool set_property (string schema, string name, string @value, uint32 option_bits);
369 public bool set_property_float (string schema, string name, float @value, uint32 option_bits);
370 public bool set_property_int32 (string schema, string name, int32 @value, uint32 option_bits);
371 public bool set_property_int64 (string schema, string name, int64 @value, uint32 option_bits);
372 public bool set_array_item (string schema, string name, int32 index, string @value, uint32 option_bits);
373
374 [CCode (cname = "__vala_xmp_set_property_date")]
375 public bool set_property_date (string schema, string name, GLib.DateTime @value, uint32 option_bits) {
376 return set_property (schema, name, @value.format_iso8601 (), option_bits);
377 }
378
379 [CCode (cname = "__vala_xmp_append_array_item")]
380 public bool append_array_item (string schema, string name, PropsBits array_options, string @value, uint32 option_bits) {
381 return append_array_item_xmp (schema, name, (uint32) array_options, @value, option_bits);
382 }
383
384 [CCode (cname = "xmp_append_array_item")]
385 private bool append_array_item_xmp (string schema, string name, uint32 array_options, string @value, uint32 option_bits);
386
387 public bool delete_property (string schema, string name);
388 public bool has_property (string schema, string name);
389
390 [CCode (cname = "__vala_xmp_get_localized_text")]
391 public bool get_localized_text (string schema, string name, string generic_lang,
392 string specific_lang, out string actual_lang,
393 out string item_value, out PropsBits props_bits)
394 requires (generic_lang != "")
395 requires (specific_lang != "") {
396 uint32 bits = 0x0;
397 String x_actual = new String (), x_value = new String ();
398 bool retval = get_localized_text_xmp (schema, name, generic_lang, specific_lang,
399 x_actual, x_value, out bits);
400 actual_lang = x_actual.to_string ();
401 item_value = x_value.to_string ();
402 props_bits = (PropsBits) bits;
403 return retval;
404 }
405 [CCode (cname = "xmp_get_localized_text")]
406 private bool get_localized_text_xmp (string schema, string name, string generic_lang, string specific_lang, String actual_lang, String item_value, out uint32 bits);
407
408 public bool set_localized_text (string schema, string name, string generic_lang, string specific_lang, string @value, uint32 option_bits);
409 public bool delete_localized_text (string schema, string name, string generic_lang, string specific_lang);
410
411 public int count_array_items (string schema, string name) {
412 PropsBits bits;
413 int count = 0;
414 bool property = get_property (schema, name, null, out bits);
415 if (!property) {
416 return -1;
417 }
418 if (!(VALUE_IS_ARRAY in bits)) {
419 return 1;
420 }
421 var iterator = new Iterator (this, schema, name, JUSTCHILDREN);
422 string schema_ns, prop_path, prop_val;
423 while (iterator.next (out schema_ns, out prop_path, out prop_val, out bits)) {
424 if (COMPOSITE_MASK in bits) {
425 iterator.skip (SUBTREE);
426 }
427 if (!(name in prop_path)) {
428 break;
429 }
430 count++;
431 }
432 return count;
433 }
434 }
435
436 [Compact (opaque = true)]
437 [CCode (cname = "struct _XmpFile", lower_case_cprefix = "xmp_files_", free_function = "xmp_files_free")]
438 public class File {
439 [CCode (cname = "xmp_files_new")]
440 public File ();
441 [CCode (cname = "xmp_files_open_new")]
442 public static File? open_new (string path, OpenFileOptions options);
443
444 [CCode (cname = "xmp_files_open")]
445 public bool open_file (string path, OpenFileOptions options);
446
447 public bool close (CloseFileOptions options);
448 public Meta get_new_xmp ();
449
450 public bool get_xmp (Meta xmp);
451 public bool can_put_xmp (Meta xmp);
452 public bool put_xmp (Meta xmp);
453
454 [CCode (cname = "xmp_files_can_put_xmp_cstr")]
455 public bool can_put_string (string xmp_packet);
456
457 [CCode (cname = "__vala_xmp_files_get_info")]
458 public bool get_file_info (ref string? file_path, out OpenFileOptions options, out FileType format, out FileFormatOptions handler_flags) {
459 bool retval = false;
460 if (file_path != null) {
461 var xmp_str = new String ();
462 retval = get_file_info_xmp_str (xmp_str, out options, out format, out handler_flags);
463 file_path = xmp_str.to_string ();
464 } else {
465 retval = get_file_info_xmp_str (null, out options, out format, out handler_flags);
466 }
467 return retval;
468 }
469
470 [CCode (cname = "xmp_files_get_file_info")]
471 private bool get_file_info_xmp_str (String? file_path, out OpenFileOptions options, out FileType format, out FileFormatOptions handler_flags);
472 }
473
474 [Compact (opaque = true)]
475 [CCode (cname = "struct _XmpIterator", lower_case_cprefix = "xmp_iterator_", free_function = "xmp_iterator_free")]
476 public class Iterator {
477 [CCode (cname = "xmp_iterator_new")]
478 public Iterator (Meta xmp, string schema, string prop_name, IterOptions options);
479
480 [CCode (cname = "__vala_xmp_iter_next")]
481 public bool next (out string schema, out string prop_name, out string prop_value,
482 out PropsBits options) {
483 String schema_str = new String (), name_str = new String (), value_str = new String ();
484 uint32 bits = 0x0;
485 bool retval = next_xmp (schema_str, name_str, value_str, out bits);
486 schema = schema_str.to_string ();
487 prop_name = name_str.to_string ();
488 prop_value = value_str.to_string ();
489 options = (PropsBits) bits;
490 return retval;
491 }
492
493 [CCode (cname = "xmp_iterator_next")]
494 private bool next_xmp (String? schema, String? prop_name, String? prop_value, out uint32 options);
495
496 public bool skip (IterSkipOptions options);
497 }
498
499 namespace Namespace {
500 [CCode (cheader_filename = "exempi/xmpconsts.h", cname = "NS_XMP_META")]
501 public const string XMP_META;
502 [CCode (cheader_filename = "exempi/xmpconsts.h", cname = "NS_RDF")]
503 public const string RDF;
504 [CCode (cheader_filename = "exempi/xmpconsts.h", cname = "NS_EXIF")]
505 public const string EXIF;
506 [CCode (cheader_filename = "exempi/xmpconsts.h", cname = "NS_TIFF")]
507 public const string TIFF;
508 [CCode (cheader_filename = "exempi/xmpconsts.h", cname = "NS_XAP")]
509 public const string XAP;
510 [CCode (cheader_filename = "exempi/xmpconsts.h", cname = "NS_XAP_RIGHTS")]
511 public const string XAP_RIGHTS;
512 [CCode (cheader_filename = "exempi/xmpconsts.h", cname = "NS_DC")]
513 public const string DC;
514 [CCode (cheader_filename = "exempi/xmpconsts.h", cname = "NS_EXIF_AUX")]
515 public const string EXIF_AUX;
516 [CCode (cheader_filename = "exempi/xmpconsts.h", cname = "NS_CRS")]
517 public const string CRS;
518 [CCode (cheader_filename = "exempi/xmpconsts.h", cname = "NS_LIGHTROOM")]
519 public const string LIGHTROOM;
520 [CCode (cheader_filename = "exempi/xmpconsts.h", cname = "NS_PHOTOSHOP")]
521 public const string PHOTOSHOP;
522 [CCode (cheader_filename = "exempi/xmpconsts.h", cname = "NS_CAMERA_RAW_SETTINGS")]
523 public const string CAMERA_RAW_SETTINGS;
524 [CCode (cheader_filename = "exempi/xmpconsts.h", cname = "NS_CAMERA_RAW_SAVED_SETTINGS")]
525 public const string CAMERA_RAW_SAVED_SETTINGS;
526 [CCode (cheader_filename = "exempi/xmpconsts.h", cname = "NS_IPTC4XMP")]
527 public const string IPTC4XMP;
528 [CCode (cheader_filename = "exempi/xmpconsts.h", cname = "NS_TPG")]
529 public const string TPG;
530 [CCode (cheader_filename = "exempi/xmpconsts.h", cname = "NS_DIMENSIONS_TYPE")]
531 public const string DIMENSIONS_TYPE;
532 [CCode (cheader_filename = "exempi/xmpconsts.h", cname = "NS_CC")]
533 public const string CC;
534 [CCode (cheader_filename = "exempi/xmpconsts.h", cname = "NS_PDF")]
535 public const string PDF;
536 [CCode (cheader_filename = "exempi/xmpconsts.h", cname = "NS_XML")]
537 public const string XML;
538
539 [CCode (cname = "__vala_xmp_register_namespace")]
540 public bool register_namespace (string namespace_uri, string suggested_prefix, out string registered_prefix) {
541 var xmp_str = new String ();
542 bool retval = register_namespace_xmp_str (namespace_uri, suggested_prefix, xmp_str);
543 registered_prefix = xmp_str.to_string ();
544 return retval;
545 }
546 [CCode (cname = "xmp_register_namespace")]
547 private bool register_namespace_xmp_str (string namespace_uri, string suggested_prefix, String registered_prefix);
548
549 [CCode (cname = "__vala_xmp_namespace_prefix")]
550 public bool namespace_prefix (string ns, out string prefix) {
551 var xmp_str = new String ();
552 bool retval = namespace_is_registered_xmp_str (ns, xmp_str);
553 prefix = xmp_str.to_string ();
554 return retval;
555 }
556
557 [CCode (cname = "xmp_namespace_prefix")]
558 private bool namespace_is_registered_xmp_str (string ns, String? prefix);
559
560 [CCode (cname = "__vala_xmp_prefix_is_registered")]
561 public bool prefix_namespace_uri (string uri, out string @namespace) {
562 bool retval;
563 var xmp_str = new String ();
564 retval = prefix_is_registered_xmp_str (uri, xmp_str);
565 @namespace = xmp_str.to_string ();
566 return retval;
567 }
568
569 [CCode (cname = "xmp_prefix_namespace_uri")]
570 private bool prefix_is_registered_xmp_str (string uri, String? ns);
571 }
572 }