[tracker/extractor-rules-list: 3/5] extractor: mass change extractors
- From: Carlos Garnacho <carlosg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [tracker/extractor-rules-list: 3/5] extractor: mass change extractors
- Date: Thu, 10 Mar 2011 16:15:54 +0000 (UTC)
commit 7b0391b0b66704b201be0b54c7a72327b9049db7
Author: Carlos Garnacho <carlosg gnome org>
Date: Thu Mar 10 13:15:32 2011 +0100
extractor: mass change extractors
The API has changed, now the following function must be exported:
gboolean tracker_extract_get_metadata (const gchar *uri,
const gchar *mimetype,
TrackerSparqlBuilder *preupdate,
TrackerSparqlBuilder *metadata);
This was done in one go as there's no painless way to do this...
src/tracker-extract/tracker-extract-abw.c | 25 ++----
src/tracker-extract/tracker-extract-flac.c | 28 ++----
src/tracker-extract/tracker-extract-gif.c | 29 ++-----
.../tracker-extract-gstreamer-helix.c | 49 +++--------
src/tracker-extract/tracker-extract-gstreamer.c | 93 +++++---------------
src/tracker-extract/tracker-extract-gupnp-dlna.c | 79 ++++------------
src/tracker-extract/tracker-extract-html.c | 25 ++----
src/tracker-extract/tracker-extract-icon.c | 24 ++----
src/tracker-extract/tracker-extract-jpeg.c | 30 ++----
src/tracker-extract/tracker-extract-libxine.c | 29 ++----
src/tracker-extract/tracker-extract-mp3.c | 35 ++-----
src/tracker-extract/tracker-extract-mplayer.c | 26 ++----
src/tracker-extract/tracker-extract-msoffice-xml.c | 28 ++-----
src/tracker-extract/tracker-extract-msoffice.c | 57 ++-----------
src/tracker-extract/tracker-extract-oasis.c | 54 ++----------
src/tracker-extract/tracker-extract-pdf.c | 39 +++-----
src/tracker-extract/tracker-extract-playlist.c | 31 ++-----
src/tracker-extract/tracker-extract-png.c | 39 +++------
src/tracker-extract/tracker-extract-ps.c | 35 +++----
src/tracker-extract/tracker-extract-text.c | 25 ++----
src/tracker-extract/tracker-extract-tiff.c | 26 ++----
src/tracker-extract/tracker-extract-totem.c | 28 ++----
src/tracker-extract/tracker-extract-vorbis.c | 29 ++-----
src/tracker-extract/tracker-extract-xmp.c | 28 ++----
24 files changed, 234 insertions(+), 657 deletions(-)
---
diff --git a/src/tracker-extract/tracker-extract-abw.c b/src/tracker-extract/tracker-extract-abw.c
index f89d088..6d42aa7 100644
--- a/src/tracker-extract/tracker-extract-abw.c
+++ b/src/tracker-extract/tracker-extract-abw.c
@@ -37,20 +37,11 @@
#include <libtracker-extract/tracker-extract.h>
-static void extract_abw (const gchar *uri,
- TrackerSparqlBuilder *preupdate,
- TrackerSparqlBuilder *metadata);
-
-static TrackerExtractData data[] = {
- { "application/x-abiword", extract_abw },
- { NULL, NULL }
-};
-
-
-static void
-extract_abw (const gchar *uri,
- TrackerSparqlBuilder *preupdate,
- TrackerSparqlBuilder *metadata)
+G_MODULE_EXPORT gboolean
+tracker_extract_get_metadata (const gchar *uri,
+ const gchar *mimetype,
+ TrackerSparqlBuilder *preupdate,
+ TrackerSparqlBuilder *metadata)
{
FILE *f;
gchar *filename;
@@ -111,10 +102,6 @@ extract_abw (const gchar *uri,
tracker_file_close (f, FALSE);
}
-}
-TrackerExtractData *
-tracker_extract_get_data (void)
-{
- return data;
+ return TRUE;
}
diff --git a/src/tracker-extract/tracker-extract-flac.c b/src/tracker-extract/tracker-extract-flac.c
index ceb0238..5062d79 100644
--- a/src/tracker-extract/tracker-extract-flac.c
+++ b/src/tracker-extract/tracker-extract-flac.c
@@ -64,15 +64,6 @@ typedef struct {
guint64 total;
} FlacData;
-static void extract_flac (const gchar *uri,
- TrackerSparqlBuilder *preupdate,
- TrackerSparqlBuilder *metadata);
-
-static TrackerExtractData extract_data[] = {
- { "audio/x-flac", extract_flac },
- { NULL, NULL }
-};
-
static void
parse_vorbis_comments (FLAC__StreamMetadata_VorbisComment *comment,
FlacData *fd)
@@ -159,10 +150,11 @@ add_tuple (TrackerSparqlBuilder *metadata,
}
}
-static void
-extract_flac (const gchar *uri,
- TrackerSparqlBuilder *preupdate,
- TrackerSparqlBuilder *metadata)
+G_MODULE_EXPORT gboolean
+tracker_extract_get_metadata (const gchar *uri,
+ const gchar *mimetype,
+ TrackerSparqlBuilder *preupdate,
+ TrackerSparqlBuilder *metadata)
{
FLAC__Metadata_SimpleIterator *iter;
FLAC__StreamMetadata *stream = NULL, *vorbis, *picture;
@@ -178,7 +170,7 @@ extract_flac (const gchar *uri,
if (size < 18) {
g_free (filename);
- return;
+ return FALSE;
}
iter = FLAC__metadata_simple_iterator_new ();
@@ -187,7 +179,7 @@ extract_flac (const gchar *uri,
if (!success) {
FLAC__metadata_simple_iterator_delete (iter);
- return;
+ return FALSE;
}
while (!FLAC__metadata_simple_iterator_is_last (iter)) {
@@ -439,10 +431,6 @@ extract_flac (const gchar *uri,
g_free (fd.organisation);
g_free (fd.location);
g_free (fd.publisher);
-}
-TrackerExtractData *
-tracker_extract_get_data (void)
-{
- return extract_data;
+ return TRUE;
}
diff --git a/src/tracker-extract/tracker-extract-gif.c b/src/tracker-extract/tracker-extract-gif.c
index d5fecb0..58cb598 100644
--- a/src/tracker-extract/tracker-extract-gif.c
+++ b/src/tracker-extract/tracker-extract-gif.c
@@ -45,15 +45,6 @@ typedef struct {
gchar *comment;
} GifData;
-static void extract_gif (const gchar *filename,
- TrackerSparqlBuilder *preupdate,
- TrackerSparqlBuilder *metadata);
-
-static TrackerExtractData data[] = {
- { "image/gif", extract_gif },
- { NULL, NULL }
-};
-
typedef struct {
unsigned int byteCount;
char *bytes;
@@ -487,10 +478,11 @@ read_metadata (TrackerSparqlBuilder *preupdate,
}
-static void
-extract_gif (const gchar *uri,
- TrackerSparqlBuilder *preupdate,
- TrackerSparqlBuilder *metadata)
+G_MODULE_EXPORT gboolean
+tracker_extract_get_metadata (const gchar *uri,
+ const gchar *mimetype,
+ TrackerSparqlBuilder *preupdate,
+ TrackerSparqlBuilder *metadata)
{
goffset size;
GifFileType *gifFile = NULL;
@@ -501,12 +493,12 @@ extract_gif (const gchar *uri,
if (size < 64) {
g_free (filename);
- return;
+ return FALSE;
}
if ((gifFile = DGifOpenFileName (filename)) == NULL) {
PrintGifError ();
- return;
+ return FALSE;
}
g_free (filename);
@@ -521,10 +513,5 @@ extract_gif (const gchar *uri,
PrintGifError ();
}
-}
-
-TrackerExtractData *
-tracker_extract_get_data (void)
-{
- return data;
+ return TRUE;
}
diff --git a/src/tracker-extract/tracker-extract-gstreamer-helix.c b/src/tracker-extract/tracker-extract-gstreamer-helix.c
index 43e2bd8..b18bd6d 100644
--- a/src/tracker-extract/tracker-extract-gstreamer-helix.c
+++ b/src/tracker-extract/tracker-extract-gstreamer-helix.c
@@ -68,23 +68,6 @@ typedef struct {
} MetadataExtractor;
-static void extract_gstreamer_helix_audio (const gchar *uri,
- TrackerSparqlBuilder *preupdate,
- TrackerSparqlBuilder *metadata);
-static void extract_gstreamer_helix_video (const gchar *uri,
- TrackerSparqlBuilder *preupdate,
- TrackerSparqlBuilder *metadata);
-
-static TrackerExtractData data[] = {
- { "audio/vnd.rn-realaudio", extract_gstreamer_helix_audio },
- { "audio/x-pn-realaudio", extract_gstreamer_helix_audio },
- { "audio/x-pn-realaudio-plugin", extract_gstreamer_helix_audio },
- { "video/vnd.rn-realvideo", extract_gstreamer_helix_video },
- { "video/x-pn-realvideo", extract_gstreamer_helix_video },
- { "application/vnd.rn-realmedia", extract_gstreamer_helix_video },
- { NULL, NULL }
-};
-
static void
caps_set (GObject *object,
MetadataExtractor *extractor,
@@ -858,24 +841,20 @@ tracker_extract_gstreamer_helix (const gchar *uri,
g_slice_free (MetadataExtractor, extractor);
}
-static void
-extract_gstreamer_helix_audio (const gchar *uri,
- TrackerSparqlBuilder *preupdate,
- TrackerSparqlBuilder *metadata)
-{
- tracker_extract_gstreamer_helix (uri, preupdate, metadata, EXTRACT_MIME_AUDIO);
-}
-
-static void
-extract_gstreamer_helix_video (const gchar *uri,
- TrackerSparqlBuilder *preupdate,
- TrackerSparqlBuilder *metadata)
+G_MODULE_EXPORT gboolean
+tracker_extract_get_metadata (const gchar *uri,
+ const gchar *mimetype,
+ TrackerSparqlBuilder *preupdate,
+ TrackerSparqlBuilder *metadata)
{
- tracker_extract_gstreamer_helix (uri, preupdate, metadata, EXTRACT_MIME_VIDEO);
-}
+ if (g_str_has_prefix (mimetype, "audio/")) {
+ tracker_extract_gstreamer_helix (uri, preupdate, metadata, EXTRACT_MIME_AUDIO);
+ } else if (g_str_has_prefix (mimetype, "video/") ||
+ strcmp (mimetype, "application/vnd.rn-realmedia") == 0) {
+ tracker_extract_gstreamer_helix (uri, preupdate, metadata, EXTRACT_MIME_VIDEO);
+ } else {
+ return FALSE;
+ }
-TrackerExtractData *
-tracker_extract_get_data (void)
-{
- return data;
+ return TRUE;
}
diff --git a/src/tracker-extract/tracker-extract-gstreamer.c b/src/tracker-extract/tracker-extract-gstreamer.c
index 3b66086..ce613a2 100644
--- a/src/tracker-extract/tracker-extract-gstreamer.c
+++ b/src/tracker-extract/tracker-extract-gstreamer.c
@@ -123,34 +123,6 @@ typedef struct {
} MetadataExtractor;
-static void extract_gstreamer_audio (const gchar *uri,
- TrackerSparqlBuilder *preupdate,
- TrackerSparqlBuilder *metadata);
-static void extract_gstreamer_video (const gchar *uri,
- TrackerSparqlBuilder *preupdate,
- TrackerSparqlBuilder *metadata);
-static void extract_gstreamer_image (const gchar *uri,
- TrackerSparqlBuilder *preupdate,
- TrackerSparqlBuilder *metadata);
-static void extract_gstreamer_svg (const gchar *uri,
- TrackerSparqlBuilder *preupdate,
- TrackerSparqlBuilder *metadata);
-static void extract_gstreamer_guess (const gchar *uri,
- TrackerSparqlBuilder *preupdate,
- TrackerSparqlBuilder *metadata);
-
-static TrackerExtractData data[] = {
- { "audio/*", extract_gstreamer_audio },
- { "video/*", extract_gstreamer_video },
- { "image/*", extract_gstreamer_image },
- { "image/svg+xml", extract_gstreamer_svg },
- /* Tell gstreamer to guess if mimetype guessing returns video also for audio files */
- { "video/3gpp", extract_gstreamer_guess },
- { "video/mp4", extract_gstreamer_guess },
- { "video/x-ms-asf", extract_gstreamer_guess },
- { NULL, NULL }
-};
-
/* Not using define directly since we might want to make this dynamic */
#ifdef TRACKER_EXTRACT_GSTREAMER_USE_TAGREADBIN
const gboolean use_tagreadbin = TRUE;
@@ -1346,50 +1318,27 @@ tracker_extract_gstreamer (const gchar *uri,
g_slice_free (MetadataExtractor, extractor);
}
-
-static void
-extract_gstreamer_audio (const gchar *uri,
- TrackerSparqlBuilder *preupdate,
- TrackerSparqlBuilder *metadata)
-{
- tracker_extract_gstreamer (uri, preupdate, metadata, EXTRACT_MIME_AUDIO);
-}
-
-static void
-extract_gstreamer_video (const gchar *uri,
- TrackerSparqlBuilder *preupdate,
- TrackerSparqlBuilder *metadata)
-{
- tracker_extract_gstreamer (uri, preupdate, metadata, EXTRACT_MIME_VIDEO);
-}
-
-static void
-extract_gstreamer_image (const gchar *uri,
- TrackerSparqlBuilder *preupdate,
- TrackerSparqlBuilder *metadata)
-{
- tracker_extract_gstreamer (uri, preupdate, metadata, EXTRACT_MIME_IMAGE);
-}
-
-static void
-extract_gstreamer_svg (const gchar *uri,
- TrackerSparqlBuilder *preupdate,
- TrackerSparqlBuilder *metadata)
-{
- tracker_extract_gstreamer (uri, preupdate, metadata, EXTRACT_MIME_SVG);
-}
-
-static void
-extract_gstreamer_guess (const gchar *uri,
- TrackerSparqlBuilder *preupdate,
- TrackerSparqlBuilder *metadata)
+G_MODULE_EXPORT gboolean
+tracker_extract_get_metadata (const gchar *uri,
+ const gchar *mimetype,
+ TrackerSparqlBuilder *preupdate,
+ TrackerSparqlBuilder *metadata)
{
- tracker_extract_gstreamer (uri, preupdate, metadata, EXTRACT_MIME_GUESS);
-}
+ if (strcmp (mimetype, "image/svg+xml") == 0) {
+ tracker_extract_gstreamer (uri, preupdate, metadata, EXTRACT_MIME_SVG);
+ } else if (strcmp (mimetype, "video/3gpp") == 0 ||
+ strcmp (mimetype, "video/mp4") == 0 ||
+ strcmp (mimetype, "video/x-ms-asf") == 0) {
+ tracker_extract_gstreamer (uri, preupdate, metadata, EXTRACT_MIME_GUESS);
+ } else if (g_str_has_prefix (mimetype, "audio/")) {
+ tracker_extract_gstreamer (uri, preupdate, metadata, EXTRACT_MIME_AUDIO);
+ } else if (g_str_has_prefix (mimetype, "video/")) {
+ tracker_extract_gstreamer (uri, preupdate, metadata, EXTRACT_MIME_VIDEO);
+ } else if (g_str_has_prefix (mimetype, "image/")) {
+ tracker_extract_gstreamer (uri, preupdate, metadata, EXTRACT_MIME_IMAGE);
+ } else {
+ return FALSE;
+ }
-TrackerExtractData *
-tracker_extract_get_data (void)
-{
- return data;
+ return TRUE;
}
-
diff --git a/src/tracker-extract/tracker-extract-gupnp-dlna.c b/src/tracker-extract/tracker-extract-gupnp-dlna.c
index aacd0da..6f8c1ca 100644
--- a/src/tracker-extract/tracker-extract-gupnp-dlna.c
+++ b/src/tracker-extract/tracker-extract-gupnp-dlna.c
@@ -83,30 +83,6 @@ long long int llroundl(long double x);
#define GST_TAG_DEVICE_MAKE "device-make"
#endif
-static void extract_gupnp_dlna_audio (const gchar *uri,
- TrackerSparqlBuilder *preupdate,
- TrackerSparqlBuilder *metadata);
-static void extract_gupnp_dlna_video (const gchar *uri,
- TrackerSparqlBuilder *preupdate,
- TrackerSparqlBuilder *metadata);
-static void extract_gupnp_dlna_image (const gchar *uri,
- TrackerSparqlBuilder *preupdate,
- TrackerSparqlBuilder *metadata);
-static void extract_gupnp_dlna_guess (const gchar *uri,
- TrackerSparqlBuilder *preupdate,
- TrackerSparqlBuilder *metadata);
-
-static TrackerExtractData data[] = {
- { "audio/*", extract_gupnp_dlna_audio },
- { "video/*", extract_gupnp_dlna_video },
- { "image/*", extract_gupnp_dlna_image },
- { "dlna/*", extract_gupnp_dlna_guess },
- { "video/3gpp", extract_gupnp_dlna_guess },
- { "video/mp4", extract_gupnp_dlna_guess },
- { "video/x-ms-asf", extract_gupnp_dlna_guess },
- { NULL, NULL }
-};
-
typedef enum {
CONTENT_NONE,
CONTENT_GUESS,
@@ -839,41 +815,26 @@ extract_gupnp_dlna (const gchar *uri,
g_object_unref (dlna_info);
}
-static void
-extract_gupnp_dlna_audio (const gchar *uri,
- TrackerSparqlBuilder *preupdate,
- TrackerSparqlBuilder *metadata)
-{
- extract_gupnp_dlna (uri, preupdate, metadata, CONTENT_AUDIO);
-}
-
-static void
-extract_gupnp_dlna_video (const gchar *uri,
- TrackerSparqlBuilder *preupdate,
- TrackerSparqlBuilder *metadata)
-{
- extract_gupnp_dlna (uri, preupdate, metadata, CONTENT_VIDEO);
-}
-
-static void
-extract_gupnp_dlna_image (const gchar *uri,
- TrackerSparqlBuilder *preupdate,
- TrackerSparqlBuilder *metadata)
+G_MODULE_EXPORT gboolean
+tracker_extract_get_metadata (const gchar *uri,
+ const gchar *mimetype,
+ TrackerSparqlBuilder *preupdate,
+ TrackerSparqlBuilder *metadata)
{
- extract_gupnp_dlna (uri, preupdate, metadata, CONTENT_IMAGE);
-}
-
-static void
-extract_gupnp_dlna_guess (const gchar *uri,
- TrackerSparqlBuilder *preupdate,
- TrackerSparqlBuilder *metadata)
-{
- extract_gupnp_dlna (uri, preupdate, metadata, CONTENT_GUESS);
-}
-
+ if (strcmp (mimetype, "video/3gpp") == 0 ||
+ strcmp (mimetype, "video/mp4") == 0 ||
+ strcmp (mimetype, "video/x-ms-asf") == 0 ||
+ g_str_has_prefix (mimetype, "dlna/")) {
+ extract_gupnp_dlna (uri, preupdate, metadata, CONTENT_GUESS);
+ } else if (g_str_has_prefix (mimetype, "video/")) {
+ extract_gupnp_dlna (uri, preupdate, metadata, CONTENT_VIDEO);
+ } else if (g_str_has_prefix (mimetype, "audio/")) {
+ extract_gupnp_dlna (uri, preupdate, metadata, CONTENT_AUDIO);
+ } else if (g_str_has_prefix (mimetype, "image/")) {
+ extract_gupnp_dlna (uri, preupdate, metadata, CONTENT_IMAGE);
+ } else {
+ return FALSE;
+ }
-TrackerExtractData *
-tracker_extract_get_data (void)
-{
- return data;
+ return TRUE;
}
diff --git a/src/tracker-extract/tracker-extract-html.c b/src/tracker-extract/tracker-extract-html.c
index c727780..b15407c 100644
--- a/src/tracker-extract/tracker-extract-html.c
+++ b/src/tracker-extract/tracker-extract-html.c
@@ -45,16 +45,6 @@ typedef struct {
guint n_bytes_remaining;
} parser_data;
-static void extract_html (const gchar *filename,
- TrackerSparqlBuilder *preupdate,
- TrackerSparqlBuilder *metadata);
-
-static TrackerExtractData data[] = {
- { "text/html", extract_html },
- { "application/xhtml+xml", extract_html },
- { NULL, NULL }
-};
-
static gboolean
has_attribute (const gchar **attrs,
const gchar *attr,
@@ -240,10 +230,11 @@ parser_characters (void *data,
}
}
-static void
-extract_html (const gchar *uri,
- TrackerSparqlBuilder *preupdate,
- TrackerSparqlBuilder *metadata)
+G_MODULE_EXPORT gboolean
+tracker_extract_get_metadata (const gchar *uri,
+ const gchar *mimetype,
+ TrackerSparqlBuilder *preupdate,
+ TrackerSparqlBuilder *metadata)
{
TrackerConfig *config;
htmlDocPtr doc;
@@ -322,10 +313,6 @@ extract_html (const gchar *uri,
g_string_free (pd.plain_text, TRUE);
g_string_free (pd.title, TRUE);
-}
-TrackerExtractData *
-tracker_extract_get_data (void)
-{
- return data;
+ return TRUE;
}
diff --git a/src/tracker-extract/tracker-extract-icon.c b/src/tracker-extract/tracker-extract-icon.c
index 0a6185f..add946e 100644
--- a/src/tracker-extract/tracker-extract-icon.c
+++ b/src/tracker-extract/tracker-extract-icon.c
@@ -22,15 +22,6 @@
#include <libtracker-common/tracker-file-utils.h>
#include <libtracker-extract/tracker-extract.h>
-static void extract_icon (const gchar *filename,
- TrackerSparqlBuilder *preupdate,
- TrackerSparqlBuilder *metadata);
-
-static TrackerExtractData data[] = {
- { "image/vnd.microsoft.icon", extract_icon },
- { NULL, NULL }
-};
-
#define ICON_HEADER_SIZE_16 3
#define ICON_IMAGE_METADATA_SIZE_8 16
@@ -133,10 +124,11 @@ find_max_width_and_height (const gchar *uri,
return TRUE;
}
-static void
-extract_icon (const gchar *uri,
- TrackerSparqlBuilder *preupdate,
- TrackerSparqlBuilder *metadata)
+G_MODULE_EXPORT gboolean
+tracker_extract_get_metadata (const gchar *uri,
+ const gchar *mimetype,
+ TrackerSparqlBuilder *preupdate,
+ TrackerSparqlBuilder *metadata)
{
guint max_width;
guint max_height;
@@ -158,10 +150,6 @@ extract_icon (const gchar *uri,
tracker_sparql_builder_object_int64 (metadata, (gint64) max_height);
}
}
-}
-TrackerExtractData *
-tracker_extract_get_data (void)
-{
- return data;
+ return TRUE;
}
diff --git a/src/tracker-extract/tracker-extract-jpeg.c b/src/tracker-extract/tracker-extract-jpeg.c
index fadfeb5..06cd43c 100644
--- a/src/tracker-extract/tracker-extract-jpeg.c
+++ b/src/tracker-extract/tracker-extract-jpeg.c
@@ -77,15 +77,6 @@ typedef struct {
const gchar *country;
} MergeData;
-static void extract_jpeg (const gchar *filename,
- TrackerSparqlBuilder *preupdate,
- TrackerSparqlBuilder *metadata);
-
-static TrackerExtractData data[] = {
- { "image/jpeg", extract_jpeg },
- { NULL, NULL }
-};
-
struct tej_error_mgr {
struct jpeg_error_mgr jpeg;
jmp_buf setjmp_buffer;
@@ -99,10 +90,11 @@ extract_jpeg_error_exit (j_common_ptr cinfo)
longjmp (h->setjmp_buffer, 1);
}
-static void
-extract_jpeg (const gchar *uri,
- TrackerSparqlBuilder *preupdate,
- TrackerSparqlBuilder *metadata)
+G_MODULE_EXPORT gboolean
+tracker_extract_get_metadata (const gchar *uri,
+ const gchar *mimetype,
+ TrackerSparqlBuilder *preupdate,
+ TrackerSparqlBuilder *metadata)
{
struct jpeg_decompress_struct cinfo;
struct tej_error_mgr tejerr;
@@ -116,6 +108,7 @@ extract_jpeg (const gchar *uri,
gchar *filename;
gchar *comment = NULL;
GPtrArray *keywords;
+ gboolean success = TRUE;
guint i;
filename = g_filename_from_uri (uri, NULL, NULL);
@@ -124,14 +117,14 @@ extract_jpeg (const gchar *uri,
if (size < 18) {
g_free (filename);
- return;
+ return FALSE;
}
f = tracker_file_open (filename, "rb", FALSE);
g_free (filename);
if (!f) {
- return;
+ return FALSE;
}
tracker_sparql_builder_predicate (metadata, "a");
@@ -142,6 +135,7 @@ extract_jpeg (const gchar *uri,
cinfo.err = jpeg_std_error (&tejerr.jpeg);
tejerr.jpeg.error_exit = extract_jpeg_error_exit;
if (setjmp (tejerr.setjmp_buffer)) {
+ success = FALSE;
goto fail;
}
@@ -630,10 +624,6 @@ extract_jpeg (const gchar *uri,
fail:
tracker_file_close (f, FALSE);
-}
-TrackerExtractData *
-tracker_extract_get_data (void)
-{
- return data;
+ return success;
}
diff --git a/src/tracker-extract/tracker-extract-libxine.c b/src/tracker-extract/tracker-extract-libxine.c
index 7e08bcd..743bfbf 100644
--- a/src/tracker-extract/tracker-extract-libxine.c
+++ b/src/tracker-extract/tracker-extract-libxine.c
@@ -28,10 +28,11 @@
#include <libtracker-extract/tracker-extract.h>
-static void
-tracker_extract_xine (const gchar *uri,
- TrackerSparqlBuilder *preupdate,
- TrackerSparqlBuilder *metadata)
+G_MODULE_EXPORT gboolean
+tracker_extract_get_metadata (const gchar *uri,
+ const gchar *mimetype,
+ TrackerSparqlBuilder *preupdate,
+ TrackerSparqlBuilder *metadata)
{
xine_t *xine_base;
xine_audio_port_t *audio_port;
@@ -59,7 +60,7 @@ tracker_extract_xine (const gchar *uri,
xine_base = xine_new ();
if (!xine_base) {
- return;
+ return FALSE;
}
xine_init (xine_base);
@@ -69,7 +70,7 @@ tracker_extract_xine (const gchar *uri,
if (!audio_port || !video_port) {
xine_exit (xine_base);
- return;
+ return FALSE;
}
stream = xine_stream_new (xine_base, audio_port, video_port);
@@ -78,7 +79,7 @@ tracker_extract_xine (const gchar *uri,
xine_close_audio_driver (xine_base, audio_port);
xine_close_video_driver (xine_base, video_port);
xine_exit (xine_base);
- return;
+ return FALSE;
}
mrl = g_filename_from_uri (uri, NULL, NULL);
@@ -89,7 +90,7 @@ tracker_extract_xine (const gchar *uri,
xine_close_audio_driver (xine_base, audio_port);
xine_close_video_driver (xine_base, video_port);
xine_exit (xine_base);
- return;
+ return FALSE;
}
g_free (mrl);
@@ -269,16 +270,6 @@ endofit:
xine_close_video_driver (xine_base, video_port);
xine_exit (xine_base);
-}
-
-TrackerExtractData data[] = {
- { "audio/*", tracker_extract_xine },
- { "video/*", tracker_extract_xine },
- { NULL, NULL }
-};
-TrackerExtractData *
-tracker_extract_get_data (void)
-{
- return data;
+ return TRUE;
}
diff --git a/src/tracker-extract/tracker-extract-mp3.c b/src/tracker-extract/tracker-extract-mp3.c
index 0c56894..770007e 100644
--- a/src/tracker-extract/tracker-extract-mp3.c
+++ b/src/tracker-extract/tracker-extract-mp3.c
@@ -179,10 +179,6 @@ typedef struct {
id3v2tag id3v24;
} MP3Data;
-static void extract_mp3 (const gchar *uri,
- TrackerSparqlBuilder *preupdate,
- TrackerSparqlBuilder *metadata);
-
enum {
MPEG_ERR,
MPEG_V1,
@@ -437,14 +433,6 @@ static gint spf_table[6] = {
48, 144, 144, 48, 144, 72
};
-static TrackerExtractData extract_data[] = {
- { "audio/mpeg", extract_mp3 },
- { "audio/x-mp3", extract_mp3 },
- { NULL, NULL }
-};
-
-
-
static void
id3tag_free (id3tag *tags)
{
@@ -2014,10 +2002,11 @@ parse_id3v2 (const gchar *data,
return offset;
}
-static void
-extract_mp3 (const gchar *uri,
- TrackerSparqlBuilder *preupdate,
- TrackerSparqlBuilder *metadata)
+G_MODULE_EXPORT gboolean
+tracker_extract_get_metadata (const gchar *uri,
+ const gchar *mimetype,
+ TrackerSparqlBuilder *preupdate,
+ TrackerSparqlBuilder *metadata)
{
gchar *filename;
int fd;
@@ -2034,7 +2023,7 @@ extract_mp3 (const gchar *uri,
if (size == 0) {
g_free (filename);
- return;
+ return FALSE;
}
md.size = size;
@@ -2050,13 +2039,13 @@ extract_mp3 (const gchar *uri,
fd = open (filename, O_RDONLY);
if (fd == -1) {
- return;
+ return FALSE;
}
}
#else
fd = open (filename, O_RDONLY);
if (fd == -1) {
- return;
+ return FALSE;
}
#endif
@@ -2080,7 +2069,7 @@ extract_mp3 (const gchar *uri,
if (buffer == NULL || buffer == (void*) -1) {
g_free (filename);
- return;
+ return FALSE;
}
if (!get_id3 (id3v1_buffer, ID3V1_SIZE, &md.id3v1)) {
@@ -2417,11 +2406,7 @@ extract_mp3 (const gchar *uri,
#endif
g_free (filename);
-}
-TrackerExtractData *
-tracker_extract_get_data (void)
-{
- return extract_data;
+ return TRUE;
}
diff --git a/src/tracker-extract/tracker-extract-mplayer.c b/src/tracker-extract/tracker-extract-mplayer.c
index f27e55a..3e1c373 100644
--- a/src/tracker-extract/tracker-extract-mplayer.c
+++ b/src/tracker-extract/tracker-extract-mplayer.c
@@ -31,16 +31,6 @@
#include <libtracker-extract/tracker-extract.h>
-static void extract_mplayer (const gchar *uri,
- TrackerSparqlBuilder *preupdate,
- TrackerSparqlBuilder *metadata);
-
-static TrackerExtractData extract_data[] = {
- { "audio/*", extract_mplayer },
- { "video/*", extract_mplayer },
- { NULL, NULL }
-};
-
static const gchar *video_tags[][2] = {
{ "ID_VIDEO_HEIGHT", "nfo:height" },
{ "ID_VIDEO_WIDTH", "nfo:width" },
@@ -110,10 +100,11 @@ copy_hash_table_entry (gpointer key,
}
}
-static void
-extract_mplayer (const gchar *uri,
- TrackerSparqlBuilder *preupdate,
- TrackerSparqlBuilder *metadata)
+G_MODULE_EXPORT gboolean
+tracker_extract_get_metadata (const gchar *uri,
+ const gchar *mimetype,
+ TrackerSparqlBuilder *preupdate,
+ TrackerSparqlBuilder *metadata)
{
gchar *argv[10];
gchar *mplayer;
@@ -293,11 +284,8 @@ extract_mplayer (const gchar *uri,
tracker_sparql_builder_object (metadata, "nfo:FileDataObject");
}
+ return TRUE;
}
-}
-TrackerExtractData *
-tracker_extract_get_data (void)
-{
- return extract_data;
+ return FALSE;
}
diff --git a/src/tracker-extract/tracker-extract-msoffice-xml.c b/src/tracker-extract/tracker-extract-msoffice-xml.c
index 85485e9..cdcc9d1 100644
--- a/src/tracker-extract/tracker-extract-msoffice-xml.c
+++ b/src/tracker-extract/tracker-extract-msoffice-xml.c
@@ -90,10 +90,6 @@ typedef struct {
gboolean preserve_attribute_present;
} MsOfficeXMLParserInfo;
-static void extract_msoffice_xml (const gchar *uri,
- TrackerSparqlBuilder *preupdate,
- TrackerSparqlBuilder *metadata);
-
static void msoffice_xml_content_parse_start (GMarkupParseContext *context,
const gchar *element_name,
const gchar **attribute_names,
@@ -159,15 +155,6 @@ static const GMarkupParser content_types_parser = {
static GQuark maximum_size_error_quark = 0;
-static TrackerExtractData data[] = {
- /* MSoffice2007*/
- { "application/vnd.openxmlformats-officedocument.presentationml.presentation", extract_msoffice_xml },
- { "application/vnd.openxmlformats-officedocument.presentationml.slideshow", extract_msoffice_xml },
- { "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", extract_msoffice_xml },
- { "application/vnd.openxmlformats-officedocument.wordprocessingml.document", extract_msoffice_xml },
- { NULL, NULL }
-};
-
/* ------------------------- CONTENT files parsing -----------------------------------*/
static void
@@ -719,10 +706,11 @@ msoffice_xml_get_file_type (const gchar *uri)
return file_type;
}
-static void
-extract_msoffice_xml (const gchar *uri,
- TrackerSparqlBuilder *preupdate,
- TrackerSparqlBuilder *metadata)
+G_MODULE_EXPORT gboolean
+tracker_extract_get_metadata (const gchar *uri,
+ const gchar *mimetype,
+ TrackerSparqlBuilder *preupdate,
+ TrackerSparqlBuilder *metadata)
{
MsOfficeXMLParserInfo info;
MsOfficeXMLFileType file_type;
@@ -790,10 +778,6 @@ extract_msoffice_xml (const gchar *uri,
}
g_markup_parse_context_free (context);
-}
-TrackerExtractData *
-tracker_extract_get_data (void)
-{
- return data;
+ return TRUE;
}
diff --git a/src/tracker-extract/tracker-extract-msoffice.c b/src/tracker-extract/tracker-extract-msoffice.c
index 61132e7..572ddd6 100644
--- a/src/tracker-extract/tracker-extract-msoffice.c
+++ b/src/tracker-extract/tracker-extract-msoffice.c
@@ -131,18 +131,6 @@ typedef struct {
const gchar *uri;
} MetadataInfo;
-static void extract_msoffice (const gchar *uri,
- TrackerSparqlBuilder *preupdate,
- TrackerSparqlBuilder *metadata);
-
-static TrackerExtractData data[] = {
- { "application/msword", extract_msoffice },
- { "application/vnd.ms-powerpoint", extract_msoffice },
- { "application/vnd.ms-excel", extract_msoffice },
- { "application/vnd.ms-*", extract_msoffice },
- { NULL, NULL }
-};
-
/* Valid range from \000 to \377 (0 to 255) */
#define octal_ascii_triplet_is_valid(slash, a2, a1, a0) \
(slash == '\\' && \
@@ -1643,55 +1631,29 @@ extract_summary (TrackerSparqlBuilder *metadata,
* @param uri URI of the file to extract data
* @param metadata where to store extracted data to
*/
-static void
-extract_msoffice (const gchar *uri,
- TrackerSparqlBuilder *preupdate,
- TrackerSparqlBuilder *metadata)
+G_MODULE_EXPORT gboolean
+tracker_extract_get_metadata (const gchar *uri,
+ const gchar *mime_used,
+ TrackerSparqlBuilder *preupdate,
+ TrackerSparqlBuilder *metadata)
{
TrackerConfig *config;
- GFile *file = NULL;
- GFileInfo *file_info = NULL;
- const gchar *mime_used;
GsfInfile *infile = NULL;
gchar *content = NULL;
gboolean is_encrypted = FALSE;
gsize max_bytes;
- file = g_file_new_for_uri (uri);
-
- if (!file) {
- g_warning ("Could not create GFile for URI:'%s'",
- uri);
- return;
- }
-
- file_info = g_file_query_info (file,
- G_FILE_ATTRIBUTE_STANDARD_CONTENT_TYPE,
- G_FILE_QUERY_INFO_NONE,
- NULL,
- NULL);
- g_object_unref (file);
-
- if (!file_info) {
- g_warning ("Could not get GFileInfo for URI:'%s'",
- uri);
- return;
- }
-
gsf_init ();
infile = open_uri (uri);
if (!infile) {
- g_object_unref (file_info);
gsf_shutdown ();
- return;
+ return FALSE;
}
/* Extracting summary */
extract_summary (metadata, infile, uri);
- mime_used = g_file_info_get_content_type (file_info);
-
/* Set max bytes to read from content */
config = tracker_main_get_config ();
max_bytes = tracker_config_get_max_bytes (config);
@@ -1727,12 +1689,7 @@ extract_msoffice (const gchar *uri,
}
g_object_unref (infile);
- g_object_unref (file_info);
gsf_shutdown ();
-}
-TrackerExtractData *
-tracker_extract_get_data (void)
-{
- return data;
+ return TRUE;
}
diff --git a/src/tracker-extract/tracker-extract-oasis.c b/src/tracker-extract/tracker-extract-oasis.c
index e473b68..7ef8688 100644
--- a/src/tracker-extract/tracker-extract-oasis.c
+++ b/src/tracker-extract/tracker-extract-oasis.c
@@ -97,19 +97,11 @@ static void xml_text_handler_content (GMarkupParseContext *context,
gsize text_len,
gpointer user_data,
GError **error);
-static void extract_oasis (const gchar *filename,
- TrackerSparqlBuilder *preupdate,
- TrackerSparqlBuilder *metadata);
static void extract_oasis_content (const gchar *uri,
gulong total_bytes,
ODTFileType file_type,
TrackerSparqlBuilder *metadata);
-static TrackerExtractData extract_data[] = {
- { "application/vnd.oasis.opendocument.*", extract_oasis },
- { NULL, NULL }
-};
-
static void
extract_oasis_content (const gchar *uri,
gulong total_bytes,
@@ -164,17 +156,15 @@ extract_oasis_content (const gchar *uri,
g_markup_parse_context_free (context);
}
-static void
-extract_oasis (const gchar *uri,
- TrackerSparqlBuilder *preupdate,
- TrackerSparqlBuilder *metadata)
+G_MODULE_EXPORT gboolean
+tracker_extract_get_metadata (const gchar *uri,
+ const gchar *mime_used,
+ TrackerSparqlBuilder *preupdate,
+ TrackerSparqlBuilder *metadata)
{
TrackerConfig *config;
ODTMetadataParseInfo info;
ODTFileType file_type;
- GFile *file = NULL;
- GFileInfo *file_info = NULL;
- const gchar *mime_used;
GMarkupParseContext *context;
GMarkupParser parser = {
xml_start_element_handler_metadata,
@@ -212,30 +202,6 @@ extract_oasis (const gchar *uri,
tracker_gsf_parse_xml_in_zip (uri, "meta.xml", context, NULL);
g_markup_parse_context_free (context);
- /* Next, parse contents */
- file = g_file_new_for_uri (uri);
-
- if (!file) {
- g_warning ("Could not create GFile for URI:'%s'",
- uri);
- return;
- }
-
- file_info = g_file_query_info (file,
- G_FILE_ATTRIBUTE_STANDARD_CONTENT_TYPE,
- G_FILE_QUERY_INFO_NONE,
- NULL,
- NULL);
- g_object_unref (file);
-
- if (!file_info) {
- g_warning ("Could not get GFileInfo for URI:'%s'",
- uri);
- return;
- }
-
- mime_used = g_file_info_get_content_type (file_info);
-
if (g_ascii_strcasecmp (mime_used, "application/vnd.oasis.opendocument.text") == 0) {
file_type = FILE_TYPE_ODT;
} else if (g_ascii_strcasecmp (mime_used, "application/vnd.oasis.opendocument.presentation") == 0) {
@@ -247,13 +213,13 @@ extract_oasis (const gchar *uri,
file_type = FILE_TYPE_INVALID;
}
- g_object_unref (file_info);
-
/* Extract content with the given limitations */
extract_oasis_content (uri,
tracker_config_get_max_bytes (config),
file_type,
metadata);
+
+ return TRUE;
}
static void
@@ -542,9 +508,3 @@ xml_text_handler_content (GMarkupParseContext *context,
break;
}
}
-
-TrackerExtractData *
-tracker_extract_get_data (void)
-{
- return extract_data;
-}
diff --git a/src/tracker-extract/tracker-extract-pdf.c b/src/tracker-extract/tracker-extract-pdf.c
index 345f6b9..fdb6c9a 100644
--- a/src/tracker-extract/tracker-extract-pdf.c
+++ b/src/tracker-extract/tracker-extract-pdf.c
@@ -13,7 +13,8 @@
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
- * You should have received a copy of the GNU General Public
+ * You should have received a copy
+ of the GNU General Public
* License along with this program; if not, write to the
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
@@ -42,15 +43,6 @@ typedef struct {
gchar *keywords;
} PDFData;
-static void extract_pdf (const gchar *uri,
- TrackerSparqlBuilder *preupdate,
- TrackerSparqlBuilder *metadata);
-
-static TrackerExtractData data[] = {
- { "application/pdf", extract_pdf },
- { NULL, NULL }
-};
-
static void
read_toc (PopplerIndexIter *index,
GString **toc)
@@ -273,10 +265,11 @@ write_pdf_data (PDFData data,
}
}
-static void
-extract_pdf (const gchar *uri,
- TrackerSparqlBuilder *preupdate,
- TrackerSparqlBuilder *metadata)
+G_MODULE_EXPORT gboolean
+tracker_extract_get_metadata (const gchar *uri,
+ const gchar *mimetype,
+ TrackerSparqlBuilder *preupdate,
+ TrackerSparqlBuilder *metadata)
{
TrackerConfig *config;
GTime creation_date;
@@ -302,22 +295,24 @@ extract_pdf (const gchar *uri,
tracker_sparql_builder_predicate (metadata, "nfo:isContentEncrypted");
tracker_sparql_builder_object_boolean (metadata, TRUE);
- return;
+
+ g_error_free (error);
+ return TRUE;
} else {
g_warning ("Couldn't create PopplerDocument from uri:'%s', %s",
uri,
error->message ? error->message : "no error given");
- }
- g_error_free (error);
- return;
+ g_error_free (error);
+ return FALSE;
+ }
}
if (!document) {
g_warning ("Could not create PopplerDocument from uri:'%s', "
"NULL returned without an error",
uri);
- return;
+ return FALSE;
}
tracker_sparql_builder_predicate (metadata, "a");
@@ -606,10 +601,6 @@ extract_pdf (const gchar *uri,
g_free (pd.date);
g_object_unref (document);
-}
-TrackerExtractData *
-tracker_extract_get_data (void)
-{
- return data;
+ return TRUE;
}
diff --git a/src/tracker-extract/tracker-extract-playlist.c b/src/tracker-extract/tracker-extract-playlist.c
index 765074f..ebbefc0 100644
--- a/src/tracker-extract/tracker-extract-playlist.c
+++ b/src/tracker-extract/tracker-extract-playlist.c
@@ -52,22 +52,6 @@ typedef struct {
const gchar *uri;
} PlaylistMetadata;
-static void extract_playlist (const gchar *uri,
- TrackerSparqlBuilder *preupdate,
- TrackerSparqlBuilder *metadata);
-
-static TrackerExtractData playlist_data[] = {
- { "audio/x-mpegurl", extract_playlist },
- { "audio/mpegurl", extract_playlist },
- { "audio/x-scpls", extract_playlist },
- { "audio/x-pn-realaudio", extract_playlist },
- { "application/ram", extract_playlist },
- { "application/vnd.ms-wpl", extract_playlist },
- { "application/smil", extract_playlist },
- { "audio/x-ms-asx", extract_playlist },
- { NULL, NULL }
-};
-
static void
entry_parsed (TotemPlParser *parser, const gchar *to_uri, GHashTable *to_metadata, gpointer user_data)
{
@@ -108,10 +92,11 @@ entry_parsed (TotemPlParser *parser, const gchar *to_uri, GHashTable *to_metadat
}
}
-static void
-extract_playlist (const gchar *uri,
- TrackerSparqlBuilder *preupdate,
- TrackerSparqlBuilder *metadata)
+G_MODULE_EXPORT gboolean
+tracker_extract_get_metadata (const gchar *uri,
+ const gchar *mimetype,
+ TrackerSparqlBuilder *preupdate,
+ TrackerSparqlBuilder *metadata)
{
TotemPlParser *pl;
TotemPlParserResult result;
@@ -153,10 +138,6 @@ extract_playlist (const gchar *uri,
}
g_object_unref (pl);
-}
-TrackerExtractData *
-tracker_extract_get_data (void)
-{
- return playlist_data;
+ return TRUE;
}
diff --git a/src/tracker-extract/tracker-extract-png.c b/src/tracker-extract/tracker-extract-png.c
index 1a2d109..aa8a2f2 100644
--- a/src/tracker-extract/tracker-extract-png.c
+++ b/src/tracker-extract/tracker-extract-png.c
@@ -69,16 +69,6 @@ typedef struct {
const gchar *disclaimer;
} PngData;
-static void extract_png (const gchar *filename,
- TrackerSparqlBuilder *preupdate,
- TrackerSparqlBuilder *metadata);
-
-static TrackerExtractData data[] = {
- { "image/png", extract_png },
- { "sketch/png", extract_png },
- { NULL, NULL }
-};
-
static gchar *
rfc1123_to_iso8601_date (const gchar *date)
{
@@ -505,10 +495,11 @@ read_metadata (TrackerSparqlBuilder *preupdate,
g_free (pd.creation_time);
}
-static void
-extract_png (const gchar *uri,
- TrackerSparqlBuilder *preupdate,
- TrackerSparqlBuilder *metadata)
+G_MODULE_EXPORT gboolean
+tracker_extract_get_metadata (const gchar *uri,
+ const gchar *mimetype,
+ TrackerSparqlBuilder *preupdate,
+ TrackerSparqlBuilder *metadata)
{
goffset size;
FILE *f;
@@ -526,14 +517,14 @@ extract_png (const gchar *uri,
size = tracker_file_get_size (filename);
if (size < 64) {
- return;
+ return FALSE;
}
f = tracker_file_open (filename, "r", FALSE);
g_free (filename);
if (!f) {
- return;
+ return FALSE;
}
png_ptr = png_create_read_struct (PNG_LIBPNG_VER_STRING,
@@ -542,27 +533,27 @@ extract_png (const gchar *uri,
NULL);
if (!png_ptr) {
tracker_file_close (f, FALSE);
- return;
+ return FALSE;
}
info_ptr = png_create_info_struct (png_ptr);
if (!info_ptr) {
png_destroy_read_struct (&png_ptr, &info_ptr, NULL);
tracker_file_close (f, FALSE);
- return;
+ return FALSE;
}
end_ptr = png_create_info_struct (png_ptr);
if (!end_ptr) {
png_destroy_read_struct (&png_ptr, &info_ptr, NULL);
tracker_file_close (f, FALSE);
- return;
+ return FALSE;
}
if (setjmp (png_jmpbuf (png_ptr))) {
png_destroy_read_struct (&png_ptr, &info_ptr, &end_ptr);
tracker_file_close (f, FALSE);
- return;
+ return FALSE;
}
png_init_io (png_ptr, f);
@@ -579,7 +570,7 @@ extract_png (const gchar *uri,
&filter_type)) {
png_destroy_read_struct (&png_ptr, &info_ptr, &end_ptr);
tracker_file_close (f, FALSE);
- return;
+ return FALSE;
}
/* Read the image. FIXME We should be able to skip this step and
@@ -616,10 +607,6 @@ extract_png (const gchar *uri,
png_destroy_read_struct (&png_ptr, &info_ptr, &end_ptr);
tracker_file_close (f, FALSE);
-}
-TrackerExtractData *
-tracker_extract_get_data (void)
-{
- return data;
+ return TRUE;
}
diff --git a/src/tracker-extract/tracker-extract-ps.c b/src/tracker-extract/tracker-extract-ps.c
index fcd24a4..7cd7613 100644
--- a/src/tracker-extract/tracker-extract-ps.c
+++ b/src/tracker-extract/tracker-extract-ps.c
@@ -38,23 +38,6 @@
#include <libtracker-extract/tracker-extract.h>
-#ifdef USING_UNZIPPSFILES
-static void extract_ps_gz (const gchar *uri,
- TrackerSparqlBuilder *preupdate,
- TrackerSparqlBuilder *metadata);
-#endif
-static void extract_ps (const gchar *uri,
- TrackerSparqlBuilder *preupdate,
- TrackerSparqlBuilder *metadata);
-
-static TrackerExtractData data[] = {
-#ifdef USING_UNZIPPSFILES
- { "application/x-gzpostscript", extract_ps_gz },
-#endif /* USING_UNZIPPSFILES */
- { "application/postscript", extract_ps },
- { NULL, NULL }
-};
-
static gchar *
hour_day_str_day (const gchar *date)
{
@@ -295,8 +278,20 @@ extract_ps_gz (const gchar *uri,
#endif /* USING_UNZIPPSFILES */
-TrackerExtractData *
-tracker_extract_get_data (void)
+G_MODULE_EXPORT gboolean
+tracker_extract_get_metadata (const gchar *uri,
+ const gchar *mimetype,
+ TrackerSparqlBuilder *preupdate,
+ TrackerSparqlBuilder *metadata)
{
- return data;
+#ifdef USING_UNZIPPSFILES
+ if (strcmp (mimetype, "application/x-gzpostscript") == 0) {
+ extract_ps_gz (uri, preupdate, metadata);
+ } else
+#endif /* USING_UNZIPPSFILES */
+ {
+ extract_ps (uri, preupdate, metadata);
+ }
+
+ return TRUE;
}
diff --git a/src/tracker-extract/tracker-extract-text.c b/src/tracker-extract/tracker-extract-text.c
index 4ad8100..2141c87 100644
--- a/src/tracker-extract/tracker-extract-text.c
+++ b/src/tracker-extract/tracker-extract-text.c
@@ -31,16 +31,6 @@
#define TRY_LOCALE_TO_UTF8_CONVERSION 0
-static void extract_text (const gchar *uri,
- TrackerSparqlBuilder *preupdate,
- TrackerSparqlBuilder *metadata);
-
-static TrackerExtractData data[] = {
- { "text/*", extract_text },
- { NULL, NULL }
-};
-
-
static gchar *
get_file_content (const gchar *uri,
gsize n_bytes)
@@ -82,10 +72,11 @@ get_file_content (const gchar *uri,
return text;
}
-static void
-extract_text (const gchar *uri,
- TrackerSparqlBuilder *preupdate,
- TrackerSparqlBuilder *metadata)
+G_MODULE_EXPORT gboolean
+tracker_extract_get_metadata (const gchar *uri,
+ const gchar *mimetype,
+ TrackerSparqlBuilder *preupdate,
+ TrackerSparqlBuilder *metadata)
{
TrackerConfig *config;
gchar *content;
@@ -103,10 +94,6 @@ extract_text (const gchar *uri,
tracker_sparql_builder_object_unvalidated (metadata, content);
g_free (content);
}
-}
-TrackerExtractData *
-tracker_extract_get_data (void)
-{
- return data;
+ return TRUE;
}
diff --git a/src/tracker-extract/tracker-extract-tiff.c b/src/tracker-extract/tracker-extract-tiff.c
index 4b550b8..67cea6d 100644
--- a/src/tracker-extract/tracker-extract-tiff.c
+++ b/src/tracker-extract/tracker-extract-tiff.c
@@ -75,15 +75,6 @@ typedef struct {
gchar *orientation;
} TiffData;
-static void extract_tiff (const gchar *filename,
- TrackerSparqlBuilder *preupdate,
- TrackerSparqlBuilder *metadata);
-
-static TrackerExtractData extract_data[] = {
- { "image/tiff", extract_tiff },
- { NULL, NULL }
-};
-
static void
tiff_data_free (TiffData *tags)
{
@@ -248,10 +239,11 @@ tag_to_string (TIFF *image,
return NULL;
}
-static void
-extract_tiff (const gchar *uri,
- TrackerSparqlBuilder *preupdate,
- TrackerSparqlBuilder *metadata)
+G_MODULE_EXPORT gboolean
+tracker_extract_get_metadata (const gchar *uri,
+ const gchar *mimetype,
+ TrackerSparqlBuilder *preupdate,
+ TrackerSparqlBuilder *metadata)
{
TIFF *image;
TrackerXmpData *xd = NULL;
@@ -280,7 +272,7 @@ extract_tiff (const gchar *uri,
if ((image = TIFFOpen (filename, "r")) == NULL){
g_warning ("Could not open image:'%s'\n", filename);
g_free (filename);
- return;
+ return FALSE;
}
tracker_sparql_builder_predicate (metadata, "a");
@@ -713,10 +705,6 @@ extract_tiff (const gchar *uri,
tracker_exif_free (ed);
tracker_xmp_free (xd);
tracker_iptc_free (id);
-}
-TrackerExtractData *
-tracker_extract_get_data (void)
-{
- return extract_data;
+ return TRUE;
}
diff --git a/src/tracker-extract/tracker-extract-totem.c b/src/tracker-extract/tracker-extract-totem.c
index 6bbd44b..1c7cec2 100644
--- a/src/tracker-extract/tracker-extract-totem.c
+++ b/src/tracker-extract/tracker-extract-totem.c
@@ -28,10 +28,6 @@
#include <libtracker-extract/tracker-extract.h>
-static void extract_totem (const gchar *uri,
- TrackerSparqlBuilder *preupdate,
- TrackerSparqlBuilder *metadata);
-
static const gchar *tags[][2] = {
{ "TOTEM_INFO_VIDEO_HEIGHT", "nfo:height" },
{ "TOTEM_INFO_VIDEO_WIDTH", "nfo:width" },
@@ -48,12 +44,6 @@ static const gchar *tags[][2] = {
{ NULL, NULL }
};
-static TrackerExtractData data[] = {
- { "audio/*", extract_totem },
- { "video/*", extract_totem },
- { NULL, NULL }
-};
-
static void
metadata_write_foreach (gpointer key,
gpointer value,
@@ -65,10 +55,11 @@ metadata_write_foreach (gpointer key,
tracker_sparql_builder_object_unvalidated (metadata, (const gchar *) value);
}
-static void
-extract_totem (const gchar *uri,
- TrackerSparqlBuilder *preupdate,
- TrackerSparqlBuilder *metadata)
+G_MODULE_EXPORT gboolean
+tracker_extract_get_metadata (const gchar *uri,
+ const gchar *mimetype,
+ TrackerSparqlBuilder *preupdate,
+ TrackerSparqlBuilder *metadata)
{
gchar *argv[3];
gchar *totem;
@@ -176,17 +167,16 @@ extract_totem (const gchar *uri,
tracker_sparql_builder_object_iri (metadata, album_uri);
}
+ g_hash_table_destroy (tmp_metadata);
g_free (album_uri);
g_free (artist_uri);
g_free (album);
g_free (artist);
+
+ return TRUE;
}
g_hash_table_destroy (tmp_metadata);
-}
-TrackerExtractData *
-tracker_extract_get_data (void)
-{
- return data;
+ return FALSE;
}
diff --git a/src/tracker-extract/tracker-extract-vorbis.c b/src/tracker-extract/tracker-extract-vorbis.c
index 0108fcc..a328d37 100644
--- a/src/tracker-extract/tracker-extract-vorbis.c
+++ b/src/tracker-extract/tracker-extract-vorbis.c
@@ -68,16 +68,6 @@ typedef struct {
gchar *publisher;
} VorbisData;
-static void extract_vorbis (const char *uri,
- TrackerSparqlBuilder *preupdate,
- TrackerSparqlBuilder *metadata);
-
-static TrackerExtractData extract_data[] = {
- { "audio/x-vorbis+ogg", extract_vorbis },
- { "application/ogg", extract_vorbis },
- { NULL, NULL }
-};
-
static gchar *
ogg_get_comment (vorbis_comment *vc,
const gchar *label)
@@ -95,10 +85,11 @@ ogg_get_comment (vorbis_comment *vc,
}
}
-static void
-extract_vorbis (const char *uri,
- TrackerSparqlBuilder *preupdate,
- TrackerSparqlBuilder *metadata)
+G_MODULE_EXPORT gboolean
+tracker_extract_get_metadata (const char *uri,
+ const gchar *mimetype,
+ TrackerSparqlBuilder *preupdate,
+ TrackerSparqlBuilder *metadata)
{
VorbisData vd = { 0 };
MergeData md = { 0 };
@@ -115,12 +106,12 @@ extract_vorbis (const char *uri,
g_free (filename);
if (!f) {
- return;
+ return FALSE;
}
if (ov_open (f, &vf, NULL, 0) < 0) {
tracker_file_close (f, FALSE);
- return;
+ return FALSE;
}
tracker_sparql_builder_predicate (metadata, "a");
@@ -465,10 +456,6 @@ extract_vorbis (const char *uri,
/* NOTE: This calls fclose on the file */
ov_clear (&vf);
-}
-TrackerExtractData *
-tracker_extract_get_data (void)
-{
- return extract_data;
+ return TRUE;
}
diff --git a/src/tracker-extract/tracker-extract-xmp.c b/src/tracker-extract/tracker-extract-xmp.c
index 21ac36b..b0faf37 100644
--- a/src/tracker-extract/tracker-extract-xmp.c
+++ b/src/tracker-extract/tracker-extract-xmp.c
@@ -23,15 +23,6 @@
#include <libtracker-extract/tracker-extract.h>
-static void extract_xmp (const gchar *filename,
- TrackerSparqlBuilder *preupdate,
- TrackerSparqlBuilder *metadata);
-
-static TrackerExtractData data[] = {
- { "application/rdf+xml", extract_xmp },
- { NULL, NULL }
-};
-
/* This function is used to find the URI for a file.xmp file. The point here is
* that the URI for file.xmp is not file:///file.xmp but instead for example
* file:///file.jpeg or file:///file.png. The reason is that file.xmp is a
@@ -128,10 +119,11 @@ find_orig_uri (const gchar *xmp_filename)
return found_file;
}
-static void
-extract_xmp (const gchar *uri,
- TrackerSparqlBuilder *preupdate,
- TrackerSparqlBuilder *metadata)
+G_MODULE_EXPORT gboolean
+tracker_extract_get_metadata (const gchar *uri,
+ const gchar *mimetype,
+ TrackerSparqlBuilder *preupdate,
+ TrackerSparqlBuilder *metadata)
{
TrackerXmpData *xd = NULL;
GError *error = NULL;
@@ -160,13 +152,11 @@ extract_xmp (const gchar *uri,
g_free (original_uri);
tracker_xmp_free (xd);
g_free (contents);
+ g_free (filename);
+
+ return TRUE;
}
g_free (filename);
-}
-
-TrackerExtractData *
-tracker_extract_get_data (void)
-{
- return data;
+ return FALSE;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]