tracker r1849 - in branches/xesam-support: . data data/dbus data/modules src/libtracker-common src/libtracker-db src/tracker-indexer src/tracker-indexer/modules src/trackerd tests tests/common tests/libtracker-common tests/libtracker-db tests/tracker-indexer tests/trackerd
- From: pvanhoof svn gnome org
- To: svn-commits-list gnome org
- Subject: tracker r1849 - in branches/xesam-support: . data data/dbus data/modules src/libtracker-common src/libtracker-db src/tracker-indexer src/tracker-indexer/modules src/trackerd tests tests/common tests/libtracker-common tests/libtracker-db tests/tracker-indexer tests/trackerd
- Date: Thu, 3 Jul 2008 14:55:07 +0000 (UTC)
Author: pvanhoof
Date: Thu Jul 3 14:55:07 2008
New Revision: 1849
URL: http://svn.gnome.org/viewvc/tracker?rev=1849&view=rev
Log:
2008-07-03 Philip Van Hoof <pvanhoof gnome org>
* svn merge -r 1797:1847 ../indexer-split
Added:
branches/xesam-support/src/trackerd/tracker-processor.c
- copied unchanged from r1847, /branches/indexer-split/src/trackerd/tracker-processor.c
branches/xesam-support/src/trackerd/tracker-processor.h
- copied unchanged from r1847, /branches/indexer-split/src/trackerd/tracker-processor.h
branches/xesam-support/tests/libtracker-common/tracker-file-utils-test.c
- copied unchanged from r1847, /branches/indexer-split/tests/libtracker-common/tracker-file-utils-test.c
branches/xesam-support/tests/tracker-indexer/
- copied from r1847, /branches/indexer-split/tests/tracker-indexer/
Removed:
branches/xesam-support/src/trackerd/tracker-process.c
branches/xesam-support/src/trackerd/tracker-process.h
Modified:
branches/xesam-support/ChangeLog
branches/xesam-support/configure.ac
branches/xesam-support/data/dbus/tracker-indexer.xml
branches/xesam-support/data/modules/applications.module
branches/xesam-support/data/modules/evolution.module
branches/xesam-support/data/modules/files.module
branches/xesam-support/data/sqlite-stored-procs.sql
branches/xesam-support/src/libtracker-common/tracker-config.c
branches/xesam-support/src/libtracker-common/tracker-config.h
branches/xesam-support/src/libtracker-common/tracker-dbus.c
branches/xesam-support/src/libtracker-common/tracker-dbus.h
branches/xesam-support/src/libtracker-common/tracker-file-utils.c
branches/xesam-support/src/libtracker-common/tracker-hal.c
branches/xesam-support/src/libtracker-common/tracker-log.c
branches/xesam-support/src/libtracker-common/tracker-module-config.c
branches/xesam-support/src/libtracker-common/tracker-module-config.h
branches/xesam-support/src/libtracker-common/tracker-ontology.c
branches/xesam-support/src/libtracker-common/tracker-service.h
branches/xesam-support/src/libtracker-common/tracker-utils.c
branches/xesam-support/src/libtracker-common/tracker-utils.h
branches/xesam-support/src/libtracker-db/tracker-db-dbus.c
branches/xesam-support/src/libtracker-db/tracker-db-manager.c
branches/xesam-support/src/libtracker-db/tracker-db-manager.h
branches/xesam-support/src/tracker-indexer/modules/Makefile.am
branches/xesam-support/src/tracker-indexer/modules/applications.c
branches/xesam-support/src/tracker-indexer/modules/dummy.c
branches/xesam-support/src/tracker-indexer/modules/evolution.c
branches/xesam-support/src/tracker-indexer/modules/files.c
branches/xesam-support/src/tracker-indexer/modules/gaim-conversations.c
branches/xesam-support/src/tracker-indexer/tracker-index.c
branches/xesam-support/src/tracker-indexer/tracker-indexer-db.c
branches/xesam-support/src/tracker-indexer/tracker-indexer-db.h
branches/xesam-support/src/tracker-indexer/tracker-indexer-module.c
branches/xesam-support/src/tracker-indexer/tracker-indexer-module.h
branches/xesam-support/src/tracker-indexer/tracker-indexer.c
branches/xesam-support/src/tracker-indexer/tracker-indexer.h
branches/xesam-support/src/tracker-indexer/tracker-main.c
branches/xesam-support/src/tracker-indexer/tracker-module.h
branches/xesam-support/src/trackerd/Makefile.am
branches/xesam-support/src/trackerd/tracker-crawler.c
branches/xesam-support/src/trackerd/tracker-crawler.h
branches/xesam-support/src/trackerd/tracker-daemon.c
branches/xesam-support/src/trackerd/tracker-db.c
branches/xesam-support/src/trackerd/tracker-db.h
branches/xesam-support/src/trackerd/tracker-files.c
branches/xesam-support/src/trackerd/tracker-indexer.c
branches/xesam-support/src/trackerd/tracker-keywords.c
branches/xesam-support/src/trackerd/tracker-main.c
branches/xesam-support/src/trackerd/tracker-main.h
branches/xesam-support/src/trackerd/tracker-marshal.list
branches/xesam-support/src/trackerd/tracker-metadata.c
branches/xesam-support/src/trackerd/tracker-monitor.c
branches/xesam-support/src/trackerd/tracker-search.c
branches/xesam-support/src/trackerd/tracker-utils.c
branches/xesam-support/src/trackerd/tracker-xesam-live-search.c
branches/xesam-support/src/trackerd/tracker-xesam-manager.c
branches/xesam-support/tests/Makefile.am
branches/xesam-support/tests/common/tracker-test-helpers.c
branches/xesam-support/tests/common/tracker-test-helpers.h
branches/xesam-support/tests/libtracker-common/Makefile.am
branches/xesam-support/tests/libtracker-common/non-utf8.txt
branches/xesam-support/tests/libtracker-common/tracker-dbus-test.c
branches/xesam-support/tests/libtracker-common/tracker-ontology-test.c
branches/xesam-support/tests/libtracker-common/tracker-type-utils-test.c
branches/xesam-support/tests/libtracker-db/tracker-db-manager-common.c
branches/xesam-support/tests/libtracker-db/tracker-db-manager-common.h
branches/xesam-support/tests/libtracker-db/tracker-db-manager-test-attach.c
branches/xesam-support/tests/libtracker-db/tracker-db-manager-test-custom.c
branches/xesam-support/tests/libtracker-db/tracker-db-manager-test-unattach.c
branches/xesam-support/tests/libtracker-db/union-performance.c
branches/xesam-support/tests/trackerd/tracker-xesam-hit-test.h
branches/xesam-support/tests/trackerd/tracker-xesam-hits-test.h
branches/xesam-support/tests/trackerd/tracker-xesam-session-test.h
branches/xesam-support/tests/trackerd/tracker-xesam-test.c
branches/xesam-support/tests/trackerd/tracker-xesam-test.h
Modified: branches/xesam-support/configure.ac
==============================================================================
--- branches/xesam-support/configure.ac (original)
+++ branches/xesam-support/configure.ac Thu Jul 3 14:55:07 2008
@@ -83,6 +83,13 @@
AC_SUBST(LIBPNG_CFLAGS)
AC_SUBST(LIBPNG_LIBS)
+# Check for GConf
+PKG_CHECK_MODULES(GCONF, [ gconf-2.0 >= 2.2.0 ], have_gconf=yes, have_gconf=no)
+AC_SUBST(GCONF_CFLAGS)
+AC_SUBST(GCONF_LIBS)
+
+AM_CONDITIONAL(HAVE_GCONF, test "$have_gconf" = "yes")
+
# Check we have the DBUS binding tool we need
AC_PATH_PROG(DBUSBINDINGTOOL, dbus-binding-tool)
if test -z $DBUSBINDINGTOOL; then
@@ -740,6 +747,7 @@
src/tracker-preferences/tracker-preferences.desktop.in
src/trackerd/Makefile
tests/Makefile
+ tests/tracker-indexer/Makefile
tests/common/Makefile
tests/libtracker-common/Makefile
tests/trackerd/Makefile
Modified: branches/xesam-support/data/dbus/tracker-indexer.xml
==============================================================================
--- branches/xesam-support/data/dbus/tracker-indexer.xml (original)
+++ branches/xesam-support/data/dbus/tracker-indexer.xml Thu Jul 3 14:55:07 2008
@@ -18,12 +18,15 @@
</method>
<method name="FilesCheck">
+ <arg type="s" name="module" direction="in" />
<arg type="as" name="files" direction="in" />
</method>
<method name="FilesUpdate">
+ <arg type="s" name="module" direction="in" />
<arg type="as" name="files" direction="in" />
</method>
<method name="FilesDelete">
+ <arg type="s" name="module" direction="in" />
<arg type="as" name="files" direction="in" />
</method>
Modified: branches/xesam-support/data/modules/applications.module
==============================================================================
--- branches/xesam-support/data/modules/applications.module (original)
+++ branches/xesam-support/data/modules/applications.module Thu Jul 3 14:55:07 2008
@@ -4,7 +4,7 @@
[Monitors]
Directories=
-RecurseDirectories=/usr/share;
+RecurseDirectories=/usr/share/applications;
[Ignored]
Directories=
Modified: branches/xesam-support/data/modules/evolution.module
==============================================================================
--- branches/xesam-support/data/modules/evolution.module (original)
+++ branches/xesam-support/data/modules/evolution.module Thu Jul 3 14:55:07 2008
@@ -4,7 +4,7 @@
[Monitors]
Directories=
-RecurseDirectories=
+RecurseDirectories=$HOME/.evolution/mail/local/;$HOME/.evolution/mail/imap/
[Ignored]
Directories=
Modified: branches/xesam-support/data/modules/files.module
==============================================================================
--- branches/xesam-support/data/modules/files.module (original)
+++ branches/xesam-support/data/modules/files.module Thu Jul 3 14:55:07 2008
@@ -4,7 +4,7 @@
[Monitors]
Directories=
-RecurseDirectories=
+RecurseDirectories=$HOME;
[Ignored]
Directories=po;CVS;.svn;.git
Modified: branches/xesam-support/data/sqlite-stored-procs.sql
==============================================================================
--- branches/xesam-support/data/sqlite-stored-procs.sql (original)
+++ branches/xesam-support/data/sqlite-stored-procs.sql Thu Jul 3 14:55:07 2008
@@ -78,7 +78,7 @@
DeleteEmbeddedServiceMetadata2 DELETE FROM ServiceKeywordMetaData WHERE ServiceID = ? and MetaDataID in (select ID from MetaDataTypes where Embedded = 1);
DeleteEmbeddedServiceMetadata3 DELETE FROM ServiceNumericMetaData WHERE ServiceID = ? and MetaDataID in (select ID from MetaDataTypes where Embedded = 1);
-GetByServiceType SELECT DISTINCT F.Path || '/' || F.Name as uri FROM Services F WHERE F.ServiceTypeID in (select TypeId from common.ServiceTypes where TypeName = ? or Parent = ?) LIMIT ?,?;
+GetByServiceType SELECT DISTINCT F.Path || '/' || F.Name as uri FROM Services F WHERE F.ServiceTypeID in (select TypeId from ServiceTypes where TypeName = ? or Parent = ?) LIMIT ?,?;
SaveServiceContents REPLACE into ServiceContents (ServiceID, MetadataID, Content) values (?,?,compress (?));
DeleteContent DELETE FROM ServiceContents where ServiceID = ? and MetadataId = ?;
@@ -218,4 +218,4 @@
InsertXesamMimePrefixes replace into XesamFileMimePrefixes (MimePrefix) Values (?);
GetXesamMimeForServiceId select Mime from XesamFileMimes where ServiceTypeId = ?;
-GetXesamMimePrefixForServiceId select MimePrefix from XesamFileMimePrefixes where ServiceTypeId = ?;
\ No newline at end of file
+GetXesamMimePrefixForServiceId select MimePrefix from XesamFileMimePrefixes where ServiceTypeId = ?;
Modified: branches/xesam-support/src/libtracker-common/tracker-config.c
==============================================================================
--- branches/xesam-support/src/libtracker-common/tracker-config.c (original)
+++ branches/xesam-support/src/libtracker-common/tracker-config.c Thu Jul 3 14:55:07 2008
@@ -62,10 +62,6 @@
#define KEY_LOW_DISK_SPACE_LIMIT "LowDiskSpaceLimit"
#define KEY_INDEX_MOUNTED_DIRECTORIES "IndexMountedDirectories"
#define KEY_INDEX_REMOVABLE_DEVICES "IndexRemovableMedia"
-#define KEY_INDEX_MODULES "IndexModules"
-
-#define GROUP_EMAILS "Emails"
-#define KEY_EMAIL_CLIENT "IndexEMailClient"
#define GROUP_PERFORMANCE "Performance"
#define KEY_MAX_TEXT_TO_INDEX "MaxTextToIndex"
@@ -76,7 +72,6 @@
#define KEY_DIVISIONS "Divisions"
#define KEY_BUCKET_RATIO "BucketRatio"
#define KEY_PADDING "Padding"
-#define KEY_THREAD_STACK_SIZE "ThreadStackSize"
#define GROUP_SERVICES "Services"
#define KEY_ENABLE_XESAM "EnableXesam"
@@ -84,7 +79,7 @@
/* Default values */
#define DEFAULT_VERBOSITY 0
#define DEFAULT_INITIAL_SLEEP 45 /* 0->1000 */
-#define DEFAULT_LOW_MEMORY_MODE TRUE
+#define DEFAULT_LOW_MEMORY_MODE FALSE
#define DEFAULT_NFS_LOCKING FALSE
#define DEFAULT_ENABLE_WATCHES TRUE
#define DEFAULT_THROTTLE 0 /* 0->20 */
@@ -100,8 +95,6 @@
#define DEFAULT_DISABLE_INDEXING_ON_BATTERY_INIT FALSE
#define DEFAULT_INDEX_MOUNTED_DIRECTORIES TRUE
#define DEFAULT_INDEX_REMOVABLE_DEVICES TRUE
-#define DEFAULT_INDEX_MODULES "applications;files;gaim-conversations;firefox-history"
-#define DEFAULT_INDEX_EMAIL_CLIENT "evolution"
#define DEFAULT_LOW_DISK_SPACE_LIMIT 1 /* 0->100 / -1 */
#define DEFAULT_MAX_TEXT_TO_INDEX 1048576 /* Bytes */
#define DEFAULT_MAX_WORDS_TO_INDEX 10000
@@ -111,7 +104,6 @@
#define DEFAULT_DIVISIONS 4 /* 1->64 */
#define DEFAULT_BUCKET_RATIO 1 /* 0=50%, 1=100%, 2=200%, 3=300%, 4=400% */
#define DEFAULT_PADDING 2 /* 1->8 */
-#define DEFAULT_THREAD_STACK_SIZE 0 /* 0 is the default for the platform */
/*typedef struct _ConfigLanguages ConfigLanguages;*/
typedef struct _TrackerConfigPriv TrackerConfigPriv;
@@ -148,10 +140,6 @@
gint low_disk_space_limit;
gboolean index_mounted_directories;
gboolean index_removable_devices;
- GSList *index_modules;
-
- /* Emails */
- gchar *email_client;
/* Performance */
gint max_text_to_index;
@@ -162,7 +150,6 @@
gint divisions;
gint bucket_ratio;
gint padding;
- gint thread_stack_size;
/* Services*/
gboolean enable_xesam;
@@ -210,10 +197,6 @@
PROP_LOW_DISK_SPACE_LIMIT,
PROP_INDEX_MOUNTED_DIRECTORIES,
PROP_INDEX_REMOVABLE_DEVICES,
- PROP_INDEX_MODULES,
-
- /* Emails */
- PROP_EMAIL_CLIENT,
/* Performance */
PROP_MAX_TEXT_TO_INDEX,
@@ -224,7 +207,6 @@
PROP_DIVISIONS,
PROP_BUCKET_RATIO,
PROP_PADDING,
- PROP_THREAD_STACK_SIZE,
/* Services*/
PROP_ENABLE_XESAM
@@ -433,20 +415,6 @@
"which are for removable devices",
DEFAULT_INDEX_REMOVABLE_DEVICES,
G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
- g_object_class_install_property (object_class,
- PROP_INDEX_MODULES,
- g_param_spec_pointer ("index-modules",
- "Used index modules",
- "Modules used to index data",
- G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
- /* Emails */
- g_object_class_install_property (object_class,
- PROP_EMAIL_CLIENT,
- g_param_spec_string ("email-client",
- "Email client",
- "Email client to index",
- DEFAULT_INDEX_EMAIL_CLIENT,
- G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
/* Performance */
g_object_class_install_property (object_class,
@@ -529,16 +497,6 @@
8,
DEFAULT_PADDING,
G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
- g_object_class_install_property (object_class,
- PROP_THREAD_STACK_SIZE,
- g_param_spec_int ("thread-stack-size",
- "Thread stack size",
- "Thread stack size to use inside tracker. "
- "Use this carefully, as it may lead to misterious crashes. "
- "The default is 0, which uses the default for the platform.",
- 0, G_MAXINT,
- DEFAULT_THREAD_STACK_SIZE,
- G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
/* Services */
g_object_class_install_property (object_class,
@@ -576,11 +534,7 @@
g_slist_foreach (priv->no_index_file_types, (GFunc) g_free, NULL);
g_slist_free (priv->no_index_file_types);
- g_slist_foreach (priv->index_modules, (GFunc) g_free, NULL);
- g_slist_free (priv->index_modules);
-
g_free (priv->language);
- g_free (priv->email_client);
if (priv->monitor) {
g_object_unref (priv->monitor);
@@ -678,14 +632,6 @@
case PROP_INDEX_REMOVABLE_DEVICES:
g_value_set_boolean (value, priv->index_removable_devices);
break;
- case PROP_INDEX_MODULES:
- g_value_set_pointer (value, priv->index_modules);
- break;
-
- /* Emails */
- case PROP_EMAIL_CLIENT:
- g_value_set_string (value, priv->email_client);
- break;
/* Performance */
case PROP_MAX_TEXT_TO_INDEX:
@@ -712,9 +658,6 @@
case PROP_PADDING:
g_value_set_int (value, priv->padding);
break;
- case PROP_THREAD_STACK_SIZE:
- g_value_set_int (value, priv->thread_stack_size);
- break;
/* Services */
case PROP_ENABLE_XESAM:
@@ -825,15 +768,6 @@
tracker_config_set_index_removable_devices (TRACKER_CONFIG (object),
g_value_get_boolean (value));
break;
- case PROP_INDEX_MODULES:
- /* Not writable */
- break;
-
- /* Emails */
- case PROP_EMAIL_CLIENT:
- tracker_config_set_email_client (TRACKER_CONFIG (object),
- g_value_get_string (value));
- break;
/* Performance */
case PROP_MAX_TEXT_TO_INDEX:
@@ -868,10 +802,6 @@
tracker_config_set_padding (TRACKER_CONFIG (object),
g_value_get_int (value));
break;
- case PROP_THREAD_STACK_SIZE:
- tracker_config_set_thread_stack_size (TRACKER_CONFIG (object),
- g_value_get_int (value));
- break;
/* Services */
case PROP_ENABLE_XESAM:
@@ -1002,15 +932,12 @@
gchar *language;
const gchar *watch_directory_roots[2] = { NULL, NULL };
const gchar *empty_string_list[] = { NULL };
- gchar **index_modules;
/* Get default values */
language = tracker_language_get_default_code ();
watch_directory_roots[0] = g_get_home_dir ();
- index_modules = g_strsplit (DEFAULT_INDEX_MODULES, ";", -1);
-
/* General */
g_key_file_set_integer (key_file, GROUP_GENERAL, KEY_VERBOSITY, DEFAULT_VERBOSITY);
g_key_file_set_comment (key_file, GROUP_GENERAL, KEY_VERBOSITY,
@@ -1131,14 +1058,6 @@
g_key_file_set_comment (key_file, GROUP_INDEXING, KEY_INDEX_REMOVABLE_DEVICES,
" Set to true to enable traversing mounted directories for removable devices",
NULL);
- g_key_file_set_string_list (key_file, GROUP_INDEXING, KEY_INDEX_MODULES,
- (const gchar **) index_modules, g_strv_length (index_modules));
- g_key_file_set_comment (key_file, GROUP_INDEXING, KEY_INDEX_MODULES,
- " Modules used to extract data, they will be queried in the same order than they're written here",
- NULL);
-
- /* Emails */
- g_key_file_set_string (key_file, GROUP_EMAILS, KEY_EMAIL_CLIENT, DEFAULT_INDEX_EMAIL_CLIENT);
/* Performance */
g_key_file_set_integer (key_file, GROUP_PERFORMANCE, KEY_MAX_TEXT_TO_INDEX, DEFAULT_MAX_TEXT_TO_INDEX);
@@ -1171,12 +1090,6 @@
" Higher values improve indexing speed but waste more disk space.\n"
" Values should be between 1 and 8.",
NULL);
- g_key_file_set_integer (key_file, GROUP_PERFORMANCE, KEY_THREAD_STACK_SIZE, DEFAULT_THREAD_STACK_SIZE);
- g_key_file_set_comment (key_file, GROUP_PERFORMANCE, KEY_THREAD_STACK_SIZE,
- " Stack size to use in threads inside Tracker.\n"
- " Use this carefully, or expect misterious crashes.\n"
- " 0 uses the default stack size for this platform",
- NULL);
/* Services */
g_key_file_set_boolean (key_file, GROUP_SERVICES, KEY_ENABLE_XESAM, DEFAULT_ENABLE_XESAM);
@@ -1201,7 +1114,6 @@
}
g_print ("Writting default configuration to file:'%s'\n", filename);
- g_strfreev (index_modules);
g_free (content);
return TRUE;
@@ -1342,12 +1254,6 @@
config_string_list_to_gslist ((const gchar **) value, FALSE);
}
}
- else if (strcmp (property, "index-modules") == 0) {
- if (value) {
- priv->index_modules =
- config_string_list_to_gslist ((const gchar **) value, FALSE);
- }
- }
else {
g_warning ("Property '%s' not recognized to set string list from key '%s'",
property, key);
@@ -1466,10 +1372,6 @@
config_load_int (config, "low-disk-space-limit", key_file, GROUP_INDEXING, KEY_LOW_DISK_SPACE_LIMIT);
config_load_boolean (config, "index-mounted-directories", key_file, GROUP_INDEXING, KEY_INDEX_MOUNTED_DIRECTORIES);
config_load_boolean (config, "index-removable-devices", key_file, GROUP_INDEXING, KEY_INDEX_REMOVABLE_DEVICES);
- config_load_string_list (config, "index-modules", key_file, GROUP_INDEXING, KEY_INDEX_MODULES);
-
- /* Emails */
- config_load_string (config, "email-client", key_file, GROUP_EMAILS, KEY_EMAIL_CLIENT);
/* Performance */
config_load_int (config, "max-text-to-index", key_file, GROUP_PERFORMANCE, KEY_MAX_TEXT_TO_INDEX);
@@ -1480,7 +1382,6 @@
config_load_int (config, "divisions", key_file, GROUP_PERFORMANCE, KEY_DIVISIONS);
config_load_int (config, "bucket-ratio", key_file, GROUP_PERFORMANCE, KEY_BUCKET_RATIO);
config_load_int (config, "padding", key_file, GROUP_PERFORMANCE, KEY_PADDING);
- config_load_int (config, "thread-stack-size", key_file, GROUP_PERFORMANCE, KEY_THREAD_STACK_SIZE);
/* Services */
config_load_boolean (config, "enable-xesam", key_file, GROUP_SERVICES, KEY_ENABLE_XESAM);
@@ -1812,30 +1713,6 @@
return priv->index_removable_devices;
}
-GSList *
-tracker_config_get_index_modules (TrackerConfig *config)
-{
- TrackerConfigPriv *priv;
-
- g_return_val_if_fail (TRACKER_IS_CONFIG (config), NULL);
-
- priv = GET_PRIV (config);
-
- return priv->index_modules;
-}
-
-const gchar *
-tracker_config_get_email_client (TrackerConfig *config)
-{
- TrackerConfigPriv *priv;
-
- g_return_val_if_fail (TRACKER_IS_CONFIG (config), DEFAULT_INDEX_EMAIL_CLIENT);
-
- priv = GET_PRIV (config);
-
- return priv->email_client;
-}
-
gint
tracker_config_get_max_text_to_index (TrackerConfig *config)
{
@@ -1932,18 +1809,6 @@
return priv->padding;
}
-gint
-tracker_config_get_thread_stack_size (TrackerConfig *config)
-{
- TrackerConfigPriv *priv;
-
- g_return_val_if_fail (TRACKER_IS_CONFIG (config), DEFAULT_THREAD_STACK_SIZE);
-
- priv = GET_PRIV (config);
-
- return priv->thread_stack_size;
-}
-
void
tracker_config_set_verbosity (TrackerConfig *config,
gint value)
@@ -2263,27 +2128,6 @@
}
void
-tracker_config_set_email_client (TrackerConfig *config,
- const gchar *value)
-{
- TrackerConfigPriv *priv;
-
- g_return_if_fail (TRACKER_IS_CONFIG (config));
-
- priv = GET_PRIV (config);
-
- g_free (priv->email_client);
-
- if (value) {
- priv->email_client = g_strdup (value);
- } else {
- priv->email_client = NULL;
- }
-
- g_object_notify (G_OBJECT (config), "email-client");
-}
-
-void
tracker_config_set_max_text_to_index (TrackerConfig *config,
gint value)
{
@@ -2428,24 +2272,6 @@
}
void
-tracker_config_set_thread_stack_size (TrackerConfig *config,
- gint value)
-{
- TrackerConfigPriv *priv;
-
- g_return_if_fail (TRACKER_IS_CONFIG (config));
-
- if (!config_int_validate (config, "thread-stack-size", value)) {
- return;
- }
-
- priv = GET_PRIV (config);
-
- priv->thread_stack_size = value;
- g_object_notify (G_OBJECT (config), "thread-stack-size");
-}
-
-void
tracker_config_add_watch_directory_roots (TrackerConfig *config,
gchar * const *roots)
{
Modified: branches/xesam-support/src/libtracker-common/tracker-config.h
==============================================================================
--- branches/xesam-support/src/libtracker-common/tracker-config.h (original)
+++ branches/xesam-support/src/libtracker-common/tracker-config.h Thu Jul 3 14:55:07 2008
@@ -73,9 +73,7 @@
gboolean tracker_config_get_disable_indexing_on_battery_init (TrackerConfig *config);
gint tracker_config_get_low_disk_space_limit (TrackerConfig *config);
gboolean tracker_config_get_index_removable_devices (TrackerConfig *config);
-GSList * tracker_config_get_index_modules (TrackerConfig *config);
gboolean tracker_config_get_index_mounted_directories (TrackerConfig *config);
-const gchar * tracker_config_get_email_client (TrackerConfig *config);
gint tracker_config_get_max_text_to_index (TrackerConfig *config);
gint tracker_config_get_max_words_to_index (TrackerConfig *config);
gint tracker_config_get_optimization_sweep_count (TrackerConfig *config);
@@ -84,7 +82,6 @@
gint tracker_config_get_divisions (TrackerConfig *config);
gint tracker_config_get_bucket_ratio (TrackerConfig *config);
gint tracker_config_get_padding (TrackerConfig *config);
-gint tracker_config_get_thread_stack_size (TrackerConfig *config);
void tracker_config_set_verbosity (TrackerConfig *config,
gint value);
void tracker_config_set_initial_sleep (TrackerConfig *config,
@@ -125,8 +122,6 @@
gboolean value);
void tracker_config_set_index_mounted_directories (TrackerConfig *config,
gboolean value);
-void tracker_config_set_email_client (TrackerConfig *config,
- const gchar *value);
void tracker_config_set_max_text_to_index (TrackerConfig *config,
gint value);
void tracker_config_set_max_words_to_index (TrackerConfig *config,
@@ -143,8 +138,6 @@
gint value);
void tracker_config_set_padding (TrackerConfig *config,
gint value);
-void tracker_config_set_thread_stack_size (TrackerConfig *config,
- gint value);
/* Directory root APIs*/
void tracker_config_add_watch_directory_roots (TrackerConfig *config,
Modified: branches/xesam-support/src/libtracker-common/tracker-dbus.c
==============================================================================
--- branches/xesam-support/src/libtracker-common/tracker-dbus.c (original)
+++ branches/xesam-support/src/libtracker-common/tracker-dbus.c Thu Jul 3 14:55:07 2008
@@ -21,8 +21,10 @@
#include "tracker-dbus.h"
+#include <gio/gio.h>
+
GValue *
-tracker_dbus_g_value_slice_new (GType type)
+tracker_dbus_gvalue_slice_new (GType type)
{
GValue *value;
@@ -33,7 +35,7 @@
}
void
-tracker_dbus_g_value_slice_free (GValue *value)
+tracker_dbus_gvalue_slice_free (GValue *value)
{
g_value_unset (value);
g_slice_free (GValue, value);
@@ -86,17 +88,15 @@
}
gchar **
-tracker_dbus_async_queue_to_strv (GAsyncQueue *queue,
- gint max)
+tracker_dbus_queue_str_to_strv (GQueue *queue,
+ gint max)
{
gchar **strv;
gchar *str;
gint i, j;
gint length;
- g_async_queue_lock (queue);
-
- length = g_async_queue_length_unlocked (queue);
+ length = g_queue_get_length (queue);
if (max > 0) {
length = MIN (max, length);
@@ -105,7 +105,7 @@
strv = g_new0 (gchar*, length + 1);
for (i = 0, j = 0; i < length; i++) {
- str = g_async_queue_try_pop_unlocked (queue);
+ str = g_queue_pop_head (queue);
if (!str) {
break;
@@ -122,7 +122,47 @@
strv[j] = NULL;
- g_async_queue_unlock (queue);
+ return strv;
+}
+
+gchar **
+tracker_dbus_queue_gfile_to_strv (GQueue *queue,
+ gint max)
+{
+ gchar **strv;
+ gchar *str;
+ GFile *file;
+ gint i, j;
+ gint length;
+
+ length = g_queue_get_length (queue);
+
+ if (max > 0) {
+ length = MIN (max, length);
+ }
+
+ strv = g_new0 (gchar*, length + 1);
+
+ for (i = 0, j = 0; i < length; i++) {
+ file = g_queue_pop_head (queue);
+
+ if (!file) {
+ break;
+ }
+
+ str = g_file_get_path (file);
+ g_object_unref (file);
+
+ if (!g_utf8_validate (str, -1, NULL)) {
+ g_message ("Could not add string:'%s' to GStrv, invalid UTF-8", str);
+ g_free (str);
+ continue;
+ }
+
+ strv[j++] = str;
+ }
+
+ strv[j] = NULL;
return strv;
}
Modified: branches/xesam-support/src/libtracker-common/tracker-dbus.h
==============================================================================
--- branches/xesam-support/src/libtracker-common/tracker-dbus.h (original)
+++ branches/xesam-support/src/libtracker-common/tracker-dbus.h Thu Jul 3 14:55:07 2008
@@ -80,10 +80,12 @@
const gpointer arg2);
/* Utils */
-GValue * tracker_dbus_g_value_slice_new (GType type);
-void tracker_dbus_g_value_slice_free (GValue *value);
+GValue * tracker_dbus_gvalue_slice_new (GType type);
+void tracker_dbus_gvalue_slice_free (GValue *value);
gchar ** tracker_dbus_slist_to_strv (GSList *list);
-gchar ** tracker_dbus_async_queue_to_strv (GAsyncQueue *queue,
+gchar ** tracker_dbus_queue_str_to_strv (GQueue *queue,
+ gint max);
+gchar ** tracker_dbus_queue_gfile_to_strv (GQueue *queue,
gint max);
/* Requests */
Modified: branches/xesam-support/src/libtracker-common/tracker-file-utils.c
==============================================================================
--- branches/xesam-support/src/libtracker-common/tracker-file-utils.c (original)
+++ branches/xesam-support/src/libtracker-common/tracker-file-utils.c Thu Jul 3 14:55:07 2008
@@ -476,6 +476,11 @@
GSList *checked_roots = NULL;
GSList *l1, *l2;
+ /* This function CREATES a new list and the data in the list
+ * is new too! g_free() must be called on the list data and
+ * g_slist_free() on the list too when done with.
+ */
+
/* ONLY HERE do we add separators on each location we check.
* The reason for this is that these locations are user
* entered in the configuration and we need to make sure we
@@ -511,6 +516,7 @@
if (g_str_has_prefix (l2->data, path)) {
checked_roots = g_slist_remove_link (checked_roots, l2);
g_free (l2->data);
+
l2 = checked_roots;
continue;
}
Modified: branches/xesam-support/src/libtracker-common/tracker-hal.c
==============================================================================
--- branches/xesam-support/src/libtracker-common/tracker-hal.c (original)
+++ branches/xesam-support/src/libtracker-common/tracker-hal.c Thu Jul 3 14:55:07 2008
@@ -369,7 +369,10 @@
libhal_free_string_array (devices);
priv->battery_in_use = FALSE;
+ g_object_notify (G_OBJECT (hal), "battery-in-use");
+
priv->battery_udi = NULL;
+ g_object_notify (G_OBJECT (hal), "battery-exists");
return TRUE;
}
@@ -378,6 +381,8 @@
if (!priv->battery_udi) {
/* For now just use the first one we find */
priv->battery_udi = g_strdup (*p);
+ g_object_notify (G_OBJECT (hal), "battery-exists");
+
g_message (" - Device '%s' (default)", *p);
} else {
g_message (" - Device '%s'", *p);
@@ -403,11 +408,13 @@
priv->battery_udi,
PROP_AC_ADAPTER_ON,
NULL);
-
- g_message ("HAL reports system is currently powered by %s",
- priv->battery_in_use ? "battery" : "AC adapter");
+
+ g_message ("HAL reports system is currently powered by %s",
+ priv->battery_in_use ? "battery" : "AC adapter");
- return TRUE;
+ g_object_notify (G_OBJECT (hal), "battery-in-use");
+
+ return TRUE;
}
static void
@@ -748,23 +755,17 @@
priv->battery_udi,
PROP_AC_ADAPTER_ON,
&error);
+ g_message ("HAL reports system is now powered by %s",
+ priv->battery_in_use ? "battery" : "AC adapter");
+
+ g_object_notify (G_OBJECT (hal), "battery-in-use");
if (dbus_error_is_set (&error)) {
- g_critical ("Could not device property:'%s' for udi:'%s', %s",
+ g_critical ("Could not get device property:'%s' for udi:'%s', %s",
udi, PROP_AC_ADAPTER_ON, error.message);
dbus_error_free (&error);
return;
}
-
- g_message ("HAL reports system is now powered by %s",
- priv->battery_in_use ? "battery" : "AC adapter");
-
-#if 0
- /* If we have come off battery power wakeup index thread */
- if (current_state && !priv->battery_in_use) {
- tracker_notify_file_data_available ();
- }
-#endif
} else {
gboolean is_mounted;
Modified: branches/xesam-support/src/libtracker-common/tracker-log.c
==============================================================================
--- branches/xesam-support/src/libtracker-common/tracker-log.c (original)
+++ branches/xesam-support/src/libtracker-common/tracker-log.c Thu Jul 3 14:55:07 2008
@@ -55,7 +55,7 @@
gchar *output;
struct tm *local_time;
GTimeVal current_time;
- static size_t size = 0;
+ static gsize size = 0;
const gchar *log_level_str;
g_return_if_fail (log != NULL);
@@ -66,7 +66,7 @@
fd = g_fopen (log->filename, "a");
if (!fd) {
- g_warning ("Could not open log: '%s'", log->filename);
+ g_fprintf (stderr, "Could not open log: '%s'", log->filename);
g_mutex_unlock (log->mutex);
return;
}
Modified: branches/xesam-support/src/libtracker-common/tracker-module-config.c
==============================================================================
--- branches/xesam-support/src/libtracker-common/tracker-module-config.c (original)
+++ branches/xesam-support/src/libtracker-common/tracker-module-config.c Thu Jul 3 14:55:07 2008
@@ -38,22 +38,26 @@
typedef struct {
/* General */
- gchar *description;
- gboolean enabled;
-
+ gchar *description;
+ gboolean enabled;
+
/* Monitors */
- GSList *monitor_directories;
- GSList *monitor_recurse_directories;
-
+ GHashTable *monitor_directories;
+ GHashTable *monitor_recurse_directories;
+
/* Ignored */
- GSList *ignored_directories;
- GSList *ignored_files;
+ GHashTable *ignored_directories;
+ GHashTable *ignored_files;
+
+ GList *ignored_directory_patterns;
+ GList *ignored_file_patterns;
/* Index */
- gchar *service;
- GSList *mime_types;
- GSList *files;
-
+ gchar *index_service;
+ GHashTable *index_mime_types;
+ GHashTable *index_files;
+ GList *index_file_patterns;
+
/* Specific Options, FIXME: Finish */
} ModuleConfig;
@@ -65,27 +69,32 @@
static void
module_config_free (ModuleConfig *mc)
{
- g_free (mc->description);
-
- g_slist_foreach (mc->monitor_directories, (GFunc) g_free, NULL);
- g_slist_free (mc->monitor_directories);
-
- g_slist_foreach (mc->monitor_recurse_directories, (GFunc) g_free, NULL);
- g_slist_free (mc->monitor_recurse_directories);
-
- g_slist_foreach (mc->ignored_directories, (GFunc) g_free, NULL);
- g_slist_free (mc->ignored_directories);
-
- g_slist_foreach (mc->ignored_files, (GFunc) g_free, NULL);
- g_slist_free (mc->ignored_files);
+ g_list_foreach (mc->index_file_patterns,
+ (GFunc) g_pattern_spec_free,
+ NULL);
+ g_list_free (mc->index_file_patterns);
+
+ g_hash_table_unref (mc->index_files);
+ g_hash_table_unref (mc->index_mime_types);
+ g_free (mc->index_service);
+
+ g_list_foreach (mc->ignored_file_patterns,
+ (GFunc) g_pattern_spec_free,
+ NULL);
+ g_list_free (mc->ignored_file_patterns);
+
+ g_list_foreach (mc->ignored_directory_patterns,
+ (GFunc) g_pattern_spec_free,
+ NULL);
+ g_list_free (mc->ignored_directory_patterns);
- g_free (mc->service);
+ g_hash_table_unref (mc->ignored_files);
+ g_hash_table_unref (mc->ignored_directories);
- g_slist_foreach (mc->mime_types, (GFunc) g_free, NULL);
- g_slist_free (mc->mime_types);
+ g_hash_table_unref (mc->monitor_recurse_directories);
+ g_hash_table_unref (mc->monitor_directories);
- g_slist_foreach (mc->files, (GFunc) g_free, NULL);
- g_slist_free (mc->files);
+ g_free (mc->description);
g_slice_free (ModuleConfig, mc);
}
@@ -96,7 +105,88 @@
return g_build_path (G_DIR_SEPARATOR_S, SHAREDIR, "tracker", "modules", NULL);
}
-gboolean
+static void
+module_config_set_ignored_file_patterns (ModuleConfig *mc)
+{
+ GPatternSpec *spec;
+ GList *ignored_files;
+ GList *l;
+ GList *patterns = NULL;
+
+ g_list_foreach (mc->ignored_file_patterns,
+ (GFunc) g_pattern_spec_free,
+ NULL);
+ g_list_free (mc->ignored_file_patterns);
+
+ ignored_files = g_hash_table_get_keys (mc->ignored_files);
+
+ for (l = ignored_files; l; l = l->next) {
+ g_message (" Adding file ignore pattern:'%s'",
+ (gchar *) l->data);
+ spec = g_pattern_spec_new (l->data);
+ patterns = g_list_prepend (patterns, spec);
+ }
+
+ g_list_free (ignored_files);
+
+ mc->ignored_file_patterns = g_list_reverse (patterns);
+}
+
+static void
+module_config_set_ignored_directory_patterns (ModuleConfig *mc)
+{
+ GPatternSpec *spec;
+ GList *ignored_directories;
+ GList *l;
+ GList *patterns = NULL;
+
+ g_list_foreach (mc->ignored_directory_patterns,
+ (GFunc) g_pattern_spec_free,
+ NULL);
+ g_list_free (mc->ignored_directory_patterns);
+
+ ignored_directories = g_hash_table_get_keys (mc->ignored_directories);
+
+ for (l = ignored_directories; l; l = l->next) {
+ g_message (" Adding directory ignore pattern:'%s'",
+ (gchar *) l->data);
+ spec = g_pattern_spec_new (l->data);
+ patterns = g_list_prepend (patterns, spec);
+ }
+
+ g_list_free (ignored_directories);
+
+ mc->ignored_directory_patterns = g_list_reverse (patterns);
+}
+
+static void
+module_config_set_index_file_patterns (ModuleConfig *mc)
+{
+ GPatternSpec *spec;
+ GList *index_files;
+ GList *l;
+ GList *patterns = NULL;
+
+ g_list_foreach (mc->index_file_patterns,
+ (GFunc) g_pattern_spec_free,
+ NULL);
+ g_list_free (mc->index_file_patterns);
+
+ index_files = g_hash_table_get_keys (mc->index_files);
+
+ for (l = index_files; l; l = l->next) {
+ g_message (" Adding file index pattern:'%s'",
+ (gchar *) l->data);
+ spec = g_pattern_spec_new (l->data);
+ patterns = g_list_prepend (patterns, spec);
+ }
+
+ g_list_free (index_files);
+
+ mc->index_file_patterns = g_list_reverse (patterns);
+}
+
+static gboolean
module_config_load_boolean (GKeyFile *key_file,
const gchar *group,
const gchar *key)
@@ -108,11 +198,11 @@
if (error) {
g_message ("Couldn't load module config boolean in "
- "group:'%s' with key:'%s', %s",
+ "group:'%s' with key:'%s', %s",
group,
- key,
+ key,
error->message);
-
+
g_error_free (error);
g_key_file_free (key_file);
@@ -122,7 +212,7 @@
return boolean;
}
-gchar *
+static gchar *
module_config_load_string (GKeyFile *key_file,
const gchar *group,
const gchar *key,
@@ -135,11 +225,11 @@
if (error) {
g_message ("Couldn't load module config string in "
- "group:'%s' with key:'%s', %s",
+ "group:'%s' with key:'%s', %s",
group,
- key,
+ key,
error->message);
-
+
g_error_free (error);
g_key_file_free (key_file);
@@ -158,52 +248,71 @@
return str;
}
-GSList *
+static GHashTable *
module_config_load_string_list (GKeyFile *key_file,
const gchar *group,
const gchar *key,
gboolean expand_strings_as_paths)
{
- GError *error = NULL;
- GSList *list;
- gchar **str;
- gchar **p;
- gsize size;
+ GError *error = NULL;
+ GHashTable *table;
+ gchar **str;
+ gchar **p;
+ gsize size;
+
+ table = g_hash_table_new_full (g_str_hash,
+ g_str_equal,
+ g_free,
+ NULL);
str = g_key_file_get_string_list (key_file, group, key, &size, &error);
if (error) {
g_message ("Couldn't load module config string list in "
- "group:'%s' with key:'%s', %s",
+ "group:'%s' with key:'%s', %s",
group,
- key,
+ key,
error->message);
-
+
g_error_free (error);
g_key_file_free (key_file);
- return NULL;
+ return table;
}
- if (!expand_strings_as_paths) {
- list = tracker_string_list_to_gslist (str, size);
- } else {
- list = NULL;
+ for (p = str; *p; p++) {
+ gchar *real_path;
- for (p = str; *p; p++) {
- gchar *real_path;
-
+ if (!expand_strings_as_paths) {
+ if (g_hash_table_lookup (table, *p)) {
+ continue;
+ }
+
+ g_hash_table_insert (table,
+ g_strdup (*p),
+ GINT_TO_POINTER (1));
+ } else {
+ if (g_hash_table_lookup (table, *p)) {
+ continue;
+ }
+
real_path = tracker_path_evaluate_name (*p);
- list = g_slist_prepend (list, real_path);
+ if (g_hash_table_lookup (table, real_path)) {
+ g_free (real_path);
+ continue;
+ }
+
+ g_hash_table_insert (table,
+ real_path,
+ GINT_TO_POINTER (1));
g_debug ("Got real path:'%s' for '%s'", real_path, *p);
}
- list = g_slist_reverse (list);
}
g_strfreev (str);
- return list;
+ return table;
}
static ModuleConfig *
@@ -214,79 +323,85 @@
ModuleConfig *mc;
key_file = g_key_file_new ();
-
+
/* Load options */
g_key_file_load_from_file (key_file, filename, G_KEY_FILE_NONE, &error);
if (error) {
- g_message ("Couldn't load module config for '%s', %s",
- filename,
+ g_message ("Couldn't load module config for '%s', %s",
+ filename,
error->message);
-
+
g_error_free (error);
g_key_file_free (key_file);
return NULL;
}
+ g_message ("Loading module config:'%s'", filename);
+
mc = g_slice_new0 (ModuleConfig);
/* General */
- mc->description =
+ mc->description =
module_config_load_string (key_file,
GROUP_GENERAL,
- "Description",
+ "Description",
FALSE);
- mc->enabled =
+ mc->enabled =
module_config_load_boolean (key_file,
GROUP_GENERAL,
"Enabled");
/* Monitors */
- mc->monitor_directories =
- module_config_load_string_list (key_file,
- GROUP_MONITORS,
+ mc->monitor_directories =
+ module_config_load_string_list (key_file,
+ GROUP_MONITORS,
"Directories",
TRUE);
- mc->monitor_recurse_directories =
- module_config_load_string_list (key_file,
- GROUP_MONITORS,
+ mc->monitor_recurse_directories =
+ module_config_load_string_list (key_file,
+ GROUP_MONITORS,
"RecurseDirectories",
TRUE);
/* Ignored */
- mc->ignored_directories =
- module_config_load_string_list (key_file,
- GROUP_IGNORED,
+ mc->ignored_directories =
+ module_config_load_string_list (key_file,
+ GROUP_IGNORED,
"Directories",
TRUE);
- mc->ignored_files =
- module_config_load_string_list (key_file,
- GROUP_IGNORED,
+ mc->ignored_files =
+ module_config_load_string_list (key_file,
+ GROUP_IGNORED,
"Files",
FALSE);
/* Index */
- mc->service =
+ mc->index_service =
module_config_load_string (key_file,
GROUP_INDEX,
"Service",
FALSE);
- mc->mime_types =
- module_config_load_string_list (key_file,
- GROUP_INDEX,
+ mc->index_mime_types =
+ module_config_load_string_list (key_file,
+ GROUP_INDEX,
"MimeTypes",
FALSE);
- mc->files =
- module_config_load_string_list (key_file,
- GROUP_INDEX,
+ mc->index_files =
+ module_config_load_string_list (key_file,
+ GROUP_INDEX,
"Files",
FALSE);
-
+
/* FIXME: Specific options */
- g_message ("Loaded module config:'%s'", filename);
-
+ module_config_set_ignored_file_patterns (mc);
+ module_config_set_ignored_directory_patterns (mc);
+ module_config_set_index_file_patterns (mc);
+
+ g_key_file_free (key_file);
+
return mc;
}
@@ -310,7 +425,7 @@
G_FILE_ATTRIBUTE_STANDARD_NAME ","
G_FILE_ATTRIBUTE_STANDARD_TYPE,
G_PRIORITY_DEFAULT,
- NULL,
+ NULL,
&error);
if (error) {
@@ -328,7 +443,7 @@
extension = ".module";
extension_len = g_utf8_strlen (extension, -1);
- /* We should probably do this async */
+ /* We should probably do this async */
for (info = g_file_enumerator_next_file (enumerator, NULL, &error);
info && !error;
info = g_file_enumerator_next_file (enumerator, NULL, &error)) {
@@ -342,9 +457,10 @@
continue;
}
- child = g_file_get_child (file, g_file_info_get_name (info));
+ child = g_file_get_child (file, name);
filename = g_file_get_path (child);
mc = module_config_load_file (filename);
+ g_free (filename);
if (mc) {
gchar *name_stripped;
@@ -368,7 +484,7 @@
}
g_message ("Loaded module config, %d found",
- g_hash_table_size (modules));
+ g_hash_table_size (modules));
g_object_unref (enumerator);
g_object_unref (file);
@@ -382,7 +498,7 @@
GFile *file,
GFile *other_file,
GFileMonitorEvent event_type,
- gpointer user_data)
+ gpointer user_data)
{
gchar *filename;
@@ -392,8 +508,8 @@
case G_FILE_MONITOR_EVENT_CHANGED:
case G_FILE_MONITOR_EVENT_CHANGES_DONE_HINT:
filename = g_file_get_path (file);
- g_message ("Config file changed:'%s', reloading settings...",
- filename);
+ g_message ("Config file changed:'%s', reloading settings...",
+ filename);
g_free (filename);
module_config_load ();
@@ -430,41 +546,43 @@
/* Get modules */
if (!module_config_load ()) {
g_hash_table_unref (modules);
+ g_free (path);
return FALSE;
}
/* Add file monitoring for changes */
- g_message ("Setting up monitor for changes to modules directory:'%s'",
+ g_message ("Setting up monitor for changes to modules directory:'%s'",
path);
-
+
file = g_file_new_for_path (path);
monitor = g_file_monitor_directory (file,
G_FILE_MONITOR_NONE,
NULL,
NULL);
-
+
g_signal_connect (monitor, "changed",
- G_CALLBACK (module_config_changed_cb),
+ G_CALLBACK (module_config_changed_cb),
NULL);
g_object_unref (file);
+ g_free (path);
initiated = TRUE;
return TRUE;
}
-void
+void
tracker_module_config_shutdown (void)
{
if (!initiated) {
return;
}
-
+
g_signal_handlers_disconnect_by_func (monitor,
module_config_changed_cb,
NULL);
-
+
g_object_unref (monitor);
g_hash_table_unref (modules);
@@ -495,7 +613,7 @@
tracker_module_config_get_enabled (const gchar *name)
{
ModuleConfig *mc;
-
+
g_return_val_if_fail (name != NULL, FALSE);
mc = g_hash_table_lookup (modules, name);
@@ -504,60 +622,60 @@
return mc->enabled;
}
-GSList *
+GList *
tracker_module_config_get_monitor_directories (const gchar *name)
{
ModuleConfig *mc;
-
+
g_return_val_if_fail (name != NULL, FALSE);
mc = g_hash_table_lookup (modules, name);
g_return_val_if_fail (mc, NULL);
- return mc->monitor_directories;
+ return g_hash_table_get_keys (mc->monitor_directories);
}
-GSList *
+GList *
tracker_module_config_get_monitor_recurse_directories (const gchar *name)
{
ModuleConfig *mc;
-
+
g_return_val_if_fail (name != NULL, FALSE);
mc = g_hash_table_lookup (modules, name);
g_return_val_if_fail (mc, NULL);
- return mc->monitor_recurse_directories;
+ return g_hash_table_get_keys (mc->monitor_recurse_directories);
}
-GSList *
+GList *
tracker_module_config_get_ignored_directories (const gchar *name)
{
ModuleConfig *mc;
-
+
g_return_val_if_fail (name != NULL, FALSE);
mc = g_hash_table_lookup (modules, name);
g_return_val_if_fail (mc, NULL);
- return mc->ignored_directories;
+ return g_hash_table_get_keys (mc->ignored_directories);
}
-GSList *
+GList *
tracker_module_config_get_ignored_files (const gchar *name)
{
ModuleConfig *mc;
-
+
g_return_val_if_fail (name != NULL, FALSE);
mc = g_hash_table_lookup (modules, name);
g_return_val_if_fail (mc, NULL);
- return mc->ignored_files;
+ return g_hash_table_get_keys (mc->ignored_files);
}
const gchar *
-tracker_module_config_get_service (const gchar *name)
+tracker_module_config_get_index_service (const gchar *name)
{
ModuleConfig *mc;
@@ -566,31 +684,74 @@
mc = g_hash_table_lookup (modules, name);
g_return_val_if_fail (mc, NULL);
- return mc->service;
+ return mc->index_service;
}
-GSList *
-tracker_module_config_get_mime_types (const gchar *name)
+GList *
+tracker_module_config_get_index_mime_types (const gchar *name)
{
ModuleConfig *mc;
-
+
g_return_val_if_fail (name != NULL, FALSE);
mc = g_hash_table_lookup (modules, name);
g_return_val_if_fail (mc, NULL);
- return mc->mime_types;
+ return g_hash_table_get_keys (mc->index_mime_types);
}
-GSList *
-tracker_module_config_get_files (const gchar *name)
+GList *
+tracker_module_config_get_index_files (const gchar *name)
{
ModuleConfig *mc;
-
+
g_return_val_if_fail (name != NULL, FALSE);
mc = g_hash_table_lookup (modules, name);
g_return_val_if_fail (mc, NULL);
- return mc->files;
+ return g_hash_table_get_keys (mc->index_files);
+}
+
+/*
+ * Convenience functions
+ */
+
+GList *
+tracker_module_config_get_ignored_file_patterns (const gchar *name)
+{
+ ModuleConfig *mc;
+
+ g_return_val_if_fail (name != NULL, NULL);
+
+ mc = g_hash_table_lookup (modules, name);
+ g_return_val_if_fail (mc, NULL);
+
+ return g_list_copy (mc->ignored_file_patterns);
+}
+
+GList *
+tracker_module_config_get_ignored_directory_patterns (const gchar *name)
+{
+ ModuleConfig *mc;
+
+ g_return_val_if_fail (name != NULL, NULL);
+
+ mc = g_hash_table_lookup (modules, name);
+ g_return_val_if_fail (mc, NULL);
+
+ return g_list_copy (mc->ignored_directory_patterns);
+}
+
+GList *
+tracker_module_config_get_index_file_patterns (const gchar *name)
+{
+ ModuleConfig *mc;
+
+ g_return_val_if_fail (name != NULL, NULL);
+
+ mc = g_hash_table_lookup (modules, name);
+ g_return_val_if_fail (mc, NULL);
+
+ return g_list_copy (mc->index_file_patterns);
}
Modified: branches/xesam-support/src/libtracker-common/tracker-module-config.h
==============================================================================
--- branches/xesam-support/src/libtracker-common/tracker-module-config.h (original)
+++ branches/xesam-support/src/libtracker-common/tracker-module-config.h Thu Jul 3 14:55:07 2008
@@ -32,14 +32,21 @@
const gchar *tracker_module_config_get_description (const gchar *name);
gboolean tracker_module_config_get_enabled (const gchar *name);
-GSList * tracker_module_config_get_monitor_directories (const gchar *name);
-GSList * tracker_module_config_get_monitor_recurse_directories (const gchar *name);
-GSList * tracker_module_config_get_ignored_directories (const gchar *name);
-GSList * tracker_module_config_get_ignored_files (const gchar *name);
-const gchar *tracker_module_config_get_service (const gchar *name);
-const gchar *tracker_module_config_get_service (const gchar *name);
-GSList * tracker_module_config_get_mime_types (const gchar *name);
-GSList * tracker_module_config_get_files (const gchar *name);
+
+GList * tracker_module_config_get_monitor_directories (const gchar *name);
+GList * tracker_module_config_get_monitor_recurse_directories (const gchar *name);
+
+GList * tracker_module_config_get_ignored_directories (const gchar *name);
+GList * tracker_module_config_get_ignored_files (const gchar *name);
+
+const gchar *tracker_module_config_get_index_service (const gchar *name);
+GList * tracker_module_config_get_index_mime_types (const gchar *name);
+GList * tracker_module_config_get_index_files (const gchar *name);
+
+/* Convenience functions */
+GList * tracker_module_config_get_ignored_directory_patterns (const gchar *name);
+GList * tracker_module_config_get_ignored_file_patterns (const gchar *name);
+GList * tracker_module_config_get_index_file_patterns (const gchar *name);
G_END_DECLS
Modified: branches/xesam-support/src/libtracker-common/tracker-ontology.c
==============================================================================
--- branches/xesam-support/src/libtracker-common/tracker-ontology.c (original)
+++ branches/xesam-support/src/libtracker-common/tracker-ontology.c Thu Jul 3 14:55:07 2008
@@ -146,19 +146,19 @@
return;
}
- g_hash_table_remove_all (service_directory_table);
+ g_hash_table_destroy (service_directory_table);
service_directory_table = NULL;
- g_hash_table_remove_all (service_id_table);
+ g_hash_table_destroy (service_id_table);
service_id_table = NULL;
- g_hash_table_remove_all (service_table);
+ g_hash_table_destroy (service_table);
service_table = NULL;
- g_hash_table_remove_all (mime_service);
+ g_hash_table_destroy (mime_service);
mime_service = NULL;
- g_hash_table_remove_all (metadata_table);
+ g_hash_table_destroy (metadata_table);
metadata_table = NULL;
if (mime_prefix_service) {
@@ -340,6 +340,10 @@
if (g_str_has_prefix (str, "emails") ||
g_str_has_prefix (str, "attachments")) {
type = TRACKER_DB_TYPE_EMAIL;
+ } else if (g_str_has_prefix (str, "files")) {
+ type = TRACKER_DB_TYPE_FILES;
+ } else if (g_str_has_prefix (str, "xesam")) {
+ type = TRACKER_DB_TYPE_XESAM;
}
g_free (str);
Modified: branches/xesam-support/src/libtracker-common/tracker-service.h
==============================================================================
--- branches/xesam-support/src/libtracker-common/tracker-service.h (original)
+++ branches/xesam-support/src/libtracker-common/tracker-service.h Thu Jul 3 14:55:07 2008
@@ -34,6 +34,8 @@
TRACKER_DB_TYPE_COMMON,
TRACKER_DB_TYPE_CONTENT,
TRACKER_DB_TYPE_EMAIL,
+ TRACKER_DB_TYPE_FILES,
+ TRACKER_DB_TYPE_XESAM,
TRACKER_DB_TYPE_CACHE,
TRACKER_DB_TYPE_USER
} TrackerDBType;
Modified: branches/xesam-support/src/libtracker-common/tracker-utils.c
==============================================================================
--- branches/xesam-support/src/libtracker-common/tracker-utils.c (original)
+++ branches/xesam-support/src/libtracker-common/tracker-utils.c Thu Jul 3 14:55:07 2008
@@ -29,6 +29,44 @@
return str == NULL || str[0] == '\0';
}
+/* Removes a substring modifing haystack in place */
+gchar *
+tracker_string_remove (gchar *haystack,
+ const gchar *needle)
+{
+ gchar *current, *pos, *next, *end;
+ gint len;
+
+ len = strlen (needle);
+ end = haystack + strlen (haystack);
+ current = pos = strstr (haystack, needle);
+
+ if (!current) {
+ return haystack;
+ }
+
+ while (*current != '\0') {
+ pos = strstr (pos, needle) + len;
+ next = strstr (pos, needle);
+
+ if (!next) {
+ next = end;
+ }
+
+ while (pos < next) {
+ *current = *pos;
+ current++;
+ pos++;
+ }
+
+ if (*pos == '\0') {
+ *current = *pos;
+ }
+ }
+
+ return haystack;
+}
+
gchar *
tracker_string_replace (const gchar *haystack,
gchar *needle,
Modified: branches/xesam-support/src/libtracker-common/tracker-utils.h
==============================================================================
--- branches/xesam-support/src/libtracker-common/tracker-utils.h (original)
+++ branches/xesam-support/src/libtracker-common/tracker-utils.h Thu Jul 3 14:55:07 2008
@@ -28,6 +28,9 @@
gchar * tracker_string_replace (const gchar *haystack,
gchar *needle,
gchar *replacement);
+gchar * tracker_string_remove (gchar *haystack,
+ const gchar *needle);
+
gchar * tracker_escape_string (const gchar *in);
Modified: branches/xesam-support/src/libtracker-db/tracker-db-dbus.c
==============================================================================
--- branches/xesam-support/src/libtracker-db/tracker-db-dbus.c (original)
+++ branches/xesam-support/src/libtracker-db/tracker-db-dbus.c Thu Jul 3 14:55:07 2008
@@ -73,7 +73,7 @@
hash_table = g_hash_table_new_full (g_str_hash,
g_str_equal,
(GDestroyNotify) g_free,
- (GDestroyNotify) tracker_dbus_g_value_slice_free);
+ (GDestroyNotify) tracker_dbus_gvalue_slice_free);
if (result_set) {
valid = TRUE;
@@ -92,7 +92,7 @@
g_value_init (&transform, G_TYPE_STRING);
tracker_db_result_set_get (result_set, 0, &key, -1);
- values = tracker_dbus_g_value_slice_new (G_TYPE_STRV);
+ values = tracker_dbus_gvalue_slice_new (G_TYPE_STRV);
for (i = 1; i < field_count; i++) {
GValue value;
Modified: branches/xesam-support/src/libtracker-db/tracker-db-manager.c
==============================================================================
--- branches/xesam-support/src/libtracker-db/tracker-db-manager.c (original)
+++ branches/xesam-support/src/libtracker-db/tracker-db-manager.c Thu Jul 3 14:55:07 2008
@@ -139,7 +139,6 @@
static TrackerDBInterface *db_interface_create (TrackerDB db);
static gboolean initialized;
-static gboolean attach_all;
static GHashTable *prepared_queries;
static gchar *services_dir;
static gchar *sql_dir;
@@ -147,7 +146,9 @@
static gchar *user_data_dir;
static gchar *sys_tmp_dir;
static gpointer db_type_enum_class_pointer;
-static TrackerDBInterface *attach_iface = NULL;
+static TrackerDBInterface *file_iface = NULL;
+static TrackerDBInterface *email_iface = NULL;
+static TrackerDBInterface *xesam_iface = NULL;
static const gchar *
location_to_directory (TrackerDBLocation location)
@@ -1745,51 +1746,10 @@
path,
db_type_to_string (type));
- if (attach_all) {
- iface = tracker_db_interface_sqlite_new (path);
- tracker_db_interface_set_procedure_table (iface,
- prepared_queries);
-
- /* We don't have separate interfaces for each db in
- * this situation. We just have one interface.
- * One analyze when we create interfaces.
- */
- if (*create) {
- g_message (" Analyzing...");
- db_exec_no_reply (iface, "ANALYZE");
- }
-
- /* The reason we do this is because we need to create
- * a new interface for EACH filename so the sql files
- * are loaded into the right file instead of the
- * first one we create.
- */
- if (attach_iface && dbs[type].attached) {
- g_message (" Already attached '%s' as '%s'",
- dbs[type].abs_filename,
- dbs[type].name);
- }
+ iface = tracker_db_interface_sqlite_new (path);
- if (attach_iface && !dbs[type].attached) {
-
- g_message (" Attaching '%s' as '%s'",
- dbs[type].abs_filename,
- dbs[type].name);
-
- db_exec_no_reply (attach_iface,
- "ATTACH '%s' as '%s'",
- dbs[type].abs_filename,
- dbs[type].name);
-
- dbs[type].attached = TRUE;
- } else if (!attach_iface) {
- attach_iface = iface;
- }
- } else {
- iface = tracker_db_interface_sqlite_new (path);
- tracker_db_interface_set_procedure_table (iface,
- prepared_queries);
- }
+ tracker_db_interface_set_procedure_table (iface,
+ prepared_queries);
db_set_params (iface,
dbs[type].cache_size,
@@ -2295,6 +2255,10 @@
dir = location_to_directory (dbs[i].location);
dbs[i].abs_filename = g_build_filename (dir, dbs[i].file, NULL);
+ if (flags & TRACKER_DB_MANAGER_LOW_MEMORY_MODE) {
+ dbs[i].cache_size /= 2;
+ }
+
/* Check we have each database in place, if one is
* missing, we reindex, except the cache which we
* expect to be replaced on each startup.
@@ -2342,9 +2306,6 @@
g_unlink (dbs[i].abs_filename);
}
- /* Don't attach while we do this... */
- attach_all = TRUE;
-
/* In cases where we re-init this module, make sure
* we have cleaned up the ontology before we load all
* new databases.
@@ -2370,7 +2331,6 @@
dbs[i].iface = NULL;
}
- attach_iface = NULL;
} else {
/* Make sure we remove and recreate the cache directory in tmp
* each time we start up, this is meant to be a per-run
@@ -2386,8 +2346,6 @@
tracker_ontology_init ();
}
- attach_all = flags & TRACKER_DB_MANAGER_ATTACH_ALL;
-
/* Load databases */
g_message ("Loading databases files...");
@@ -2395,36 +2353,11 @@
dbs[i].iface = db_interface_create (i);
}
- if (attach_all) {
- TrackerDBInterface *dummy;
-
- dummy = db_interface_get_common ();
- g_object_unref (dummy);
-
- dummy = db_interface_get_cache ();
- g_object_unref (dummy);
-
- dummy = db_interface_get_file_contents ();
- g_object_unref (dummy);
-
- dummy = db_interface_get_file_metadata ();
- g_object_unref (dummy);
-
- dummy = db_interface_get_email_metadata ();
- g_object_unref (dummy);
-
- dummy = db_interface_get_email_metadata ();
- g_object_unref (dummy);
-
- dummy = db_interface_get_xesam ();
- g_object_unref (dummy);
- }
-
initialized = TRUE;
}
void
-tracker_db_manager_shutdown (gboolean remove_tmp)
+tracker_db_manager_shutdown (void)
{
guint i;
@@ -2447,18 +2380,20 @@
g_hash_table_unref (prepared_queries);
prepared_queries = NULL;
- /* Remove directory in tmp */
- if (remove_tmp) {
- g_message ("Removing directory:'%s'", sys_tmp_dir);
- tracker_path_remove (sys_tmp_dir);
- }
-
g_free (data_dir);
g_free (user_data_dir);
g_free (sys_tmp_dir);
g_free (services_dir);
g_free (sql_dir);
+ if (file_iface)
+ g_object_unref (file_iface);
+ if (email_iface)
+ g_object_unref (email_iface);
+ if (xesam_iface)
+ g_object_unref (xesam_iface);
+
+
/* Since we don't reference this enum anywhere, we do
* it here to make sure it exists when we call
* g_type_class_peek(). This wouldn't be necessary if
@@ -2471,8 +2406,6 @@
g_type_class_unref (db_type_enum_class_pointer);
db_type_enum_class_pointer = NULL;
- attach_iface = NULL;
-
/* Make sure we shutdown all other modules we depend on */
tracker_ontology_shutdown ();
@@ -2487,6 +2420,18 @@
return dbs[db].abs_filename;
}
+/**
+ * tracker_db_manager_get_db_interfaces:
+ * @num: amount of TrackerDB files wanted
+ * @...: All the files that you want in the connection as TrackerDB items
+ *
+ * Request a database connection where the first requested file gets connected
+ * to and the subsequent requsted files get attached to the connection.
+ *
+ * The caller must g_object_unref the result when finished using it.
+ *
+ * returns: (caller-owns): a database connection
+ **/
TrackerDBInterface *
tracker_db_manager_get_db_interfaces (gint num, ...)
{
@@ -2505,9 +2450,6 @@
tracker_db_interface_set_procedure_table (connection,
prepared_queries);
- /* You could set specific cache and page sizes for the
- * indexer's INSERT connection here. */
-
db_set_params (connection,
dbs[db].cache_size,
dbs[db].page_size,
@@ -2528,26 +2470,41 @@
}
+
+/**
+ * tracker_db_manager_get_db_interface:
+ * @db: the database file wanted
+ *
+ * Request a database connection to the database file @db.
+ *
+ * The caller must NOT g_object_unref the result
+ *
+ * returns: (callee-owns): a database connection
+ **/
TrackerDBInterface *
tracker_db_manager_get_db_interface (TrackerDB db)
{
g_return_val_if_fail (initialized != FALSE, NULL);
- if (attach_all) {
- return attach_iface;
- }
-
return dbs[db].iface;
}
+/**
+ * tracker_db_manager_get_db_interface_by_service:
+ * @service: the server for which you'll use the database connection
+ *
+ * Request a database connection that can be used for @service. At this moment
+ * service can either be "Files", "Emails", "Attachments" or "Xesam".
+ *
+ * The caller must NOT g_object_unref the result
+ *
+ * returns: (callee-owns): a database connection
+ **/
TrackerDBInterface *
-tracker_db_manager_get_db_interface_by_service (const gchar *service,
- gboolean content)
+tracker_db_manager_get_db_interface_by_service (const gchar *service)
{
TrackerDBInterface *iface;
TrackerDBType type;
- static TrackerDBInterface *file_iface = NULL;
- static TrackerDBInterface *email_iface = NULL;
g_return_val_if_fail (initialized != FALSE, NULL);
g_return_val_if_fail (service != NULL, NULL);
@@ -2556,6 +2513,7 @@
switch (type) {
case TRACKER_DB_TYPE_EMAIL:
+
if (!email_iface) {
email_iface = tracker_db_manager_get_db_interfaces (4,
TRACKER_DB_COMMON,
@@ -2563,9 +2521,26 @@
TRACKER_DB_EMAIL_METADATA,
TRACKER_DB_CACHE);
}
+
iface = email_iface;
break;
+ case TRACKER_DB_TYPE_XESAM:
+ if (!xesam_iface) {
+ xesam_iface = tracker_db_manager_get_db_interfaces (7,
+ TRACKER_DB_CACHE,
+ TRACKER_DB_COMMON,
+ TRACKER_DB_FILE_CONTENTS,
+ TRACKER_DB_FILE_METADATA,
+ TRACKER_DB_EMAIL_CONTENTS,
+ TRACKER_DB_EMAIL_METADATA,
+ TRACKER_DB_XESAM);
+ }
+
+ iface = xesam_iface;
+ break;
+
+ case TRACKER_DB_TYPE_FILES:
default:
if (!file_iface) {
file_iface = tracker_db_manager_get_db_interfaces (4,
@@ -2574,6 +2549,7 @@
TRACKER_DB_FILE_METADATA,
TRACKER_DB_CACHE);
}
+
iface = file_iface;
break;
}
@@ -2581,6 +2557,7 @@
return iface;
}
+/*
TrackerDBInterface *
tracker_db_manager_get_db_interface_content (TrackerDBInterface *iface)
{
@@ -2603,4 +2580,4 @@
return NULL;
}
-
+*/
Modified: branches/xesam-support/src/libtracker-db/tracker-db-manager.h
==============================================================================
--- branches/xesam-support/src/libtracker-db/tracker-db-manager.h (original)
+++ branches/xesam-support/src/libtracker-db/tracker-db-manager.h Thu Jul 3 14:55:07 2008
@@ -40,16 +40,20 @@
} TrackerDB;
typedef enum {
- TRACKER_DB_MANAGER_ATTACH_ALL = 1 << 0,
- TRACKER_DB_MANAGER_FORCE_REINDEX = 1 << 1,
- TRACKER_DB_MANAGER_REMOVE_CACHE = 1 << 2,
+ TRACKER_DB_MANAGER_FORCE_REINDEX = 1 << 1,
+ TRACKER_DB_MANAGER_REMOVE_CACHE = 1 << 2,
+ TRACKER_DB_MANAGER_LOW_MEMORY_MODE = 1 << 3,
} TrackerDBManagerFlags;
+#define TRACKER_DB_FOR_FILE_SERVICE "Files"
+#define TRACKER_DB_FOR_EMAIL_SERVICE "Emails"
+#define TRACKER_DB_FOR_XESAM_SERVICE "Xesam"
+
GType tracker_db_get_type (void) G_GNUC_CONST;
void tracker_db_manager_init (TrackerDBManagerFlags flags,
gboolean *first_time);
-void tracker_db_manager_shutdown (gboolean remove_tmp);
+void tracker_db_manager_shutdown (void);
void tracker_db_manager_close_all (void);
@@ -59,11 +63,11 @@
TrackerDBInterface *
tracker_db_manager_get_db_interfaces (gint num, ...);
TrackerDBInterface *
- tracker_db_manager_get_db_interface_by_service (const gchar *service,
- gboolean content);
+ tracker_db_manager_get_db_interface_by_service (const gchar *service);
+/*
TrackerDBInterface *
tracker_db_manager_get_db_interface_content (TrackerDBInterface *iface);
-
+*/
G_END_DECLS
#endif /* __TRACKER_DB_MANAGER_H__ */
Modified: branches/xesam-support/src/tracker-indexer/modules/Makefile.am
==============================================================================
--- branches/xesam-support/src/tracker-indexer/modules/Makefile.am (original)
+++ branches/xesam-support/src/tracker-indexer/modules/Makefile.am Thu Jul 3 14:55:07 2008
@@ -12,13 +12,13 @@
$(GMODULE_CFLAGS) \
$(GIO_CFLAGS) \
$(GLIB2_CFLAGS) \
+ $(GCONF_CFLAGS) \
$(GMIME_CFLAGS)
indexer_modules_LTLIBRARIES = \
libtracker-indexer-applications.la \
libtracker-indexer-files.la \
- libtracker-indexer-gaim-conversations.la \
- libtracker-indexer-evolution.la
+ libtracker-indexer-gaim-conversations.la
# Applications module
libtracker_indexer_applications_la_SOURCES = applications.c
@@ -46,10 +46,18 @@
$(GIO_LIBS) \
$(GLIB2_LIBS)
+if HAVE_GCONF
+
+indexer_modules_LTLIBRARIES += \
+ libtracker-indexer-evolution.la
+
# Evolution
libtracker_indexer_evolution_la_SOURCES = evolution.c
libtracker_indexer_evolution_la_LDFLAGS = $(module_flags)
libtracker_indexer_evolution_la_LIBADD = \
$(GMODULE_LIBS) \
$(GLIB2_LIBS) \
+ $(GCONF_LIBS) \
$(GMIME_LIBS)
+
+endif
\ No newline at end of file
Modified: branches/xesam-support/src/tracker-indexer/modules/applications.c
==============================================================================
--- branches/xesam-support/src/tracker-indexer/modules/applications.c (original)
+++ branches/xesam-support/src/tracker-indexer/modules/applications.c Thu Jul 3 14:55:07 2008
@@ -49,49 +49,6 @@
return "Applications";
}
-gchar **
-tracker_module_get_directories (void)
-{
- GPtrArray *dirs;
- gchar *value, *dir;
-
- dirs = g_ptr_array_new ();
- value = getenv ("XDG_DATA_HOME");
-
- if (value) {
- dir = g_build_filename (value, "applications", NULL);
- } else {
- dir = g_build_filename (g_get_home_dir (), ".local/share/applications", NULL);
- }
-
- /* Add user defined applications path to service directory list */
- g_ptr_array_add (dirs, dir);
-
- /* Add system defined applications path to service directory list */
- value = getenv ("XDG_DATA_DIRS");
-
- if (value) {
- gchar **dir_array;
- gint i;
-
- dir_array = g_strsplit (value, ":", 0);
-
- for (i = 0; dir_array[i]; i++) {
- dir = g_build_filename (dir_array[i], "applications", NULL);
- g_ptr_array_add (dirs, dir);
- }
-
- g_strfreev (dir_array);
- } else {
- g_ptr_array_add (dirs, g_strdup ("/usr/share/applications"));
- g_ptr_array_add (dirs, g_strdup ("/usr/local/share/applications"));
- }
-
- g_ptr_array_add (dirs, NULL);
-
- return (gchar **) g_ptr_array_free (dirs, FALSE);
-}
-
static void
insert_data_from_desktop_file (GHashTable *metadata,
const gchar *metadata_key,
Modified: branches/xesam-support/src/tracker-indexer/modules/dummy.c
==============================================================================
--- branches/xesam-support/src/tracker-indexer/modules/dummy.c (original)
+++ branches/xesam-support/src/tracker-indexer/modules/dummy.c Thu Jul 3 14:55:07 2008
@@ -19,6 +19,24 @@
#include <glib.h>
+void
+tracker_module_init (void)
+{
+ /* Implementing this function is optional.
+ *
+ * Allocate here all static resources for the module.
+ */
+}
+
+void
+tracker_module_shutdown (void)
+{
+ /* Implementing this function is optional.
+ *
+ * Free here all resources allocated in tracker_module_init()
+ */
+}
+
G_CONST_RETURN gchar *
tracker_module_get_name (void)
{
@@ -26,13 +44,6 @@
return "Dummy";
}
-gchar **
-tracker_module_get_directories (void)
-{
- /* Return directories/files (a NULL-ended array of gchar*) to scan */
- return NULL;
-}
-
gpointer
tracker_module_file_get_data (const gchar *path)
{
Modified: branches/xesam-support/src/tracker-indexer/modules/evolution.c
==============================================================================
--- branches/xesam-support/src/tracker-indexer/modules/evolution.c (original)
+++ branches/xesam-support/src/tracker-indexer/modules/evolution.c Thu Jul 3 14:55:07 2008
@@ -25,6 +25,7 @@
#include <fcntl.h>
#include <string.h>
#include <stdlib.h>
+#include <gconf/gconf-client.h>
#include <tracker-indexer/tracker-module.h>
#include <libtracker-common/tracker-utils.h>
#include <libtracker-common/tracker-file-utils.h>
@@ -40,6 +41,7 @@
typedef union EvolutionFileData EvolutionFileData;
typedef struct EvolutionLocalData EvolutionLocalData;
typedef struct EvolutionImapData EvolutionImapData;
+typedef struct EvolutionAccountContext EvolutionAccountContext;
typedef enum MailStorageType MailStorageType;
enum MailStorageType {
@@ -77,8 +79,18 @@
SUMMARY_TYPE_TIME_T
};
+struct EvolutionAccountContext {
+ gchar *account;
+ gchar *uid;
+};
+
static gchar *local_dir = NULL;
static gchar *imap_dir = NULL;
+static GHashTable *accounts = NULL;
+
+
+void get_imap_accounts (void);
+
static gboolean
read_summary (FILE *summary,
@@ -182,6 +194,26 @@
return TRUE;
}
+void
+tracker_module_init (void)
+{
+ g_mime_init (0);
+ get_imap_accounts ();
+
+ local_dir = g_build_filename (g_get_home_dir (), ".evolution", "mail", "local", G_DIR_SEPARATOR_S, NULL);
+ imap_dir = g_build_filename (g_get_home_dir (), ".evolution", "mail", "imap", G_DIR_SEPARATOR_S, NULL);
+}
+
+void
+tracker_module_shutdown (void)
+{
+ g_mime_shutdown ();
+
+ g_hash_table_destroy (accounts);
+ g_free (local_dir);
+ g_free (imap_dir);
+}
+
G_CONST_RETURN gchar *
tracker_module_get_name (void)
{
@@ -189,21 +221,138 @@
return "EvolutionEmails";
}
-gchar **
-tracker_module_get_directories (void)
+static void
+account_start_element_handler (GMarkupParseContext *context,
+ const gchar *element_name,
+ const gchar **attr_names,
+ const gchar **attr_values,
+ gpointer user_data,
+ GError **error)
+{
+ EvolutionAccountContext *account_context;
+ gint i = 0;
+
+ if (strcmp (element_name, "account") != 0) {
+ return;
+ }
+
+ account_context = (EvolutionAccountContext *) user_data;
+
+ while (attr_names[i]) {
+ if (strcmp (attr_names[i], "uid") == 0) {
+ account_context->uid = g_strdup (attr_values[i]);
+ return;
+ }
+
+ i++;
+ }
+}
+
+static gchar *
+get_account_name_from_imap_uri (const gchar *imap_uri)
{
- gchar **dirs;
+ /* Assume url schema is:
+ * imap://foo imap free fr/;etc
+ * or
+ * imap://foo;auth=DIGEST-MD5 imap bar com/;etc
+ *
+ * We try to get "foo imap free fr".
+ */
- g_mime_init (0);
+ /* check for embedded @ and then look for first colon after that */
- local_dir = g_build_filename (g_get_home_dir (), ".evolution", "mail", "local", G_DIR_SEPARATOR_S, NULL);
- imap_dir = g_build_filename (g_get_home_dir (), ".evolution", "mail", "imap", G_DIR_SEPARATOR_S, NULL);
+ const gchar *start = imap_uri + 7;
+ const gchar *at = strchr (start, '@');
+ const gchar *semic = strchr (start, ';');
+
+ gchar *user_name = NULL;
+ gchar *at_host_name = NULL;
+ gchar *account_name = NULL;
- dirs = g_new0 (gchar *, 3);
- dirs[0] = g_strdup (local_dir);
- dirs[1] = g_strdup (imap_dir);
+ if ( strlen (imap_uri) < 7 || at == NULL ) {
+ return NULL;
+ }
+
+ if (semic < at) {
+ /* we have a ";auth=FOO host" schema
+ Set semic to the next semicolon, which ends the hostname. */
+ user_name = g_strndup (start, semic - start);
+ /* look for ';' at the end of the domain name */
+ semic = strchr (at, ';');
+ } else {
+ user_name = g_strndup (start, at - start);
+ }
- return dirs;
+ at_host_name = g_strndup (at, (semic - 1) - at);
+
+ account_name = g_strconcat (user_name, at_host_name, NULL);
+
+ g_free (user_name);
+ g_free (at_host_name);
+
+ return account_name;
+}
+
+static void
+account_text_handler (GMarkupParseContext *context,
+ const gchar *text,
+ gsize text_len,
+ gpointer user_data,
+ GError **error)
+{
+ EvolutionAccountContext *account_context;
+ const gchar *element;
+ gchar *url;
+
+ element = g_markup_parse_context_get_element (context);
+
+ if (strcmp (element, "url") != 0) {
+ return;
+ }
+
+ account_context = (EvolutionAccountContext *) user_data;
+
+ url = g_strndup (text, text_len);
+ account_context->account = get_account_name_from_imap_uri (url);
+ g_free (url);
+}
+
+void
+get_imap_accounts (void)
+{
+ GConfClient *client;
+ GMarkupParser parser = { 0 };
+ GMarkupParseContext *parse_context;
+ GSList *list, *l;
+ EvolutionAccountContext account_context = { 0 };
+
+ client = gconf_client_get_default ();
+
+ list = gconf_client_get_list (client,
+ "/apps/evolution/mail/accounts",
+ GCONF_VALUE_STRING,
+ NULL);
+
+ parser.start_element = account_start_element_handler;
+ parser.text = account_text_handler;
+ parse_context = g_markup_parse_context_new (&parser, 0, &account_context, NULL);
+
+ accounts = g_hash_table_new_full (g_str_hash, g_str_equal,
+ (GDestroyNotify) g_free,
+ (GDestroyNotify) g_free);
+
+ for (l = list; l; l = l->next) {
+ g_markup_parse_context_parse (parse_context, (const gchar *) l->data, -1, NULL);
+
+ g_hash_table_insert (accounts,
+ account_context.account,
+ account_context.uid);
+ }
+
+ g_markup_parse_context_free (parse_context);
+
+ g_slist_foreach (list, (GFunc) g_free, NULL);
+ g_slist_free (list);
}
static MailStorageType
@@ -488,11 +637,49 @@
}
}
+void
+get_imap_uri (const gchar *path,
+ gchar **uri_base,
+ gchar **basename)
+{
+ GList *keys, *k;
+ gchar *dir, *subdirs;
+
+ keys = g_hash_table_get_keys (accounts);
+ *uri_base = *basename = NULL;
+
+ for (k = keys; k; k = k->next) {
+ if (strstr (path, k->data)) {
+ *uri_base = g_strdup_printf ("email://%s", (gchar *) g_hash_table_lookup (accounts, k->data));
+
+ dir = g_build_filename (imap_dir, k->data, NULL);
+
+ /* now remove all relevant info to create the email:// basename */
+ subdirs = g_strdup (path);
+ subdirs = tracker_string_remove (subdirs, dir);
+ subdirs = tracker_string_remove (subdirs, "/folders");
+ subdirs = tracker_string_remove (subdirs, "/subfolders");
+ subdirs = tracker_string_remove (subdirs, "/summary");
+
+ *basename = subdirs;
+
+ g_free (dir);
+
+ break;
+ }
+ }
+
+ g_list_free (keys);
+
+ return;
+}
+
GHashTable *
get_metadata_for_imap (TrackerFile *file)
{
EvolutionImapData *data;
GHashTable *metadata;
+ gchar *dirname, *basename;
gchar *uid, *subject, *from, *to;
gint32 i, count;
time_t date;
@@ -520,6 +707,12 @@
NULL,
(GDestroyNotify) g_free);
+ get_imap_uri (file->path, &dirname, &basename);
+
+ g_hash_table_insert (metadata, METADATA_FILE_PATH, dirname);
+ g_hash_table_insert (metadata, METADATA_FILE_NAME, g_strdup_printf ("%s;uid=%s", basename, uid));
+ g_free (basename);
+
g_hash_table_insert (metadata, METADATA_EMAIL_DATE,
tracker_uint_to_string (date));
Modified: branches/xesam-support/src/tracker-indexer/modules/files.c
==============================================================================
--- branches/xesam-support/src/tracker-indexer/modules/files.c (original)
+++ branches/xesam-support/src/tracker-indexer/modules/files.c Thu Jul 3 14:55:07 2008
@@ -50,51 +50,7 @@
return "Files";
}
-gchar **
-tracker_module_get_directories (void)
-{
- GSList *watch_roots;
- GPtrArray *dirs;
-
- if (!config) {
- config = tracker_config_new ();
- }
-
- watch_roots = tracker_config_get_watch_directory_roots (config);
- dirs = g_ptr_array_new ();
-
- for (; watch_roots; watch_roots = watch_roots->next) {
- g_ptr_array_add (dirs, g_strdup (watch_roots->data));
- }
-
- g_ptr_array_add (dirs, NULL);
-
- return (gchar **) g_ptr_array_free (dirs, FALSE);
-}
-
-gchar **
-tracker_module_get_ignore_directories (void)
-{
- GSList *ignore_roots;
- GPtrArray *dirs;
-
- if (!config) {
- config = tracker_config_new ();
- }
-
- ignore_roots = tracker_config_get_no_watch_directory_roots (config);
- dirs = g_ptr_array_new ();
-
- for (; ignore_roots; ignore_roots = ignore_roots->next) {
- g_ptr_array_add (dirs, g_strdup (ignore_roots->data));
- }
-
- g_ptr_array_add (dirs, NULL);
-
- return (gchar **) g_ptr_array_free (dirs, FALSE);
-}
-
-void
+static void
tracker_metadata_get_embedded (const char *path,
const char *mimetype,
GHashTable *table)
@@ -114,6 +70,8 @@
return;
}
+ g_free (service_type);
+
/* we extract metadata out of process using pipes */
argv = g_new0 (gchar *, 4);
argv[0] = g_strdup ("tracker-extract");
Modified: branches/xesam-support/src/tracker-indexer/modules/gaim-conversations.c
==============================================================================
--- branches/xesam-support/src/tracker-indexer/modules/gaim-conversations.c (original)
+++ branches/xesam-support/src/tracker-indexer/modules/gaim-conversations.c Thu Jul 3 14:55:07 2008
@@ -26,18 +26,6 @@
return "GaimConversations";
}
-gchar **
-tracker_module_get_directories (void)
-{
- gchar **log_directories;
-
- log_directories = g_new0 (gchar*, 3);
- log_directories[0] = g_build_filename (g_get_home_dir(), ".gaim", "logs", NULL);
- log_directories[1] = g_build_filename (g_get_home_dir(), ".purple", "logs", NULL);
-
- return log_directories;
-}
-
GHashTable *
tracker_module_get_file_metadata (const gchar *file)
{
Modified: branches/xesam-support/src/tracker-indexer/tracker-index.c
==============================================================================
--- branches/xesam-support/src/tracker-indexer/tracker-index.c (original)
+++ branches/xesam-support/src/tracker-indexer/tracker-index.c Thu Jul 3 14:55:07 2008
@@ -42,8 +42,28 @@
* metadata */
};
+/* This functions will be used also in the search code! */
+static inline gint16
+index_get_score (TrackerIndexElement *element)
+{
+ unsigned char a[2];
+
+ a[0] = (element->amalgamated >> 16) & 0xFF;
+ a[1] = (element->amalgamated >> 8) & 0xFF;
+
+ return (gint16) (a[0] << 8) | (a[1]);
+}
+
+
+static inline guint8
+index_get_service_type (TrackerIndexElement *element)
+{
+ return (element->amalgamated >> 24) & 0xFF;
+}
+
+
static guint32
-tracker_index_calc_amalgamated (gint service,
+index_calc_amalgamated (gint service,
gint weight)
{
unsigned char a[4];
@@ -64,12 +84,14 @@
return (a[0] << 24) | (a[1] << 16) | (a[2] << 8) | a[3];
}
+
static void
free_cache_values (GArray *array)
{
g_array_free (array, TRUE);
}
+
TrackerIndex *
tracker_index_new (const gchar *file,
gint bucket_count)
@@ -87,6 +109,7 @@
return index;
}
+
void
tracker_index_free (TrackerIndex *index)
{
@@ -99,6 +122,7 @@
g_free (index);
}
+
void
tracker_index_add_word (TrackerIndex *index,
const gchar *word,
@@ -108,21 +132,156 @@
{
TrackerIndexElement elem;
GArray *array;
+ guint i, new_score;
+ TrackerIndexElement *current;
elem.id = service_id;
- elem.amalgamated = tracker_index_calc_amalgamated (service_type, weight);
+ elem.amalgamated = index_calc_amalgamated (service_type, weight);
array = g_hash_table_lookup (index->cache, word);
if (!array) {
- /* create the array if it didn't exist */
+ /* create the array if it didn't exist (first time we find the word) */
array = g_array_new (FALSE, TRUE, sizeof (TrackerIndexElement));
g_hash_table_insert (index->cache, g_strdup (word), array);
+ g_array_append_val (array, elem);
+ return;
+ }
+
+ /* It is not the first time we find the word */
+ for (i = 0; i < array->len; i++) {
+
+ current = &g_array_index (array, TrackerIndexElement, i);
+
+ if (current->id == service_id) {
+ /* The word was already found in the same service_id (file), increase score */
+ new_score = index_get_score (current) + weight;
+ current->amalgamated = index_calc_amalgamated (index_get_service_type (current),
+ new_score);
+ return;
+ }
}
+ /* First time in the file */
g_array_append_val (array, elem);
}
+
+/* use for deletes or updates of multiple entities when they are not new */
+static gboolean
+indexer_update_word (DEPOT *index,
+ const gchar *word,
+ GArray *new_hits)
+{
+ gint tsiz, i, score;
+ guint j;
+ gint k;
+
+ TrackerIndexElement *new_hit, *previous_hits;
+ gboolean write_back = FALSE, edited = FALSE;
+ gint old_hit_count = 0;
+ GArray *pending_hits = NULL;
+ gboolean result;
+
+ g_return_val_if_fail (index, FALSE);
+ g_return_val_if_fail (word, FALSE);
+ g_return_val_if_fail (new_hits, FALSE);
+
+ previous_hits = (TrackerIndexElement *)dpget (index, word, -1, 0, MAX_HIT_BUFFER, &tsiz);
+
+ /* New word in the index */
+ if (previous_hits == NULL) {
+
+ result = dpput (index,
+ word, -1,
+ (char *) new_hits->data, (new_hits->len * sizeof (TrackerIndexElement)),
+ DP_DCAT);
+
+ if (!result) {
+ g_warning ("Could not store word: %s", word);
+ return FALSE;
+ }
+
+ return TRUE;
+ }
+
+ /* Word already exists */
+ old_hit_count = tsiz / sizeof (TrackerIndexElement);
+
+ for (j = 0; j < new_hits->len; j++) {
+
+ new_hit = &g_array_index (new_hits, TrackerIndexElement, j);
+
+ edited = FALSE;
+
+ for (i = 0; i < old_hit_count; i++) {
+
+ if (previous_hits[i].id == new_hit->id) {
+
+ write_back = TRUE;
+
+ /* NB the paramter score can be negative */
+ score = index_get_score (&previous_hits[i]) + index_get_score (new_hit);
+ /* g_print ("current score for %s is %d and new is %d and final is %d\n",
+ word, index_get_score (&previous_hits[i]), index_get_score (new_hit), score); */
+
+
+ /* check for deletion */
+ if (score < 1) {
+
+ /* g_print ("Deleting word hit %s\n", word); */
+
+ /* shift all subsequent records in array down one place */
+ for (k = i + 1; k < old_hit_count; k++) {
+ previous_hits[k - 1] = previous_hits[k];
+ }
+
+ old_hit_count--;
+
+ } else {
+ previous_hits[i].amalgamated = index_calc_amalgamated (index_get_service_type (&previous_hits[i]), score);
+ }
+
+ edited = TRUE;
+ break;
+ }
+ }
+
+ /* add hits that could not be updated directly here so they can be appended later */
+ if (!edited) {
+
+ if (!pending_hits) {
+ pending_hits = g_array_new (FALSE, TRUE, sizeof (TrackerIndexElement));
+ }
+
+ g_array_append_val (pending_hits, *new_hit);
+ g_debug ("could not update word hit %s - appending", word);
+ }
+ }
+
+ /* write back if we have modded anything */
+ if (write_back) {
+ dpput (index,
+ word, -1,
+ (char *) previous_hits, (old_hit_count * sizeof (TrackerIndexElement)),
+ DP_DOVER);
+ }
+
+ /* Append new occurences */
+ if (pending_hits) {
+ dpput (index,
+ word, -1,
+ (char *) pending_hits->data, (pending_hits->len * sizeof (TrackerIndexElement)),
+ DP_DCAT);
+ g_array_free (pending_hits, TRUE);
+ }
+
+ g_free (previous_hits);
+
+ return TRUE;
+}
+
+
static gboolean
cache_flush_foreach (gpointer key,
gpointer value,
@@ -131,28 +290,13 @@
GArray *array;
DEPOT *index;
gchar *word;
-#if 0
- gchar *tmp;
- gint table_size;
-#endif
word = (gchar *) key;
array = (GArray *) value;
index = (DEPOT *) user_data;
-#if 0
- if ((tmp = dpget (index, word, -1, 0, MAX_HIT_BUFFER, &table_size)) != NULL) {
- /* FIXME: missing merge with previous values */
- }
-#endif
-
- if (!dpput (index, word, -1, (char *) array->data, (array->len * sizeof (TrackerIndexElement)), DP_DCAT)) {
- g_warning ("Could not store word: %s", word);
- return FALSE;
- }
-
- /* Mark element for removal */
- return TRUE;
+ /* Mark element for removal if succesfull insertion */
+ return indexer_update_word (index, word, array);
}
guint
Modified: branches/xesam-support/src/tracker-indexer/tracker-indexer-db.c
==============================================================================
--- branches/xesam-support/src/tracker-indexer/tracker-indexer-db.c (original)
+++ branches/xesam-support/src/tracker-indexer/tracker-indexer-db.c Thu Jul 3 14:55:07 2008
@@ -27,6 +27,17 @@
#include "tracker-indexer-db.h"
+void
+tracker_db_inc_service_id (TrackerDBInterface *iface, guint32 id)
+{
+ gchar *id_str;
+
+ id_str = tracker_int_to_string (id);
+
+ tracker_db_interface_execute_procedure (iface, NULL, "UpdateNewID", id_str, NULL);
+ g_free (id_str);
+}
+
guint32
tracker_db_get_new_service_id (TrackerDBInterface *iface)
{
@@ -45,15 +56,21 @@
g_object_unref (result_set);
id = atoi (id_str);
+ id++;
g_free (id_str);
- id++;
+ return id;
+}
+
+void
+tracker_db_inc_event_id (TrackerDBInterface *iface, guint32 id)
+{
+ gchar *id_str;
+
id_str = tracker_int_to_string (id);
- tracker_db_interface_execute_procedure (iface, NULL, "UpdateNewID", id_str, NULL);
+ tracker_db_interface_execute_procedure (iface, NULL, "UpdateNewEventID", id_str, NULL);
g_free (id_str);
-
- return id;
}
guint32
@@ -74,12 +91,7 @@
g_object_unref (result_set);
id = atoi (id_str);
- g_free (id_str);
-
id++;
- id_str = tracker_int_to_string (id);
-
- tracker_db_interface_execute_procedure (iface, NULL, "UpdateNewEventID", id_str, NULL);
g_free (id_str);
return id;
Modified: branches/xesam-support/src/tracker-indexer/tracker-indexer-db.h
==============================================================================
--- branches/xesam-support/src/tracker-indexer/tracker-indexer-db.h (original)
+++ branches/xesam-support/src/tracker-indexer/tracker-indexer-db.h Thu Jul 3 14:55:07 2008
@@ -48,6 +48,11 @@
guint32 id,
guint32 service_id,
const gchar *type);
+void tracker_db_inc_service_id (TrackerDBInterface *iface,
+ guint32 id);
+void tracker_db_inc_event_id (TrackerDBInterface *iface,
+ guint32 id);
+
G_END_DECLS
Modified: branches/xesam-support/src/tracker-indexer/tracker-indexer-module.c
==============================================================================
--- branches/xesam-support/src/tracker-indexer/tracker-indexer-module.c (original)
+++ branches/xesam-support/src/tracker-indexer/tracker-indexer-module.c Thu Jul 3 14:55:07 2008
@@ -48,38 +48,34 @@
return module;
}
-G_CONST_RETURN gchar *
-tracker_indexer_module_get_name (GModule *module)
+void
+tracker_indexer_module_init (GModule *module)
{
- TrackerModuleGetNameFunc func;
+ TrackerModuleInit func;
- if (g_module_symbol (module, "tracker_module_get_name", (gpointer *) &func)) {
- return (func) ();
+ if (g_module_symbol (module, "tracker_module_init", (gpointer *) &func)) {
+ (func) ();
}
-
- return NULL;
}
-gchar **
-tracker_indexer_module_get_directories (GModule *module)
+void
+tracker_indexer_module_shutdown (GModule *module)
{
- TrackerModuleGetDirectoriesFunc func;
-
- if (g_module_symbol (module, "tracker_module_get_directories", (gpointer *) &func)) {
- return (func) ();
- }
+ TrackerModuleShutdown func;
- return NULL;
+ if (g_module_symbol (module, "tracker_module_shutdown", (gpointer *) &func)) {
+ (func) ();
+ }
}
-gchar **
-tracker_indexer_module_get_ignore_directories (GModule *module)
+G_CONST_RETURN gchar *
+tracker_indexer_module_get_name (GModule *module)
{
- TrackerModuleGetDirectoriesFunc func;
+ TrackerModuleGetNameFunc func;
- if (g_module_symbol (module, "tracker_module_get_ignore_directories", (gpointer *) &func)) {
+ if (g_module_symbol (module, "tracker_module_get_name", (gpointer *) &func)) {
return (func) ();
- }
+ }
return NULL;
}
Modified: branches/xesam-support/src/tracker-indexer/tracker-indexer-module.h
==============================================================================
--- branches/xesam-support/src/tracker-indexer/tracker-indexer-module.h (original)
+++ branches/xesam-support/src/tracker-indexer/tracker-indexer-module.h Thu Jul 3 14:55:07 2008
@@ -29,9 +29,10 @@
GModule * tracker_indexer_module_load (const gchar *module_name);
+void tracker_indexer_module_init (GModule *module);
+void tracker_indexer_module_shutdown (GModule *module);
+
G_CONST_RETURN gchar * tracker_indexer_module_get_name (GModule *module);
-gchar ** tracker_indexer_module_get_directories (GModule *module);
-gchar ** tracker_indexer_module_get_ignore_directories (GModule *module);
TrackerFile * tracker_indexer_module_file_new (GModule *module,
const gchar *path);
Modified: branches/xesam-support/src/tracker-indexer/tracker-indexer.c
==============================================================================
--- branches/xesam-support/src/tracker-indexer/tracker-indexer.c (original)
+++ branches/xesam-support/src/tracker-indexer/tracker-indexer.c Thu Jul 3 14:55:07 2008
@@ -39,8 +39,13 @@
* Once all queues are empty, all elements have been inspected, and the
* indexer will emit the ::finished signal, this behavior can be observed
* in the indexing_func() function.
+ *
+ * NOTE: Normally all indexing petitions will be sent over DBus, being
+ * everything just pushed in the files queue.
*/
+#include "config.h"
+
#include <stdlib.h>
#include <string.h>
@@ -50,9 +55,11 @@
#include <libtracker-common/tracker-config.h>
#include <libtracker-common/tracker-dbus.h>
#include <libtracker-common/tracker-file-utils.h>
+#include <libtracker-common/tracker-hal.h>
#include <libtracker-common/tracker-language.h>
#include <libtracker-common/tracker-parser.h>
#include <libtracker-common/tracker-ontology.h>
+#include <libtracker-common/tracker-module-config.h>
#include <libtracker-db/tracker-db-manager.h>
#include <libtracker-db/tracker-db-interface-sqlite.h>
@@ -66,7 +73,14 @@
#define TRACKER_INDEXER_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), TRACKER_TYPE_INDEXER, TrackerIndexerPrivate))
/* Flush every 'x' seconds */
-#define FLUSH_FREQUENCY 10
+#define FLUSH_FREQUENCY 10
+
+/* Transaction every 'x' items */
+#define TRANSACTION_MAX 50
+
+/* Throttle defaults */
+#define THROTTLE_DEFAULT 0
+#define THROTTLE_DEFAULT_ON_BATTERY 5
typedef struct TrackerIndexerPrivate TrackerIndexerPrivate;
typedef struct PathInfo PathInfo;
@@ -75,14 +89,15 @@
struct TrackerIndexerPrivate {
GQueue *dir_queue;
GQueue *file_process_queue;
+ GQueue *modules_queue;
- GSList *module_names;
- GSList *current_module;
+ GList *module_names;
GHashTable *indexer_modules;
gchar *db_dir;
TrackerIndex *index;
+
TrackerDBInterface *metadata;
TrackerDBInterface *contents;
TrackerDBInterface *common;
@@ -91,11 +106,17 @@
TrackerConfig *config;
TrackerLanguage *language;
+#ifdef HAVE_HAL
+ TrackerHal *hal;
+#endif /* HAVE_HAL */
+
GTimer *timer;
- guint items_indexed;
+ guint items_indexed;
guint idle_id;
guint flush_id;
+ gint items_processed;
+ gboolean in_transaction;
};
struct PathInfo {
@@ -148,6 +169,40 @@
g_slice_free (PathInfo, info);
}
+
+static void
+start_transaction (TrackerIndexer *indexer)
+{
+ TrackerIndexerPrivate *priv;
+ priv = TRACKER_INDEXER_GET_PRIVATE (indexer);
+
+ g_message ("Transaction start");
+ priv->in_transaction = TRUE;
+
+ tracker_db_interface_start_transaction (priv->cache);
+ tracker_db_interface_start_transaction (priv->contents);
+ tracker_db_interface_start_transaction (priv->metadata);
+ tracker_db_interface_start_transaction (priv->common);
+
+}
+
+static void
+stop_transaction (TrackerIndexer *indexer)
+{
+ TrackerIndexerPrivate *priv;
+ priv = TRACKER_INDEXER_GET_PRIVATE (indexer);
+
+ tracker_db_interface_end_transaction (priv->common);
+ tracker_db_interface_end_transaction (priv->metadata);
+ tracker_db_interface_end_transaction (priv->contents);
+ tracker_db_interface_end_transaction (priv->cache);
+
+ priv->items_processed = 0;
+ priv->in_transaction = FALSE;
+
+ g_message ("Transaction commit");
+}
+
static gboolean
schedule_flush_cb (gpointer data)
{
@@ -161,6 +216,10 @@
priv->items_indexed += tracker_index_flush (priv->index);
+ if (priv->items_processed) {
+ stop_transaction (indexer);
+ }
+
return FALSE;
}
@@ -183,6 +242,62 @@
}
static void
+set_up_throttle (TrackerIndexer *indexer)
+{
+#ifdef HAVE_HAL
+ TrackerIndexerPrivate *priv;
+ gint throttle;
+
+ priv = TRACKER_INDEXER_GET_PRIVATE (indexer);
+
+ /* If on a laptop battery and the throttling is default (i.e.
+ * 0), then set the throttle to be higher so we don't kill
+ * the laptop battery.
+ */
+ throttle = tracker_config_get_throttle (priv->config);
+
+ if (tracker_hal_get_battery_in_use (priv->hal)) {
+ g_message ("We are running on battery");
+
+ if (throttle == THROTTLE_DEFAULT) {
+ tracker_config_set_throttle (priv->config,
+ THROTTLE_DEFAULT_ON_BATTERY);
+ g_message ("Setting throttle from %d to %d",
+ throttle,
+ THROTTLE_DEFAULT_ON_BATTERY);
+ } else {
+ g_message ("Not setting throttle, it is currently set to %d",
+ throttle);
+ }
+ } else {
+ g_message ("We are not running on battery");
+
+ if (throttle == THROTTLE_DEFAULT_ON_BATTERY) {
+ tracker_config_set_throttle (priv->config,
+ THROTTLE_DEFAULT);
+ g_message ("Setting throttle from %d to %d",
+ throttle,
+ THROTTLE_DEFAULT);
+ } else {
+ g_message ("Not setting throttle, it is currently set to %d",
+ throttle);
+ }
+ }
+#else /* HAVE_HAL */
+ g_message ("HAL is not available to know if we are using a battery or not.");
+ g_message ("Not setting the throttle");
+#endif /* HAVE_HAL */
+}
+
+static void
+notify_battery_in_use_cb (GObject *gobject,
+ GParamSpec *arg1,
+ gpointer user_data)
+{
+ set_up_throttle (TRACKER_INDEXER (user_data));
+}
+
+static void
tracker_indexer_finalize (GObject *object)
{
TrackerIndexerPrivate *priv;
@@ -195,12 +310,13 @@
if (priv->flush_id) {
g_source_remove (priv->flush_id);
schedule_flush (TRACKER_INDEXER (object), TRUE);
- }
+ }
if (priv->timer) {
g_timer_destroy (priv->timer);
}
+ g_list_free (priv->module_names);
g_free (priv->db_dir);
g_queue_foreach (priv->dir_queue, (GFunc) path_info_free, NULL);
@@ -209,8 +325,19 @@
g_queue_foreach (priv->file_process_queue, (GFunc) path_info_free, NULL);
g_queue_free (priv->file_process_queue);
+ /* The queue doesn't own the module names */
+ g_queue_free (priv->modules_queue);
+
g_hash_table_destroy (priv->indexer_modules);
+#ifdef HAVE_HAL
+ g_signal_handlers_disconnect_by_func (priv->hal,
+ notify_battery_in_use_cb,
+ TRACKER_INDEXER (object));
+
+ g_object_unref (priv->hal);
+#endif /* HAVE_HAL */
+
g_object_unref (priv->config);
g_object_unref (priv->language);
@@ -278,8 +405,10 @@
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (TrackerIndexerClass, finished),
NULL, NULL,
- g_cclosure_marshal_VOID__VOID,
- G_TYPE_NONE, 0);
+ g_cclosure_marshal_VOID__UINT,
+ G_TYPE_NONE,
+ 1,
+ G_TYPE_UINT);
signals [INDEX_UPDATED] =
g_signal_new ("index-updated",
G_OBJECT_CLASS_TYPE (object_class),
@@ -301,41 +430,68 @@
}
static void
+close_module (GModule *module)
+{
+ tracker_indexer_module_shutdown (module);
+ g_module_close (module);
+}
+
+static void
tracker_indexer_init (TrackerIndexer *indexer)
{
TrackerIndexerPrivate *priv;
gchar *index_file;
- GSList *m;
+ GList *m;
priv = TRACKER_INDEXER_GET_PRIVATE (indexer);
+ priv->items_processed = 0;
+ priv->in_transaction = FALSE;
priv->dir_queue = g_queue_new ();
priv->file_process_queue = g_queue_new ();
+ priv->modules_queue = g_queue_new ();
priv->config = tracker_config_new ();
+
+#ifdef HAVE_HAL
+ priv->hal = tracker_hal_new ();
+
+ g_signal_connect (priv->hal, "notify::battery-in-use",
+ G_CALLBACK (notify_battery_in_use_cb),
+ indexer);
+
+ set_up_throttle (indexer);
+#endif /* HAVE_HAL */
+
priv->language = tracker_language_new (priv->config);
priv->db_dir = g_build_filename (g_get_user_cache_dir (),
"tracker",
NULL);
- priv->module_names = tracker_config_get_index_modules (priv->config);
+ priv->module_names = tracker_module_config_get_modules ();
priv->indexer_modules = g_hash_table_new_full (g_str_hash,
g_str_equal,
NULL,
- (GDestroyNotify) g_module_close);
+ (GDestroyNotify) close_module);
for (m = priv->module_names; m; m = m->next) {
GModule *module;
+ if (!tracker_module_config_get_enabled (m->data)) {
+ continue;
+ }
+
module = tracker_indexer_module_load (m->data);
if (module) {
+ tracker_indexer_module_init (module);
+
g_hash_table_insert (priv->indexer_modules,
m->data, module);
}
}
-
+
index_file = g_build_filename (priv->db_dir, "file-index.db", NULL);
priv->index = tracker_index_new (index_file,
@@ -343,10 +499,7 @@
priv->cache = tracker_db_manager_get_db_interface (TRACKER_DB_CACHE);
priv->common = tracker_db_manager_get_db_interface (TRACKER_DB_COMMON);
- priv->metadata = tracker_db_manager_get_db_interfaces (3,
- TRACKER_DB_COMMON,
- TRACKER_DB_CACHE,
- TRACKER_DB_FILE_METADATA);
+ priv->metadata = tracker_db_manager_get_db_interface (TRACKER_DB_FILE_METADATA);
priv->contents = tracker_db_manager_get_db_interface (TRACKER_DB_FILE_CONTENTS);
priv->timer = g_timer_new ();
@@ -375,23 +528,12 @@
{
TrackerIndexerPrivate *priv;
gboolean ignore = FALSE;
- gchar **ignore_dirs;
- gint i;
g_return_if_fail (info != NULL);
priv = TRACKER_INDEXER_GET_PRIVATE (indexer);
- ignore_dirs = tracker_indexer_module_get_ignore_directories (info->module);
-
- if (ignore_dirs) {
- for (i = 0; ignore_dirs[i]; i++) {
- if (strcmp (info->file->path, ignore_dirs[i]) == 0) {
- ignore = TRUE;
- break;
- }
- }
- }
+ /* FIXME: check ignored directories */
if (!ignore) {
g_queue_push_tail (priv->dir_queue, info);
@@ -399,8 +541,25 @@
g_message ("Ignoring directory:'%s'", info->file->path);
path_info_free (info);
}
+}
- g_strfreev (ignore_dirs);
+static void
+indexer_throttle (TrackerConfig *config,
+ gint multiplier)
+{
+ gint throttle;
+
+ throttle = tracker_config_get_throttle (config);
+
+ if (throttle < 1) {
+ return;
+ }
+
+ throttle *= multiplier;
+
+ if (throttle > 0) {
+ g_usleep (throttle);
+ }
}
static void
@@ -412,12 +571,20 @@
MetadataForeachData *data;
gchar *parsed_value;
gchar **arr;
+ gint throttle;
gint i;
if (!value) {
return;
}
+ /* Throttle indexer, value 9 is from older code, why 9? */
+ throttle = tracker_config_get_throttle (data->config);
+ if (throttle > 9) {
+ indexer_throttle (data->config, throttle * 100);
+ }
+
+ /* Parse */
field = tracker_ontology_get_field_def ((gchar *) key);
data = (MetadataForeachData *) user_data;
@@ -473,42 +640,40 @@
process_file (TrackerIndexer *indexer,
PathInfo *info)
{
+ TrackerIndexerPrivate *priv;
GHashTable *metadata;
g_message ("Processing file:'%s'", info->file->path);
+ priv = TRACKER_INDEXER_GET_PRIVATE (indexer);
+
+ /* Sleep to throttle back indexing */
+ indexer_throttle (priv->config, 100);
+
+ /* Process file */
metadata = tracker_indexer_module_file_get_metadata (info->module, info->file);
if (metadata) {
TrackerService *service;
- TrackerIndexerPrivate *priv;
const gchar *service_type;
guint32 id;
- priv = TRACKER_INDEXER_GET_PRIVATE (indexer);
-
service_type = tracker_indexer_module_get_name (info->module);
service = tracker_ontology_get_service_type_by_name (service_type);
id = tracker_db_get_new_service_id (priv->common);
- /* Begin of transaction point X */
-
- /* If you ever need to remove this transaction, because it gets
- * wrapped into a larger one, that's fine IF you indeed have a
- * larger one in place that spans cache,common and the selected
- * metadata database file */
-
- tracker_db_interface_start_transaction (priv->metadata);
-
if (tracker_db_create_service (priv->metadata, id, service, info->file->path, metadata)) {
gchar *text;
guint32 eid;
+ gboolean inc_events = FALSE;
- eid = tracker_db_get_new_event_id (priv->metadata);
+ eid = tracker_db_get_new_event_id (priv->common);
- tracker_db_create_event (priv->metadata, eid, id, "Create");
+ if (tracker_db_create_event (priv->cache, eid, id, "Create")) {
+ inc_events = TRUE;
+ }
- tracker_db_increment_stats (priv->metadata, service);
+ tracker_db_increment_stats (priv->common, service);
index_metadata (indexer, id, service, metadata);
@@ -518,11 +683,12 @@
tracker_db_set_text (priv->contents, id, text);
g_free (text);
}
+
+ if (inc_events)
+ tracker_db_inc_event_id (priv->common, eid);
+
+ tracker_db_inc_service_id (priv->common, id);
}
-
- tracker_db_interface_end_transaction (priv->metadata);
-
- /* End of transaction point X */
g_hash_table_destroy (metadata);
}
@@ -572,8 +738,7 @@
{
TrackerIndexerPrivate *priv;
GModule *module;
- gchar **dirs;
- gint i;
+ GList *dirs, *d;
priv = TRACKER_INDEXER_GET_PRIVATE (indexer);
module = g_hash_table_lookup (priv->indexer_modules, module_name);
@@ -585,19 +750,17 @@
g_message ("Starting module:'%s'", module_name);
- dirs = tracker_indexer_module_get_directories (module);
+ dirs = tracker_module_config_get_monitor_recurse_directories (module_name);
g_return_if_fail (dirs != NULL);
- for (i = 0; dirs[i]; i++) {
+ for (d = dirs; d; d = d->next) {
PathInfo *info;
- info = path_info_new (module, dirs[i]);
+ info = path_info_new (module, d->data);
tracker_indexer_add_directory (indexer, info);
-
- g_free (dirs[i]);
}
- g_free (dirs);
+ g_list_free (dirs);
}
static gboolean
@@ -606,48 +769,60 @@
TrackerIndexer *indexer;
TrackerIndexerPrivate *priv;
PathInfo *path;
+ gchar *module;
indexer = (TrackerIndexer *) data;
priv = TRACKER_INDEXER_GET_PRIVATE (indexer);
+ priv->items_processed++;
+
+ if (!priv->in_transaction) {
+ start_transaction (indexer);
+ }
+
if ((path = g_queue_peek_head (priv->file_process_queue)) != NULL) {
/* Process file */
if (process_file (indexer, path)) {
path = g_queue_pop_head (priv->file_process_queue);
path_info_free (path);
}
+ priv->items_processed++;
} else if ((path = g_queue_pop_head (priv->dir_queue)) != NULL) {
/* Process directory contents */
process_directory (indexer, path, TRUE);
path_info_free (path);
} else {
/* Dirs/files queues are empty, process the next module */
- if (!priv->current_module) {
- priv->current_module = priv->module_names;
- } else {
- priv->current_module = priv->current_module->next;
- }
+ module = g_queue_pop_head (priv->modules_queue);
- if (!priv->current_module) {
+ if (!module) {
/* Flush remaining items */
schedule_flush (indexer, TRUE);
/* No more modules to query, we're done */
g_timer_stop (priv->timer);
+ if (priv->in_transaction) {
+ stop_transaction (indexer);
+ }
+
g_message ("Indexer finished in %4.4f seconds, %d items indexed in total",
g_timer_elapsed (priv->timer, NULL),
priv->items_indexed);
- g_signal_emit (indexer, signals[FINISHED], 0);
+ g_signal_emit (indexer, signals[FINISHED], 0, priv->items_indexed);
return FALSE;
}
- process_module (indexer, priv->current_module->data);
+ process_module (indexer, module);
g_signal_emit (indexer, signals[INDEX_UPDATED], 0);
}
+ if (priv->items_processed > TRANSACTION_MAX && priv->in_transaction) {
+ stop_transaction (indexer);
+ }
+
return TRUE;
}
@@ -719,8 +894,22 @@
return TRUE;
}
+void
+tracker_indexer_process_all (TrackerIndexer *indexer)
+{
+ TrackerIndexerPrivate *priv;
+ GList *m;
+
+ priv = TRACKER_INDEXER_GET_PRIVATE (indexer);
+
+ for (m = priv->module_names; m; m = m->next) {
+ g_queue_push_tail (priv->modules_queue, m->data);
+ }
+}
+
gboolean
tracker_indexer_files_check (TrackerIndexer *indexer,
+ const gchar *module_name,
GStrv files,
GError **error)
{
@@ -739,13 +928,12 @@
"DBus request to check %d files",
g_strv_length (files));
- /* Assume we're using always the files module, bail out if it's not available */
- module = g_hash_table_lookup (priv->indexer_modules, "files");
+ module = g_hash_table_lookup (priv->indexer_modules, module_name);
if (!module) {
tracker_dbus_request_failed (request_id,
error,
- "The files module is not loaded");
+ "The module is not loaded");
return FALSE;
}
@@ -764,6 +952,7 @@
gboolean
tracker_indexer_files_update (TrackerIndexer *indexer,
+ const gchar *module_name,
GStrv files,
GError **error)
{
@@ -782,13 +971,12 @@
"DBus request to update %d files",
g_strv_length (files));
- /* Assume we're using always the files module, bail out if it's not available */
- module = g_hash_table_lookup (priv->indexer_modules, "files");
+ module = g_hash_table_lookup (priv->indexer_modules, module_name);
if (!module) {
tracker_dbus_request_failed (request_id,
error,
- "The files module is not loaded");
+ "The module is not loaded");
return FALSE;
}
@@ -807,6 +995,7 @@
gboolean
tracker_indexer_files_delete (TrackerIndexer *indexer,
+ const gchar *module_name,
GStrv files,
GError **error)
{
@@ -825,13 +1014,12 @@
"DBus request to delete %d files",
g_strv_length (files));
- /* Assume we're using always the files module, bail out if it's not available */
- module = g_hash_table_lookup (priv->indexer_modules, "files");
+ module = g_hash_table_lookup (priv->indexer_modules, module_name);
if (!module) {
tracker_dbus_request_failed (request_id,
error,
- "The files module is not loaded");
+ "The module is not loaded");
return FALSE;
}
Modified: branches/xesam-support/src/tracker-indexer/tracker-indexer.h
==============================================================================
--- branches/xesam-support/src/tracker-indexer/tracker-indexer.h (original)
+++ branches/xesam-support/src/tracker-indexer/tracker-indexer.h Thu Jul 3 14:55:07 2008
@@ -47,27 +47,33 @@
struct TrackerIndexerClass {
GObjectClass parent_class;
- void (*finished) (TrackerIndexer *indexer);
+ void (*finished) (TrackerIndexer *indexer,
+ guint items_indexed);
void (*index_updated) (TrackerIndexer *indexer);
};
-GType tracker_indexer_get_type (void) G_GNUC_CONST;
-TrackerIndexer *tracker_indexer_new (void);
-gboolean tracker_indexer_set_running (TrackerIndexer *indexer,
- gboolean should_be_running,
- GError **error);
-gboolean tracker_indexer_get_running (TrackerIndexer *indexer,
- gboolean *is_running,
- GError **error);
-gboolean tracker_indexer_files_check (TrackerIndexer *indexer,
- GStrv files,
- GError **error);
-gboolean tracker_indexer_files_update (TrackerIndexer *indexer,
- GStrv files,
- GError **error);
-gboolean tracker_indexer_files_delete (TrackerIndexer *indexer,
- GStrv files,
- GError **error);
+GType tracker_indexer_get_type (void) G_GNUC_CONST;
+TrackerIndexer *tracker_indexer_new (void);
+gboolean tracker_indexer_set_running (TrackerIndexer *indexer,
+ gboolean should_be_running,
+ GError **error);
+gboolean tracker_indexer_get_running (TrackerIndexer *indexer,
+ gboolean *is_running,
+ GError **error);
+void tracker_indexer_process_all (TrackerIndexer *indexer);
+gboolean tracker_indexer_files_check (TrackerIndexer *indexer,
+ const gchar *module,
+ GStrv files,
+ GError **error);
+gboolean tracker_indexer_files_update (TrackerIndexer *indexer,
+ const gchar *module,
+ GStrv files,
+ GError **error);
+gboolean tracker_indexer_files_delete (TrackerIndexer *indexer,
+ const gchar *module,
+ GStrv files,
+ GError **error);
+void tracker_indexer_process_all (TrackerIndexer *indexer);
G_END_DECLS
Modified: branches/xesam-support/src/tracker-indexer/tracker-main.c
==============================================================================
--- branches/xesam-support/src/tracker-indexer/tracker-main.c (original)
+++ branches/xesam-support/src/tracker-indexer/tracker-main.c Thu Jul 3 14:55:07 2008
@@ -33,6 +33,7 @@
#include <libtracker-common/tracker-config.h>
#include <libtracker-common/tracker-log.h>
#include <libtracker-common/tracker-ontology.h>
+#include <libtracker-common/tracker-module-config.h>
#include <libtracker-db/tracker-db-manager.h>
#include "tracker-dbus.h"
@@ -54,9 +55,13 @@
"\n" \
" http://www.gnu.org/licenses/gpl.txt\n"
+#define QUIT_TIMEOUT 10 /* Seconds */
+
static GMainLoop *main_loop;
-
+static guint quit_timeout_id;
+
static gint verbosity = -1;
+static gboolean process_all = FALSE;
static GOptionEntry entries[] = {
{ "verbosity", 'v', 0,
@@ -64,10 +69,67 @@
N_("Logging, 0 = errors only, "
"1 = minimal, 2 = detailed and 3 = debug (default = 0)"),
NULL },
+ { "process-all", 'p', 0,
+ G_OPTION_ARG_NONE, &process_all,
+ N_("Whether to process data from all configured modules to be indexed"),
+ NULL },
{ NULL }
};
static void
+sanity_check_option_values (TrackerConfig *config)
+{
+ g_message ("General options:");
+ g_message (" Verbosity ............................ %d",
+ tracker_config_get_verbosity (config));
+ g_message (" Low memory mode ...................... %s",
+ tracker_config_get_low_memory_mode (config) ? "yes" : "no");
+
+ g_message ("Indexer options:");
+ g_message (" Throttle level ....................... %d",
+ tracker_config_get_throttle (config));
+ g_message (" File content indexing enabled ........ %s",
+ tracker_config_get_enable_content_indexing (config) ? "yes" : "no");
+ g_message (" Thumbnail indexing enabled ........... %s",
+ tracker_config_get_enable_thumbnails (config) ? "yes" : "no");
+ g_message (" Indexer language code ................ %s",
+ tracker_config_get_language (config));
+ g_message (" Stemmer enabled ...................... %s",
+ tracker_config_get_enable_stemmer (config) ? "yes" : "no");
+ g_message (" Fast merges enabled .................. %s",
+ tracker_config_get_fast_merges (config) ? "yes" : "no");
+ g_message (" Disable indexing on battery .......... %s (initially = %s)",
+ tracker_config_get_disable_indexing_on_battery (config) ? "yes" : "no",
+ tracker_config_get_disable_indexing_on_battery_init (config) ? "yes" : "no");
+
+ if (tracker_config_get_low_disk_space_limit (config) == -1) {
+ g_message (" Low disk space limit ................. Disabled");
+ } else {
+ g_message (" Low disk space limit ................. %d%%",
+ tracker_config_get_low_disk_space_limit (config));
+ }
+
+ g_message (" Minimum index word length ............ %d",
+ tracker_config_get_min_word_length (config));
+ g_message (" Maximum index word length ............ %d",
+ tracker_config_get_max_word_length (config));
+ g_message (" Maximum text to index ................ %d",
+ tracker_config_get_max_text_to_index (config));
+ g_message (" Maximum words to index ............... %d",
+ tracker_config_get_max_words_to_index (config));
+ g_message (" Maximum bucket count ................. %d",
+ tracker_config_get_max_bucket_count (config));
+ g_message (" Minimum bucket count ................. %d",
+ tracker_config_get_min_bucket_count (config));
+ g_message (" Divisions ............................ %d",
+ tracker_config_get_divisions (config));
+ g_message (" Padding .............................. %d",
+ tracker_config_get_padding (config));
+ g_message (" Optimization sweep count ............. %d",
+ tracker_config_get_optimization_sweep_count (config));
+}
+
+static void
signal_handler (gint signo)
{
static gboolean in_loop = FALSE;
@@ -124,11 +186,47 @@
#endif
}
+static gboolean
+quit_timeout_cb (gpointer user_data)
+{
+ TrackerIndexer *indexer;
+ gboolean running = FALSE;
+
+ indexer = TRACKER_INDEXER (user_data);
+
+ if (!tracker_indexer_get_running (indexer, &running, NULL) || !running) {
+ g_message ("Indexer is still not running after %d seconds, quitting...",
+ QUIT_TIMEOUT);
+ g_main_loop_quit (main_loop);
+ quit_timeout_id = 0;
+ } else {
+ g_message ("Indexer is now running, staying alive until finished...");
+ }
+
+ g_object_unref (indexer);
+
+ return FALSE;
+}
+
static void
indexer_finished_cb (TrackerIndexer *indexer,
+ guint items_indexed,
gpointer user_data)
{
- g_main_loop_quit (main_loop);
+ if (items_indexed > 0) {
+ g_main_loop_quit (main_loop);
+ return;
+ }
+
+ /* If we didn't index anything yet, wait for a minimum of 10
+ * seconds or so before quitting.
+ */
+ g_message ("Nothing was indexed, waiting %d seconds before quitting...",
+ QUIT_TIMEOUT);
+
+ quit_timeout_id = g_timeout_add_seconds (QUIT_TIMEOUT,
+ quit_timeout_cb,
+ g_object_ref (indexer));
}
static void
@@ -148,7 +246,11 @@
sys_tmp_dir = g_build_filename (g_get_tmp_dir (), filename, NULL);
g_free (filename);
+ /* if you want low memory mode in the indexer, pass
+ TRACKER_DB_MANAGER_LOW_MEMORY_MODE */
+
tracker_db_manager_init (0, NULL);
+ tracker_module_config_init ();
g_free (data_dir);
g_free (user_data_dir);
@@ -160,7 +262,8 @@
{
g_message ("Shutting down...\n");
- tracker_db_manager_shutdown (FALSE);
+ tracker_db_manager_shutdown ();
+ tracker_module_config_shutdown ();
}
gint
@@ -223,6 +326,8 @@
return EXIT_FAILURE;
}
+ sanity_check_option_values (config);
+
initialize_indexer ();
#ifdef HAVE_IOPRIO
@@ -251,15 +356,24 @@
}
/* Create the indexer and run the main loop */
-
- g_signal_connect (indexer, "finished",
- G_CALLBACK (indexer_finished_cb), NULL);
+ g_signal_connect (indexer, "finished",
+ G_CALLBACK (indexer_finished_cb),
+ NULL);
+
+ if (process_all) {
+ /* Tell the indexer to process all configured modules */
+ tracker_indexer_process_all (indexer);
+ }
g_message ("Starting...");
main_loop = g_main_loop_new (NULL, FALSE);
g_main_loop_run (main_loop);
+ if (quit_timeout_id) {
+ g_source_remove (quit_timeout_id);
+ }
+
g_object_unref (indexer);
g_object_unref (config);
Modified: branches/xesam-support/src/tracker-indexer/tracker-module.h
==============================================================================
--- branches/xesam-support/src/tracker-indexer/tracker-module.h (original)
+++ branches/xesam-support/src/tracker-indexer/tracker-module.h Thu Jul 3 14:55:07 2008
@@ -31,6 +31,8 @@
gpointer data;
};
+typedef void (* TrackerModuleInit) (void);
+typedef void (* TrackerModuleShutdown) (void);
typedef const gchar * (* TrackerModuleGetNameFunc) (void);
typedef gchar ** (* TrackerModuleGetDirectoriesFunc) (void);
@@ -43,9 +45,10 @@
typedef gboolean (* TrackerModuleFileIterContents) (TrackerFile *path);
+void tracker_module_init (void);
+void tracker_module_shutdown (void);
+
G_CONST_RETURN gchar * tracker_module_get_name (void);
-gchar ** tracker_module_get_directories (void);
-gchar ** tracker_module_get_ignore_directories (void);
gpointer tracker_module_file_get_data (const gchar *path);
void tracker_module_file_free_data (gpointer file_data);
Modified: branches/xesam-support/src/trackerd/Makefile.am
==============================================================================
--- branches/xesam-support/src/trackerd/Makefile.am (original)
+++ branches/xesam-support/src/trackerd/Makefile.am Thu Jul 3 14:55:07 2008
@@ -38,8 +38,8 @@
tracker-keywords.h \
tracker-indexer.c \
tracker-indexer.h \
- tracker-process.c \
- tracker-process.h \
+ tracker-processor.c \
+ tracker-processor.h \
tracker-main.c \
tracker-main.h \
tracker-marshal-main.c \
Modified: branches/xesam-support/src/trackerd/tracker-crawler.c
==============================================================================
--- branches/xesam-support/src/trackerd/tracker-crawler.c (original)
+++ branches/xesam-support/src/trackerd/tracker-crawler.c Thu Jul 3 14:55:07 2008
@@ -1,5 +1,5 @@
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-/*
+/*
* Copyright (C) 2008, Nokia
*
* This library is free software; you can redistribute it and/or
@@ -27,15 +27,15 @@
#include <libtracker-common/tracker-dbus.h>
#include <libtracker-common/tracker-file-utils.h>
#include <libtracker-common/tracker-utils.h>
+#include <libtracker-common/tracker-module-config.h>
#include "tracker-crawler.h"
#include "tracker-dbus.h"
#include "tracker-indexer-client.h"
#include "tracker-monitor.h"
+#include "tracker-marshal.h"
-#define GET_PRIV(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), TRACKER_TYPE_CRAWLER, TrackerCrawlerPriv))
-
-/*#define TESTING*/
+#define TRACKER_CRAWLER_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), TRACKER_TYPE_CRAWLER, TrackerCrawlerPrivate))
#define FILE_ATTRIBUTES \
G_FILE_ATTRIBUTE_STANDARD_NAME "," \
@@ -44,7 +44,7 @@
#define FILES_QUEUE_PROCESS_INTERVAL 2000
#define FILES_QUEUE_PROCESS_MAX 5000
-struct _TrackerCrawlerPriv {
+struct _TrackerCrawlerPrivate {
TrackerConfig *config;
#ifdef HAVE_HAL
TrackerHal *hal;
@@ -52,32 +52,44 @@
GTimer *timer;
- GAsyncQueue *files;
- guint files_queue_handle_id;
+ GQueue *directories;
+ GQueue *files;
- GSList *ignored_file_types;
-
- GHashTable *ignored_names;
- GHashTable *temp_black_list;
+ guint idle_id;
+ guint files_queue_handle_id;
- gchar **ignored_suffixes;
- gchar **ignored_prefixes;
+ /* Specific to each crawl ... */
+ GList *ignored_directory_patterns;
+ GList *ignored_file_patterns;
+ GList *index_file_patterns;
+ gchar *current_module_name;
+ /* Statistics */
guint enumerations;
- guint files_found;
- guint files_ignored;
-
+ guint directories_found;
+ guint directories_ignored;
+ guint files_found;
+ guint files_ignored;
+ guint monitors_added;
+ guint monitors_ignored;
+
gboolean running;
+ gboolean finished;
};
enum {
PROP_0,
PROP_CONFIG,
-#ifdef HAVE_HAL
+#ifdef HAVE_HAL
PROP_HAL
#endif
};
+enum {
+ FINISHED,
+ LAST_SIGNAL
+};
+
typedef struct {
TrackerCrawler *crawler;
GFile *parent;
@@ -88,7 +100,6 @@
guint param_id,
const GValue *value,
GParamSpec *pspec);
-static void set_ignored_file_types (TrackerCrawler *crawler);
#ifdef HAVE_HAL
static void mount_point_added_cb (TrackerHal *hal,
@@ -103,7 +114,8 @@
EnumeratorData *ed);
static void file_enumerate_children (TrackerCrawler *crawler,
GFile *file);
-static void file_queue_handler_set_up (TrackerCrawler *crawler);
+
+static guint signals[LAST_SIGNAL] = { 0, };
G_DEFINE_TYPE(TrackerCrawler, tracker_crawler, G_TYPE_OBJECT)
@@ -125,7 +137,7 @@
tracker_config_get_type (),
G_PARAM_WRITABLE));
-#ifdef HAVE_HAL
+#ifdef HAVE_HAL
g_object_class_install_property (object_class,
PROP_HAL,
g_param_spec_object ("hal",
@@ -135,129 +147,82 @@
G_PARAM_WRITABLE));
#endif /* HAVE_HAL */
- g_type_class_add_private (object_class, sizeof (TrackerCrawlerPriv));
+ signals[FINISHED] =
+ g_signal_new ("finished",
+ G_TYPE_FROM_CLASS (klass),
+ G_SIGNAL_RUN_LAST,
+ 0,
+ NULL, NULL,
+ tracker_marshal_VOID__UINT_UINT_UINT_UINT,
+ G_TYPE_NONE,
+ 4,
+ G_TYPE_UINT,
+ G_TYPE_UINT,
+ G_TYPE_UINT,
+ G_TYPE_UINT);
+
+ g_type_class_add_private (object_class, sizeof (TrackerCrawlerPrivate));
}
static void
tracker_crawler_init (TrackerCrawler *object)
{
- TrackerCrawlerPriv *priv;
- GPtrArray *ptr_array;
+ TrackerCrawlerPrivate *priv;
- object->priv = GET_PRIV (object);
+ object->private = TRACKER_CRAWLER_GET_PRIVATE (object);
- priv = object->priv;
+ priv = object->private;
- /* Create async queue for handling file pushes to the indexer */
- priv->files = g_async_queue_new ();
-
- /* Whole file names to ignore */
- priv->ignored_names = g_hash_table_new (g_str_hash, g_str_equal);
- g_hash_table_insert (priv->ignored_names, "po", NULL);
- g_hash_table_insert (priv->ignored_names, "CVS", NULL);
- g_hash_table_insert (priv->ignored_names, "Makefile", NULL);
- g_hash_table_insert (priv->ignored_names, "SCCS", NULL);
- g_hash_table_insert (priv->ignored_names, "ltmain.sh", NULL);
- g_hash_table_insert (priv->ignored_names, "libtool", NULL);
- g_hash_table_insert (priv->ignored_names, "config.status", NULL);
- g_hash_table_insert (priv->ignored_names, "conftest", NULL);
- g_hash_table_insert (priv->ignored_names, "confdefs.h", NULL);
-
- /* Temporary black list */
- priv->temp_black_list = g_hash_table_new_full (g_str_hash,
- g_str_equal,
- g_free,
- NULL);
-
- /* Suffixes to ignore */
- ptr_array = g_ptr_array_new ();
- g_ptr_array_add (ptr_array, g_strdup ("~"));
- g_ptr_array_add (ptr_array, g_strdup (".o"));
- g_ptr_array_add (ptr_array, g_strdup (".la"));
- g_ptr_array_add (ptr_array, g_strdup (".lo"));
- g_ptr_array_add (ptr_array, g_strdup (".loT"));
- g_ptr_array_add (ptr_array, g_strdup (".in"));
- g_ptr_array_add (ptr_array, g_strdup (".csproj"));
- g_ptr_array_add (ptr_array, g_strdup (".m4"));
- g_ptr_array_add (ptr_array, g_strdup (".rej"));
- g_ptr_array_add (ptr_array, g_strdup (".gmo"));
- g_ptr_array_add (ptr_array, g_strdup (".orig"));
- g_ptr_array_add (ptr_array, g_strdup (".pc"));
- g_ptr_array_add (ptr_array, g_strdup (".omf"));
- g_ptr_array_add (ptr_array, g_strdup (".aux"));
- g_ptr_array_add (ptr_array, g_strdup (".tmp"));
- g_ptr_array_add (ptr_array, g_strdup (".po"));
- g_ptr_array_add (ptr_array, g_strdup (".vmdk"));
- g_ptr_array_add (ptr_array, g_strdup (".vmx"));
- g_ptr_array_add (ptr_array, g_strdup (".vmxf"));
- g_ptr_array_add (ptr_array, g_strdup (".vmsd"));
- g_ptr_array_add (ptr_array, g_strdup (".nvram"));
- g_ptr_array_add (ptr_array, g_strdup (".part"));
- g_ptr_array_add (ptr_array, NULL);
- priv->ignored_suffixes = (gchar **) g_ptr_array_free (ptr_array, FALSE);
-
- /* Prefixes to ignore */
- ptr_array = g_ptr_array_new ();
- g_ptr_array_add (ptr_array, g_strdup ("autom4te"));
- g_ptr_array_add (ptr_array, g_strdup ("conftest."));
- g_ptr_array_add (ptr_array, g_strdup ("confstat"));
- g_ptr_array_add (ptr_array, g_strdup ("config."));
- g_ptr_array_add (ptr_array, NULL);
- priv->ignored_prefixes = (gchar **) g_ptr_array_free (ptr_array, FALSE);
+ priv->directories = g_queue_new ();
+ priv->files = g_queue_new ();
}
static void
crawler_finalize (GObject *object)
{
- TrackerCrawlerPriv *priv;
- gchar *str;
- gint i;
-
- priv = GET_PRIV (object);
+ TrackerCrawlerPrivate *priv;
- for (i = 0; priv->ignored_prefixes[i] != NULL; i++) {
- g_free (priv->ignored_prefixes[i]);
+ priv = TRACKER_CRAWLER_GET_PRIVATE (object);
+
+ if (priv->idle_id) {
+ g_source_remove (priv->idle_id);
}
- g_free (priv->ignored_prefixes);
+ g_free (priv->current_module_name);
- for (i = 0; priv->ignored_suffixes[i] != NULL; i++) {
- g_free (priv->ignored_suffixes[i]);
+ if (priv->index_file_patterns) {
+ g_list_free (priv->index_file_patterns);
}
- g_free (priv->ignored_suffixes);
+ if (priv->ignored_file_patterns) {
+ g_list_free (priv->ignored_file_patterns);
+ }
- g_hash_table_unref (priv->temp_black_list);
- g_hash_table_unref (priv->ignored_names);
+ if (priv->ignored_directory_patterns) {
+ g_list_free (priv->ignored_directory_patterns);
+ }
- g_slist_foreach (priv->ignored_file_types,
- (GFunc) g_pattern_spec_free,
- NULL);
- g_slist_free (priv->ignored_file_types);
+ if (priv->timer) {
+ g_timer_destroy (priv->timer);
+ }
if (priv->files_queue_handle_id) {
- g_source_remove (priv->files_queue_handle_id);
+ g_source_remove (priv->files_queue_handle_id);
priv->files_queue_handle_id = 0;
}
- for (str = g_async_queue_try_pop (priv->files);
- str;
- str = g_async_queue_try_pop (priv->files)) {
- g_free (str);
- }
+ g_queue_foreach (priv->files, (GFunc) g_object_unref, NULL);
+ g_queue_free (priv->files);
- g_async_queue_unref (priv->files);
-
- if (priv->timer) {
- g_timer_destroy (priv->timer);
- }
+ g_queue_foreach (priv->directories, (GFunc) g_object_unref, NULL);
+ g_queue_free (priv->directories);
-#ifdef HAVE_HAL
+#ifdef HAVE_HAL
if (priv->hal) {
- g_signal_handlers_disconnect_by_func (priv->hal,
+ g_signal_handlers_disconnect_by_func (priv->hal,
mount_point_added_cb,
object);
- g_signal_handlers_disconnect_by_func (priv->hal,
+ g_signal_handlers_disconnect_by_func (priv->hal,
mount_point_removed_cb,
object);
@@ -278,9 +243,9 @@
const GValue *value,
GParamSpec *pspec)
{
- TrackerCrawlerPriv *priv;
+ TrackerCrawlerPrivate *priv;
- priv = GET_PRIV (object);
+ priv = TRACKER_CRAWLER_GET_PRIVATE (object);
switch (param_id) {
case PROP_CONFIG:
@@ -306,21 +271,21 @@
{
g_return_val_if_fail (TRACKER_IS_CONFIG (config), NULL);
- return g_object_new (TRACKER_TYPE_CRAWLER,
+ return g_object_new (TRACKER_TYPE_CRAWLER,
"config", config,
- NULL);
+ NULL);
}
void
tracker_crawler_set_config (TrackerCrawler *object,
TrackerConfig *config)
{
- TrackerCrawlerPriv *priv;
+ TrackerCrawlerPrivate *priv;
g_return_if_fail (TRACKER_IS_CRAWLER (object));
g_return_if_fail (TRACKER_IS_CONFIG (config));
- priv = GET_PRIV (object);
+ priv = TRACKER_CRAWLER_GET_PRIVATE (object);
if (config) {
g_object_ref (config);
@@ -332,40 +297,37 @@
priv->config = config;
- /* The ignored file types depend on the config */
- set_ignored_file_types (object);
-
g_object_notify (G_OBJECT (object), "config");
}
-#ifdef HAVE_HAL
+#ifdef HAVE_HAL
void
tracker_crawler_set_hal (TrackerCrawler *object,
TrackerHal *hal)
{
- TrackerCrawlerPriv *priv;
+ TrackerCrawlerPrivate *priv;
g_return_if_fail (TRACKER_IS_CRAWLER (object));
g_return_if_fail (TRACKER_IS_HAL (hal));
- priv = GET_PRIV (object);
+ priv = TRACKER_CRAWLER_GET_PRIVATE (object);
if (hal) {
- g_signal_connect (hal, "mount-point-added",
+ g_signal_connect (hal, "mount-point-added",
G_CALLBACK (mount_point_added_cb),
object);
- g_signal_connect (hal, "mount-point-removed",
+ g_signal_connect (hal, "mount-point-removed",
G_CALLBACK (mount_point_removed_cb),
object);
g_object_ref (hal);
}
if (priv->hal) {
- g_signal_handlers_disconnect_by_func (hal,
+ g_signal_handlers_disconnect_by_func (hal,
mount_point_added_cb,
object);
- g_signal_handlers_disconnect_by_func (hal,
+ g_signal_handlers_disconnect_by_func (hal,
mount_point_removed_cb,
object);
g_object_unref (priv->hal);
@@ -381,36 +343,6 @@
/*
* Functions
*/
-static void
-set_ignored_file_types (TrackerCrawler *crawler)
-{
- TrackerCrawlerPriv *priv;
- GPatternSpec *spec;
- GSList *ignored_file_types;
- GSList *patterns = NULL;
- GSList *l;
-
- priv = crawler->priv;
-
- g_slist_foreach (priv->ignored_file_types,
- (GFunc) g_pattern_spec_free,
- NULL);
- g_slist_free (priv->ignored_file_types);
-
- if (!priv->config) {
- return;
- }
-
- /* File types as configured to ignore, using pattern matching */
- ignored_file_types = tracker_config_get_no_index_file_types (priv->config);
-
- for (l = ignored_file_types; l; l = l->next) {
- spec = g_pattern_spec_new (l->data);
- patterns = g_slist_prepend (patterns, spec);
- }
-
- priv->ignored_file_types = g_slist_reverse (patterns);
-}
#ifdef HAVE_HAL
@@ -420,7 +352,7 @@
gpointer user_data)
{
g_message ("** TRAWLING THROUGH NEW MOUNT POINT:'%s'", mount_point);
-
+
/* list = g_slist_prepend (NULL, (gchar*) mount_point); */
/* process_directory_list (list, TRUE, iface); */
/* g_slist_free (list); */
@@ -432,7 +364,7 @@
gpointer user_data)
{
g_message ("** CLEANING UP OLD MOUNT POINT:'%s'", mount_point);
-
+
/* process_index_delete_directory_check (mount_point, iface); */
}
@@ -440,7 +372,7 @@
static void
get_remote_roots (TrackerCrawler *crawler,
- GSList **mounted_directory_roots,
+ GSList **mounted_directory_roots,
GSList **removable_device_roots)
{
GSList *l1 = NULL;
@@ -450,11 +382,11 @@
* so we make this process faster?
*/
-#ifdef HAVE_HAL
- l1 = tracker_hal_get_mounted_directory_roots (crawler->priv->hal);
- l2 = tracker_hal_get_removable_device_roots (crawler->priv->hal);
+#ifdef HAVE_HAL
+ l1 = tracker_hal_get_mounted_directory_roots (crawler->private->hal);
+ l2 = tracker_hal_get_removable_device_roots (crawler->private->hal);
#endif /* HAVE_HAL */
-
+
/* The options to index removable media and the index mounted
* directories are both mutually exclusive even though
* removable media is mounted on a directory.
@@ -465,12 +397,12 @@
if (l2) {
GSList *l;
GSList *list = NULL;
-
+
for (l = l1; l; l = l->next) {
if (g_slist_find_custom (l2, l->data, (GCompareFunc) strcmp)) {
continue;
- }
-
+ }
+
list = g_slist_prepend (list, l->data);
}
@@ -495,14 +427,14 @@
gboolean ignore = FALSE;
ignore_mounted_directories =
- !tracker_config_get_index_mounted_directories (crawler->priv->config);
- ignore_removable_devices =
- !tracker_config_get_index_removable_devices (crawler->priv->config);
+ !tracker_config_get_index_mounted_directories (crawler->private->config);
+ ignore_removable_devices =
+ !tracker_config_get_index_removable_devices (crawler->private->config);
if (ignore_mounted_directories || ignore_removable_devices) {
- get_remote_roots (crawler,
- &mounted_directory_roots,
- &removable_device_roots);
+ get_remote_roots (crawler,
+ &mounted_directory_roots,
+ &removable_device_roots);
}
if (ignore_mounted_directories) {
@@ -523,7 +455,7 @@
}
/* FIXME: Should we add a DIR_SEPARATOR on the end of
- * these before comparing them?
+ * these before comparing them?
*/
if (g_str_has_prefix (path, l->data)) {
ignore = TRUE;
@@ -537,34 +469,34 @@
static gboolean
path_should_be_ignored (TrackerCrawler *crawler,
- const gchar *path)
+ const gchar *path,
+ gboolean is_directory)
{
- GSList *l;
- gchar *basename;
- gchar **p;
- gboolean ignore;
+ GList *l;
+ gchar *basename;
+ gboolean ignore;
if (tracker_is_empty_string (path)) {
return TRUE;
}
+ if (!g_utf8_validate (path, -1, NULL)) {
+ g_message ("Ignoring path:'%s', not valid UTF-8", path);
+ return TRUE;
+ }
+
/* Most common things to ignore */
if (strcmp (path, "/boot") == 0 ||
strcmp (path, "/dev") == 0 ||
strcmp (path, "/lib") == 0 ||
strcmp (path, "/proc") == 0 ||
strcmp (path, "/sys") == 0 ||
- strcmp (path, "/tmp") == 0 ||
+ strcmp (path, "/tmp") == 0 ||
strcmp (path, "/var") == 0) {
return TRUE;
}
-
- if (g_str_has_prefix (path, g_get_tmp_dir ())) {
- return TRUE;
- }
- if (!g_utf8_validate (path, -1, NULL)) {
- g_message ("Ignoring path:'%s', not valid UTF-8", path);
+ if (g_str_has_prefix (path, g_get_tmp_dir ())) {
return TRUE;
}
@@ -575,36 +507,24 @@
goto done;
}
- /* Test exact basenames */
- if (g_hash_table_lookup (crawler->priv->ignored_names,
- basename)) {
- goto done;
- }
-
- /* Test temporary black list */
- if (g_hash_table_lookup (crawler->priv->temp_black_list,
- basename)) {
- goto done;
- }
-
- /* Test suffixes */
- for (p = crawler->priv->ignored_suffixes; *p; p++) {
- if (g_str_has_suffix (basename, *p)) {
- goto done;
+ /* Test ignore types */
+ if (is_directory) {
+ for (l = crawler->private->ignored_directory_patterns; l; l = l->next) {
+ if (g_pattern_match_string (l->data, basename)) {
+ goto done;
+ }
}
- }
-
- /* Test prefixes */
- for (p = crawler->priv->ignored_prefixes; *p; p++) {
- if (g_str_has_prefix (basename, *p)) {
- goto done;
+ } else {
+ for (l = crawler->private->ignored_file_patterns; l; l = l->next) {
+ if (g_pattern_match_string (l->data, basename)) {
+ goto done;
+ }
}
- }
- /* Test ignore types */
- for (l = crawler->priv->ignored_file_types; l; l = l->next) {
- if (g_pattern_match_string (l->data, basename)) {
- goto done;
+ for (l = crawler->private->index_file_patterns; l; l = l->next) {
+ if (!g_pattern_match_string (l->data, basename)) {
+ goto done;
+ }
}
}
@@ -612,7 +532,7 @@
if (path_should_be_ignored_for_media (crawler, path)) {
goto done;
}
-
+
ignore = FALSE;
done:
@@ -621,73 +541,236 @@
return ignore;
}
-static EnumeratorData *
-enumerator_data_new (TrackerCrawler *crawler,
- GFile *parent)
+static void
+add_file (TrackerCrawler *crawler,
+ GFile *file)
{
- EnumeratorData *ed;
+ gchar *path;
- ed = g_slice_new0 (EnumeratorData);
- ed->crawler = g_object_ref (crawler);
- ed->parent = g_object_ref (parent);
+ g_return_if_fail (G_IS_FILE (file));
- return ed;
+ path = g_file_get_path (file);
+
+ if (path_should_be_ignored (crawler, path, FALSE)) {
+ crawler->private->files_ignored++;
+
+ g_debug ("Ignored:'%s' (%d)",
+ path,
+ crawler->private->enumerations);
+ } else {
+ crawler->private->files_found++;
+
+ g_debug ("Found :'%s' (%d)",
+ path,
+ crawler->private->enumerations);
+
+ g_queue_push_tail (crawler->private->files, g_object_ref (file));
+ }
+
+ g_free (path);
}
static void
-enumerator_data_free (EnumeratorData *ed)
+add_directory (TrackerCrawler *crawler,
+ GFile *file)
{
- g_object_unref (ed->parent);
- g_object_unref (ed->crawler);
- g_slice_free (EnumeratorData, ed);
+ gchar *path;
+
+ g_return_if_fail (G_IS_FILE (file));
+
+ path = g_file_get_path (file);
+
+ if (path_should_be_ignored (crawler, path, TRUE)) {
+ crawler->private->directories_ignored++;
+
+ g_debug ("Ignored:'%s' (%d)",
+ path,
+ crawler->private->enumerations);
+ } else {
+ crawler->private->directories_found++;
+
+ g_debug ("Found :'%s' (%d)",
+ path,
+ crawler->private->enumerations);
+
+ g_queue_push_tail (crawler->private->directories, g_object_ref (file));
+ }
+
+ g_free (path);
}
static void
-file_enumerators_increment (TrackerCrawler *crawler)
+indexer_check_files_cb (DBusGProxy *proxy,
+ GError *error,
+ gpointer user_data)
{
- TrackerCrawlerPriv *priv;
+ GStrv files;
- priv = crawler->priv;
+ if (error) {
+ g_message ("Files could not be checked by the indexer, %s",
+ error->message);
+ g_error_free (error);
+ } else {
+ g_debug ("Sent!");
+ }
- if (priv->enumerations == 0) {
- g_message ("Starting to crawl file system...");
+ files = (GStrv) user_data;
+ g_strfreev (files);
+}
- if (!priv->timer) {
- priv->timer = g_timer_new ();
- } else {
- g_timer_reset (priv->timer);
- }
+static void
+indexer_get_running_cb (DBusGProxy *proxy,
+ gboolean running,
+ GError *error,
+ gpointer user_data)
+{
+ TrackerCrawler *crawler;
+ GStrv files;
+ guint total;
+
+ crawler = TRACKER_CRAWLER (user_data);
+
+ if (error || !running) {
+ g_message ("%s",
+ error ? error->message : "Indexer exists but is not available yet, waiting...");
+
+ g_object_unref (crawler);
+ g_clear_error (&error);
+
+ return;
+ }
+
+ total = g_queue_get_length (crawler->private->files);
+ files = tracker_dbus_queue_gfile_to_strv (crawler->private->files,
+ FILES_QUEUE_PROCESS_MAX);
+
+ g_debug ("File check queue processed, sending first %d/%d to the indexer",
+ g_strv_length (files),
+ total);
+
+ org_freedesktop_Tracker_Indexer_files_check_async (proxy,
+ crawler->private->current_module_name,
+ (const gchar **) files,
+ indexer_check_files_cb,
+ files);
+
+ g_object_unref (crawler);
+}
+
+static gboolean
+file_queue_handler_cb (gpointer user_data)
+{
+ TrackerCrawler *crawler;
+
+ crawler = TRACKER_CRAWLER (user_data);
- priv->files_found = 0;
- priv->files_ignored = 0;
+ if (g_queue_get_length (crawler->private->files) < 1) {
+ g_debug ("File check queue is empty... nothing to do");
+ crawler->private->files_queue_handle_id = 0;
+ return FALSE;
}
- priv->enumerations++;
+ /* Check we can actually talk to the indexer */
+ org_freedesktop_Tracker_Indexer_get_running_async (tracker_dbus_indexer_get_proxy (),
+ indexer_get_running_cb,
+ g_object_ref (crawler));
+
+ return TRUE;
}
static void
-file_enumerators_decrement (TrackerCrawler *crawler)
+file_queue_handler_set_up (TrackerCrawler *crawler)
{
- TrackerCrawlerPriv *priv;
+ if (crawler->private->files_queue_handle_id != 0) {
+ return;
+ }
- priv = crawler->priv;
+ crawler->private->files_queue_handle_id =
+ g_timeout_add (FILES_QUEUE_PROCESS_INTERVAL,
+ file_queue_handler_cb,
+ crawler);
+}
+
+static void
+process_file (TrackerCrawler *crawler,
+ GFile *file)
+{
+ file_queue_handler_set_up (crawler);
+}
+
+static void
+process_directory (TrackerCrawler *crawler,
+ GFile *file)
+{
+ tracker_monitor_add (file);
- priv->enumerations--;
+ file_enumerate_children (crawler, file);
+}
+
+static gboolean
+process_func (gpointer data)
+{
+ TrackerCrawler *crawler;
+ GFile *file;
+
+ crawler = TRACKER_CRAWLER (data);
+
+ /* Crawler file */
+ file = g_queue_peek_head (crawler->private->files);
+
+ if (file) {
+ /* Only return here if we want to throttle the
+ * directory crawling. I don't think we want to do
+ * that.
+ */
+ process_file (crawler, file);
+ /* return TRUE; */
+ }
- if (priv->enumerations == 0) {
- g_timer_stop (priv->timer);
+ /* Crawler directory contents */
+ file = g_queue_pop_head (crawler->private->directories);
+
+ if (file) {
+ process_directory (crawler, file);
+ g_object_unref (file);
- g_message ("%s crawling files in %4.4f seconds, %d found, %d ignored, "
- "%d monitors, %d monitors ignored",
- priv->running ? "Finished" : "Stopped",
- g_timer_elapsed (priv->timer, NULL),
- priv->files_found,
- priv->files_ignored,
- tracker_monitor_get_count (),
- tracker_monitor_get_ignored ());
+ return TRUE;
+ }
- priv->running = FALSE;
+ /* If we still have some async operations in progress, wait
+ * for them to finish, if not, we are truly done.
+ */
+ if (crawler->private->enumerations > 0) {
+ return TRUE;
}
+
+ crawler->private->idle_id = 0;
+ crawler->private->finished = TRUE;
+
+ tracker_crawler_stop (crawler);
+
+ return FALSE;
+}
+
+static EnumeratorData *
+enumerator_data_new (TrackerCrawler *crawler,
+ GFile *parent)
+{
+ EnumeratorData *ed;
+
+ ed = g_slice_new0 (EnumeratorData);
+ ed->crawler = g_object_ref (crawler);
+ ed->parent = g_object_ref (parent);
+
+ return ed;
+}
+
+static void
+enumerator_data_free (EnumeratorData *ed)
+{
+ g_object_unref (ed->parent);
+ g_object_unref (ed->crawler);
+ g_slice_free (EnumeratorData, ed);
}
static void
@@ -698,12 +781,12 @@
TrackerCrawler *crawler;
crawler = TRACKER_CRAWLER (user_data);
- file_enumerators_decrement (crawler);
+ crawler->private->enumerations--;
- if (!g_file_enumerator_close_finish (G_FILE_ENUMERATOR (enumerator),
- result,
+ if (!g_file_enumerator_close_finish (G_FILE_ENUMERATOR (enumerator),
+ result,
NULL)) {
- g_warning ("Couldn't close GFileEnumerator:%p",
+ g_warning ("Couldn't close GFileEnumerator:%p",
enumerator);
}
}
@@ -719,8 +802,7 @@
GFile *parent, *child;
GFileInfo *info;
GList *files;
- gchar *path;
-
+
enumerator = G_FILE_ENUMERATOR (object);
ed = (EnumeratorData*) user_data;
@@ -731,16 +813,12 @@
result,
NULL);
- if (!crawler->priv->running) {
- return;
- }
-
- if (!files || !crawler->priv->running) {
+ if (!files || !crawler->private->running) {
/* No more files or we are stopping anyway, so clean
* up and close all file enumerators.
*/
enumerator_data_free (ed);
- g_file_enumerator_close_async (enumerator,
+ g_file_enumerator_close_async (enumerator,
G_PRIORITY_DEFAULT,
NULL,
file_enumerator_close_cb,
@@ -751,37 +829,14 @@
/* Files should only have 1 item in it */
info = files->data;
child = g_file_get_child (parent, g_file_info_get_name (info));
- path = g_file_get_path (child);
-
- if (path_should_be_ignored (crawler, path)) {
- crawler->priv->files_ignored++;
-
-#ifdef TESTING
- g_debug ("Ignored:'%s' (%d)",
- path,
- crawler->priv->enumerations);
-#endif /* TESTING */
- g_free (path);
+ if (g_file_info_get_file_type (info) == G_FILE_TYPE_DIRECTORY) {
+ add_directory (crawler, child);
} else {
- crawler->priv->files_found++;
-
-#ifdef TESTING
- g_debug ("Found :'%s' (%d)",
- path,
- crawler->priv->enumerations);
-#endif /* TESTING */
-
- if (g_file_info_get_file_type (info) == G_FILE_TYPE_DIRECTORY) {
- file_enumerate_children (crawler, child);
- g_free (path);
- } else {
- g_async_queue_push (crawler->priv->files, path);
- file_queue_handler_set_up (crawler);
- }
- }
+ add_file (crawler, child);
+ }
- g_object_unref (child);
+ g_object_unref (child);
g_list_free (files);
/* Get next file */
@@ -792,7 +847,7 @@
file_enumerate_next (GFileEnumerator *enumerator,
EnumeratorData *ed)
{
- g_file_enumerator_next_files_async (enumerator,
+ g_file_enumerator_next_files_async (enumerator,
1,
G_PRIORITY_DEFAULT,
NULL,
@@ -815,7 +870,7 @@
enumerator = g_file_enumerate_children_finish (parent, result, NULL);
if (!enumerator) {
- file_enumerators_decrement (crawler);
+ crawler->private->enumerations--;
return;
}
@@ -830,177 +885,187 @@
file_enumerate_children (TrackerCrawler *crawler,
GFile *file)
{
- file_enumerators_increment (crawler);
-
- tracker_monitor_add (file);
+ crawler->private->enumerations++;
- g_file_enumerate_children_async (file,
- FILE_ATTRIBUTES,
+ g_file_enumerate_children_async (file,
+ FILE_ATTRIBUTES,
G_FILE_QUERY_INFO_NOFOLLOW_SYMLINKS,
G_PRIORITY_DEFAULT,
- NULL,
+ NULL,
file_enumerate_children_cb,
crawler);
}
-static void
-indexer_check_files_cb (DBusGProxy *proxy,
- GError *error,
- gpointer user_data)
-{
- GStrv files;
-
- files = (GStrv) user_data;
-
- if (error) {
- g_critical ("Could not send files to indexer to check, %s",
- error->message);
- g_error_free (error);
- } else {
- g_debug ("Sent!");
+gboolean
+tracker_crawler_start (TrackerCrawler *crawler,
+ const gchar *module_name)
+{
+ TrackerCrawlerPrivate *priv;
+ GFile *file;
+ GSList *paths = NULL;
+ GSList *sl;
+ GList *directories;
+ GList *l;
+ gchar *path;
+ gboolean exists;
+
+ g_return_val_if_fail (TRACKER_IS_CRAWLER (crawler), FALSE);
+ g_return_val_if_fail (module_name != NULL, FALSE);
+
+ priv = crawler->private;
+
+ g_message ("Crawling directories for module:'%s'",
+ module_name);
+
+ directories = tracker_module_config_get_monitor_recurse_directories (module_name);
+ if (!directories) {
+ g_message (" No directories to iterate, doing nothing");
+ return FALSE;
}
-}
-static void
-indexer_get_running_cb (DBusGProxy *proxy,
- gboolean running,
- GError *error,
- gpointer user_data)
-{
- TrackerCrawler *crawler;
- GStrv files;
+ for (l = directories; l; l = l->next) {
+ path = l->data;
- crawler = TRACKER_CRAWLER (user_data);
-
- if (error || !running) {
- g_message ("%s",
- error ? error->message : "Indexer exists but is not available yet, waiting...");
+ /* Check location exists before we do anything */
+ file = g_file_new_for_path (path);
+ exists = g_file_query_exists (file, NULL);
- g_object_unref (crawler);
- g_clear_error (&error);
+ if (!exists) {
+ g_message (" Directory:'%s' does not exist",
+ path);
+ g_object_unref (file);
+ continue;
+ }
- return;
+ paths = g_slist_prepend (paths, g_strdup (l->data));
+ g_object_unref (file);
}
- g_debug ("File check queue being processed...");
- files = tracker_dbus_async_queue_to_strv (crawler->priv->files,
- FILES_QUEUE_PROCESS_MAX);
-
- g_debug ("File check queue processed, sending first %d to the indexer",
- g_strv_length (files));
-
- org_freedesktop_Tracker_Indexer_files_check_async (proxy,
- (const gchar **) files,
- indexer_check_files_cb,
- files);
-
- g_object_unref (crawler);
-}
-
-static gboolean
-file_queue_handler_cb (gpointer user_data)
-{
- TrackerCrawler *crawler;
- DBusGProxy *proxy;
- gint length;
+ g_list_free (directories);
- crawler = user_data;
-
- length = g_async_queue_length (crawler->priv->files);
- if (length < 1) {
- g_debug ("File check queue is empty... nothing to do");
- crawler->priv->files_queue_handle_id = 0;
+ if (!paths) {
+ g_message (" No directories that actually exist to iterate, doing nothing");
return FALSE;
}
- /* Check we can actually talk to the indexer */
- proxy = tracker_dbus_indexer_get_proxy ();
-
- org_freedesktop_Tracker_Indexer_get_running_async (proxy,
- indexer_get_running_cb,
- g_object_ref (crawler));
-
- return TRUE;
-}
+ paths = g_slist_reverse (paths);
+ sl = tracker_path_list_filter_duplicates (paths);
+ g_slist_foreach (paths, (GFunc) g_free, NULL);
+ g_slist_free (paths);
+ paths = sl;
-static void
-file_queue_handler_set_up (TrackerCrawler *crawler)
-{
- if (crawler->priv->files_queue_handle_id != 0) {
- return;
+ /* Time the event */
+ if (priv->timer) {
+ g_timer_destroy (priv->timer);
}
- crawler->priv->files_queue_handle_id =
- g_timeout_add (FILES_QUEUE_PROCESS_INTERVAL,
- file_queue_handler_cb,
- crawler);
-}
+ priv->timer = g_timer_new ();
-void
-tracker_crawler_start (TrackerCrawler *crawler)
-{
- TrackerCrawlerPriv *priv;
- GFile *file;
- GSList *config_roots;
- GSList *roots = NULL;
- GSList *l;
- gboolean exists;
-
- g_return_if_fail (TRACKER_IS_CRAWLER (crawler));
-
- priv = crawler->priv;
+ /* Set up all the important data to start this crawl */
+ if (priv->ignored_directory_patterns) {
+ g_list_free (priv->ignored_directory_patterns);
+ }
- /* Get locations to index from config, if none are set, we use
- * $HOME as the default.
- */
- config_roots = tracker_config_get_crawl_directory_roots (priv->config);
- if (config_roots) {
- /* Make sure none of the roots co-inside each other */
- roots = tracker_path_list_filter_duplicates (config_roots);
+ if (priv->ignored_file_patterns) {
+ g_list_free (priv->ignored_file_patterns);
}
- if (!roots) {
- const gchar *home;
+ if (priv->index_file_patterns) {
+ g_list_free (priv->index_file_patterns);
+ }
- home = g_get_home_dir ();
- roots = g_slist_prepend (roots, g_strdup (home));
+ priv->ignored_directory_patterns =
+ tracker_module_config_get_ignored_directory_patterns (module_name);
+ priv->ignored_file_patterns =
+ tracker_module_config_get_ignored_file_patterns (module_name);
+ priv->index_file_patterns =
+ tracker_module_config_get_index_file_patterns (module_name);
- g_message ("No locations are configured to crawl, "
- "using default location (home directory)");
- }
+ priv->current_module_name = g_strdup (module_name);
+ /* Set idle handler to process directories and files found */
+ priv->idle_id = g_idle_add (process_func, crawler);
+
/* Set as running now */
priv->running = TRUE;
+ priv->finished = FALSE;
- /* Start iterating roots */
- for (l = roots; l; l = l->next) {
- file = g_file_new_for_path (l->data);
- exists = g_file_query_exists (file, NULL);
-
- if (exists) {
- g_message ("Searching directory:'%s'",
- (gchar*) l->data);
- file_enumerate_children (crawler, file);
- } else {
- g_message ("Searching directory:'%s' failed, does not exist",
- (gchar*) l->data);
- }
+ /* Reset stats */
+ priv->directories_found = 0;
+ priv->directories_ignored = 0;
+ priv->files_found = 0;
+ priv->files_ignored = 0;
+ priv->monitors_added = tracker_monitor_get_count ();
+ priv->monitors_ignored = tracker_monitor_get_ignored ();
+
+ for (sl = paths; sl; sl = sl->next) {
+ file = g_file_new_for_path (sl->data);
+ g_message (" Searching directory:'%s'", (gchar *) sl->data);
+ file_enumerate_children (crawler, file);
g_object_unref (file);
- g_free (l->data);
+ g_free (sl->data);
}
- g_slist_free (roots);
+ g_slist_free (paths);
+
+ return TRUE;
}
void
tracker_crawler_stop (TrackerCrawler *crawler)
{
- TrackerCrawlerPriv *priv;
+ TrackerCrawlerPrivate *priv;
g_return_if_fail (TRACKER_IS_CRAWLER (crawler));
- priv = crawler->priv;
+ priv = crawler->private;
priv->running = FALSE;
+
+ if (priv->idle_id) {
+ g_source_remove (priv->idle_id);
+ }
+
+ g_free (priv->current_module_name);
+ priv->current_module_name = NULL;
+
+ if (priv->index_file_patterns) {
+ g_list_free (priv->index_file_patterns);
+ priv->index_file_patterns = NULL;
+ }
+
+ if (priv->ignored_file_patterns) {
+ g_list_free (priv->ignored_file_patterns);
+ priv->ignored_file_patterns = NULL;
+ }
+
+ if (priv->ignored_directory_patterns) {
+ g_list_free (priv->ignored_directory_patterns);
+ priv->ignored_directory_patterns = NULL;
+ }
+
+ g_timer_stop (priv->timer);
+
+ g_message (" %s crawling files in %4.4f seconds",
+ priv->finished ? "Finished" : "Stopped",
+ g_timer_elapsed (priv->timer, NULL));
+ g_message (" Found %d directories, ignored %d directories",
+ priv->directories_found,
+ priv->directories_ignored);
+ g_message (" Found %d files, ignored %d files",
+ priv->files_found,
+ priv->files_ignored);
+ g_message (" Added %d monitors, ignored %d monitors",
+ tracker_monitor_get_count () - priv->monitors_added,
+ tracker_monitor_get_ignored () - priv->monitors_ignored);
+
+ g_timer_destroy (priv->timer);
+ priv->timer = NULL;
+
+ g_signal_emit (crawler, signals[FINISHED], 0,
+ priv->directories_found,
+ priv->directories_ignored,
+ priv->files_found,
+ priv->files_ignored);
}
Modified: branches/xesam-support/src/trackerd/tracker-crawler.h
==============================================================================
--- branches/xesam-support/src/trackerd/tracker-crawler.h (original)
+++ branches/xesam-support/src/trackerd/tracker-crawler.h Thu Jul 3 14:55:07 2008
@@ -38,17 +38,17 @@
#define TRACKER_IS_CRAWLER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TRACKER_TYPE_CRAWLER))
#define TRACKER_CRAWLER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TRACKER_TYPE_CRAWLER, TrackerCrawlerClass))
-typedef struct _TrackerCrawler TrackerCrawler;
-typedef struct _TrackerCrawlerClass TrackerCrawlerClass;
-typedef struct _TrackerCrawlerPriv TrackerCrawlerPriv;
+typedef struct _TrackerCrawler TrackerCrawler;
+typedef struct _TrackerCrawlerClass TrackerCrawlerClass;
+typedef struct _TrackerCrawlerPrivate TrackerCrawlerPrivate;
struct _TrackerCrawler {
- GObject parent;
- TrackerCrawlerPriv *priv;
+ GObject parent;
+ TrackerCrawlerPrivate *private;
};
struct _TrackerCrawlerClass {
- GObjectClass parent;
+ GObjectClass parent;
};
GType tracker_crawler_get_type (void);
@@ -61,7 +61,8 @@
TrackerHal *hal);
#endif /* HAVE_HAL */
-void tracker_crawler_start (TrackerCrawler *crawler);
+gboolean tracker_crawler_start (TrackerCrawler *crawler,
+ const gchar *module_name);
void tracker_crawler_stop (TrackerCrawler *crawler);
G_END_DECLS
Modified: branches/xesam-support/src/trackerd/tracker-daemon.c
==============================================================================
--- branches/xesam-support/src/trackerd/tracker-daemon.c (original)
+++ branches/xesam-support/src/trackerd/tracker-daemon.c Thu Jul 3 14:55:07 2008
@@ -319,10 +319,18 @@
tracker_dbus_return_val_if_fail (values != NULL, FALSE, error);
- tracker_dbus_request_new (request_id,
+ tracker_dbus_request_new (request_id,
"DBus request to get daemon services");
- iface = tracker_db_manager_get_db_interface (TRACKER_DB_FILE_METADATA);
+ /* Here it doesn't matter which one we ask, as long as it has common.db
+ * attached. The service ones are cached connections, so we can use
+ * those instead of asking for an individual-file connection (like what
+ * the original code had) */
+
+ /* iface = tracker_db_manager_get_db_interfaceX (TRACKER_DB_COMMON); */
+
+ iface = tracker_db_manager_get_db_interface_by_service (TRACKER_DB_FOR_FILE_SERVICE);
+
result_set = tracker_db_exec_proc (iface, "GetServices", 0);
*values = tracker_dbus_query_result_to_hash_table (result_set);
@@ -348,13 +356,20 @@
tracker_dbus_return_val_if_fail (values != NULL, FALSE, error);
- tracker_dbus_request_new (request_id,
+ tracker_dbus_request_new (request_id,
"DBus request to get daemon service stats");
- iface = tracker_db_manager_get_db_interface (TRACKER_DB_FILE_METADATA);
+ /* Here it doesn't matter which one we ask, as long as it has common.db
+ * attached. The service ones are cached connections, so we can use
+ * those instead of asking for an individual-file connection (like what
+ * the original code had) */
+
+ /* iface = tracker_db_manager_get_db_interfaceX (TRACKER_DB_COMMON); */
+
+ iface = tracker_db_manager_get_db_interface_by_service (TRACKER_DB_FOR_FILE_SERVICE);
result_set = tracker_db_exec_proc (iface, "GetStats", 0);
- *values = tracker_dbus_query_result_to_ptr_array (result_set);
+ *values = tracker_dbus_query_result_to_ptr_array (result_set);
if (result_set) {
g_object_unref (result_set);
Modified: branches/xesam-support/src/trackerd/tracker-db.c
==============================================================================
--- branches/xesam-support/src/trackerd/tracker-db.c (original)
+++ branches/xesam-support/src/trackerd/tracker-db.c Thu Jul 3 14:55:07 2008
@@ -39,7 +39,6 @@
#include <libtracker-db/tracker-db-manager.h>
#include "tracker-db.h"
-#include "tracker-process.h"
#include "tracker-query-tree.h"
#include "tracker-monitor.h"
#include "tracker-xesam-manager.h"
@@ -323,7 +322,7 @@
backup_id = get_backup_id (iface, id);
if (backup_id) {
- tracker_db_exec_proc (tracker_db_manager_get_db_interface (TRACKER_DB_COMMON),
+ tracker_db_exec_proc (iface,
"SetBackupMetadata",
backup_id,
key_id,
@@ -344,7 +343,7 @@
backup_id = get_backup_id (iface, id);
if (backup_id) {
- tracker_db_exec_proc (tracker_db_manager_get_db_interface (TRACKER_DB_COMMON),
+ tracker_db_exec_proc (iface,
"DeleteBackupMetadataValue",
backup_id,
key_id,
@@ -364,7 +363,7 @@
backup_id = get_backup_id (iface, id);
if (backup_id) {
- tracker_db_exec_proc (tracker_db_manager_get_db_interface (TRACKER_DB_COMMON),
+ tracker_db_exec_proc (iface,
"DeleteBackupMetadata",
backup_id,
key_id,
@@ -462,7 +461,7 @@
return id;
}
-
+/*
static void
delete_index_for_service (TrackerDBInterface *iface,
guint32 id)
@@ -478,11 +477,11 @@
g_free (str_file_id);
}
-
+*/
+/*
static void
-dec_stat (gint id)
+dec_stat (TrackerDBInterface *iface, gint id)
{
- TrackerDBInterface *iface;
gchar *service;
gchar *parent;
@@ -492,8 +491,6 @@
return;
}
- iface = tracker_db_manager_get_db_interface (TRACKER_DB_COMMON);
-
tracker_db_exec_proc (iface, "DecStat", service, NULL);
parent = tracker_ontology_get_parent_service (service);
@@ -505,8 +502,11 @@
g_free (service);
}
+*/
/* Update all non-dirs in a dir for a file move */
+
+/*
static void
directory_move_files (TrackerDBInterface *iface,
const gchar *moved_from_uri,
@@ -514,7 +514,7 @@
{
TrackerDBResultSet *result_set;
- /* Get all sub files (excluding folders) that were moved and add watches */
+ * Get all sub files (excluding folders) that were moved and add watches *
result_set = tracker_db_exec_proc (iface,
"SelectFileChildWithoutDirs",
moved_from_uri,
@@ -557,10 +557,10 @@
const gchar *moved_from_uri,
const gchar *moved_to_uri)
{
- /* FIXME: the monitor updates should not be done here, -mr */
+ * FIXME: the monitor updates should not be done here, -mr *
#if 0
- /* Stop watching old dir, start watching new dir */
+ * Stop watching old dir, start watching new dir *
tracker_monitor_remove (moved_from_uri, TRUE);
#endif
@@ -571,6 +571,7 @@
tracker_monitor_add (moved_to_uri);
#endif
}
+*/
static gint
get_memory_usage (void)
@@ -1452,6 +1453,7 @@
/* Fast insert of embedded metadata. Table parameter is used to build
* up a unique word list of indexable contents.
*/
+/*
void
tracker_db_metadata_insert_single_embedded (TrackerDBInterface *iface,
const gchar *service,
@@ -1588,7 +1590,7 @@
tracker_field_get_delimited (def));
}
- db_save_full_text (tracker_db_manager_get_db_interface_content (iface),
+ db_save_full_text (tracker_db_manager_get_db_interface_contentX (iface),
id,
values[i],
strlen (values[i]));
@@ -1711,6 +1713,7 @@
}
}
}
+*/
void
tracker_db_metadata_set_single (TrackerDBInterface *iface,
@@ -1876,7 +1879,7 @@
/* FIXME: is the blog the metadata blob/email
* blob or something else?
*/
- db_save_full_text (tracker_db_manager_get_db_interface_content (iface),
+ db_save_full_text (iface,
id,
values[0],
strlen (values[0]));
@@ -2723,7 +2726,6 @@
{
TrackerDBResultSet *result_set;
TrackerDBResultSet *result_set_proc;
- TrackerDBInterface *iface_common;
gint i;
guint32 id = 0;
gchar *sid;
@@ -2752,10 +2754,8 @@
path = tracker_file_get_vfs_path (info->uri);
}
- iface_common = tracker_db_manager_get_db_interface (TRACKER_DB_COMMON);
-
/* Get a new unique ID for the service - use mutex to prevent race conditions */
- result_set = tracker_db_exec_proc (iface_common, "GetNewID", NULL);
+ result_set = tracker_db_exec_proc (iface, "GetNewID", NULL);
if (!result_set) {
g_critical ("Could not create service, GetNewID failed");
@@ -2768,7 +2768,7 @@
i++;
sid = tracker_int_to_string (i);
- result_set_proc = tracker_db_exec_proc (iface_common, "UpdateNewID", sid, NULL);
+ result_set_proc = tracker_db_exec_proc (iface, "UpdateNewID", sid, NULL);
if (result_set_proc) {
g_object_unref (result_set_proc);
@@ -2853,7 +2853,7 @@
(int) id);
}
- result_set_proc = tracker_db_exec_proc (iface_common,
+ result_set_proc = tracker_db_exec_proc (iface,
"IncStat",
service,
NULL);
@@ -2865,7 +2865,7 @@
parent = tracker_ontology_get_parent_service (service);
if (parent) {
- result_set_proc = tracker_db_exec_proc (iface_common,
+ result_set_proc = tracker_db_exec_proc (iface,
"IncStat",
parent,
NULL);
@@ -2982,6 +2982,7 @@
return NULL;
}
+/*
TrackerDBFileInfo *
tracker_db_file_get_info (TrackerDBInterface *iface,
TrackerDBFileInfo *info)
@@ -3033,7 +3034,9 @@
return info;
}
+*/
+/*
gboolean
tracker_db_file_is_up_to_date (TrackerDBInterface *iface,
const gchar *uri,
@@ -3084,7 +3087,9 @@
return TRUE;
}
+*/
+/*
void
tracker_db_file_delete (TrackerDBInterface *iface,
guint32 file_id)
@@ -3096,8 +3101,6 @@
gchar *path;
gint id;
- iface_common = tracker_db_manager_get_db_interface (TRACKER_DB_COMMON);
-
g_return_if_fail (TRACKER_IS_DB_INTERFACE (iface));
g_return_if_fail (TRACKER_IS_DB_INTERFACE (iface_common));
@@ -3115,14 +3118,14 @@
-1);
if (name && path) {
- dec_stat (id);
+ dec_stat (iface, id);
tracker_db_exec_proc (iface, "DeleteService1", str_file_id, NULL);
- tracker_db_exec_proc (iface_common, "DeleteService6", path, name, NULL);
- tracker_db_exec_proc (iface_common, "DeleteService7", path, name, NULL);
- tracker_db_exec_proc (iface_common, "DeleteService9", path, name, NULL);
+ tracker_db_exec_proc (iface, "DeleteService6", path, name, NULL);
+ tracker_db_exec_proc (iface, "DeleteService7", path, name, NULL);
+ tracker_db_exec_proc (iface, "DeleteService9", path, name, NULL);
- db_create_event (iface_common, str_file_id, "Delete");
+ db_create_event (iface, str_file_id, "Delete");
g_free (name);
g_free (path);
@@ -3133,7 +3136,9 @@
g_free (str_file_id);
}
+*/
+/*
void
tracker_db_directory_delete (TrackerDBInterface *iface,
guint32 file_id,
@@ -3150,7 +3155,7 @@
uri_prefix = g_strconcat (uri, G_DIR_SEPARATOR_S, "*", NULL);
delete_index_for_service (iface, file_id);
- /* Get all file id's for all files recursively under directory amd delete them */
+ * Get all file id's for all files recursively under directory amd delete them *
result_set = tracker_db_exec_proc (iface,
"SelectSubFileIDs",
uri,
@@ -3171,13 +3176,15 @@
g_object_unref (result_set);
}
- /* Delete directory */
+ * Delete directory *
tracker_db_file_delete (iface, file_id);
g_free (uri_prefix);
g_free (str_file_id);
}
+*/
+/*
void
tracker_db_uri_insert_pending (const gchar *id,
const gchar *action,
@@ -3201,7 +3208,7 @@
g_return_if_fail (uri != NULL);
g_return_if_fail (mime != NULL);
- iface = tracker_db_manager_get_db_interface (TRACKER_DB_CACHE);
+ iface = tracker_db_manager_get_db_interfaceX (TRACKER_DB_CACHE);
time (&time_now);
@@ -3239,6 +3246,9 @@
g_free (time_str);
}
+*/
+
+/*
void
tracker_db_uri_update_pending (const gchar *counter,
const gchar *action,
@@ -3253,7 +3263,7 @@
g_return_if_fail (action != NULL);
g_return_if_fail (uri != NULL);
- iface = tracker_db_manager_get_db_interface (TRACKER_DB_CACHE);
+ iface = tracker_db_manager_get_db_interfaceX (TRACKER_DB_CACHE);
time (&time_now);
@@ -3270,6 +3280,7 @@
g_free (time_str);
}
+*/
gchar **
tracker_db_files_get (TrackerDBInterface *iface,
@@ -3421,6 +3432,7 @@
}
}
+/*
TrackerDBResultSet *
tracker_db_uri_sub_watches_get (const gchar *dir)
{
@@ -3430,7 +3442,7 @@
g_return_val_if_fail (dir != NULL, NULL);
- iface = tracker_db_manager_get_db_interface (TRACKER_DB_CACHE);
+ iface = tracker_db_manager_get_db_interfaceX (TRACKER_DB_CACHE);
folder = g_build_filename (dir, "*", NULL);
result_set = tracker_db_exec_proc (iface,
@@ -3441,7 +3453,9 @@
return result_set;
}
+*/
+/*
TrackerDBResultSet *
tracker_db_uri_sub_watches_delete (const gchar *dir)
{
@@ -3451,7 +3465,7 @@
g_return_val_if_fail (dir != NULL, NULL);
- iface = tracker_db_manager_get_db_interface (TRACKER_DB_CACHE);
+ iface = tracker_db_manager_get_db_interfaceX (TRACKER_DB_CACHE);
folder = g_build_filename (dir, "*", NULL);
result_set = tracker_db_exec_proc (iface,
@@ -3463,13 +3477,13 @@
return result_set;
}
-
+*/
+/*
void
tracker_db_file_move (TrackerDBInterface *iface,
const gchar *moved_from_uri,
const gchar *moved_to_uri)
{
- TrackerDBInterface *iface_common;
gchar *str_file_id;
gchar *name;
gchar *path;
@@ -3486,7 +3500,7 @@
moved_from_uri,
moved_to_uri);
- /* If orig file not in DB, treat it asa create action */
+ * If orig file not in DB, treat it asa create action *
id = tracker_db_file_get_id (iface, moved_from_uri);
if (id == 0) {
@@ -3502,7 +3516,7 @@
old_name = g_path_get_basename (moved_from_uri);
old_path = g_path_get_dirname (moved_from_uri);
- /* Update db so that fileID reflects new uri */
+ * Update db so that fileID reflects new uri *
tracker_db_exec_proc (iface,
"UpdateFileMove",
path,
@@ -3510,10 +3524,9 @@
str_file_id,
NULL);
- iface_common = tracker_db_manager_get_db_interface (TRACKER_DB_COMMON);
- db_create_event (iface_common, str_file_id, "Update");
+ db_create_event (iface, str_file_id, "Update");
- /* update File:Path and File:Filename metadata */
+ * update File:Path and File:Filename metadata *
tracker_db_metadata_set_single (iface,
"Files", str_file_id,
"File:Path", path,
@@ -3532,8 +3545,8 @@
FALSE);
}
- /* Update backup service if necessary */
- tracker_db_exec_proc (iface_common,
+ * Update backup service if necessary *
+ tracker_db_exec_proc (iface,
"UpdateBackupService",
path,
name,
@@ -3547,7 +3560,9 @@
g_free (old_name);
g_free (old_path);
}
+*/
+/*
void
tracker_db_directory_move (TrackerDBInterface *iface,
const gchar *moved_from_uri,
@@ -3562,7 +3577,7 @@
old_path = g_strconcat (moved_from_uri, G_DIR_SEPARATOR_S, NULL);
- /* Get all sub folders that were moved and add watches */
+ * Get all sub folders that were moved and add watches *
result_set = tracker_db_uri_get_subfolders (iface, moved_from_uri);
if (result_set) {
@@ -3579,7 +3594,7 @@
dir_name = g_build_filename (prefix, name, NULL);
- /* Get string after prefix */
+ * Get string after prefix *
if (!old_path) {
sep = g_strdup (dir_name);
} else {
@@ -3611,7 +3626,7 @@
directory_move (iface, dir_name, new_path);
- /* FIXME: Why? */
+ * FIXME: Why? *
g_usleep (1000);
g_free (prefix);
@@ -3629,7 +3644,8 @@
g_free (old_path);
}
-
+*/
+/*
TrackerDBResultSet *
tracker_db_uri_get_subfolders (TrackerDBInterface *iface,
const gchar *uri)
@@ -3650,6 +3666,7 @@
return result_set;
}
+*/
TrackerDBResultSet *
tracker_db_keywords_get_list (TrackerDBInterface *iface,
@@ -3797,6 +3814,7 @@
return field_data;
}
+/*
gchar *
tracker_db_get_option_string (const gchar *option)
{
@@ -3806,7 +3824,7 @@
g_return_val_if_fail (option != NULL, NULL);
- iface = tracker_db_manager_get_db_interface (TRACKER_DB_COMMON);
+ iface = tracker_db_manager_get_db_interfaceX (TRACKER_DB_COMMON);
result_set = tracker_db_exec_proc (iface, "GetOption", option, NULL);
if (result_set) {
@@ -3817,6 +3835,7 @@
return value;
}
+
void
tracker_db_set_option_string (const gchar *option,
const gchar *value)
@@ -3827,13 +3846,14 @@
g_return_if_fail (option != NULL);
g_return_if_fail (value != NULL);
- iface = tracker_db_manager_get_db_interface (TRACKER_DB_COMMON);
+ iface = tracker_db_manager_get_db_interfaceX (TRACKER_DB_COMMON);
result_set = tracker_db_exec_proc (iface, "SetOption", value, option, NULL);
if (result_set) {
g_object_unref (result_set);
}
}
+*/
gint
tracker_db_get_option_int (const gchar *option)
@@ -3845,7 +3865,15 @@
g_return_val_if_fail (option != NULL, 0);
- iface = tracker_db_manager_get_db_interface (TRACKER_DB_COMMON);
+ /* Here it doesn't matter which one we ask, as long as it has common.db
+ * attached. The service ones are cached connections, so we can use
+ * those instead of asking for an individual-file connection (like what
+ * the original code had) */
+
+ /* iface = tracker_db_manager_get_db_interfaceX (TRACKER_DB_COMMON); */
+
+ iface = tracker_db_manager_get_db_interface_by_service (TRACKER_DB_FOR_FILE_SERVICE);
+
result_set = tracker_db_exec_proc (iface, "GetOption", option, NULL);
if (result_set) {
@@ -3872,8 +3900,15 @@
g_return_if_fail (option != NULL);
- iface = tracker_db_manager_get_db_interface (TRACKER_DB_COMMON);
-
+ /* Here it doesn't matter which one we ask, as long as it has common.db
+ * attached. The service ones are cached connections, so we can use
+ * those instead of asking for an individual-file connection (like what
+ * the original code had) */
+
+ /* iface = tracker_db_manager_get_db_interfaceX (TRACKER_DB_COMMON); */
+
+ iface = tracker_db_manager_get_db_interface_by_service (TRACKER_DB_FOR_FILE_SERVICE);
+
str = tracker_int_to_string (value);
result_set = tracker_db_exec_proc (iface, "SetOption", str, option, NULL);
g_free (str);
Modified: branches/xesam-support/src/trackerd/tracker-db.h
==============================================================================
--- branches/xesam-support/src/trackerd/tracker-db.h (original)
+++ branches/xesam-support/src/trackerd/tracker-db.h Thu Jul 3 14:55:07 2008
@@ -51,9 +51,12 @@
TrackerDBResultSet *tracker_db_exec (TrackerDBInterface *iface,
const char *query,
...);
+/*
gchar * tracker_db_get_option_string (const gchar *option);
+
void tracker_db_set_option_string (const gchar *option,
const gchar *value);
+*/
gint tracker_db_get_option_int (const gchar *option);
void tracker_db_set_option_int (const gchar *option,
gint value);
@@ -84,6 +87,7 @@
const gchar *key,
const gchar *value,
gboolean do_backup);
+/*
void tracker_db_metadata_insert_embedded (TrackerDBInterface *iface,
const gchar *service,
const gchar *id,
@@ -96,6 +100,7 @@
const gchar *key,
const gchar *value,
GHashTable *table);
+*/
void tracker_db_metadata_delete_value (TrackerDBInterface *iface,
const gchar *service,
const gchar *id,
@@ -154,22 +159,35 @@
gchar * tracker_db_file_get_id_as_string (TrackerDBInterface *iface,
const gchar *service,
const gchar *uri);
+/*
TrackerDBFileInfo * tracker_db_file_get_info (TrackerDBInterface *iface,
TrackerDBFileInfo *info);
+*/
+/*
gboolean tracker_db_file_is_up_to_date (TrackerDBInterface *iface,
const gchar *uri,
guint32 *id);
+*/
+/*
void tracker_db_file_delete (TrackerDBInterface *iface,
guint32 file_id);
+*/
+/*
void tracker_db_file_move (TrackerDBInterface *iface,
const gchar *moved_from_uri,
const gchar *moved_to_uri);
+*/
+/*
void tracker_db_directory_delete (TrackerDBInterface *iface,
guint32 file_id,
const gchar *uri);
+*/
+/*
void tracker_db_directory_move (TrackerDBInterface *iface,
const gchar *moved_from_uri,
const gchar *moved_to_uri);
+*/
+ /*
void tracker_db_uri_insert_pending (const gchar *id,
const gchar *action,
const gchar *counter,
@@ -181,10 +199,15 @@
void tracker_db_uri_update_pending (const gchar *counter,
const gchar *action,
const gchar *uri);
+*/
+/*
TrackerDBResultSet *tracker_db_uri_get_subfolders (TrackerDBInterface *iface,
const gchar *uri);
+*/
+/*
TrackerDBResultSet *tracker_db_uri_sub_watches_get (const gchar *dir);
TrackerDBResultSet *tracker_db_uri_sub_watches_delete (const gchar *dir);
+*/
/* Keywords API */
TrackerDBResultSet *tracker_db_keywords_get_list (TrackerDBInterface *iface,
Modified: branches/xesam-support/src/trackerd/tracker-files.c
==============================================================================
--- branches/xesam-support/src/trackerd/tracker-files.c (original)
+++ branches/xesam-support/src/trackerd/tracker-files.c Thu Jul 3 14:55:07 2008
@@ -37,6 +37,7 @@
#include "tracker-files.h"
#include "tracker-db.h"
#include "tracker-marshal.h"
+#include "tracker-indexer-client.h"
G_DEFINE_TYPE(TrackerFiles, tracker_files, G_TYPE_OBJECT)
@@ -81,7 +82,7 @@
"uri:'%s'",
uri);
- iface = tracker_db_manager_get_db_interface (TRACKER_DB_FILE_METADATA);
+ iface = tracker_db_manager_get_db_interface_by_service (TRACKER_DB_FOR_FILE_SERVICE);
file_id = tracker_db_file_get_id (iface, uri);
exists = file_id > 0;
@@ -148,7 +149,7 @@
size,
mtime);
- iface = tracker_db_manager_get_db_interface (TRACKER_DB_FILE_METADATA);
+ iface = tracker_db_manager_get_db_interface_by_service (TRACKER_DB_FOR_FILE_SERVICE);
/* Create structure */
info = tracker_db_file_info_new (uri, 1, 0, 0);
@@ -234,6 +235,13 @@
return created;
}
+static void
+on_indexer_deleted (DBusGProxy *proxy, GError *error, gpointer user_data)
+{
+ GStrv files = user_data;
+ g_strfreev (files);
+}
+
gboolean
tracker_files_delete (TrackerFiles *object,
const gchar *uri,
@@ -243,27 +251,24 @@
TrackerDBResultSet *result_set;
guint request_id;
guint32 file_id;
- gchar *name;
+ gchar *full;
gchar *path;
+ gchar *name;
gboolean is_directory;
- TrackerDBAction action;
+ GStrv files;
request_id = tracker_dbus_get_next_request_id ();
tracker_dbus_return_val_if_fail (uri != NULL, FALSE, error);
- tracker_dbus_request_new (request_id,
- "DBus request to delete file, "
- "uri:'%s'",
- uri);
-
- iface = tracker_db_manager_get_db_interface (TRACKER_DB_FILE_METADATA);
+ iface = tracker_db_manager_get_db_interface_by_service (TRACKER_DB_FOR_FILE_SERVICE);
file_id = tracker_db_file_get_id (iface, uri);
if (file_id == 0) {
tracker_dbus_request_comment (request_id,
"File or directory was not in database to delete, uri:'%s'",
uri);
+
tracker_dbus_request_success (request_id);
return TRUE;
}
@@ -271,46 +276,52 @@
if (uri[0] == G_DIR_SEPARATOR) {
name = g_path_get_basename (uri);
path = g_path_get_dirname (uri);
+ full = g_strdup (uri);
} else {
name = tracker_file_get_vfs_name (uri);
path = tracker_file_get_vfs_path (uri);
+ full = g_build_filename (G_DIR_SEPARATOR_S, path, name, NULL);
}
is_directory = FALSE;
-
+
result_set = tracker_db_exec_proc (iface,
"GetServiceID",
path,
name,
NULL);
+ g_free (name);
+ g_free (path);
+
if (result_set) {
tracker_db_result_set_get (result_set, 2, &is_directory, -1);
g_object_unref (result_set);
}
- if (is_directory) {
- action = TRACKER_DB_ACTION_DIRECTORY_DELETED;
- } else {
- action = TRACKER_DB_ACTION_FILE_DELETED;
- }
-
- /* tracker_db_insert_pending_file (iface_cache, */
- /* file_id, */
- /* uri, */
- /* NULL, */
- /* g_strdup ("unknown"), */
- /* 0, */
- /* action, */
- /* is_directory, */
- /* FALSE, */
- /* -1); */
+ files = (GStrv) g_malloc0 (sizeof (gchar*) * 1);
- g_free (path);
- g_free (name);
+ /* full is freed as part of the GStrv in the callback */
+ files[0] = full;
- tracker_dbus_request_success (request_id);
+ tracker_dbus_request_new (request_id,
+ "DBus request to delete file, "
+ "uri:'%s'",
+ uri);
- return TRUE;
+ org_freedesktop_Tracker_Indexer_files_delete_async (tracker_dbus_indexer_get_proxy (),
+ "files",
+ (const char **) files,
+ on_indexer_deleted,
+ files);
+
+ /* When we refactor to use async DBus api implementations, we can start
+ * caring about errors that happen in on_indexer_deleted and only
+ * dbus_g_method_return_error or dbus_g_method_return in the callback
+ * on_indexer_deleted */
+
+ tracker_dbus_request_success (request_id);
+
+ return TRUE;
}
gboolean
@@ -336,7 +347,7 @@
"uri:'%s'",
uri);
- iface = tracker_db_manager_get_db_interface (TRACKER_DB_FILE_METADATA);
+ iface = tracker_db_manager_get_db_interface_by_service (TRACKER_DB_FOR_FILE_SERVICE);
file_id = tracker_db_file_get_id (iface, uri);
@@ -399,8 +410,7 @@
gchar **value,
GError **error)
{
- TrackerDBInterface *iface_metadata;
- TrackerDBInterface *iface_contents;
+ TrackerDBInterface *iface;
TrackerDBResultSet *result_set;
guint request_id;
gchar *service_id;
@@ -421,12 +431,11 @@
offset,
max_length);
- iface_metadata = tracker_db_manager_get_db_interface (TRACKER_DB_FILE_METADATA);
- iface_contents = tracker_db_manager_get_db_interface (TRACKER_DB_FILE_CONTENTS);
+ iface = tracker_db_manager_get_db_interface_by_service (TRACKER_DB_FOR_FILE_SERVICE);
- service_id = tracker_db_file_get_id_as_string (iface_metadata, "Files", uri);
+ service_id = tracker_db_file_get_id_as_string (iface, "Files", uri);
if (!service_id) {
- service_id = tracker_db_file_get_id_as_string (iface_metadata, "Emails", uri);
+ service_id = tracker_db_file_get_id_as_string (iface, "Emails", uri);
if (!service_id) {
tracker_dbus_request_failed (request_id,
@@ -440,7 +449,7 @@
offset_str = tracker_int_to_string (offset);
max_length_str = tracker_int_to_string (max_length);
- result_set = tracker_db_exec_proc (iface_contents,
+ result_set = tracker_db_exec_proc (iface,
"GetFileContents",
offset_str,
max_length_str,
@@ -499,7 +508,7 @@
text,
max_length);
- iface = tracker_db_manager_get_db_interface (TRACKER_DB_FILE_METADATA);
+ iface = tracker_db_manager_get_db_interface_by_service (TRACKER_DB_FOR_FILE_SERVICE);
if (uri[0] == G_DIR_SEPARATOR) {
name = g_path_get_basename (uri);
@@ -570,7 +579,7 @@
offset,
max_hits);
- iface = tracker_db_manager_get_db_interface (TRACKER_DB_FILE_METADATA);
+ iface = tracker_db_manager_get_db_interface_by_service (TRACKER_DB_FOR_FILE_SERVICE);
if (!tracker_ontology_is_valid_service_type (service)) {
tracker_dbus_request_failed (request_id,
@@ -625,7 +634,7 @@
offset,
max_hits);
- iface = tracker_db_manager_get_db_interface (TRACKER_DB_FILE_METADATA);
+ iface = tracker_db_manager_get_db_interface_by_service (TRACKER_DB_FOR_FILE_SERVICE);
result_set = tracker_db_files_get_by_mime (iface,
mime_types,
@@ -674,7 +683,7 @@
offset,
max_hits);
- iface = tracker_db_manager_get_db_interface (TRACKER_DB_FILE_METADATA);
+ iface = tracker_db_manager_get_db_interface_by_service (TRACKER_DB_FOR_FILE_SERVICE);
/* NOTE: The only difference between this function and the
* non-VFS version is the boolean in this function call:
@@ -719,7 +728,7 @@
"uri:'%s'",
uri);
- iface = tracker_db_manager_get_db_interface (TRACKER_DB_FILE_METADATA);
+ iface = tracker_db_manager_get_db_interface_by_service (TRACKER_DB_FOR_FILE_SERVICE);
if (uri[0] == G_DIR_SEPARATOR) {
name = g_path_get_basename (uri);
@@ -786,7 +795,7 @@
uri,
g_strv_length (fields));
- iface = tracker_db_manager_get_db_interface (TRACKER_DB_FILE_METADATA);
+ iface = tracker_db_manager_get_db_interface_by_service (TRACKER_DB_FOR_FILE_SERVICE);
/* Get fields for metadata list provided */
for (i = 0; i < g_strv_length (fields); i++) {
@@ -914,7 +923,8 @@
text,
g_strv_length (mime_types));
- iface = tracker_db_manager_get_db_interface (TRACKER_DB_FILE_METADATA);
+ iface = tracker_db_manager_get_db_interface_by_service (TRACKER_DB_FOR_FILE_SERVICE);
+
result_set = tracker_db_search_text_and_mime (iface, text, mime_types);
if (result_set) {
@@ -973,7 +983,8 @@
text,
uri);
- iface = tracker_db_manager_get_db_interface (TRACKER_DB_FILE_METADATA);
+ iface = tracker_db_manager_get_db_interface_by_service (TRACKER_DB_FOR_FILE_SERVICE);
+
result_set = tracker_db_search_text_and_location (iface, text, uri);
if (result_set) {
@@ -1036,7 +1047,8 @@
g_strv_length (mime_types),
uri);
- iface = tracker_db_manager_get_db_interface (TRACKER_DB_FILE_METADATA);
+ iface = tracker_db_manager_get_db_interface_by_service (TRACKER_DB_FOR_FILE_SERVICE);
+
result_set = tracker_db_search_text_and_mime_and_location (iface, text, mime_types, uri);
if (result_set) {
Modified: branches/xesam-support/src/trackerd/tracker-indexer.c
==============================================================================
--- branches/xesam-support/src/trackerd/tracker-indexer.c (original)
+++ branches/xesam-support/src/trackerd/tracker-indexer.c Thu Jul 3 14:55:07 2008
@@ -55,7 +55,6 @@
#include "tracker-indexer.h"
#include "tracker-dbus.h"
#include "tracker-daemon.h"
-#include "tracker-process.h"
#include "tracker-query-tree.h"
#include "tracker-main.h"
#include "tracker-status.h"
Modified: branches/xesam-support/src/trackerd/tracker-keywords.c
==============================================================================
--- branches/xesam-support/src/trackerd/tracker-keywords.c (original)
+++ branches/xesam-support/src/trackerd/tracker-keywords.c Thu Jul 3 14:55:07 2008
@@ -138,7 +138,7 @@
return FALSE;
}
- iface = tracker_db_manager_get_db_interface_by_service (service, FALSE);
+ iface = tracker_db_manager_get_db_interface_by_service (service);
result_set = tracker_db_keywords_get_list (iface, service);
*values = tracker_dbus_query_result_to_ptr_array (result_set);
@@ -189,7 +189,7 @@
return FALSE;
}
- iface = tracker_db_manager_get_db_interface_by_service (service, FALSE);
+ iface = tracker_db_manager_get_db_interface_by_service (service);
id = tracker_db_file_get_id_as_string (iface, service, uri);
if (!id) {
tracker_dbus_request_failed (request_id,
@@ -254,7 +254,7 @@
return FALSE;
}
- iface = tracker_db_manager_get_db_interface_by_service (service, FALSE);
+ iface = tracker_db_manager_get_db_interface_by_service (service);
id = tracker_db_file_get_id_as_string (iface, service, uri);
tracker_dbus_return_val_if_fail (id != NULL, FALSE, error);
@@ -315,7 +315,7 @@
return FALSE;
}
- iface = tracker_db_manager_get_db_interface_by_service (service, FALSE);
+ iface = tracker_db_manager_get_db_interface_by_service (service);
id = tracker_db_file_get_id_as_string (iface, service, uri);
if (!id) {
tracker_dbus_request_failed (request_id,
@@ -375,7 +375,7 @@
return FALSE;
}
- iface = tracker_db_manager_get_db_interface_by_service (service, FALSE);
+ iface = tracker_db_manager_get_db_interface_by_service (service);
id = tracker_db_file_get_id_as_string (iface, service, uri);
if (!id) {
tracker_dbus_request_failed (request_id,
@@ -440,7 +440,7 @@
return FALSE;
}
- iface = tracker_db_manager_get_db_interface_by_service (service, FALSE);
+ iface = tracker_db_manager_get_db_interface_by_service (service);
/* Sanity check values */
offset = MAX (offset, 0);
Modified: branches/xesam-support/src/trackerd/tracker-main.c
==============================================================================
--- branches/xesam-support/src/trackerd/tracker-main.c (original)
+++ branches/xesam-support/src/trackerd/tracker-main.c Thu Jul 3 14:55:07 2008
@@ -40,6 +40,7 @@
#include <libtracker-common/tracker-language.h>
#include <libtracker-common/tracker-log.h>
#include <libtracker-common/tracker-hal.h>
+#include <libtracker-common/tracker-module-config.h>
#include <libtracker-common/tracker-ontology.h>
#include <libtracker-common/tracker-file-utils.h>
#include <libtracker-common/tracker-nfs-lock.h>
@@ -51,7 +52,7 @@
#include "tracker-indexer.h"
#include "tracker-indexer-client.h"
#include "tracker-monitor.h"
-#include "tracker-process.h"
+#include "tracker-processor.h"
#include "tracker-status.h"
#include "tracker-xesam-manager.h"
@@ -244,74 +245,30 @@
}
static void
-sanity_check_option_values (void)
+sanity_check_option_values (TrackerConfig *config)
{
- g_message ("Tracker configuration options:");
+ g_message ("General options:");
g_message (" Initial sleep ........................ %d (seconds)",
- tracker_config_get_initial_sleep (tracker->config));
+ tracker_config_get_initial_sleep (config));
g_message (" Verbosity ............................ %d",
- tracker_config_get_verbosity (tracker->config));
+ tracker_config_get_verbosity (config));
g_message (" Low memory mode ...................... %s",
- tracker_config_get_low_memory_mode (tracker->config) ? "yes" : "no");
+ tracker_config_get_low_memory_mode (config) ? "yes" : "no");
+
+
+ g_message ("Daemon options:");
g_message (" Indexing enabled ..................... %s",
- tracker_config_get_enable_indexing (tracker->config) ? "yes" : "no");
+ tracker_config_get_enable_indexing (config) ? "yes" : "no");
g_message (" Monitoring enabled ................... %s",
- tracker_config_get_enable_watches (tracker->config) ? "yes" : "no");
- g_message (" File content indexing enabled ........ %s",
- tracker_config_get_enable_content_indexing (tracker->config) ? "yes" : "no");
- g_message (" Thumbnailing enabled ................. %s",
- tracker_config_get_enable_thumbnails (tracker->config) ? "yes" : "no");
- g_message (" Email client to index ................ %s",
- tracker_config_get_email_client (tracker->config));
-
- g_message ("Tracker indexer parameters:");
- g_message (" Indexer language code ................ %s",
- tracker_config_get_language (tracker->config));
- g_message (" Stemmer enabled ...................... %s",
- tracker_config_get_enable_stemmer (tracker->config) ? "yes" : "no");
- g_message (" Fast merges enabled .................. %s",
- tracker_config_get_fast_merges (tracker->config) ? "yes" : "no");
- g_message (" Disable indexing on battery .......... %s (initially = %s)",
- tracker_config_get_disable_indexing_on_battery (tracker->config) ? "yes" : "no",
- tracker_config_get_disable_indexing_on_battery_init (tracker->config) ? "yes" : "no");
-
- if (tracker_config_get_low_disk_space_limit (tracker->config) == -1) {
- g_message (" Low disk space limit ................. Disabled");
- } else {
- g_message (" Low disk space limit ................. %d%%",
- tracker_config_get_low_disk_space_limit (tracker->config));
- }
+ tracker_config_get_enable_watches (config) ? "yes" : "no");
- g_message (" Minimum index word length ............ %d",
- tracker_config_get_min_word_length (tracker->config));
- g_message (" Maximum index word length ............ %d",
- tracker_config_get_max_word_length (tracker->config));
- g_message (" Maximum text to index ................ %d",
- tracker_config_get_max_text_to_index (tracker->config));
- g_message (" Maximum words to index ............... %d",
- tracker_config_get_max_words_to_index (tracker->config));
- g_message (" Maximum bucket count ................. %d",
- tracker_config_get_max_bucket_count (tracker->config));
- g_message (" Minimum bucket count ................. %d",
- tracker_config_get_min_bucket_count (tracker->config));
- g_message (" Divisions ............................ %d",
- tracker_config_get_divisions (tracker->config));
- g_message (" Padding .............................. %d",
- tracker_config_get_padding (tracker->config));
- g_message (" Optimization sweep count ............. %d",
- tracker_config_get_optimization_sweep_count (tracker->config));
- g_message (" Thread stack size .................... %d",
- tracker_config_get_thread_stack_size (tracker->config));
- g_message (" Throttle level ....................... %d",
- tracker_config_get_throttle (tracker->config));
-
- log_option_list (tracker_config_get_watch_directory_roots (tracker->config),
+ log_option_list (tracker_config_get_watch_directory_roots (config),
"Monitor directories included");
- log_option_list (tracker_config_get_no_watch_directory_roots (tracker->config),
+ log_option_list (tracker_config_get_no_watch_directory_roots (config),
"Monitor directories excluded");
- log_option_list (tracker_config_get_crawl_directory_roots (tracker->config),
+ log_option_list (tracker_config_get_crawl_directory_roots (config),
"Crawling directories");
- log_option_list (tracker_config_get_no_index_file_types (tracker->config),
+ log_option_list (tracker_config_get_no_index_file_types (config),
"File types excluded from indexing");
}
@@ -454,8 +411,16 @@
tracker->first_time_index = TRUE;
/* Reset stats for embedded services if they are being reindexed */
- iface = tracker_db_manager_get_db_interface (TRACKER_DB_FILE_METADATA);
-
+
+ /* Here it doesn't matter which one we ask, as long as it has common.db
+ * attached. The service ones are cached connections, so we can use
+ * those instead of asking for an individual-file connection (like what
+ * the original code had) */
+
+ /* iface = tracker_db_manager_get_db_interfaceX (TRACKER_DB_COMMON); */
+
+ iface = tracker_db_manager_get_db_interface_by_service (TRACKER_DB_FOR_FILE_SERVICE);
+
g_message ("*** DELETING STATS *** ");
tracker_db_exec_no_reply (iface,
"update ServiceTypes set TypeCount = 0 where Embedded = 1");
@@ -638,7 +603,7 @@
}
/* Get files first */
- tracker_process_start (user_data);
+ tracker_processor_start (user_data);
proxy = tracker_dbus_indexer_get_proxy ();
tracker_xesam_subscribe_index_updated (proxy);
@@ -653,6 +618,7 @@
GOptionGroup *group;
GError *error = NULL;
TrackerDBManagerFlags flags;
+ TrackerProcessor *processor;
g_type_init ();
@@ -780,28 +746,26 @@
return EXIT_FAILURE;
}
- sanity_check_option_values ();
+ sanity_check_option_values (tracker->config);
tracker_nfs_lock_init (tracker_config_get_nfs_locking (tracker->config));
- flags = TRACKER_DB_MANAGER_ATTACH_ALL |
- TRACKER_DB_MANAGER_REMOVE_CACHE;
+ flags = TRACKER_DB_MANAGER_REMOVE_CACHE;
if (reindex) {
flags |= TRACKER_DB_MANAGER_FORCE_REINDEX;
}
+ if (tracker_config_get_low_memory_mode (tracker->config)) {
+ flags |= TRACKER_DB_MANAGER_LOW_MEMORY_MODE;
+ }
+
tracker_db_manager_init (flags, &tracker->first_time_index);
tracker_db_init ();
tracker_xesam_manager_init ();
- tracker_process_init ();
+ tracker_module_config_init ();
- tracker->crawler = tracker_crawler_new (tracker->config);
-
-#ifdef HAVE_HAL
- tracker->hal = tracker_hal_new ();
- tracker_crawler_set_hal (tracker->crawler, tracker->hal);
-#endif /* HAVE_HAL */
+ processor = tracker_processor_new (tracker->config);
umask (077);
@@ -838,7 +802,7 @@
seconds);
g_timeout_add (seconds * 1000,
start_cb,
- tracker->crawler);
+ processor);
} else {
g_idle_add (start_cb, tracker);
}
@@ -861,29 +825,24 @@
/* Set kill timeout */
g_timeout_add_full (G_PRIORITY_LOW, 5000, shutdown_timeout_cb, NULL, NULL);
+ if (processor) {
+ g_object_unref (processor);
+ }
+
shutdown_indexer ();
shutdown_databases ();
shutdown_directories ();
/* Shutdown major subsystems */
tracker_dbus_shutdown ();
- tracker_process_shutdown ();
+ tracker_module_config_shutdown ();
tracker_xesam_manager_shutdown ();
- tracker_db_manager_shutdown (TRUE);
+ tracker_db_manager_shutdown ();
tracker_db_shutdown ();
tracker_monitor_shutdown ();
tracker_nfs_lock_shutdown ();
tracker_log_shutdown ();
-#ifdef HAVE_HAL
- if (tracker->hal) {
- g_object_unref (tracker->hal);
- }
-#endif
- if (tracker->crawler) {
- g_object_unref (tracker->crawler);
- }
-
if (tracker->language) {
g_object_unref (tracker->language);
}
@@ -903,7 +862,7 @@
tracker->is_running = FALSE;
/* Stop any tight loop operations */
- tracker_process_stop ();
+/* tracker_processor_stop ();*/
g_main_loop_quit (main_loop);
}
Modified: branches/xesam-support/src/trackerd/tracker-main.h
==============================================================================
--- branches/xesam-support/src/trackerd/tracker-main.h (original)
+++ branches/xesam-support/src/trackerd/tracker-main.h Thu Jul 3 14:55:07 2008
@@ -42,14 +42,9 @@
G_BEGIN_DECLS
typedef struct {
-#ifdef HAVE_HAL
- TrackerHal *hal;
-#endif
-
TrackerConfig *config;
TrackerLanguage *language;
- TrackerCrawler *crawler;
TrackerIndexer *file_index;
TrackerIndexer *file_update_index;
TrackerIndexer *email_index;
Modified: branches/xesam-support/src/trackerd/tracker-marshal.list
==============================================================================
--- branches/xesam-support/src/trackerd/tracker-marshal.list (original)
+++ branches/xesam-support/src/trackerd/tracker-marshal.list Thu Jul 3 14:55:07 2008
@@ -1,3 +1,4 @@
+VOID:UINT,UINT,UINT,UINT
VOID:STRING,STRING,INT,INT,INT
VOID:STRING,STRING,STRING
VOID:STRING,BOOLEAN,BOOLEAN,BOOLEAN,BOOLEAN,BOOLEAN,BOOLEAN
Modified: branches/xesam-support/src/trackerd/tracker-metadata.c
==============================================================================
--- branches/xesam-support/src/trackerd/tracker-metadata.c (original)
+++ branches/xesam-support/src/trackerd/tracker-metadata.c Thu Jul 3 14:55:07 2008
@@ -103,7 +103,7 @@
"service:'%s'",
service);
- iface = tracker_db_manager_get_db_interface_by_service (service, FALSE);
+ iface = tracker_db_manager_get_db_interface_by_service (service);
service_id = tracker_db_file_get_id_as_string (iface, service, id);
if (!service_id) {
@@ -239,7 +239,7 @@
return FALSE;
}
- iface = tracker_db_manager_get_db_interface_by_service (service, FALSE);
+ iface = tracker_db_manager_get_db_interface_by_service (service);
service_id = tracker_db_file_get_id_as_string (iface, service, id);
if (!service_id) {
@@ -284,6 +284,7 @@
return TRUE;
}
+
gboolean
tracker_metadata_get_type_details (TrackerMetadata *object,
const gchar *metadata,
@@ -304,8 +305,15 @@
tracker_dbus_return_val_if_fail (is_embedded != NULL, FALSE, error);
tracker_dbus_return_val_if_fail (is_writable != NULL, FALSE, error);
- iface = tracker_db_manager_get_db_interface (TRACKER_DB_FILE_METADATA);
-
+ /* Here it doesn't matter which one we ask, as long as it has common.db
+ * attached. The service ones are cached connections, so we can use
+ * those instead of asking for an individual-file connection (like what
+ * the original code had) */
+
+ /* iface = tracker_db_manager_get_db_interfaceX (TRACKER_DB_COMMON); */
+
+ iface = tracker_db_manager_get_db_interface_by_service (TRACKER_DB_FOR_FILE_SERVICE);
+
tracker_dbus_request_new (request_id,
"DBus request to get metadata details, "
"name:'%s'",
@@ -358,7 +366,14 @@
"class:'%s'",
class);
- iface = tracker_db_manager_get_db_interface (TRACKER_DB_COMMON);
+ /* Here it doesn't matter which one we ask, as long as it has common.db
+ * attached. The service ones are cached connections, so we can use
+ * those instead of asking for an individual-file connection (like what
+ * the original code had) */
+
+ /* iface = tracker_db_manager_get_db_interfaceX (TRACKER_DB_COMMON); */
+
+ iface = tracker_db_manager_get_db_interface_by_service (TRACKER_DB_FOR_FILE_SERVICE);
result_set = tracker_db_metadata_get_types (iface, class, FALSE);
if (result_set) {
@@ -387,7 +402,14 @@
tracker_dbus_request_new (request_id,
"DBus request to get registered classes");
- iface = tracker_db_manager_get_db_interface (TRACKER_DB_FILE_METADATA);
+ /* Here it doesn't matter which one we ask, as long as it has common.db
+ * attached. The service ones are cached connections, so we can use
+ * those instead of asking for an individual-file connection (like what
+ * the original code had) */
+
+ /* iface = tracker_db_manager_get_db_interfaceX (TRACKER_DB_COMMON); */
+
+ iface = tracker_db_manager_get_db_interface_by_service (TRACKER_DB_FOR_FILE_SERVICE);
result_set = tracker_db_exec_proc (iface,
"SelectMetadataClasses",
Modified: branches/xesam-support/src/trackerd/tracker-monitor.c
==============================================================================
--- branches/xesam-support/src/trackerd/tracker-monitor.c (original)
+++ branches/xesam-support/src/trackerd/tracker-monitor.c Thu Jul 3 14:55:07 2008
@@ -28,16 +28,14 @@
#include "tracker-dbus.h"
#include "tracker-indexer-client.h"
-/* #define TESTING */
-
#define FILES_QUEUE_PROCESS_INTERVAL 2000
#define FILES_QUEUE_PROCESS_MAX 5000
static TrackerConfig *config;
static GHashTable *monitors;
-static GAsyncQueue *files_created;
-static GAsyncQueue *files_updated;
-static GAsyncQueue *files_deleted;
+static GQueue *files_created;
+static GQueue *files_updated;
+static GQueue *files_deleted;
static guint files_queue_handlers_id;
static GType monitor_backend;
static guint monitor_limit;
@@ -90,15 +88,15 @@
}
if (!files_created) {
- files_created = g_async_queue_new ();
+ files_created = g_queue_new ();
}
if (!files_updated) {
- files_updated = g_async_queue_new ();
+ files_updated = g_queue_new ();
}
if (!files_deleted) {
- files_deleted = g_async_queue_new ();
+ files_deleted = g_queue_new ();
}
/* For the first monitor we get the type and find out if we
@@ -192,8 +190,6 @@
void
tracker_monitor_shutdown (void)
{
- gchar *str;
-
monitors_ignored = 0;
monitor_limit_warned = FALSE;
monitor_limit = 0;
@@ -204,29 +200,14 @@
files_queue_handlers_id = 0;
}
- for (str = g_async_queue_try_pop (files_deleted);
- str;
- str = g_async_queue_try_pop (files_deleted)) {
- g_free (str);
- }
-
- g_async_queue_unref (files_deleted);
-
- for (str = g_async_queue_try_pop (files_updated);
- str;
- str = g_async_queue_try_pop (files_updated)) {
- g_free (str);
- }
-
- g_async_queue_unref (files_updated);
+ g_queue_foreach (files_deleted, (GFunc) g_free, NULL);
+ g_queue_free (files_deleted);
- for (str = g_async_queue_try_pop (files_created);
- str;
- str = g_async_queue_try_pop (files_created)) {
- g_free (str);
- }
+ g_queue_foreach (files_updated, (GFunc) g_free, NULL);
+ g_queue_free (files_updated);
- g_async_queue_unref (files_created);
+ g_queue_foreach (files_created, (GFunc) g_free, NULL);
+ g_queue_free (files_created);
if (monitors) {
g_hash_table_unref (monitors);
@@ -246,8 +227,6 @@
{
GStrv files;
- files = (GStrv) user_data;
-
if (error) {
g_critical ("Could not send %d files to indexer, %s",
g_strv_length (files),
@@ -256,6 +235,9 @@
} else {
g_debug ("Sent!");
}
+
+ files = (GStrv) user_data;
+ g_strfreev (files);
}
static void
@@ -277,13 +259,13 @@
/* First do the deleted queue */
g_debug ("Files deleted queue being processed...");
- files = tracker_dbus_async_queue_to_strv (files_deleted,
- FILES_QUEUE_PROCESS_MAX);
+ files = tracker_dbus_queue_str_to_strv (files_deleted, FILES_QUEUE_PROCESS_MAX);
if (g_strv_length (files) > 0) {
g_debug ("Files deleted queue processed, sending first %d to the indexer",
g_strv_length (files));
- org_freedesktop_Tracker_Indexer_files_delete_async (proxy,
+ org_freedesktop_Tracker_Indexer_files_delete_async (proxy,
+ "files",
(const gchar **) files,
indexer_files_processed_cb,
files);
@@ -291,12 +273,12 @@
/* Second do the created queue */
g_debug ("Files created queue being processed...");
- files = tracker_dbus_async_queue_to_strv (files_created,
- FILES_QUEUE_PROCESS_MAX);
+ files = tracker_dbus_queue_str_to_strv (files_created, FILES_QUEUE_PROCESS_MAX);
if (g_strv_length (files) > 0) {
g_debug ("Files created queue processed, sending first %d to the indexer",
g_strv_length (files));
- org_freedesktop_Tracker_Indexer_files_check_async (proxy,
+ org_freedesktop_Tracker_Indexer_files_check_async (proxy,
+ "files",
(const gchar **) files,
indexer_files_processed_cb,
files);
@@ -304,13 +286,13 @@
/* Second do the created queue */
g_debug ("Files updated queue being processed...");
- files = tracker_dbus_async_queue_to_strv (files_updated,
- FILES_QUEUE_PROCESS_MAX);
+ files = tracker_dbus_queue_str_to_strv (files_updated, FILES_QUEUE_PROCESS_MAX);
if (g_strv_length (files) > 0) {
g_debug ("Files updated queue processed, sending first %d to the indexer",
g_strv_length (files));
- org_freedesktop_Tracker_Indexer_files_update_async (proxy,
+ org_freedesktop_Tracker_Indexer_files_update_async (proxy,
+ "files",
(const gchar **) files,
indexer_files_processed_cb,
files);
@@ -323,9 +305,9 @@
DBusGProxy *proxy;
gint items_to_process = 0;
- items_to_process += g_async_queue_length (files_created);
- items_to_process += g_async_queue_length (files_updated);
- items_to_process += g_async_queue_length (files_deleted);
+ items_to_process += g_queue_get_length (files_created);
+ items_to_process += g_queue_get_length (files_updated);
+ items_to_process += g_queue_get_length (files_deleted);
if (items_to_process < 1) {
g_debug ("All queues are empty... nothing to do");
@@ -406,17 +388,17 @@
case G_FILE_MONITOR_EVENT_CHANGED:
case G_FILE_MONITOR_EVENT_CHANGES_DONE_HINT:
case G_FILE_MONITOR_EVENT_ATTRIBUTE_CHANGED:
- g_async_queue_push (files_updated, str1);
+ g_queue_push_tail (files_updated, str1);
file_queue_handlers_set_up ();
break;
case G_FILE_MONITOR_EVENT_DELETED:
- g_async_queue_push (files_deleted, str1);
+ g_queue_push_tail (files_deleted, str1);
file_queue_handlers_set_up ();
break;
case G_FILE_MONITOR_EVENT_CREATED:
- g_async_queue_push (files_created, str1);
+ g_queue_push_tail (files_created, str1);
file_queue_handlers_set_up ();
break;
@@ -440,6 +422,10 @@
gchar *path;
g_return_val_if_fail (G_IS_FILE (file), FALSE);
+
+ if (!tracker_config_get_enable_watches (config)) {
+ return TRUE;
+ }
if (g_hash_table_lookup (monitors, file)) {
return TRUE;
@@ -462,6 +448,7 @@
path = g_file_get_path (file);
ignored_roots = tracker_config_get_no_watch_directory_roots (config);
+
/* Check this location isn't excluded in the config */
for (l = ignored_roots; l; l = l->next) {
if (strcmp (path, l->data) == 0) {
@@ -500,11 +487,9 @@
g_object_ref (file),
monitor);
-#ifdef TESTING
g_debug ("Added monitor for:'%s', total monitors:%d",
path,
g_hash_table_size (monitors));
-#endif /* TESTING */
g_free (path);
@@ -520,6 +505,10 @@
g_return_val_if_fail (G_IS_FILE (file), FALSE);
+ if (!tracker_config_get_enable_watches (config)) {
+ return TRUE;
+ }
+
monitor = g_hash_table_lookup (monitors, file);
if (!monitor) {
return TRUE;
@@ -532,11 +521,9 @@
path = g_file_get_path (file);
-#ifdef TESTING
g_debug ("Removed monitor for:'%s', total monitors:%d",
path,
g_hash_table_size (monitors));
-#endif /* TESTING */
g_free (path);
Modified: branches/xesam-support/src/trackerd/tracker-search.c
==============================================================================
--- branches/xesam-support/src/trackerd/tracker-search.c (original)
+++ branches/xesam-support/src/trackerd/tracker-search.c Thu Jul 3 14:55:07 2008
@@ -766,7 +766,7 @@
return FALSE;
}
- iface = tracker_db_manager_get_db_interface_by_service (service, FALSE);
+ iface = tracker_db_manager_get_db_interface_by_service (service);
result_set = tracker_db_search_text (iface,
service,
@@ -864,7 +864,7 @@
return FALSE;
}
- iface = tracker_db_manager_get_db_interface_by_service (service, FALSE);
+ iface = tracker_db_manager_get_db_interface_by_service (service);
result_set = tracker_db_search_text (iface,
service,
@@ -931,7 +931,7 @@
return FALSE;
}
- iface = tracker_db_manager_get_db_interface_by_service (service, FALSE);
+ iface = tracker_db_manager_get_db_interface_by_service (service);
service_id = tracker_db_file_get_id_as_string (iface, service, id);
if (!service_id) {
@@ -942,7 +942,7 @@
return FALSE;
}
- iface = tracker_db_manager_get_db_interface_by_service (service, TRUE);
+ iface = tracker_db_manager_get_db_interface_by_service (service);
result_set = tracker_db_exec_proc (iface,
"GetAllContents",
@@ -991,7 +991,7 @@
GHashTable **values,
GError **error)
{
- TrackerDBInterface *iface;
+ /* TrackerDBInterface *iface; */
TrackerDBResultSet *result_set;
guint request_id;
@@ -1010,7 +1010,7 @@
max_hits,
group_results ? "yes" : "no");
- iface = tracker_db_manager_get_db_interface (TRACKER_DB_FILE_METADATA);
+ /* iface = tracker_db_manager_get_db_interface_by_service (TRACKER_DB_FOR_FILE_SERVICE); */
/* FIXME: This function no longer exists, it was returning
* NULL in every case, this DBus function needs rewriting or
@@ -1076,7 +1076,7 @@
return FALSE;
}
- iface = tracker_db_manager_get_db_interface_by_service (service, FALSE);
+ iface = tracker_db_manager_get_db_interface_by_service (service);
/* FIXME: This function no longer exists, it was returning
* NULL in every case, this DBus function needs rewriting or
@@ -1142,7 +1142,7 @@
return FALSE;
}
- iface = tracker_db_manager_get_db_interface_by_service (service, FALSE);
+ iface = tracker_db_manager_get_db_interface_by_service (service);
/* FIXME: This function no longer exists, it was returning
* NULL in every case, this DBus function needs rewriting or
@@ -1216,7 +1216,7 @@
result_set = NULL;
- iface = tracker_db_manager_get_db_interface_by_service (service, FALSE);
+ iface = tracker_db_manager_get_db_interface_by_service (service);
if (query_condition) {
GError *query_error = NULL;
Modified: branches/xesam-support/src/trackerd/tracker-utils.c
==============================================================================
--- branches/xesam-support/src/trackerd/tracker-utils.c (original)
+++ branches/xesam-support/src/trackerd/tracker-utils.c Thu Jul 3 14:55:07 2008
@@ -28,7 +28,6 @@
#include "tracker-utils.h"
#include "tracker-main.h"
-#include "tracker-process.h"
#include "tracker-xesam-manager.h"
extern Tracker *tracker;
Modified: branches/xesam-support/src/trackerd/tracker-xesam-live-search.c
==============================================================================
--- branches/xesam-support/src/trackerd/tracker-xesam-live-search.c (original)
+++ branches/xesam-support/src/trackerd/tracker-xesam-live-search.c Thu Jul 3 14:55:07 2008
@@ -406,7 +406,7 @@
g_return_if_fail (removed != NULL);
g_return_if_fail (modified != NULL);
- iface = tracker_db_manager_get_db_interface (TRACKER_DB_XESAM);
+ iface = tracker_db_manager_get_db_interface_by_service (TRACKER_DB_FOR_XESAM_SERVICE);
*added = NULL;
*removed = NULL;
@@ -478,8 +478,8 @@
"Search was already closed");
} else {
TrackerDBInterface *iface;
-
- iface = tracker_db_manager_get_db_interface (TRACKER_DB_XESAM);
+
+ iface = tracker_db_manager_get_db_interface_by_service (TRACKER_DB_FOR_XESAM_SERVICE);
g_message ("Closing search '%s'",
tracker_xesam_live_search_get_id (self));
@@ -525,7 +525,7 @@
TrackerDBResultSet *result_set;
GValue value = {0, };
- iface = tracker_db_manager_get_db_interface (TRACKER_DB_XESAM);
+ iface = tracker_db_manager_get_db_interface_by_service (TRACKER_DB_FOR_XESAM_SERVICE);
result_set = tracker_db_live_search_get_hit_count (iface,
tracker_xesam_live_search_get_id (self));
@@ -865,7 +865,7 @@
fields = g_value_get_boxed (value);
- iface = tracker_db_manager_get_db_interface (TRACKER_DB_XESAM);
+ iface = tracker_db_manager_get_db_interface_by_service (TRACKER_DB_FOR_XESAM_SERVICE);
/* For ottela: fetch results for get_hits */
@@ -917,7 +917,7 @@
GValue *value;
GError *tmp_error = NULL;
- iface = tracker_db_manager_get_db_interface (TRACKER_DB_XESAM);
+ iface = tracker_db_manager_get_db_interface_by_service (TRACKER_DB_FOR_XESAM_SERVICE);
tracker_xesam_session_get_property (session,
"hit.fields",
@@ -1007,7 +1007,7 @@
TrackerDBInterface *iface;
TrackerDBResultSet *result_set;
- iface = tracker_db_manager_get_db_interface (TRACKER_DB_XESAM);
+ iface = tracker_db_manager_get_db_interface_by_service (TRACKER_DB_FOR_XESAM_SERVICE);
result_set = tracker_db_live_search_get_hit_data (iface,
tracker_xesam_live_search_get_id (self),
@@ -1052,7 +1052,7 @@
TrackerDBInterface *iface;
TrackerDBResultSet *result_set;
- iface = tracker_db_manager_get_db_interface (TRACKER_DB_XESAM);
+ iface = tracker_db_manager_get_db_interface_by_service (TRACKER_DB_FOR_XESAM_SERVICE);
result_set = tracker_db_live_search_get_hit_data (iface,
tracker_xesam_live_search_get_id (self),
@@ -1114,7 +1114,7 @@
TrackerDBInterface *iface;
GArray *hits;
- iface = tracker_db_manager_get_db_interface (TRACKER_DB_XESAM);
+ iface = tracker_db_manager_get_db_interface_by_service (TRACKER_DB_FOR_XESAM_SERVICE);
tracker_db_live_search_start (iface,
tracker_xesam_live_search_get_from_query (self),
@@ -1234,7 +1234,8 @@
priv = self->priv;
- iface = tracker_db_manager_get_db_interface (TRACKER_DB_XESAM);
+ iface = tracker_db_manager_get_db_interface_by_service (TRACKER_DB_FOR_XESAM_SERVICE);
+
xesam = tracker_dbus_get_object (TRACKER_TYPE_XESAM);
orig_from = priv->from_sql;
Modified: branches/xesam-support/src/trackerd/tracker-xesam-manager.c
==============================================================================
--- branches/xesam-support/src/trackerd/tracker-xesam-manager.c (original)
+++ branches/xesam-support/src/trackerd/tracker-xesam-manager.c Thu Jul 3 14:55:07 2008
@@ -263,7 +263,7 @@
GList *sessions;
gboolean reason_to_live = FALSE;
- iface = tracker_db_manager_get_db_interface (TRACKER_DB_XESAM);
+ iface = tracker_db_manager_get_db_interface_by_service (TRACKER_DB_FOR_XESAM_SERVICE);
g_return_val_if_fail (iface != NULL, FALSE);
@@ -337,6 +337,7 @@
tracker_db_xesam_delete_handled_events (iface);
+
return reason_to_live;
}
Modified: branches/xesam-support/tests/Makefile.am
==============================================================================
--- branches/xesam-support/tests/Makefile.am (original)
+++ branches/xesam-support/tests/Makefile.am Thu Jul 3 14:55:07 2008
@@ -1,3 +1,8 @@
include $(top_srcdir)/Makefile.decl
-SUBDIRS = common libtracker-common trackerd scripts libtracker-db
+SUBDIRS = common \
+ libtracker-common \
+ trackerd \
+ scripts \
+ libtracker-db \
+ tracker-indexer
Modified: branches/xesam-support/tests/common/tracker-test-helpers.c
==============================================================================
--- branches/xesam-support/tests/common/tracker-test-helpers.c (original)
+++ branches/xesam-support/tests/common/tracker-test-helpers.c Thu Jul 3 14:55:07 2008
@@ -1,3 +1,22 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+/*
+ * Copyright (C) 2008, Nokia (urho konttori nokia com)
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
#include "tracker-test-helpers.h"
gboolean
@@ -21,3 +40,29 @@
return FALSE;
}
}
+
+static gchar *nonutf8_str = NULL;
+
+const gchar *
+tracker_test_helpers_get_nonutf8 ()
+{
+ GMappedFile *file = NULL;
+
+ if (!nonutf8_str) {
+ file = g_mapped_file_new ("./non-utf8.txt", FALSE, NULL);
+ nonutf8_str = g_strdup (g_mapped_file_get_contents (file));
+ nonutf8_str [g_mapped_file_get_length (file) -1] = '\0';
+ g_mapped_file_free (file);
+ }
+
+ return nonutf8_str;
+}
+
+void
+tracker_test_helpers_free_nonutf8 ()
+{
+ if (nonutf8_str) {
+ g_free (nonutf8_str);
+ nonutf8_str = NULL;
+ }
+}
Modified: branches/xesam-support/tests/common/tracker-test-helpers.h
==============================================================================
--- branches/xesam-support/tests/common/tracker-test-helpers.h (original)
+++ branches/xesam-support/tests/common/tracker-test-helpers.h Thu Jul 3 14:55:07 2008
@@ -1,9 +1,31 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+/*
+ * Copyright (C) 2008, Nokia (urho konttori nokia com)
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
#ifndef __TRACKER_TEST_HELPERS_H__
#define __TRACKER_TEST_HELPERS_H__
#include <glib.h>
-gboolean tracker_test_helpers_cmpstr_equal (const gchar *obtained,
- const gchar *expected);
+gboolean tracker_test_helpers_cmpstr_equal (const gchar *obtained,
+ const gchar *expected);
+const gchar *tracker_test_helpers_get_nonutf8 ();
+void tracker_test_helpers_free_nonutf8 ();
+
#endif
Modified: branches/xesam-support/tests/libtracker-common/Makefile.am
==============================================================================
--- branches/xesam-support/tests/libtracker-common/Makefile.am (original)
+++ branches/xesam-support/tests/libtracker-common/Makefile.am Thu Jul 3 14:55:07 2008
@@ -2,7 +2,7 @@
noinst_PROGRAMS = $(TEST_PROGS)
-TEST_PROGS += tracker-ontology tracker-dbus tracker-type-utils
+TEST_PROGS += tracker-ontology tracker-dbus tracker-type-utils tracker-file-utils
INCLUDES = \
-g \
@@ -32,6 +32,7 @@
tracker_dbus_LDADD = \
$(top_builddir)/src/libtracker-common/libtracker-common.la \
+ $(top_builddir)/tests/common/libtracker-testcommon.la \
$(DBUS_LIBS) \
$(GMODULE_LIBS) \
$(GTHREAD_LIBS) \
@@ -46,3 +47,14 @@
$(GMODULE_LIBS) \
$(GTHREAD_LIBS) \
$(GLIB2_LIBS)
+
+tracker_file_utils_SOURCES = \
+ tracker-file-utils-test.c
+
+tracker_file_utils_LDADD = \
+ $(top_builddir)/src/libtracker-common/libtracker-common.la \
+ $(top_builddir)/tests/common/libtracker-testcommon.la \
+ $(top_builddir)/src/xdgmime/libxdgmime.la \
+ $(GMODULE_LIBS) \
+ $(GTHREAD_LIBS) \
+ $(GLIB2_LIBS)
Modified: branches/xesam-support/tests/libtracker-common/non-utf8.txt
==============================================================================
--- branches/xesam-support/tests/libtracker-common/non-utf8.txt (original)
+++ branches/xesam-support/tests/libtracker-common/non-utf8.txt Thu Jul 3 14:55:07 2008
@@ -1 +1 @@
-Non UTF-8: ä90808.
+/invalid/file/ä90808.
Modified: branches/xesam-support/tests/libtracker-common/tracker-dbus-test.c
==============================================================================
--- branches/xesam-support/tests/libtracker-common/tracker-dbus-test.c (original)
+++ branches/xesam-support/tests/libtracker-common/tracker-dbus-test.c Thu Jul 3 14:55:07 2008
@@ -1,21 +1,27 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+/*
+ * Copyright (C) 2008, Nokia (urho konttori nokia com)
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
#include <glib.h>
#include <glib/gtestutils.h>
#include <libtracker-common/tracker-dbus.h>
+#include <tracker-test-helpers.h>
-gchar * nonutf8_str = NULL;
-
-static void
-load_nonutf8_string ()
-{
- GMappedFile *file = NULL;
-
- if (!nonutf8_str) {
- file = g_mapped_file_new ("./non-utf8.txt", FALSE, NULL);
- nonutf8_str = g_strdup (g_mapped_file_get_contents (file));
- nonutf8_str [g_mapped_file_get_length (file) -1] = '\0';
- g_mapped_file_free (file);
- }
-}
static void
slist_to_strv (gboolean utf8)
@@ -29,7 +35,7 @@
if (utf8) {
input = g_slist_prepend (input, g_strdup_printf ("%d", i));
} else {
- input = g_slist_prepend (input, g_strdup (nonutf8_str));
+ input = g_slist_prepend (input, g_strdup (tracker_test_helpers_get_nonutf8 ()));
}
}
g_assert_cmpint (g_slist_length (input), ==, strings);
@@ -59,28 +65,28 @@
static void
async_queue_to_strv (gboolean utf8)
{
- GAsyncQueue *queue;
+ GQueue *queue;
gint i;
gchar **queue_as_strv;
gint strings = 5;
- queue = g_async_queue_new ();
+ queue = g_queue_new ();
for (i = 0; i < strings; i++) {
if (utf8) {
- g_async_queue_push (queue, g_strdup_printf ("%d", i));
+ g_queue_push_tail (queue, g_strdup_printf ("%d", i));
} else {
- g_async_queue_push (queue, g_strdup (nonutf8_str));
+ g_queue_push_tail (queue, g_strdup (tracker_test_helpers_get_nonutf8 ()));
}
}
- g_assert_cmpint (g_async_queue_length (queue), ==, strings);
+ g_assert_cmpint (g_queue_get_length (queue), ==, strings);
- queue_as_strv = tracker_dbus_async_queue_to_strv (queue, g_async_queue_length (queue));
+ queue_as_strv = tracker_dbus_queue_str_to_strv (queue, g_queue_get_length (queue));
g_assert_cmpint (g_strv_length (queue_as_strv), ==, (utf8 ? strings : 0));
// Queue empty by tracker_dbus_async_queue_to_strv
- g_async_queue_unref (queue);
+ g_queue_free (queue);
g_strfreev (queue_as_strv);
}
@@ -108,8 +114,6 @@
g_thread_init (NULL);
g_test_init (&argc, &argv, NULL);
- load_nonutf8_string ();
-
g_test_add_func ("/libtracker-common/tracker-dbus/slist_to_strv_ok", test_slist_to_strv);
g_test_add_func ("/libtracker-common/tracker-dbus/slist_to_strv_nonutf8", test_slist_to_strv_nonutf8);
g_test_add_func ("/libtracker-common/tracker-dbus/async_queue_to_strv_ok", test_async_queue_to_strv);
@@ -117,7 +121,7 @@
result = g_test_run ();
- g_free (nonutf8_str);
+ tracker_test_helpers_free_nonutf8 ();
return result;
}
Modified: branches/xesam-support/tests/libtracker-common/tracker-ontology-test.c
==============================================================================
--- branches/xesam-support/tests/libtracker-common/tracker-ontology-test.c (original)
+++ branches/xesam-support/tests/libtracker-common/tracker-ontology-test.c Thu Jul 3 14:55:07 2008
@@ -1,3 +1,22 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+/*
+ * Copyright (C) 2008, Nokia (urho konttori nokia com)
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
#include <libtracker-common/tracker-service.h>
#include <libtracker-common/tracker-field.h>
#include <libtracker-common/tracker-ontology.h>
Modified: branches/xesam-support/tests/libtracker-common/tracker-type-utils-test.c
==============================================================================
--- branches/xesam-support/tests/libtracker-common/tracker-type-utils-test.c (original)
+++ branches/xesam-support/tests/libtracker-common/tracker-type-utils-test.c Thu Jul 3 14:55:07 2008
@@ -1,3 +1,22 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+/*
+ * Copyright (C) 2008, Nokia (urho konttori nokia com)
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
#include <glib.h>
#include <glib/gtestutils.h>
@@ -51,38 +70,36 @@
static void
test_string_to_date ()
{
- gchar *input = "2008-06-16T23:53:10+0300";
- struct tm *original;
- time_t expected, result;
-
- original = g_new0 (struct tm, 1);
- original->tm_sec = 10;
- original->tm_min = 53;
- original->tm_hour = 23;
- original->tm_mday = 16;
- original->tm_mon = 5;
- original->tm_year = 108;
- original->tm_isdst = 1;
-
- expected = mktime (original);
-
- result = tracker_string_to_date (input);
- g_assert_cmpint (expected, ==, result);
+ GDate *expected;
+ GDate *result;
+ time_t result_time_t;
+ gchar *input = "2008-06-16T11:10:10+0600";
+
+ expected = g_date_new_dmy (16, G_DATE_JUNE, 2008);
+
+ result_time_t = tracker_string_to_date (input);
+
+ result = g_date_new ();
+ g_date_set_time_t (result, result_time_t);
+
+ g_assert_cmpint (g_date_get_year (expected), ==, g_date_get_year (result));
+ g_assert_cmpint (g_date_get_day (expected), ==, g_date_get_day (result));
+ g_assert_cmpint (g_date_get_month (expected), ==, g_date_get_month (result));
if (g_test_trap_fork (0, G_TEST_TRAP_SILENCE_STDERR)) {
- result = tracker_string_to_date (NULL);
+ result_time_t = tracker_string_to_date (NULL);
}
g_test_trap_assert_failed ();
- result = tracker_string_to_date ("");
- g_assert_cmpint (result, ==, -1);
+ result_time_t = tracker_string_to_date ("");
+ g_assert_cmpint (result_time_t, ==, -1);
- result = tracker_string_to_date ("i am not a date");
- g_assert_cmpint (result, ==, -1);
+ result_time_t = tracker_string_to_date ("i am not a date");
+ g_assert_cmpint (result_time_t, ==, -1);
/* Fails! Check the code
- result = tracker_string_to_date ("2008-06-32T04:23:10+0000");
- g_assert_cmpint (result, ==, -1);
+ result_time_t = tracker_string_to_date ("2008-06-32T04:23:10+0000");
+ g_assert_cmpint (result_time_t, ==, -1);
*/
}
@@ -105,7 +122,7 @@
input = mktime (original);
result = tracker_date_to_string (input);
- g_print ("%s", result);
+
g_assert (result != NULL && strncmp (result, "2008-06-16T23:53:10", 19) == 0);
}
Modified: branches/xesam-support/tests/libtracker-db/tracker-db-manager-common.c
==============================================================================
--- branches/xesam-support/tests/libtracker-db/tracker-db-manager-common.c (original)
+++ branches/xesam-support/tests/libtracker-db/tracker-db-manager-common.c Thu Jul 3 14:55:07 2008
@@ -1,3 +1,22 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+/*
+ * Copyright (C) 2008, Nokia (urho konttori nokia com)
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
#include "tracker-db-manager-common.h"
gboolean
Modified: branches/xesam-support/tests/libtracker-db/tracker-db-manager-common.h
==============================================================================
--- branches/xesam-support/tests/libtracker-db/tracker-db-manager-common.h (original)
+++ branches/xesam-support/tests/libtracker-db/tracker-db-manager-common.h Thu Jul 3 14:55:07 2008
@@ -1,3 +1,22 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+/*
+ * Copyright (C) 2008, Nokia (urho konttori nokia com)
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
#ifndef __TRACKER_DB_MANAGER_TEST_COMMON__
#define __TRACKER_DB_MANAGER_TEST_COMMON__
Modified: branches/xesam-support/tests/libtracker-db/tracker-db-manager-test-attach.c
==============================================================================
--- branches/xesam-support/tests/libtracker-db/tracker-db-manager-test-attach.c (original)
+++ branches/xesam-support/tests/libtracker-db/tracker-db-manager-test-attach.c Thu Jul 3 14:55:07 2008
@@ -1,3 +1,22 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+/*
+ * Copyright (C) 2008, Nokia (urho konttori nokia com)
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
#include <glib.h>
#include <glib/gtestutils.h>
@@ -20,12 +39,11 @@
if (db_manager_status == NO_INIT) {
if (must_reindex) {
- tracker_db_manager_init (TRACKER_DB_MANAGER_ATTACH_ALL |TRACKER_DB_MANAGER_FORCE_REINDEX,
+ tracker_db_manager_init (TRACKER_DB_MANAGER_FORCE_REINDEX,
&first);
db_manager_status = INIT_REINDEX;
} else {
- tracker_db_manager_init (TRACKER_DB_MANAGER_ATTACH_ALL,
- &first);
+ tracker_db_manager_init (0, &first);
db_manager_status = INIT_NO_REINDEX;
}
return;
@@ -41,14 +59,13 @@
return ;
}
- tracker_db_manager_shutdown (must_reindex);
+ tracker_db_manager_shutdown ();
if (must_reindex) {
- tracker_db_manager_init (TRACKER_DB_MANAGER_ATTACH_ALL |TRACKER_DB_MANAGER_FORCE_REINDEX,
+ tracker_db_manager_init (TRACKER_DB_MANAGER_FORCE_REINDEX,
&first);
db_manager_status = INIT_REINDEX;
} else {
- tracker_db_manager_init (TRACKER_DB_MANAGER_ATTACH_ALL,
- &first);
+ tracker_db_manager_init (0, &first);
db_manager_status = INIT_NO_REINDEX;
}
}
Modified: branches/xesam-support/tests/libtracker-db/tracker-db-manager-test-custom.c
==============================================================================
--- branches/xesam-support/tests/libtracker-db/tracker-db-manager-test-custom.c (original)
+++ branches/xesam-support/tests/libtracker-db/tracker-db-manager-test-custom.c Thu Jul 3 14:55:07 2008
@@ -1,3 +1,22 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+/*
+ * Copyright (C) 2008, Nokia (urho konttori nokia com)
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
#include <glib.h>
#include <glib/gtestutils.h>
@@ -63,7 +82,7 @@
result = g_test_run ();
/* End */
- tracker_db_manager_shutdown (TRUE);
+ tracker_db_manager_shutdown ();
return result;
}
Modified: branches/xesam-support/tests/libtracker-db/tracker-db-manager-test-unattach.c
==============================================================================
--- branches/xesam-support/tests/libtracker-db/tracker-db-manager-test-unattach.c (original)
+++ branches/xesam-support/tests/libtracker-db/tracker-db-manager-test-unattach.c Thu Jul 3 14:55:07 2008
@@ -1,3 +1,22 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+/*
+ * Copyright (C) 2008, Nokia (urho konttori nokia com)
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
#include <glib.h>
#include <glib/gtestutils.h>
@@ -85,7 +104,7 @@
result = g_test_run ();
/* End */
- tracker_db_manager_shutdown (TRUE);
+ tracker_db_manager_shutdown ();
return result;
}
Modified: branches/xesam-support/tests/libtracker-db/union-performance.c
==============================================================================
--- branches/xesam-support/tests/libtracker-db/union-performance.c (original)
+++ branches/xesam-support/tests/libtracker-db/union-performance.c Thu Jul 3 14:55:07 2008
@@ -1,3 +1,22 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+/*
+ * Copyright (C) 2008, Nokia (urho konttori nokia com)
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
#include <glib.h>
#include <glib/gtestutils.h>
@@ -14,12 +33,12 @@
GError *error = NULL;
iface = tracker_db_manager_get_db_interfaces (7, TRACKER_DB_COMMON,
- TRACKER_DB_XESAM,
- TRACKER_DB_FILE_METADATA,
- TRACKER_DB_FILE_CONTENTS,
- TRACKER_DB_EMAIL_CONTENTS,
- TRACKER_DB_EMAIL_METADATA,
- TRACKER_DB_CACHE);
+ TRACKER_DB_XESAM,
+ TRACKER_DB_FILE_METADATA,
+ TRACKER_DB_FILE_CONTENTS,
+ TRACKER_DB_EMAIL_CONTENTS,
+ TRACKER_DB_EMAIL_METADATA,
+ TRACKER_DB_CACHE);
g_assert (iface);
@@ -64,12 +83,12 @@
GError *error = NULL;
iface = tracker_db_manager_get_db_interfaces (7, TRACKER_DB_COMMON,
- TRACKER_DB_XESAM,
- TRACKER_DB_FILE_METADATA,
- TRACKER_DB_FILE_CONTENTS,
- TRACKER_DB_EMAIL_CONTENTS,
- TRACKER_DB_EMAIL_METADATA,
- TRACKER_DB_CACHE);
+ TRACKER_DB_XESAM,
+ TRACKER_DB_FILE_METADATA,
+ TRACKER_DB_FILE_CONTENTS,
+ TRACKER_DB_EMAIL_CONTENTS,
+ TRACKER_DB_EMAIL_METADATA,
+ TRACKER_DB_CACHE);
g_assert (iface);
@@ -126,7 +145,7 @@
result = g_test_run ();
/* End */
- tracker_db_manager_shutdown (TRUE);
+ tracker_db_manager_shutdown ();
return result;
}
Modified: branches/xesam-support/tests/trackerd/tracker-xesam-hit-test.h
==============================================================================
--- branches/xesam-support/tests/trackerd/tracker-xesam-hit-test.h (original)
+++ branches/xesam-support/tests/trackerd/tracker-xesam-hit-test.h Thu Jul 3 14:55:07 2008
@@ -1,3 +1,22 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+/*
+ * Copyright (C) 2008, Nokia (urho konttori nokia com)
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
#ifndef _TRACKER_XESAM_HIT_TEST_H_
#define _TRACKER_XESAM_HIT_TEST_H_
Modified: branches/xesam-support/tests/trackerd/tracker-xesam-hits-test.h
==============================================================================
--- branches/xesam-support/tests/trackerd/tracker-xesam-hits-test.h (original)
+++ branches/xesam-support/tests/trackerd/tracker-xesam-hits-test.h Thu Jul 3 14:55:07 2008
@@ -1,3 +1,22 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+/*
+ * Copyright (C) 2008, Nokia (urho konttori nokia com)
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
#ifndef _TRACKER_XESAM_HITS_TEST_H_
#define _TRACKER_XESAM_HITS_TEST_H_
Modified: branches/xesam-support/tests/trackerd/tracker-xesam-session-test.h
==============================================================================
--- branches/xesam-support/tests/trackerd/tracker-xesam-session-test.h (original)
+++ branches/xesam-support/tests/trackerd/tracker-xesam-session-test.h Thu Jul 3 14:55:07 2008
@@ -1,3 +1,22 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+/*
+ * Copyright (C) 2008, Nokia (urho konttori nokia com)
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
#ifndef _TRACKER_XESAM_SESSION_TEST_H_
#define _TRACKER_XESAM_SESSION_TEST_H_
Modified: branches/xesam-support/tests/trackerd/tracker-xesam-test.c
==============================================================================
--- branches/xesam-support/tests/trackerd/tracker-xesam-test.c (original)
+++ branches/xesam-support/tests/trackerd/tracker-xesam-test.c Thu Jul 3 14:55:07 2008
@@ -1,3 +1,22 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+/*
+ * Copyright (C) 2008, Nokia (urho konttori nokia com)
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
#include <glib.h>
#include <glib/gtestutils.h>
Modified: branches/xesam-support/tests/trackerd/tracker-xesam-test.h
==============================================================================
--- branches/xesam-support/tests/trackerd/tracker-xesam-test.h (original)
+++ branches/xesam-support/tests/trackerd/tracker-xesam-test.h Thu Jul 3 14:55:07 2008
@@ -1,3 +1,22 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+/*
+ * Copyright (C) 2008, Nokia (urho konttori nokia com)
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
#ifndef _TRACKER_XESAM_TEST_H_
#define _TRACKER_XESAM_TEST_H_
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]