tracker r1425 - in branches/indexer-split: . data data/services src/trackerd
- From: pvanhoof svn gnome org
- To: svn-commits-list gnome org
- Subject: tracker r1425 - in branches/indexer-split: . data data/services src/trackerd
- Date: Wed, 14 May 2008 12:11:22 +0100 (BST)
Author: pvanhoof
Date: Wed May 14 11:11:22 2008
New Revision: 1425
URL: http://svn.gnome.org/viewvc/tracker?rev=1425&view=rev
Log:
2008-05-14 Philip Van Hoof <pvanhoof gnome org>
* Merged xesam-support to indexer-split
-> svn merge -r 1398:1423 ../xesam-support
Added:
branches/indexer-split/data/services/xesam-convenience.metadata
- copied unchanged from r1423, /branches/xesam-support/data/services/xesam-convenience.metadata
branches/indexer-split/data/services/xesam-convenience.service
- copied unchanged from r1423, /branches/xesam-support/data/services/xesam-convenience.service
branches/indexer-split/data/services/xesam-metadata.mmapping
- copied unchanged from r1423, /branches/xesam-support/data/services/xesam-metadata.mmapping
branches/indexer-split/data/services/xesam-service.smapping
- copied unchanged from r1423, /branches/xesam-support/data/services/xesam-service.smapping
branches/indexer-split/data/services/xesam-virtual.metadata
- copied unchanged from r1423, /branches/xesam-support/data/services/xesam-virtual.metadata
branches/indexer-split/data/services/xesam.metadata
- copied unchanged from r1423, /branches/xesam-support/data/services/xesam.metadata
branches/indexer-split/data/services/xesam.service
- copied unchanged from r1423, /branches/xesam-support/data/services/xesam.service
branches/indexer-split/data/sqlite-xesam.sql
- copied unchanged from r1423, /branches/xesam-support/data/sqlite-xesam.sql
branches/indexer-split/src/trackerd/tracker-xesam-query.c
- copied unchanged from r1423, /branches/xesam-support/src/trackerd/tracker-xesam-query.c
branches/indexer-split/src/trackerd/tracker-xesam-query.h
- copied unchanged from r1423, /branches/xesam-support/src/trackerd/tracker-xesam-query.h
Modified:
branches/indexer-split/ChangeLog
branches/indexer-split/INSTALL
branches/indexer-split/data/Makefile.am
branches/indexer-split/data/services/Makefile.am
branches/indexer-split/data/sqlite-cache.sql
branches/indexer-split/data/sqlite-stored-procs.sql
branches/indexer-split/src/trackerd/Makefile.am
branches/indexer-split/src/trackerd/tracker-db-sqlite.c
branches/indexer-split/src/trackerd/tracker-db-sqlite.h
branches/indexer-split/src/trackerd/tracker-xesam-live-search.c
branches/indexer-split/src/trackerd/tracker-xesam-live-search.h
branches/indexer-split/src/trackerd/tracker-xesam-session.c
branches/indexer-split/src/trackerd/tracker-xesam.c
branches/indexer-split/src/trackerd/tracker-xesam.h
Modified: branches/indexer-split/INSTALL
==============================================================================
--- branches/indexer-split/INSTALL (original)
+++ branches/indexer-split/INSTALL Wed May 14 11:11:22 2008
@@ -1,8 +1,8 @@
Installation Instructions
*************************
-Copyright (C) 1994, 1995, 1996, 1999, 2000, 2001, 2002, 2004, 2005 Free
-Software Foundation, Inc.
+Copyright (C) 1994, 1995, 1996, 1999, 2000, 2001, 2002, 2004, 2005,
+2006 Free Software Foundation, Inc.
This file is free documentation; the Free Software Foundation gives
unlimited permission to copy, distribute and modify it.
@@ -10,7 +10,10 @@
Basic Installation
==================
-These are generic installation instructions.
+Briefly, the shell commands `./configure; make; make install' should
+configure, build, and install this package. The following
+more-detailed instructions are generic; see the `README' file for
+instructions specific to this package.
The `configure' shell script attempts to guess correct values for
various system-dependent variables used during compilation. It uses
@@ -23,9 +26,9 @@
It can also use an optional file (typically called `config.cache'
and enabled with `--cache-file=config.cache' or simply `-C') that saves
-the results of its tests to speed up reconfiguring. (Caching is
+the results of its tests to speed up reconfiguring. Caching is
disabled by default to prevent problems with accidental use of stale
-cache files.)
+cache files.
If you need to do unusual things to compile the package, please try
to figure out how `configure' could check whether to do them, and mail
@@ -35,20 +38,17 @@
may remove or edit it.
The file `configure.ac' (or `configure.in') is used to create
-`configure' by a program called `autoconf'. You only need
-`configure.ac' if you want to change it or regenerate `configure' using
-a newer version of `autoconf'.
+`configure' by a program called `autoconf'. You need `configure.ac' if
+you want to change it or regenerate `configure' using a newer version
+of `autoconf'.
The simplest way to compile this package is:
1. `cd' to the directory containing the package's source code and type
- `./configure' to configure the package for your system. If you're
- using `csh' on an old version of System V, you might need to type
- `sh ./configure' instead to prevent `csh' from trying to execute
- `configure' itself.
+ `./configure' to configure the package for your system.
- Running `configure' takes awhile. While running, it prints some
- messages telling which features it is checking for.
+ Running `configure' might take a while. While running, it prints
+ some messages telling which features it is checking for.
2. Type `make' to compile the package.
@@ -78,7 +78,7 @@
by setting variables in the command line or in the environment. Here
is an example:
- ./configure CC=c89 CFLAGS=-O2 LIBS=-lposix
+ ./configure CC=c99 CFLAGS=-g LIBS=-lposix
*Note Defining Variables::, for more details.
@@ -87,17 +87,15 @@
You can compile the package for more than one kind of computer at the
same time, by placing the object files for each architecture in their
-own directory. To do this, you must use a version of `make' that
-supports the `VPATH' variable, such as GNU `make'. `cd' to the
+own directory. To do this, you can use GNU `make'. `cd' to the
directory where you want the object files and executables to go and run
the `configure' script. `configure' automatically checks for the
source code in the directory that `configure' is in and in `..'.
- If you have to use a `make' that does not support the `VPATH'
-variable, you have to compile the package for one architecture at a
-time in the source code directory. After you have installed the
-package for one architecture, use `make distclean' before reconfiguring
-for another architecture.
+ With a non-GNU `make', it is safer to compile the package for one
+architecture at a time in the source code directory. After you have
+installed the package for one architecture, use `make distclean' before
+reconfiguring for another architecture.
Installation Names
==================
@@ -190,12 +188,12 @@
./configure CC=/usr/local2/bin/gcc
causes the specified `gcc' to be used as the C compiler (unless it is
-overridden in the site shell script). Here is a another example:
+overridden in the site shell script).
- /bin/bash ./configure CONFIG_SHELL=/bin/bash
+Unfortunately, this technique does not work for `CONFIG_SHELL' due to
+an Autoconf bug. Until the bug is fixed you can use this workaround:
-Here the `CONFIG_SHELL=/bin/bash' operand causes subsequent
-configuration-related scripts to be executed by `/bin/bash'.
+ CONFIG_SHELL=/bin/bash /bin/bash ./configure CONFIG_SHELL=/bin/bash
`configure' Invocation
======================
Modified: branches/indexer-split/data/Makefile.am
==============================================================================
--- branches/indexer-split/data/Makefile.am (original)
+++ branches/indexer-split/data/Makefile.am Wed May 14 11:11:22 2008
@@ -20,7 +20,8 @@
sqlite-stored-procs.sql \
sqlite-service.sql \
sqlite-service-types.sql \
- sqlite-metadata.sql
+ sqlite-metadata.sql \
+ sqlite-xesam.sql
servicedir = $(DBUS_SERVICES_DIR)
service_in_files = tracker.service.in
Modified: branches/indexer-split/data/services/Makefile.am
==============================================================================
--- branches/indexer-split/data/services/Makefile.am (original)
+++ branches/indexer-split/data/services/Makefile.am Wed May 14 11:11:22 2008
@@ -8,6 +8,13 @@
file.metadata \
image.metadata \
video.metadata \
- default.service
+ default.service \
+ xesam-convenience.metadata \
+ xesam-convenience.service \
+ xesam.metadata \
+ xesam.service \
+ xesam-virtual.metadata \
+ xesam-service.smapping \
+ xesam-metadata.mmapping
EXTRA_DIST = $(config_DATA)
Modified: branches/indexer-split/data/sqlite-cache.sql
==============================================================================
--- branches/indexer-split/data/sqlite-cache.sql (original)
+++ branches/indexer-split/data/sqlite-cache.sql Wed May 14 11:11:22 2008
@@ -76,7 +76,7 @@
EventType Text
);
-CREATE TABLE XesamLiveSearches
+CREATE TABLE LiveSearches
(
ID Integer primary key not null,
ServiceID Integer not null,
Modified: branches/indexer-split/data/sqlite-stored-procs.sql
==============================================================================
--- branches/indexer-split/data/sqlite-stored-procs.sql (original)
+++ branches/indexer-split/data/sqlite-stored-procs.sql Wed May 14 11:11:22 2008
@@ -29,8 +29,9 @@
GetEvents SELECT ID, ServiceID, EventType FROM Events WHERE BeingHandled = 1;
SetEventsBeingHandled UPDATE Events SET BeingHandled = 1;
-GetLiveSearchModifiedIDs SELECT E.ServiceID FROM Events as E, LiveSearches as X WHERE E.ServiceID = X.ServiceID AND X.SearchID = ? AND E.EventType IS NOT 'Create';
+GetLiveSearchDeletedIDs SELECT E.ServiceID FROM Events as E, LiveSearches as X WHERE E.ServiceID = X.ServiceID AND X.SearchID = ? AND E.EventType IS 'Delete';
GetLiveSearchHitCount SELECT count(*) FROM LiveSearches WHERE SearchID = ?;
+LiveSearchStopSearch DELETE FROM LiveSearches as X WHERE E.SearchID = ?
GetNewEventID SELECT OptionValue FROM Options WHERE OptionKey = 'EventSequence';
UpdateNewEventID UPDATE Options set OptionValue = ? WHERE OptionKey = 'EventSequence';
@@ -190,3 +191,19 @@
UpdateHitDetails Update HitIndex set HitCount = ?, HitArraySize = ? where ROWID = ?;
ResizeHitDetails Update HitIndex set HitCount = ?, HitArraySize = ?, HitArray = Zeroblob(?) where ROWID = ?;
+InsertXesamMetadataType INSERT INTO XesamMetaDataTypes (MetaName) Values (?);
+InsertXesamServiceType INSERT INTO XesamServiceTypes (TypeName) Values (?);
+InsertXesamMetaDataMapping INSERT INTO XesamMetaDataMapping (XesamMetaName, MetaName) Values (?, ?);
+InsertXesamServiceMapping INSERT INTO XesamServiceMapping (XesamTypeName, TypeName) Values (?, ?);
+InsertXesamServiceLookup REPLACE INTO XesamServiceLookup (XesamTypeName, TypeName) Values (?, ?);
+InsertXesamMetaDataLookup REPLACE INTO XesamMetaDataLookup (XesamMetaName, MetaName) Values (?, ?);
+
+GetXesamServiceTypes SELECT TypeName, Parents FROM XesamServiceTypes;
+GetXesamServiceChildren SELECT Child FROM XesamServiceChildren WHERE Parent = ?;
+GetXesamServiceMappings SELECT TypeName FROM XesamServiceMapping WHERE XesamTypeName = ?;
+GetXesamServiceLookups SELECT DISTINCT TypeName FROM XesamServiceLookup WHERE XesamTypeName = ?;
+
+GetXesamMetaDataTypes SELECT MetaName, Parents FROM XesamMetaDataTypes;
+GetXesamMetaDataChildren SELECT Child FROM XesamMetaDataChildren WHERE Parent = ?;
+GetXesamMetaDataMappings SELECT MetaName FROM XesamMetaDataMapping WHERE XesamMetaName = ?;
+GetXesamMetaDataLookups SELECT DISTINCT MetaName FROM XesamMetaDataLookup WHERE XesamMetaName = ?;
Modified: branches/indexer-split/src/trackerd/Makefile.am
==============================================================================
--- branches/indexer-split/src/trackerd/Makefile.am (original)
+++ branches/indexer-split/src/trackerd/Makefile.am Wed May 14 11:11:22 2008
@@ -132,6 +132,8 @@
tracker-status.h \
tracker-xesam.h \
tracker-xesam.c \
+ tracker-xesam-query.c \
+ tracker-xesam-query.h \
tracker-xesam-session.c \
tracker-xesam-session.h \
tracker-xesam-live-search.c \
Modified: branches/indexer-split/src/trackerd/tracker-db-sqlite.c
==============================================================================
--- branches/indexer-split/src/trackerd/tracker-db-sqlite.c (original)
+++ branches/indexer-split/src/trackerd/tracker-db-sqlite.c Wed May 14 11:11:22 2008
@@ -438,7 +438,7 @@
gchar **groups, **keys;
gchar **group, **key;
TrackerService *service;
- gint id;
+ gint id;
service_file = tracker_db_manager_get_service_file (filename);
@@ -1123,7 +1123,19 @@
load_service_description_file (db_con->db, "email.metadata");
load_service_description_file (db_con->db, "image.metadata");
load_service_description_file (db_con->db, "video.metadata");
-
+
+ load_sql_file (db_con->db, "sqlite-xesam.sql");
+
+ tracker_db_load_xesam_service_file (db_con, "xesam.metadata");
+ tracker_db_load_xesam_service_file (db_con, "xesam-convenience.metadata");
+ tracker_db_load_xesam_service_file (db_con, "xesam-virtual.metadata");
+ tracker_db_load_xesam_service_file (db_con, "xesam.service");
+ tracker_db_load_xesam_service_file (db_con, "xesam-convenience.service");
+ tracker_db_load_xesam_service_file (db_con, "xesam-service.smapping");
+ tracker_db_load_xesam_service_file (db_con, "xesam-metadata.mmapping");
+
+ tracker_db_create_xesam_lookup(db_con);
+
tracker_db_exec_no_reply (db_con->db, "ANALYZE");
}
@@ -1135,6 +1147,9 @@
tracker_db_attach_db (db_con, TRACKER_DB_COMMON);
tracker_db_attach_db (db_con, TRACKER_DB_CACHE);
+ /* this is not needed, it's the root db
+ tracker_db_attach_db (db_con, TRACKER_DB_FILE_META); */
+
db_con->cache = db_con;
db_con->common = db_con;
@@ -1389,6 +1404,24 @@
return TRUE;
}
+
+TrackerDBResultSet *
+tracker_db_exec (TrackerDBInterface *iface, const char *query, ...)
+{
+ va_list args;
+ TrackerDBResultSet *result_set;
+
+ tracker_nfs_lock_obtain ();
+
+ va_start (args, query);
+ result_set = tracker_db_interface_execute_vquery (iface, NULL, query, args);
+ va_end (args);
+
+ tracker_nfs_lock_release ();
+
+ return result_set;
+}
+
TrackerDBResultSet *
tracker_exec_proc (DBConnection *db_con, const char *procedure, ...)
{
@@ -1457,6 +1490,18 @@
load_service_description_file (db_con->db, "default.service");
+ load_sql_file (db_con->db, "sqlite-xesam.sql");
+
+ tracker_db_load_xesam_service_file (db_con, "xesam.metadata");
+ tracker_db_load_xesam_service_file (db_con, "xesam-convenience.metadata");
+ tracker_db_load_xesam_service_file (db_con, "xesam-virtual.metadata");
+ tracker_db_load_xesam_service_file (db_con, "xesam.service");
+ tracker_db_load_xesam_service_file (db_con, "xesam-convenience.service");
+ tracker_db_load_xesam_service_file (db_con, "xesam-service.smapping");
+ tracker_db_load_xesam_service_file (db_con, "xesam-metadata.mmapping");
+
+ tracker_db_create_xesam_lookup(db_con);
+
tracker_db_exec_no_reply (db_con->db, "ANALYZE");
tracker_db_close (db_con->db);
@@ -2289,6 +2334,28 @@
return NULL;
}
+
+TrackerDBResultSet *
+tracker_get_xesam_metadata_names (DBConnection *db_con, const char *name)
+{
+ TrackerDBResultSet *result_set;
+
+ result_set = tracker_exec_proc (db_con, "GetXesamMetaDataLookups", name, NULL);
+
+ return result_set;
+}
+
+TrackerDBResultSet *
+tracker_get_xesam_service_names (DBConnection *db_con, const char *name)
+{
+ TrackerDBResultSet *result_set;
+
+ result_set = tracker_exec_proc (db_con, "GetXesamServiceLookups", name, NULL);
+
+ return result_set;
+}
+
+
char *
tracker_get_metadata_table (DataTypes type)
{
@@ -3197,108 +3264,123 @@
}
-GStaticRecMutex events_table_lock = G_STATIC_REC_MUTEX_INIT;
-
TrackerDBResultSet*
tracker_db_get_live_search_hit_count (DBConnection *db_con, const gchar *search_id)
{
- TrackerDBResultSet *result;
tracker_debug ("GetLiveSearchHitCount");
- result = tracker_exec_proc (db_con->cache, "GetLiveSearchHitCount", search_id, NULL);
- return result;
+
+ /* SELECT count(*)
+ * FROM LiveSearches
+ * WHERE SearchID = ? */
+
+ return tracker_exec_proc (db_con->cache, "GetLiveSearchHitCount", search_id, NULL);
}
TrackerDBResultSet*
-tracker_db_get_live_search_modified_ids (DBConnection *db_con, const gchar *search_id)
+tracker_db_get_live_search_deleted_ids (DBConnection *db_con, const gchar *search_id)
{
- TrackerDBResultSet *result;
+ tracker_debug ("GetLiveSearchDeletedIDs");
- /* This happens in the GMainLoop */
- g_static_rec_mutex_lock (&events_table_lock);
+ /* SELECT E.ServiceID
+ * FROM Events as E, LiveSearches as X
+ * WHERE E.ServiceID = X.ServiceID
+ * AND X.SearchID = ?
+ * AND E.EventType IS 'Delete' */
- /* Uses the Events table */
- tracker_debug ("GetLiveSearchModifiedIDs");
+ return tracker_exec_proc (db_con->cache, "GetLiveSearchDeletedIDs", search_id, NULL);
+}
- result = tracker_exec_proc (db_con->cache, "GetLiveSearchModifiedIDs", search_id, NULL);
+void
+tracker_db_stop_live_search (DBConnection *db_con, const gchar *search_id)
+{
+ tracker_debug ("LiveSearchStopSearch");
- g_static_rec_mutex_unlock (&events_table_lock);
+ /* DELETE
+ * FROM LiveSearches as X
+ * WHERE E.SearchID = ? */
- return result;
+ tracker_exec_proc_no_reply (db_con->cache->db, "LiveSearchStopSearch", search_id, NULL);
}
-TrackerDBResultSet*
-tracker_db_get_live_search_new_ids (DBConnection *db_con, const gchar *search_id, const gchar *columns, const gchar *tables, const gchar *query)
+void
+tracker_db_start_live_search (DBConnection *db_con, const gchar *from_query, const gchar *where_query, const gchar *search_id)
{
- TrackerDBResultSet *result;
-
- /* This happens in the GMainLoop */
- g_static_rec_mutex_lock (&events_table_lock);
+ /* INSERT
+ * INTO LiveSearches
+ * SELECT ID, SEARCH_ID FROM_QUERY WHERE_QUERY */
+
+ tracker_db_exec_no_reply (db_con->db, NULL,
+ "INSERT INTO LiveSearches SELECT ID, '%s' %s %s",
+ search_id, from_query, where_query);
+}
+TrackerDBResultSet*
+tracker_db_get_live_search_new_ids (DBConnection *db_con, const gchar *search_id, const gchar *columns, const gchar *from_query, const gchar *where_query)
+{
// todo: this is a query for ottela to review
- // Contract, in @result:
- // ServiceID is #1
- // EventType is #2
-
- /* Uses the Events table */
- gchar *m_query = g_strdup_printf (
- "SELECT E.ServiceID, E.EventType%s %s "
- "FROM XesamLiveSearches as X, Events as E%s %s "
- "X.ServiceID = E.ServiceID "
- "AND X.SearchID = ? "
- "AND X.EventType IS 'Create' OR X.EventType IS 'Update' "
- "%s%s%s",
- columns?",":"", columns,
- tables?",":"", tables,
- query?"AND (":"", query, query?")":"");
-
- tracker_debug ("LiveSearchUpdateQuery: %s", m_query);
-
- result = tracker_db_interface_execute_query (db_con->common->db, NULL, m_query);
-
- g_static_rec_mutex_unlock (&events_table_lock);
+ /* Contract, in @result:
+ * ServiceID is #1
+ * EventType is #2 */
+
+ /**
+ * SELECT E.ServiceID, E.EventType, COLUMNS
+ * FROM_QUERY XesamLiveSearches as X, Events as E
+ * WHERE_QUERY"
+ * AND X.ServiceID = E.ServiceID
+ * AND X.SearchID = SEARCH_ID
+ * AND (X.EventType IS 'Create'
+ * OR X.EventType IS 'Update')
+ **/
+
+ tracker_debug ("LiveSearchUpdateQuery");
+
+ return tracker_db_exec (db_con->db,
+ /* COLUMNS */ "SELECT E.ServiceID, E.EventType%s%s "
+ /* FROM_QUERY */ "%s%s LiveSearches as X, Events as E "
+ /* WHERE_QUERY */ "%s"
+ /* AND or space */ "%sX.ServiceID = E.ServiceID "
+ "AND X.SearchID = '%s' " /* search_id arg */
+ "AND (X.EventType IS 'Create' "
+ "OR X.EventType IS 'Update') ",
+
+ columns?", ":"",
+ columns?columns:"",
+ from_query?from_query:"FROM",
+ from_query?",":"",
+ where_query?where_query:"WHERE",
+ where_query?"AND":" ",
+ search_id);
+}
- g_free (m_query);
+TrackerDBResultSet *
+tracker_db_get_live_search_get_hit_data (DBConnection *db_con, const gchar *search_id)
+{
+ tracker_debug ("tracker_db_get_live_search_get_hit_data");
- return result;
+ return tracker_db_exec (db_con->db,
+ "SELECT * FROM LiveSearches as X "
+ "WHERE X.SearchID = '%s'",
+ search_id);
}
TrackerDBResultSet*
tracker_db_get_events (DBConnection *db_con)
{
- TrackerDBResultSet *result;
-
- /* This happens in the GMainLoop */
- g_static_rec_mutex_lock (&events_table_lock);
- /* Uses the Events table */
tracker_debug ("SetEventsBeingHandled");
tracker_exec_proc_no_reply (db_con->cache->db, "SetEventsBeingHandled", NULL);
tracker_debug ("GetEvents");
- result = tracker_exec_proc (db_con->cache, "GetEvents", NULL);
- g_static_rec_mutex_unlock (&events_table_lock);
- return result;
+ return tracker_exec_proc (db_con->cache, "GetEvents", NULL);
}
void
tracker_db_delete_handled_events (DBConnection *db_con, TrackerDBResultSet *events)
{
- TrackerDBResultSet *result_set;
-
- /* This happens in the GMainLoop */
- g_static_rec_mutex_lock (&events_table_lock);
-
- /* Uses the Events table */
tracker_debug ("DeleteHandledEvents");
-
- result_set = tracker_exec_proc (db_con->cache, "DeleteHandledEvents", NULL);
- if (result_set)
- g_object_unref (result_set);
-
- g_static_rec_mutex_unlock (&events_table_lock);
-
+ tracker_exec_proc_no_reply (db_con->cache->db, "DeleteHandledEvents", NULL);
}
static guint32
@@ -3309,14 +3391,10 @@
int i;
guint32 id = 0;
- /* This happens in the indexer's thread */
- g_static_rec_mutex_lock (&events_table_lock);
-
result_set = tracker_exec_proc (db_con->common, "GetNewEventID", NULL);
if (!result_set) {
tracker_error ("ERROR: could not create event - GetNewEventID failed");
- g_static_rec_mutex_unlock (&events_table_lock);
return 0;
}
@@ -3342,8 +3420,6 @@
g_free (eid);
- g_static_rec_mutex_unlock (&events_table_lock);
-
return id;
}
@@ -3360,11 +3436,8 @@
int service_type_id;
char *str_service_type_id, *path, *name;
- g_static_rec_mutex_lock (&events_table_lock);
-
if (!info || !info->uri || !info->uri[0] || !service || !db_con) {
tracker_error ("ERROR: cannot create service");
- g_static_rec_mutex_unlock (&events_table_lock);
return 0;
}
@@ -3384,7 +3457,6 @@
if (!result_set) {
tracker_error ("ERROR: could not create service - GetNewID failed");
- g_static_rec_mutex_unlock (&events_table_lock);
return 0;
}
@@ -3489,8 +3561,6 @@
g_free (str_mtime);
g_free (str_offset);
- g_static_rec_mutex_unlock (&events_table_lock);
-
return id;
}
@@ -4941,6 +5011,362 @@
}
+// FIXME Do this in a non-retarded way
+
+gboolean
+get_service_mapping(DBConnection *db_con, const char *type, GList **list)
+{
+ TrackerDBResultSet *result_set;
+ gboolean valid = TRUE;
+
+ result_set = tracker_exec_proc (db_con, "GetXesamServiceMappings", type, NULL);
+
+ if (result_set) {
+ while (valid) {
+ gchar *st;
+
+ tracker_db_result_set_get (result_set, 0, &st, -1);
+ if (strcmp(st, " ") != 0) {
+ *list = g_list_append (*list,g_strdup (st));
+ }
+
+ valid = tracker_db_result_set_iter_next (result_set);
+ g_free (st);
+ }
+
+ g_object_unref (result_set);
+ }
+
+ result_set = tracker_exec_proc (db_con, "GetXesamServiceChildren", type, NULL);
+ valid = TRUE;
+
+ if (result_set) {
+ while (valid) {
+ gchar *st;
+
+ tracker_db_result_set_get (result_set, 0, &st, -1);
+ get_service_mapping(db_con, st ,list);
+
+ valid = tracker_db_result_set_iter_next (result_set);
+ g_free (st);
+ }
+
+ g_object_unref (result_set);
+ }
+
+ return TRUE;
+}
+
+gboolean
+get_metadata_mapping(DBConnection *db_con, const char *type, GList **list)
+{
+ TrackerDBResultSet *result_set;
+ gboolean valid = TRUE;
+
+ result_set = tracker_exec_proc (db_con, "GetXesamMetaDataMappings", type, NULL);
+
+ if (result_set) {
+ while (valid) {
+ gchar *st;
+
+ tracker_db_result_set_get (result_set, 0, &st, -1);
+ if (strcmp(st, " ") != 0) {
+ *list = g_list_append (*list,g_strdup (st));
+ }
+
+ valid = tracker_db_result_set_iter_next (result_set);
+ g_free (st);
+ }
+
+ g_object_unref (result_set);
+ }
+
+ result_set = tracker_exec_proc (db_con, "GetXesamMetaDataChildren", type, NULL);
+ valid = TRUE;
+
+ if (result_set) {
+ while (valid) {
+ gchar *st;
+
+ tracker_db_result_set_get (result_set, 0, &st, -1);
+ get_service_mapping(db_con, st ,list);
+
+ valid = tracker_db_result_set_iter_next (result_set);
+ g_free (st);
+ }
+
+ g_object_unref (result_set);
+ }
+
+ return TRUE;
+}
+
+
+gboolean
+tracker_db_create_xesam_lookup (DBConnection *db_con)
+{
+ TrackerDBResultSet *result_set;
+ gboolean valid = TRUE;
+
+ result_set = tracker_exec_proc (db_con, "GetXesamServiceTypes", NULL);
+
+ if (result_set) {
+ while (valid) {
+ gchar *st;
+ GList *list = NULL;
+ GList *iter = NULL;
+
+ tracker_db_result_set_get (result_set, 0, &st, -1);
+ get_service_mapping(db_con, st, &list);
+
+ iter = g_list_first(list);
+ while (iter) {
+ tracker_exec_proc (db_con, "InsertXesamServiceLookup", st, iter->data, NULL);
+ g_free(iter->data);
+
+ iter = g_list_next (iter);
+ }
+
+ g_list_free (list);
+
+ valid = tracker_db_result_set_iter_next (result_set);
+ g_free (st);
+ }
+ }
+
+ g_object_unref (result_set);
+ valid = TRUE;
+
+ result_set = tracker_exec_proc (db_con, "GetXesamMetaDataTypes", NULL);
+
+ if (result_set) {
+ while (valid) {
+ gchar *st;
+ GList *list = NULL;
+ GList *iter = NULL;
+
+ tracker_db_result_set_get (result_set, 0, &st, -1);
+ get_metadata_mapping(db_con, st, &list);
+
+ iter = g_list_first(list);
+ while (iter) {
+ tracker_exec_proc (db_con, "InsertXesamMetaDataLookup", st, iter->data, NULL);
+ g_free(iter->data);
+
+ iter = g_list_next (iter);
+ }
+
+ g_list_free (list);
+
+ valid = tracker_db_result_set_iter_next (result_set);
+ g_free (st);
+ }
+ }
+
+ g_object_unref (result_set);
+
+ return TRUE;
+}
+
+gboolean
+tracker_db_load_xesam_service_file (DBConnection *db_con, const char *filename)
+{
+ GKeyFile *key_file = NULL;
+ const char * const *locale_array;
+ char *service_file, *sql;
+ gboolean is_metadata = FALSE, is_service = FALSE, is_metadata_mapping = FALSE, is_service_mapping = FALSE;
+ int id;
+
+ char *DataTypeArray[11] = {"string", "float", "integer", "boolean", "dateTime", "List of strings", "List of Uris", "List of Urls", NULL};
+
+ service_file = tracker_db_manager_get_service_file (filename);
+
+ locale_array = g_get_language_names ();
+
+ key_file = g_key_file_new ();
+
+ if (g_key_file_load_from_file (key_file, service_file, G_KEY_FILE_NONE, NULL)) {
+
+ if (g_str_has_suffix (filename, ".metadata")) {
+ is_metadata = TRUE;
+ } else if (g_str_has_suffix (filename, ".service")) {
+ is_service = TRUE;
+ } else if (g_str_has_suffix (filename, ".mmapping")) {
+ is_metadata_mapping = TRUE;
+ } else if (g_str_has_suffix (filename, ".smapping")) {
+ is_service_mapping = TRUE;
+ } else {
+ g_key_file_free (key_file);
+ g_free (service_file);
+ return FALSE;
+ }
+
+
+ char **groups = g_key_file_get_groups (key_file, NULL);
+ char **array;
+
+ for (array = groups; *array; array++) {
+ if (is_metadata) {
+
+ tracker_exec_proc (db_con, "InsertXesamMetadataType", *array, NULL);
+ id = tracker_db_interface_sqlite_get_last_insert_id (TRACKER_DB_INTERFACE_SQLITE (db_con->db));
+
+
+ } else if (is_service) {
+
+ tracker_exec_proc (db_con, "InsertXesamServiceType", *array, NULL);
+ id = tracker_db_interface_sqlite_get_last_insert_id (TRACKER_DB_INTERFACE_SQLITE (db_con->db));
+
+ } else {
+ /* Nothing required */
+ }
+
+ /* get inserted ID */
+
+ char *str_id = tracker_uint_to_string (id);
+
+ char **keys = g_key_file_get_keys (key_file, *array, NULL, NULL);
+ char **array2;
+
+ for (array2 = keys; *array2; array2++) {
+
+ char *value = g_key_file_get_locale_string (key_file, *array, *array2, locale_array[0], NULL);
+
+ if (value) {
+
+ if (strcasecmp (value, "true") == 0) {
+
+ g_free (value);
+ value = g_strdup ("1");
+
+ } else if (strcasecmp (value, "false") == 0) {
+
+ g_free (value);
+ value = g_strdup ("0");
+ }
+
+ if (is_metadata) {
+
+ if (strcasecmp (*array2, "Parents") == 0) {
+
+ char **parents, **parents_p ;
+
+ parents = g_strsplit_set (value, ";", -1);
+
+ if (parents) {
+ for (parents_p = parents; *parents_p; parents_p++) {
+ sql = g_strdup_printf ("INSERT INTO XesamMetadataChildren (Parent, Child) VALUES ('%s', '%s')", *parents_p, *array);
+ tracker_db_exec_no_reply (db_con->db, sql);
+
+ g_free(sql);
+ }
+ }
+
+ } else if (strcasecmp (*array2, "ValueType") == 0) {
+
+ int data_id = tracker_string_in_string_list (value, DataTypeArray);
+
+ if (data_id != -1) {
+ sql = g_strdup_printf ("update XesamMetadataTypes set DataTypeID = %d where ID = %s", data_id, str_id);
+ tracker_db_exec_no_reply (db_con->db, sql);
+ g_free (sql);
+
+ }
+
+
+ } else {
+ char *esc_value = tracker_escape_string (value);
+
+ sql = g_strdup_printf ("update XesamMetadataTypes set %s = '%s' where ID = %s", *array2, esc_value, str_id);
+
+ tracker_db_exec_no_reply (db_con->db, sql);
+ g_free (sql);
+ g_free (esc_value);
+ }
+
+ } else if (is_service) {
+ if (strcasecmp (*array2, "Parents") == 0) {
+
+ char **parents, **parents_p ;
+
+ parents = g_strsplit_set (value, ";", -1);
+
+ if (parents) {
+ for (parents_p = parents; *parents_p; parents_p++) {
+ sql = g_strdup_printf ("INSERT INTO XesamServiceChildren (Parent, Child) VALUES ('%s', '%s')", *parents_p, *array);
+ tracker_db_exec_no_reply (db_con->db, sql);
+
+ g_free(sql);
+ }
+ }
+ } else {
+ char *esc_value = tracker_escape_string (value);
+ sql = g_strdup_printf ("update XesamServiceTypes set %s = '%s' where typeID = %s", *array2, esc_value, str_id);
+ tracker_db_exec_no_reply (db_con->db, sql);
+ g_free (sql);
+ g_free (esc_value);
+ }
+
+ } else if (is_metadata_mapping) {
+ char **mappings, **mappings_p ;
+
+ mappings = g_strsplit_set (value, ";", -1);
+
+ if (mappings) {
+ for (mappings_p = mappings; *mappings_p; mappings_p++) {
+ char *esc_value = tracker_escape_string (*mappings_p);
+ tracker_exec_proc (db_con, "InsertXesamMetaDataMapping", *array, esc_value, NULL);
+ g_free (esc_value);
+ }
+ }
+
+ } else {
+ char **mappings, **mappings_p ;
+
+ mappings = g_strsplit_set (value, ";", -1);
+
+ if (mappings) {
+ for (mappings_p = mappings; *mappings_p; mappings_p++) {
+ char *esc_value = tracker_escape_string (*mappings_p);
+ tracker_exec_proc (db_con, "InsertXesamServiceMapping", *array, esc_value, NULL);
+ g_free (esc_value);
+ }
+ }
+
+ }
+
+ g_free (value);
+
+ }
+ }
+
+ if (keys) {
+ g_strfreev (keys);
+ }
+
+ g_free (str_id);
+
+ }
+
+
+ if (groups) {
+ g_strfreev (groups);
+ }
+
+
+ g_key_file_free (key_file);
+
+ } else {
+ g_key_file_free (key_file);
+ return FALSE;
+ }
+
+ g_free (service_file);
+
+ return TRUE;
+}
+
+
FieldData *
tracker_db_get_metadata_field (DBConnection *db_con, const char *service, const char *field_name, int field_count, gboolean is_select, gboolean is_condition)
{
Modified: branches/indexer-split/src/trackerd/tracker-db-sqlite.h
==============================================================================
--- branches/indexer-split/src/trackerd/tracker-db-sqlite.h (original)
+++ branches/indexer-split/src/trackerd/tracker-db-sqlite.h Wed May 14 11:11:22 2008
@@ -124,6 +124,9 @@
gboolean tracker_db_exec_no_reply (TrackerDBInterface *iface,
const gchar *query,
...);
+TrackerDBResultSet *tracker_db_exec (TrackerDBInterface *iface,
+ const char *query,
+ ...);
gboolean tracker_db_is_in_transaction (DBConnection *db_con);
gchar * tracker_db_get_option_string (DBConnection *db_con,
@@ -359,7 +362,7 @@
TrackerDBResultSet *tracker_db_get_events (DBConnection *db_con);
void tracker_db_delete_handled_events (DBConnection *db_con,
TrackerDBResultSet *events);
-TrackerDBResultSet *tracker_db_get_live_search_modified_ids (DBConnection *db_con,
+TrackerDBResultSet *tracker_db_get_live_search_deleted_ids (DBConnection *db_con,
const gchar *search_id);
TrackerDBResultSet *tracker_db_get_live_search_new_ids (DBConnection *db_con,
const gchar *search_id,
@@ -370,6 +373,23 @@
const gchar *search_id);
+TrackerDBResultSet *tracker_get_xesam_metadata_names (DBConnection *db_con,
+ const char *name);
+TrackerDBResultSet *tracker_get_xesam_service_names (DBConnection *db_con,
+ const char *name);
+
+gboolean tracker_db_load_xesam_service_file (DBConnection *db_con,
+ const char *filename);
+gboolean tracker_db_create_xesam_lookup (DBConnection *db_con);
+void tracker_db_stop_live_search (DBConnection *db_con,
+ const gchar *search_id);
+void tracker_db_start_live_search (DBConnection *db_con,
+ const gchar *from_query,
+ const gchar *where_query,
+ const gchar *search_id);
+TrackerDBResultSet *tracker_db_get_live_search_get_hit_data (DBConnection *db_con,
+ const gchar *search_id);
+
G_END_DECLS
#endif /* __TRACKERD_DB_SQLITE_H__ */
Modified: branches/indexer-split/src/trackerd/tracker-xesam-live-search.c
==============================================================================
--- branches/indexer-split/src/trackerd/tracker-xesam-live-search.c (original)
+++ branches/indexer-split/src/trackerd/tracker-xesam-live-search.c Wed May 14 11:11:22 2008
@@ -15,8 +15,7 @@
*
* 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.
+ * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * Boston, MA 02110-1301, USA.
*/
#include <string.h>
@@ -25,13 +24,15 @@
#include "tracker-dbus-xesam.h"
#include "tracker-dbus.h"
#include "tracker-xesam.h"
+#include "tracker-xesam-query.h"
struct _TrackerXesamLiveSearchPriv {
- TrackerXesamSession *session;
gchar *search_id;
+ TrackerXesamSession *session;
gboolean active;
gboolean closed;
gchar *query;
+ gchar *from_sql, *where_sql;
};
enum {
@@ -41,7 +42,7 @@
G_DEFINE_TYPE (TrackerXesamLiveSearch, tracker_xesam_live_search, G_TYPE_OBJECT)
-#define GET_PRIV(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), TRACKER_TYPE_XESAM_LIVE_SEARCH, TrackerXesamLiveSearch))
+#define GET_PRIV(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), TRACKER_TYPE_XESAM_LIVE_SEARCH, struct _TrackerXesamLiveSearchPriv))
static void
tracker_xesam_live_search_finalize (GObject *object)
@@ -52,6 +53,11 @@
g_object_unref (priv->session);
g_free (priv->search_id);
g_free (priv->query);
+ g_free (priv->from_sql);
+ g_free (priv->where_sql);
+
+ if (priv->session)
+ g_object_unref (priv->session);
}
void
@@ -70,15 +76,11 @@
TrackerXesamLiveSearchPriv *priv = self->priv;
g_free (priv->query);
-
- // ottela, look!
- // TODO: parse XML query into SQL query here
-
priv->query = g_strdup (query);
}
static void
-xexam_search_set_property (GObject *object,
+xesam_search_set_property (GObject *object,
guint param_id,
const GValue *value,
GParamSpec *pspec)
@@ -100,7 +102,7 @@
{
GObjectClass *object_class;
object_class = G_OBJECT_CLASS (klass);
- object_class->set_property = xexam_search_set_property;
+ object_class->set_property = xesam_search_set_property;
g_object_class_install_property (object_class,
PROP_XMLQUERY,
@@ -110,17 +112,27 @@
G_PARAM_WRITABLE));
object_class->finalize = tracker_xesam_live_search_finalize;
+ g_type_class_add_private( klass, sizeof(struct _TrackerXesamLiveSearchPriv) );
+
}
static void
tracker_xesam_live_search_init (TrackerXesamLiveSearch *self)
{
- TrackerXesamLiveSearchPriv *priv = self->priv;
+ TrackerXesamLiveSearchPriv *priv;
+
+ priv = self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self,TRACKER_TYPE_XESAM_LIVE_SEARCH,struct _TrackerXesamLiveSearchPriv);
+
priv->session = NULL;
priv->search_id = NULL;
+ priv->session = NULL;
+
priv->active = FALSE;
priv->closed = FALSE;
- priv->query = g_strdup ("1=1");
+ priv->query = NULL;
+ priv->from_sql = g_strdup ("");
+ priv->where_sql = g_strdup ("");
+
}
/**
@@ -220,66 +232,43 @@
g_object_get (proxy, "db-connection", &db_con, NULL);
- result_set = tracker_db_get_live_search_modified_ids (db_con,
+ /* Deleted items */
+
+ result_set = tracker_db_get_live_search_deleted_ids (db_con,
tracker_xesam_live_search_get_id (self));
if (!result_set)
- return;
+ goto part_two;
while (ls_valid) {
GValue ls_value = { 0, };
- gboolean ev_valid = TRUE;
+ gint ls_i_value;
_tracker_db_result_set_get_value (result_set, 0, &ls_value);
+ ls_i_value = g_value_get_int (&ls_value);
- while (ev_valid) {
- GValue ev_value = { 0, };
- gint ev_i_value;
-
- _tracker_db_result_set_get_value (result_set, 1, &ev_value);
-
- ev_i_value = g_value_get_int (&ev_value);
-
- if (ev_i_value == g_value_get_int (&ls_value)) {
- GValue ev_type = { 0, };
- const gchar *str;
-
- _tracker_db_result_set_get_value (events, 2, &ev_type);
- str = g_value_get_string (&ev_type);
-
- if (!strcmp (str, "Update")) {
- if (m_modified == NULL)
- m_modified = g_array_new (FALSE, TRUE, sizeof (guint32));
- g_array_append_val (m_modified, ev_i_value);
- } else if (!strcmp (str, "Delete")) {
- if (*removed == NULL)
- m_removed = g_array_new (FALSE, TRUE, sizeof (guint32));
- g_array_append_val (m_removed, ev_i_value);
- }
-
- g_value_unset (&ev_type);
- }
+ if (m_removed == NULL)
+ m_removed = g_array_new (FALSE, TRUE, sizeof (guint32));
+ g_array_append_val (m_removed, ls_i_value);
- g_value_unset (&ev_value);
- ev_valid = tracker_db_result_set_iter_next (events);
- }
-
- tracker_db_result_set_rewind (events);
+ g_value_unset (&ls_value);
ls_valid = tracker_db_result_set_iter_next (result_set);
}
g_object_unref (result_set);
- ls_valid = TRUE;
+part_two:
- // For ottela to review (add columns and tables)
+ /* Created and Modified items */
+
+ ls_valid = TRUE;
result_set = tracker_db_get_live_search_new_ids (db_con,
tracker_xesam_live_search_get_id (self),
- "", /* Columns */
- "", /* Tables */
- tracker_xesam_live_search_get_query (self)); /* Query */
+ NULL, /* Columns */
+ tracker_xesam_live_search_get_from_query (self),
+ tracker_xesam_live_search_get_where_query (self)); /* Query */
if (!result_set)
return;
@@ -344,10 +333,20 @@
GError **error)
{
TrackerXesamLiveSearchPriv *priv = self->priv;
+
if (priv->closed)
- g_set_error (error, TRACKER_XESAM_ERROR,
+ g_set_error (error, TRACKER_XESAM_ERROR_DOMAIN,
TRACKER_XESAM_ERROR_SEARCH_CLOSED,
"Search was already closed");
+ else {
+ DBConnection *db_con = NULL;
+ TrackerDBusXesam *proxy = TRACKER_DBUS_XESAM (tracker_dbus_get_object (TRACKER_TYPE_DBUS_XESAM));
+
+ g_object_get (proxy, "db-connection", &db_con, NULL);
+ tracker_db_stop_live_search (db_con,
+ tracker_xesam_live_search_get_id (self));
+ }
+
priv->closed = TRUE;
priv->active = FALSE;
}
@@ -371,7 +370,7 @@
TrackerXesamLiveSearchPriv *priv = self->priv;
if (!priv->active)
- g_set_error (error, TRACKER_XESAM_ERROR,
+ g_set_error (error, TRACKER_XESAM_ERROR_DOMAIN,
TRACKER_XESAM_ERROR_SEARCH_NOT_ACTIVE,
"Search is not active");
else {
@@ -424,6 +423,7 @@
gint hitfields_columns = 0, column;
GPtrArray *result = g_ptr_array_new ();
+
while (valid) {
GPtrArray *row = g_ptr_array_new ();
@@ -477,15 +477,25 @@
TrackerXesamLiveSearchPriv *priv = self->priv;
if (!priv->active)
- g_set_error (error, TRACKER_XESAM_ERROR,
+ g_set_error (error, TRACKER_XESAM_ERROR_DOMAIN,
TRACKER_XESAM_ERROR_SEARCH_NOT_ACTIVE,
"Search is not active");
else {
TrackerDBResultSet *result_set = NULL;
+ DBConnection *db_con = NULL;
+ TrackerDBusXesam *proxy = TRACKER_DBUS_XESAM (tracker_dbus_get_object (TRACKER_TYPE_DBUS_XESAM));
+
+ g_object_get (proxy, "db-connection", &db_con, NULL);
// For ottela: fetch results for get_hits
- get_hit_data (self, result_set, hits);
+ result_set = tracker_db_get_live_search_get_hit_data (db_con,
+ tracker_xesam_live_search_get_id (self));
+
+ if (result_set) {
+ get_hit_data (self, result_set, hits);
+ g_object_unref (result_set);
+ }
}
}
@@ -498,15 +508,25 @@
TrackerXesamLiveSearchPriv *priv = self->priv;
if (!priv->active)
- g_set_error (error, TRACKER_XESAM_ERROR,
+ g_set_error (error, TRACKER_XESAM_ERROR_DOMAIN,
TRACKER_XESAM_ERROR_SEARCH_NOT_ACTIVE,
"Search is not active");
else {
TrackerDBResultSet *result_set = NULL;
+ DBConnection *db_con = NULL;
+ TrackerDBusXesam *proxy = TRACKER_DBUS_XESAM (tracker_dbus_get_object (TRACKER_TYPE_DBUS_XESAM));
+
+ g_object_get (proxy, "db-connection", &db_con, NULL);
// For ottela: fetch results for get_hits
- get_hit_data (self, result_set, hits);
+ result_set = tracker_db_get_live_search_get_hit_data (db_con,
+ tracker_xesam_live_search_get_id (self));
+
+ if (result_set) {
+ get_hit_data (self, result_set, hits);
+ g_object_unref (result_set);
+ }
}
}
@@ -548,15 +568,25 @@
TrackerXesamLiveSearchPriv *priv = self->priv;
if (!priv->active)
- g_set_error (error, TRACKER_XESAM_ERROR,
+ g_set_error (error, TRACKER_XESAM_ERROR_DOMAIN,
TRACKER_XESAM_ERROR_SEARCH_NOT_ACTIVE,
"Search is not active yet");
else {
TrackerDBResultSet *result_set = NULL;
+ DBConnection *db_con = NULL;
+ TrackerDBusXesam *proxy = TRACKER_DBUS_XESAM (tracker_dbus_get_object (TRACKER_TYPE_DBUS_XESAM));
+
+ g_object_get (proxy, "db-connection", &db_con, NULL);
- // For ottela: fetch results for get_hit_data
+ // For ottela: fetch results for get_hits
+
+ result_set = tracker_db_get_live_search_get_hit_data (db_con,
+ tracker_xesam_live_search_get_id (self));
- get_hit_data (self, result_set, hit_data);
+ if (result_set) {
+ get_hit_data (self, result_set, hit_data);
+ g_object_unref (result_set);
+ }
}
}
@@ -572,15 +602,25 @@
TrackerXesamLiveSearchPriv *priv = self->priv;
if (!priv->active)
- g_set_error (error, TRACKER_XESAM_ERROR,
+ g_set_error (error, TRACKER_XESAM_ERROR_DOMAIN,
TRACKER_XESAM_ERROR_SEARCH_NOT_ACTIVE,
"Search is not active yet");
else {
TrackerDBResultSet *result_set = NULL;
+ DBConnection *db_con = NULL;
+ TrackerDBusXesam *proxy = TRACKER_DBUS_XESAM (tracker_dbus_get_object (TRACKER_TYPE_DBUS_XESAM));
+
+ g_object_get (proxy, "db-connection", &db_con, NULL);
+
+ // For ottela: fetch results for get_hits
- // For ottela: fetch results for get_hit_data
+ result_set = tracker_db_get_live_search_get_hit_data (db_con,
+ tracker_xesam_live_search_get_id (self));
- get_hit_data (self, result_set, hit_data);
+ if (result_set) {
+ get_hit_data (self, result_set, hit_data);
+ g_object_unref (result_set);
+ }
}
}
@@ -615,9 +655,19 @@
TrackerXesamLiveSearchPriv *priv = self->priv;
if (priv->closed)
- g_set_error (error, TRACKER_XESAM_ERROR,
+ g_set_error (error, TRACKER_XESAM_ERROR_DOMAIN,
TRACKER_XESAM_ERROR_SEARCH_CLOSED,
"Search is closed");
+ else {
+ DBConnection *db_con = NULL;
+ TrackerDBusXesam *proxy = TRACKER_DBUS_XESAM (tracker_dbus_get_object (TRACKER_TYPE_DBUS_XESAM));
+
+ g_object_get (proxy, "db-connection", &db_con, NULL);
+ tracker_db_start_live_search (db_con,
+ tracker_xesam_live_search_get_id (self),
+ tracker_xesam_live_search_get_from_query (self),
+ tracker_xesam_live_search_get_where_query (self));
+ }
priv->active = TRUE;
}
@@ -633,7 +683,7 @@
* @returns: a read-only string with the query
**/
const gchar*
-tracker_xesam_live_search_get_query (TrackerXesamLiveSearch *self)
+tracker_xesam_live_search_get_xml_query (TrackerXesamLiveSearch *self)
{
TrackerXesamLiveSearchPriv *priv = self->priv;
return (const gchar *) priv->query;
@@ -674,6 +724,77 @@
}
/**
+ * tracker_xesam_live_search_parse_query:
+ * @self: a #TrackerXesamLiveSearch
+ *
+ * Parses the current xml query and sets the sql
+ **/
+void
+tracker_xesam_live_search_parse_query (TrackerXesamLiveSearch *self,
+ GError **error)
+{
+ TrackerXesamLiveSearchPriv *priv = self->priv;
+ TrackerDBusXesam *proxy = TRACKER_DBUS_XESAM (tracker_dbus_get_object (TRACKER_TYPE_DBUS_XESAM));
+ DBConnection *db_con = NULL;
+ GError *parse_error = NULL;
+
+ g_object_get (proxy, "db-connection", &db_con, NULL);
+
+ g_free (priv->from_sql);
+ g_free (priv->where_sql);
+
+ priv->from_sql = NULL;
+ priv->where_sql = NULL;
+
+ tracker_xesam_query_to_sql (db_con, priv->query,
+ &priv->from_sql,
+ &priv->where_sql,
+ &parse_error);
+
+ if (parse_error) {
+ gchar *str = g_strdup_printf ("Parse error: %s",
+ parse_error->message);
+ g_set_error (error, TRACKER_XESAM_ERROR_DOMAIN,
+ TRACKER_XESAM_ERROR_PARSING_FAILED,
+ str);
+ g_free (str);
+ g_error_free (parse_error);
+ }
+
+ return;
+}
+
+/**
+ * tracker_xesam_live_search_get_from_query:
+ * @self: a #TrackerXesamLiveSearch
+ *
+ * Gets the parsed FROM SQL string for the query
+ *
+ * @returns: a read-only string with the FROM query
+ **/
+const gchar*
+tracker_xesam_live_search_get_from_query (TrackerXesamLiveSearch *self)
+{
+ TrackerXesamLiveSearchPriv *priv = self->priv;
+ return (const gchar *) priv->from_sql;
+}
+
+/**
+ * tracker_xesam_live_search_get_where_query:
+ * @self: a #TrackerXesamLiveSearch
+ *
+ * Gets the parsed WHERE SQL for the query
+ *
+ * @returns: a read-only string with the WHERE query
+ **/
+const gchar*
+tracker_xesam_live_search_get_where_query (TrackerXesamLiveSearch *self)
+{
+ TrackerXesamLiveSearchPriv *priv = self->priv;
+ return (const gchar *) priv->where_sql;
+}
+
+/**
* tracker_xesam_live_search_new:
*
* Create a new #TrackerXesamLiveSearch
Modified: branches/indexer-split/src/trackerd/tracker-xesam-live-search.h
==============================================================================
--- branches/indexer-split/src/trackerd/tracker-xesam-live-search.h (original)
+++ branches/indexer-split/src/trackerd/tracker-xesam-live-search.h Wed May 14 11:11:22 2008
@@ -53,14 +53,21 @@
void tracker_xesam_live_search_set_id (TrackerXesamLiveSearch *self,
const gchar *search_id);
const gchar* tracker_xesam_live_search_get_id (TrackerXesamLiveSearch *self);
-const gchar* tracker_xesam_live_search_get_query (TrackerXesamLiveSearch *self);
-void tracker_xesam_live_search_set_xml_query (TrackerXesamLiveSearch *self,
- const gchar *xml_query);
+
+const gchar* tracker_xesam_live_search_get_where_query (TrackerXesamLiveSearch *self);
+const gchar* tracker_xesam_live_search_get_from_query (TrackerXesamLiveSearch *self);
+const gchar* tracker_xesam_live_search_get_xml_query (TrackerXesamLiveSearch *self);
+void tracker_xesam_live_search_set_xml_query (TrackerXesamLiveSearch *self,
+ const gchar *xml_query);
+void tracker_xesam_live_search_set_session (TrackerXesamLiveSearch *self,
+ gpointer session);
void tracker_xesam_live_search_set_session (TrackerXesamLiveSearch *self,
gpointer session);
void tracker_xesam_live_search_activate (TrackerXesamLiveSearch *self,
GError **error);
gboolean tracker_xesam_live_search_is_active (TrackerXesamLiveSearch *self);
+void tracker_xesam_live_search_parse_query (TrackerXesamLiveSearch *self,
+ GError **error);
void tracker_xesam_live_search_get_hit_data (TrackerXesamLiveSearch *self,
GArray *hit_ids,
GStrv fields,
Modified: branches/indexer-split/src/trackerd/tracker-xesam-session.c
==============================================================================
--- branches/indexer-split/src/trackerd/tracker-xesam-session.c (original)
+++ branches/indexer-split/src/trackerd/tracker-xesam-session.c Wed May 14 11:11:22 2008
@@ -31,6 +31,9 @@
G_DEFINE_TYPE (TrackerXesamSession, tracker_xesam_session, G_TYPE_OBJECT)
+#define GET_PRIV(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), TRACKER_TYPE_XESAM_SESSION, struct _TrackerXesamSessionPriv))
+
+
static void
tracker_xesam_session_g_value_free (GValue *value)
{
@@ -60,7 +63,7 @@
static void
tracker_xesam_session_init (TrackerXesamSession *self)
{
- TrackerXesamSessionPriv *priv = self->priv;
+ TrackerXesamSessionPriv *priv;
GValue *value;
const gchar *hit_fields[2] = {"xesam:url", NULL};
const gchar *hit_fields_extended[1] = {NULL};
@@ -70,9 +73,13 @@
const gchar *exts[1] = {NULL};
const gchar *dummy_onto[4] = {"dummy-onto","0.1","/usr/share/xesam/ontologies/dummy-onto-0.1", NULL};
GPtrArray *ontos = g_ptr_array_new ();
- g_ptr_array_add (ontos, dummy_onto);
+
+ priv = self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self,TRACKER_TYPE_XESAM_SESSION,struct _TrackerXesamSessionPriv);
+ g_ptr_array_add (ontos, dummy_onto);
+
priv->session_id = NULL;
+
priv->searches = g_hash_table_new_full (g_str_hash, g_str_equal,
(GDestroyNotify) g_free,
(GDestroyNotify) g_object_unref);
@@ -189,6 +196,8 @@
GObjectClass *object_class;
object_class = G_OBJECT_CLASS (klass);
object_class->finalize = tracker_xesam_session_finalize;
+
+ g_type_class_add_private( klass, sizeof(struct _TrackerXesamSessionPriv) );
}
/**
@@ -296,7 +305,7 @@
property = g_hash_table_lookup (priv->props, prop);
if (!property) {
- g_set_error (error, TRACKER_XESAM_ERROR,
+ g_set_error (error, TRACKER_XESAM_ERROR_DOMAIN,
TRACKER_XESAM_ERROR_PROPERTY_NOT_SUPPORTED,
"Property not supported");
*new_val = NULL;
@@ -332,7 +341,7 @@
GValue *property = g_hash_table_lookup (priv->props, prop);
if (!property) {
- g_set_error (error, TRACKER_XESAM_ERROR,
+ g_set_error (error, TRACKER_XESAM_ERROR_DOMAIN,
TRACKER_XESAM_ERROR_PROPERTY_NOT_SUPPORTED,
"Property not supported");
*value = NULL;
@@ -368,22 +377,22 @@
gchar **search_id,
GError **error)
{
- TrackerXesamLiveSearch *search;
+ TrackerXesamLiveSearch *search;
TrackerXesamSessionPriv *priv = self->priv;
- // ottela!
- // todo: parse the query and pass the parsed query or throw an error
-
search = tracker_xesam_live_search_new (query_xml);
+ tracker_xesam_live_search_set_session (search, self);
tracker_xesam_live_search_set_id (search, tracker_xesam_generate_unique_key ());
+ if (search_id)
+ *search_id = g_strdup (tracker_xesam_live_search_get_id (search));
+
tracker_xesam_live_search_set_session (search, self);
g_hash_table_insert (priv->searches,
g_strdup (tracker_xesam_live_search_get_id (search)),
g_object_ref (search));
- if (search_id)
- *search_id = g_strdup (tracker_xesam_live_search_get_id (search));
+ tracker_xesam_live_search_parse_query (search, error);
return search;
}
Modified: branches/indexer-split/src/trackerd/tracker-xesam.c
==============================================================================
--- branches/indexer-split/src/trackerd/tracker-xesam.c (original)
+++ branches/indexer-split/src/trackerd/tracker-xesam.c Wed May 14 11:11:22 2008
@@ -36,7 +36,10 @@
GQuark
tracker_xesam_error_quark (void)
{
- return g_quark_from_static_string (TRACKER_XESAM_ERROR_DOMAIN);
+ static GQuark quark = 0;
+ if (quark == 0)
+ quark = g_quark_from_static_string ("TrackerXesam");
+ return quark;
}
void
@@ -85,34 +88,25 @@
void
tracker_xesam_close_session (const gchar *session_id, GError **error)
{
- gpointer session;
-
- session = g_hash_table_lookup (xesam_sessions, session_id);
- if (!session) {
- g_set_error (error,
- TRACKER_XESAM_ERROR,
- TRACKER_XESAM_ERROR_SESSION_ID_NOT_REGISTERED,
- "Session ID is not registered");
- } else {
+ gpointer inst = g_hash_table_lookup (xesam_sessions, session_id);
+ if (!inst)
+ g_set_error (error, TRACKER_XESAM_ERROR_DOMAIN,
+ TRACKER_XESAM_ERROR_SESSION_ID_NOT_REGISTERED,
+ "Session ID is not registered");
+ else
g_hash_table_remove (xesam_sessions, session_id);
- }
}
TrackerXesamSession *
tracker_xesam_get_session (const gchar *session_id, GError **error)
{
- TrackerXesamSession *session;
-
- session = g_hash_table_lookup (xesam_sessions, session_id);
- if (session) {
+ TrackerXesamSession *session = g_hash_table_lookup (xesam_sessions, session_id);
+ if (session)
g_object_ref (session);
- } else {
- g_set_error (error,
- TRACKER_XESAM_ERROR,
- TRACKER_XESAM_ERROR_SESSION_ID_NOT_REGISTERED,
- "Session ID is not registered");
- }
-
+ else
+ g_set_error (error, TRACKER_XESAM_ERROR_DOMAIN,
+ TRACKER_XESAM_ERROR_SESSION_ID_NOT_REGISTERED,
+ "Session ID is not registered");
return session;
}
@@ -147,13 +141,10 @@
g_list_free (sessions);
- if (!session) {
- g_set_error (error,
- TRACKER_XESAM_ERROR,
- TRACKER_XESAM_ERROR_SEARCH_ID_NOT_REGISTERED,
- "Search ID is not registered");
- }
-
+ if (!session)
+ g_set_error (error, TRACKER_XESAM_ERROR_DOMAIN,
+ TRACKER_XESAM_ERROR_SEARCH_ID_NOT_REGISTERED,
+ "Search ID is not registered");
return session;
}
@@ -180,12 +171,10 @@
g_list_free (sessions);
- if (!search) {
- g_set_error (error,
- TRACKER_XESAM_ERROR,
- TRACKER_XESAM_ERROR_SEARCH_ID_NOT_REGISTERED,
- "Search ID is not registered");
- }
+ if (!search)
+ g_set_error (error, TRACKER_XESAM_ERROR_DOMAIN,
+ TRACKER_XESAM_ERROR_SEARCH_ID_NOT_REGISTERED,
+ "Search ID is not registered");
return search;
}
Modified: branches/indexer-split/src/trackerd/tracker-xesam.h
==============================================================================
--- branches/indexer-split/src/trackerd/tracker-xesam.h (original)
+++ branches/indexer-split/src/trackerd/tracker-xesam.h Wed May 14 11:11:22 2008
@@ -29,8 +29,7 @@
G_BEGIN_DECLS
-#define TRACKER_XESAM_ERROR_DOMAIN "TrackerDBus"
-#define TRACKER_XESAM_ERROR tracker_dbus_error_quark()
+#define TRACKER_XESAM_ERROR_DOMAIN tracker_xesam_error_quark()
typedef enum {
TRACKER_XESAM_ERROR_SEARCH_ID_NOT_REGISTERED = 1,
@@ -38,6 +37,7 @@
TRACKER_XESAM_ERROR_SEARCH_CLOSED = 3,
TRACKER_XESAM_ERROR_SEARCH_NOT_ACTIVE = 4,
TRACKER_XESAM_ERROR_PROPERTY_NOT_SUPPORTED = 5,
+ TRACKER_XESAM_ERROR_PARSING_FAILED = 6,
} TrackerXesamError;
GQuark tracker_xesam_error_quark (void);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]