tracker r3154 - in trunk: . docs/reference/libtracker-module/tmpl src/libtracker-common src/tracker-extract src/tracker-indexer/modules
- From: mr svn gnome org
- To: svn-commits-list gnome org
- Subject: tracker r3154 - in trunk: . docs/reference/libtracker-module/tmpl src/libtracker-common src/tracker-extract src/tracker-indexer/modules
- Date: Mon, 30 Mar 2009 22:48:39 +0000 (UTC)
Author: mr
Date: Mon Mar 30 22:48:38 2009
New Revision: 3154
URL: http://svn.gnome.org/viewvc/tracker?rev=3154&view=rev
Log:
* configure.ac:
* src/tracker-extract/Makefile.am:
* src/tracker-extract/tracker-extract-vorbis.c: Added vorbis
checks and cleaned up vorbis code. This is a backup, we use
GStreamer normally and this is disabled by default.
* src/tracker-extract/tracker-extract-abw.c:
* src/tracker-extract/tracker-extract-jpeg.c:
* src/tracker-extract/tracker-extract-mp3.c:
* src/tracker-extract/tracker-extract-png.c:
* src/tracker-extract/tracker-extract-ps.c:
* src/tracker-indexer/modules/evolution-imap.[ch]: Use
tracker_file_() functions to open/close files with
posix_fadvise().
* src/tracker-extract/tracker-extract.c: Fixed 2 memory leaks.
Modified:
trunk/ChangeLog
trunk/configure.ac
trunk/docs/reference/libtracker-module/tmpl/tracker-module-file.sgml
trunk/src/libtracker-common/tracker-file-utils.c
trunk/src/libtracker-common/tracker-file-utils.h
trunk/src/tracker-extract/Makefile.am
trunk/src/tracker-extract/tracker-extract-abw.c
trunk/src/tracker-extract/tracker-extract-jpeg.c
trunk/src/tracker-extract/tracker-extract-mp3.c
trunk/src/tracker-extract/tracker-extract-png.c
trunk/src/tracker-extract/tracker-extract-ps.c
trunk/src/tracker-extract/tracker-extract-vorbis.c
trunk/src/tracker-extract/tracker-extract.c
trunk/src/tracker-indexer/modules/evolution-imap.c
trunk/src/tracker-indexer/modules/evolution-imap.h
Modified: trunk/configure.ac
==============================================================================
--- trunk/configure.ac (original)
+++ trunk/configure.ac Mon Mar 30 22:48:38 2009
@@ -141,6 +141,7 @@
POPPLER_GLIB_REQUIRED=0.4.5
CAIRO_REQUIRED=1.0
GDK_REQUIRED=1.0
+LIBVORBIS_REQUIRED=0.22
LIBEXIF_REQUIRED=0.6
LIBGSF_REQUIRED=1.13
EXEMPI_REQUIRED=1.99.2
@@ -1098,6 +1099,39 @@
CFLAGS="$OLD_CFLAGS"
LIBS="$OLD_LIBS"
+##################################################################
+# Check for vorbis
+##################################################################
+
+AC_ARG_ENABLE(libvorbis,
+ AS_HELP_STRING([--enable-libvorbis],
+ [enable extractor for vorbis data (ogg)]),,
+ [enable_libvorbis=no])
+
+if test "x$enable_libvorbis" != "xno" ; then
+ PKG_CHECK_MODULES(LIBVORBIS,
+ [vorbis >= $LIBVORBIS_REQUIRED],
+ [have_libvorbis=yes],
+ [have_libvorbis=no])
+
+ AC_SUBST(LIBVORBIS_CFLAGS)
+ AC_SUBST(LIBVORBIS_LIBS)
+
+ if test "x$have_libvorbis" = "xyes"; then
+ AC_DEFINE(HAVE_LIBVORBIS, [], [Define if we have libvorbis])
+ fi
+else
+ have_libvorbis="no (disabled)"
+fi
+
+if test "x$enable_libvorbis" = "xyes"; then
+ if test "x$have_libvorbis" != "xyes"; then
+ AC_MSG_ERROR([Couldn't find libvorbis >= $LIBVORBIS_REQUIRED.])
+ fi
+fi
+
+AM_CONDITIONAL(HAVE_LIBVORBIS, test "x$have_libvorbis" = "xyes")
+
####################################################################
# Check ioprio support
####################################################################
@@ -1407,6 +1441,7 @@
Support PDF: $have_poppler_glib
Support JPEG: $have_libjpeg (xmp: $have_exempi, exif: $have_libexif, iptc: $have_libiptcdata)
Support TIFF: $have_libtiff (xmp: $have_exempi, exif: yes, iptc: $have_libiptcdata)
+ Support Vorbis (ogg/etc): $have_libvorbis
Support MS & Open Office: $have_libgsf
Support XML / HTML: $have_libxml2
Support embedded / sidecar XMP: $have_exempi
Modified: trunk/docs/reference/libtracker-module/tmpl/tracker-module-file.sgml
==============================================================================
--- trunk/docs/reference/libtracker-module/tmpl/tracker-module-file.sgml (original)
+++ trunk/docs/reference/libtracker-module/tmpl/tracker-module-file.sgml Mon Mar 30 22:48:38 2009
@@ -27,6 +27,11 @@
</para>
+<!-- ##### ARG TrackerModuleFile:cancelled ##### -->
+<para>
+
+</para>
+
<!-- ##### ARG TrackerModuleFile:file ##### -->
<para>
The GFile that corresponds to the TrackerModuleFile
Modified: trunk/src/libtracker-common/tracker-file-utils.c
==============================================================================
--- trunk/src/libtracker-common/tracker-file-utils.c (original)
+++ trunk/src/libtracker-common/tracker-file-utils.c Mon Mar 30 22:48:38 2009
@@ -39,35 +39,63 @@
#define TEXT_SNIFF_SIZE 4096
-gint
+FILE *
tracker_file_open (const gchar *uri,
- gboolean lreadahead)
+ const gchar *how,
+ gboolean sequential)
{
- gint fd;
+ FILE *file;
+ gboolean readonly;
+ int flags;
-#if defined(__linux__)
- fd = open (uri, O_RDONLY | O_NOATIME);
+ g_return_val_if_fail (uri != NULL, NULL);
+ g_return_val_if_fail (how != NULL, NULL);
- if (fd == -1) {
- fd = open (uri, O_RDONLY);
+ file = fopen (uri, how);
+ if (!file) {
+ return NULL;
}
-#else
- fd = open (uri, O_RDONLY);
-#endif
- if (fd == -1) {
- return -1;
+ /* Are we opening for readonly? */
+ readonly = !strstr (uri, "r+") && strchr (uri, 'r');
+
+ if (readonly) {
+ int fd;
+
+ fd = fileno (file);
+
+ /* Make sure we set the NOATIME flag if we have permissions to */
+ if ((flags = fcntl (fd, F_GETFL, 0)) != -1) {
+ fcntl (fd, F_SETFL, flags | O_NOATIME);
+ }
+
+#ifdef HAVE_POSIX_FADVISE
+ if (sequential_access) {
+ posix_fadvise (fd, 0, 0, POSIX_FADV_SEQUENTIAL);
+ } else {
+ posix_fadvise (fd, 0, 0, POSIX_FADV_RANDOM);
+ }
+#endif
}
+
+ /* FIXME: Do nothing with posix_fadvise() for non-readonly operations */
+
+ return file;
+}
+
+void
+tracker_file_close (FILE *file,
+ gboolean need_again_soon)
+{
+ g_return_if_fail (file != NULL);
#ifdef HAVE_POSIX_FADVISE
- if (lreadahead) {
- posix_fadvise (fd, 0, 0, POSIX_FADV_SEQUENTIAL);
- } else {
- posix_fadvise (fd, 0, 0, POSIX_FADV_RANDOM);
+ if (!need_again_soon) {
+ posix_fadvise (fileno (file), 0, 0, POSIX_FADV_DONTNEED);
}
#endif
- return fd;
+ fclose (file);
}
gboolean
Modified: trunk/src/libtracker-common/tracker-file-utils.h
==============================================================================
--- trunk/src/libtracker-common/tracker-file-utils.h (original)
+++ trunk/src/libtracker-common/tracker-file-utils.h Mon Mar 30 22:48:38 2009
@@ -26,24 +26,28 @@
#error "only <libtracker-common/tracker-common.h> must be included directly."
#endif
+#include <stdio.h>
#include <glib.h>
-gint tracker_file_open (const gchar *uri,
- gboolean readahead);
-gboolean tracker_file_unlink (const gchar *uri);
-goffset tracker_file_get_size (const gchar *uri);
-guint64 tracker_file_get_mtime (const gchar *uri);
-gchar * tracker_file_get_mime_type (const gchar *uri);
-void tracker_file_get_path_and_name (const gchar *uri,
- gchar **path,
- gchar **name);
-void tracker_path_remove (const gchar *uri);
-gboolean tracker_path_is_in_path (const gchar *path,
- const gchar *in_path);
-void tracker_path_hash_table_filter_duplicates (GHashTable *roots);
-GSList * tracker_path_list_filter_duplicates (GSList *roots,
- const gchar *basename_exception_prefix);
-gchar * tracker_path_evaluate_name (const gchar *uri);
-gboolean tracker_env_check_xdg_dirs (void);
+FILE* tracker_file_open (const gchar *uri,
+ const gchar *how,
+ gboolean sequential);
+void tracker_file_close (FILE *file,
+ gboolean need_again_soon);
+gboolean tracker_file_unlink (const gchar *uri);
+goffset tracker_file_get_size (const gchar *uri);
+guint64 tracker_file_get_mtime (const gchar *uri);
+gchar * tracker_file_get_mime_type (const gchar *uri);
+void tracker_file_get_path_and_name (const gchar *uri,
+ gchar **path,
+ gchar **name);
+void tracker_path_remove (const gchar *uri);
+gboolean tracker_path_is_in_path (const gchar *path,
+ const gchar *in_path);
+void tracker_path_hash_table_filter_duplicates (GHashTable *roots);
+GSList * tracker_path_list_filter_duplicates (GSList *roots,
+ const gchar *basename_exception_prefix);
+gchar * tracker_path_evaluate_name (const gchar *uri);
+gboolean tracker_env_check_xdg_dirs (void);
#endif /* __LIBTRACKER_COMMON_FILE_UTILS_H__ */
Modified: trunk/src/tracker-extract/Makefile.am
==============================================================================
--- trunk/src/tracker-extract/Makefile.am (original)
+++ trunk/src/tracker-extract/Makefile.am Mon Mar 30 22:48:38 2009
@@ -35,6 +35,10 @@
libextract-png.la \
libextract-ps.la
+if HAVE_LIBVORBIS
+modules_LTLIBRARIES += libextract-vorbis.la
+endif
+
if HAVE_EXEMPI
modules_LTLIBRARIES += libextract-xmp.la
endif
@@ -118,6 +122,11 @@
libextract_mp3_la_LDFLAGS = $(module_flags) $(albumart_flags)
libextract_mp3_la_LIBADD = $(albumart_libs) $(GLIB2_LIBS) $(GCOV_LIBS)
+# Vorbis (OGG)
+libextract_vorbis_la_SOURCES = tracker-extract-vorbis.c $(escape_sources)
+libextract_vorbis_la_LDFLAGS = $(module_flags)
+libextract_vorbis_la_LIBADD = $(GLIB2_LIBS) $(LIBVORBIS_LIBS) $(GCOV_LIBS)
+
# MPlayer
libextract_mplayer_la_SOURCES = tracker-extract-mplayer.c $(escape_sources)
libextract_mplayer_la_LDFLAGS = $(module_flags)
Modified: trunk/src/tracker-extract/tracker-extract-abw.c
==============================================================================
--- trunk/src/tracker-extract/tracker-extract-abw.c (original)
+++ trunk/src/tracker-extract/tracker-extract-abw.c Mon Mar 30 22:48:38 2009
@@ -34,6 +34,8 @@
#include <glib.h>
#include <glib/gstdio.h>
+#include <libtracker-common/tracker-file-utils.h>
+
#include "tracker-main.h"
#include "tracker-escape.h"
@@ -49,18 +51,11 @@
extract_abw (const gchar *filename,
GHashTable *metadata)
{
- gint fd;
FILE *f;
-#if defined(__linux__)
- if ((fd = g_open (filename, (O_RDONLY | O_NOATIME))) == -1) {
-#else
- if ((fd = g_open (filename, O_RDONLY)) == -1) {
-#endif
- return;
- }
+ f = tracker_file_open (filename, "r", TRUE);
- if ((f = fdopen (fd, "r"))) {
+ if (f) {
gchar *line;
gsize length;
gssize read_char;
@@ -107,9 +102,7 @@
g_free (line);
}
- fclose (f);
- } else {
- close (fd);
+ tracker_file_close (f, FALSE);
}
}
Modified: trunk/src/tracker-extract/tracker-extract-jpeg.c
==============================================================================
--- trunk/src/tracker-extract/tracker-extract-jpeg.c (original)
+++ trunk/src/tracker-extract/tracker-extract-jpeg.c Mon Mar 30 22:48:38 2009
@@ -274,32 +274,21 @@
extract_jpeg (const gchar *filename,
GHashTable *metadata)
{
- struct stat fstatbuf;
- size_t size;
-
struct jpeg_decompress_struct cinfo;
struct tej_error_mgr tejerr;
struct jpeg_marker_struct *marker;
- FILE *jpeg;
- gint fd_jpeg;
+ FILE *f;
+ goffset size;
- if ((fd_jpeg = g_open (filename, O_RDONLY)) == -1) {
- return;
- }
+ size = tracker_file_get_size (filename);
- if (stat (filename, &fstatbuf) == -1) {
- close(fd_jpeg);
- return;
- }
-
- /* Check size at least SOI+JFIF without thumb */
- size = fstatbuf.st_size;
if (size < 18) {
- close (fd_jpeg);
return;
}
- if ((jpeg = fdopen (fd_jpeg, "rb"))) {
+ f = tracker_file_open (filename, "rb", FALSE);
+
+ if (f) {
gchar *str;
gsize len;
#ifdef HAVE_LIBIPTCDATA
@@ -319,7 +308,7 @@
jpeg_save_markers (&cinfo, JPEG_APP0 + 1, 0xFFFF);
jpeg_save_markers (&cinfo, JPEG_APP0 + 13, 0xFFFF);
- jpeg_stdio_src (&cinfo, jpeg);
+ jpeg_stdio_src (&cinfo, f);
jpeg_read_header (&cinfo, TRUE);
@@ -414,9 +403,7 @@
jpeg_destroy_decompress (&cinfo);
fail:
- fclose (jpeg);
- } else {
- close (fd_jpeg);
+ tracker_file_close (f, FALSE);
}
}
Modified: trunk/src/tracker-extract/tracker-extract-mp3.c
==============================================================================
--- trunk/src/tracker-extract/tracker-extract-mp3.c (original)
+++ trunk/src/tracker-extract/tracker-extract-mp3.c Mon Mar 30 22:48:38 2009
@@ -39,6 +39,8 @@
#include <sys/mman.h>
#endif /* G_OS_WIN32 */
+#include <libtracker-common/tracker-file-utils.h>
+
#include "tracker-main.h"
#include "tracker-extract-albumart.h"
#include "tracker-escape.h"
@@ -1479,10 +1481,9 @@
extract_mp3 (const gchar *filename,
GHashTable *metadata)
{
- gint file;
+ int fd;
void *buffer;
- struct stat fstatbuf;
- size_t size;
+ goffset size;
id3tag info;
file_data filedata;
@@ -1498,37 +1499,46 @@
filedata.albumartdata = NULL;
filedata.albumartsize = 0;
-#if defined(__linux__)
- /* O_NOATIME fails for files we do not own (even if we can read) */
- file = g_open (filename, (O_RDONLY | O_NOATIME), 0);
- if (file == -1) {
- file = g_open (filename, O_RDONLY, 0);
- }
-#else
- file = g_open (filename, O_RDONLY, 0);
-#endif
-
- if (file == -1 || stat (filename, &fstatbuf) == -1) {
- close (file);
- return;
- }
+ size = tracker_file_get_size (filename);
- size = fstatbuf.st_size;
if (size == 0) {
- close (file);
return;
}
- if (size > MAX_FILE_READ) {
- size = MAX_FILE_READ;
+ /* Can return -1 because of O_NOATIME, so we try again after
+ * without as a last resort. This can happen due to
+ * permissions.
+ */
+ fd = open (filename, O_RDONLY | O_NOATIME);
+ if (fd == -1) {
+ fd = open (filename, O_RDONLY);
+
+ if (fd == -1) {
+ return;
+ }
}
+#ifdef HAVE_POSIX_FADVISE
+ posix_fadvise (fd, 0, 0, POSIX_FADV_SEQUENTIAL);
+#endif
+
#ifndef G_OS_WIN32
- buffer = mmap (NULL, size, PROT_READ, MAP_PRIVATE, file, 0);
+ /* We don't use GLib's mmap because size can not be specified */
+ buffer = mmap (NULL,
+ MIN (size, MAX_FILE_READ),
+ PROT_READ,
+ MAP_PRIVATE,
+ fd,
+ 0);
#endif
+#ifdef HAVE_POSIX_FADVISE
+ posix_fadvise (fd, 0, 0, POSIX_FADV_DONTNEED);
+#endif
+
+ close (fd);
+
if (buffer == NULL || buffer == (void*) -1) {
- close(file);
return;
}
@@ -1591,7 +1601,6 @@
mp3_parse (buffer, size, metadata, &filedata);
#ifdef HAVE_GDKPIXBUF
-
tracker_process_albumart (filedata.albumartdata, filedata.albumartsize,
/* g_hash_table_lookup (metadata, "Audio:Artist") */ NULL,
g_hash_table_lookup (metadata, "Audio:Album"),
@@ -1631,7 +1640,6 @@
#ifndef G_OS_WIN32
munmap (buffer, size);
#endif
- close(file);
}
TrackerExtractData *
Modified: trunk/src/tracker-extract/tracker-extract-png.c
==============================================================================
--- trunk/src/tracker-extract/tracker-extract-png.c (original)
+++ trunk/src/tracker-extract/tracker-extract-png.c Mon Mar 30 22:48:38 2009
@@ -143,11 +143,8 @@
extract_png (const gchar *filename,
GHashTable *metadata)
{
- struct stat fstatbuf;
- size_t size;
-
- gint fd_png;
- FILE *png;
+ goffset size;
+ FILE *f;
png_structp png_ptr;
png_infop info_ptr;
png_infop end_ptr;
@@ -158,62 +155,47 @@
gint bit_depth, color_type;
gint interlace_type, compression_type, filter_type;
-#if defined(__linux__)
- if (((fd_png = g_open (filename, (O_RDONLY | O_NOATIME))) == -1) &&
- ((fd_png = g_open (filename, (O_RDONLY))) == -1 ) ) {
-#else
- if ((fd_png = g_open (filename, O_RDONLY)) == -1) {
-#endif
- return;
- }
+ size = tracker_file_get_size (filename);
- if (stat (filename, &fstatbuf) == -1) {
- close(fd_png);
- return;
- }
-
- /* Check for minimum header size */
- size = fstatbuf.st_size;
if (size < 64) {
- close (fd_png);
return;
}
- if ((png = fdopen (fd_png, "r"))) {
+ f = tracker_file_open (filename, "r", FALSE);
+
+ if (f) {
png_ptr = png_create_read_struct (PNG_LIBPNG_VER_STRING,
NULL,
NULL,
NULL);
if (!png_ptr) {
- fclose (png);
+ tracker_file_close (f, FALSE);
return;
}
info_ptr = png_create_info_struct (png_ptr);
if (!info_ptr) {
png_destroy_read_struct (&png_ptr, &info_ptr, NULL);
- fclose (png);
+ tracker_file_close (f, FALSE);
return;
}
end_ptr = png_create_info_struct (png_ptr);
- if (!info_ptr) {
+ if (!end_ptr) {
png_destroy_read_struct (&png_ptr, &info_ptr, NULL);
png_destroy_read_struct (&png_ptr, &end_ptr, NULL);
- fclose (png);
+ tracker_file_close (f, FALSE);
return;
}
- if (setjmp(png_jmpbuf(png_ptr))) {
- png_destroy_read_struct (&png_ptr, &info_ptr,
- (png_infopp)NULL);
- png_destroy_read_struct (&png_ptr, &end_ptr,
- (png_infopp)NULL);
- fclose (png);
+ if (setjmp (png_jmpbuf (png_ptr))) {
+ png_destroy_read_struct (&png_ptr, &info_ptr, NULL);
+ png_destroy_read_struct (&png_ptr, &end_ptr, NULL);
+ tracker_file_close (f, FALSE);
return;
}
- png_init_io (png_ptr, png);
+ png_init_io (png_ptr, f);
png_read_info (png_ptr, info_ptr);
if (!png_get_IHDR (png_ptr,
@@ -227,17 +209,18 @@
&filter_type)) {
png_destroy_read_struct (&png_ptr, &info_ptr, NULL);
png_destroy_read_struct (&png_ptr, &end_ptr, NULL);
- fclose (png);
+ tracker_file_close (f, FALSE);
return;
}
/* Read the image. FIXME We should be able to skip this step and
* just get the info from the end. This causes some errors atm.
*/
- row_pointers = (png_bytepp) malloc (height * sizeof (png_bytep));
+ row_pointers = g_new0 (png_bytep, height);
+
for (row = 0; row < height; row++) {
row_pointers[row] = png_malloc (png_ptr,
- png_get_rowbytes(png_ptr,info_ptr));
+ png_get_rowbytes (png_ptr,info_ptr));
}
png_read_image (png_ptr, row_pointers);
@@ -245,6 +228,7 @@
for (row = 0; row < height; row++) {
png_free (png_ptr, row_pointers[row]);
}
+
g_free (row_pointers);
png_read_end (png_ptr, end_ptr);
@@ -262,7 +246,6 @@
tracker_escape_metadata_printf ("%ld", height));
/* Check that we have the minimum data. FIXME We should not need to do this */
-
if (!g_hash_table_lookup (metadata, "Image:Date")) {
gchar *date;
guint64 mtime;
@@ -277,9 +260,8 @@
}
png_destroy_read_struct (&png_ptr, &info_ptr, NULL);
- fclose (png);
- } else {
- close (fd_png);
+ png_destroy_read_struct (&png_ptr, &end_ptr, NULL);
+ tracker_file_close (f, FALSE);
}
}
Modified: trunk/src/tracker-extract/tracker-extract-ps.c
==============================================================================
--- trunk/src/tracker-extract/tracker-extract-ps.c (original)
+++ trunk/src/tracker-extract/tracker-extract-ps.c Mon Mar 30 22:48:38 2009
@@ -34,6 +34,7 @@
#include <glib.h>
#include <glib/gstdio.h>
+#include <libtracker-common/tracker-file-utils.h>
#include <libtracker-common/tracker-type-utils.h>
#include <libtracker-common/tracker-os-dependant.h>
@@ -204,18 +205,11 @@
extract_ps (const gchar *filename,
GHashTable *metadata)
{
- gint fd;
FILE *f;
-#if defined(__linux__)
- if ((fd = g_open (filename, (O_RDONLY | O_NOATIME))) == -1) {
-#else
- if ((fd = g_open (filename, O_RDONLY)) == -1) {
-#endif
- return;
- }
+ f = tracker_file_open (filename, "r", TRUE);
- if ((f = fdopen (fd, "r"))) {
+ if (f) {
gchar *line;
gsize length;
gssize read_char;
@@ -256,7 +250,6 @@
g_free (date);
}
-
} else if (strncmp (line, "%%Pages:", 8) == 0) {
if (strcmp (line + 9, "(atend)") == 0) {
pageno_atend = TRUE;
@@ -282,9 +275,7 @@
g_free (line);
}
- fclose (f);
- } else {
- close (fd);
+ tracker_file_close (f, FALSE);
}
}
Modified: trunk/src/tracker-extract/tracker-extract-vorbis.c
==============================================================================
--- trunk/src/tracker-extract/tracker-extract-vorbis.c (original)
+++ trunk/src/tracker-extract/tracker-extract-vorbis.c Mon Mar 30 22:48:38 2009
@@ -19,184 +19,174 @@
#include "config.h"
-#ifdef HAVE_VORBIS
-
#include <stdio.h>
#include <string.h>
+#include <fcntl.h>
+
#include <glib.h>
+
#include <vorbis/vorbisfile.h>
+#include <libtracker-common/tracker-file-utils.h>
+
#include "tracker-main.h"
+static void extract_vorbis (const char *filename,
+ GHashTable *metadata);
+
static struct {
- char * name;
- char *meta_name;
+ gchar *name;
+ gchar *meta_name;
gboolean writable;
} tags[] = {
- {"title", "Audio.Title", FALSE},
- {"artist", "Audio.Artist", FALSE},
- {"album", "Audio.Album", FALSE},
- {"albumartist", "Audio.AlbumArtist", FALSE},
- {"trackcount", "Audio.AlbumTrackCount", FALSE},
- {"tracknumber", "Audio.TrackNo", FALSE},
- {"DiscNo", "Audio.DiscNo", FALSE},
- {"Performer", "Audio.Performer", FALSE},
- {"TrackGain", "Audio.TrackGain", FALSE},
- {"TrackPeakGain", "Audio.TrackPeakGain", FALSE},
- {"AlbumGain", "Audio.AlbumGain", FALSE},
- {"AlbumPeakGain", "Audio.AlbumPeakGain", FALSE},
- {"date", "Audio.ReleaseDate", FALSE},
- {"comment", "Audio.Comment", FALSE},
- {"genre", "Audio.Genre", FALSE},
- {"Codec", "Audio.Codec", FALSE},
- {"CodecVersion", "Audio.CodecVersion", FALSE},
- {"Samplerate", "Audio.Samplerate", FALSE},
- {"Channels", "Audio.Channels", FALSE},
- {"MBAlbumID", "Audio.MBAlbumID", FALSE},
- {"MBArtistID", "Audio.MBArtistID", FALSE},
- {"MBAlbumArtistID", "Audio.MBAlbumArtistID", FALSE},
- {"MBTrackID", "Audio.MBTrackID", FALSE},
- {"Lyrics", "Audio.Lyrics", FALSE},
- {"Copyright", "File.Copyright", FALSE},
- {"License", "File.License", FALSE},
- {"Organization", "File.Organization", FALSE},
- {"Location", "File.Location", FALSE},
- {"Publisher", "File.Publisher", FALSE},
- {NULL, NULL, FALSE},
+ { "title", "Audio.Title", FALSE },
+ { "artist", "Audio.Artist", FALSE },
+ { "album", "Audio.Album", FALSE },
+ { "albumartist", "Audio.AlbumArtist", FALSE },
+ { "trackcount", "Audio.AlbumTrackCount", FALSE },
+ { "tracknumber", "Audio.TrackNo", FALSE },
+ { "DiscNo", "Audio.DiscNo", FALSE },
+ { "Performer", "Audio.Performer", FALSE },
+ { "TrackGain", "Audio.TrackGain", FALSE },
+ { "TrackPeakGain", "Audio.TrackPeakGain", FALSE },
+ { "AlbumGain", "Audio.AlbumGain", FALSE },
+ { "AlbumPeakGain", "Audio.AlbumPeakGain", FALSE },
+ { "date", "Audio.ReleaseDate", FALSE },
+ { "comment", "Audio.Comment", FALSE },
+ { "genre", "Audio.Genre", FALSE },
+ { "Codec", "Audio.Codec", FALSE },
+ { "CodecVersion", "Audio.CodecVersion", FALSE },
+ { "Samplerate", "Audio.Samplerate", FALSE },
+ { "Channels", "Audio.Channels", FALSE },
+ { "MBAlbumID", "Audio.MBAlbumID", FALSE },
+ { "MBArtistID", "Audio.MBArtistID", FALSE },
+ { "MBAlbumArtistID", "Audio.MBAlbumArtistID", FALSE },
+ { "MBTrackID", "Audio.MBTrackID", FALSE },
+ { "Lyrics", "Audio.Lyrics", FALSE },
+ { "Copyright", "File.Copyright", FALSE },
+ { "License", "File.License", FALSE },
+ { "Organization", "File.Organization", FALSE },
+ { "Location", "File.Location", FALSE },
+ { "Publisher", "File.Publisher", FALSE },
+ { NULL, NULL, FALSE },
};
+static TrackerExtractData extract_data[] = {
+ { "audio/x-vorbis+ogg", extract_vorbis },
+ { "application/ogg", extract_vorbis },
+ { NULL, NULL }
+};
-static char*
-get_comment (vorbis_comment *vc, char *label)
+static gchar *
+ogg_get_comment (vorbis_comment *vc,
+ gchar *label)
{
- char *tag;
- char *utf_tag;
+ gchar *tag;
+ gchar *utf_tag;
if (vc && (tag = vorbis_comment_query (vc, label, 0)) != NULL) {
-
utf_tag = g_locale_to_utf8 (tag, -1, NULL, NULL, NULL);
-
/*g_free (tag);*/
return utf_tag;
-
} else {
return NULL;
}
-
}
+#if 0
-gboolean
-tracker_metadata_ogg_is_writable (const char *meta)
+static gboolean
+ogg_is_writable (const gchar *meta)
{
- int i;
-
- i = 0;
- while (tags[i].name != NULL) {
+ gint i;
- if (strcmp (tags[i].meta_name, meta) == 0) {
+ for (i = 0; tags[i].name != NULL; i++) {
+ if (g_strcmp0 (tags[i].meta_name, meta) == 0) {
return tags[i].writable;
}
-
- i++;
}
return FALSE;
-
}
-
-gboolean
-tracker_metadata_ogg_write (const char *meta_name, const char *value)
+static gboolean
+ogg_write (const char *meta_name,
+ const char *value)
{
/* to do */
return FALSE;
}
-
-void
-tracker_extract_vorbis (const char *filename, GHashTable *metadata)
-{
- gint fd;
- FILE *oggFile;
- OggVorbis_File vf;
- gint i;
-
-#if defined(__linux__)
- if ((fd = g_open (filename, (O_RDONLY | O_NOATIME))) == -1) {
-#else
- if ((fd = g_open (filename, O_RDONLY)) == -1) {
#endif
- return;
- }
-
- oggFile = fdopen (fd, "r");
-
- if (!oggFile) {
- close (fd);
- return;
- }
-
- if ( ov_open (oggFile, &vf, NULL, 0) < 0 ) {
- fclose (oggFile);
- return;
- }
-
- char *tmpComment;
+static void
+extract_vorbis (const char *filename,
+ GHashTable *metadata)
+{
+ FILE *f;
+ OggVorbis_File vf;
+ gint i;
vorbis_comment *comment;
+ vorbis_info *vi;
+ unsigned int bitrate;
+ gchar *str_bitrate;
+ gint time;
+ gchar *str_time;
+
+ f = tracker_file_open (filename, "r", FALSE);
+
+ if (!f) {
+ return;
+ }
- if ((comment = ov_comment (&vf, -1)) == NULL) {
- ov_clear (&vf);
+ if (ov_open (f, &vf, NULL, 0) < 0) {
+ tracker_file_close (f, FALSE);
return;
}
- i = 0;
- while (tags[i].name != NULL) {
- tmpComment = get_comment (comment, tags[i].name);
-
- if (tmpComment) {
- g_hash_table_insert (metadata, g_strdup (tags[i].meta_name), tmpComment);
- }
-
- i++;
- }
-
- vorbis_comment_clear(comment);
-
- /* Bitrate */
-
- vorbis_info *vi;
- unsigned int bitrate;
- char *str_bitrate;
-
- if ( ( vi = ov_info(&vf, 0)) != NULL ) {
- bitrate = vi->bitrate_nominal/1000;
- str_bitrate = g_strdup_printf ("%d", bitrate);
- g_hash_table_insert (metadata, g_strdup ("Audio.Bitrate"), str_bitrate);
- g_hash_table_insert (metadata, g_strdup ("Audio.CodecVersion"), g_strdup_printf ("%d", vi->version));
- g_hash_table_insert (metadata, g_strdup ("Audio.Channels"), g_strdup_printf ("%d", vi->channels));
- g_hash_table_insert (metadata, g_strdup ("Audio.Samplerate"), g_strdup_printf ("%ld", vi->rate));
- }
-
+ if ((comment = ov_comment (&vf, -1)) != NULL) {
+ for (i = 0; tags[i].name != NULL; i++) {
+ gchar *str;
+
+ str = ogg_get_comment (comment, tags[i].name);
+
+ if (str) {
+ g_hash_table_insert (metadata, g_strdup (tags[i].meta_name), str);
+ }
+ }
+
+ vorbis_comment_clear (comment);
+
+ if ((vi = ov_info (&vf, 0)) != NULL ) {
+ bitrate = vi->bitrate_nominal / 1000;
+ str_bitrate = g_strdup_printf ("%d", bitrate);
+
+ g_hash_table_insert (metadata, g_strdup ("Audio.Bitrate"), str_bitrate);
+ g_hash_table_insert (metadata, g_strdup ("Audio.CodecVersion"), g_strdup_printf ("%d", vi->version));
+ g_hash_table_insert (metadata, g_strdup ("Audio.Channels"), g_strdup_printf ("%d", vi->channels));
+ g_hash_table_insert (metadata, g_strdup ("Audio.Samplerate"), g_strdup_printf ("%ld", vi->rate));
+ }
+
+ /* Duration */
+ if ((time = ov_time_total (&vf, -1)) != OV_EINVAL) {
+ str_time = g_strdup_printf ("%d", time);
+ g_hash_table_insert (metadata, g_strdup ("Audio.Duration"), str_time);
+ }
+
+ g_hash_table_insert (metadata, g_strdup ("Audio.Codec"), g_strdup ("vorbis"));
+ }
+#ifdef HAVE_POSIX_FADVISE
+ posix_fadvise (fileno (f), 0, 0, POSIX_FADV_DONTNEED);
+#endif
- /* Duration */
-
- int time;
- char *str_time;
- if ( ( time = ov_time_total(&vf, -1) ) != OV_EINVAL ) {
- str_time = g_strdup_printf ("%d", time);
- g_hash_table_insert (metadata, g_strdup ("Audio.Duration"), str_time);
- }
-
- g_hash_table_insert (metadata, g_strdup ("Audio.Codec"), g_strdup ("vorbis"));
-
- ov_clear(&vf);
-
+ /* NOTE: This calls fclose on the file */
+ ov_clear (&vf);
}
-#else
-#warning "Not building ogg/vorbis metadata extractor"
-#endif /* HAVE_VORBIS */
+TrackerExtractData *
+tracker_get_extract_data (void)
+{
+ return extract_data;
+}
Modified: trunk/src/tracker-extract/tracker-extract.c
==============================================================================
--- trunk/src/tracker-extract/tracker-extract.c (original)
+++ trunk/src/tracker-extract/tracker-extract.c Mon Mar 30 22:48:38 2009
@@ -67,6 +67,8 @@
priv = TRACKER_EXTRACT_GET_PRIVATE (object);
+ g_array_free (priv->extractors, TRUE);
+
G_OBJECT_CLASS (tracker_extract_parent_class)->finalize (object);
}
@@ -105,9 +107,8 @@
if (!dir) {
g_error ("Error opening modules directory: %s", error->message);
g_error_free (error);
- g_array_free (extractors, TRUE);
- extractors = NULL;
g_array_free (generic_extractors, TRUE);
+ g_array_free (extractors, TRUE);
return NULL;
}
@@ -136,20 +137,20 @@
if (g_module_symbol (module, "tracker_get_extract_data", (gpointer *) &func)) {
data = (func) ();
- while (data->mime) {
+ for (; data->mime; data++) {
if (strchr (data->mime, '*') != NULL) {
g_array_append_val (generic_extractors, *data);
} else {
g_array_append_val (extractors, *data);
}
-
- data++;
}
}
g_free (module_path);
}
+ g_dir_close (dir);
+
/* Append the generic extractors at the end of
* the list, so the specific ones are used first
*/
Modified: trunk/src/tracker-indexer/modules/evolution-imap.c
==============================================================================
--- trunk/src/tracker-indexer/modules/evolution-imap.c (original)
+++ trunk/src/tracker-indexer/modules/evolution-imap.c Mon Mar 30 22:48:38 2009
@@ -131,8 +131,7 @@
g_free (file->imap_dir);
g_free (file->cur_message_uid);
- fclose (file->summary);
- close (file->fd);
+ tracker_file_close (file->summary, FALSE);
G_OBJECT_CLASS (tracker_evolution_imap_file_parent_class)->finalize (object);
}
@@ -493,18 +492,20 @@
self = TRACKER_EVOLUTION_IMAP_FILE (file);
self->imap_dir = g_build_filename (g_get_home_dir (),
- ".evolution", "mail", "imap", G_DIR_SEPARATOR_S,
+ ".evolution",
+ "mail",
+ "imap",
+ G_DIR_SEPARATOR_S,
NULL);
path = g_file_get_path (tracker_module_file_get_file (file));
- self->fd = tracker_file_open (path, TRUE);
+ self->summary = tracker_file_open (path, "r", TRUE);
g_free (path);
- if (self->fd == -1) {
+ if (!self->summary) {
return;
}
- self->summary = fdopen (self->fd, "r");
self->n_messages = read_summary_header (self->summary);
self->cur_message = 1;
Modified: trunk/src/tracker-indexer/modules/evolution-imap.h
==============================================================================
--- trunk/src/tracker-indexer/modules/evolution-imap.h (original)
+++ trunk/src/tracker-indexer/modules/evolution-imap.h Mon Mar 30 22:48:38 2009
@@ -48,7 +48,6 @@
gchar *imap_dir;
- gint fd;
FILE *summary;
guint n_messages;
guint cur_message;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]