summarylogtreecommitdiffstats
path: root/0001-exiv-0.28.patch
blob: b0ea9556f4aab1066e0822980571a7d5ce717dd3 (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
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
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
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
From e28dcda26b3eb3cbd8905b616d1ec583ea37d45e Mon Sep 17 00:00:00 2001
From: nate <njsimon10@gmail.com>
Date: Fri, 7 Jul 2023 14:43:34 -0500
Subject: [PATCH] patch to build with exiv 0.28

---
 extensions/exiv2_tools/exiv2-utils.cpp | 141 +++++++++++++++++++++++++
 1 file changed, 141 insertions(+)

diff --git a/extensions/exiv2_tools/exiv2-utils.cpp b/extensions/exiv2_tools/exiv2-utils.cpp
index fb2b292..fa997e2 100644
--- a/extensions/exiv2_tools/exiv2-utils.cpp
+++ b/extensions/exiv2_tools/exiv2-utils.cpp
@@ -740,7 +740,11 @@ get_exif_default_category (const Exiv2::Exifdatum &md)
 
 
 static void
+#if EXIV2_TEST_VERSION(0,28,0)
+exiv2_read_metadata (Exiv2::Image::UniquePtr  image,
+#else
 exiv2_read_metadata (Exiv2::Image::AutoPtr  image,
+#endif
 		     GFileInfo             *info,
 		     gboolean               update_general_attributes)
 {
@@ -882,7 +886,11 @@ exiv2_read_metadata_from_file (GFile         *file,
 			return FALSE;
 		}
 
+#if EXIV2_TEST_VERSION(0,28,0)
+		Exiv2::Image::UniquePtr image = Exiv2::ImageFactory::open(path);
+#else
 		Exiv2::Image::AutoPtr image = Exiv2::ImageFactory::open(path);
+#endif
 		g_free (path);
 
 		if (image.get() == 0) {
@@ -892,9 +900,17 @@ exiv2_read_metadata_from_file (GFile         *file,
 		}
 		// Set the log level to only show errors (and suppress warnings, informational and debug messages)
 		Exiv2::LogMsg::setLevel(Exiv2::LogMsg::error);
+#if EXIV2_TEST_VERSION(0,28,0)
+		exiv2_read_metadata (std::move(image), info, update_general_attributes);
+#else
 		exiv2_read_metadata (image, info, update_general_attributes);
+#endif
 	}
+#if EXIV2_TEST_VERSION(0,28,0)
+	catch (Exiv2::Error& e) {
+#else
 	catch (Exiv2::AnyError& e) {
+#endif
 		if (error != NULL)
 			*error = g_error_new_literal (G_IO_ERROR, G_IO_ERROR_FAILED, e.what());
 		return FALSE;
@@ -913,7 +929,11 @@ exiv2_read_metadata_from_buffer (void       *buffer,
 				 GError    **error)
 {
 	try {
+#if EXIV2_TEST_VERSION(0,28,0)
+		Exiv2::Image::UniquePtr image = Exiv2::ImageFactory::open ((Exiv2::byte*) buffer, buffer_size);
+#else
 		Exiv2::Image::AutoPtr image = Exiv2::ImageFactory::open ((Exiv2::byte*) buffer, buffer_size);
+#endif
 
 		if (image.get() == 0) {
 			if (error != NULL)
@@ -921,9 +941,17 @@ exiv2_read_metadata_from_buffer (void       *buffer,
 			return FALSE;
 		}
 
+#if EXIV2_TEST_VERSION(0,28,0)
+		exiv2_read_metadata (std::move(image), info, update_general_attributes);
+#else
 		exiv2_read_metadata (image, info, update_general_attributes);
+#endif
 	}
+#if EXIV2_TEST_VERSION(0,28,0)
+	catch (Exiv2::Error& e) {
+#else
 	catch (Exiv2::AnyError& e) {
+#endif
 		if (error != NULL)
 			*error = g_error_new_literal (G_IO_ERROR, G_IO_ERROR_FAILED, e.what());
 		return FALSE;
@@ -972,7 +1000,11 @@ exiv2_read_sidecar (GFile     *file,
 		g_free (path);
 
 		std::string xmpPacket;
+#if EXIV2_TEST_VERSION(0,28,0)
+		xmpPacket.assign(reinterpret_cast<char*>(buf.data()), buf.size());
+#else
 		xmpPacket.assign(reinterpret_cast<char*>(buf.pData_), buf.size_);
+#endif
 		Exiv2::XmpData xmpData;
 
 		if (0 != Exiv2::XmpParser::decode(xmpData, xmpPacket))
@@ -1018,7 +1050,11 @@ exiv2_read_sidecar (GFile     *file,
 
 		set_attributes_from_tagsets (info, update_general_attributes);
 	}
+#if EXIV2_TEST_VERSION(0,28,0)
+	catch (Exiv2::Error& e) {
+#else
 	catch (Exiv2::AnyError& e) {
+#endif
 		std::cerr << "Caught Exiv2 exception '" << e << "'\n";
 		return FALSE;
 	}
@@ -1118,7 +1154,11 @@ dump_exif_data (Exiv2::ExifData &exifData,
 
 
 static Exiv2::DataBuf
+#if EXIV2_TEST_VERSION(0,28,0)
+exiv2_write_metadata_private (Exiv2::Image::UniquePtr  image,
+#else
 exiv2_write_metadata_private (Exiv2::Image::AutoPtr  image,
+#endif
 			      GFileInfo             *info,
 			      GthImage              *image_data)
 {
@@ -1155,13 +1195,21 @@ exiv2_write_metadata_private (Exiv2::Image::AutoPtr  image,
 			const char *value_type = gth_main_get_metadata_type (metadatum, attributes[i]);
 
 			if ((raw_value != NULL) && (strcmp (raw_value, "") != 0) && (value_type != NULL)) {
+#if EXIV2_TEST_VERSION(0,28,0)
+				Exiv2::Value::UniquePtr value = Exiv2::Value::create (Exiv2::TypeInfo::typeId (value_type));
+#else
 				Exiv2::Value::AutoPtr value = Exiv2::Value::create (Exiv2::TypeInfo::typeId (value_type));
+#endif
 				value->read (raw_value);
 				Exiv2::ExifKey exif_key(key);
 				ed.add (exif_key, value.get());
 			}
 		}
+#if EXIV2_TEST_VERSION(0,28,0)
+		catch (Exiv2::Error& e) {
+#else
 		catch (Exiv2::AnyError& e) {
+#endif
 			/* we don't care about invalid key errors */
 			g_warning ("%s", e.what());
 		}
@@ -1277,7 +1325,11 @@ exiv2_write_metadata_private (Exiv2::Image::AutoPtr  image,
 			value_type = gth_main_get_metadata_type (metadatum, attributes[i]);
 			if (value_type != NULL) {
 				/* See the exif data code above for an explanation. */
+#if EXIV2_TEST_VERSION(0,28,0)
+				Exiv2::Value::UniquePtr value = Exiv2::Value::create (Exiv2::TypeInfo::typeId (value_type));
+#else
 				Exiv2::Value::AutoPtr value = Exiv2::Value::create (Exiv2::TypeInfo::typeId (value_type));
+#endif
 				Exiv2::IptcKey iptc_key(key);
 
 				const char *raw_value;
@@ -1303,7 +1355,11 @@ exiv2_write_metadata_private (Exiv2::Image::AutoPtr  image,
 				}
 			}
 		}
+#if EXIV2_TEST_VERSION(0,28,0)
+		catch (Exiv2::Error& e) {
+#else
 		catch (Exiv2::AnyError& e) {
+#endif
 			/* we don't care about invalid key errors */
 			g_warning ("%s", e.what());
 		}
@@ -1327,7 +1383,11 @@ exiv2_write_metadata_private (Exiv2::Image::AutoPtr  image,
 			value_type = gth_main_get_metadata_type (metadatum, attributes[i]);
 			if (value_type != NULL) {
 				/* See the exif data code above for an explanation. */
+#if EXIV2_TEST_VERSION(0,28,0)
+				Exiv2::Value::UniquePtr value = Exiv2::Value::create (Exiv2::TypeInfo::typeId (value_type));
+#else
 				Exiv2::Value::AutoPtr value = Exiv2::Value::create (Exiv2::TypeInfo::typeId (value_type));
+#endif
 				Exiv2::XmpKey xmp_key(key);
 
 				const char *raw_value;
@@ -1353,7 +1413,11 @@ exiv2_write_metadata_private (Exiv2::Image::AutoPtr  image,
 				}
 			}
 		}
+#if EXIV2_TEST_VERSION(0,28,0)
+		catch (Exiv2::Error& e) {
+#else
 		catch (Exiv2::AnyError& e) {
+#endif
 			/* we don't care about invalid key errors */
 			g_warning ("%s", e.what());
 		}
@@ -1369,7 +1433,11 @@ exiv2_write_metadata_private (Exiv2::Image::AutoPtr  image,
 		image->setXmpData(xd);
 		image->writeMetadata();
 	}
+#if EXIV2_TEST_VERSION(0,28,0)
+	catch (Exiv2::Error& e) {
+#else
 	catch (Exiv2::AnyError& e) {
+#endif
 		g_warning ("%s", e.what());
 	}
 
@@ -1396,16 +1464,33 @@ exiv2_write_metadata (GthImageSaveData *data)
 {
 	if (exiv2_supports_writes (data->mime_type) && (data->file_data != NULL)) {
 		try {
+#if EXIV2_TEST_VERSION(0,28,0)
+			Exiv2::Image::UniquePtr image = Exiv2::ImageFactory::open ((Exiv2::byte*) data->buffer, data->buffer_size);
+#else
 			Exiv2::Image::AutoPtr image = Exiv2::ImageFactory::open ((Exiv2::byte*) data->buffer, data->buffer_size);
+#endif
 			g_assert (image.get() != 0);
 
+#if EXIV2_TEST_VERSION(0,28,0)
+			Exiv2::DataBuf buf = exiv2_write_metadata_private (std::move(image), data->file_data->info, data->image);
+#else
 			Exiv2::DataBuf buf = exiv2_write_metadata_private (image, data->file_data->info, data->image);
+#endif
 
 			g_free (data->buffer);
+#if EXIV2_TEST_VERSION(0,28,0)
+			data->buffer = g_memdup (buf.data(), buf.size());
+			data->buffer_size = buf.size();
+#else
 			data->buffer = g_memdup (buf.pData_, buf.size_);
 			data->buffer_size = buf.size_;
+#endif
 		}
+#if EXIV2_TEST_VERSION(0,28,0)
+		catch (Exiv2::Error& e) {
+#else
 		catch (Exiv2::AnyError& e) {
+#endif
 			if (data->error != NULL)
 				*data->error = g_error_new_literal (G_IO_ERROR, G_IO_ERROR_FAILED, e.what());
 			g_warning ("%s\n", e.what());
@@ -1426,16 +1511,33 @@ exiv2_write_metadata_to_buffer (void      **buffer,
 				GError    **error)
 {
 	try {
+#if EXIV2_TEST_VERSION(0,28,0)
+		Exiv2::Image::UniquePtr image = Exiv2::ImageFactory::open ((Exiv2::byte*) *buffer, *buffer_size);
+#else
 		Exiv2::Image::AutoPtr image = Exiv2::ImageFactory::open ((Exiv2::byte*) *buffer, *buffer_size);
+#endif
 		g_assert (image.get() != 0);
 
+#if EXIV2_TEST_VERSION(0,28,0)
+		Exiv2::DataBuf buf = exiv2_write_metadata_private (std::move(image), info, image_data);
+#else
 		Exiv2::DataBuf buf = exiv2_write_metadata_private (image, info, image_data);
+#endif
 
 		g_free (*buffer);
+#if EXIV2_TEST_VERSION(0,28,0)
+		*buffer = g_memdup (buf.data(), buf.size());
+		*buffer_size = buf.size();
+#else
 		*buffer = g_memdup (buf.pData_, buf.size_);
 		*buffer_size = buf.size_;
+#endif
 	}
+#if EXIV2_TEST_VERSION(0,28,0)
+	catch (Exiv2::Error& e) {
+#else
 	catch (Exiv2::AnyError& e) {
+#endif
 		if (error != NULL)
 			*error = g_error_new_literal (G_IO_ERROR, G_IO_ERROR_FAILED, e.what());
 		return FALSE;
@@ -1452,7 +1554,11 @@ exiv2_clear_metadata (void   **buffer,
 		      GError **error)
 {
 	try {
+#if EXIV2_TEST_VERSION(0,28,0)
+		Exiv2::Image::UniquePtr image = Exiv2::ImageFactory::open ((Exiv2::byte*) *buffer, *buffer_size);
+#else
 		Exiv2::Image::AutoPtr image = Exiv2::ImageFactory::open ((Exiv2::byte*) *buffer, *buffer_size);
+#endif
 
 		if (image.get() == 0) {
 			if (error != NULL)
@@ -1464,7 +1570,11 @@ exiv2_clear_metadata (void   **buffer,
 			image->clearMetadata();
 			image->writeMetadata();
 		}
+#if EXIV2_TEST_VERSION(0,28,0)
+		catch (Exiv2::Error& e) {
+#else
 		catch (Exiv2::AnyError& e) {
+#endif
 			g_warning ("%s", e.what());
 		}
 
@@ -1473,10 +1583,19 @@ exiv2_clear_metadata (void   **buffer,
 		Exiv2::DataBuf buf = io.read(io.size());
 
 		g_free (*buffer);
+#if EXIV2_TEST_VERSION(0,28,0)
+		*buffer = g_memdup (buf.data(), buf.size());
+		*buffer_size = buf.size();
+#else
 		*buffer = g_memdup (buf.pData_, buf.size_);
 		*buffer_size = buf.size_;
+#endif
 	}
+#if EXIV2_TEST_VERSION(0,28,0)
+	catch (Exiv2::Error& e) {
+#else
 	catch (Exiv2::AnyError& e) {
+#endif
 		if (error != NULL)
 			*error = g_error_new_literal (G_IO_ERROR, G_IO_ERROR_FAILED, e.what());
 		return FALSE;
@@ -1509,26 +1628,44 @@ exiv2_generate_thumbnail (const char *uri,
 		if (path == NULL)
 			return NULL;
 
+#if EXIV2_TEST_VERSION(0,28,0)
+		Exiv2::Image::UniquePtr image = Exiv2::ImageFactory::open (path);
+#else
 		Exiv2::Image::AutoPtr image = Exiv2::ImageFactory::open (path);
+#endif
 		image->readMetadata ();
 		Exiv2::ExifThumbC exifThumb (image->exifData ());
 		Exiv2::DataBuf thumb = exifThumb.copy ();
 
 		g_free (path);
 
+#if EXIV2_TEST_VERSION(0,28,0)
+		if (thumb.data() == NULL)
+#else
 		if (thumb.pData_ == NULL)
+#endif
 			return NULL;
 
 		Exiv2::ExifData &ed = image->exifData();
 
+#if EXIV2_TEST_VERSION(0,28,0)
+		long orientation = (ed["Exif.Image.Orientation"].count() > 0) ? ed["Exif.Image.Orientation"].toUint32() : 1;
+		long image_width = (ed["Exif.Photo.PixelXDimension"].count() > 0) ? ed["Exif.Photo.PixelXDimension"].toUint32() : -1;
+		long image_height = (ed["Exif.Photo.PixelYDimension"].count() > 0) ? ed["Exif.Photo.PixelYDimension"].toUint32() : -1;
+#else
 		long orientation = (ed["Exif.Image.Orientation"].count() > 0) ? ed["Exif.Image.Orientation"].toLong() : 1;
 		long image_width = (ed["Exif.Photo.PixelXDimension"].count() > 0) ? ed["Exif.Photo.PixelXDimension"].toLong() : -1;
 		long image_height = (ed["Exif.Photo.PixelYDimension"].count() > 0) ? ed["Exif.Photo.PixelYDimension"].toLong() : -1;
+#endif
 
 		if ((orientation != 1) || (image_width <= 0) || (image_height <= 0))
 			return NULL;
 
+#if EXIV2_TEST_VERSION(0,28,0)
+		GInputStream *stream = g_memory_input_stream_new_from_data (thumb.data(), thumb.size(), NULL);
+#else
 		GInputStream *stream = g_memory_input_stream_new_from_data (thumb.pData_, thumb.size_, NULL);
+#endif
 		pixbuf = gdk_pixbuf_new_from_stream (stream, NULL, NULL);
 		g_object_unref (stream);
 
@@ -1582,7 +1719,11 @@ exiv2_generate_thumbnail (const char *uri,
 		gdk_pixbuf_set_option (pixbuf, "orientation", orientation_s);
 		g_free (orientation_s);
 	}
+#if EXIV2_TEST_VERSION(0,28,0)
+	catch (Exiv2::Error& e) {
+#else
 	catch (Exiv2::AnyError& e) {
+#endif
 	}
 
 	return pixbuf;
-- 
2.41.0