[tracker/libtracker-extract-fixes: 1/9] libtracker-extract: Add tracker_exif_new() and tracker_exif_free().
- From: Carlos Garnacho <carlosg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [tracker/libtracker-extract-fixes: 1/9] libtracker-extract: Add tracker_exif_new() and tracker_exif_free().
- Date: Thu, 8 Apr 2010 12:07:45 +0000 (UTC)
commit e63ed5244747e3ac21860450567c0dafe4b21aa2
Author: Carlos Garnacho <carlosg gnome org>
Date: Thu Apr 8 13:42:57 2010 +0200
libtracker-extract: Add tracker_exif_new() and tracker_exif_free().
These functions deprecate tracker_exif_read().
src/libtracker-extract/tracker-exif.c | 139 ++++++++++++++++++++++++++------
src/libtracker-extract/tracker-exif.h | 13 +++-
2 files changed, 125 insertions(+), 27 deletions(-)
---
diff --git a/src/libtracker-extract/tracker-exif.c b/src/libtracker-extract/tracker-exif.c
index df9e4fc..d42fc9b 100644
--- a/src/libtracker-extract/tracker-exif.c
+++ b/src/libtracker-extract/tracker-exif.c
@@ -297,37 +297,16 @@ get_value (ExifData *exif,
#endif /* HAVE_LIBEXIF */
-/**
- * tracker_exif_read:
- * @buffer: a chunk of data with exif data in it.
- * @len: the size of @buffer.
- * @uri: the URI this is related to.
- * @data: a pointer to a TrackerExifData struture to populate.
- *
- * This function takes @len bytes of @buffer and runs it through the
- * EXIF library. The result is that @data is populated with the EXIF
- * data found in @uri.
- *
- * Returns: %TRUE if the @data was populated successfully, otherwise
- * %FALSE is returned.
- *
- * Since: 0.8
- **/
-gboolean
-tracker_exif_read (const unsigned char *buffer,
- size_t len,
- const gchar *uri,
- TrackerExifData *data)
+static gboolean
+tracker_exif_parse (const unsigned char *buffer,
+ size_t len,
+ const gchar *uri,
+ TrackerExifData *data)
{
#ifdef HAVE_LIBEXIF
ExifData *exif;
#endif
- g_return_val_if_fail (buffer != NULL, FALSE);
- g_return_val_if_fail (len > 0, FALSE);
- g_return_val_if_fail (uri != NULL, FALSE);
- g_return_val_if_fail (data != NULL, FALSE);
-
memset (data, 0, sizeof (TrackerExifData));
#ifdef HAVE_LIBEXIF
@@ -395,3 +374,111 @@ tracker_exif_read (const unsigned char *buffer,
return TRUE;
}
+/**
+ * tracker_exif_read:
+ * @buffer: a chunk of data with exif data in it.
+ * @len: the size of @buffer.
+ * @uri: the URI this is related to.
+ * @data: a pointer to a TrackerExifData struture to populate.
+ *
+ * This function takes @len bytes of @buffer and runs it through the
+ * EXIF library. The result is that @data is populated with the EXIF
+ * data found in @uri.
+ *
+ * Returns: %TRUE if the @data was populated successfully, otherwise
+ * %FALSE is returned.
+ *
+ * Since: 0.8
+ *
+ * Deprecated: 0.9. Use tracker_exif_new() instead.
+ **/
+gboolean
+tracker_exif_read (const unsigned char *buffer,
+ size_t len,
+ const gchar *uri,
+ TrackerExifData *data)
+{
+ g_return_val_if_fail (buffer != NULL, FALSE);
+ g_return_val_if_fail (len > 0, FALSE);
+ g_return_val_if_fail (uri != NULL, FALSE);
+ g_return_val_if_fail (data != NULL, FALSE);
+
+ return tracker_exif_parse (buffer, len, uri, data);
+}
+
+/**
+ * tracker_exif_new:
+ * @buffer: a chunk of data with exif data in it.
+ * @len: the size of @buffer.
+ * @uri: the URI this is related to.
+ *
+ * This function takes @len bytes of @buffer and runs it through the
+ * EXIF library.
+ *
+ * Returns: a newly allocated #TrackerExifData struct if EXIF data was
+ * found, %NULL otherwise. Free the returned struct with
+ * tracker_exif_free().
+ *
+ * Since: 0.9
+ **/
+TrackerExifData *
+tracker_exif_new (const guchar *buffer,
+ size_t len,
+ const gchar *uri)
+{
+ TrackerExifData *data;
+
+ g_return_val_if_fail (buffer != NULL, NULL);
+ g_return_val_if_fail (len > 0, NULL);
+ g_return_val_if_fail (uri != NULL, NULL);
+
+ data = g_new0 (TrackerExifData, 1);
+
+ if (!tracker_exif_parse (buffer, len, uri, data)) {
+ tracker_exif_free (data, TRUE);
+ return NULL;
+ }
+
+ return data;
+}
+
+/**
+ * tracker_exif_free:
+ * @data: a #TrackerExifData
+ * @free_members: %TRUE to free all struct members.
+ *
+ * Frees @data, and optionally all struct members if @free_members
+ * is %TRUE.
+ *
+ * Since: 0.9
+ **/
+void
+tracker_exif_free (TrackerExifData *data,
+ gboolean free_members)
+{
+ if (free_members) {
+ g_free (data->y_dimension);
+ g_free (data->x_dimension);
+ g_free (data->image_width);
+ g_free (data->document_name);
+ g_free (data->time);
+ g_free (data->time_original);
+ g_free (data->artist);
+ g_free (data->user_comment);
+ g_free (data->description);
+ g_free (data->make);
+ g_free (data->model);
+ g_free (data->orientation);
+ g_free (data->exposure_time);
+ g_free (data->fnumber);
+ g_free (data->flash);
+ g_free (data->focal_length);
+ g_free (data->iso_speed_ratings);
+ g_free (data->metering_mode);
+ g_free (data->white_balance);
+ g_free (data->copyright);
+ g_free (data->software);
+ }
+
+ g_free (data);
+}
diff --git a/src/libtracker-extract/tracker-exif.h b/src/libtracker-extract/tracker-exif.h
index 481d1db..6dfce3e 100644
--- a/src/libtracker-extract/tracker-exif.h
+++ b/src/libtracker-extract/tracker-exif.h
@@ -52,10 +52,21 @@ typedef struct {
gchar *software;
} TrackerExifData;
+#ifndef TRACKER_DISABLE_DEPRECATED
+
gboolean tracker_exif_read (const unsigned char *buffer,
size_t len,
const gchar *uri,
- TrackerExifData *data);
+ TrackerExifData *data) G_GNUC_DEPRECATED;
+
+#endif /* TRACKER_DISABLE_DEPRECATED */
+
+TrackerExifData * tracker_exif_new (const guchar *buffer,
+ size_t len,
+ const gchar *uri);
+
+void tracker_exif_free (TrackerExifData *data,
+ gboolean free_members);
G_END_DECLS
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]