summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog72
-rw-r--r--Makefile.am26
-rw-r--r--README2
-rw-r--r--configure.in20
-rw-r--r--data/Makefile.am11
-rw-r--r--data/mysql-stored-procs.sql7
-rw-r--r--data/mysql-tracker.sql210
-rw-r--r--debian/changelog6
-rw-r--r--debian/compat2
-rw-r--r--debian/control61
-rwxr-xr-xdebian/rules22
-rw-r--r--filters/application/Makefile.am4
-rwxr-xr-xfilters/application/pdf_filter2
-rw-r--r--filters/text/Makefile.am4
-rw-r--r--ltmain.sh575
-rw-r--r--src/Makefile.am5
-rw-r--r--src/tracker-extract/Makefile.am2
-rw-r--r--src/tracker-extract/tracker-extract.c4
-rw-r--r--src/trackerd/Makefile.am29
-rw-r--r--src/trackerd/tracker-db.c1048
-rw-r--r--src/trackerd/tracker-db.h40
-rw-r--r--src/trackerd/tracker-dbus-files.c114
-rw-r--r--src/trackerd/tracker-dbus-keywords.c28
-rw-r--r--src/trackerd/tracker-dbus-metadata.c36
-rw-r--r--src/trackerd/tracker-dbus-methods.c54
-rw-r--r--src/trackerd/tracker-dbus-methods.h9
-rw-r--r--src/trackerd/tracker-dbus-search.c49
-rw-r--r--src/trackerd/tracker-dbus.c81
-rw-r--r--src/trackerd/tracker-fam.c6
-rw-r--r--src/trackerd/tracker-inotify.c115
-rw-r--r--src/trackerd/tracker-metadata.c7
-rw-r--r--src/trackerd/tracker-metadata.h11
-rw-r--r--src/trackerd/tracker-utils.c241
-rw-r--r--src/trackerd/tracker-utils.h57
-rw-r--r--src/trackerd/trackerd.c879
-rw-r--r--thumbnailers/application/Makefile.am3
36 files changed, 1969 insertions, 1873 deletions
diff --git a/ChangeLog b/ChangeLog
index 0a3e7d277..ea6eb42c4 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,48 +1,88 @@
-2006-07-03 Marcus Fritzsch <fritschy@googlemail.com>
+2006-08-21 Jamie McCracken <jamiemcc@gnome.org>
+
+ * Improved thread synchronisation using G_COND and g_cond_signal and g_cond_wait
+ * Eliminated redundant mutexes (file available/metadata available)
+ * Restructured threads to be more efficient
+ * Added two phase program halt so that stuff ends gracefully and all threads are exited smoothly
+
+
+2006-08-21 Laurent Aguerreche <laurent.aguerreche@free.fr>
+
+ * Patch to fix signal handling amongst threads
+ * Jamie McCracken heavily modified this patch to make sure it avoids deadlocks and race conditions
+
+
+2006-08-19 Laurent Aguerreche <laurent.aguerreche@free.fr>
+
+ * Patch to fix debain build
+ * split up tracker into several debs
+ * Fixed make dist in autofoo
+
+
+2006-08-19 Jamie McCracken <jamiemcc@gnome.org>
+
+ * Abstracted all mysql specific stuff into tracker-db-mysql
+ * Paved the way to support alternative backends like sqlite/qdbm
+
+
+2006-08-13 Jamie McCracken <jamiemcc@gnome.org>
+
+ * Added new tracker-file-convert to convert text file into list of unique words with associated counts
+ * Added support for stemming
+ * Added new parsing word breaker
+ * Added experimental (but currently disabled) qdbm indexing (tracker-indexer.c)
+
+
+2006-08-13 Marcus Fritzsch <fritschy@googlemail.com>
+
+ * Patch to make sure a dbus reply is sent if the rdf query string is NULL or erroneous
+
+
+2006-08-03 Marcus Fritzsch <fritschy@googlemail.com>
* Patch to make sure query is not null in tracker_exec_sql
-2006-07-03 Jamie McCracken <jamiemcc@gnome.org>
+2006-08-03 Jamie McCracken <jamiemcc@gnome.org>
* Added new Dbus methods for File.Exists and File.GetServiceType
-2006-07-02 Jamie McCracken <jamiemcc@gnome.org>
+2006-08-02 Jamie McCracken <jamiemcc@gnome.org>
* Added new command line tool tracker-files
-2006-07-02 Edward Duffy <eduffy@gmail.com>
+2006-08-02 Edward Duffy <eduffy@gmail.com>
* Patch for small fix to XdgMime
-2006-07-02 Jedy Wang <Jedy.Wang@Sun.COM>
+2006-08-02 Jedy Wang <Jedy.Wang@Sun.COM>
* Patch to add build instructions for Solaris to README file
-2006-07-02 Laurent Aguerreche <laurent.aguerreche@free.fr>
+2006-08-02 Laurent Aguerreche <laurent.aguerreche@free.fr>
* Patch to fix sql
-2006-07-01 Jamie McCracken <jamiemcc@gnome.org>
+2006-08-01 Jamie McCracken <jamiemcc@gnome.org>
* Added offset parameter to search methods
-2006-06-31 Jedy Wang <Jedy.Wang@Sun.COM>
+2006-07-31 Jedy Wang <Jedy.Wang@Sun.COM>
* Patch to improve compilation on Solaris
-2006-06-31 Jamie McCracken <jamiemcc@gnome.org>
+2006-07-31 Jamie McCracken <jamiemcc@gnome.org>
* Added realpath for file parameters in command line tools
* Improved search terms to *and* them by default
@@ -51,41 +91,41 @@
* added bugfixed XDGMIME from Beagle to prevent crashes
-2006-06-30 Marcus Fritzsch <fritschy@googlemail.com>
+2006-07-30 Marcus Fritzsch <fritschy@googlemail.com>
* Patch to make build more debian friendly
-2006-06-30 Jedy Wang <Jedy.Wang@Sun.COM>
+2006-07-30 Jedy Wang <Jedy.Wang@Sun.COM>
* Patch to fix crasher on solaris
-2006-06-30 Christoph Laimburg <christoph.laimburg@rolmail.net>
+2006-07-30 Christoph Laimburg <christoph.laimburg@rolmail.net>
* Patch to replace deprecated dbus call (dbus_connection_disconnect)
-2006-06-30 Samuel Cormier-Iijima <ciyoshi@gmail.com>
+2006-07-30 Samuel Cormier-Iijima <ciyoshi@gmail.com>
* Patch to add RegExp rdf query extension support
-2006-06-30 Samuel Cormier-Iijima <ciyoshi@gmail.com>
+2006-07-30 Samuel Cormier-Iijima <ciyoshi@gmail.com>
* Modified patch to make no watch directories parameter functional
-2006-06-30 Jamie McCracken <jamiemcc@gnome.org>
+2006-07-30 Jamie McCracken <jamiemcc@gnome.org>
* Added new command line tools (tracker-tag)
* Fixed bugs in tracker-search methods
* Fixed bugs in tracker-query
-2006-06-25 Jamie McCracken <jamiemcc@gnome.org>
+2006-07-25 Jamie McCracken <jamiemcc@gnome.org>
* Sorted out libtracker
* updated to reflect new dbus interfaces
diff --git a/Makefile.am b/Makefile.am
index f78edc8bc..29fa61cba 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -3,8 +3,30 @@ SUBDIRS = data src filters thumbnailers
pkgconfigdir = $(libdir)/pkgconfig
pkgconfig_DATA = tracker.pc
+debian_files = \
+ debian/changelog \
+ debian/compat \
+ debian/control \
+ debian/copyright \
+ debian/libmetatracker0-dev.docs \
+ debian/libmetatracker0-dev.install \
+ debian/libmetatracker0-dev.links \
+ debian/libmetatracker0.docs \
+ debian/libmetatracker0.install \
+ debian/libmetatracker0.links \
+ debian/meta-tracker-dev.docs \
+ debian/meta-tracker-dev.install \
+ debian/meta-tracker.docs \
+ debian/meta-tracker.install \
+ debian/meta-tracker-utils.docs \
+ debian/meta-tracker-utils.examples \
+ debian/meta-tracker-utils.install \
+ debian/rules
+
EXTRA_DIST = \
+ $(pkgconfig_DATA) \
AUTHORS NEWS INSTALL COPYING README \
ChangeLog \
- configure.in
-
+ configure.in \
+ rdf-query-examples/*.rdf \
+ $(debian_files)
diff --git a/README b/README
index 60ee8d3b6..15e94e1ce 100644
--- a/README
+++ b/README
@@ -117,7 +117,7 @@ lThe embedded mysql library ibmysqld.a version 5.0.19 or higher is required comp
If not present you can compile libmysqld.a by downloading source tarball for an appropriate version (5.0.19+) from the bottom of page http://dev.mysql.com/downloads/mysql/5.0.html
-The following configure flags are reccommended if building mysqld.a from source: --without-server --with-embedded-server --enable-assembler
+The following configure flags are reccommended if building mysqld.a from source: --without-server --with-embedded-server --enable-assembler --without-debug --without-query-cache --without-geometry --without-extra-tools --without-docs --without-man --without-bench --without-innodb --with-senna
Generic RPMs and tarballs are also provided for the embedded mysql library and another for the development headers at http://www.gnome.org/~jamiemcc/tracker/
diff --git a/configure.in b/configure.in
index 2d6717df6..c117244d4 100644
--- a/configure.in
+++ b/configure.in
@@ -13,21 +13,32 @@ CFLAGS="$CFLAGS"
-
# Checks for programs.
AC_PROG_CC
AC_HEADER_STDC
- AC_PROG_LIBTOOL
+#AC_PROG_LIBTOOL
+
+AM_PROG_LIBTOOL
# Checks for header files.
AC_HEADER_STDC
-AC_CHECK_HEADERS([fcntl.h sitdlib.h string.h sys/time.h unistd.h])
+AC_CHECK_HEADERS([fcntl.h sitdlib.h string.h sys/time.h unistd.h magic.h])
# Check for glib 2.0
PKG_CHECK_MODULES(GLIB2, [ glib-2.0 >= 2.4.0 ] gthread-2.0 >= 2.4.0)
AC_SUBST(GLIB2_CFLAGS)
AC_SUBST(GLIB2_LIBS)
+Check for pango
+PKG_CHECK_MODULES(PANGO, [ pango >= 1.0.0 ])
+AC_SUBST(PANGO_CFLAGS)
+AC_SUBST(PANGO_LIBS)
+
+# Check for QDBM
+#PKG_CHECK_MODULES(QDBM, [ qdbm >= 1.8.0 ])
+#AC_SUBST(QDBM_CFLAGS)
+#AC_SUBST(QDBM_LIBS)
+
# Check for Dbus 0.50 or higher
PKG_CHECK_MODULES(DBUS, [dbus-1 >= 0.50 dbus-glib-1 >= 0.50 ])
AC_SUBST(DBUS_CFLAGS)
@@ -58,6 +69,9 @@ fi
####################################################################
# Embedded Mysql checks
####################################################################
+
+AM_CONDITIONAL(USING_SQLITE, false)
+
mysql_dir=""
AC_ARG_WITH(mysql,
AC_HELP_STRING([--with-mysql=PATH], [directory where mysql is installed]),
diff --git a/data/Makefile.am b/data/Makefile.am
index 872c67514..8e62483ac 100644
--- a/data/Makefile.am
+++ b/data/Makefile.am
@@ -2,13 +2,18 @@ SUBDIRS = english
configdir = $(datadir)/tracker
-config_DATA = tracker-introspect.xml mysql-tracker.sql mysql-stored-procs.sql mysql-system.sql tracker.cfg tracker-stop-words.txt
+config_DATA = tracker-introspect.xml \
+ mysql-tracker.sql \
+ mysql-stored-procs.sql \
+ mysql-system.sql \
+ tracker.cfg \
+ tracker-stop-words.txt
servicedir = $(prefix)/share/dbus-1/services
service_in_files = tracker.service.in
service_DATA = tracker.service
+EXTRA_DIST = $(config_DATA) $(service_in_files)
+
%.service: %.service.in
@sed -e "s|\@bindir\@|$(bindir)|" $< > $@
-
-
diff --git a/data/mysql-stored-procs.sql b/data/mysql-stored-procs.sql
index 896e72b81..fc37cf9e6 100644
--- a/data/mysql-stored-procs.sql
+++ b/data/mysql-stored-procs.sql
@@ -134,6 +134,13 @@ BEGIN
END|
+DROP PROCEDURE if exists IndexIDExists;|
+
+CREATE PROCEDURE IndexIDExists (ID int unsigned)
+BEGIN
+ select 1 where exists (select IndexID from ServiceMetaData where IndexID = ID);
+END|
+
-- service SPs --
DROP PROCEDURE if exists GetServices;|
diff --git a/data/mysql-tracker.sql b/data/mysql-tracker.sql
index c51b6f729..f0bf2d024 100644
--- a/data/mysql-tracker.sql
+++ b/data/mysql-tracker.sql
@@ -84,10 +84,8 @@ create table if not exists Services
IsDirectory bool default 0,
IsWatchedDirectory bool default 0,
IsLink bool default 0,
+ IsVfs bool default 0,
VolumeID int default -1, /* link to Volumes table */
- Misc varchar(255),
- MiscInt int,
- MiscDate DateTime,
IndexTime int unsigned, /* should equal st_mtime for file if up-to-date */
Offset int unsigned, /* last used disk offset for indexable files that always grow (like chat logs) */
@@ -98,6 +96,9 @@ create table if not exists Services
);
+
+
+
/* provides links from one service entity to another */
create table if not exists ServiceLinks
(
@@ -121,6 +122,7 @@ create table if not exists ServiceLinkTypes
insert into ServiceLinkTypes (Type) Values ('PlayListItem');
+
/* store all keywords here. */
create table if not exists ServiceKeywords
(
@@ -148,30 +150,51 @@ create table if not exists Keywords
/* store all metadata here. */
create table if not exists ServiceMetaData
(
+ IndexID int unsigned auto_increment not null,
ServiceID int unsigned not null,
MetaDataID smallint unsigned not null,
MetaDataValue Text character set utf8,
MetaDataIndexValue MediumText character set utf8,
MetaDataNumericValue double,
- Primary Key (ServiceID, MetaDataID),
+ Primary Key (IndexID),
+ Key (ServiceID, MetaDataID),
Key (MetaDataIndexValue (32)),
key INumericValue (MetaDataID, MetaDataNumericValue),
- FullText (MetaDataIndexValue)
+ FullText INDEX (MetaDataIndexValue)
);
+/* store all indexable metadata here. */
+create table if not exists ServiceIndexMetaData
+(
+ ServiceID int unsigned not null,
+ MetaDataID smallint unsigned not null,
+ IndexerID int unsigned,
+ MetaDataIndexValue varchar (255),
+ MetaDataIndexBlob MediumText,
+
+ Primary Key (ServiceID, MetaDataID),
+ Key (MetaDataID, MetaDataIndexValue (32))
+
+);
+
+
+
+
+
/* describes the types of metadata */
create table if not exists MetaDataTypes
(
ID smallint unsigned auto_increment not null,
MetaName varchar (128) not null,
- DataTypeID tinyint unsigned, /* 0=full text indexable string, 1=string, 2=numeric, 3=datetime (as string) */
- Embedded bool, /* if the metadata is embedded in the file */
- Writeable bool, /* is metadata writable */
+ DataTypeID tinyint unsigned not null, /* 0=full text indexable string (max 255 long), 1=string or Blob, 2=numeric, 3=datetime, 4==IndexBlob (99=special case)*/
+ Embedded bool not null, /* if the metadata is embedded in the file */
+ Writeable bool not null, /* is metadata writable */
+ Weight tinyint unsigned default 1 not null, /* weight of metdata type in ranking */
Primary Key (ID),
Unique (MetaName)
@@ -179,93 +202,90 @@ create table if not exists MetaDataTypes
/* built in metadata types */
-insert into MetaDataTypes (MetaName, DatatypeID, Embedded, Writeable) values
-('File.Name', 0, 1, 0),
-('File.Path', 0, 1, 0),
-('File.Link', 1, 1, 0),
-('File.Format', 0, 1, 0 ),
-('File.Size', 2, 1, 0),
-('File.Permissions', 1, 1, 0),
-('File.Publisher', 0, 1, 1),
-('File.Content', 0, 1, 0),
-('File.Description', 0, 0, 1),
-('File.License', 0, 1, 0),
-('File.Keywords', 0, 0, 1),
-('File.Rank', 2, 0, 1),
-('File.IconPath', 1, 0, 1 ),
-('File.SmallThumbnailPath', 1, 0, 1),
-('File.LargeThumbnailPath', 1, 0, 1),
-('File.Modified', 3, 1, 0),
-('File.Accessed', 3, 1, 0 ),
-('File.Other', 0, 1, 0 ),
-('Audio.Title', 0, 1, 1),
-('Audio.Artist', 0, 1, 1),
-('Audio.Album', 0, 1, 1),
-('Audio.AlbumArtist', 0, 1, 1),
-('Audio.AlbumTrackCount', 2, 1, 1),
-('Audio.TrackNo', 2, 1, 1),
-('Audio.DiscNo', 2, 1, 1),
-('Audio.Performer', 0, 1, 1),
-('Audio.TrackGain', 2, 1, 1),
-('Audio.TrackPeakGain', 2, 1, 1),
-('Audio.AlbumGain', 2, 1, 1),
-('Audio.AlbumPeakGain', 2, 1, 1),
-('Audio.Duration', 2, 1, 0),
-('Audio.ReleaseDate', 3, 1, 1),
-('Audio.Comment', 0, 1, 1),
-('Audio.Genre', 0, 1, 1),
-('Audio.Codec', 0, 1, 1),
-('Audio.CodecVersion', 1, 1, 1),
-('Audio.Samplerate', 2, 1, 1),
-('Audio.Bitrate', 2, 1, 1),
-('Audio.Channels', 2, 1, 1),
-('Audio.LastPlay', 3, 0, 1),
-('Audio.PlayCount', 2, 0, 1),
-('Audio.IsNew', 2, 0, 1),
-('Audio.MBAlbumID', 1, 0, 1),
-('Audio.MBArtistID', 1, 0, 1),
-('Audio.MBAlbumArtistID', 1, 0, 1),
-('Audio.MBTrackID', 1, 0, 1),
-('Audio.Lyrics', 0, 0, 1),
-('Audio.CoverAlbumThumbnailPath', 1, 0, 1),
-('Doc.Title', 0, 1, 0),
-('Doc.Subject', 0, 1, 0),
-('Doc.Author', 0, 1, 0),
-('Doc.Keywords', 0, 1, 0),
-('Doc.Comments', 0, 1, 0),
-('Doc.PageCount', 2, 1, 0),
-('Doc.WordCount', 2, 1, 0),
-('Doc.Created', 3, 1, 0),
-('Image.Height', 2, 1, 0),
-('Image.Width', 2, 1, 0),
-('Image.Title', 0, 1, 0),
-('Image.Album', 0, 0, 1),
-('Image.Date', 3, 1, 0),
-('Image.Keywords', 0, 1, 0),
-('Image.Creator', 0, 1, 0),
-('Image.Comments', 0, 1, 0),
-('Image.Description', 0, 1, 0),
-('Image.Software', 0, 1, 0),
-('Image.CameraMake', 0, 1, 0),
-('Image.CameraModel', 0, 1, 0),
-('Image.Orientation', 1, 1, 0),
-('Image.ExposureProgram', 1, 1, 0),
-('Image.ExposureTime', 2, 1, 0),
-('Image.FNumber', 2 , 1, 0),
-('Image.Flash', 2, 1, 0),
-('Image.FocalLength', 2, 1, 0),
-('Image.ISOSpeed', 2, 1, 0),
-('Image.MeteringMode', 1, 1, 0),
-('Image.WhiteBalance', 1, 1, 0),
-('Image.Copyright', 0, 1, 0),
-('PlayList.DateCreated', 3, 0, 1),
-('PlayList.LastPlay', 3, 0, 1),
-('PlayList.PlayCount', 2, 0, 1),
-('PlayList.Description', 0, 0, 1),
-('PlayList.RDFQuery', 1, 0, 1),
-('PlayList.Name', 0, 0, 1),
-('PlayList.Rank', 2, 0, 1),
-('PlayList.Keywords', 0, 0, 1);
+insert into MetaDataTypes (MetaName, DatatypeID, Embedded, Writeable, Weight) values
+
+('File.Content', 0, 1, 0, 1),
+('File.Name', 0, 1, 0, 5),
+('File.Path', 0, 1, 0, 1),
+('File.Ext', 0, 1, 0, 50),
+('File.Link', 1, 1, 0, 0),
+('File.Format', 0, 1, 0, 15),
+('File.Size', 2, 1, 0, 0),
+('File.Origin', 0, 0, 1, 5),
+('File.OriginURI', 1, 0, 1, 0),
+('File.Permissions', 1, 1, 0, 0),
+('File.Publisher', 0, 0, 1, 20),
+('File.Description', 0, 0, 1, 25),
+('File.License', 4, 1, 0, 10),
+('File.Keywords', 99, 0, 0, 100),
+('File.Rank', 2, 0, 1, 0),
+('File.IconPath', 1, 0, 1, 0 ),
+('File.SmallThumbnailPath', 1, 0, 1, 0),
+('File.LargeThumbnailPath', 1, 0, 1, 0),
+('File.Modified', 3, 1, 0, 0),
+('File.Accessed', 3, 1, 0, 0),
+('File.Other', 0, 1, 0, 5),
+('Audio.Title', 0, 1, 1, 50),
+('Audio.Artist', 0, 1, 1, 50),
+('Audio.Album', 0, 1, 1, 50),
+('Audio.AlbumArtist', 0, 1, 1, 25),
+('Audio.AlbumTrackCount', 2, 1, 1, 0),
+('Audio.TrackNo', 2, 1, 1, 0),
+('Audio.DiscNo', 2, 1, 1, 0),
+('Audio.Performer', 0, 1, 1, 70),
+('Audio.TrackGain', 2, 1, 1, 0),
+('Audio.TrackPeakGain', 2, 1, 1, 0),
+('Audio.AlbumGain', 2, 1, 1, 0),
+('Audio.AlbumPeakGain', 2, 1, 1, 0),
+('Audio.Duration', 2, 1, 0, 0),
+('Audio.ReleaseDate', 3, 1, 1, 0),
+('Audio.Comment', 0, 1, 1, 25),
+('Audio.Genre', 0, 1, 1, 90),
+('Audio.Codec', 0, 1, 1, 1),
+('Audio.CodecVersion', 1, 1, 1, 0),
+('Audio.Samplerate', 2, 1, 1, 0),
+('Audio.Bitrate', 2, 1, 1, 0),
+('Audio.Channels', 2, 1, 1, 0),
+('Audio.LastPlay', 3, 0, 1, 0),
+('Audio.PlayCount', 2, 0, 1, 0),
+('Audio.IsNew', 2, 0, 1, 0),
+('Audio.MBAlbumID', 1, 0, 1, 0),
+('Audio.MBArtistID', 1, 0, 1, 0),
+('Audio.MBAlbumArtistID', 1, 0, 1, 0),
+('Audio.MBTrackID', 1, 0, 1, 0),
+('Audio.Lyrics', 0, 0, 1, 4),
+('Audio.CoverAlbumThumbnailPath', 1, 0, 1, 0),
+('Doc.Title', 0, 1, 0, 90),
+('Doc.Subject', 0, 1, 0, 100),
+('Doc.Author', 0, 1, 0, 90),
+('Doc.Keywords', 0, 1, 0, 100),
+('Doc.Comments', 0, 1, 0, 80),
+('Doc.PageCount', 2, 1, 0, 0),
+('Doc.WordCount', 2, 1, 0, 0),
+('Doc.Created', 3, 1, 0, 0),
+('Doc.Text', 4, 1, 0, 5),
+('Image.Height', 2, 1, 0, 0),
+('Image.Width', 2, 1, 0, 0),
+('Image.Title', 0, 1, 0, 60),
+('Image.Album', 0, 0, 1, 30),
+('Image.Date', 3, 1, 0, 0),
+('Image.Keywords', 0, 1, 0, 100),
+('Image.Creator', 0, 1, 0, 50),
+('Image.Comments', 0, 1, 0, 20),
+('Image.Description', 0, 1, 0, 15),
+('Image.Software', 0, 1, 0, 1),
+('Image.CameraMake', 0, 1, 0, 1),
+('Image.CameraModel', 0, 1, 0, 10),
+('Image.Orientation', 1, 1, 0, 0),
+('Image.ExposureProgram', 1, 1, 0, 0),
+('Image.ExposureTime', 2, 1, 0, 0),
+('Image.FNumber', 2 , 1, 0, 0),
+('Image.Flash', 2, 1, 0, 0),
+('Image.FocalLength', 2, 1, 0, 0),
+('Image.ISOSpeed', 2, 1, 0, 0),
+('Image.MeteringMode', 1, 1, 0, 0),
+('Image.WhiteBalance', 1, 1, 0, 0),
+('Image.Copyright', 0, 1, 0, 1);
/* optional contextual file data - gives a nice audit trail for a file */
diff --git a/debian/changelog b/debian/changelog
index c79aa5fb8..f29af88e5 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,9 @@
+tracker (0.0.5) unstable; urgency=low
+
+ * New upstream release.
+
+ -- Jamie McCracken <jamiemcc@gnome.org> Wed, 9 Aug 2006 04:12:37 +0100
+
tracker (0.0.4) unstable; urgency=low
* Initial Release.
diff --git a/debian/compat b/debian/compat
index b8626c4cf..7ed6ff82d 100644
--- a/debian/compat
+++ b/debian/compat
@@ -1 +1 @@
-4
+5
diff --git a/debian/control b/debian/control
index 39bd1d151..540d78ba7 100644
--- a/debian/control
+++ b/debian/control
@@ -2,14 +2,59 @@ Source: tracker
Section: utils
Priority: optional
Maintainer: Jamie McCracken <jamiemcc@gnome.org>
-Build-Depends: debhelper (>= 4.0.0), autotools-dev, libmysqlclient15-dev (>= 5.0.19), libextractor-dev (>= 0.5.0), libdbus-glib-1-dev
-Standards-Version: 3.6.1
+Build-Depends: debhelper (>= 5.0.0), autotools-dev, libextractor-dev (>= 0.5.0), libdbus-glib-1-dev
+Standards-Version: 3.7.2
-Package: tracker
+Package: meta-tracker
Architecture: any
-Depends: libc6 (>= 2.3.4-1), libglib2.0-0 (>= 2.10.0), libdbus-1-2 (>= 0.60), libdbus-glib-1-2 (>= 0.60), shared-mime-info, libextractor1c2a (>= 0.5.0)
-Description: Metadata database and indexing search tool.
- Tracker is an advanced framework for first class objects with
- associated metadata and tags. It provides a one stop solution for
- all metadata, tags, shared object databases, search tools and indexing.
+Depends: ${shlibs:Depends}, ${misc:Depends}
+Recommends: meta-tracker-utils
+Description: Metadata database and indexing search tool
+ Tracker is an advanced framework for first class objects with associated
+ metadata and tags. It provides a one stop solution for all metadata, tags,
+ shared object databases, search tools and indexing.
+Package: libmetatracker0
+Architecture: any
+Section: libs
+Depends: ${shlibs:Depends}, ${misc:Depends}, meta-tracker (= ${Source-Version})
+Description: Library for accessing Tracker
+ This library allow programmers accessing Tracker daemon and performing
+ searches.
+ .
+ Tracker is an advanced framework for first class objects with associated
+ metadata and tags. It provides a one stop solution for all metadata, tags,
+ shared object databases, search tools and indexing.
+
+Package: libmetatracker0-dev
+Architecture: any
+Section: devel
+Depends: libmetatracker0 (= ${Source-Version})
+Description: Development files for Tracker
+ This package contains the headers and other development files not included in
+ the libmetatracker0 package for developing with it.
+ .
+ Tracker is an advanced framework for first class objects with associated
+ metadata and tags. It provides a one stop solution for all metadata, tags,
+ shared object databases, search tools and indexing.
+
+Package: meta-tracker-utils
+Architecture: any
+Depends: ${shlibs:Depends}, ${misc:Depends}
+Description: Utilities for Tracker
+ Included utilities for Tracker:
+ * tracker-files: get files based on a ServiceType (Documents, Music, Images,
+ Videos, Text, Development, Other), or on specified mime types.
+ * tracker-meta-folder: get metadata for files in a folder.
+ * tracker-query: this reads from STDIN an RDF Query that specifies the search
+ criteria for various fields. It prints to STDOUT all matching files. Some
+ examples are included in this package.
+ * tracker-search: this perfoms a google like search using SEARCHTERM to
+ retrieve all matching files where SEARCHTERM appears in any searchable
+ metadata.
+ * tracker-stats: retreive some statistics.
+ * tracker-tag: tool to manage tags on files.
+ .
+ Tracker is an advanced framework for first class objects with associated
+ metadata and tags. It provides a one stop solution for all metadata, tags,
+ shared object databases, search tools and indexing.
diff --git a/debian/rules b/debian/rules
index 0e5684fd7..008b804f1 100755
--- a/debian/rules
+++ b/debian/rules
@@ -24,15 +24,20 @@ else
CFLAGS += -O2
endif
-config.status: configure
+# Ensure the build aborts when there are still references to undefined
+# symbols.
+LDFLAGS += -Wl,-z,defs
+
+configure: configure-stamp
+configure-stamp:
dh_testdir
# Add here commands to configure the package.
- #CFLAGS="$(CFLAGS) -Wl,-z,defs" ./configure --host=$(DEB_HOST_GNU_TYPE) --build=$(DEB_BUILD_GNU_TYPE) --prefix=/usr --mandir=\$${prefix}/share/man --infodir=\$${prefix}/share/info
- CFLAGS="$(CFLAGS)" ./configure --host=$(DEB_HOST_GNU_TYPE) --build=$(DEB_BUILD_GNU_TYPE) --prefix=/usr
+ CFLAGS="$(CFLAGS)" ./configure --host=$(DEB_HOST_GNU_TYPE) --build=$(DEB_BUILD_GNU_TYPE) --prefix=/usr
+ touch configure-stamp
build: build-stamp
-build-stamp: config.status
+build-stamp: configure-stamp
dh_testdir
# Add here commands to compile the package.
@@ -44,7 +49,7 @@ build-stamp: config.status
clean:
dh_testdir
dh_testroot
- rm -f build-stamp
+ rm -f build-stamp configure-stamp
# Add here commands to clean up after the build process.
-$(MAKE) distclean
@@ -64,9 +69,10 @@ install: build
dh_clean -k
dh_installdirs
- # Add here commands to install the package into debian/tracker.
- $(MAKE) install DESTDIR=$(CURDIR)/debian/tracker
+ # Add here commands to install the package into debian/tmp.
+ $(MAKE) install DESTDIR=$(CURDIR)/debian/tmp
+ dh_install
# Build architecture-independent files here.
binary-indep: build install
@@ -104,4 +110,4 @@ binary-arch: build install
dh_builddeb
binary: binary-indep binary-arch
-.PHONY: build clean binary-indep binary-arch binary install
+.PHONY: build clean binary-indep binary-arch binary install
diff --git a/filters/application/Makefile.am b/filters/application/Makefile.am
index ebf1410bf..4a7448e43 100644
--- a/filters/application/Makefile.am
+++ b/filters/application/Makefile.am
@@ -9,7 +9,5 @@ thumbappbin_SCRIPTS = pdf_filter \
vnd.sun.xml.calc_filter \
vnd.sun.xml.impress_filter \
vnd.sun.xml.writer_filter
-
-
-
+EXTRA_DIST = $(thumbappbin_SCRIPTS)
diff --git a/filters/application/pdf_filter b/filters/application/pdf_filter
index 73004b23e..93dac6f80 100755
--- a/filters/application/pdf_filter
+++ b/filters/application/pdf_filter
@@ -1,4 +1,4 @@
#!/bin/sh
-nice -n19 pdftotext -q -nopgbrk $1 $2
+nice -n19 pdftotext -enc UTF-8 -q -nopgbrk $1 $2
diff --git a/filters/text/Makefile.am b/filters/text/Makefile.am
index 5db829967..fb9c32837 100644
--- a/filters/text/Makefile.am
+++ b/filters/text/Makefile.am
@@ -1,5 +1,5 @@
filterbindir = $(datadir)/tracker/filters/text
-filterbin_SCRIPTS = html_filter
-
+filterbin_SCRIPTS = html_filter
+EXTRA_DIST = $(filterbin_SCRIPTS)
diff --git a/ltmain.sh b/ltmain.sh
index db4982d8a..8fc56db8f 100644
--- a/ltmain.sh
+++ b/ltmain.sh
@@ -43,8 +43,8 @@ EXIT_FAILURE=1
PROGRAM=ltmain.sh
PACKAGE=libtool
-VERSION="1.5.20 Debian 1.5.20-2"
-TIMESTAMP=" (1.1220.2.287 2005/08/31 18:54:15)"
+VERSION="1.5.22 Debian 1.5.22-2"
+TIMESTAMP=" (1.1220.2.365 2005/12/18 22:14:06)"
# See if we are running on zsh, and set the options which allow our
# commands through without removal of \ escapes.
@@ -132,6 +132,8 @@ run=
show="$echo"
show_help=
execute_dlfiles=
+duplicate_deps=no
+preserve_args=
lo2o="s/\\.lo\$/.${objext}/"
o2lo="s/\\.${objext}\$/.lo/"
@@ -139,6 +141,43 @@ o2lo="s/\\.${objext}\$/.lo/"
# Shell function definitions:
# This seems to be the best place for them
+# func_mktempdir [string]
+# Make a temporary directory that won't clash with other running
+# libtool processes, and avoids race conditions if possible. If
+# given, STRING is the basename for that directory.
+func_mktempdir ()
+{
+ my_template="${TMPDIR-/tmp}/${1-$progname}"
+
+ if test "$run" = ":"; then
+ # Return a directory name, but don't create it in dry-run mode
+ my_tmpdir="${my_template}-$$"
+ else
+
+ # If mktemp works, use that first and foremost
+ my_tmpdir=`mktemp -d "${my_template}-XXXXXXXX" 2>/dev/null`
+
+ if test ! -d "$my_tmpdir"; then
+ # Failing that, at least try and use $RANDOM to avoid a race
+ my_tmpdir="${my_template}-${RANDOM-0}$$"
+
+ save_mktempdir_umask=`umask`
+ umask 0077
+ $mkdir "$my_tmpdir"
+ umask $save_mktempdir_umask
+ fi
+
+ # If we're not in dry-run mode, bomb out on failure
+ test -d "$my_tmpdir" || {
+ $echo "cannot create temporary directory \`$my_tmpdir'" 1>&2
+ exit $EXIT_FAILURE
+ }
+ fi
+
+ $echo "X$my_tmpdir" | $Xsed
+}
+
+
# func_win32_libid arg
# return the library type of file 'arg'
#
@@ -157,12 +196,11 @@ func_win32_libid ()
if eval $OBJDUMP -f $1 | $SED -e '10q' 2>/dev/null | \
$EGREP -e 'file format pe-i386(.*architecture: i386)?' >/dev/null ; then
win32_nmres=`eval $NM -f posix -A $1 | \
- sed -n -e '1,100{/ I /{x;/import/!{s/^/import/;h;p;};x;};}'`
- if test "X$win32_nmres" = "Ximport" ; then
- win32_libid_type="x86 archive import"
- else
- win32_libid_type="x86 archive static"
- fi
+ $SED -n -e '1,100{/ I /{s,.*,import,;p;q;};}'`
+ case $win32_nmres in
+ import*) win32_libid_type="x86 archive import";;
+ *) win32_libid_type="x86 archive static";;
+ esac
fi
;;
*DLL*)
@@ -295,9 +333,9 @@ func_extract_archives ()
$run ${rm}r "$my_xdir"
$show "$mkdir $my_xdir"
$run $mkdir "$my_xdir"
- status=$?
- if test "$status" -ne 0 && test ! -d "$my_xdir"; then
- exit $status
+ exit_status=$?
+ if test "$exit_status" -ne 0 && test ! -d "$my_xdir"; then
+ exit $exit_status
fi
case $host in
*-darwin*)
@@ -352,6 +390,8 @@ func_extract_archives ()
# Darwin sucks
eval std_shrext=\"$shrext_cmds\"
+disable_libs=no
+
# Parse our command line options once, thoroughly.
while test "$#" -gt 0
do
@@ -468,7 +508,11 @@ do
preserve_args="$preserve_args $arg"
;;
- --tag) prevopt="--tag" prev=tag ;;
+ --tag)
+ prevopt="--tag"
+ prev=tag
+ preserve_args="$preserve_args --tag"
+ ;;
--tag=*)
set tag "$optarg" ${1+"$@"}
shift
@@ -500,6 +544,18 @@ if test -n "$prevopt"; then
exit $EXIT_FAILURE
fi
+case $disable_libs in
+no)
+ ;;
+shared)
+ build_libtool_libs=no
+ build_old_libs=yes
+ ;;
+static)
+ build_old_libs=`case $build_libtool_libs in yes) echo no;; *) echo yes;; esac`
+ ;;
+esac
+
# If this variable is set in any of the actions, the command in it
# will be execed at the end. This prevents here-documents from being
# left over by shells.
@@ -856,9 +912,9 @@ EOF
if test ! -d "${xdir}$objdir"; then
$show "$mkdir ${xdir}$objdir"
$run $mkdir ${xdir}$objdir
- status=$?
- if test "$status" -ne 0 && test ! -d "${xdir}$objdir"; then
- exit $status
+ exit_status=$?
+ if test "$exit_status" -ne 0 && test ! -d "${xdir}$objdir"; then
+ exit $exit_status
fi
fi
@@ -1061,6 +1117,7 @@ EOF
no_install=no
objs=
non_pic_objects=
+ notinst_path= # paths that contain not-installed libtool libraries
precious_files_regex=
prefer_static_libs=no
preload=no
@@ -1089,14 +1146,15 @@ EOF
if test -n "$link_static_flag"; then
dlopen_self=$dlopen_self_static
fi
+ prefer_static_libs=yes
else
if test -z "$pic_flag" && test -n "$link_static_flag"; then
dlopen_self=$dlopen_self_static
fi
+ prefer_static_libs=built
fi
build_libtool_libs=no
build_old_libs=yes
- prefer_static_libs=yes
break
;;
esac
@@ -1271,6 +1329,11 @@ EOF
if test -z "$pic_object" || test "$pic_object" = none ; then
arg="$non_pic_object"
fi
+ else
+ # If the PIC object exists, use it instead.
+ # $xdir was prepended to $pic_object above.
+ non_pic_object="$pic_object"
+ non_pic_objects="$non_pic_objects $non_pic_object"
fi
else
# Only an error if not doing a dry-run.
@@ -1354,8 +1417,8 @@ EOF
prev=
continue
;;
- darwin_framework)
- compiler_flags="$compiler_flags $arg"
+ darwin_framework|darwin_framework_skip)
+ test "$prev" = "darwin_framework" && compiler_flags="$compiler_flags $arg"
compile_command="$compile_command $arg"
finalize_command="$finalize_command $arg"
prev=
@@ -1419,13 +1482,17 @@ EOF
continue
;;
- -framework|-arch)
- prev=darwin_framework
- compiler_flags="$compiler_flags $arg"
+ -framework|-arch|-isysroot)
+ case " $CC " in
+ *" ${arg} ${1} "* | *" ${arg} ${1} "*)
+ prev=darwin_framework_skip ;;
+ *) compiler_flags="$compiler_flags $arg"
+ prev=darwin_framework ;;
+ esac
compile_command="$compile_command $arg"
finalize_command="$finalize_command $arg"
- continue
- ;;
+ continue
+ ;;
-inst-prefix-dir)
prev=inst_prefix
@@ -1453,7 +1520,8 @@ EOF
absdir=`cd "$dir" && pwd`
if test -z "$absdir"; then
$echo "$modename: cannot determine absolute directory name of \`$dir'" 1>&2
- exit $EXIT_FAILURE
+ absdir="$dir"
+ notinst_path="$notinst_path $dir"
fi
dir="$absdir"
;;
@@ -1467,10 +1535,15 @@ EOF
esac
case $host in
*-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2*)
+ testbindir=`$echo "X$dir" | $Xsed -e 's*/lib$*/bin*'`
case :$dllsearchpath: in
*":$dir:"*) ;;
*) dllsearchpath="$dllsearchpath:$dir";;
esac
+ case :$dllsearchpath: in
+ *":$testbindir:"*) ;;
+ *) dllsearchpath="$dllsearchpath:$testbindir";;
+ esac
;;
esac
continue
@@ -1479,11 +1552,11 @@ EOF
-l*)
if test "X$arg" = "X-lc" || test "X$arg" = "X-lm"; then
case $host in
- *-*-cygwin* | *-*-pw32* | *-*-beos*)
+ *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-beos*)
# These systems don't actually have a C or math library (as such)
continue
;;
- *-*-mingw* | *-*-os2*)
+ *-*-os2*)
# These systems don't actually have a C library (as such)
test "X$arg" = "X-lc" && continue
;;
@@ -1495,6 +1568,15 @@ EOF
# Rhapsody C and math libraries are in the System framework
deplibs="$deplibs -framework System"
continue
+ ;;
+ *-*-sco3.2v5* | *-*-sco5v6*)
+ # Causes problems with __ctype
+ test "X$arg" = "X-lc" && continue
+ ;;
+ *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*)
+ # Compiler inserts libc in the correct place for threads to work
+ test "X$arg" = "X-lc" && continue
+ ;;
esac
elif test "X$arg" = "X-lc_r"; then
case $host in
@@ -1536,7 +1618,12 @@ EOF
# +DA*, +DD* enable 64-bit mode on the HP compiler
# -q* pass through compiler args for the IBM compiler
# -m* pass through architecture-specific compiler args for GCC
- -64|-mips[0-9]|-r[0-9][0-9]*|-xarch=*|-xtarget=*|+DA*|+DD*|-q*|-m*)
+ # -m*, -t[45]*, -txscale* pass through architecture-specific
+ # compiler args for GCC
+ # -pg pass through profiling flag for GCC
+ # @file GCC response files
+ -64|-mips[0-9]|-r[0-9][0-9]*|-xarch=*|-xtarget=*|+DA*|+DD*|-q*|-m*|-pg| \
+ -t[45]*|-txscale*|@*)
# Unknown arguments in both finalize_command and compile_command need
# to be aesthetically quoted because they are evaled later.
@@ -1548,9 +1635,7 @@ EOF
esac
compile_command="$compile_command $arg"
finalize_command="$finalize_command $arg"
- if test "$with_gcc" = "yes" ; then
- compiler_flags="$compiler_flags $arg"
- fi
+ compiler_flags="$compiler_flags $arg"
continue
;;
@@ -1788,6 +1873,11 @@ EOF
if test -z "$pic_object" || test "$pic_object" = none ; then
arg="$non_pic_object"
fi
+ else
+ # If the PIC object exists, use it instead.
+ # $xdir was prepended to $pic_object above.
+ non_pic_object="$pic_object"
+ non_pic_objects="$non_pic_objects $non_pic_object"
fi
else
# Only an error if not doing a dry-run.
@@ -1893,9 +1983,9 @@ EOF
if test ! -d "$output_objdir"; then
$show "$mkdir $output_objdir"
$run $mkdir $output_objdir
- status=$?
- if test "$status" -ne 0 && test ! -d "$output_objdir"; then
- exit $status
+ exit_status=$?
+ if test "$exit_status" -ne 0 && test ! -d "$output_objdir"; then
+ exit $exit_status
fi
fi
@@ -1958,7 +2048,6 @@ EOF
newlib_search_path=
need_relink=no # whether we're linking any uninstalled libtool libraries
notinst_deplibs= # not-installed libtool libraries
- notinst_path= # paths that contain not-installed libtool libraries
case $linkmode in
lib)
passes="conv link"
@@ -2197,7 +2286,7 @@ EOF
esac # case $deplib
if test "$found" = yes || test -f "$lib"; then :
else
- $echo "$modename: cannot find the library \`$lib'" 1>&2
+ $echo "$modename: cannot find the library \`$lib' or unhandled argument \`$deplib'" 1>&2
exit $EXIT_FAILURE
fi
@@ -2448,8 +2537,12 @@ EOF
fi
link_static=no # Whether the deplib will be linked statically
+ use_static_libs=$prefer_static_libs
+ if test "$use_static_libs" = built && test "$installed" = yes ; then
+ use_static_libs=no
+ fi
if test -n "$library_names" &&
- { test "$prefer_static_libs" = no || test -z "$old_library"; }; then
+ { test "$use_static_libs" = no || test -z "$old_library"; }; then
if test "$installed" = no; then
notinst_deplibs="$notinst_deplibs $lib"
need_relink=yes
@@ -2562,11 +2655,15 @@ EOF
if test "$hardcode_direct" = no; then
add="$dir/$linklib"
case $host in
- *-*-sco3.2v5* ) add_dir="-L$dir" ;;
+ *-*-sco3.2v5.0.[024]*) add_dir="-L$dir" ;;
+ *-*-sysv4*uw2*) add_dir="-L$dir" ;;
+ *-*-sysv5OpenUNIX* | *-*-sysv5UnixWare7.[01].[10]* | \
+ *-*-unixware7*) add_dir="-L$dir" ;;
*-*-darwin* )
# if the lib is a module then we can not link against
# it, someone is ignoring the new warnings I added
- if /usr/bin/file -L $add 2> /dev/null | $EGREP "bundle" >/dev/null ; then
+ if /usr/bin/file -L $add 2> /dev/null |
+ $EGREP ": [^:]* bundle" >/dev/null ; then
$echo "** Warning, lib $linklib is a module, not a shared library"
if test -z "$old_library" ; then
$echo
@@ -3322,9 +3419,9 @@ EOF
# Eliminate all temporary directories.
for path in $notinst_path; do
- lib_search_path=`$echo "$lib_search_path " | ${SED} -e 's% $path % %g'`
- deplibs=`$echo "$deplibs " | ${SED} -e 's% -L$path % %g'`
- dependency_libs=`$echo "$dependency_libs " | ${SED} -e 's% -L$path % %g'`
+ lib_search_path=`$echo "$lib_search_path " | ${SED} -e "s% $path % %g"`
+ deplibs=`$echo "$deplibs " | ${SED} -e "s% -L$path % %g"`
+ dependency_libs=`$echo "$dependency_libs " | ${SED} -e "s% -L$path % %g"`
done
if test -n "$xrpath"; then
@@ -3377,7 +3474,12 @@ EOF
;;
*-*-openbsd* | *-*-freebsd* | *-*-dragonfly*)
# Do not include libc due to us having libc/libc_r.
- test "X$arg" = "X-lc" && continue
+ ;;
+ *-*-sco3.2v5* | *-*-sco5v6*)
+ # Causes problems with __ctype
+ ;;
+ *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*)
+ # Compiler inserts libc in the correct place for threads to work
;;
*)
# Add libc to deplibs on all other systems if necessary.
@@ -3421,7 +3523,7 @@ EOF
int main() { return 0; }
EOF
$rm conftest
- $LTCC -o conftest conftest.c $deplibs
+ $LTCC $LTCFLAGS -o conftest conftest.c $deplibs
if test "$?" -eq 0 ; then
ldd_output=`ldd conftest`
for i in $deplibs; do
@@ -3466,7 +3568,7 @@ EOF
# If $name is empty we are operating on a -L argument.
if test "$name" != "" && test "$name" != "0"; then
$rm conftest
- $LTCC -o conftest conftest.c $i
+ $LTCC $LTCFLAGS -o conftest conftest.c $i
# Did it work?
if test "$?" -eq 0 ; then
ldd_output=`ldd conftest`
@@ -3713,6 +3815,35 @@ EOF
deplibs=$newdeplibs
fi
+
+ # move library search paths that coincide with paths to not yet
+ # installed libraries to the beginning of the library search list
+ new_libs=
+ for path in $notinst_path; do
+ case " $new_libs " in
+ *" -L$path/$objdir "*) ;;
+ *)
+ case " $deplibs " in
+ *" -L$path/$objdir "*)
+ new_libs="$new_libs -L$path/$objdir" ;;
+ esac
+ ;;
+ esac
+ done
+ for deplib in $deplibs; do
+ case $deplib in
+ -L*)
+ case " $new_libs " in
+ *" $deplib "*) ;;
+ *) new_libs="$new_libs $deplib" ;;
+ esac
+ ;;
+ *) new_libs="$new_libs $deplib" ;;
+ esac
+ done
+ deplibs="$new_libs"
+
+
# All the library-specific variables (install_libdir is set above).
library_names=
old_library=
@@ -3796,6 +3927,7 @@ EOF
fi
lib="$output_objdir/$realname"
+ linknames=
for link
do
linknames="$linknames $link"
@@ -4227,6 +4359,35 @@ EOF
;;
esac
+
+ # move library search paths that coincide with paths to not yet
+ # installed libraries to the beginning of the library search list
+ new_libs=
+ for path in $notinst_path; do
+ case " $new_libs " in
+ *" -L$path/$objdir "*) ;;
+ *)
+ case " $compile_deplibs " in
+ *" -L$path/$objdir "*)
+ new_libs="$new_libs -L$path/$objdir" ;;
+ esac
+ ;;
+ esac
+ done
+ for deplib in $compile_deplibs; do
+ case $deplib in
+ -L*)
+ case " $new_libs " in
+ *" $deplib "*) ;;
+ *) new_libs="$new_libs $deplib" ;;
+ esac
+ ;;
+ *) new_libs="$new_libs $deplib" ;;
+ esac
+ done
+ compile_deplibs="$new_libs"
+
+
compile_command="$compile_command $compile_deplibs"
finalize_command="$finalize_command $finalize_deplibs"
@@ -4271,10 +4432,15 @@ EOF
fi
case $host in
*-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2*)
+ testbindir=`$echo "X$libdir" | $Xsed -e 's*/lib$*/bin*'`
case :$dllsearchpath: in
*":$libdir:"*) ;;
*) dllsearchpath="$dllsearchpath:$libdir";;
esac
+ case :$dllsearchpath: in
+ *":$testbindir:"*) ;;
+ *) dllsearchpath="$dllsearchpath:$testbindir";;
+ esac
;;
esac
done
@@ -4391,10 +4557,22 @@ extern \"C\" {
export_symbols="$output_objdir/$outputname.exp"
$run $rm $export_symbols
$run eval "${SED} -n -e '/^: @PROGRAM@ $/d' -e 's/^.* \(.*\)$/\1/p' "'< "$nlist" > "$export_symbols"'
+ case $host in
+ *cygwin* | *mingw* )
+ $run eval "echo EXPORTS "'> "$output_objdir/$outputname.def"'
+ $run eval 'cat "$export_symbols" >> "$output_objdir/$outputname.def"'
+ ;;
+ esac
else
- $run eval "${SED} -e 's/\([ ][.*^$]\)/\\\1/g' -e 's/^/ /' -e 's/$/$/'"' < "$export_symbols" > "$output_objdir/$outputname.exp"'
+ $run eval "${SED} -e 's/\([].[*^$]\)/\\\\\1/g' -e 's/^/ /' -e 's/$/$/'"' < "$export_symbols" > "$output_objdir/$outputname.exp"'
$run eval 'grep -f "$output_objdir/$outputname.exp" < "$nlist" > "$nlist"T'
$run eval 'mv "$nlist"T "$nlist"'
+ case $host in
+ *cygwin* | *mingw* )
+ $run eval "echo EXPORTS "'> "$output_objdir/$outputname.def"'
+ $run eval 'cat "$nlist" >> "$output_objdir/$outputname.def"'
+ ;;
+ esac
fi
fi
@@ -4511,16 +4689,29 @@ static const void *lt_preloaded_setup() {
esac
# Now compile the dynamic symbol file.
- $show "(cd $output_objdir && $LTCC -c$no_builtin_flag$pic_flag_for_symtable \"$dlsyms\")"
- $run eval '(cd $output_objdir && $LTCC -c$no_builtin_flag$pic_flag_for_symtable "$dlsyms")' || exit $?
+ $show "(cd $output_objdir && $LTCC $LTCFLAGS -c$no_builtin_flag$pic_flag_for_symtable \"$dlsyms\")"
+ $run eval '(cd $output_objdir && $LTCC $LTCFLAGS -c$no_builtin_flag$pic_flag_for_symtable "$dlsyms")' || exit $?
# Clean up the generated files.
$show "$rm $output_objdir/$dlsyms $nlist ${nlist}S ${nlist}T"
$run $rm "$output_objdir/$dlsyms" "$nlist" "${nlist}S" "${nlist}T"
# Transform the symbol file into the correct name.
- compile_command=`$echo "X$compile_command" | $Xsed -e "s%@SYMFILE@%$output_objdir/${outputname}S.${objext}%"`
- finalize_command=`$echo "X$finalize_command" | $Xsed -e "s%@SYMFILE@%$output_objdir/${outputname}S.${objext}%"`
+ case $host in
+ *cygwin* | *mingw* )
+ if test -f "$output_objdir/${outputname}.def" ; then
+ compile_command=`$echo "X$compile_command" | $Xsed -e "s%@SYMFILE@%$output_objdir/${outputname}.def $output_objdir/${outputname}S.${objext}%"`
+ finalize_command=`$echo "X$finalize_command" | $Xsed -e "s%@SYMFILE@%$output_objdir/${outputname}.def $output_objdir/${outputname}S.${objext}%"`
+ else
+ compile_command=`$echo "X$compile_command" | $Xsed -e "s%@SYMFILE@%$output_objdir/${outputname}S.${objext}%"`
+ finalize_command=`$echo "X$finalize_command" | $Xsed -e "s%@SYMFILE@%$output_objdir/${outputname}S.${objext}%"`
+ fi
+ ;;
+ * )
+ compile_command=`$echo "X$compile_command" | $Xsed -e "s%@SYMFILE@%$output_objdir/${outputname}S.${objext}%"`
+ finalize_command=`$echo "X$finalize_command" | $Xsed -e "s%@SYMFILE@%$output_objdir/${outputname}S.${objext}%"`
+ ;;
+ esac
;;
*)
$echo "$modename: unknown suffix for \`$dlsyms'" 1>&2
@@ -4545,7 +4736,7 @@ static const void *lt_preloaded_setup() {
# We have no uninstalled library dependencies, so finalize right now.
$show "$link_command"
$run eval "$link_command"
- status=$?
+ exit_status=$?
# Delete the generated files.
if test -n "$dlsyms"; then
@@ -4553,7 +4744,7 @@ static const void *lt_preloaded_setup() {
$run $rm "$output_objdir/${outputname}S.${objext}"
fi
- exit $status
+ exit $exit_status
fi
if test -n "$shlibpath_var"; then
@@ -4693,10 +4884,12 @@ static const void *lt_preloaded_setup() {
esac
case $host in
*cygwin* | *mingw* )
- cwrappersource=`$echo ${objdir}/lt-${outputname}.c`
- cwrapper=`$echo ${output}.exe`
- $rm $cwrappersource $cwrapper
- trap "$rm $cwrappersource $cwrapper; exit $EXIT_FAILURE" 1 2 15
+ output_name=`basename $output`
+ output_path=`dirname $output`
+ cwrappersource="$output_path/$objdir/lt-$output_name.c"
+ cwrapper="$output_path/$output_name.exe"
+ $rm $cwrappersource $cwrapper
+ trap "$rm $cwrappersource $cwrapper; exit $EXIT_FAILURE" 1 2 15
cat > $cwrappersource <<EOF
@@ -4721,6 +4914,9 @@ EOF
#include <malloc.h>
#include <stdarg.h>
#include <assert.h>
+#include <string.h>
+#include <ctype.h>
+#include <sys/stat.h>
#if defined(PATH_MAX)
# define LT_PATHMAX PATH_MAX
@@ -4731,15 +4927,19 @@ EOF
#endif
#ifndef DIR_SEPARATOR
-#define DIR_SEPARATOR '/'
+# define DIR_SEPARATOR '/'
+# define PATH_SEPARATOR ':'
#endif
#if defined (_WIN32) || defined (__MSDOS__) || defined (__DJGPP__) || \
defined (__OS2__)
-#define HAVE_DOS_BASED_FILE_SYSTEM
-#ifndef DIR_SEPARATOR_2
-#define DIR_SEPARATOR_2 '\\'
-#endif
+# define HAVE_DOS_BASED_FILE_SYSTEM
+# ifndef DIR_SEPARATOR_2
+# define DIR_SEPARATOR_2 '\\'
+# endif
+# ifndef PATH_SEPARATOR_2
+# define PATH_SEPARATOR_2 ';'
+# endif
#endif
#ifndef DIR_SEPARATOR_2
@@ -4749,17 +4949,32 @@ EOF
(((ch) == DIR_SEPARATOR) || ((ch) == DIR_SEPARATOR_2))
#endif /* DIR_SEPARATOR_2 */
+#ifndef PATH_SEPARATOR_2
+# define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR)
+#else /* PATH_SEPARATOR_2 */
+# define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR_2)
+#endif /* PATH_SEPARATOR_2 */
+
#define XMALLOC(type, num) ((type *) xmalloc ((num) * sizeof(type)))
#define XFREE(stale) do { \
if (stale) { free ((void *) stale); stale = 0; } \
} while (0)
+/* -DDEBUG is fairly common in CFLAGS. */
+#undef DEBUG
+#if defined DEBUGWRAPPER
+# define DEBUG(format, ...) fprintf(stderr, format, __VA_ARGS__)
+#else
+# define DEBUG(format, ...)
+#endif
+
const char *program_name = NULL;
void * xmalloc (size_t num);
char * xstrdup (const char *string);
-char * basename (const char *name);
-char * fnqualify(const char *path);
+const char * base_name (const char *name);
+char * find_executable(const char *wrapper);
+int check_executable(const char *path);
char * strendzap(char *str, const char *pat);
void lt_fatal (const char *message, ...);
@@ -4769,29 +4984,50 @@ main (int argc, char *argv[])
char **newargz;
int i;
- program_name = (char *) xstrdup ((char *) basename (argv[0]));
+ program_name = (char *) xstrdup (base_name (argv[0]));
+ DEBUG("(main) argv[0] : %s\n",argv[0]);
+ DEBUG("(main) program_name : %s\n",program_name);
newargz = XMALLOC(char *, argc+2);
EOF
- cat >> $cwrappersource <<EOF
- newargz[0] = "$SHELL";
+ cat >> $cwrappersource <<EOF
+ newargz[0] = (char *) xstrdup("$SHELL");
EOF
- cat >> $cwrappersource <<"EOF"
- newargz[1] = fnqualify(argv[0]);
+ cat >> $cwrappersource <<"EOF"
+ newargz[1] = find_executable(argv[0]);
+ if (newargz[1] == NULL)
+ lt_fatal("Couldn't find %s", argv[0]);
+ DEBUG("(main) found exe at : %s\n",newargz[1]);
/* we know the script has the same name, without the .exe */
/* so make sure newargz[1] doesn't end in .exe */
strendzap(newargz[1],".exe");
for (i = 1; i < argc; i++)
newargz[i+1] = xstrdup(argv[i]);
newargz[argc+1] = NULL;
+
+ for (i=0; i<argc+1; i++)
+ {
+ DEBUG("(main) newargz[%d] : %s\n",i,newargz[i]);
+ ;
+ }
+
EOF
- cat >> $cwrappersource <<EOF
+ case $host_os in
+ mingw*)
+ cat >> $cwrappersource <<EOF
+ execv("$SHELL",(char const **)newargz);
+EOF
+ ;;
+ *)
+ cat >> $cwrappersource <<EOF
execv("$SHELL",newargz);
EOF
+ ;;
+ esac
- cat >> $cwrappersource <<"EOF"
+ cat >> $cwrappersource <<"EOF"
return 127;
}
@@ -4812,48 +5048,148 @@ xstrdup (const char *string)
;
}
-char *
-basename (const char *name)
+const char *
+base_name (const char *name)
{
const char *base;
#if defined (HAVE_DOS_BASED_FILE_SYSTEM)
/* Skip over the disk name in MSDOS pathnames. */
- if (isalpha (name[0]) && name[1] == ':')
+ if (isalpha ((unsigned char)name[0]) && name[1] == ':')
name += 2;
#endif
for (base = name; *name; name++)
if (IS_DIR_SEPARATOR (*name))
base = name + 1;
- return (char *) base;
+ return base;
+}
+
+int
+check_executable(const char * path)
+{
+ struct stat st;
+
+ DEBUG("(check_executable) : %s\n", path ? (*path ? path : "EMPTY!") : "NULL!");
+ if ((!path) || (!*path))
+ return 0;
+
+ if ((stat (path, &st) >= 0) &&
+ (
+ /* MinGW & native WIN32 do not support S_IXOTH or S_IXGRP */
+#if defined (S_IXOTH)
+ ((st.st_mode & S_IXOTH) == S_IXOTH) ||
+#endif
+#if defined (S_IXGRP)
+ ((st.st_mode & S_IXGRP) == S_IXGRP) ||
+#endif
+ ((st.st_mode & S_IXUSR) == S_IXUSR))
+ )
+ return 1;
+ else
+ return 0;
}
+/* Searches for the full path of the wrapper. Returns
+ newly allocated full path name if found, NULL otherwise */
char *
-fnqualify(const char *path)
+find_executable (const char* wrapper)
{
- size_t size;
- char *p;
+ int has_slash = 0;
+ const char* p;
+ const char* p_next;
+ /* static buffer for getcwd */
char tmp[LT_PATHMAX + 1];
+ int tmp_len;
+ char* concat_name;
- assert(path != NULL);
+ DEBUG("(find_executable) : %s\n", wrapper ? (*wrapper ? wrapper : "EMPTY!") : "NULL!");
- /* Is it qualified already? */
+ if ((wrapper == NULL) || (*wrapper == '\0'))
+ return NULL;
+
+ /* Absolute path? */
#if defined (HAVE_DOS_BASED_FILE_SYSTEM)
- if (isalpha (path[0]) && path[1] == ':')
- return xstrdup (path);
+ if (isalpha ((unsigned char)wrapper[0]) && wrapper[1] == ':')
+ {
+ concat_name = xstrdup (wrapper);
+ if (check_executable(concat_name))
+ return concat_name;
+ XFREE(concat_name);
+ }
+ else
+ {
+#endif
+ if (IS_DIR_SEPARATOR (wrapper[0]))
+ {
+ concat_name = xstrdup (wrapper);
+ if (check_executable(concat_name))
+ return concat_name;
+ XFREE(concat_name);
+ }
+#if defined (HAVE_DOS_BASED_FILE_SYSTEM)
+ }
#endif
- if (IS_DIR_SEPARATOR (path[0]))
- return xstrdup (path);
- /* prepend the current directory */
- /* doesn't handle '~' */
+ for (p = wrapper; *p; p++)
+ if (*p == '/')
+ {
+ has_slash = 1;
+ break;
+ }
+ if (!has_slash)
+ {
+ /* no slashes; search PATH */
+ const char* path = getenv ("PATH");
+ if (path != NULL)
+ {
+ for (p = path; *p; p = p_next)
+ {
+ const char* q;
+ size_t p_len;
+ for (q = p; *q; q++)
+ if (IS_PATH_SEPARATOR(*q))
+ break;
+ p_len = q - p;
+ p_next = (*q == '\0' ? q : q + 1);
+ if (p_len == 0)
+ {
+ /* empty path: current directory */
+ if (getcwd (tmp, LT_PATHMAX) == NULL)
+ lt_fatal ("getcwd failed");
+ tmp_len = strlen(tmp);
+ concat_name = XMALLOC(char, tmp_len + 1 + strlen(wrapper) + 1);
+ memcpy (concat_name, tmp, tmp_len);
+ concat_name[tmp_len] = '/';
+ strcpy (concat_name + tmp_len + 1, wrapper);
+ }
+ else
+ {
+ concat_name = XMALLOC(char, p_len + 1 + strlen(wrapper) + 1);
+ memcpy (concat_name, p, p_len);
+ concat_name[p_len] = '/';
+ strcpy (concat_name + p_len + 1, wrapper);
+ }
+ if (check_executable(concat_name))
+ return concat_name;
+ XFREE(concat_name);
+ }
+ }
+ /* not found in PATH; assume curdir */
+ }
+ /* Relative path | not found in path: prepend cwd */
if (getcwd (tmp, LT_PATHMAX) == NULL)
lt_fatal ("getcwd failed");
- size = strlen(tmp) + 1 + strlen(path) + 1; /* +2 for '/' and '\0' */
- p = XMALLOC(char, size);
- sprintf(p, "%s%c%s", tmp, DIR_SEPARATOR, path);
- return p;
+ tmp_len = strlen(tmp);
+ concat_name = XMALLOC(char, tmp_len + 1 + strlen(wrapper) + 1);
+ memcpy (concat_name, tmp, tmp_len);
+ concat_name[tmp_len] = '/';
+ strcpy (concat_name + tmp_len + 1, wrapper);
+
+ if (check_executable(concat_name))
+ return concat_name;
+ XFREE(concat_name);
+ return NULL;
}
char *
@@ -4897,16 +5233,16 @@ lt_fatal (const char *message, ...)
va_end (ap);
}
EOF
- # we should really use a build-platform specific compiler
- # here, but OTOH, the wrappers (shell script and this C one)
- # are only useful if you want to execute the "real" binary.
- # Since the "real" binary is built for $host, then this
- # wrapper might as well be built for $host, too.
- $run $LTCC -s -o $cwrapper $cwrappersource
- ;;
- esac
- $rm $output
- trap "$rm $output; exit $EXIT_FAILURE" 1 2 15
+ # we should really use a build-platform specific compiler
+ # here, but OTOH, the wrappers (shell script and this C one)
+ # are only useful if you want to execute the "real" binary.
+ # Since the "real" binary is built for $host, then this
+ # wrapper might as well be built for $host, too.
+ $run $LTCC $LTCFLAGS -s -o $cwrapper $cwrappersource
+ ;;
+ esac
+ $rm $output
+ trap "$rm $output; exit $EXIT_FAILURE" 1 2 15
$echo > $output "\
#! $SHELL
@@ -5136,9 +5472,9 @@ fi\
$run ${rm}r "$gentop"
$show "$mkdir $gentop"
$run $mkdir "$gentop"
- status=$?
- if test "$status" -ne 0 && test ! -d "$gentop"; then
- exit $status
+ exit_status=$?
+ if test "$exit_status" -ne 0 && test ! -d "$gentop"; then
+ exit $exit_status
fi
fi
@@ -5805,18 +6141,7 @@ relink_command=\"$relink_command\""
outputname=
if test "$fast_install" = no && test -n "$relink_command"; then
if test "$finalize" = yes && test -z "$run"; then
- tmpdir="/tmp"
- test -n "$TMPDIR" && tmpdir="$TMPDIR"
- tmpdir="$tmpdir/libtool-$$"
- save_umask=`umask`
- umask 0077
- if $mkdir "$tmpdir"; then
- umask $save_umask
- else
- umask $save_umask
- $echo "$modename: error: cannot create temporary directory \`$tmpdir'" 1>&2
- continue
- fi
+ tmpdir=`func_mktempdir`
file=`$echo "X$file$stripped_ext" | $Xsed -e 's%^.*/%%'`
outputname="$tmpdir/$file"
# Replace the output file specification.
@@ -5940,7 +6265,7 @@ relink_command=\"$relink_command\""
# Exit here if they wanted silent mode.
test "$show" = : && exit $EXIT_SUCCESS
- $echo "----------------------------------------------------------------------"
+ $echo "X----------------------------------------------------------------------" | $Xsed
$echo "Libraries have been installed in:"
for libdir in $libdirs; do
$echo " $libdir"
@@ -5973,7 +6298,7 @@ relink_command=\"$relink_command\""
$echo
$echo "See any operating system documentation about shared libraries for"
$echo "more information, such as the ld(1) and ld.so(8) manual pages."
- $echo "----------------------------------------------------------------------"
+ $echo "X----------------------------------------------------------------------" | $Xsed
exit $EXIT_SUCCESS
;;
@@ -6190,9 +6515,17 @@ relink_command=\"$relink_command\""
rmfiles="$rmfiles $objdir/$n"
done
test -n "$old_library" && rmfiles="$rmfiles $objdir/$old_library"
- test "$mode" = clean && rmfiles="$rmfiles $objdir/$name $objdir/${name}i"
- if test "$mode" = uninstall; then
+ case "$mode" in
+ clean)
+ case " $library_names " in
+ # " " in the beginning catches empty $dlname
+ *" $dlname "*) ;;
+ *) rmfiles="$rmfiles $objdir/$dlname" ;;
+ esac
+ test -n "$libdir" && rmfiles="$rmfiles $objdir/$name $objdir/${name}i"
+ ;;
+ uninstall)
if test -n "$library_names"; then
# Do each command in the postuninstall commands.
cmds=$postuninstall_cmds
@@ -6225,7 +6558,8 @@ relink_command=\"$relink_command\""
IFS="$save_ifs"
fi
# FIXME: should reinstall the best remaining shared library.
- fi
+ ;;
+ esac
fi
;;
@@ -6524,12 +6858,11 @@ exit $?
# configuration. But we'll never go from static-only to shared-only.
# ### BEGIN LIBTOOL TAG CONFIG: disable-shared
-build_libtool_libs=no
-build_old_libs=yes
+disable_libs=shared
# ### END LIBTOOL TAG CONFIG: disable-shared
# ### BEGIN LIBTOOL TAG CONFIG: disable-static
-build_old_libs=`case $build_libtool_libs in yes) $echo no;; *) $echo yes;; esac`
+disable_libs=static
# ### END LIBTOOL TAG CONFIG: disable-static
# Local Variables:
diff --git a/src/Makefile.am b/src/Makefile.am
index c1345abd9..7ccf73606 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -5,6 +5,5 @@ else
extractor_dir =
endif
-SUBDIRS =text-filters trackerd libtracker $(extractor_dir) tracker-extract
-
-
+SUBDIRS = text-filters trackerd libtracker $(extractor_dir) tracker-extract
+DIST_SUBDIRS = text-filters trackerd libtracker $(extractor_dir) tracker-extract
diff --git a/src/tracker-extract/Makefile.am b/src/tracker-extract/Makefile.am
index fd49979ff..94516e488 100644
--- a/src/tracker-extract/Makefile.am
+++ b/src/tracker-extract/Makefile.am
@@ -11,5 +11,3 @@ extractor_ldadd = -lextractor
endif
tracker_extract_LDADD = $(GLIB2_LIBS) $(extractor_ldadd)
-
-
diff --git a/src/tracker-extract/tracker-extract.c b/src/tracker-extract/tracker-extract.c
index 628e45986..d9b017443 100644
--- a/src/tracker-extract/tracker-extract.c
+++ b/src/tracker-extract/tracker-extract.c
@@ -22,7 +22,11 @@
#include <string.h>
#include <unistd.h>
#include <glib.h>
+#ifndef USING_INTERNAL_LIBEXTRACTOR
+#include <extractor.h>
+#else
#include "../libextractor/src/include/extractor.h"
+#endif
typedef enum {
diff --git a/src/trackerd/Makefile.am b/src/trackerd/Makefile.am
index 3e718fea8..4c256ef6d 100644
--- a/src/trackerd/Makefile.am
+++ b/src/trackerd/Makefile.am
@@ -4,6 +4,8 @@ additional_mysql_flags = -D_THREAD_SAFE -D_REENTRANT
INCLUDES = \
-DDATADIR=\""$(datadir)"\" \
$(GLIB2_CFLAGS) \
+ $(PANGO_CFLAGS) \
+ $(QDBM_CFLAGS) \
$(FAM_CFLAGS) \
$(DBUS_CFLAGS) \
$(MYSQL_CFLAGS) \
@@ -13,6 +15,7 @@ INCLUDES = \
if HAVE_INOTIFY
inotify_sources = \
+ linux-inotify-syscalls.h \
tracker-inotify.c \
tracker-inotify.h
else
@@ -23,9 +26,21 @@ fam_sources = \
endif
endif
+if USING_SQLITE
+db_sources = \
+ tracker-indexer.c \
+ tracker-indexer.h \
+ tracker-parser.c \
+ tracker-parser.h \
+ tracker-db-sqlite.h \
+ tracker-db-sqlite.c
+else
+db_sources = \
+ tracker-db-mysql.h \
+ tracker-db-mysql.c
+endif
-
-bin_PROGRAMS = trackerd
+bin_PROGRAMS = trackerd tracker-convert-file
trackerd_SOURCES = \
trackerd.c \
@@ -45,10 +60,13 @@ trackerd_SOURCES = \
tracker-dbus-keywords.c \
tracker-dbus-search.h \
tracker-dbus-search.c \
+ $(db_sources) \
tracker-metadata.c \
tracker-metadata.h \
tracker-rdf-query.c \
tracker-rdf-query.h \
+ tracker-stemmer.c \
+ tracker-stemmer.h \
tracker-utils.c \
tracker-utils.h \
xdgmime.c \
@@ -72,6 +90,11 @@ trackerd_LDADD = $(GLIB2_LIBS) \
$(FAM_LIBS) \
$(DBUS_LIBS) \
$(MYSQL_LIBS) \
- -lstdc++
+ $(PANGO_LIBS) \
+ $(QDBM_LIBS) \
+ -lstdc++ \
+ -lmagic
+tracker_convert_file_SOURCES = tracker-convert-file.c tracker-parser.c tracker-stemmer.c
+tracker_convert_file_LDADD = $(GLIB2_LIBS) $(PANGO_LIBS) -lmagic
diff --git a/src/trackerd/tracker-db.c b/src/trackerd/tracker-db.c
index bb00b3f64..4d05de5b5 100644
--- a/src/trackerd/tracker-db.c
+++ b/src/trackerd/tracker-db.c
@@ -5,11 +5,10 @@
#include <unistd.h>
#include <sys/stat.h>
#include <fcntl.h>
-#include <mysql/mysql.h>
#include "tracker-db.h"
-extern GMutex *metadata_available_mutex;
-extern GMutex *files_available_mutex;
+extern Tracker *tracker;
+
typedef struct {
@@ -17,160 +16,26 @@ typedef struct {
char *file_id;
} DatabaseAction;
-gboolean use_nfs_safe_locking;
-
-
-static MYSQL *
-db_connect (const char* dbname)
-{
-
-
- MYSQL *db = mysql_init (NULL);
-
- if (!db) {
- tracker_log ( "Fatal error - mysql_init failed");
- exit (1);
- }
-
- mysql_options (db, MYSQL_OPT_USE_EMBEDDED_CONNECTION, NULL);
-
-
- if (!mysql_real_connect (db, NULL, "root", NULL, dbname, 0, NULL, CLIENT_MULTI_STATEMENTS)) {
- tracker_log ("Fatal error : mysql_real_connect failed: %s", mysql_error (db));
- exit (1);
- }
-
- return db;
-}
-
-MYSQL *
-tracker_db_connect ()
-{
- return db_connect ("tracker");
-}
-
-int
-tracker_db_prepare_statement (MYSQL *db, MYSQL_STMT **stmt, const char *query)
-{
- *stmt = mysql_stmt_init (db);
- if (!*stmt) {
- tracker_log (" mysql_stmt_init(), out of memory");
- exit (0);
- }
-
- if (mysql_stmt_prepare (*stmt, query, strlen (query)) != 0) {
- tracker_log (" mysql_stmt_prepare(), query failed due to %s", mysql_stmt_error (*stmt));
- return -5;
- }
- return mysql_stmt_param_count (*stmt);
-}
-
-/* get no of links to a file - used for safe NFS atomic file locking */
-static int
-get_nlinks (const char *name)
-{
- struct stat st;
- if (stat( name, &st) == 0) {
-
- return st.st_nlink;
- } else {
- return -1;
- }
-}
-
-
-static int
-get_mtime (const char *name)
-{
- struct stat st;
-
- if (stat( name, &st) == 0) {
-
- return st.st_mtime;
- } else {
- return -1;
- }
-}
-
-
-
-/* serialises db access via a lock file for safe use on (lock broken) NFS mounts */
-static gboolean
-lock_db ()
+char **
+tracker_db_get_row (char ***result, int num)
{
- int attempt, fd;
- char *lock_file, *tmp, *tmp_file;
-
- if (!use_nfs_safe_locking) {
- return TRUE;
- }
-
- lock_file = g_build_filename (g_get_home_dir (), ".Tracker", "tracker.lock", NULL);
- tmp = g_build_filename (g_get_home_dir (), ".Tracker", g_get_host_name (), NULL);
- tmp_file = g_strdup_printf ("%s_%ld.lock", tmp, (long)getpid ());
- g_free (tmp);
-
- for ( attempt=0; attempt < 10000; ++attempt) {
-
- /* delete existing lock file if older than 5 mins */
- if (g_file_test (lock_file, G_FILE_TEST_EXISTS) && ( time((time_t *)NULL) - get_mtime (lock_file)) > 300) {
- unlink (lock_file);
- }
- fd = open (lock_file, O_CREAT|O_EXCL, 0644);
- if (fd >= 0) {
-
- /* create host specific file and link to lock file */
- link (lock_file, tmp_file);
-
- /* for atomic NFS-safe locks, stat links = 2 if file locked. If greater than 2 then we have a race condition */
- if (get_nlinks (lock_file) == 2) {
- close (fd);
- g_free (lock_file);
- g_free (tmp_file);
- return TRUE;
-
- } else {
- close (fd);
- g_usleep (5000);
- }
-
- }
+ if (!result) {
+ return NULL;
}
- tracker_log ("lock failure");
- g_free (lock_file);
- g_free (tmp_file);
- return FALSE;
-}
-
-static void
-unlock_db ()
-{
- char *lock_file, *tmp, *tmp_file;
-
- if (!use_nfs_safe_locking) {
- return;
+ if (result[num]) {
+ return result[num];
}
- lock_file = g_build_filename (g_get_home_dir (), ".Tracker", "tracker.lock", NULL);
- tmp = g_build_filename (g_get_home_dir (), ".Tracker", g_get_host_name (), NULL);
- tmp_file = g_strdup_printf ("%s_%ld.lock", tmp, (long)getpid ());
- g_free (tmp);
-
- unlink (tmp_file);
- unlink (lock_file);
-
- g_free (tmp_file);
- g_free (lock_file);
+ return NULL;
}
-
void
tracker_db_log_result (char ***result)
{
@@ -228,226 +93,52 @@ tracker_db_free_result (char ***result)
}
-
int
-tracker_db_exec_stmt (MYSQL_STMT *stmt, int param_count, ...)
+tracker_get_row_count (char ***result)
{
+ char ***rows;
+ int i;
- va_list args;
- MYSQL_BIND bind[16];
- unsigned long length[16];
- char params[16][2048];
- int i;
- char *str;
-
-
- if (param_count > 16) {
- tracker_log ("Too many parameters to execute query");
- return -1;
- }
-
-
-
- memset(bind, 0, sizeof(bind));
-
- va_start(args, param_count);
-
- for (i = 0; i < param_count; i++ ) {
-
- str = va_arg (args, char *);
-
- if (strlen(str) > 2048) {
- tracker_log ("Warning - length of parameter %s is too long", str);
- }
-
- strncpy (params[i], str, 2048);
- length[i] = strlen (params[i]);
-
- /* Bind input buffers */
- bind[i].buffer_type = MYSQL_TYPE_VAR_STRING;
- bind[i].buffer = (char *)params[i];
- bind[i].buffer_length = 2048;
- bind[i].is_null = 0;
- bind[i].length = &length[i];
-
- }
-
- if (mysql_stmt_bind_param (stmt, bind)) {
- tracker_log ("bind failed");
- return -1;
+ if (!result) {
+ return 0;
}
+ i = 0;
- /* Execute the select statement */
- if (!lock_db ()) {
- return -1;
- }
- if (mysql_stmt_execute (stmt)) {
- unlock_db ();
- tracker_log ("error %s occured whilst executing stmt", mysql_stmt_error (stmt));
- return -1;
- }
- unlock_db ();
- va_end (args);
-
- int result = mysql_stmt_affected_rows (stmt);
- if (mysql_stmt_free_result (stmt)) {
- tracker_log ("ERROR Freeing statement %s", mysql_stmt_error (stmt));
+ for (rows = result; *rows; rows++) {
+ i++;
}
- //mysql_stmt_reset (stmt);
+ return i;
- return result;
-
}
-
-char ***
-tracker_db_exec_stmt_result (MYSQL_STMT *stmt, int param_count, ...)
+int
+tracker_get_field_count (char ***result)
{
+ char **p;
+ int i;
- va_list args;
- MYSQL_BIND bind[16];
- unsigned long length[16];
- gboolean is_null[16];
- char params[16][255];
- MYSQL_RES *prepare_meta_result;
- int i, column_count, row_count, row_num;
- char *str, **result;
-
-
- if (param_count > 16) {
- tracker_log ("Too many parameters to execute query");
- return NULL;
- }
-
-
-
- memset(bind, 0, sizeof(bind));
-
- va_start(args, param_count);
-
- for (i = 0; i < param_count; i++ ) {
-
- str = va_arg (args, char *);
-
- if (strlen(str) > 254) {
- tracker_log ("Warning - length of parameter %s is too long", str);
- }
-
- strncpy (params[i], str, 255);
-
- length[i] = strlen (params[i]);
-
- /* Bind input buffers */
- bind[i].buffer_type = MYSQL_TYPE_VAR_STRING;
- bind[i].buffer = (char *)params[i];
- bind[i].buffer_length = 255;
- bind[i].is_null = 0;
- bind[i].length = &length[i];
-
- }
-
- if (mysql_stmt_bind_param (stmt, bind)) {
- tracker_log ("bind failed");
- }
-
- prepare_meta_result = mysql_stmt_result_metadata (stmt);
-
- column_count = mysql_num_fields (prepare_meta_result);
-
- /* Execute the select statement */
- if (!lock_db ()) {
- return NULL;
- }
- if (mysql_stmt_execute (stmt)) {
- tracker_log ("error executing stmt");
+ if (!result || (tracker_get_row_count == 0)) {
+ return 0;
}
- unlock_db ();
-
- va_end (args);
- memset(bind, 0, sizeof(bind));
+ i = 0;
+ char **row = tracker_db_get_row (result, 0);
- for (i = 0; i < column_count; i++ ) {
- bind[i].buffer_type= MYSQL_TYPE_VAR_STRING;
- bind[i].buffer= (char *)params[i];
- bind[i].buffer_length= 255;
- bind[i].is_null = (my_bool*) &is_null[i];
- bind[i].length = &length[i];
+ if (!row) {
+ return 0;
}
- /* Bind the result buffers */
- if (mysql_stmt_bind_result (stmt, bind)) {
- tracker_log (" mysql_stmt_bind_result() failed");
- tracker_log ( " %s", mysql_stmt_error(stmt));
- return NULL;
- }
-
- /* Now buffer all results to client */
- if (mysql_stmt_store_result (stmt)) {
- tracker_log ( " mysql_stmt_store_result() failed");
- tracker_log ( " %s", mysql_stmt_error(stmt));
- return NULL;
+ for (p = row; *p; p++) {
+ i++;
}
- /* prepare result set string array */
- row_count = mysql_stmt_num_rows (stmt);
-
- if (!row_count > 0) {
- mysql_free_result (prepare_meta_result);
- mysql_stmt_free_result (stmt);
- return NULL;
- }
+ return i;
- result = g_new ( char *, row_count + 1);
- result [row_count] = NULL;
-
- /* Fetch all rows */
- row_num = 0;
-
- while (!mysql_stmt_fetch (stmt)) {
- char **row = g_new (char *, column_count + 1);
- row [column_count] = NULL;
-
- for (i = 0; i < column_count; i++ ) {
- if (length[i] > 10000) {
- row[i] = g_strndup (params[i], 10000);
- } else {
- row[i] = g_strndup (params[i], length[i]);
- }
- }
-
- result[row_num] = (gpointer)row;
- row_num++;
- }
-
-
- /* Free the prepared result metadata */
- mysql_free_result (prepare_meta_result);
-
- if (mysql_stmt_free_result (stmt)) {
- tracker_log ("ERROR Freeing statement");
- }
-
- //mysql_stmt_reset (stmt);
-
- return (char ***)result;
}
-
-
-void
-tracker_db_prepare_queries (DBConnection *db_con)
-{
-
- /* prepare queries to be used and bomb out if queries contain sql errors or erroneous parameter counts */
-
- g_assert (tracker_db_prepare_statement (db_con->db, &db_con->insert_contents_stmt, INSERT_CONTENTS) == 3);
-
-}
-
char *
@@ -477,131 +168,6 @@ tracker_db_get_id (DBConnection *db_con, const char* service, const char *uri)
-MYSQL_RES *
-tracker_exec_sql (MYSQL *db, const char *query)
-{
- MYSQL_RES *res = NULL;
- GTimeVal before, after;
- double elapsed;
-
-
- g_return_val_if_fail (query, NULL);
-
- //tracker_log ("executing query:\n%s\n", query);
- g_get_current_time (&before);
- if (!lock_db ()) {
- return NULL;
- }
-
-
- if (mysql_query (db, query) != 0) {
- unlock_db ();
- tracker_log ("tracker_exec_sql failed: %s [%s]", mysql_error (db), query);
- return res;
- }
- unlock_db ();
-
- g_get_current_time (&after);
-
- elapsed = (1000 * (after.tv_sec - before.tv_sec)) + ((after.tv_usec - before.tv_usec) / 1000);
-
-// tracker_log ("Query execution time is %f ms\n\n", elapsed);
-
- if (mysql_field_count (db) > 0) {
- if (!(res = mysql_store_result (db))) {
- tracker_log ("tracker_exec_sql failed: %s [%s]", mysql_error (db), query);
- }
- }
- return res;
-
-}
-
-char *
-tracker_escape_string (MYSQL *db, const char *in)
-{
- char *str, *str2;
- int i,j;
-
- if (!in) {
- return NULL;
- }
-
- i = strlen (in);
-
- str = g_new (char, (i*2)+1);
-
- j = mysql_real_escape_string (db, str, in, i);
-
- str2 = g_strndup (str, j);
-
- g_free (str);
-
- return str2;
-
-}
-
-MYSQL_RES *
-tracker_exec_proc (MYSQL *db, const char *procedure, int param_count, ...)
-{
- va_list args;
- int i;
- char *str, *param, *query_str;
- GString *query;
- MYSQL_RES *result;
-
-
- va_start (args, param_count);
-
- query = g_string_new ("Call ");
-
- g_string_append (query, procedure);
-
- g_string_append (query, "(");
-
- for (i = 0; i < param_count; i++ ) {
-
- str = va_arg (args, char *);
-
- if (!str) {
- tracker_log ("Warning - parameter %d is null", i);
- param = NULL;
- } else {
- param = tracker_escape_string (db, str);
- }
-
- if (i > 0) {
- g_string_append (query, ", ");
- }
-
- if (param) {
- g_string_append (query, "'");
-
- g_string_append (query, param);
-
- g_string_append (query, "'");
-
- g_free (param);
-
- } else {
- g_string_append (query, "NULL ");
- }
-
-
- }
-
- va_end (args);
-
- g_string_append (query, ")");
-
- query_str = g_string_free (query, FALSE);
-
- result = tracker_exec_sql (db, query_str);
-
- g_free (query_str);
-
- return result;
-
-}
int
@@ -624,15 +190,14 @@ tracker_db_get_file_id (DBConnection *db_con, const char* uri)
path = tracker_get_vfs_path (uri);
}
- MYSQL_RES *res = NULL;
- MYSQL_ROW row;
+ char ***res = NULL;
+ char **row = NULL;
-
- res = tracker_exec_proc (db_con->db, "GetServiceID", 2, path, name);
+ res = tracker_exec_proc (db_con, "GetServiceID", 2, path, name);
if (res) {
- row = mysql_fetch_row (res);
+ row = tracker_db_get_row (res, 0);
if (row && row[0]) {
id = atoi (row[0]);
@@ -644,7 +209,7 @@ tracker_db_get_file_id (DBConnection *db_con, const char* uri)
id = -1;
}
- mysql_free_result (res);
+ tracker_db_free_result (res);
}
@@ -667,23 +232,23 @@ tracker_db_get_file_info (DBConnection *db_con, FileInfo *info)
char *name = g_path_get_basename (info->uri);
char *path = g_path_get_dirname (info->uri);
- MYSQL_RES *res = NULL;
- MYSQL_ROW row;
+ char ***res = NULL;
+ char **row;
- char* apath = tracker_escape_string (db_con->db, path);
- char* aname = tracker_escape_string (db_con->db, name);
+ char* apath = tracker_escape_string (db_con, path);
+ char* aname = tracker_escape_string (db_con, name);
char *query = g_strconcat ("SELECT ID, IndexTime, IsDirectory FROM Files WHERE Path = '", apath ,"' AND FileName = '", aname , "'", NULL);
g_free (aname);
g_free (apath);
- res = tracker_exec_proc (db_con->db, "GetServiceID", 2, path, name);
+ res = tracker_exec_proc (db_con, "GetServiceID", 2, path, name);
g_free (query);
if (res) {
- row = mysql_fetch_row (res);
+ row = tracker_db_get_row (res, 0);
if (row && row[0]) {
info->file_id = atol (row[0]);
@@ -697,7 +262,7 @@ tracker_db_get_file_info (DBConnection *db_con, FileInfo *info)
info->is_directory = (strcmp (row[2], "1") == 0) ;
}
- mysql_free_result (res);
+ tracker_db_free_result (res);
}
@@ -708,281 +273,6 @@ tracker_db_get_file_info (DBConnection *db_con, FileInfo *info)
}
-static void
-create_system_db ()
-{
- MYSQL *db;
- char *sql_file;
- char *query;
- char **queries, **queries_p ;
-
-
- tracker_log ("Creating system database...");
- db = db_connect (NULL);
- tracker_exec_sql (db, "CREATE DATABASE mysql");
- mysql_close (db);
- db = db_connect ("mysql");
-
- sql_file = g_strdup (DATADIR "/tracker/mysql-system.sql");
-
- if (!g_file_get_contents (sql_file, &query, NULL, NULL)) {
- tracker_log ("Tracker cannot read required file %s - Please reinstall tracker or check read permissions on the file if it exists", sql_file);
- g_assert (FALSE);
- } else {
- queries = g_strsplit_set (query, ";", -1);
- for (queries_p = queries; *queries_p; queries_p++) {
- if (*queries_p) {
- tracker_exec_sql (db, *queries_p);
- }
- }
-
- g_strfreev (queries);
- g_free (query);
- }
-
- g_free (sql_file);
-
- mysql_close (db);
-
-}
-
-void
-tracker_db_load_stored_procs (MYSQL *db)
-{
- char *sql_file;
- char *query;
- char **queries, **queries_p ;
- MYSQL_RES *res = NULL;
-
- tracker_log ("Creating stored procedures...");
- sql_file = g_strdup (DATADIR "/tracker/mysql-stored-procs.sql");
-
- if (!g_file_get_contents (sql_file, &query, NULL, NULL)) {
- tracker_log ("Tracker cannot read required file %s - Please reinstall tracker or check read permissions on the file if it exists", sql_file);
- g_assert (FALSE);
- } else {
- queries = g_strsplit_set (query, "|", -1);
- for (queries_p = queries; *queries_p; queries_p++) {
- if (*queries_p) {
- res = tracker_exec_sql (db, *queries_p);
-
- if (res) {
- mysql_free_result (res);
- }
- }
- }
- g_strfreev (queries);
- g_free (query);
- }
-
- g_free (sql_file);
-
-
-}
-
-
-static void
-create_tracker_db ()
-{
- MYSQL *db;
- char *sql_file;
- char *query;
- char **queries, **queries_p ;
-
-
-
- tracker_log ("Creating tracker database...");
- db = db_connect (NULL);
- tracker_exec_sql (db, "CREATE DATABASE tracker");
- mysql_close (db);
- db = db_connect ("tracker");
- sql_file = g_strdup (DATADIR "/tracker/mysql-tracker.sql");
- tracker_log ("Creating tables...");
- if (!g_file_get_contents (sql_file, &query, NULL, NULL)) {
- tracker_log ("Tracker cannot read required file %s - Please reinstall tracker or check read permissions on the file if it exists", sql_file);
- g_assert (FALSE);
- } else {
- queries = g_strsplit_set (query, ";", -1);
- for (queries_p = queries; *queries_p; queries_p++) {
- if (*queries_p) {
- tracker_exec_sql (db, *queries_p);
- }
- }
- g_strfreev (queries);
- g_free (query);
-
- }
-
- g_free (sql_file);
-
- mysql_close (db);
-
-}
-
-
-
-void
-tracker_create_db ()
-{
- create_system_db ();
- create_tracker_db ();
-}
-
-
-void
-tracker_log_sql (MYSQL *db, const char *query)
-{
- MYSQL_RES *res = NULL;
- MYSQL_ROW row, end_row;
- char *str = NULL;
- GString *contents;
- int num_fields;
-
- contents = g_string_new ("");
-
- res = tracker_exec_sql (db, query);
-
- if (!res) {
- return;
- }
-
- num_fields = mysql_num_fields(res);
-
- while ((row = mysql_fetch_row (res))) {
-
- for (end_row = row + num_fields; row < end_row; ++row) {
-
- if (*row) {
- g_string_append (contents, (char *) *row);
- } else {
- g_string_append (contents, "NULL");
- }
-
- g_string_append (contents, ", ");
-
- }
- g_string_append (contents, "\n");
- }
-
- str = g_string_free (contents, FALSE);
- tracker_log ("results of query %s is \n%s\n\n", query, str);
- g_free (str);
- mysql_free_result (res);
-}
-
-gboolean
-tracker_update_db (MYSQL *db)
-{
- MYSQL_RES *res = NULL;
- MYSQL_ROW row;
- char *sql_file;
- char *query;
- char **queries, **queries_p;
- gboolean refresh = FALSE;
-
- res = tracker_exec_sql (db, "show tables");
- tracker_log ("Checking for Options table...");
-
- gboolean found_options = FALSE;
- if (res) {
-
- while ((row = mysql_fetch_row (res))) {
- if (((row[0]) && (strcmp (row[0], "Options") == 0))) {
- tracker_log ("Options table is present");
- found_options = TRUE;
- break;
- }
- }
-
- mysql_free_result (res);
-
- if (!found_options) {
- tracker_log ("Cannot find Options table - your database is out of date and will need to be rebuilt");
- tracker_exec_sql (db, "Drop Database tracker");
- tracker_create_db ();
- return TRUE;
- }
- }
-
- res = tracker_exec_sql (db, "SELECT OptionValue FROM Options WHERE OptionKey = 'DBVersion'");
-
- if (!res) {
- return FALSE;
- }
-
- row = mysql_fetch_row (res);
-
- if (!row || !row[0]) {
- mysql_free_result (res);
- return FALSE;
- }
-
- char* version = row[0];
- int i = atoi (version);
- mysql_free_result (res);
-
- tracker_log ("Checking tracker DB version...Current version is %d and needed version is %d", i, TRACKER_DB_VERSION_REQUIRED);
- if (i < 3) {
- tracker_log ("Your database is out of date and will need to be rebuilt and all your files reindexed.\nThis may take a while...please wait...");
- tracker_exec_sql (db, "Drop Database tracker");
- create_tracker_db ();
- return TRUE;
-
- }
-
- /* apply and table changes for each version update */
-/* while (i < TRACKER_DB_VERSION_REQUIRED) {
-
- i++;
-
- sql_file = g_strconcat (DATADIR, "/tracker/tracker-db-table-update", version, ".sql", NULL);
-
- tracker_log ("Please wait while database is being updated to the latest version");
-
- if (g_file_get_contents (sql_file, &query, NULL, NULL)) {
-
- queries = g_strsplit_set (query, ";", -1);
- for (queries_p = queries; *queries_p; queries_p++) {
- if (*queries_p) {
- tracker_exec_sql (db, *queries_p);
- }
- }
- g_strfreev (queries);
- g_free (query);
- }
-
- g_free (sql_file);
-
-
- }
-*/
- /* regenerate SPs */
- tracker_log ("Creating stored procedures...");
- sql_file = g_strdup (DATADIR "/tracker/mysql-stored-procs.sql");
-
- if (!g_file_get_contents (sql_file, &query, NULL, NULL)) {
- tracker_log ("Tracker cannot read required file %s - Please reinstall tracker or check read permissions on the file if it exists", sql_file);
- g_assert (FALSE);
- } else {
- queries = g_strsplit_set (query, "|", -1);
- for (queries_p = queries; *queries_p; queries_p++) {
- if (*queries_p) {
- res = tracker_exec_sql (db, *queries_p);
-
- if (res) {
- mysql_free_result (res);
- }
- }
- }
- g_strfreev (queries);
- g_free (query);
- }
-
- g_free (sql_file);
-
- return refresh;
-}
-
static void
@@ -992,8 +282,8 @@ get_meta_table_data (gpointer key,
{
DatabaseAction *db_action;
char *mtype, *mvalue, *avalue, *dvalue = NULL, *evalue;
- MYSQL_RES *res = NULL;
- MYSQL_ROW row;
+ char ***res = NULL;
+ char ** row;
mtype = (char *)key;
avalue = (char *)value;
@@ -1029,23 +319,23 @@ get_meta_table_data (gpointer key,
evalue = g_strdup (avalue);
}
- mvalue = tracker_escape_string (db_action->db_con->db, evalue);
+ mvalue = tracker_escape_string (db_action->db_con, evalue);
if (evalue) {
g_free (evalue);
}
- res = tracker_exec_proc (db_action->db_con->db, "SetMetadata", 5, "Files", db_action->file_id, mtype, mvalue, "1");
+ res = tracker_exec_proc (db_action->db_con, "SetMetadata", 5, "Files", db_action->file_id, mtype, mvalue, "1");
if (res) {
- if ((row = mysql_fetch_row (res))) {
+ if ((row = tracker_db_get_row (res, 0))) {
if (row[0]) {
tracker_log ("Error %s saving metadata %s with value %s", row[0], mtype, mvalue);
}
}
- mysql_free_result (res);
+ tracker_db_free_result (res);
}
if (mvalue) {
@@ -1087,16 +377,16 @@ tracker_db_save_thumbs (DBConnection *db_con, const char *small_thumb, const cha
str_file_id = g_strdup_printf ("%ld", file_id);
if (small_thumb) {
- small_thumb_file = tracker_escape_string (db_con->db, small_thumb);
- tracker_exec_proc (db_con->db, "SetMetadata", 5, "Files", str_file_id, "File.SmallThumbnailPath", small_thumb_file, "1");
+ small_thumb_file = tracker_escape_string (db_con, small_thumb);
+ tracker_exec_proc (db_con, "SetMetadata", 5, "Files", str_file_id, "File.SmallThumbnailPath", small_thumb_file, "1");
g_free (small_thumb_file);
}
if (large_thumb) {
- large_thumb_file = tracker_escape_string (db_con->db, large_thumb);
- tracker_exec_proc (db_con->db, "SetMetadata", 5, "Files", str_file_id, "File.LargeThumbnailPath", large_thumb_file, "1");
+ large_thumb_file = tracker_escape_string (db_con, large_thumb);
+ tracker_exec_proc (db_con, "SetMetadata", 5, "Files", str_file_id, "File.LargeThumbnailPath", large_thumb_file, "1");
g_free (large_thumb_file);
}
@@ -1108,140 +398,6 @@ tracker_db_save_thumbs (DBConnection *db_con, const char *small_thumb, const cha
}
-void
-tracker_db_save_file_contents (DBConnection *db_con, const char *file_name, long file_id)
-{
-
- FILE *file;
- char buffer[16384];
- int bytes_read = 0;
- unsigned long file_id_length, meta_id_length;
- MYSQL_BIND bind[3];
- unsigned long length;
- char *str_file_id, *str_meta_id, *value;
- FieldDef *def;
-
- file = fopen (file_name,"r");
- //tracker_log ("saving text to db with file_id %ld", file_id);
-
- if (!file) {
- tracker_log ("Could not open file %s", file_name);
- return;
- }
-
- def = tracker_db_get_field_def (db_con, "File.Content");
- if (!def || !def->id) {
- tracker_log ("Could not get metadata for File.Content");
- return;
- }
-
- str_meta_id = g_strdup (def->id);
-
- tracker_db_free_field_def (def);
-
- str_file_id = g_strdup_printf ("%ld", file_id);
- file_id_length = strlen (str_file_id);
- meta_id_length = strlen (str_meta_id);
-
-
- memset (bind, 0, sizeof(bind));
-
- bind[0].buffer_type= MYSQL_TYPE_VAR_STRING;
- bind[0].buffer= str_file_id;
- bind[0].is_null= 0;
- bind[0].length = &file_id_length;
-
- bind[1].buffer_type= MYSQL_TYPE_VAR_STRING;
- bind[1].buffer= str_meta_id;
- bind[1].is_null= 0;
- bind[1].length = &meta_id_length;
-
- bind[2].buffer_type= MYSQL_TYPE_VAR_STRING;
- bind[2].length= &length;
- bind[2].is_null= 0;
-
-
- /* Bind the buffers */
- if (mysql_stmt_bind_param (db_con->insert_contents_stmt, bind)) {
- tracker_log ("binding error : %s\n", mysql_stmt_error (db_con->insert_contents_stmt));
- g_free (str_meta_id);
- g_free (str_file_id);
- fclose (file);
-
- return;
- }
-
- /* Supply file's text in chunks to server as it could be huge */
- /* to do - need a gconf setting to define max bytes to be read */
- while ( (feof (file) == 0) && (bytes_read < (1024 * 2048)) ) {
-
- /* leave 2x space in buffer so that potential utf8 conversion can fit */
- fgets (buffer, 8192, file);
-
- if (strlen (buffer) < 2) {
- continue;
- }
-
- if (!g_utf8_validate (buffer, -1, NULL)) {
-
- /* attempt to convert it into valid utf8 using locale */
- value = g_locale_to_utf8 (buffer, -1, NULL, NULL, NULL);
-
- if (!value) {
- continue;
- } else {
- if (strlen (value) > 16383) {
- g_free (value);
- continue;
- } else {
- strncpy (buffer, value, 16384);
- g_free (value);
- }
- }
- }
-
- bytes_read += strlen (buffer);
-
- if (mysql_stmt_send_long_data (db_con->insert_contents_stmt, 2, buffer, strlen (buffer)) != 0) {
-
- tracker_log ("error sending data : %s\n", mysql_stmt_error (db_con->insert_contents_stmt));
- g_free (str_meta_id);
- g_free (str_file_id);
- fclose (file);
- return;
-
- }
- }
-
- if (!lock_db ()) {
- g_free (str_file_id);
- g_free (str_meta_id);
- fclose (file);
- return;
- }
-
- if (bytes_read > 3) {
- if (mysql_stmt_execute (db_con->insert_contents_stmt) != 0) {
-
- tracker_log ("insert metadata indexed query failed :%s", mysql_stmt_error (db_con->insert_contents_stmt));
- } else {
-
- //tracker_log ("%d bytes of text successfully inserted into file id %s", bytes_read, str_file_id);
- }
- }
- unlock_db ();
- g_free (str_meta_id);
- g_free (str_file_id);
- fclose (file);
-
-
- if (mysql_stmt_free_result (db_con->insert_contents_stmt)) {
- tracker_log ("ERROR Freeing file contents statement");
- }
-
-
-}
-
char **
tracker_db_get_files_in_folder (DBConnection *db_con, const char *folder_uri)
@@ -1252,14 +408,14 @@ tracker_db_get_files_in_folder (DBConnection *db_con, const char *folder_uri)
g_return_val_if_fail (db_con && folder_uri && (strlen (folder_uri) > 0), NULL);
- MYSQL_RES *res = NULL;
- MYSQL_ROW row;
+ char ***res = NULL;
+ char ** row;
- res = tracker_exec_proc (db_con->db, "SelectFileChild", 1, folder_uri);
+ res = tracker_exec_proc (db_con, "SelectFileChild", 1, folder_uri);
if (res) {
- row_count = mysql_num_rows (res);
+ row_count = tracker_get_row_count (res);
if (row_count > 0) {
@@ -1267,7 +423,7 @@ tracker_db_get_files_in_folder (DBConnection *db_con, const char *folder_uri)
i = 0;
- while ((row = mysql_fetch_row (res))) {
+ while ((row = tracker_db_get_row (res, i))) {
if (row[1] && row[2]) {
array[i] = g_build_filename (row[1], row[2], NULL);
@@ -1284,7 +440,7 @@ tracker_db_get_files_in_folder (DBConnection *db_con, const char *folder_uri)
array[0] = NULL;
}
- mysql_free_result (res);
+ tracker_db_free_result (res);
} else {
array = g_new (char *, 1);
@@ -1303,23 +459,23 @@ tracker_db_get_field_def (DBConnection *db_con, const char *field_name)
{
FieldDef *def;
- MYSQL_RES *res = NULL;
- MYSQL_ROW row;
+ char ***res = NULL;
+ char ** row;
def = g_new (FieldDef, 1);
- res = tracker_exec_proc (db_con->db, "GetMetadataTypeInfo", 1, field_name);
+ res = tracker_exec_proc (db_con, "GetMetadataTypeInfo", 1, field_name);
if (res) {
- row = mysql_fetch_row (res);
+ row = tracker_db_get_row (res, 0);
}
if (res && row && row[0]) {
def->id = g_strdup (row[0]);
} else {
g_free (def);
- mysql_free_result (res);
+ tracker_db_free_result (res);
return NULL;
}
@@ -1337,7 +493,7 @@ tracker_db_get_field_def (DBConnection *db_con, const char *field_name)
- mysql_free_result (res);
+ tracker_db_free_result (res);
return def;
@@ -1379,13 +535,13 @@ tracker_db_get_pending_file (DBConnection *db_con, const char *uri)
{
FileInfo *info = NULL;
- MYSQL_RES *res = NULL;
- MYSQL_ROW row;
+ char ***res = NULL;
+ char **row;
- res = tracker_exec_proc (db_con->db, "SelectPendingByUri", 1, uri);
+ res = tracker_exec_proc (db_con, "SelectPendingByUri", 1, uri);
if (res) {
- row = mysql_fetch_row (res);
+ row = tracker_db_get_row (res, 0);
if (row && row[0] && row[1] && row[2] && row[3] && row[4]) {
info = tracker_create_file_info (uri, atoi(row[2]), 0, 0);
@@ -1393,7 +549,7 @@ tracker_db_get_pending_file (DBConnection *db_con, const char *uri)
info->is_directory = (strcmp (row[4], "0") == 0);
}
- mysql_free_result (res);
+ tracker_db_free_result (res);
}
@@ -1418,18 +574,26 @@ make_pending_file (DBConnection *db_con, long file_id, const char *uri, const ch
str_counter = g_strdup_printf ("%d", counter);
if (!mime) {
- tracker_exec_proc (db_con->db, "InsertPendingFile", 6, str_file_id, str_action, str_counter, uri, "unknown", str_is_directory);
+ if (tracker->is_running) {
+ tracker_exec_proc (db_con, "InsertPendingFile", 6, str_file_id, str_action, str_counter, uri, "unknown", str_is_directory);
+ } else {
+ return;
+ }
} else {
- tracker_exec_proc (db_con->db, "InsertPendingFile", 6, str_file_id, str_action, str_counter, uri, mime, str_is_directory);
+ if (tracker->is_running) {
+ tracker_exec_proc (db_con, "InsertPendingFile", 6, str_file_id, str_action, str_counter, uri, mime, str_is_directory);
+ } else {
+ return;
+ }
}
//tracker_log ("inserting pending file for %s with action %s", uri, tracker_actions[action]);
- /* signal respective thread that data is available if its waiting */
+ /* signal respective thread that data is available and awake it if its asleep */
if (action == TRACKER_ACTION_EXTRACT_METADATA) {
- g_mutex_trylock (metadata_available_mutex);
+ tracker_notify_meta_data_available ();
} else {
- g_mutex_trylock (files_available_mutex);
+ tracker_notify_file_data_available ();
}
g_free (str_file_id);
@@ -1449,7 +613,9 @@ tracker_db_update_pending_file (DBConnection *db_con, const char* uri, int count
str_counter = g_strdup_printf ("%d", counter);
str_action = g_strdup_printf ("%d", action);
- tracker_exec_proc (db_con->db, "UpdatePendingFile", 3, str_counter, str_action, uri);
+ if (tracker->is_running) {
+ tracker_exec_proc (db_con, "UpdatePendingFile", 3, str_counter, str_action, uri);
+ }
g_free (str_counter);
g_free (str_action);
@@ -1531,14 +697,14 @@ tracker_db_insert_pending_file (DBConnection *db_con, long file_id, const char *
gboolean
tracker_is_valid_service (DBConnection *db_con, const char *service)
{
- MYSQL_RES *res = NULL;
- MYSQL_ROW row;
+ char ***res = NULL;
+ char ** row;
gboolean result = FALSE;
- res = tracker_exec_proc (db_con->db, "ValidService", 1, service);
+ res = tracker_exec_proc (db_con, "ValidService", 1, service);
if (res) {
- row = mysql_fetch_row (res);
+ row = tracker_db_get_row (res, 0);
if (row && row[0]) {
if (strcmp (row[0], "1") == 0) {
@@ -1546,9 +712,41 @@ tracker_is_valid_service (DBConnection *db_con, const char *service)
}
}
- mysql_free_result (res);
+ tracker_db_free_result (res);
}
return result;
}
+
+
+gboolean
+tracker_db_index_id_exists (DBConnection *db_con, unsigned int id)
+{
+
+ char ***res = NULL;
+ char ** row;
+ gboolean result = FALSE;
+
+ char *id_str = tracker_int_to_str (id);
+ res = tracker_exec_proc (db_con, "IndexIDExists", 1, id_str);
+ g_free (id_str);
+
+ if (res) {
+ row = tracker_db_get_row (res, 0);
+
+ if (row && row[0]) {
+ if (strcmp (row[0], "1") == 0) {
+ result = TRUE;
+ }
+ }
+
+ tracker_db_free_result (res);
+ }
+
+ return result;
+
+
+}
+
+
diff --git a/src/trackerd/tracker-db.h b/src/trackerd/tracker-db.h
index 4362ae1ad..a0e14e432 100644
--- a/src/trackerd/tracker-db.h
+++ b/src/trackerd/tracker-db.h
@@ -20,24 +20,15 @@
#ifndef _TRACKER_DB_H_
#define _TRACKER_DB_H_
-#include <mysql/mysql.h>
#include <glib.h>
#include "tracker-utils.h"
+#include "config.h"
-/* Paramterised queries : */
-
-#define INSERT_CONTENTS "INSERT INTO ServiceMetaData (ServiceID, MetaDataID, MetaDataIndexValue) VALUES (?,?,?)"
-
-
-
-typedef struct {
- MYSQL *db;
-
- /* statement for parameterised query */
-
- MYSQL_STMT *insert_contents_stmt;
-
-} DBConnection;
+#ifdef USING_SQLITE
+#include "tracker-db-sqlite.h"
+#else
+#include "tracker-db-mysql.h"
+#endif
typedef enum {
DATA_INDEX_STRING,
@@ -55,29 +46,17 @@ typedef struct {
} FieldDef;
-
-MYSQL * tracker_db_connect ();
-gboolean tracker_update_db ();
-char * tracker_escape_string (MYSQL *db, const char *in);
-int tracker_db_prepare_statement (MYSQL *db, MYSQL_STMT **stmt, const char *query);
-void tracker_db_prepare_queries (DBConnection *db_con);
-MYSQL_RES * tracker_exec_proc (MYSQL *db, const char *procedure, int param_count, ...);
-//char *** tracker_db_exec_stmt_result (MYSQL_STMT *stmt, int param_count, ...);
-//int tracker_db_exec_stmt (MYSQL_STMT *stmt, int param_count, ...);
+char ** tracker_db_get_row (char ***result, int num);
void tracker_db_free_result (char ***result);
void tracker_db_log_result (char ***result);
+int tracker_get_row_count (char ***result);
+int tracker_get_field_count (char ***result);
FileInfo * tracker_db_get_file_info (DBConnection *db_con, FileInfo *info);
int tracker_db_get_file_id (DBConnection *db_con, const char* uri);
gboolean tracker_is_valid_service (DBConnection *db_con, const char *service);
char * tracker_db_get_id (DBConnection *db_con, const char* service, const char *uri);
-MYSQL_RES * tracker_exec_sql (MYSQL *db, const char *query);
-void tracker_log_sql (MYSQL *db, const char *query);
-void tracker_create_db ();
-void tracker_db_load_stored_procs (MYSQL *db);
-gboolean tracker_db_save_file (FileInfo *info);
void tracker_db_save_metadata (DBConnection *db_con, GHashTable *table, long file_id);
void tracker_db_save_thumbs (DBConnection *db_con, const char *small_thumb, const char *large_thumb, long file_id);
-void tracker_db_save_file_contents (DBConnection *db_con, const char *file_name, long file_id);
char ** tracker_db_get_files_in_folder (DBConnection *db_con, const char *folder_uri);
FieldDef * tracker_db_get_field_def (DBConnection *db_con, const char *field_name);
void tracker_db_free_field_def (FieldDef *def);
@@ -85,6 +64,7 @@ gboolean tracker_metadata_is_date (DBConnection *db_con, const char* meta);
FileInfo * tracker_db_get_pending_file (DBConnection *db_con, const char *uri);
void tracker_db_update_pending_file (DBConnection *db_con, const char* uri, int counter, TrackerChangeAction action);
void tracker_db_insert_pending_file (DBConnection *db_con, long file_id, const char *uri, const char *mime, int counter, TrackerChangeAction action, gboolean is_directory);
+gboolean tracker_db_index_id_exists (DBConnection *db_con, unsigned int id);
#endif
diff --git a/src/trackerd/tracker-dbus-files.c b/src/trackerd/tracker-dbus-files.c
index 3129331a1..23c49108c 100644
--- a/src/trackerd/tracker-dbus-files.c
+++ b/src/trackerd/tracker-dbus-files.c
@@ -109,18 +109,18 @@ tracker_dbus_method_files_exists (DBusRec *rec)
}
if (file_valid) {
- tracker_exec_proc (db_con->db, "CreateService", 8, path, name, service, str_is_dir, "0", "0", "0", str_mtime);
+ tracker_exec_proc (db_con, "CreateService", 8, path, name, service, str_is_dir, "0", "0", "0", str_mtime);
}
file_id = tracker_db_get_file_id (db_con, uri);
char *str_file_id = tracker_long_to_str (file_id);
if (file_id > 0) {
- tracker_exec_proc (db_con->db, "SetMetadata", 5, service, str_file_id, "File.Modified", str_mtime, "1");
- tracker_exec_proc (db_con->db, "SetMetadata", 5, service, str_file_id, "File.Size", str_size, "1");
- tracker_exec_proc (db_con->db, "SetMetadata", 5, service, str_file_id, "File.Name", name, "1");
- tracker_exec_proc (db_con->db, "SetMetadata", 5, service, str_file_id, "File.Path", path, "1");
- tracker_exec_proc (db_con->db, "SetMetadata", 5, service, str_file_id, "File.Format", mime, "1");
+ tracker_exec_proc (db_con, "SetMetadata", 5, service, str_file_id, "File.Modified", str_mtime, "1");
+ tracker_exec_proc (db_con, "SetMetadata", 5, service, str_file_id, "File.Size", str_size, "1");
+ tracker_exec_proc (db_con, "SetMetadata", 5, service, str_file_id, "File.Name", name, "1");
+ tracker_exec_proc (db_con, "SetMetadata", 5, service, str_file_id, "File.Path", path, "1");
+ tracker_exec_proc (db_con, "SetMetadata", 5, service, str_file_id, "File.Format", mime, "1");
}
g_free (mime);
@@ -202,17 +202,17 @@ tracker_dbus_method_files_create (DBusRec *rec)
path = tracker_get_vfs_path (uri);
}
- tracker_exec_proc (db_con->db, "CreateService", 8, path, name, service, str_is_dir, "0", "0", "0", str_mtime);
+ tracker_exec_proc (db_con, "CreateService", 8, path, name, service, str_is_dir, "0", "0", "0", str_mtime);
long file_id = tracker_db_get_file_id (db_con, uri);
char *str_file_id = tracker_long_to_str (file_id);
if (file_id != -1) {
- tracker_exec_proc (db_con->db, "SetMetadata", 5, service, str_file_id, "File.Modified", str_mtime, "1");
- tracker_exec_proc (db_con->db, "SetMetadata", 5, service, str_file_id, "File.Size", str_size, "1");
- tracker_exec_proc (db_con->db, "SetMetadata", 5, service, str_file_id, "File.Name", name, "1");
- tracker_exec_proc (db_con->db, "SetMetadata", 5, service, str_file_id, "File.Path", path, "1");
- tracker_exec_proc (db_con->db, "SetMetadata", 5, service, str_file_id, "File.Format", mime, "1");
+ tracker_exec_proc (db_con, "SetMetadata", 5, service, str_file_id, "File.Modified", str_mtime, "1");
+ tracker_exec_proc (db_con, "SetMetadata", 5, service, str_file_id, "File.Size", str_size, "1");
+ tracker_exec_proc (db_con, "SetMetadata", 5, service, str_file_id, "File.Name", name, "1");
+ tracker_exec_proc (db_con, "SetMetadata", 5, service, str_file_id, "File.Path", path, "1");
+ tracker_exec_proc (db_con, "SetMetadata", 5, service, str_file_id, "File.Format", mime, "1");
}
@@ -232,7 +232,7 @@ tracker_dbus_method_files_delete (DBusRec *rec)
{
DBConnection *db_con;
char *uri = NULL, *path, *name;
- MYSQL_ROW row = NULL;
+ char** row = NULL;
g_return_if_fail (rec && rec->user_data);
@@ -271,23 +271,23 @@ tracker_dbus_method_files_delete (DBusRec *rec)
char *str_file_id = tracker_long_to_str (file_id);
gboolean is_dir = FALSE;
- MYSQL_RES *res = tracker_exec_proc (db_con->db, "GetServiceID", 2, path, name);
+ char ***res = tracker_exec_proc (db_con, "GetServiceID", 2, path, name);
if (res) {
- row = mysql_fetch_row (res);
+ row = tracker_db_get_row (res, 0);
if (row && row[2] ) {
is_dir = (strcmp (row[2], "1") == 0);
}
- mysql_free_result (res);
+ tracker_db_free_result (res);
}
if (file_id != -1) {
if (is_dir) {
- tracker_exec_proc (db_con->db, "DeleteDirectory", 2, str_file_id, path);
+ tracker_exec_proc (db_con, "DeleteDirectory", 2, str_file_id, path);
} else {
- tracker_exec_proc (db_con->db, "DeleteFile", 1, str_file_id);
+ tracker_exec_proc (db_con, "DeleteFile", 1, str_file_id);
}
}
@@ -366,7 +366,7 @@ tracker_dbus_method_files_get_text_contents (DBusRec *rec)
{
DBConnection *db_con;
DBusMessage *reply;
- MYSQL_ROW row = NULL;
+ char** row = NULL;
char *uri, *path, *name;
const char *result;
int offset, max_length;
@@ -406,7 +406,7 @@ tracker_dbus_method_files_get_text_contents (DBusRec *rec)
char *str_offset = tracker_int_to_str (offset);
char *str_max_length = tracker_int_to_str (max_length);
- MYSQL_RES *res = tracker_exec_proc (db_con->db, "GetFileContents", 4, path, name, str_offset, str_max_length);
+ char ***res = tracker_exec_proc (db_con, "GetFileContents", 4, path, name, str_offset, str_max_length);
g_free (str_offset);
g_free (str_max_length);
@@ -414,7 +414,7 @@ tracker_dbus_method_files_get_text_contents (DBusRec *rec)
g_free (name);
if (res) {
- row = mysql_fetch_row (res);
+ row = tracker_db_get_row (res, 0);
if (row && row[0]) {
@@ -429,7 +429,7 @@ tracker_dbus_method_files_get_text_contents (DBusRec *rec)
dbus_message_unref (reply);
}
- mysql_free_result (res);
+ tracker_db_free_result (res);
}
@@ -445,7 +445,7 @@ tracker_dbus_method_files_search_text_contents (DBusRec *rec)
{
DBConnection *db_con;
DBusMessage *reply;
- MYSQL_ROW row = NULL;
+ char** row = NULL;
char *uri, *path, *name, *text;
const char *result;
int max_length;
@@ -485,14 +485,14 @@ tracker_dbus_method_files_search_text_contents (DBusRec *rec)
char *str_max_length = tracker_int_to_str (max_length);
- MYSQL_RES *res = tracker_exec_proc (db_con->db, "SearchFileContents", 4, path, name, text, str_max_length);
+ char ***res = tracker_exec_proc (db_con, "SearchFileContents", 4, path, name, text, str_max_length);
g_free (str_max_length);
g_free (path);
g_free (name);
if (res) {
- row = mysql_fetch_row (res);
+ row = tracker_db_get_row (res, 0);
if (row && row[0]) {
@@ -507,7 +507,7 @@ tracker_dbus_method_files_search_text_contents (DBusRec *rec)
dbus_message_unref (reply);
}
- mysql_free_result (res);
+ tracker_db_free_result (res);
}
@@ -523,7 +523,7 @@ tracker_dbus_method_files_get_mtime (DBusRec *rec)
{
DBConnection *db_con;
DBusMessage *reply;
- MYSQL_ROW row = NULL;
+ char** row = NULL;
char *uri, *path, *name;
int result;
@@ -559,14 +559,14 @@ tracker_dbus_method_files_get_mtime (DBusRec *rec)
- MYSQL_RES *res = tracker_exec_proc (db_con->db, "GetFileMTime", 2, path, name);
+ char ***res = tracker_exec_proc (db_con, "GetFileMTime", 2, path, name);
g_free (path);
g_free (name);
if (res) {
- row = mysql_fetch_row (res);
+ row = tracker_db_get_row (res, 0);
if (row && row[0]) {
@@ -581,7 +581,7 @@ tracker_dbus_method_files_get_mtime (DBusRec *rec)
dbus_message_unref (reply);
}
- mysql_free_result (res);
+ tracker_db_free_result (res);
}
@@ -638,7 +638,7 @@ tracker_dbus_method_files_get_by_service_type (DBusRec *rec)
char *str_limit = tracker_int_to_str (limit);
char *str_offset = tracker_int_to_str (offset);
- MYSQL_RES *res = tracker_exec_proc (db_con->db, "GetFilesByServiceType", 3, service, str_offset, str_limit);
+ char ***res = tracker_exec_proc (db_con, "GetFilesByServiceType", 3, service, str_offset, str_limit);
g_free (str_offset);
g_free (str_limit);
@@ -646,7 +646,7 @@ tracker_dbus_method_files_get_by_service_type (DBusRec *rec)
if (res) {
array = tracker_get_query_result_as_array (res, &row_count);
- mysql_free_result (res);
+ tracker_db_free_result (res);
}
@@ -723,7 +723,7 @@ tracker_dbus_method_files_get_by_mime_type (DBusRec *rec)
tracker_log ("Executing GetFilesByMimeType with param %s", str_mimes);
- MYSQL_RES *res = tracker_exec_proc (db_con->db, "GetFilesByMimeType", 3, str_mimes, str_offset, str_limit);
+ char ***res = tracker_exec_proc (db_con, "GetFilesByMimeType", 3, str_mimes, str_offset, str_limit);
g_free (str_mimes);
g_free (str_limit);
@@ -731,7 +731,7 @@ tracker_dbus_method_files_get_by_mime_type (DBusRec *rec)
if (res) {
array = tracker_get_query_result_as_array (res, &row_count);
- mysql_free_result (res);
+ tracker_db_free_result (res);
}
@@ -798,7 +798,7 @@ tracker_dbus_method_files_get_by_mime_type_vfs (DBusRec *rec)
char *str_limit = tracker_int_to_str (limit);
char *str_offset = tracker_int_to_str (offset);
- MYSQL_RES *res = tracker_exec_proc (db_con->db, "GetVFSFilesByMimeType", 3, str_mimes, str_offset, str_limit);
+ char ***res = tracker_exec_proc (db_con, "GetVFSFilesByMimeType", 3, str_mimes, str_offset, str_limit);
g_free (str_mimes);
g_free (str_offset);
@@ -806,7 +806,7 @@ tracker_dbus_method_files_get_by_mime_type_vfs (DBusRec *rec)
if (res) {
array = tracker_get_query_result_as_array (res, &row_count);
- mysql_free_result (res);
+ tracker_db_free_result (res);
}
@@ -837,7 +837,7 @@ tracker_dbus_method_files_get_metadata_for_files_in_folder (DBusRec *rec)
int i, id, n, table_count, query_id;
char **array, *folder, *field, *str, *mid;
GString *sql;
- MYSQL_RES *res;
+ char ***res;
g_return_if_fail (rec && rec->user_data);
@@ -946,7 +946,7 @@ tracker_dbus_method_files_get_metadata_for_files_in_folder (DBusRec *rec)
str = g_string_free (sql, FALSE);
tracker_log (str);
- res = tracker_exec_sql (db_con->db, str);
+ res = tracker_exec_sql (db_con, str);
g_free (str);
@@ -966,7 +966,7 @@ tracker_dbus_method_files_get_metadata_for_files_in_folder (DBusRec *rec)
if (res) {
tracker_add_query_result_to_dict (res, &iter_dict);
- mysql_free_result (res);
+ tracker_db_free_result (res);
}
@@ -992,8 +992,8 @@ tracker_dbus_method_files_search_by_text_mime (DBusRec *rec)
char *str, *mime_list, *search_term = NULL;
GString *mimes = NULL;
gboolean use_boolean_search = TRUE;
- MYSQL_RES *res = NULL;
- MYSQL_ROW row;
+ char ***res = NULL;
+ char** row;
g_return_if_fail (rec && rec->user_data);
@@ -1022,7 +1022,7 @@ tracker_dbus_method_files_search_by_text_mime (DBusRec *rec)
/* check search string for embedded special chars like hyphens and format appropriately */
search_term = tracker_format_search_terms (str, &use_boolean_search);
- res = tracker_exec_proc (db_con->db, "SearchTextMime", 2, search_term , mime_list);
+ res = tracker_exec_proc (db_con, "SearchTextMime", 2, search_term , mime_list);
g_free (search_term);
@@ -1030,7 +1030,7 @@ tracker_dbus_method_files_search_by_text_mime (DBusRec *rec)
if (res) {
- row_count = mysql_num_rows (res);
+ row_count = tracker_get_row_count (res);
if (row_count > 0) {
@@ -1038,7 +1038,7 @@ tracker_dbus_method_files_search_by_text_mime (DBusRec *rec)
i = 0;
- while ((row = mysql_fetch_row (res))) {
+ while ((row = tracker_db_get_row (res, i))) {
if (row && row[0] && row[1]) {
array[i] = g_strconcat (row[0], "/", row[1], NULL);
@@ -1050,7 +1050,7 @@ tracker_dbus_method_files_search_by_text_mime (DBusRec *rec)
tracker_log ("result set is empty");
}
- mysql_free_result (res);
+ tracker_db_free_result (res);
} else {
array = g_new (char *, 1);
@@ -1081,8 +1081,8 @@ tracker_dbus_method_files_search_by_text_location (DBusRec *rec)
int row_count = 0, i = 0;
char *str, *location, *search_term = NULL;
gboolean use_boolean_search = TRUE;
- MYSQL_RES *res = NULL;
- MYSQL_ROW row;
+ char ***res = NULL;
+ char** row;
g_return_if_fail (rec && rec->user_data);
@@ -1092,14 +1092,14 @@ tracker_dbus_method_files_search_by_text_location (DBusRec *rec)
search_term = tracker_format_search_terms (str, &use_boolean_search);
- res = tracker_exec_proc (db_con->db, "SearchTextLocation", 2, search_term , location);
+ res = tracker_exec_proc (db_con, "SearchTextLocation", 2, search_term , location);
g_free (search_term);
if (res) {
- row_count = mysql_num_rows (res);
+ row_count = tracker_get_row_count (res);
if (row_count > 0) {
@@ -1107,7 +1107,7 @@ tracker_dbus_method_files_search_by_text_location (DBusRec *rec)
i = 0;
- while ((row = mysql_fetch_row (res))) {
+ while ((row = tracker_db_get_row (res, i))) {
if (row && row[0] && row[1]) {
array[i] = g_strconcat (row[0], "/", row[1], NULL);
@@ -1119,7 +1119,7 @@ tracker_dbus_method_files_search_by_text_location (DBusRec *rec)
tracker_log ("result set is empty");
}
- mysql_free_result (res);
+ tracker_db_free_result (res);
} else {
array = g_new (char *, 1);
@@ -1151,8 +1151,8 @@ tracker_dbus_method_files_search_by_text_mime_location (DBusRec *rec)
char *str, *mime_list, *location, *search_term = NULL;
GString *mimes = NULL;
gboolean use_boolean_search = TRUE;
- MYSQL_RES *res = NULL;
- MYSQL_ROW row;
+ char ***res = NULL;
+ char** row;
g_return_if_fail (rec && rec->user_data);
@@ -1181,7 +1181,7 @@ tracker_dbus_method_files_search_by_text_mime_location (DBusRec *rec)
//g_print ("search term is before %s and after %s\n\n", str, search_term);
- res = tracker_exec_proc (db_con->db, "SearchTextLocation", 2, search_term , mime_list, location);
+ res = tracker_exec_proc (db_con, "SearchTextLocation", 2, search_term , mime_list, location);
g_free (search_term);
@@ -1189,7 +1189,7 @@ tracker_dbus_method_files_search_by_text_mime_location (DBusRec *rec)
if (res) {
- row_count = mysql_num_rows (res);
+ row_count = tracker_get_row_count (res);
if (row_count > 0) {
@@ -1197,7 +1197,7 @@ tracker_dbus_method_files_search_by_text_mime_location (DBusRec *rec)
i = 0;
- while ((row = mysql_fetch_row (res))) {
+ while ((row = tracker_db_get_row (res, i))) {
if (row && row[0] && row[1]) {
array[i] = g_strconcat (row[0], "/", row[1], NULL);
@@ -1209,7 +1209,7 @@ tracker_dbus_method_files_search_by_text_mime_location (DBusRec *rec)
tracker_log ("result set is empty");
}
- mysql_free_result (res);
+ tracker_db_free_result (res);
} else {
array = g_new (char *, 1);
diff --git a/src/trackerd/tracker-dbus-keywords.c b/src/trackerd/tracker-dbus-keywords.c
index e81e73e3e..c40a925c3 100644
--- a/src/trackerd/tracker-dbus-keywords.c
+++ b/src/trackerd/tracker-dbus-keywords.c
@@ -39,11 +39,11 @@ update_keywords_metadata (DBConnection *db_con, const char *path, const char *n
return;
}
- MYSQL_RES *res = tracker_exec_proc (db_con->db, "GetKeywords", 2, path, name);
+ char ***res = tracker_exec_proc (db_con, "GetKeywords", 2, path, name);
if (res) {
- MYSQL_ROW row;
+ char** row;
GString *words = g_string_new (" ");
@@ -51,7 +51,7 @@ update_keywords_metadata (DBConnection *db_con, const char *path, const char *n
- while ((row = mysql_fetch_row (res))) {
+ while ((row = tracker_db_get_row (res, i))) {
if (row[0]) {
@@ -66,7 +66,7 @@ update_keywords_metadata (DBConnection *db_con, const char *path, const char *n
}
- mysql_free_result (res);
+ tracker_db_free_result (res);
char *keywords = g_string_free (words, FALSE);
@@ -114,7 +114,7 @@ tracker_dbus_method_keywords_get_list (DBusRec *rec)
}
- MYSQL_RES *res = tracker_exec_proc (db_con->db, "GetKeywordList", 1, service);
+ char ***res = tracker_exec_proc (db_con, "GetKeywordList", 1, service);
reply = dbus_message_new_method_return (rec->message);
@@ -132,7 +132,7 @@ tracker_dbus_method_keywords_get_list (DBusRec *rec)
if (res) {
tracker_add_query_result_to_dict (res, &iter_dict);
- mysql_free_result (res);
+ tracker_db_free_result (res);
}
@@ -200,14 +200,14 @@ tracker_dbus_method_keywords_get (DBusRec *rec)
path = tracker_get_vfs_path (uri);
}
- MYSQL_RES *res = tracker_exec_proc (db_con->db, "GetKeywords", 2, path, name);
+ char ***res = tracker_exec_proc (db_con, "GetKeywords", 2, path, name);
g_free (name);
g_free (path);
if (res) {
array = tracker_get_query_result_as_array (res, &row_count);
- mysql_free_result (res);
+ tracker_db_free_result (res);
}
@@ -288,7 +288,7 @@ tracker_dbus_method_keywords_add (DBusRec *rec)
for (i = 0; i < row_count; i++) {
if (array[i]) {
- tracker_exec_proc (db_con->db, "AddKeyword", 3, path, name, array[i]);
+ tracker_exec_proc (db_con, "AddKeyword", 3, path, name, array[i]);
}
}
}
@@ -367,7 +367,7 @@ tracker_dbus_method_keywords_remove (DBusRec *rec)
for (i = 0; i < row_count; i++) {
if (array[i]) {
- tracker_exec_proc (db_con->db, "RemoveKeyword", 3, path, name, array[i]);
+ tracker_exec_proc (db_con, "RemoveKeyword", 3, path, name, array[i]);
}
}
}
@@ -438,7 +438,7 @@ tracker_dbus_method_keywords_remove_all (DBusRec *rec)
path = tracker_get_vfs_path (uri);
}
- tracker_exec_proc (db_con->db, "RemoveAllKeywords", 2, path, name);
+ tracker_exec_proc (db_con, "RemoveAllKeywords", 2, path, name);
update_keywords_metadata (db_con, path, name);
@@ -462,7 +462,7 @@ tracker_dbus_method_keywords_search (DBusRec *rec)
char *service;
char **array = NULL;
int row_count = 0, limit, query_id, offset;
- MYSQL_RES *res;
+ char ***res;
g_return_if_fail (rec && rec->user_data);
@@ -525,7 +525,7 @@ tracker_dbus_method_keywords_search (DBusRec *rec)
char *query = g_strconcat (query_sel, query_where, NULL);
- res = tracker_exec_sql (db_con->db, query);
+ res = tracker_exec_sql (db_con, query);
g_free (query_sel);
g_free (query_where);
@@ -535,7 +535,7 @@ tracker_dbus_method_keywords_search (DBusRec *rec)
if (res) {
array = tracker_get_query_result_as_array (res, &row_count);
- mysql_free_result (res);
+ tracker_db_free_result (res);
}
diff --git a/src/trackerd/tracker-dbus-metadata.c b/src/trackerd/tracker-dbus-metadata.c
index 782f4f56d..93146e22a 100644
--- a/src/trackerd/tracker-dbus-metadata.c
+++ b/src/trackerd/tracker-dbus-metadata.c
@@ -127,8 +127,8 @@ tracker_dbus_method_metadata_get (DBusRec *rec)
int i, key_count, table_count, row_count = 0;
char **keys = NULL, **array, *uri, *id, *field, *str, *mid, *service;
GString *sql;
- MYSQL_RES *res;
- MYSQL_ROW row = NULL;
+ char ***res;
+ char** row = NULL;
char **date_array;
g_return_if_fail (rec && rec->user_data);
@@ -283,7 +283,7 @@ tracker_dbus_method_metadata_get (DBusRec *rec)
str = g_string_free (sql, FALSE);
tracker_log (str);
- res = tracker_exec_sql (db_con->db, str);
+ res = tracker_exec_sql (db_con, str);
g_free (str);
@@ -296,7 +296,7 @@ tracker_dbus_method_metadata_get (DBusRec *rec)
if (res) {
- row_count = mysql_num_rows (res);
+ row_count = tracker_get_row_count (res);
i = 0;
@@ -304,7 +304,7 @@ tracker_dbus_method_metadata_get (DBusRec *rec)
array = g_new (char *, key_count);
- row = mysql_fetch_row (res);
+ row = tracker_db_get_row (res, 0);
for (i = 0; i < key_count; i++) {
@@ -328,7 +328,7 @@ tracker_dbus_method_metadata_get (DBusRec *rec)
array[0] = NULL;
}
- mysql_free_result (res);
+ tracker_db_free_result (res);
} else {
array = g_new (char *, 1);
@@ -361,7 +361,7 @@ tracker_dbus_method_metadata_register_type (DBusRec *rec)
DBusMessage *reply;
char *meta, *type_id;
char *type;
- int i;
+
g_return_if_fail (rec && rec->user_data);
@@ -389,7 +389,7 @@ tracker_dbus_method_metadata_register_type (DBusRec *rec)
return;
}
- tracker_exec_proc (db_con->db, "InsertMetadataType", 4, meta, type_id, "0", "1");
+ tracker_exec_proc (db_con, "InsertMetadataType", 4, meta, type_id, "0", "1");
reply = dbus_message_new_method_return (rec->message);
@@ -407,7 +407,7 @@ tracker_dbus_method_metadata_get_type_details (DBusRec *rec)
{
DBConnection *db_con;
DBusMessage *reply;
- MYSQL_ROW row = NULL;
+ char** row = NULL;
char *meta, *data_type = NULL;
gboolean is_embedded = FALSE, is_writable = FALSE;
@@ -429,10 +429,10 @@ tracker_dbus_method_metadata_get_type_details (DBusRec *rec)
if (meta) {
- MYSQL_RES *res = tracker_exec_proc (db_con->db, "GetMetadataTypeInfo", 1, meta);
+ char ***res = tracker_exec_proc (db_con, "GetMetadataTypeInfo", 1, meta);
if (res) {
- row = mysql_fetch_row (res);
+ row = tracker_db_get_row (res, 0);
if (row && row[1] && row[2] && row[3]) {
@@ -448,7 +448,7 @@ tracker_dbus_method_metadata_get_type_details (DBusRec *rec)
is_writable = (strcmp (row[3], "1") == 0);
}
- mysql_free_result (res);
+ tracker_db_free_result (res);
}
@@ -494,11 +494,11 @@ tracker_dbus_method_metadata_get_registered_types (DBusRec *rec)
if (class) {
- MYSQL_RES *res = tracker_exec_proc (db_con->db, "SelectMetadataTypes", 2, class, "0");
+ char ***res = tracker_exec_proc (db_con, "SelectMetadataTypes", 2, class, "0");
if (res) {
array = tracker_get_query_result_as_array (res, &row_count);
- mysql_free_result (res);
+ tracker_db_free_result (res);
}
}
@@ -548,11 +548,11 @@ tracker_dbus_method_metadata_get_writeable_types (DBusRec *rec)
if (class) {
- MYSQL_RES *res = tracker_exec_proc (db_con->db, "SelectMetadataTypes", 2, class, "1");
+ char ***res = tracker_exec_proc (db_con, "SelectMetadataTypes", 2, class, "1");
if (res) {
array = tracker_get_query_result_as_array (res, &row_count);
- mysql_free_result (res);
+ tracker_db_free_result (res);
}
}
@@ -595,11 +595,11 @@ tracker_dbus_method_metadata_get_registered_classes (DBusRec *rec)
db_con = rec->user_data;
- MYSQL_RES *res = tracker_exec_proc (db_con->db, "SelectMetadataClasses", 0);
+ char ***res = tracker_exec_proc (db_con, "SelectMetadataClasses", 0);
if (res) {
array = tracker_get_query_result_as_array (res, &row_count);
- mysql_free_result (res);
+ tracker_db_free_result (res);
}
diff --git a/src/trackerd/tracker-dbus-methods.c b/src/trackerd/tracker-dbus-methods.c
index f8d72734d..86425ba97 100644
--- a/src/trackerd/tracker-dbus-methods.c
+++ b/src/trackerd/tracker-dbus-methods.c
@@ -63,23 +63,23 @@ tracker_get_metadata (DBConnection *db_con, const char *service, const char *id,
int row_count = 0;
char *value;
- MYSQL_RES *res = NULL;
- MYSQL_ROW row;
+ char ***res = NULL;
+ char** row;
g_return_val_if_fail (db_con && id && (strlen (id) > 0), NULL);
value = g_strdup (" ");
- res = tracker_exec_proc (db_con->db, "GetMetadata", 3, service, id, key);
+ res = tracker_exec_proc (db_con, "GetMetadata", 3, service, id, key);
if (res) {
- row_count = mysql_num_rows (res);
+ row_count = tracker_get_row_count (res);
if (row_count > 0) {
- row = mysql_fetch_row (res);
+ row = tracker_db_get_row (res, 0);
if (row && row[0]) {
g_free (value);
@@ -90,7 +90,7 @@ tracker_get_metadata (DBConnection *db_con, const char *service, const char *id,
tracker_log ("result set is empty");
}
- mysql_free_result (res);
+ tracker_db_free_result (res);
}
tracker_log ("metadata %s is %s", key, value);
@@ -110,7 +110,7 @@ tracker_set_metadata (DBConnection *db_con, const char *service, const char *id,
str_write = "0";
}
- tracker_exec_proc (db_con->db, "SetMetadata", 5, service, id, key, value, str_write);
+ tracker_exec_proc (db_con, "SetMetadata", 5, service, id, key, value, str_write);
}
@@ -161,7 +161,7 @@ tracker_get_file_id (DBConnection *db_con, const char *uri, gboolean create_reco
char *str_mtime = g_strdup_printf ("%ld", finfo.st_mtime);
- tracker_exec_proc (db_con->db, "CreateService", 8, path, name, service_name, is_dir, is_link, "0", "0", str_mtime);
+ tracker_exec_proc (db_con, "CreateService", 8, path, name, service_name, is_dir, is_link, "0", "0", str_mtime);
g_free (service_name);
@@ -179,7 +179,7 @@ tracker_get_file_id (DBConnection *db_con, const char *uri, gboolean create_reco
name = tracker_get_vfs_name (uri);
path = tracker_get_vfs_path (uri);
- tracker_exec_proc (db_con->db, "CreateService", 8, path, name, "VFSFiles", "0", "0", "0", "0", "unknown");
+ tracker_exec_proc (db_con, "CreateService", 8, path, name, "VFSFiles", "0", "0", "0", "0", "unknown");
result = tracker_db_get_file_id (db_con, uri);
}
@@ -198,22 +198,26 @@ tracker_get_file_id (DBConnection *db_con, const char *uri, gboolean create_reco
void
-tracker_add_query_result_to_dict (MYSQL_RES *res, DBusMessageIter *iter_dict)
+tracker_add_query_result_to_dict (char ***res, DBusMessageIter *iter_dict)
{
char *key, *value;
int i, row_count, field_count;
- MYSQL_ROW row = NULL;
+ char** row = NULL;
g_return_if_fail (res);
- row_count = mysql_num_rows (res);
+ row_count = tracker_get_row_count (res);
if (row_count > 0) {
- field_count = mysql_num_fields (res);
+ field_count = tracker_get_field_count (res);
- while ((row = mysql_fetch_row (res)) != NULL) {
+ int k = 0;
+
+ while ((row = tracker_db_get_row (res, k)) != NULL) {
+
+ k++;
if (row[0]) {
key = row[0];
@@ -278,14 +282,14 @@ tracker_add_query_result_to_dict (MYSQL_RES *res, DBusMessageIter *iter_dict)
char **
-tracker_get_query_result_as_array (MYSQL_RES *res, int *row_count)
+tracker_get_query_result_as_array (char ***res, int *row_count)
{
char **array;
int i;
- MYSQL_ROW row = NULL;
+ char** row = NULL;
- *row_count = mysql_num_rows (res);
+ *row_count = tracker_get_row_count (res);
if (*row_count > 0) {
@@ -293,7 +297,7 @@ tracker_get_query_result_as_array (MYSQL_RES *res, int *row_count)
i = 0;
- while ((row = mysql_fetch_row (res))) {
+ while ((row = tracker_db_get_row (res, i))) {
if (row && row[0]) {
array[i] = g_strdup (row[0]);
@@ -331,7 +335,7 @@ tracker_dbus_method_get_services (DBusRec *rec)
DBusMessageIter iter;
DBusMessageIter iter_dict;
gboolean main_only;
- MYSQL_RES *res = NULL;
+ char ***res = NULL;
g_return_if_fail (rec && rec->user_data);
@@ -342,9 +346,9 @@ tracker_dbus_method_get_services (DBusRec *rec)
dbus_message_get_args (rec->message, NULL, DBUS_TYPE_BOOLEAN, &main_only, DBUS_TYPE_INVALID);
if (main_only) {
- res = tracker_exec_proc (db_con->db, "GetServices", 1, "1" );
+ res = tracker_exec_proc (db_con, "GetServices", 1, "1" );
} else {
- res = tracker_exec_proc (db_con->db, "GetServices", 1, "0");
+ res = tracker_exec_proc (db_con, "GetServices", 1, "0");
}
@@ -362,7 +366,7 @@ tracker_dbus_method_get_services (DBusRec *rec)
if (res) {
tracker_add_query_result_to_dict (res, &iter_dict);
- mysql_free_result (res);
+ tracker_db_free_result (res);
}
dbus_message_iter_close_container (&iter, &iter_dict);
@@ -379,7 +383,7 @@ tracker_dbus_method_get_stats (DBusRec *rec)
DBusMessage *reply;
DBusMessageIter iter;
DBusMessageIter iter_dict;
- MYSQL_RES *res = NULL;
+ char ***res = NULL;
g_return_if_fail (rec && rec->user_data);
@@ -387,7 +391,7 @@ tracker_dbus_method_get_stats (DBusRec *rec)
tracker_log ("Executing GetStats Dbus Call");
- res = tracker_exec_proc (db_con->db, "GetStats", 0);
+ res = tracker_exec_proc (db_con, "GetStats", 0);
reply = dbus_message_new_method_return (rec->message);
@@ -405,7 +409,7 @@ tracker_dbus_method_get_stats (DBusRec *rec)
if (res) {
tracker_add_query_result_to_dict (res, &iter_dict);
- mysql_free_result (res);
+ tracker_db_free_result (res);
}
diff --git a/src/trackerd/tracker-dbus-methods.h b/src/trackerd/tracker-dbus-methods.h
index 9ffa401b4..9c31437df 100644
--- a/src/trackerd/tracker-dbus-methods.h
+++ b/src/trackerd/tracker-dbus-methods.h
@@ -17,15 +17,10 @@
* Boston, MA 02111-1307, USA.
*/
-#include <mysql/mysql.h>
#include "tracker-dbus.h"
#include "tracker-db.h"
-
-
-
-
void tracker_set_error (DBusRec *rec,
const char *fmt,
...);
@@ -36,12 +31,12 @@ void tracker_set_metadata (DBConnection *db_con, const char *service, const ch
int tracker_get_file_id (DBConnection *db_con, const char *uri, gboolean create_record);
-void tracker_add_query_result_to_dict (MYSQL_RES *res, DBusMessageIter *iter_dict);
+void tracker_add_query_result_to_dict (char ***res, DBusMessageIter *iter_dict);
char * tracker_format_search_terms (const char *str, gboolean *do_bool_search);
-char ** tracker_get_query_result_as_array (MYSQL_RES *res, int *row_count);
+char ** tracker_get_query_result_as_array (char ***res, int *row_count);
void tracker_dbus_method_get_stats (DBusRec *rec);
void tracker_dbus_method_get_services (DBusRec *rec);
diff --git a/src/trackerd/tracker-dbus-search.c b/src/trackerd/tracker-dbus-search.c
index 437514b21..b71084550 100644
--- a/src/trackerd/tracker-dbus-search.c
+++ b/src/trackerd/tracker-dbus-search.c
@@ -35,8 +35,8 @@ tracker_dbus_method_search_text (DBusRec *rec)
int limit, query_id, offset;
char *str = NULL, *service = NULL, *search_term = NULL;
gboolean sort_results = FALSE, use_boolean_search = FALSE;
- MYSQL_RES *res = NULL;
- MYSQL_ROW row;
+ char ***res = NULL;
+ char** row;
g_return_if_fail (rec && rec->user_data);
@@ -97,7 +97,7 @@ tracker_dbus_method_search_text (DBusRec *rec)
tracker_log ("Executing search with params %s, %s. %s, %s, %s", service, search_term, str_limit, str_sort, str_bool );
- res = tracker_exec_proc (db_con->db, "SearchText", 6, service, search_term, str_offset, str_limit, str_sort, str_bool);
+ res = tracker_exec_proc (db_con, "SearchText", 6, service, search_term, str_offset, str_limit, str_sort, str_bool);
g_free (search_term);
g_free (str_limit);
@@ -107,7 +107,7 @@ tracker_dbus_method_search_text (DBusRec *rec)
if (res) {
- row_count = mysql_num_rows (res);
+ row_count = tracker_get_row_count (res);
if (row_count > 0) {
@@ -115,7 +115,7 @@ tracker_dbus_method_search_text (DBusRec *rec)
i = 0;
- while ((row = mysql_fetch_row (res))) {
+ while ((row = tracker_db_get_row (res, i))) {
if (row && row[0] && row[1]) {
array[i] = g_strconcat (row[0], "/", row[1], NULL);
@@ -128,7 +128,7 @@ tracker_dbus_method_search_text (DBusRec *rec)
}
- mysql_free_result (res);
+ tracker_db_free_result (res);
} else {
array = g_new (char *, 1);
@@ -200,7 +200,7 @@ tracker_dbus_method_search_files_by_text (DBusRec *rec)
gboolean na;
char *search_term = tracker_format_search_terms (text, &na);
- MYSQL_RES *res = tracker_exec_proc (db_con->db, "SearchFilesText", 4, search_term, str_offset, str_limit, str_sort);
+ char ***res = tracker_exec_proc (db_con, "SearchFilesText", 4, search_term, str_offset, str_limit, str_sort);
g_free (search_term);
g_free (str_limit);
@@ -223,7 +223,7 @@ tracker_dbus_method_search_files_by_text (DBusRec *rec)
tracker_add_query_result_to_dict (res, &iter_dict);
- mysql_free_result (res);
+ tracker_db_free_result (res);
} else {
return;
@@ -283,7 +283,7 @@ tracker_dbus_method_search_metadata (DBusRec *rec)
gboolean na;
char *search_term = tracker_format_search_terms (text, &na);
- MYSQL_RES *res = tracker_exec_proc (db_con->db, "SearchMetaData", 5, service, field, search_term, str_offset, str_limit);
+ char ***res = tracker_exec_proc (db_con, "SearchMetaData", 5, service, field, search_term, str_offset, str_limit);
g_free (search_term);
g_free (str_limit);
@@ -292,7 +292,7 @@ tracker_dbus_method_search_metadata (DBusRec *rec)
if (res) {
array = tracker_get_query_result_as_array (res, &row_count);
- mysql_free_result (res);
+ tracker_db_free_result (res);
}
@@ -373,7 +373,7 @@ tracker_dbus_method_search_matching_fields (DBusRec *rec)
gboolean na;
char *search_term = tracker_format_search_terms (text, &na);
- MYSQL_RES *res = tracker_exec_proc (db_con->db, "SearchMatchingMetaData", 4, service, path, name, search_term);
+ char ***res = tracker_exec_proc (db_con, "SearchMatchingMetaData", 4, service, path, name, search_term);
g_free (search_term);
g_free (name);
@@ -397,7 +397,7 @@ tracker_dbus_method_search_matching_fields (DBusRec *rec)
tracker_add_query_result_to_dict (res, &iter_dict);
- mysql_free_result (res);
+ tracker_db_free_result (res);
dbus_message_iter_close_container (&iter, &iter_dict);
dbus_connection_send (rec->connection, reply, NULL);
@@ -418,7 +418,7 @@ tracker_dbus_method_search_query (DBusRec *rec)
DBusMessageIter iter_dict;
char **fields = NULL;
int limit, row_count, query_id, offset;
- MYSQL_RES *res = NULL;
+ char ***res = NULL;
char *str, *query, *search_text, *service;
gboolean sort_results = FALSE;
GError *error;
@@ -482,9 +482,28 @@ tracker_dbus_method_search_query (DBusRec *rec)
str = tracker_rdf_query_to_sql (db_con, query, service, fields, row_count, search_term, sort_results, offset, limit , NULL);
+ if (! str) {
+ g_free (search_term);
+ reply = dbus_message_new_method_return (rec->message);
+ dbus_message_iter_init_append (reply, &iter);
+
+ dbus_message_iter_open_container (&iter,
+ DBUS_TYPE_ARRAY,
+ DBUS_DICT_ENTRY_BEGIN_CHAR_AS_STRING
+ DBUS_TYPE_STRING_AS_STRING
+ DBUS_TYPE_VARIANT_AS_STRING
+ DBUS_DICT_ENTRY_END_CHAR_AS_STRING,
+ &iter_dict);
+ dbus_message_iter_close_container (&iter, &iter_dict);
+
+ dbus_connection_send (rec->connection, reply, NULL);
+ dbus_message_unref (reply);
+ g_return_if_fail (str); /* show us a warning */
+ }
+
g_free (search_term);
tracker_log ("translated rdf query is %s\n", str);
- res = tracker_exec_sql (db_con->db, str);
+ res = tracker_exec_sql (db_con, str);
g_free (str);
} else {
@@ -505,7 +524,7 @@ tracker_dbus_method_search_query (DBusRec *rec)
if (res) {
tracker_add_query_result_to_dict (res, &iter_dict);
- mysql_free_result (res);
+ tracker_db_free_result (res);
}
dbus_message_iter_close_container (&iter, &iter_dict);
diff --git a/src/trackerd/tracker-dbus.c b/src/trackerd/tracker-dbus.c
index 069d108b8..2ef877ef0 100644
--- a/src/trackerd/tracker-dbus.c
+++ b/src/trackerd/tracker-dbus.c
@@ -20,7 +20,7 @@
#include "tracker-dbus.h"
#include "tracker-utils.h"
-extern GAsyncQueue *user_request_queue;
+extern Tracker *tracker;
static void unregistered_func (DBusConnection *conn, gpointer data);
@@ -110,30 +110,31 @@ message_func (DBusConnection *conn,
rec->connection = conn;
rec->message = message;
+ if (!tracker->is_running) return;
+
if (dbus_message_is_method_call (message, TRACKER_INTERFACE, TRACKER_METHOD_PING)) {
/* ref the message here because we are going to reply to it in a different thread */
dbus_message_ref (message);
rec->action = DBUS_ACTION_PING;
- g_async_queue_push (user_request_queue, rec);
} else if (dbus_message_is_method_call (message, TRACKER_INTERFACE, TRACKER_METHOD_GET_STATS)) {
dbus_message_ref (message);
rec->action = DBUS_ACTION_GET_STATS;
- g_async_queue_push (user_request_queue, rec);
+
} else if (dbus_message_is_method_call (message, TRACKER_INTERFACE, TRACKER_METHOD_GET_SERVICES)) {
dbus_message_ref (message);
rec->action = DBUS_ACTION_GET_SERVICES;
- g_async_queue_push (user_request_queue, rec);
+
} else if (dbus_message_is_method_call (message, TRACKER_INTERFACE, TRACKER_METHOD_GET_VERSION)) {
dbus_message_ref (message);
rec->action = DBUS_ACTION_GET_VERSION;
- g_async_queue_push (user_request_queue, rec);
+
@@ -143,49 +144,49 @@ message_func (DBusConnection *conn,
dbus_message_ref (message);
rec->action = DBUS_ACTION_METADATA_GET;
- g_async_queue_push (user_request_queue, rec);
+
} else if (dbus_message_is_method_call (message, TRACKER_INTERFACE_METADATA, TRACKER_METHOD_METADATA_SET)) {
dbus_message_ref (message);
rec->action = DBUS_ACTION_METADATA_SET;
- g_async_queue_push (user_request_queue, rec);
+
} else if (dbus_message_is_method_call (message, TRACKER_INTERFACE_METADATA, TRACKER_METHOD_METADATA_REGISTER_TYPE)) {
dbus_message_ref (message);
rec->action = DBUS_ACTION_METADATA_REGISTER_TYPE;
- g_async_queue_push (user_request_queue, rec);
+
} else if (dbus_message_is_method_call (message, TRACKER_INTERFACE_METADATA, TRACKER_METHOD_METADATA_GET_TYPE_DETAILS )) {
dbus_message_ref (message);
rec->action = DBUS_ACTION_METADATA_GET_TYPE_DETAILS;
- g_async_queue_push (user_request_queue, rec);
+
} else if (dbus_message_is_method_call (message, TRACKER_INTERFACE_METADATA, TRACKER_METHOD_METADATA_GET_REGISTERED_TYPES)) {
dbus_message_ref (message);
rec->action = DBUS_ACTION_METADATA_GET_REGISTERED_TYPES;
- g_async_queue_push (user_request_queue, rec);
+
} else if (dbus_message_is_method_call (message, TRACKER_INTERFACE_METADATA, TRACKER_METHOD_METADATA_GET_WRITEABLE_TYPES)) {
dbus_message_ref (message);
rec->action = DBUS_ACTION_METADATA_GET_WRITEABLE_TYPES;
- g_async_queue_push (user_request_queue, rec);
+
} else if (dbus_message_is_method_call (message, TRACKER_INTERFACE_METADATA, TRACKER_METHOD_METADATA_GET_REGISTERED_CLASSES)) {
dbus_message_ref (message);
rec->action = DBUS_ACTION_METADATA_GET_REGISTERED_CLASSES;
- g_async_queue_push (user_request_queue, rec);
+
@@ -194,39 +195,39 @@ message_func (DBusConnection *conn,
dbus_message_ref (message);
rec->action = DBUS_ACTION_KEYWORDS_GET_LIST;
- g_async_queue_push (user_request_queue, rec);
+
} else if (dbus_message_is_method_call (message, TRACKER_INTERFACE_KEYWORDS, TRACKER_METHOD_KEYWORDS_GET)) {
dbus_message_ref (message);
rec->action = DBUS_ACTION_KEYWORDS_GET;
- g_async_queue_push (user_request_queue, rec);
+
} else if (dbus_message_is_method_call (message, TRACKER_INTERFACE_KEYWORDS, TRACKER_METHOD_KEYWORDS_ADD)) {
dbus_message_ref (message);
rec->action = DBUS_ACTION_KEYWORDS_ADD;
- g_async_queue_push (user_request_queue, rec);
+
} else if (dbus_message_is_method_call (message, TRACKER_INTERFACE_KEYWORDS, TRACKER_METHOD_KEYWORDS_REMOVE)) {
dbus_message_ref (message);
rec->action = DBUS_ACTION_KEYWORDS_REMOVE;
- g_async_queue_push (user_request_queue, rec);
+
} else if (dbus_message_is_method_call (message, TRACKER_INTERFACE_KEYWORDS, TRACKER_METHOD_KEYWORDS_REMOVE_ALL)) {
dbus_message_ref (message);
rec->action = DBUS_ACTION_KEYWORDS_REMOVE_ALL;
- g_async_queue_push (user_request_queue, rec);
+
} else if (dbus_message_is_method_call (message, TRACKER_INTERFACE_KEYWORDS, TRACKER_METHOD_KEYWORDS_SEARCH)) {
dbus_message_ref (message);
rec->action = DBUS_ACTION_KEYWORDS_SEARCH;
- g_async_queue_push (user_request_queue, rec);
+
@@ -236,7 +237,7 @@ message_func (DBusConnection *conn,
dbus_message_ref (message);
rec->action = DBUS_ACTION_SEARCH_TEXT;
- g_async_queue_push (user_request_queue, rec);
+
@@ -244,14 +245,14 @@ message_func (DBusConnection *conn,
dbus_message_ref (message);
rec->action = DBUS_ACTION_SEARCH_FILES_BY_TEXT;
- g_async_queue_push (user_request_queue, rec);
+
} else if (dbus_message_is_method_call (message, TRACKER_INTERFACE_SEARCH, TRACKER_METHOD_SEARCH_METADATA)) {
dbus_message_ref (message);
rec->action = DBUS_ACTION_SEARCH_METADATA;
- g_async_queue_push (user_request_queue, rec);
+
@@ -259,14 +260,14 @@ message_func (DBusConnection *conn,
dbus_message_ref (message);
rec->action = DBUS_ACTION_SEARCH_MATCHING_FIELDS;
- g_async_queue_push (user_request_queue, rec);
+
} else if (dbus_message_is_method_call (message, TRACKER_INTERFACE_SEARCH, TRACKER_METHOD_SEARCH_QUERY)) {
dbus_message_ref (message);
rec->action = DBUS_ACTION_SEARCH_QUERY;
- g_async_queue_push (user_request_queue, rec);
+
@@ -275,99 +276,99 @@ message_func (DBusConnection *conn,
dbus_message_ref (message);
rec->action = DBUS_ACTION_FILES_EXISTS;
- g_async_queue_push (user_request_queue, rec);
+
} else if (dbus_message_is_method_call (message, TRACKER_INTERFACE_FILES, TRACKER_METHOD_FILES_CREATE)) {
dbus_message_ref (message);
rec->action = DBUS_ACTION_FILES_CREATE;
- g_async_queue_push (user_request_queue, rec);
+
} else if (dbus_message_is_method_call (message, TRACKER_INTERFACE_FILES, TRACKER_METHOD_FILES_DELETE)) {
dbus_message_ref (message);
rec->action = DBUS_ACTION_FILES_DELETE;
- g_async_queue_push (user_request_queue, rec);
+
} else if (dbus_message_is_method_call (message, TRACKER_INTERFACE_FILES, TRACKER_METHOD_FILES_GET_SERVICE_TYPE)) {
dbus_message_ref (message);
rec->action = DBUS_ACTION_FILES_GET_SERVICE_TYPE;
- g_async_queue_push (user_request_queue, rec);
+
} else if (dbus_message_is_method_call (message, TRACKER_INTERFACE_FILES, TRACKER_METHOD_FILES_GET_TEXT_CONTENTS )) {
dbus_message_ref (message);
rec->action = DBUS_ACTION_FILES_GET_TEXT_CONTENTS ;
- g_async_queue_push (user_request_queue, rec);
+
} else if (dbus_message_is_method_call (message, TRACKER_INTERFACE_FILES, TRACKER_METHOD_FILES_SEARCH_TEXT_CONTENTS)) {
dbus_message_ref (message);
rec->action = DBUS_ACTION_FILES_SEARCH_TEXT_CONTENTS;
- g_async_queue_push (user_request_queue, rec);
+
} else if (dbus_message_is_method_call (message, TRACKER_INTERFACE_FILES, TRACKER_METHOD_FILES_GET_BY_SERVICE_TYPE)) {
dbus_message_ref (message);
rec->action = DBUS_ACTION_FILES_GET_BY_SERVICE_TYPE;
- g_async_queue_push (user_request_queue, rec);
+
} else if (dbus_message_is_method_call (message, TRACKER_INTERFACE_FILES, TRACKER_METHOD_FILES_GET_BY_MIME_TYPE)) {
dbus_message_ref (message);
rec->action = DBUS_ACTION_FILES_GET_BY_MIME_TYPE;
- g_async_queue_push (user_request_queue, rec);
+
} else if (dbus_message_is_method_call (message, TRACKER_INTERFACE_FILES, TRACKER_METHOD_FILES_GET_BY_MIME_TYPE_VFS)) {
dbus_message_ref (message);
rec->action = DBUS_ACTION_FILES_GET_BY_MIME_TYPE_VFS;
- g_async_queue_push (user_request_queue, rec);
+
} else if (dbus_message_is_method_call (message, TRACKER_INTERFACE_FILES, TRACKER_METHOD_FILES_REFRESH_METADATA)) {
dbus_message_ref (message);
rec->action = DBUS_ACTION_FILES_REFRESH_METADATA;
- g_async_queue_push (user_request_queue, rec);
+
} else if (dbus_message_is_method_call (message, TRACKER_INTERFACE_FILES, TRACKER_METHOD_FILES_GET_MTIME)) {
dbus_message_ref (message);
rec->action = DBUS_ACTION_FILES_GET_MTIME;
- g_async_queue_push (user_request_queue, rec);
+
} else if (dbus_message_is_method_call (message, TRACKER_INTERFACE_FILES, TRACKER_METHOD_FILES_GET_METADATA_FOLDER_FILES)) {
dbus_message_ref (message);
rec->action = DBUS_ACTION_FILES_GET_METADATA_FOLDER_FILES;
- g_async_queue_push (user_request_queue, rec);
+
} else if (dbus_message_is_method_call (message, TRACKER_INTERFACE_FILES, TRACKER_METHOD_FILES_SEARCH_BY_TEXT_MIME)) {
dbus_message_ref (message);
rec->action = DBUS_ACTION_FILES_SEARCH_BY_TEXT_MIME;
- g_async_queue_push (user_request_queue, rec);
+
} else if (dbus_message_is_method_call (message, TRACKER_INTERFACE_FILES, TRACKER_METHOD_FILES_SEARCH_BY_TEXT_MIME_LOCATION)) {
dbus_message_ref (message);
rec->action = DBUS_ACTION_FILES_SEARCH_BY_TEXT_MIME_LOCATION;
- g_async_queue_push (user_request_queue, rec);
+
} else if (dbus_message_is_method_call (message, TRACKER_INTERFACE_FILES, TRACKER_METHOD_FILES_SEARCH_BY_TEXT_LOCATION)) {
dbus_message_ref (message);
rec->action = DBUS_ACTION_FILES_SEARCH_BY_TEXT_LOCATION;
- g_async_queue_push (user_request_queue, rec);
+
@@ -377,6 +378,10 @@ message_func (DBusConnection *conn,
}
+ g_async_queue_push (tracker->user_request_queue, rec);
+
+ tracker_notify_request_data_available ();
+
return DBUS_HANDLER_RESULT_HANDLED;
}
diff --git a/src/trackerd/tracker-fam.c b/src/trackerd/tracker-fam.c
index 26c882e79..f816b2279 100644
--- a/src/trackerd/tracker-fam.c
+++ b/src/trackerd/tracker-fam.c
@@ -31,9 +31,7 @@
//#include "tracker-global.h"
#include "tracker-fam.h"
-
-
-extern GAsyncQueue *file_process_queue;
+extern Tracker *tracker;
extern DBConnection *main_thread_db_con;
typedef struct {
@@ -217,7 +215,7 @@ fam_callback (GIOChannel *source,
char *parent = g_path_get_dirname (info->uri);
if (tracker_is_directory_watched (parent, NULL) || tracker_is_directory_watched (info->uri, NULL)) {
- g_async_queue_push (file_process_queue, info);
+ g_async_queue_push (tracker->file_process_queue, info);
} else {
info = tracker_free_file_info (info);
}
diff --git a/src/trackerd/tracker-inotify.c b/src/trackerd/tracker-inotify.c
index e9b4d67d0..7d558211f 100644
--- a/src/trackerd/tracker-inotify.c
+++ b/src/trackerd/tracker-inotify.c
@@ -27,15 +27,12 @@
#include <unistd.h>
#include <sys/stat.h>
-
-
-
#include "tracker-inotify.h"
/* project wide global vars */
-extern GAsyncQueue *file_process_queue;
+extern Tracker *tracker;
extern DBConnection *main_thread_db_con;
/* list to temporarily store moved_from events so they can be matched against moved_to events */
@@ -44,22 +41,28 @@ static GQueue *inotify_queue;
static int inotify_monitor_fd = -1;
static int inotify_count = 0;
+static GIOChannel *gio;
+
gboolean
tracker_is_directory_watched (const char * dir, DBConnection *db_con)
{
- MYSQL_RES *res = NULL;
- MYSQL_ROW row;
+ char ***res = NULL;
+ char** row;
+
+ if (!tracker->is_running) {
+ return FALSE;
+ }
if (!dir || strlen (dir) == 0 || dir[0] != '/') {
return FALSE;
}
- res = tracker_exec_proc (db_con->db, "GetWatchID", 1, dir);
+ res = tracker_exec_proc (db_con, "GetWatchID", 1, dir);
if (res) {
- row = mysql_fetch_row (res);
+ row = tracker_db_get_row (res, 0);
if (row && row[0]) {
if (atoi (row[0]) > -1) {
@@ -67,7 +70,7 @@ tracker_is_directory_watched (const char * dir, DBConnection *db_con)
}
}
- mysql_free_result (res);
+ tracker_db_free_result (res);
}
@@ -127,7 +130,9 @@ process_event (const char *uri, gboolean is_dir, TrackerChangeAction action, gui
char *parent = g_path_get_dirname (info->uri);
if (tracker_file_is_valid (parent)) {
- g_async_queue_push (file_process_queue, info);
+ g_async_queue_push (tracker->file_process_queue, info);
+
+ tracker_notify_file_data_available ();
} else {
info = tracker_free_file_info (info);
}
@@ -197,11 +202,11 @@ process_event (const char *uri, gboolean is_dir, TrackerChangeAction action, gui
/* update db so that fileID reflects new uri */
- tracker_exec_proc (main_thread_db_con->db, "UpdateFileMove", 4, str_file_id, path, name, index_time);
+ tracker_exec_proc (main_thread_db_con, "UpdateFileMove", 4, str_file_id, path, name, index_time);
/* update File.Path and File.Filename metadata */
- tracker_exec_proc (main_thread_db_con->db, "SetMetadata", 5, "Files", str_file_id, "File.Path", path, "1");
- tracker_exec_proc (main_thread_db_con->db, "SetMetadata", 5, "Files", str_file_id, "File.Name", name, "1");
+ tracker_exec_proc (main_thread_db_con, "SetMetadata", 5, "Files", str_file_id, "File.Path", path, "1");
+ tracker_exec_proc (main_thread_db_con, "SetMetadata", 5, "Files", str_file_id, "File.Name", name, "1");
g_free (str_file_id);
g_free (index_time);
@@ -215,8 +220,8 @@ process_event (const char *uri, gboolean is_dir, TrackerChangeAction action, gui
char *old_path = g_strconcat (moved_from_info->uri, "/", NULL);
char *match_path = g_strconcat (old_path, "%", NULL);
- MYSQL_RES *res = NULL;
- MYSQL_ROW row;
+ char ***res = NULL;
+ char** row;
tracker_log ("moved file is a dir");
@@ -232,19 +237,21 @@ process_event (const char *uri, gboolean is_dir, TrackerChangeAction action, gui
/* update all changed File.Path metadata */
- tracker_exec_proc (main_thread_db_con->db, "UpdateFileMovePath", 2, moved_to_info->uri, moved_from_info->uri);
+ tracker_exec_proc (main_thread_db_con, "UpdateFileMovePath", 2, moved_to_info->uri, moved_from_info->uri);
/* for each subfolder, we must do the same as above */
/* get all sub folders that were moved and add watches */
- res = tracker_exec_proc (main_thread_db_con->db, "SelectFileSubFolders", 1, moved_from_info->uri);
+ res = tracker_exec_proc (main_thread_db_con, "SelectFileSubFolders", 1, moved_from_info->uri);
if (res) {
- while ((row = mysql_fetch_row (res))) {
+ int k =0;
+
+ while ((row = tracker_db_get_row (res, k))) {
-
+ k++;
if (row && row[0] && row[1] && row[2]) {
char *dir_name = g_strconcat (row[1], "/", row[2], NULL);
@@ -258,10 +265,10 @@ process_event (const char *uri, gboolean is_dir, TrackerChangeAction action, gui
tracker_log ("moving subfolder %s to %s", dir_name, new_path);
/* update all changed File.Path metadata for all files in this subfolder*/
- tracker_exec_proc (main_thread_db_con->db, "UpdateFileMovePath", 2, new_path, dir_name);
+ tracker_exec_proc (main_thread_db_con, "UpdateFileMovePath", 2, new_path, dir_name);
/* update all subfolders and contained files to new path */
- tracker_exec_proc (main_thread_db_con->db, "UpdateFileMoveChild", 2, new_path, dir_name);
+ tracker_exec_proc (main_thread_db_con, "UpdateFileMoveChild", 2, new_path, dir_name);
if (tracker_count_watch_dirs () < MAX_FILE_WATCHES) {
@@ -276,13 +283,13 @@ process_event (const char *uri, gboolean is_dir, TrackerChangeAction action, gui
}
}
- mysql_free_result (res);
+ tracker_db_free_result (res);
}
/* update uri path of all files in moved folder */
- tracker_exec_proc (main_thread_db_con->db, "UpdateFileMoveChild", 2, moved_to_info->uri, moved_from_info->uri);
+ tracker_exec_proc (main_thread_db_con, "UpdateFileMoveChild", 2, moved_to_info->uri, moved_from_info->uri);
g_free (modified_path);
g_free (old_path);
@@ -311,7 +318,7 @@ process_event (const char *uri, gboolean is_dir, TrackerChangeAction action, gui
return;
} else if (action == TRACKER_ACTION_WRITABLE_FILE_CLOSED) {
- tracker_log ("File %s has finished changing", info->uri);
+ //tracker_log ("File %s has finished changing", info->uri);
tracker_db_insert_pending_file (main_thread_db_con, info->file_id, info->uri, info->mime, 0, info->action, info->is_directory);
info = tracker_free_file_info (info);
return;
@@ -330,6 +337,10 @@ process_moved_events ()
FileInfo *info;
const GSList *tmp;
+ if (!tracker->is_running) {
+ return FALSE;
+ }
+
if (!move_list) {
return TRUE;
}
@@ -446,6 +457,10 @@ process_inotify_events (void)
struct inotify_event *event;
+ if (!tracker->is_running) {
+ return FALSE;
+ }
+
event = g_queue_pop_head (inotify_queue);
if (!event) {
@@ -466,16 +481,16 @@ process_inotify_events (void)
char *str_wd = g_strdup_printf ("%d", event->wd);
- MYSQL_RES *res = NULL;
- MYSQL_ROW row;
+ char ***res = NULL;
+ char** row;
- res = tracker_exec_proc (main_thread_db_con->db, "GetWatchUri", 1, str_wd);
+ res = tracker_exec_proc (main_thread_db_con, "GetWatchUri", 1, str_wd);
g_free (str_wd);
if (res) {
- row = mysql_fetch_row (res);
+ row = tracker_db_get_row (res, 0);
if (row && row[0]) {
monitor_name = g_strdup (row[0]);
@@ -484,7 +499,7 @@ process_inotify_events (void)
free_inotify_event (event);
continue;
}
- mysql_free_result (res);
+ tracker_db_free_result (res);
}
@@ -566,6 +581,11 @@ inotify_watch_func( GIOChannel *source, GIOCondition condition, gpointer data )
while (buffer_i < (size_t)r) {
/* Parse events and process them ! */
+
+ if (!tracker->is_running) {
+ return FALSE;
+ }
+
pevent = (struct inotify_event *)&buffer[buffer_i];
event_size = sizeof(struct inotify_event) + pevent->len;
event = malloc(event_size);
@@ -583,7 +603,7 @@ gboolean
tracker_start_watching (void)
{
- GIOChannel *gio;
+
if (inotify_monitor_fd != -1) {
return FALSE;
@@ -629,6 +649,11 @@ tracker_add_watch_dir (const char *dir, DBConnection *db_con)
int wd;
char *str_wd;
+
+ if (!tracker->is_running) {
+ return FALSE;
+ }
+
if (!dir || strlen (dir) == 0 || dir[0] != '/') {
return FALSE;
}
@@ -648,7 +673,7 @@ tracker_add_watch_dir (const char *dir, DBConnection *db_con)
return FALSE;
} else {
str_wd = g_strdup_printf ("%d", wd);
- tracker_exec_proc (db_con->db, "InsertWatch", 2, dir, str_wd);
+ tracker_exec_proc (db_con, "InsertWatch", 2, dir, str_wd);
g_free (str_wd);
inotify_count++;
tracker_log ("Watching directory %s (total watches = %d)", dir, inotify_count);
@@ -662,8 +687,8 @@ tracker_add_watch_dir (const char *dir, DBConnection *db_con)
static gboolean
delete_watch (const char *dir, DBConnection *db_con)
{
- MYSQL_RES *res = NULL;
- MYSQL_ROW row;
+ char ***res = NULL;
+ char** row;
int wd = -1;
@@ -672,19 +697,19 @@ delete_watch (const char *dir, DBConnection *db_con)
}
- res = tracker_exec_proc (db_con->db, "GetWatchID", 1, dir);
+ res = tracker_exec_proc (db_con, "GetWatchID", 1, dir);
gboolean found = FALSE;
if (res) {
- row = mysql_fetch_row (res);
+ row = tracker_db_get_row (res, 0);
if (row && row[0]) {
wd = atoi (row[0]);
found = TRUE;
} else {
found = FALSE;
}
- mysql_free_result (res);
+ tracker_db_free_result (res);
} else {
found = FALSE;
}
@@ -694,7 +719,7 @@ delete_watch (const char *dir, DBConnection *db_con)
return FALSE;
}
- tracker_exec_proc (db_con->db, "DeleteWatch", 1, dir);
+ tracker_exec_proc (db_con, "DeleteWatch", 1, dir);
if (wd > -1) {
inotify_rm_watch (inotify_monitor_fd, wd);
@@ -720,15 +745,18 @@ tracker_remove_watch_dir (const char *dir, gboolean delete_subdirs, DBConnection
if (delete_subdirs) {
int wd = -1;
- MYSQL_RES *res = NULL;
- MYSQL_ROW row;
+ char ***res = NULL;
+ char** row;
- res = tracker_exec_proc (db_con->db, "GetSubWatches", 1, dir);
+ res = tracker_exec_proc (db_con, "GetSubWatches", 1, dir);
if (res) {
+ int k = 0;
+
+ while ((row = tracker_db_get_row (res, k))) {
+ k++;
- while ((row = mysql_fetch_row (res))) {
if (row && row[0]) {
wd = atoi (row[0]);
if (wd > -1) {
@@ -739,8 +767,8 @@ tracker_remove_watch_dir (const char *dir, gboolean delete_subdirs, DBConnection
}
}
- mysql_free_result (res);
- tracker_exec_proc (db_con->db, "DeleteSubWatches", 1, dir);
+ tracker_db_free_result (res);
+ tracker_exec_proc (db_con, "DeleteSubWatches", 1, dir);
}
@@ -755,6 +783,7 @@ tracker_remove_watch_dir (const char *dir, gboolean delete_subdirs, DBConnection
void
tracker_end_watching (void)
{
+ g_io_channel_shutdown (gio, TRUE, NULL);
}
diff --git a/src/trackerd/tracker-metadata.c b/src/trackerd/tracker-metadata.c
index 4cb40d432..281f93bf7 100644
--- a/src/trackerd/tracker-metadata.c
+++ b/src/trackerd/tracker-metadata.c
@@ -19,11 +19,15 @@
*/
#include <stdlib.h>
+#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include "tracker-metadata.h"
#include "tracker-utils.h"
+
+
+
typedef enum {
IGNORE_METADATA,
NO_METADATA,
@@ -231,6 +235,9 @@ tracker_get_service_type_for_mime (const char *mime)
+
+
+
char *
tracker_metadata_get_text_file (const char *uri, const char *mime)
{
diff --git a/src/trackerd/tracker-metadata.h b/src/trackerd/tracker-metadata.h
index 5b9dd0815..61aee2aad 100644
--- a/src/trackerd/tracker-metadata.h
+++ b/src/trackerd/tracker-metadata.h
@@ -19,11 +19,12 @@
#include <glib.h>
-#define THUMB_SMALL "128"
+#define THUMB_SMALL "128"
#define THUMB_LARGE "640"
-void tracker_metadata_get_embedded (const char *uri, const char *mime, GHashTable *table);
-char * tracker_metadata_get_text_file (const char *uri, const char *mime);
-char * tracker_metadata_get_thumbnail (const char *uri, const char *mime, const char *max_size);
-char * tracker_get_service_type_for_mime (const char *mime);
+void tracker_metadata_get_embedded (const char *uri, const char *mime, GHashTable *table);
+char * tracker_metadata_get_text_file (const char *uri, const char *mime);
+void tracker_metadata_parse_text_contents (const char *file_as_text, unsigned int ID);
+char * tracker_metadata_get_thumbnail (const char *uri, const char *mime, const char *max_size);
+char * tracker_get_service_type_for_mime (const char *mime);
diff --git a/src/trackerd/tracker-utils.c b/src/trackerd/tracker-utils.c
index 8f93e0e24..e6e8d253a 100644
--- a/src/trackerd/tracker-utils.c
+++ b/src/trackerd/tracker-utils.c
@@ -36,11 +36,7 @@
#include "tracker-utils.h"
#include "xdgmime.h"
-extern GMutex *log_access_mutex;
-extern char *log_file;
-extern GSList *poll_list;
-
-
+extern Tracker *tracker;
char *implemented_services[] = {"Files", "Folders", "Documents", "Images", "Music", "Videos", "Text Files", "Development Files", "Other Files",
"VFS Files", "VFS Folders", "VFS Documents", "VFS Images", "VFS Music", "VFS Videos", "VFS Text Files", "VFS Development Files", "VFS Other Files",
@@ -68,24 +64,6 @@ char *tracker_actions[] = {
static int info_allocated = 0;
static int info_deallocated = 0;
-/* global config variables */
-extern GSList *watch_directory_roots_list;
-extern GSList *no_watch_directory_list;
-extern gboolean index_text_files;
-extern gboolean index_documents;
-extern gboolean index_source_code;
-extern gboolean index_scripts;
-extern gboolean index_html;
-extern gboolean index_pdf;
-extern gboolean index_application_help_files;
-extern gboolean index_desktop_files;
-extern gboolean index_epiphany_bookmarks;
-extern gboolean index_epiphany_history;
-extern gboolean index_firefox_bookmarks;
-extern gboolean index_firefox_history;
-extern gboolean store_text_file_contents_in_db;
-extern char *db_buffer_memory_limit;
-
static const char *months[] = {
"Jan", "Feb", "Mar", "Apr", "May", "Jun",
@@ -742,25 +720,7 @@ tracker_format_search_terms (const char *str, gboolean *do_bool_search)
}
-int
-tracker_get_row_count (char ***result)
-{
- char ***rows;
- int i;
- if (!result) {
- return 0;
- }
-
- i = 0;
-
- for (rows = result; *rows; rows++) {
- i++;
- }
-
- return i;
-
-}
void
@@ -1219,13 +1179,13 @@ tracker_log (const char* fmt, ...)
}
/* ensure file logging is thread safe */
- g_mutex_lock (log_access_mutex);
+ g_mutex_lock (tracker->log_access_mutex);
- fd = fopen (log_file, "a");
+ fd = fopen (tracker->log_file, "a");
if (!fd) {
- g_mutex_unlock (log_access_mutex);
- g_warning ("could not open %s", log_file);
+ g_mutex_unlock (tracker->log_access_mutex);
+ g_warning ("could not open %s", tracker->log_file);
g_free (msg);
return;
}
@@ -1240,7 +1200,7 @@ tracker_log (const char* fmt, ...)
g_free (msg);
g_free (output);
fclose (fd);
- g_mutex_unlock (log_access_mutex);
+ g_mutex_unlock (tracker->log_access_mutex);
}
@@ -1272,6 +1232,10 @@ tracker_get_files (const char *dir, gboolean dir_only)
if ((dirp = opendir (dir)) != NULL) {
while ((entry = readdir (dirp)) != NULL) {
+ if (!tracker->is_running) {
+ return NULL;
+ }
+
char *mystr = NULL, *str = NULL;
if (entry->d_name[0] == '.') {
@@ -1290,7 +1254,7 @@ tracker_get_files (const char *dir, gboolean dir_only)
if (!dir_only || tracker_is_directory (mystr)) {
- if (g_slist_find_custom (no_watch_directory_list, mystr, (GCompareFunc) has_prefix) == NULL) {
+ if (g_slist_find_custom (tracker->no_watch_directory_list, mystr, (GCompareFunc) has_prefix) == NULL) {
file_list = g_slist_prepend (file_list, g_strdup (mystr));
}
}
@@ -1301,6 +1265,11 @@ tracker_get_files (const char *dir, gboolean dir_only)
g_free (entry);
closedir (dirp);
}
+
+ if (!tracker->is_running) {
+ return NULL;
+ }
+
return file_list;
}
@@ -1421,9 +1390,9 @@ tracker_load_config_file ()
NULL);
if (values) {
- watch_directory_roots_list = array_to_list (values);
+ tracker->watch_directory_roots_list = array_to_list (values);
} else {
- watch_directory_roots_list = g_slist_prepend (watch_directory_roots_list, g_strdup (g_get_home_dir ()));
+ tracker->watch_directory_roots_list = g_slist_prepend (tracker->watch_directory_roots_list, g_strdup (g_get_home_dir ()));
}
@@ -1434,13 +1403,14 @@ tracker_load_config_file ()
NULL);
if (values) {
- no_watch_directory_list = array_to_list (values);
+ tracker->no_watch_directory_list = array_to_list (values);
- g_slist_foreach (no_watch_directory_list,(GFunc) display_list_values, NULL);
+ g_slist_foreach (tracker->no_watch_directory_list,(GFunc) display_list_values, NULL);
} else {
- no_watch_directory_list = NULL;
+ tracker->no_watch_directory_list = NULL;
}
+/*
if (g_key_file_has_key (key_file, "Indexes", "IndexTextFiles", NULL)) {
index_text_files = g_key_file_get_boolean (key_file, "Indexes", "IndexTextFiles", NULL);
}
@@ -1492,8 +1462,8 @@ tracker_load_config_file ()
if (g_key_file_has_key (key_file, "Database", "StoreTextFileContentsInDB", NULL)) {
store_text_file_contents_in_db = g_key_file_get_boolean (key_file, "Indexes", "StoreTextFileContentsInDB", NULL);
}
-
- db_buffer_memory_limit = g_key_file_get_string ( key_file, "Database", "DBBufferMemoryLimit", NULL);
+*/
+ //db_buffer_memory_limit = g_key_file_get_string ( key_file, "Database", "DBBufferMemoryLimit", NULL);
g_free (filename);
g_key_file_free (key_file);
@@ -1506,7 +1476,7 @@ tracker_remove_poll_dir (const char *dir)
const GSList *tmp;
char *str, *str2;
- tmp = poll_list;
+ tmp = tracker->poll_list;
str2 = g_strconcat (dir, "/", NULL);
@@ -1515,7 +1485,9 @@ tracker_remove_poll_dir (const char *dir)
str = tmp->data;
if (strcmp (dir, str) ==0) {
- poll_list = g_slist_remove (poll_list, tmp->data);
+ g_mutex_lock (tracker->poll_access_mutex);
+ tracker->poll_list = g_slist_remove (tracker->poll_list, tmp->data);
+ g_mutex_unlock (tracker->poll_access_mutex);
g_free (str);
str = NULL;
}
@@ -1523,7 +1495,9 @@ tracker_remove_poll_dir (const char *dir)
/* check if subfolder of existing roots */
if (str && g_str_has_prefix (str, str2)) {
- poll_list = g_slist_remove (poll_list, tmp->data);
+ g_mutex_lock (tracker->poll_access_mutex);
+ tracker->poll_list = g_slist_remove (tracker->poll_list, tmp->data);
+ g_mutex_unlock (tracker->poll_access_mutex);
g_free (str);
}
@@ -1539,8 +1513,12 @@ tracker_add_poll_dir (const char *dir)
{
g_return_if_fail (dir && tracker_is_directory (dir));
- poll_list = g_slist_prepend (poll_list, g_strdup (dir));
- tracker_log ("adding %s for polling (poll count is %d)", dir, g_slist_length (poll_list));
+ if (!tracker->is_running) return;
+
+ g_mutex_lock (tracker->poll_access_mutex);
+ tracker->poll_list = g_slist_prepend (tracker->poll_list, g_strdup (dir));
+ g_mutex_unlock (tracker->poll_access_mutex);
+ tracker_log ("adding %s for polling (poll count is %d)", dir, g_slist_length (tracker->poll_list));
}
@@ -1550,7 +1528,7 @@ tracker_is_dir_polled (const char *dir)
GSList *tmp;
char *str;
- tmp = poll_list;
+ tmp = tracker->poll_list;
while (tmp != NULL) {
str = (char *)tmp->data;
if (strcmp (dir, str) == 0) {
@@ -1562,3 +1540,146 @@ tracker_is_dir_polled (const char *dir)
return FALSE;
}
+
+
+void
+tracker_notify_file_data_available ()
+{
+
+
+
+ /* if file thread is asleep then we just need to wake it up! */
+ if (g_mutex_trylock (tracker->files_signal_mutex)) {
+ g_cond_signal (tracker->file_thread_signal);
+ g_mutex_unlock (tracker->files_signal_mutex);
+ return;
+ }
+
+ /* if busy - check if async queue has new stuff as we do not need to notify then */
+ if (g_async_queue_length (tracker->file_process_queue) > 0) {
+ return;
+ }
+
+ /* if file thread not in check phase then we need do nothing */
+ if (g_mutex_trylock (tracker->files_check_mutex)) {
+ g_mutex_unlock (tracker->files_check_mutex);
+ return;
+ }
+
+ /* we are in check phase - we need to wait until either check_mutex is unlocked or file thread is asleep then awaken it */
+ while (TRUE) {
+
+ if (g_mutex_trylock (tracker->files_check_mutex)) {
+ g_mutex_unlock (tracker->files_check_mutex);
+ return;
+ }
+
+ if (g_mutex_trylock (tracker->files_signal_mutex)) {
+ g_cond_signal (tracker->file_thread_signal);
+ g_mutex_unlock (tracker->files_signal_mutex);
+ return;
+ }
+
+ g_thread_yield ();
+ g_usleep (10);
+
+
+ }
+
+}
+
+
+
+void
+tracker_notify_meta_data_available ()
+{
+
+
+
+ /* if metadata thread is asleep then we just need to wake it up! */
+ if (g_mutex_trylock (tracker->metadata_signal_mutex)) {
+ g_cond_signal (tracker->metadata_thread_signal);
+ g_mutex_unlock (tracker->metadata_signal_mutex);
+ return;
+ }
+
+ /* if busy - check if async queue has new stuff as we do not need to notify then */
+ if (g_async_queue_length (tracker->file_metadata_queue) > 0) {
+ return;
+ }
+
+ /* if metadata thread not in check phase then we need do nothing */
+ if (g_mutex_trylock (tracker->metadata_check_mutex)) {
+ g_mutex_unlock (tracker->metadata_check_mutex);
+ return;
+ }
+
+ /* we are in check phase - we need to wait until either check_mutex is unlocked or until metadata thread is asleep then we awaken it */
+ while (TRUE) {
+
+ if (g_mutex_trylock (tracker->metadata_check_mutex)) {
+ g_mutex_unlock (tracker->metadata_check_mutex);
+ return;
+ }
+
+ if (g_mutex_trylock (tracker->metadata_signal_mutex)) {
+ g_cond_signal (tracker->metadata_thread_signal);
+ g_mutex_unlock (tracker->metadata_signal_mutex);
+ return;
+ }
+
+ g_thread_yield ();
+ g_usleep (10);
+
+
+ }
+
+}
+
+
+void
+tracker_notify_request_data_available ()
+{
+
+
+
+ /* if thread is asleep then we just need to wake it up! */
+ if (g_mutex_trylock (tracker->request_signal_mutex)) {
+ g_cond_signal (tracker->request_thread_signal);
+ g_mutex_unlock (tracker->request_signal_mutex);
+ return;
+ }
+
+ /* if busy - check if async queue has new stuff as we do not need to notify then */
+ if (g_async_queue_length (tracker->user_request_queue) > 0) {
+ return;
+ }
+
+ /* if thread not in check phase then we need do nothing */
+ if (g_mutex_trylock (tracker->request_check_mutex)) {
+ g_mutex_unlock (tracker->request_check_mutex);
+ return;
+ }
+
+ /* we are in check phase - we need to wait until either check_mutex is unlocked or thread is asleep then awaken it */
+ while (TRUE) {
+
+ if (g_mutex_trylock (tracker->request_check_mutex)) {
+ g_mutex_unlock (tracker->request_check_mutex);
+ return;
+ }
+
+ if (g_mutex_trylock (tracker->request_signal_mutex)) {
+ g_cond_signal (tracker->request_thread_signal);
+ g_mutex_unlock (tracker->request_signal_mutex);
+ return;
+ }
+
+ g_thread_yield ();
+ g_usleep (10);
+
+ }
+
+}
+
+
diff --git a/src/trackerd/tracker-utils.h b/src/trackerd/tracker-utils.h
index 36e3bcc58..3fdc49f83 100644
--- a/src/trackerd/tracker-utils.h
+++ b/src/trackerd/tracker-utils.h
@@ -39,6 +39,55 @@ extern char *tracker_actions[];
#define TRACKER_VERSION "0.5.0"
#define TRACKER_VERSION_INT 500
+
+typedef struct {
+ GSList *watch_directory_roots_list;
+ GSList *no_watch_directory_list;
+ GSList *poll_list;
+ gboolean use_nfs_safe_locking;
+
+ GHashTable *file_scheduler;
+ GMutex *scheduler_mutex;
+
+ gboolean is_running;
+ GMainLoop *loop;
+
+ GMutex *log_access_mutex;
+ char *log_file;
+
+ GAsyncQueue *file_process_queue;
+ GAsyncQueue *file_metadata_queue;
+ GAsyncQueue *user_request_queue;
+
+ GMutex *files_check_mutex;
+ GMutex *metadata_check_mutex;
+ GMutex *request_check_mutex;
+
+ GMutex *poll_access_mutex;
+
+ GMutex *files_stopped_mutex;
+ GMutex *metadata_stopped_mutex;
+ GMutex *request_stopped_mutex;
+ GMutex *poll_stopped_mutex;
+
+ GThread *file_metadata_thread;
+ GThread *file_process_thread;
+ GThread *user_request_thread;
+ GThread *file_poll_thread;
+
+ GCond *file_thread_signal;
+ GCond *metadata_thread_signal;
+ GCond *request_thread_signal;
+ GCond *poll_thread_signal;
+
+ GMutex *metadata_signal_mutex;
+ GMutex *files_signal_mutex;
+ GMutex *request_signal_mutex;
+ GMutex *poll_signal_mutex;
+
+} Tracker;
+
+
/* Actions can represent events from FAM/iNotify or be artificially created */
typedef enum {
@@ -143,7 +192,7 @@ int tracker_str_in_array (const char *str, char **array);
char * tracker_format_search_terms (const char *str, gboolean *do_bool_search);
-int tracker_get_row_count (char ***result);
+
FileInfo * tracker_create_file_info (const char *uri, TrackerChangeAction action, int counter, WatchTypes watch);
FileInfo * tracker_get_file_info (FileInfo *info);
FileInfo * tracker_copy_file_info (FileInfo *info);
@@ -182,4 +231,10 @@ void tracker_add_poll_dir (const char *dir);
void tracker_remove_poll_dir (const char *dir);
gboolean tracker_is_dir_polled (const char *dir);
+void tracker_notify_file_data_available ();
+void tracker_notify_meta_data_available ();
+void tracker_notify_request_data_available ();
+
+//GHashTable * tracker_parse_text (const char *text, int min_word_length, GHashTable *stop_words, gboolean use_stemmer, int weight);
+
#endif
diff --git a/src/trackerd/trackerd.c b/src/trackerd/trackerd.c
index 61b5aa826..dfe6d5ffd 100644
--- a/src/trackerd/trackerd.c
+++ b/src/trackerd/trackerd.c
@@ -21,7 +21,6 @@
#define I_AM_MAIN
#include "config.h"
-#include <mysql/mysql.h>
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
@@ -37,23 +36,21 @@
#include <time.h>
#include <glib/gstdio.h>
-
#ifdef HAVE_INOTIFY
-#include "tracker-inotify.h"
+# include "tracker-inotify.h"
#else
-#ifdef HAVE_FAM
-#include "tracker-fam.h"
-#endif
+# ifdef HAVE_FAM
+# include "tracker-fam.h"
+# endif
#endif
#ifndef HAVE_INOTIFY
-#ifndef HAVE_FAM
-#define POLL_ONLY
-#include "tracker-db.h"
+# ifndef HAVE_FAM
+# define POLL_ONLY
+# endif
#endif
-#endif
-
+#include "tracker-db.h"
#include "tracker-metadata.h"
#include "tracker-dbus-methods.h"
#include "tracker-dbus-metadata.h"
@@ -61,6 +58,14 @@
#include "tracker-dbus-search.h"
#include "tracker-dbus-files.h"
+
+Tracker *tracker;
+
+static DBusConnection *main_connection;
+DBConnection *main_thread_db_con;
+
+static gboolean shutdown = FALSE;
+
/*
* The workflow to process files and notified file change events are as follows:
*
@@ -92,70 +97,12 @@
* asynchronous queue where potentially multiple threads are waiting to process them.
*/
-#define FILE_POLL_PERIOD 30 * 60 * 1000
+#define FILE_POLL_PERIOD (30 * 60 * 1000)
char *type_array[] = {"index", "string", "numeric", "date", NULL};
-/* global config options variables */
-
-GSList *watch_directory_roots_list = NULL;
-GSList *no_watch_directory_list = NULL;
-gboolean index_text_files = TRUE;
-gboolean index_documents = TRUE;
-gboolean index_source_code = TRUE;
-gboolean index_scripts = FALSE;
-gboolean index_html = TRUE;
-gboolean index_pdf = TRUE;
-gboolean index_application_help_files = TRUE;
-gboolean index_desktop_files = TRUE;
-gboolean index_epiphany_bookmarks = TRUE;
-gboolean index_epiphany_history = TRUE;
-gboolean index_firefox_bookmarks = TRUE;
-gboolean index_firefox_history = TRUE;
-gboolean store_text_file_contents_in_db = FALSE;
-char *db_buffer_memory_limit = "1M";
-
+//Indexer *file_indexer;
-/* list to store all directories to poll */
-
-static GAsyncQueue *file_pending_queue;
-
-#ifdef POLL_ONLY
-static GAsyncQueue *file_process_queue;
-#else
-GAsyncQueue *file_process_queue;
-#endif
-
-GAsyncQueue *user_request_queue;
-
-GSList *poll_list;
-DBConnection *main_thread_db_con;
-
-GMutex *metadata_available_mutex;
-GMutex *files_available_mutex;
-
-static GAsyncQueue *file_metadata_queue = NULL;
-
-GMutex *log_access_mutex;
-char *log_file;
-
-gboolean use_nfs_safe_locking;
-
-static DBusConnection *main_connection;
-static GHashTable *file_scheduler = NULL;
-static GMutex *scheduler_mutex = NULL;
-
-static gboolean is_running = FALSE;
-
-static GMutex *process_thread_mutex = NULL;
-static GMutex *metadata_thread_mutex = NULL;
-static GMutex *user_thread1_mutex = NULL;
-static GMutex *user_thread2_mutex = NULL;
-static GMutex *poll_thread_mutex = NULL;
-
-
-
-static GThread *file_poll_thread = NULL;
static void schedule_file_check (const char * uri, DBConnection *db_con);
@@ -165,12 +112,12 @@ static void delete_file (DBConnection *db_con, FileInfo *info);
static void scan_directory (const char * uri, DBConnection *db_con);
-static GMainLoop *loop;
+
#ifdef POLL_ONLY
-#define MAX_FILE_WATCHES -1
+#define MAX_FILE_WATCHES (-1)
gboolean tracker_start_watching (void){return TRUE;}
void tracker_end_watching (void){return;}
@@ -180,33 +127,76 @@ static GMainLoop *loop;
gboolean tracker_is_directory_watched (const char * dir, DBConnection *db_con) {return FALSE;}
int tracker_count_watch_dirs (void) {return 0;}
-#endif
-
+#endif /* POLL_ONLY */
static void
+my_yield ()
+{
+ while (g_main_context_iteration (NULL, FALSE)) {
+ ;
+ }
+}
+
+
+static gboolean
do_cleanup ()
{
-
tracker_print_object_allocations ();
+ tracker_log ("starting shutdown...");
+
+ shutdown = TRUE;
+
+
+
+ /* clear pending files and watch tables*/
+ tracker_db_clear_temp (main_thread_db_con);
+
+
/* stop threads from further processing of events if possible */
- is_running = FALSE;
- /* acquire thread mutexes - we wait until all threads have been stopped and DB connections closed */
+ tracker_dbus_shutdown (main_connection);
- g_mutex_lock (process_thread_mutex);
- g_mutex_lock (metadata_thread_mutex);
- g_mutex_lock (user_thread1_mutex);
- g_mutex_lock (user_thread2_mutex);
-
- tracker_end_watching ();
+ //tracker_indexer_close (file_indexer);
- g_main_loop_quit (loop);
- /* This must be called after all other mysql functions */
- mysql_server_end ();
+ tracker_log ("shutting down threads");
+ /* send signals to each thread to wake them up and then stop them */
+
+ g_mutex_lock (tracker->poll_signal_mutex);
+ g_cond_signal (tracker->poll_thread_signal);
+ g_mutex_unlock (tracker->poll_signal_mutex);
+
+ g_mutex_lock (tracker->request_signal_mutex);
+ g_cond_signal (tracker->request_thread_signal);
+ g_mutex_unlock (tracker->request_signal_mutex);
+
+ g_mutex_lock (tracker->metadata_signal_mutex);
+ g_cond_signal (tracker->metadata_thread_signal);
+ g_mutex_unlock (tracker->metadata_signal_mutex);
+
+ g_mutex_lock (tracker->files_signal_mutex);
+ g_cond_signal (tracker->file_thread_signal);
+ g_mutex_unlock (tracker->files_signal_mutex);
+
+
+ /* wait for threads to exit */
+ g_mutex_lock (tracker->request_stopped_mutex);
+ g_mutex_lock (tracker->metadata_stopped_mutex);
+ g_mutex_lock (tracker->files_stopped_mutex);
+ g_mutex_lock (tracker->poll_stopped_mutex);
+
+ tracker_db_close (main_thread_db_con);
+
+ /* This must be called after all other db functions */
+ tracker_db_finalize ();
+ tracker_log ("shutting down main thread");
+ g_main_loop_quit (tracker->loop);
+ exit (EXIT_SUCCESS);
+
+ return FALSE;
}
static int
@@ -228,8 +218,9 @@ has_prefix (const char *str1, const char *str2)
static void
poll_dir (const char *uri, DBConnection *db_con)
{
- char **files, **files_p, *str;
+ char **files, **files_p, *str;
+ if (!tracker->is_running) return;
/* check for any deletions*/
files = tracker_db_get_files_in_folder (db_con, uri);
@@ -266,12 +257,13 @@ poll_dir (const char *uri, DBConnection *db_con)
while (tmp != NULL) {
FileInfo *info;
+ if (!tracker->is_running) return;
str = (char *)tmp->data;
info = tracker_create_file_info (str, TRACKER_ACTION_DIRECTORY_CREATED, 0, 0);
info = tracker_db_get_file_info (db_con, info);
if (info->file_id == -1) {
- g_async_queue_push (file_pending_queue, info);
+ tracker_db_insert_pending_file (db_con, info->file_id, info->uri, info->mime, 0, info->action, info->is_directory);
} else {
info = tracker_free_file_info (info);
}
@@ -285,7 +277,7 @@ poll_dir (const char *uri, DBConnection *db_con)
/* scan dir for changes in all other files */
- if (g_slist_find_custom (no_watch_directory_list, uri, (GCompareFunc) has_prefix) == NULL) {
+ if (g_slist_find_custom (tracker->no_watch_directory_list, uri, (GCompareFunc) has_prefix) == NULL) {
scan_directory (uri, db_con);
} else {
tracker_log ("blocked scan of directory %s as its in the no watch list", uri);
@@ -301,10 +293,13 @@ poll_directories (gpointer db_con)
g_return_if_fail (db_con);
tracker_log ("polling dirs");
- if (g_slist_length (poll_list) > 0) {
- g_slist_foreach (poll_list, (GFunc) poll_dir, db_con);
+
+
+ if (g_slist_length (tracker->poll_list) > 0) {
+ g_slist_foreach (tracker->poll_list, (GFunc) poll_dir, db_con);
}
+
}
@@ -314,41 +309,79 @@ poll_directories (gpointer db_con)
static void
poll_files_thread ()
{
- DBConnection db_con;
+ DBConnection *db_con;
+
+ g_mutex_lock (tracker->poll_signal_mutex);
+ g_mutex_lock (tracker->poll_stopped_mutex);
/* set thread safe DB connection */
- mysql_thread_init ();
+ tracker_db_thread_init ();
- db_con.db = tracker_db_connect ();
+ db_con = tracker_db_connect ();
- while (is_running) {
- /* we only poll if we cannot lock mutex */
- if (g_mutex_trylock (poll_thread_mutex)) {
- g_mutex_unlock (poll_thread_mutex);
- g_usleep (1000000);
- continue;
- }
+ while (TRUE) {
+
+
+ /* make thread sleep if first part of the shutdown process has been activated */
+ if (!tracker->is_running) {
+
+ tracker_log ("poll thread going to deep sleep...");
+
+ g_cond_wait (tracker->poll_thread_signal , tracker->poll_signal_mutex);
+
+ /* determine if wake up call is new stuff or a shutdown signal */
+ if (!shutdown) {
+ continue;
+ } else {
+ break;
+ }
+
+ }
+
- poll_directories (&db_con);
- g_mutex_unlock (poll_thread_mutex);
+ poll_directories (db_con);
+
+ /* sleep until notified again */
+ tracker_log ("poll thread sleeping");
+ g_cond_wait (tracker->poll_thread_signal , tracker->poll_signal_mutex);
+ tracker_log ("poll thread awoken");
+
+ /* determine if wake up call is a shutdown signal or a request to poll again */
+ if (!shutdown) {
+ continue;
+ } else {
+ break;
+ }
}
- mysql_close (db_con.db);
- mysql_thread_end ();
+ tracker_db_close (db_con);
+ tracker_db_thread_end ();
+
+ tracker_log ("poll thread has exited successfully");
+
+ g_mutex_unlock (tracker->poll_stopped_mutex);
}
static gboolean
start_poll (void)
{
- if (!file_poll_thread && g_slist_length (poll_list) > 0) {
- file_poll_thread = g_thread_create ((GThreadFunc) poll_files_thread, NULL, FALSE, NULL);
+ if (!tracker->file_poll_thread && g_slist_length (tracker->poll_list) > 0) {
+ tracker->file_poll_thread = g_thread_create ((GThreadFunc) poll_files_thread, NULL, FALSE, NULL);
tracker_log ("started polling");
+ } else {
+
+ /* wake up poll thread and start polling */
+ if (tracker->file_poll_thread && g_slist_length (tracker->poll_list) > 0) {
+ if (g_mutex_trylock (tracker->poll_signal_mutex)) {
+ g_cond_signal (tracker->poll_thread_signal);
+ g_mutex_unlock (tracker->poll_signal_mutex);
+ }
+ }
}
- g_mutex_trylock (poll_thread_mutex);
return TRUE;
}
@@ -359,6 +392,8 @@ add_dirs_to_watch_list (GSList *dir_list, gboolean check_dirs, DBConnection *db_
GSList *file_list = NULL;
gboolean start_polling = FALSE;
+ if (!tracker->is_running) return;
+
g_return_if_fail (dir_list != NULL);
@@ -373,11 +408,13 @@ add_dirs_to_watch_list (GSList *dir_list, gboolean check_dirs, DBConnection *db_
str = (char *)tmp->data;
- if (g_slist_find_custom (no_watch_directory_list, str, (GCompareFunc) has_prefix) == NULL) {
+ if (g_slist_find_custom (tracker->no_watch_directory_list, str, (GCompareFunc) has_prefix) == NULL) {
/* use polling if FAM or Inotify fails */
if (!tracker_add_watch_dir (str, db_con) && tracker_is_directory (str) && !tracker_is_dir_polled (str)) {
- tracker_add_poll_dir (str);
+ if (tracker->is_running) {
+ tracker_add_poll_dir (str);
+ }
}
}
tmp = tmp->next;
@@ -412,6 +449,8 @@ watch_dir (const char* dir, DBConnection *db_con)
char *dir_utf8 = NULL;
GSList *mylist = NULL;
+ if (!tracker->is_running) return TRUE;
+
g_assert (dir);
if (!g_utf8_validate (dir, -1, NULL)) {
@@ -435,7 +474,7 @@ watch_dir (const char* dir, DBConnection *db_con)
return FALSE;
}
- if (g_slist_find_custom (no_watch_directory_list, dir_utf8, (GCompareFunc) has_prefix) == NULL) {
+ if (g_slist_find_custom (tracker->no_watch_directory_list, dir_utf8, (GCompareFunc) has_prefix) == NULL) {
mylist = g_slist_prepend (mylist, dir_utf8);
add_dirs_to_watch_list (mylist, TRUE, db_con);
}
@@ -448,7 +487,7 @@ static void
signal_handler (int signo)
{
-
+ if (!tracker->is_running) return;
static gboolean in_loop = FALSE;
@@ -465,26 +504,34 @@ signal_handler (int signo)
case SIGFPE:
case SIGPIPE:
case SIGABRT:
- if (log_file) {
+ if (tracker->log_file) {
tracker_log ("Received fatal signal %s so now aborting.",g_strsignal (signo));
}
- do_cleanup ();
+ tracker->is_running = FALSE;
+ tracker_end_watching ();
+ do_cleanup ();
exit (1);
break;
case SIGTERM:
case SIGINT:
- if (log_file) {
+ if (tracker->log_file) {
tracker_log ("Received termination signal %s so now exiting", g_strsignal (signo));
}
- do_cleanup();
- exit (0);
+ tracker->is_running = FALSE;
+ tracker_end_watching ();
+ g_timeout_add_full (G_PRIORITY_LOW,
+ 100,
+ (GSourceFunc) do_cleanup,
+ NULL, NULL
+ );
+
break;
default:
- if (log_file) {
+ if (tracker->log_file) {
tracker_log ("Received signal %s ", g_strsignal (signo));
}
in_loop = FALSE;
@@ -498,6 +545,8 @@ delete_file (DBConnection *db_con, FileInfo *info)
{
char *str_file_id;
+ //if (!tracker->is_running) return;
+
/* info struct may have been deleted in transit here so check if still valid and intact */
g_return_if_fail ( tracker_file_info_is_valid (info));
@@ -508,7 +557,7 @@ delete_file (DBConnection *db_con, FileInfo *info)
str_file_id = tracker_long_to_str (info->file_id);
- tracker_exec_proc (db_con->db, "DeleteFile", 1, str_file_id);
+ tracker_exec_proc (db_con, "DeleteFile", 1, str_file_id);
g_free (str_file_id);
@@ -523,6 +572,8 @@ delete_directory (DBConnection *db_con, FileInfo *info)
{
char *str_file_id, *str_path;
+ //if (!tracker->is_running) return;
+
/* info struct may have been deleted in transit here so check if still valid and intact */
g_return_if_fail ( tracker_file_info_is_valid (info));
@@ -541,7 +592,7 @@ delete_directory (DBConnection *db_con, FileInfo *info)
g_free (name);
g_free (path);
- tracker_exec_proc (db_con->db, "DeleteDirectory", 2, str_file_id, str_path);
+ tracker_exec_proc (db_con, "DeleteDirectory", 2, str_file_id, str_path);
tracker_remove_watch_dir (info->uri, TRUE, db_con);
@@ -563,10 +614,12 @@ index_file (DBConnection *db_con, FileInfo *info)
char *str_dir, *str_link, *str_link_uri, *str_mtime, *str_file_id;
GHashTable *meta_table;
+ if (!tracker->is_running) return;
/* the file being indexed or info struct may have been deleted in transit so check if still valid and intact */
g_return_if_fail ( tracker_file_info_is_valid (info));
+
if (!tracker_file_is_valid (info->uri)) {
tracker_log ("Warning - file %s no longer exists - abandoning index on this file", info->uri);
return;
@@ -633,7 +686,7 @@ index_file (DBConnection *db_con, FileInfo *info)
service_name = tracker_get_service_type_for_mime (info->mime);
}
- tracker_exec_proc (db_con->db, "CreateService", 8, path, name, service_name, str_dir, str_link, "0", "0", str_mtime);
+ tracker_exec_proc (db_con, "CreateService", 8, path, name, service_name, str_dir, str_link, "0", "0", str_mtime);
//tracker_log ("processed file %s with mime %s and service %s", info->uri, info->mime, service_name);
@@ -648,10 +701,10 @@ index_file (DBConnection *db_con, FileInfo *info)
tracker_log ("updating file %s ", info->uri);
- tracker_exec_proc (db_con->db, "UpdateFile", 2, str_file_id, str_mtime);
+ tracker_exec_proc (db_con, "UpdateFile", 2, str_file_id, str_mtime);
/* delete all derived metadata in DB for an updated file */
- tracker_exec_proc (db_con->db, "DeleteEmbeddedServiceMetadata", 1, str_file_id);
+ tracker_exec_proc (db_con, "DeleteEmbeddedServiceMetadata", 1, str_file_id);
}
@@ -692,13 +745,13 @@ remove_no_watch_dirs (GSList *list)
tmp = list;
-
+ if (!tracker->is_running) return NULL;
while (tmp) {
str = tmp->data;
- if (g_slist_find_custom (no_watch_directory_list, str, (GCompareFunc) has_prefix) == NULL) {
+ if (g_slist_find_custom (tracker->no_watch_directory_list, str, (GCompareFunc) has_prefix) == NULL) {
tracker_log ("removing %s from scan list", str);
tmp = tmp->next;
list = g_slist_remove (list, str);
@@ -719,6 +772,10 @@ schedule_file_check (const char *uri, DBConnection *db_con)
g_return_if_fail (uri);
g_return_if_fail (db_con);
+ if (!tracker->is_running) return;
+
+ /* keep mainloop responsive */
+ my_yield ();
tracker_db_insert_pending_file (db_con, -1, uri, "unknown", 0, TRACKER_ACTION_CHECK, 0);
}
@@ -728,16 +785,19 @@ scan_directory (const char *uri, DBConnection *db_con)
{
GSList *file_list = NULL;
+ if (!tracker->is_running) return;
+
g_return_if_fail (db_con);
g_return_if_fail (uri);
g_return_if_fail (tracker_is_directory (uri));
- file_list = tracker_get_files (uri, FALSE);
+ /* keep mainloop responsive */
+ my_yield ();
+ file_list = tracker_get_files (uri, FALSE);
-
g_slist_foreach (file_list, (GFunc) schedule_file_check, db_con);
g_slist_foreach (file_list, (GFunc) g_free, NULL);
g_slist_free (file_list);
@@ -751,6 +811,7 @@ scan_directory (const char *uri, DBConnection *db_con)
static gboolean
start_watching (gpointer data)
{
+ if (!tracker->is_running) return FALSE;
if (!tracker_start_watching ()) {
tracker_log ("File monitoring failed to start");
@@ -774,8 +835,8 @@ start_watching (gpointer data)
g_free (watch_folder);
} else {
- g_slist_foreach (watch_directory_roots_list, (GFunc) watch_dir, main_thread_db_con);
- g_slist_foreach (watch_directory_roots_list, (GFunc) schedule_file_check, main_thread_db_con);
+ g_slist_foreach (tracker->watch_directory_roots_list, (GFunc) watch_dir, main_thread_db_con);
+ g_slist_foreach (tracker->watch_directory_roots_list, (GFunc) schedule_file_check, main_thread_db_con);
}
@@ -789,80 +850,111 @@ extract_metadata_thread ()
{
FileInfo *info;
GHashTable *meta_table;
- DBConnection db_con;
+ DBConnection *db_con;
gboolean has_pending = FALSE;
- MYSQL_RES *res = NULL;
- MYSQL_ROW row;
+ char ***res = NULL;
+ char** row;
+
- /* set thread safe DB connection */
- mysql_thread_init ();
+ g_mutex_lock (tracker->metadata_signal_mutex);
+ g_mutex_lock (tracker->metadata_stopped_mutex);
- /* set mutex so we know if the thread is still processing */
- g_mutex_lock (metadata_thread_mutex);
+ /* set thread safe DB connection */
+ tracker_db_thread_init ();
- db_con.db = tracker_db_connect ();
+ db_con = tracker_db_connect ();
- tracker_db_prepare_queries (&db_con);
+ db_con->thread = "extract";
- while (is_running) {
+ tracker_db_prepare_queries (db_con);
- g_mutex_unlock (metadata_thread_mutex);
+ while (TRUE) {
- info = g_async_queue_try_pop (file_metadata_queue);
+ /* make thread sleep if first part of the shutdown process has been activated */
+ if (!tracker->is_running) {
- /* check pending table if we haven't got anything */
- if (!info) {
+ tracker_log ("metadata thread going to deep sleep...");
-
- /* we only check pending if we cannot lock mutex */
- if (g_mutex_trylock (metadata_available_mutex)) {
- g_mutex_unlock (metadata_available_mutex);
- g_usleep (100000);
+ g_cond_wait (tracker->metadata_thread_signal , tracker->metadata_signal_mutex);
+
+ /* determine if wake up call is new stuff or a shutdown signal */
+ if (!shutdown) {
continue;
- }
+ } else {
+ break;
+ }
- g_mutex_unlock (metadata_available_mutex);
+ }
- res = tracker_exec_proc (db_con.db, "GetPendingMetadataFiles", 0);
- if (res) {
- while ((row = mysql_fetch_row (res))) {
- FileInfo *info_tmp;
+ info = g_async_queue_try_pop (tracker->file_metadata_queue);
- info_tmp = tracker_create_file_info (row[1], atoi(row[2]), 0, WATCH_OTHER);
- info_tmp->file_id = atol (row[0]);
- info_tmp->mime = g_strdup (row[3]);
- g_async_queue_push (file_metadata_queue, info_tmp);
- has_pending = TRUE;
- }
- mysql_free_result (res);
- }
+ /* check pending table if we haven't got anything */
+ if (!info) {
- tracker_exec_proc (db_con.db, "RemovePendingMetadataFiles", 0);
+ /* set mutex to indicate we are in "check" state */
+ g_mutex_lock (tracker->metadata_check_mutex);
- /* relock mutex if more files still available */
- res = tracker_exec_proc (db_con.db, "CountPendingMetadataFiles", 0);
+ res = tracker_exec_proc (db_con, "CountPendingMetadataFiles", 0);
- if (res) {
+ has_pending = FALSE;
- row = mysql_fetch_row (res);
+ if (res) {
+ row = tracker_db_get_row (res, 0);
+
if (row && row[0]) {
int pending_file_count = atoi (row[0]);
+
+ has_pending = (pending_file_count > 0);
+ }
+
+ tracker_db_free_result (res);
- if (pending_file_count > 0) {
- g_mutex_trylock (metadata_available_mutex);
- //tracker_log ("%d files still pending metadata extraction...", pending_file_count);
- }
+ }
+
+ if (has_pending) {
+ g_mutex_unlock (tracker->metadata_check_mutex);
+ } else {
+ // tracker_log ("metadata thread sleeping");
+
+ /* we have no stuff to process so sleep until awoken by a new signal */
+ g_cond_wait (tracker->metadata_thread_signal , tracker->metadata_signal_mutex);
+ g_mutex_unlock (tracker->metadata_check_mutex);
+ // tracker_log ("metadata thread awoken");
+ /* determine if wake up call is new stuff or a shutdown signal */
+ if (!shutdown) {
+ continue;
+ } else {
+ break;
+ }
+
+ }
+
+ res = tracker_exec_proc (db_con, "GetPendingMetadataFiles", 0);
+
+ int k = 0;
+
+ if (res) {
+ while ((row = tracker_db_get_row (res, k))) {
+ FileInfo *info_tmp;
+
+ k++;
+ info_tmp = tracker_create_file_info (row[1], atoi(row[2]), 0, WATCH_OTHER);
+ info_tmp->file_id = atol (row[0]);
+ info_tmp->mime = g_strdup (row[3]);
+ g_async_queue_push (tracker->file_metadata_queue, info_tmp);
+
}
- mysql_free_result (res);
+ tracker_db_free_result (res);
}
+ tracker_exec_proc (db_con, "RemovePendingMetadataFiles", 0);
+
continue;
}
-
- g_mutex_lock (metadata_thread_mutex);
+
/* info struct may have been deleted in transit here so check if still valid and intact */
g_return_if_fail ( tracker_file_info_is_valid (info));
@@ -879,7 +971,7 @@ extract_metadata_thread ()
info = tracker_get_file_info (info);
if (info->file_id == -1) {
- info->file_id = (long)tracker_db_get_file_id (&db_con, info->uri);
+ info->file_id = (long)tracker_db_get_file_id (db_con, info->uri);
}
meta_table = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_free);
@@ -887,7 +979,7 @@ extract_metadata_thread ()
tracker_metadata_get_embedded (info->uri, info->mime, meta_table);
if (g_hash_table_size (meta_table) > 0) {
- tracker_db_save_metadata (&db_con, meta_table, info->file_id);
+ tracker_db_save_metadata (db_con, meta_table, info->file_id);
/* to do - emit dbus signal here for EmbeddedMetadataChanged */
@@ -904,7 +996,7 @@ extract_metadata_thread ()
if (large_thumb_file) {
- tracker_db_save_thumbs (&db_con, small_thumb_file, large_thumb_file, info->file_id);
+ tracker_db_save_thumbs (db_con, small_thumb_file, large_thumb_file, info->file_id);
/* to do - emit dbus signal ThumbNailChanged */
@@ -919,8 +1011,10 @@ extract_metadata_thread ()
if (file_as_text) {
//tracker_log ("text file is %s", file_as_text);
+
+
/* to do - we need a setting for an upper limit to how much text we read in */
- tracker_db_save_file_contents (&db_con, file_as_text, info->file_id);
+ tracker_db_save_file_contents (db_con, file_as_text, info->file_id);
/* clear up if text contents are in a temp file */
if (g_str_has_prefix (file_as_text, "/tmp/")) {
@@ -936,12 +1030,13 @@ extract_metadata_thread ()
info = tracker_dec_info_ref (info);
}
}
+ tracker_db_close (db_con);
+ tracker_db_thread_end ();
- mysql_close (db_con.db);
- mysql_thread_end ();
+ tracker_log ("metadata thread has exited successfully");
+ g_mutex_unlock (tracker->metadata_stopped_mutex);
+
- /* unlock mutex so we know thread has exited */
- g_mutex_unlock (metadata_thread_mutex);
}
@@ -1012,87 +1107,115 @@ static void
process_files_thread ()
{
FileInfo *info;
- DBConnection db_con;
+ DBConnection *db_con;
GSList *moved_from_list = NULL; /* list to hold moved_from events whilst waiting for a matching moved_to event */
gboolean need_index = FALSE, has_pending = FALSE;
- MYSQL_RES *res = NULL;
- MYSQL_ROW row;
+ char ***res = NULL;
+ char** row;
+
+ g_mutex_lock (tracker->files_signal_mutex);
+ g_mutex_lock (tracker->files_stopped_mutex);
/* set thread safe DB connection */
- mysql_thread_init ();
+ tracker_db_thread_init ();
- /* used to indicate if no db action is occuring in thread */
- g_mutex_lock (process_thread_mutex);
+ db_con = tracker_db_connect ();
- db_con.db = tracker_db_connect ();
+ db_con->thread = "files";
+ while (TRUE) {
+
+ /* make thread sleep if first part of the shutdown process has been activated */
+ if (!tracker->is_running) {
- while (is_running) {
+ tracker_log ("files thread going to deep sleep...");
+
+ g_cond_wait (tracker->file_thread_signal , tracker->files_signal_mutex);
+
+ /* determine if wake up call is new stuff or a shutdown signal */
+ if (!shutdown) {
+ continue;
+ } else {
+ break;
+ }
+
+ }
- g_mutex_unlock (process_thread_mutex);
- info = g_async_queue_try_pop (file_process_queue);
+ info = g_async_queue_try_pop (tracker->file_process_queue);
/* check pending table if we haven't got anything */
if (!info) {
+ /* set mutex to indicate we are in "check" state */
+ g_mutex_lock (tracker->files_check_mutex);
- /* we only check pending if we cannot lock mutex (this mutex is used as a flag to indicate if data could be available) */
- if (g_mutex_trylock (files_available_mutex)) {
- g_mutex_unlock (files_available_mutex);
- g_usleep (100000);
- continue;
- }
-
- g_mutex_unlock (files_available_mutex);
+ res = tracker_exec_proc (db_con, "ExistsPendingFiles", 0);
- res = tracker_exec_proc (db_con.db, "GetPendingFiles", 0);
+ has_pending = FALSE;
if (res) {
- while ((row = mysql_fetch_row (res))) {
- FileInfo *info_tmp;
- TrackerChangeAction tmp_action = atoi(row[2]);
+ row = tracker_db_get_row (res, 0);
+
+ if (row && row[0]) {
+ int pending_file_count = atoi (row[0]);
+
+ has_pending = (pending_file_count > 0);
+ }
+
+ tracker_db_free_result (res);
- if (tmp_action != TRACKER_ACTION_CHECK) {
- tracker_log ("processing %s with event %s", row[1], tracker_actions[tmp_action]);
- }
+ }
- info_tmp = tracker_create_file_info (row[1], tmp_action, 0, WATCH_OTHER);
- g_async_queue_push (file_process_queue, info_tmp);
- has_pending = TRUE;
- }
- mysql_free_result (res);
+ if (has_pending) {
+ g_mutex_unlock (tracker->files_check_mutex);
+ } else {
+ //tracker_log ("File thread sleeping");
+
+ /* we have no stuff to process so sleep until awoken by a new signal */
+ g_cond_wait (tracker->file_thread_signal , tracker->files_signal_mutex);
+ g_mutex_unlock (tracker->files_check_mutex);
+ //tracker_log ("File thread awoken");
+ /* determine if wake up call is new stuff or a shutdown signal */
+ if (!shutdown) {
+ continue;
+ } else {
+ break;
+ }
+
}
- tracker_exec_proc (db_con.db, "RemovePendingFiles", 0);
+ res = tracker_exec_proc (db_con, "GetPendingFiles", 0);
- /* relock mutex if more files still available */
- res = tracker_exec_proc (db_con.db, "ExistsPendingFiles", 0);
+ int k = 0;
if (res) {
+ while ((row = tracker_db_get_row (res, k))) {
+ FileInfo *info_tmp;
- row = mysql_fetch_row (res);
-
- if (row && row[0]) {
- int pending_file_count = atoi (row[0]);
+ k++;
+
+ TrackerChangeAction tmp_action = atoi(row[2]);
- if (pending_file_count > 0) {
- g_mutex_trylock (files_available_mutex);
-
+ if (tmp_action != TRACKER_ACTION_CHECK) {
+ tracker_log ("processing %s with event %s", row[1], tracker_actions[tmp_action]);
}
- }
- mysql_free_result (res);
+ info_tmp = tracker_create_file_info (row[1], tmp_action, 0, WATCH_OTHER);
+ g_async_queue_push (tracker->file_process_queue, info_tmp);
+
+ }
+ tracker_db_free_result (res);
}
+ tracker_exec_proc (db_con, "RemovePendingFiles", 0);
+
continue;
}
- g_mutex_lock (process_thread_mutex);
-
/* info struct may have been deleted in transit here so check if still valid and intact */
if (!tracker_file_info_is_valid (info)) {
continue;
@@ -1105,7 +1228,7 @@ process_files_thread ()
if (info->file_id == -1 && info->action != TRACKER_ACTION_CREATE &&
info->action != TRACKER_ACTION_DIRECTORY_CREATED && info->action != TRACKER_ACTION_FILE_CREATED) {
- info = tracker_db_get_file_info (&db_con, info);
+ info = tracker_db_get_file_info (db_con, info);
}
@@ -1125,7 +1248,7 @@ process_files_thread ()
if (info->action == TRACKER_ACTION_FILE_DELETED || info->action == TRACKER_ACTION_FILE_MOVED_FROM) {
- delete_file (&db_con, info);
+ delete_file (db_con, info);
if (info->action == TRACKER_ACTION_FILE_MOVED_FROM) {
moved_from_list = g_slist_prepend (moved_from_list, info);
@@ -1138,7 +1261,7 @@ process_files_thread ()
} else {
if (info->action == TRACKER_ACTION_DIRECTORY_DELETED || info->action == TRACKER_ACTION_DIRECTORY_MOVED_FROM) {
- delete_directory (&db_con, info);
+ delete_directory (db_con, info);
if (info->action == TRACKER_ACTION_DIRECTORY_MOVED_FROM) {
moved_from_list = g_slist_prepend (moved_from_list, info);
@@ -1186,8 +1309,8 @@ process_files_thread ()
case TRACKER_ACTION_DIRECTORY_CHECK :
if (need_index ) {
- if (g_slist_find_custom (no_watch_directory_list, info->uri, (GCompareFunc) has_prefix) == NULL) {
- scan_directory (info->uri, &db_con);
+ if (g_slist_find_custom (tracker->no_watch_directory_list, info->uri, (GCompareFunc) has_prefix) == NULL) {
+ scan_directory (info->uri, db_con);
} else {
tracker_log ("blocked scan of directory %s as its in the no watch list", info->uri);
}
@@ -1197,8 +1320,8 @@ process_files_thread ()
case TRACKER_ACTION_DIRECTORY_REFRESH :
- if (g_slist_find_custom (no_watch_directory_list, info->uri, (GCompareFunc) has_prefix) == NULL) {
- scan_directory (info->uri, &db_con);
+ if (g_slist_find_custom (tracker->no_watch_directory_list, info->uri, (GCompareFunc) has_prefix) == NULL) {
+ scan_directory (info->uri, db_con);
} else {
tracker_log ("blocked scan of directory %s as its in the no watch list", info->uri);
}
@@ -1213,13 +1336,13 @@ process_files_thread ()
/* add to watch folders (including subfolders) */
- watch_dir (info->uri, &db_con);
+ watch_dir (info->uri, db_con);
/* schedule a rescan for all files in folder to avoid race conditions */
if (info->action == TRACKER_ACTION_DIRECTORY_CREATED) {
- if (g_slist_find_custom (no_watch_directory_list, info->uri, (GCompareFunc) has_prefix) == NULL) {
- scan_directory (info->uri, &db_con);
+ if (g_slist_find_custom (tracker->no_watch_directory_list, info->uri, (GCompareFunc) has_prefix) == NULL) {
+ scan_directory (info->uri, db_con);
} else {
tracker_log ("blocked scan of directory %s as its in the no watch list", info->uri);
}
@@ -1235,49 +1358,86 @@ process_files_thread ()
}
if (need_index) {
- index_file (&db_con, info);
+ index_file (db_con, info);
}
info = tracker_dec_info_ref (info);
}
+ tracker_db_close (db_con);
+ tracker_db_thread_end ();
+ tracker_log ("files thread has exited successfully");
+ g_mutex_unlock (tracker->files_stopped_mutex);
+
- mysql_close (db_con.db);
- mysql_thread_end ();
-
- /* unlock mutex so we know thread has exited */
- g_mutex_unlock (process_thread_mutex);
}
static void
-process_user_request_queue_thread (GMutex *mutex)
+process_user_request_queue_thread ()
{
DBusRec *rec;
- DBConnection db_con;
+ DBConnection *db_con;
+
+ g_mutex_lock (tracker->request_signal_mutex);
+ g_mutex_lock (tracker->request_stopped_mutex);
/* set thread safe DB connection */
- mysql_thread_init ();
+ tracker_db_thread_init ();
- /* set mutex so we know if the thread is still processing */
- g_mutex_lock (mutex);
+ db_con = tracker_db_connect ();
- db_con.db = tracker_db_connect ();
+ db_con->thread = "request";
- tracker_exec_proc (db_con.db, "PrepareQueries", 0);
+ tracker_exec_proc (db_con, "PrepareQueries", 0);
+ while (TRUE) {
+
+ DBusMessage *reply;
- while (is_running) {
+ /* make thread sleep if first part of the shutdown process has been activated */
+ if (!tracker->is_running) {
- DBusMessage *reply;
+ tracker_log ("request thread going to deep sleep...");
- g_mutex_unlock (mutex);
-
- rec = g_async_queue_pop (user_request_queue);
+ g_cond_wait (tracker->request_thread_signal , tracker->request_signal_mutex);
+
+ /* determine if wake up call is new stuff or a shutdown signal */
+ if (!shutdown) {
+ continue;
+ } else {
+ break;
+ }
+
+ }
+
+ /* lock check mutex to prevent race condition when a request is submitted after popping queue but prior to sleeping */
+ g_mutex_lock (tracker->request_check_mutex);
- rec->user_data = &db_con;
+ rec = g_async_queue_try_pop (tracker->user_request_queue);
- g_mutex_lock (mutex);
+ if (!rec) {
+
+ //tracker_log ("request thread sleeping");
+ g_cond_wait (tracker->request_thread_signal , tracker->request_signal_mutex);
+ g_mutex_unlock (tracker->request_check_mutex);
+ //tracker_log ("request thread awoken");
+
+ /* determine if wake up call is new stuff or a shutdown signal */
+ if (!shutdown) {
+ continue;
+ } else {
+ break;
+ }
+
+ }
+
+
+ /* thread will not sleep without another iteration so race condition no longer applies */
+ g_mutex_unlock (tracker->request_check_mutex);
+
+
+ rec->user_data = db_con;
switch (rec->action) {
@@ -1545,11 +1705,14 @@ process_user_request_queue_thread (GMutex *mutex)
}
- mysql_close (db_con.db);
- mysql_thread_end ();
+ tracker_db_close (db_con);
+ tracker_db_thread_end ();
+
+ tracker_log ("request thread has exited successfully");
/* unlock mutex so we know thread has exited */
- g_mutex_unlock (mutex);
+ g_mutex_unlock (tracker->request_check_mutex);
+ g_mutex_unlock (tracker->request_stopped_mutex);
}
@@ -1561,10 +1724,10 @@ main (int argc, char **argv)
sigset_t empty_mask;
char *prefix, *lock_file, *str, *lock_str, *tracker_data_dir;
- GThread *file_metadata_thread, *file_process_thread, *user_request_thread1;
+
gboolean need_setup = FALSE;
- DBConnection db_con;
+ DBConnection *db_con;
/* set timezone info */
@@ -1577,9 +1740,7 @@ main (int argc, char **argv)
g_print ("Initialising tracker...\n");
- /* mysql vars */
- static char **server_options;
- static char *server_groups[] = {"libmysqd_server", "libmysqd_client", NULL};
+
if (!g_thread_supported ()) {
g_thread_init (NULL);
@@ -1587,11 +1748,43 @@ main (int argc, char **argv)
dbus_g_thread_init ();
- /* Set up mutexes for initialisation */
- g_assert (log_access_mutex == NULL);
- log_access_mutex = g_mutex_new ();
- g_assert (scheduler_mutex == NULL);
- scheduler_mutex = g_mutex_new ();
+ tracker = g_new (Tracker, 1);
+
+ tracker->watch_directory_roots_list = NULL;
+ tracker->no_watch_directory_list = NULL;
+ tracker->poll_list = NULL;
+ tracker->use_nfs_safe_locking = FALSE;
+
+ tracker->is_running = FALSE;
+
+ tracker->poll_access_mutex = g_mutex_new ();
+
+ tracker->files_check_mutex = g_mutex_new ();
+ tracker->metadata_check_mutex = g_mutex_new ();
+ tracker->request_check_mutex = g_mutex_new ();
+
+ tracker->files_stopped_mutex = g_mutex_new ();
+ tracker->metadata_stopped_mutex = g_mutex_new ();
+ tracker->request_stopped_mutex = g_mutex_new ();
+ tracker->poll_stopped_mutex = g_mutex_new ();
+
+ tracker->file_metadata_thread = NULL;
+ tracker->file_process_thread = NULL;
+ tracker->user_request_thread = NULL;;
+ tracker->file_poll_thread = NULL;
+
+ tracker->file_thread_signal = g_cond_new ();
+ tracker->metadata_thread_signal = g_cond_new ();
+ tracker->request_thread_signal = g_cond_new ();
+ tracker->poll_thread_signal = g_cond_new ();
+
+ tracker->metadata_signal_mutex = g_mutex_new ();
+ tracker->files_signal_mutex = g_mutex_new ();
+ tracker->request_signal_mutex = g_mutex_new ();
+ tracker->poll_signal_mutex = g_mutex_new ();
+
+ tracker->log_access_mutex = g_mutex_new ();
+ tracker->scheduler_mutex = g_mutex_new ();
/* check user data files */
@@ -1623,19 +1816,16 @@ main (int argc, char **argv)
umask(077);
-
-
-
prefix = g_build_filename (g_get_home_dir (), ".Tracker", NULL);
str = g_strconcat ( g_get_user_name (), "_tracker_lock", NULL);
- log_file = g_build_filename (prefix, "tracker.log", NULL);
+ tracker->log_file = g_build_filename (prefix, "tracker.log", NULL);
/* check if setup for NFS usage (and enable atomic NFS safe locking) */
//lock_str = tracker_get_config_option ("NFSLocking");
lock_str = NULL;
if (lock_str != NULL) {
- use_nfs_safe_locking = ( strcmp (str , "1" ) == 0);
+ tracker->use_nfs_safe_locking = ( strcmp (str , "1" ) == 0);
/* place lock file in tmp dir to allow multiple sessions on NFS */
lock_file = g_build_filename ("/tmp", str , NULL);
@@ -1644,7 +1834,7 @@ main (int argc, char **argv)
} else {
- use_nfs_safe_locking = FALSE;
+ tracker->use_nfs_safe_locking = FALSE;
/* place lock file in home dir to prevent multiple sessions on NFS (as standard locking might be broken on NFS) */
lock_file = g_build_filename (prefix , str , NULL);
@@ -1673,8 +1863,8 @@ main (int argc, char **argv)
/* reset log file */
- if (g_file_test (log_file, G_FILE_TEST_EXISTS)) {
- unlink (log_file);
+ if (g_file_test (tracker->log_file, G_FILE_TEST_EXISTS)) {
+ unlink (tracker->log_file);
}
@@ -1682,7 +1872,7 @@ main (int argc, char **argv)
sigemptyset (&empty_mask);
act.sa_handler = signal_handler;
act.sa_mask = empty_mask;
- act.sa_flags = 0;
+ act.sa_flags = SA_NODEFER;
sigaction (SIGTERM, &act, NULL);
sigaction (SIGILL, &act, NULL);
sigaction (SIGBUS, &act, NULL);
@@ -1696,38 +1886,16 @@ main (int argc, char **argv)
tracker_load_config_file ();
- str = g_strdup (DATADIR "/tracker/english");
- if (!tracker_file_is_valid (str)) {
- g_warning ("could not open mysql language file %s", str);
- }
-
- /* initialise embedded mysql with options*/
- server_options = g_new (char *, 11);
- server_options[0] = "anything";
- server_options[1] = g_strconcat ("--datadir=", tracker_data_dir, NULL);
- server_options[2] = "--myisam-recover=FORCE";
- server_options[3] = "--skip-grant-tables";
- server_options[4] = "--skip-innodb";
- server_options[5] = "--key_buffer_size=1M";
- server_options[6] = "--character-set-server=utf8";
- server_options[7] = "--ft_max_word_len=45";
- server_options[8] = "--ft_min_word_len=3";
- server_options[9] = "--ft_stopword_file=" DATADIR "/tracker/tracker-stop-words.txt";
- server_options[10] = g_strconcat ("--language=", str, NULL);
-
-
- mysql_server_init ( 11, server_options, server_groups);
-
- if (mysql_get_client_version () < 50019) {
- g_warning ("The currently installed version of mysql is too outdated (you need 5.0.19 or higher). Exiting...");
+
+ if (!tracker_db_initialize (tracker_data_dir) ) {
+ tracker_log ("Failed to initialise database engine - exiting...");
return 1;
}
-
-
- tracker_log ("DB initialised - embedded mysql version is %d", mysql_get_client_version () );
+ /* create and initialise indexer */
+ //file_indexer = tracker_indexer_open ("Files");
- g_free (str);
+
g_free (tracker_data_dir);
@@ -1741,35 +1909,43 @@ main (int argc, char **argv)
/* set thread safe DB connection */
- mysql_thread_init ();
+ tracker_db_thread_init ();
+
+ db_con = tracker_db_connect ();
+ db_con->thread = "main";
- db_con.db = tracker_db_connect ();
+
- if (tracker_update_db (db_con.db)) {
+ if (tracker_update_db (db_con)) {
/* refresh connection as DB might have been rebuilt */
- mysql_close (db_con.db);
- db_con.db = tracker_db_connect ();
- tracker_db_load_stored_procs (db_con.db);
+ tracker_db_close (db_con);
+ db_con = tracker_db_connect ();
+ db_con->thread = "main";
+ tracker_db_load_stored_procs (db_con);
}
/* clear pending files and watch tables*/
- tracker_exec_sql (db_con.db, "TRUNCATE TABLE FilePending");
- tracker_exec_sql (db_con.db, "TRUNCATE TABLE FileWatches");
+ tracker_exec_sql (db_con, "TRUNCATE TABLE FilePending");
+ tracker_exec_sql (db_con, "TRUNCATE TABLE FileWatches");
- MYSQL_RES *res = NULL;
- MYSQL_ROW row;
+ char ***res = NULL;
+ char** row;
- res = tracker_exec_proc (db_con.db, "GetStats", 0);
+ res = tracker_exec_proc (db_con, "GetStats", 0);
if (res) {
tracker_log ("-----------------------");
tracker_log ("Fetching index stats...");
- while ((row = mysql_fetch_row (res))) {
-
+ int k = 0;
+
+ while ((row = tracker_db_get_row (res, k))) {
+
+ k++;
+
if (row[2]) {
tracker_log ("%s : %s (%s%s)", row[0], row[1], row[2], "%");
} else {
@@ -1778,28 +1954,32 @@ main (int argc, char **argv)
}
- mysql_free_result (res);
+ tracker_db_free_result (res);
tracker_log ("-----------------------\n");
}
+
+
+ tracker_db_check_tables (db_con);
/*
//const char *query = " <rdfq:Condition> <rdfq:or><rdfq:and><rdfq:greaterThan><rdfq:Property name=\"Audio.ReleaseDate\" /><rdf:Integer>1979</rdf:Integer></rdfq:greaterThan></rdfq:and> <rdfq:contains><rdfq:Property name=\"Audio.Title\" /><rdf:String>Rain</rdf:String></rdfq:contains></rdfq:or></rdfq:Condition>";
const char *query = " <rdfq:Condition><rdfq:contains><rdfq:Property name=\"File.Name\" /><rdf:String>Rain</rdf:String></rdfq:contains></rdfq:Condition>";
- char *stsql = tracker_rdf_query_to_sql (&db_con, query, "Files", NULL, 0, "mp3", FALSE, 100 , NULL);
+ char *stsql = tracker_rdf_query_to_sql (db_con, query, "Files", NULL, 0, "mp3", FALSE, 100 , NULL);
tracker_log (stsql);
- tracker_log_sql (db_con.db, g_strconcat ("Explain ", stsql, NULL));
- tracker_log_sql (db_con.db, stsql);
+ tracker_log_sql (db_con, g_strconcat ("Explain ", stsql, NULL));
+ tracker_log_sql (db_con, stsql);
*/
- main_thread_db_con = &db_con;
- file_scheduler = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL);
- file_metadata_queue = g_async_queue_new ();
- file_process_queue = g_async_queue_new ();
- file_pending_queue = g_async_queue_new ();
- user_request_queue = g_async_queue_new ();
+ main_thread_db_con = db_con;
+
+ tracker->file_scheduler = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL);
+
+ tracker->file_metadata_queue = g_async_queue_new ();
+ tracker->file_process_queue = g_async_queue_new ();
+ tracker->user_request_queue = g_async_queue_new ();
/* periodically poll directories for changes */
@@ -1811,32 +1991,14 @@ main (int argc, char **argv)
- loop = g_main_loop_new (NULL, TRUE);
+ tracker->loop = g_main_loop_new (NULL, TRUE);
main_connection = tracker_dbus_init ();
/* this var is used to tell the threads when to quit */
- is_running = TRUE;
-
- /* thread mutexes - so we know when a thread is not busy */
- g_assert (process_thread_mutex == NULL);
- process_thread_mutex = g_mutex_new ();
+ tracker->is_running = TRUE;
- g_assert (metadata_thread_mutex == NULL);
- metadata_thread_mutex = g_mutex_new ();
- g_assert (user_thread1_mutex == NULL);
- user_thread1_mutex = g_mutex_new ();
-
- g_assert (user_thread2_mutex == NULL);
- user_thread2_mutex = g_mutex_new ();
-
- g_assert (poll_thread_mutex == NULL);
- poll_thread_mutex = g_mutex_new ();
-
- /* data available mutexes */
- metadata_available_mutex = g_mutex_new ();
- files_available_mutex = g_mutex_new ();
/* schedule the watching of directories so as not to delay start up time*/
@@ -1858,19 +2020,22 @@ main (int argc, char **argv)
/* execute events and user requests to be processed and indexed in their own threads */
- file_process_thread = g_thread_create ((GThreadFunc) process_files_thread, NULL, FALSE, NULL);
- file_metadata_thread = g_thread_create ((GThreadFunc) extract_metadata_thread, NULL, FALSE, NULL);
- user_request_thread1 = g_thread_create ((GThreadFunc) process_user_request_queue_thread, user_thread1_mutex, FALSE, NULL);
+ tracker->file_process_thread = g_thread_create ((GThreadFunc) process_files_thread, NULL, TRUE, NULL);
+ tracker->file_metadata_thread = g_thread_create ((GThreadFunc) extract_metadata_thread, NULL, TRUE, NULL);
+ tracker->user_request_thread = g_thread_create ((GThreadFunc) process_user_request_queue_thread, NULL, TRUE, NULL);
- g_main_loop_run (loop);
+ g_main_loop_run (tracker->loop);
- mysql_close (db_con.db);
+ /* the following should never be reached in practice */
+ tracker_log ("we should never get this message");
+
+ tracker_db_close (db_con);
- mysql_thread_end ();
+ tracker_db_thread_end ();
tracker_dbus_shutdown (main_connection);
do_cleanup ();
- return 0;
+ return EXIT_SUCCESS;
}
diff --git a/thumbnailers/application/Makefile.am b/thumbnailers/application/Makefile.am
index e693a7d29..05e9ac6c5 100644
--- a/thumbnailers/application/Makefile.am
+++ b/thumbnailers/application/Makefile.am
@@ -2,5 +2,4 @@ thumbappbindir = $(datadir)/tracker/thumbnailers/application
thumbappbin_SCRIPTS = pdf_thumbnailer
-
-
+EXTRA_DIST = $(thumbappbin_SCRIPTS)