tracker r1559 - in branches/indexer-split: . data/dbus src/tracker-indexer src/trackerd
- From: pvanhoof svn gnome org
- To: svn-commits-list gnome org
- Subject: tracker r1559 - in branches/indexer-split: . data/dbus src/tracker-indexer src/trackerd
- Date: Mon, 2 Jun 2008 16:24:37 +0000 (UTC)
Author: pvanhoof
Date: Mon Jun 2 16:24:36 2008
New Revision: 1559
URL: http://svn.gnome.org/viewvc/tracker?rev=1559&view=rev
Log:
2008-06-02 Philip Van Hoof <pvanhoof gnome org>
* src/tracker-indexer/tracker-indexer-db.c:
* src/tracker-indexer/tracker-indexer-db.h:
* src/tracker-indexer/tracker-indexer.c:
* src/tracker-indexer/tracker-indexer.h:
* src/trackerd/tracker-main.c:
* src/trackerd/tracker-dbus.c:
* src/trackerd/tracker-dbus.h:
* src/trackerd/tracker-db-sqlite.c:
* src/trackerd/tracker-xesam-manager.c:
* src/trackerd/tracker-xesam-manager.h:
* data/dbus/tracker-indexer.xml:
IndexerUpdated signal emitted by the indexer-process to notify trackerd
about changes it should act on in case LiveSearches are active that are
influenced by said changes.
Events table updating reinstalled after refactoring the indexing to a
separate process removed this functionality.
Modified:
branches/indexer-split/ChangeLog
branches/indexer-split/data/dbus/tracker-indexer.xml
branches/indexer-split/src/tracker-indexer/tracker-indexer-db.c
branches/indexer-split/src/tracker-indexer/tracker-indexer-db.h
branches/indexer-split/src/tracker-indexer/tracker-indexer.c
branches/indexer-split/src/tracker-indexer/tracker-indexer.h
branches/indexer-split/src/trackerd/tracker-db-sqlite.c
branches/indexer-split/src/trackerd/tracker-dbus.c
branches/indexer-split/src/trackerd/tracker-dbus.h
branches/indexer-split/src/trackerd/tracker-main.c
branches/indexer-split/src/trackerd/tracker-xesam-manager.c
branches/indexer-split/src/trackerd/tracker-xesam-manager.h
Modified: branches/indexer-split/data/dbus/tracker-indexer.xml
==============================================================================
--- branches/indexer-split/data/dbus/tracker-indexer.xml (original)
+++ branches/indexer-split/data/dbus/tracker-indexer.xml Mon Jun 2 16:24:36 2008
@@ -19,5 +19,7 @@
can add this later
-->
<signal name="Finished"/>
+ <signal name="IndexUpdated"/>
+
</interface>
</node>
Modified: branches/indexer-split/src/tracker-indexer/tracker-indexer-db.c
==============================================================================
--- branches/indexer-split/src/tracker-indexer/tracker-indexer-db.c (original)
+++ branches/indexer-split/src/tracker-indexer/tracker-indexer-db.c Mon Jun 2 16:24:36 2008
@@ -523,6 +523,36 @@
return id;
}
+
+guint32
+tracker_db_get_new_event_id (TrackerDBInterface *iface)
+{
+ TrackerDBResultSet *result_set;
+ gchar *id_str;
+ guint32 id;
+
+ result_set = tracker_db_interface_execute_procedure (iface, NULL, "GetNewEventID", NULL);
+
+ if (!result_set) {
+ g_critical ("Could not create event, GetNewEventID failed");
+ return 0;
+ }
+
+ tracker_db_result_set_get (result_set, 0, &id_str, -1);
+ 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;
+}
+
void
tracker_db_increment_stats (TrackerDBInterface *iface,
TrackerService *service)
@@ -539,6 +569,30 @@
}
}
+
+gboolean
+tracker_db_create_event (TrackerDBInterface *iface,
+ guint32 id,
+ guint32 service_id,
+ const gchar *type)
+{
+ gchar *id_str, *service_id_str;
+
+ id_str = tracker_guint32_to_string (id);
+ service_id_str = tracker_guint32_to_string (service_id);
+
+ tracker_db_interface_execute_procedure (iface, NULL, "CreateEvent",
+ id_str,
+ service_id_str,
+ type,
+ NULL);
+
+ g_free (id_str);
+ g_free (service_id_str);
+
+ return TRUE;
+}
+
gboolean
tracker_db_create_service (TrackerDBInterface *iface,
guint32 id,
@@ -581,6 +635,11 @@
id);
}
+ g_free (id_str);
+ g_free (service_type_id_str);
+ g_free (dirname);
+ g_free (basename);
+
return TRUE;
}
Modified: branches/indexer-split/src/tracker-indexer/tracker-indexer-db.h
==============================================================================
--- branches/indexer-split/src/tracker-indexer/tracker-indexer-db.h (original)
+++ branches/indexer-split/src/tracker-indexer/tracker-indexer-db.h Mon Jun 2 16:24:36 2008
@@ -30,6 +30,7 @@
TrackerDBInterface * tracker_indexer_db_get_file_metadata (void);
guint32 tracker_db_get_new_service_id (TrackerDBInterface *iface);
+guint32 tracker_db_get_new_event_id (TrackerDBInterface *iface);
void tracker_db_increment_stats (TrackerDBInterface *iface,
TrackerService *service);
@@ -42,6 +43,10 @@
guint32 id,
TrackerField *field,
const gchar *value);
+gboolean tracker_db_create_event (TrackerDBInterface *iface,
+ guint32 id,
+ guint32 service_id,
+ const gchar *type);
G_END_DECLS
Modified: branches/indexer-split/src/tracker-indexer/tracker-indexer.c
==============================================================================
--- branches/indexer-split/src/tracker-indexer/tracker-indexer.c (original)
+++ branches/indexer-split/src/tracker-indexer/tracker-indexer.c Mon Jun 2 16:24:36 2008
@@ -110,6 +110,7 @@
enum {
FINISHED,
+ INDEX_UPDATED,
LAST_SIGNAL
};
@@ -232,6 +233,15 @@
g_cclosure_marshal_VOID__VOID,
G_TYPE_NONE, 0);
+
+ signals [INDEX_UPDATED] = g_signal_new ("index-updated",
+ G_OBJECT_CLASS_TYPE (object_class),
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (TrackerIndexerClass, index_updated),
+ NULL, NULL,
+ g_cclosure_marshal_VOID__VOID,
+ G_TYPE_NONE, 0);
+
g_object_class_install_property (object_class,
PROP_RUNNING,
g_param_spec_boolean ("running",
@@ -449,12 +459,13 @@
id = tracker_db_get_new_service_id (priv->common);
if (tracker_db_create_service (priv->metadata, id, service, info->path, metadata)) {
- tracker_db_increment_stats (priv->common, service);
+ guint32 eid;
+
+ eid = tracker_db_get_new_event_id (priv->common);
+
+ tracker_db_create_event (priv->common, eid, id, "Create");
- /* FIXME
- if (tracker_config_get_enable_xesam (tracker->config))
- tracker_db_create_event (db_con, id, "Create");
- */
+ tracker_db_increment_stats (priv->common, service);
index_metadata (indexer, id, service, metadata);
}
@@ -529,6 +540,7 @@
g_strfreev (dirs);
}
+
static gboolean
indexing_func (gpointer data)
{
@@ -562,6 +574,8 @@
}
process_module (indexer, priv->current_module->data);
+
+ g_signal_emit (indexer, signals[INDEX_UPDATED], 0);
}
return TRUE;
Modified: branches/indexer-split/src/tracker-indexer/tracker-indexer.h
==============================================================================
--- branches/indexer-split/src/tracker-indexer/tracker-indexer.h (original)
+++ branches/indexer-split/src/tracker-indexer/tracker-indexer.h Mon Jun 2 16:24:36 2008
@@ -48,6 +48,7 @@
GObjectClass parent_class;
void (*finished) (TrackerIndexer *indexer);
+ void (*index_updated) (TrackerIndexer *indexer);
};
GType tracker_indexer_get_type (void) G_GNUC_CONST;
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 Mon Jun 2 16:24:36 2008
@@ -46,7 +46,6 @@
#include "tracker-utils.h"
#include "tracker-watch.h"
#include "tracker-query-tree.h"
-#include "tracker-xesam-manager.h"
#include "tracker-xesam-ontology.h"
#define MAX_INDEX_TEXT_LENGTH 1048576
@@ -3474,6 +3473,7 @@
tracker_exec_proc_no_reply (db_con->db, "DeleteHandledEvents", NULL);
}
+/* Deprecated */
static guint32
tracker_db_create_event (DBConnection *db_con, const gchar *service_id_str, const gchar *type)
{
@@ -3507,13 +3507,12 @@
if (result_set)
g_object_unref (result_set);
- tracker_xesam_manager_wakeup (id);
-
g_free (eid);
return id;
}
+/* Deprecated */
guint32
tracker_db_create_service (DBConnection *db_con, const char *service, TrackerDBFileInfo *info)
{
Modified: branches/indexer-split/src/trackerd/tracker-dbus.c
==============================================================================
--- branches/indexer-split/src/trackerd/tracker-dbus.c (original)
+++ branches/indexer-split/src/trackerd/tracker-dbus.c Mon Jun 2 16:24:36 2008
@@ -19,8 +19,6 @@
* Boston, MA 02110-1301, USA.
*/
-#include <dbus/dbus-glib-bindings.h>
-
#include <libtracker-common/tracker-log.h>
#include <libtracker-common/tracker-config.h>
#include <libtracker-common/tracker-utils.h>
@@ -323,14 +321,14 @@
return NULL;
}
-void
+DBusGProxy *
tracker_dbus_start_indexer (void)
{
GError *error = NULL;
if (!connection) {
g_critical ("DBus support must be initialized before starting the indexer!");
- return;
+ return NULL;
}
if (!proxy_for_indexer) {
@@ -342,7 +340,7 @@
if (!proxy_for_indexer) {
g_critical ("Couldn't create a DBusGProxy to the indexer service");
- return;
+ return NULL;
}
}
@@ -354,4 +352,6 @@
g_warning ("Couldn't start indexer, %s",
error->message);
}
+
+ return proxy_for_indexer;
}
Modified: branches/indexer-split/src/trackerd/tracker-dbus.h
==============================================================================
--- branches/indexer-split/src/trackerd/tracker-dbus.h (original)
+++ branches/indexer-split/src/trackerd/tracker-dbus.h Mon Jun 2 16:24:36 2008
@@ -25,6 +25,7 @@
#include <glib.h>
#include <libtracker-common/tracker-config.h>
+#include <dbus/dbus-glib-bindings.h>
#include <libtracker-db/tracker-db-interface.h>
@@ -32,11 +33,11 @@
G_BEGIN_DECLS
-gboolean tracker_dbus_init (TrackerConfig *config);
-void tracker_dbus_shutdown (void);
-gboolean tracker_dbus_register_objects (Tracker *tracker);
-GObject *tracker_dbus_get_object (GType type);
-void tracker_dbus_start_indexer (void);
+gboolean tracker_dbus_init (TrackerConfig *config);
+void tracker_dbus_shutdown (void);
+gboolean tracker_dbus_register_objects (Tracker *tracker);
+GObject *tracker_dbus_get_object (GType type);
+DBusGProxy *tracker_dbus_start_indexer (void);
G_END_DECLS
Modified: branches/indexer-split/src/trackerd/tracker-main.c
==============================================================================
--- branches/indexer-split/src/trackerd/tracker-main.c (original)
+++ branches/indexer-split/src/trackerd/tracker-main.c Mon Jun 2 16:24:36 2008
@@ -802,6 +802,7 @@
}
}
+
gint
main (gint argc, gchar *argv[])
{
@@ -998,8 +999,10 @@
}
if (tracker->is_running && !tracker->shutdown) {
+ DBusGProxy *proxy;
g_message ("Indexing enabled, starting...");
- tracker_dbus_start_indexer ();
+ proxy = tracker_dbus_start_indexer ();
+ tracker_xesam_subscribe_indexer_updated (proxy);
}
#if 0
Modified: branches/indexer-split/src/trackerd/tracker-xesam-manager.c
==============================================================================
--- branches/indexer-split/src/trackerd/tracker-xesam-manager.c (original)
+++ branches/indexer-split/src/trackerd/tracker-xesam-manager.c Mon Jun 2 16:24:36 2008
@@ -34,6 +34,8 @@
static gchar *xesam_dir;
static gboolean live_search_handler_running = FALSE;
+static void tracker_xesam_manager_wakeup (gpointer user_data);
+
GQuark
tracker_xesam_manager_error_quark (void)
{
@@ -57,8 +59,55 @@
g_str_equal,
(GDestroyNotify) g_free,
(GDestroyNotify) g_object_unref);
-
+
xesam_dir = g_build_filename (g_get_home_dir (), ".xesam", NULL);
+
+}
+
+static void
+tracker_xesam_manager_finished (DBusGProxy *proxy)
+{
+ dbus_g_proxy_disconnect_signal (proxy,
+ "IndexUpdated",
+ G_CALLBACK (tracker_xesam_manager_wakeup),
+ NULL);
+
+ dbus_g_proxy_disconnect_signal (proxy,
+ "Finished",
+ G_CALLBACK (tracker_xesam_manager_finished),
+ NULL);
+}
+
+void
+tracker_xesam_subscribe_indexer_updated (DBusGProxy *proxy)
+{
+ dbus_g_proxy_add_signal (proxy, "Finished",
+ G_TYPE_INVALID,
+ G_SIGNAL_RUN_LAST,
+ NULL,
+ NULL, NULL,
+ g_cclosure_marshal_VOID__VOID,
+ G_TYPE_NONE, 0);
+
+ dbus_g_proxy_add_signal (proxy, "IndexUpdated",
+ G_TYPE_INVALID,
+ G_SIGNAL_RUN_LAST,
+ NULL,
+ NULL, NULL,
+ g_cclosure_marshal_VOID__VOID,
+ G_TYPE_NONE, 0);
+
+ dbus_g_proxy_connect_signal (proxy,
+ "Finished",
+ G_CALLBACK (tracker_xesam_manager_finished),
+ g_object_ref (proxy),
+ (GClosureNotify) g_object_unref);
+
+ dbus_g_proxy_connect_signal (proxy,
+ "IndexUpdated",
+ G_CALLBACK (tracker_xesam_manager_wakeup),
+ g_object_ref (proxy),
+ (GClosureNotify) g_object_unref);
}
void
@@ -287,8 +336,8 @@
live_search_handler_running = FALSE;
}
-void
-tracker_xesam_manager_wakeup (guint32 last_id)
+static void
+tracker_xesam_manager_wakeup (gpointer user_data)
{
/* This happens each time a new event is created */
Modified: branches/indexer-split/src/trackerd/tracker-xesam-manager.h
==============================================================================
--- branches/indexer-split/src/trackerd/tracker-xesam-manager.h (original)
+++ branches/indexer-split/src/trackerd/tracker-xesam-manager.h Mon Jun 2 16:24:36 2008
@@ -61,9 +61,9 @@
TrackerXesamLiveSearch*
tracker_xesam_manager_get_live_search (const gchar *search_id,
GError **error);
-void tracker_xesam_manager_wakeup (guint32 last_id);
gchar * tracker_xesam_manager_generate_unique_key (void);
gboolean tracker_xesam_manager_is_uri_in_xesam_dir (const gchar *uri);
+void tracker_xesam_subscribe_indexer_updated (DBusGProxy *proxy);
G_END_DECLS
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]