[tracker/tracker-0.10] Rewrite of tracker-writeback
- From: Martyn James Russell <mr src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [tracker/tracker-0.10] Rewrite of tracker-writeback
- Date: Mon, 1 Aug 2011 16:16:18 +0000 (UTC)
commit 60b9af1e643eb86e6c60b402b6d4e9639d30f6fd
Author: Philip Van Hoof <philip codeminded be>
Date: Wed Jul 13 16:37:44 2011 +0200
Rewrite of tracker-writeback
data/dbus/Makefile.am | 39 +-
data/dbus/tracker-writeback.xml | 23 +-
src/tracker-writeback/Makefile.am | 51 +-
src/tracker-writeback/tracker-main.c | 128 +---
src/tracker-writeback/tracker-writeback-consumer.c | 456 -----------
src/tracker-writeback/tracker-writeback-consumer.h | 57 --
.../tracker-writeback-dispatcher.c | 418 ----------
.../tracker-writeback-dispatcher.h | 59 --
src/tracker-writeback/tracker-writeback-file.h | 2 +-
src/tracker-writeback/tracker-writeback-module.c | 40 +
src/tracker-writeback/tracker-writeback-module.h | 35 +-
src/tracker-writeback/tracker-writeback.c | 823 +++++++++++++++++++-
src/tracker-writeback/tracker-writeback.h | 58 +-
13 files changed, 971 insertions(+), 1218 deletions(-)
---
diff --git a/data/dbus/Makefile.am b/data/dbus/Makefile.am
index 4549048..a809137 100644
--- a/data/dbus/Makefile.am
+++ b/data/dbus/Makefile.am
@@ -2,39 +2,42 @@ include $(top_srcdir)/Makefile.decl
configdir = $(datadir)/tracker
-config_DATA = \
- tracker-backup.xml \
- tracker-extract.xml \
- tracker-miner.xml \
- tracker-miner-web.xml \
- tracker-resources.xml \
- tracker-statistics.xml \
- tracker-writeback.xml \
+config_DATA = \
+ tracker-backup.xml \
+ tracker-extract.xml \
+ tracker-miner.xml \
+ tracker-miner-web.xml \
+ tracker-resources.xml \
+ tracker-statistics.xml \
+ tracker-writeback.xml \
tracker-status.xml
-config_noinst = \
+config_noinst = \
tracker-miner-files-index.xml
# Services
-service_in_files = \
- org.freedesktop.Tracker1.service.in \
+service_in_files = \
+ org.freedesktop.Tracker1.service.in \
org.freedesktop.Tracker1.Miner.Applications.service.in \
org.freedesktop.Tracker1.Miner.EMails.service.in \
org.freedesktop.Tracker1.Miner.Files.service.in \
org.freedesktop.Tracker1.Miner.Flickr.service.in \
org.freedesktop.Tracker1.Miner.RSS.service.in \
- org.freedesktop.Tracker1.Extract.service.in
+ org.freedesktop.Tracker1.Extract.service.in \
+ org.freedesktop.Tracker1.Writeback.service.in
%.service: %.service.in
@sed -e "s|@libexecdir[ ]|${libexecdir}|" $< > $@
# Services
servicedir = $(DBUS_SERVICES_DIR)
-service_DATA = \
- org.freedesktop.Tracker1.service \
+service_DATA = \
+ org.freedesktop.Tracker1.service \
org.freedesktop.Tracker1.Miner.Applications.service \
org.freedesktop.Tracker1.Miner.Files.service \
- org.freedesktop.Tracker1.Extract.service
+ org.freedesktop.Tracker1.Extract.service \
+ org.freedesktop.Tracker1.Writeback.service
+
if HAVE_TRACKER_MINER_EVOLUTION
service_DATA += org.freedesktop.Tracker1.Miner.EMails.service
@@ -49,9 +52,9 @@ service_DATA += org.freedesktop.Tracker1.Miner.Flickr.service
endif
-EXTRA_DIST = \
- $(service_in_files) \
- $(config_DATA) \
+EXTRA_DIST = \
+ $(service_in_files) \
+ $(config_DATA) \
$(config_noinst)
CLEANFILES = $(service_DATA)
diff --git a/data/dbus/tracker-writeback.xml b/data/dbus/tracker-writeback.xml
index e67cf70..71e09f5 100644
--- a/data/dbus/tracker-writeback.xml
+++ b/data/dbus/tracker-writeback.xml
@@ -1,8 +1,27 @@
<?xml version="1.0" encoding="UTF-8"?>
+<!--
+<busconfig>
+ <policy context="default">
+ <deny send_interface="org.freedesktop.Tracker1.Indexer"/>
+ <allow send_destination="org.freedesktop.Tracker1"/>
+ </policy>
+</busconfig>
+-->
+
<node name="/">
<interface name="org.freedesktop.Tracker1.Writeback">
- <annotation name="org.freedesktop.DBus.GLib.CSymbol" value="tracker_writeback_dbus"/>
-
+ <method name="GetPid">
+ <annotation name="org.freedesktop.DBus.GLib.Async" value="true"/>
+ <arg type="i" name="value" direction="out" />
+ </method>
+ <method name='PerformWriteback'>"
+ <arg type='s' name='uri' direction='in' />"
+ <arg type='as' name='rdf_types' direction='in' />"
+ <arg type='aas' name='results' direction='in' />"
+ </method>"
+ <method name='CancelTasks'>"
+ <arg type='as' name='uri' direction='in' />"
+ </method>"
</interface>
</node>
diff --git a/src/tracker-writeback/Makefile.am b/src/tracker-writeback/Makefile.am
index f0d0f7c..f459ed8 100644
--- a/src/tracker-writeback/Makefile.am
+++ b/src/tracker-writeback/Makefile.am
@@ -10,7 +10,9 @@ AM_CPPFLAGS = \
-DLOCALEDIR=\""$(localedir)"\" \
-DMODULESDIR=\"$(modulesdir)\" \
-DWRITEBACK_MODULES_DIR=\""$(modulesdir)"\" \
- $(TRACKER_WRITEBACK_CFLAGS)
+ $(TRACKER_WRITEBACK_CFLAGS) \
+ $(LIBTRACKER_MINER_CFLAGS)
+
modules_LTLIBRARIES =
@@ -44,36 +46,31 @@ endif
#
libexec_PROGRAMS = tracker-writeback
-tracker_writeback_SOURCES = \
- $(marshal_sources) \
- $(dbus_sources) \
- tracker-config.c \
- tracker-config.h \
- tracker-writeback-consumer.c \
- tracker-writeback-consumer.h \
- tracker-writeback-dbus.h \
- tracker-writeback-dispatcher.c \
- tracker-writeback-dispatcher.h \
- tracker-writeback-file.c \
- tracker-writeback-file.h \
- tracker-writeback-module.c \
- tracker-writeback-module.h \
- tracker-writeback.c \
- tracker-writeback.h \
+tracker_writeback_SOURCES = \
+ $(marshal_sources) \
+ $(dbus_sources) \
+ tracker-config.c \
+ tracker-config.h \
+ tracker-writeback-dbus.h \
+ tracker-writeback-file.c \
+ tracker-writeback-file.h \
+ tracker-writeback-module.c \
+ tracker-writeback-module.h \
+ tracker-writeback.c \
+ tracker-writeback.h \
tracker-main.c
-tracker_writeback_LDADD = \
+tracker_writeback_LDADD = \
$(top_builddir)/src/libtracker-sparql-backend/libtracker-sparql- TRACKER_API_VERSION@.la \
$(top_builddir)/src/libtracker-miner/libtracker-miner- TRACKER_API_VERSION@.la \
$(top_builddir)/src/libtracker-common/libtracker-common.la \
- $(BUILD_LIBS) \
- $(TRACKER_WRITEBACK_LIBS)
+ $(BUILD_LIBS) \
+ $(TRACKER_WRITEBACK_LIBS) \
+ $(LIBTRACKER_MINER_LIBS)
-dbus_sources = \
- tracker-writeback-glue.h
-marshal_sources = \
- tracker-marshal.h \
+marshal_sources = \
+ tracker-marshal.h \
tracker-marshal.c
tracker-marshal.h: tracker-marshal.list
@@ -83,11 +80,7 @@ tracker-marshal.c: tracker-marshal.list
$(AM_V_GEN)echo "#include \"tracker-marshal.h\"" > $@ && \
$(GLIB_GENMARSHAL) $< --prefix=tracker_marshal --body >> $@
-%-glue.h: $(top_srcdir)/data/dbus/%.xml
- $(AM_V_GEN)$(DBUSBINDINGTOOL) --mode=glib-server --output=$@ --prefix=$(subst -,_,$*) $^
-
-BUILT_SOURCES = \
- $(dbus_sources) \
+BUILT_SOURCES = \
$(marshal_sources)
CLEANFILES = $(BUILT_SOURCES)
diff --git a/src/tracker-writeback/tracker-main.c b/src/tracker-writeback/tracker-main.c
index a42226d..f42fa69 100644
--- a/src/tracker-writeback/tracker-main.c
+++ b/src/tracker-writeback/tracker-main.c
@@ -28,8 +28,7 @@
#include <libtracker-common/tracker-log.h>
-#include "tracker-writeback-dispatcher.h"
-#include "tracker-writeback-consumer.h"
+#include "tracker-writeback.h"
#include "tracker-config.h"
#define ABOUT \
@@ -58,93 +57,6 @@ static GOptionEntry entries[] = {
{ NULL }
};
-typedef struct {
- gint subject;
- GArray *rdf_types;
-} WritebackData;
-
-static TrackerWritebackConsumer *consumer = NULL;
-static TrackerWritebackDispatcher *dispatcher = NULL;
-static GMainContext *dispatcher_context = NULL;
-
-static WritebackData *
-writeback_data_new (gint subject,
- GArray *rdf_types)
-{
- WritebackData *data;
- guint i;
-
- data = g_slice_new (WritebackData);
- data->subject = subject;
-
- data->rdf_types = g_array_sized_new (FALSE, FALSE, sizeof (gint), rdf_types->len);
-
- for (i = 0; i < rdf_types->len; i++) {
- gint id = g_array_index (rdf_types, gint, i);
- g_array_append_val (data->rdf_types, id);
- }
-
- return data;
-}
-
-static void
-writeback_data_free (WritebackData *data)
-{
- g_array_free (data->rdf_types, TRUE);
- g_slice_free (WritebackData, data);
-}
-
-/* This function will be executed in the main thread */
-static gboolean
-on_writeback_idle_cb (gpointer user_data)
-{
- WritebackData *data = user_data;
-
- g_message ("Main thread (%p) got signaled of writeback petition", g_thread_self ());
-
- tracker_writeback_consumer_add_subject (consumer, data->subject, data->rdf_types);
-
- writeback_data_free (data);
-
- return FALSE;
-}
-
-/* This callback run in the dispatcher thread */
-static void
-on_writeback_cb (TrackerWritebackDispatcher *dispatcher,
- gint subject,
- GArray *rdf_types)
-{
- WritebackData *data;
-
- g_message ("Got writeback petition on thread '%p' for subject '%d'",
- g_thread_self (), subject);
-
- data = writeback_data_new (subject, rdf_types);
- g_idle_add_full (G_PRIORITY_HIGH_IDLE,
- on_writeback_idle_cb,
- data, NULL);
-}
-
-static gpointer
-dispatcher_thread_func (gpointer data)
-{
- GMainLoop *loop;
-
- g_message ("DBus Dispatcher thread created: %p", g_thread_self ());
-
- g_signal_connect (dispatcher, "writeback",
- G_CALLBACK (on_writeback_cb), NULL);
-
- loop = g_main_loop_new (dispatcher_context, FALSE);
- g_main_loop_run (loop);
-
- g_object_unref (dispatcher);
- g_main_loop_unref (loop);
- g_main_context_unref (dispatcher_context);
-
- return NULL;
-}
static void
sanity_check_option_values (TrackerConfig *config)
@@ -159,13 +71,13 @@ main (int argc,
char *argv[])
{
TrackerConfig *config;
+ TrackerController *controller;
GOptionContext *context;
GMainLoop *loop;
GError *error = NULL;
gchar *log_filename;
g_thread_init (NULL);
- dbus_g_thread_init ();
g_type_init ();
@@ -204,38 +116,14 @@ main (int argc,
sanity_check_option_values (config);
+#warning todo here
- consumer = tracker_writeback_consumer_new (&error);
+ // get correct value from config here
+ controller = tracker_controller_new (9999, &error);
if (error) {
- g_critical ("Error creating consumer: %s", error->message);
+ g_critical ("Error creating controller: %s", error->message);
g_error_free (error);
-
- return EXIT_FAILURE;
- }
-
- /* Create dispatcher thread data here, GType
- * initialization for boxed types don't seem
- * to be threadsafe, this is troublesome with
- * signals initialization. */
-
- dispatcher_context = g_main_context_new ();
- dispatcher = tracker_writeback_dispatcher_new (dispatcher_context,
- &error);
-
- if (error) {
- g_critical ("Error creating dispatcher: %s", error->message);
- g_error_free (error);
-
- return EXIT_FAILURE;
- }
-
- g_thread_create (dispatcher_thread_func, dispatcher, FALSE, &error);
-
- if (error) {
- g_critical ("Error creating dispatcher thread: %s", error->message);
- g_error_free (error);
-
return EXIT_FAILURE;
}
@@ -244,9 +132,11 @@ main (int argc,
loop = g_main_loop_new (NULL, FALSE);
g_main_loop_run (loop);
+
tracker_log_shutdown ();
- g_object_unref (consumer);
+ g_object_unref (controller);
+
g_main_loop_unref (loop);
g_object_unref (config);
diff --git a/src/tracker-writeback/tracker-writeback-file.h b/src/tracker-writeback/tracker-writeback-file.h
index c3ffbc3..9b81813 100644
--- a/src/tracker-writeback/tracker-writeback-file.h
+++ b/src/tracker-writeback/tracker-writeback-file.h
@@ -22,7 +22,7 @@
#include <gio/gio.h>
-#include "tracker-writeback.h"
+#include "tracker-writeback-module.h"
G_BEGIN_DECLS
diff --git a/src/tracker-writeback/tracker-writeback-module.c b/src/tracker-writeback/tracker-writeback-module.c
index b45847e..4ebf731 100644
--- a/src/tracker-writeback/tracker-writeback-module.c
+++ b/src/tracker-writeback/tracker-writeback-module.c
@@ -23,11 +23,16 @@
#include "tracker-writeback-module.h"
+static TrackerMinerManager *manager = NULL;
+
static gboolean writeback_module_load (GTypeModule *module);
static void writeback_module_unload (GTypeModule *module);
G_DEFINE_TYPE (TrackerWritebackModule, tracker_writeback_module, G_TYPE_TYPE_MODULE)
+G_DEFINE_ABSTRACT_TYPE (TrackerWriteback, tracker_writeback, G_TYPE_OBJECT)
+
+
static void
tracker_writeback_module_class_init (TrackerWritebackModuleClass *klass)
{
@@ -162,3 +167,38 @@ tracker_writeback_module_get_rdf_types (TrackerWritebackModule *module)
{
return (module->get_rdf_types) ();
}
+
+static void
+tracker_writeback_class_init (TrackerWritebackClass *klass)
+{
+}
+
+static void
+tracker_writeback_init (TrackerWriteback *writeback)
+{
+}
+
+gboolean
+tracker_writeback_update_metadata (TrackerWriteback *writeback,
+ GPtrArray *values,
+ TrackerSparqlConnection *connection)
+{
+ g_return_val_if_fail (TRACKER_IS_WRITEBACK (writeback), FALSE);
+ g_return_val_if_fail (values != NULL, FALSE);
+
+ if (TRACKER_WRITEBACK_GET_CLASS (writeback)->update_metadata) {
+ return TRACKER_WRITEBACK_GET_CLASS (writeback)->update_metadata (writeback, values, connection);
+ }
+
+ return FALSE;
+}
+
+TrackerMinerManager*
+tracker_writeback_get_miner_manager (void)
+{
+ if (!manager) {
+ manager = tracker_miner_manager_new ();
+ }
+
+ return manager;
+}
diff --git a/src/tracker-writeback/tracker-writeback-module.h b/src/tracker-writeback/tracker-writeback-module.h
index be023a6..b8038a2 100644
--- a/src/tracker-writeback/tracker-writeback-module.h
+++ b/src/tracker-writeback/tracker-writeback-module.h
@@ -23,16 +23,38 @@
#include <glib.h>
#include <glib-object.h>
-#include "tracker-writeback.h"
+#include <libtracker-miner/tracker-miner.h>
+#include <libtracker-sparql/tracker-sparql.h>
G_BEGIN_DECLS
#define TRACKER_TYPE_WRITEBACK_MODULE (tracker_writeback_module_get_type ())
#define TRACKER_WRITEBACK_MODULE(module) (G_TYPE_CHECK_INSTANCE_CAST ((module), TRACKER_TYPE_WRITEBACK_MODULE, TrackerWritebackModule))
+#define TRACKER_TYPE_WRITEBACK (tracker_writeback_get_type())
+#define TRACKER_WRITEBACK(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), TRACKER_TYPE_WRITEBACK, TrackerWriteback))
+#define TRACKER_WRITEBACK_CLASS(c) (G_TYPE_CHECK_CLASS_CAST ((c), TRACKER_TYPE_WRITEBACK, TrackerWritebackClass))
+#define TRACKER_IS_WRITEBACK(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), TRACKER_TYPE_WRITEBACK))
+#define TRACKER_IS_WRITEBACK_CLASS(c) (G_TYPE_CHECK_CLASS_TYPE ((c), TRACKER_TYPE_WRITEBACK))
+#define TRACKER_WRITEBACK_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), TRACKER_TYPE_WRITEBACK, TrackerWritebackClass))
+
+typedef struct TrackerWriteback TrackerWriteback;
+typedef struct TrackerWritebackClass TrackerWritebackClass;
typedef struct TrackerWritebackModule TrackerWritebackModule;
typedef struct TrackerWritebackModuleClass TrackerWritebackModuleClass;
+struct TrackerWriteback {
+ GObject parent_instance;
+};
+
+struct TrackerWritebackClass {
+ GObjectClass parent_class;
+
+ gboolean (* update_metadata) (TrackerWriteback *writeback,
+ GPtrArray *values,
+ TrackerSparqlConnection *connection);
+};
+
struct TrackerWritebackModule {
GTypeModule parent_instance;
@@ -47,6 +69,17 @@ struct TrackerWritebackModuleClass {
GTypeModuleClass parent_class;
};
+
+GType tracker_writeback_get_type (void) G_GNUC_CONST;
+gboolean tracker_writeback_update_metadata (TrackerWriteback *writeback,
+ GPtrArray *values,
+ TrackerSparqlConnection *connection);
+TrackerMinerManager* tracker_writeback_get_miner_manager (void);
+
+/* Entry functions to be defined by modules */
+TrackerWriteback * writeback_module_create (GTypeModule *module);
+const gchar * const * writeback_module_get_rdf_types (void);
+
GType tracker_writeback_module_get_type (void) G_GNUC_CONST;
TrackerWritebackModule *tracker_writeback_module_get (const gchar *name);
diff --git a/src/tracker-writeback/tracker-writeback.c b/src/tracker-writeback/tracker-writeback.c
index 6b26733..67cb160 100644
--- a/src/tracker-writeback/tracker-writeback.c
+++ b/src/tracker-writeback/tracker-writeback.c
@@ -1,61 +1,834 @@
/*
- * Copyright (C) 2009, Nokia <ivan frade nokia com>
+ * Copyright (C) 2011, Nokia <ivan frade nokia com>
*
* This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public
+ * modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
+ * version 2.1 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.
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
*
- * You should have received a copy of the GNU General Public
+ * You should have received a copy of the GNU Lesser 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 "config.h"
-
#include "tracker-writeback.h"
+#include "tracker-writeback-module.h"
+
+#include <libtracker-common/tracker-common.h>
+#include <libtracker-miner/tracker-miner.h>
+#include <libtracker-sparql/tracker-sparql.h>
+
+#include <gio/gio.h>
+
+#ifdef STAYALIVE_ENABLE_TRACE
+#warning Stayalive traces enabled
+#endif /* STAYALIVE_ENABLE_TRACE */
+
+#define THREAD_ENABLE_TRACE
+
+#ifdef THREAD_ENABLE_TRACE
+#warning Controller thread traces enabled
+#endif /* THREAD_ENABLE_TRACE */
+
+typedef struct {
+ GMainContext *context;
+ GMainLoop *main_loop;
+
+ TrackerStorage *storage;
+
+ GDBusConnection *d_connection;
+ GDBusNodeInfo *introspection_data;
+ guint registration_id;
+ guint bus_name_id;
+
+ GList *ongoing_tasks;
+
+ guint shutdown_timeout;
+ GSource *shutdown_source;
+
+ GCond *initialization_cond;
+ GMutex *initialization_mutex;
+ GError *initialization_error;
+
+ guint initialized : 1;
+
+ GHashTable *modules;
+ TrackerSparqlConnection *connection;
+} TrackerControllerPrivate;
+
+typedef struct {
+ TrackerController *controller;
+ GCancellable *cancellable;
+ GDBusMethodInvocation *invocation;
+ TrackerDBusRequest *request;
+ gchar *subject;
+ GPtrArray *results;
+} WritebackData;
+
+#define TRACKER_WRITEBACK_SERVICE "org.freedesktop.Tracker1.Writeback"
+#define TRACKER_WRITEBACK_PATH "/org/freedesktop/Tracker1/Writeback"
+#define TRACKER_WRITEBACK_INTERFACE "org.freedesktop.Tracker1.Writeback"
-G_DEFINE_ABSTRACT_TYPE (TrackerWriteback, tracker_writeback, G_TYPE_OBJECT)
+static const gchar *introspection_xml =
+ "<node>"
+ " <interface name='org.freedesktop.Tracker1.Writeback'>"
+ " <method name='GetPid'>"
+ " <arg type='i' name='value' direction='out' />"
+ " </method>"
+ " <method name='PerformWriteback'>"
+ " <arg type='s' name='uri' direction='in' />"
+ " <arg type='as' name='rdf_types' direction='in' />"
+ " <arg type='aas' name='results' direction='in' />"
+ " </method>"
+ " <method name='CancelTasks'>"
+ " <arg type='as' name='uri' direction='in' />"
+ " </method>"
+ " </interface>"
+ "</node>";
-static TrackerMinerManager *manager = NULL;
+enum {
+ PROP_0,
+ PROP_SHUTDOWN_TIMEOUT,
+};
+
+static void tracker_controller_initable_iface_init (GInitableIface *iface);
+static gboolean tracker_controller_dbus_start (TrackerController *controller,
+ GError **error);
+static void tracker_controller_dbus_stop (TrackerController *controller);
+static gboolean tracker_controller_start (TrackerController *controller,
+ GError **error);
+
+G_DEFINE_TYPE_WITH_CODE (TrackerController, tracker_controller, G_TYPE_OBJECT,
+ G_IMPLEMENT_INTERFACE (G_TYPE_INITABLE,
+ tracker_controller_initable_iface_init));
+
+static gboolean
+tracker_controller_initable_init (GInitable *initable,
+ GCancellable *cancellable,
+ GError **error)
+{
+ return tracker_controller_start (TRACKER_CONTROLLER (initable), error);
+}
+
+static void
+tracker_controller_initable_iface_init (GInitableIface *iface)
+{
+ iface->init = tracker_controller_initable_init;
+}
static void
-tracker_writeback_class_init (TrackerWritebackClass *klass)
+tracker_controller_finalize (GObject *object)
{
+ TrackerControllerPrivate *priv;
+ TrackerController *controller;
+
+ controller = TRACKER_CONTROLLER (object);
+ priv = controller->priv;
+
+ if (priv->shutdown_source) {
+ g_source_destroy (priv->shutdown_source);
+ priv->shutdown_source = NULL;
+ }
+
+ tracker_controller_dbus_stop (controller);
+
+ g_object_unref (priv->storage);
+ g_hash_table_unref (priv->modules);
+
+ g_main_loop_unref (priv->main_loop);
+ g_main_context_unref (priv->context);
+
+ g_cond_free (priv->initialization_cond);
+ g_mutex_free (priv->initialization_mutex);
+
+ G_OBJECT_CLASS (tracker_controller_parent_class)->finalize (object);
}
static void
-tracker_writeback_init (TrackerWriteback *writeback)
+tracker_controller_get_property (GObject *object,
+ guint param_id,
+ GValue *value,
+ GParamSpec *pspec)
{
+ TrackerControllerPrivate *priv = TRACKER_CONTROLLER (object)->priv;
+
+ switch (param_id) {
+ case PROP_SHUTDOWN_TIMEOUT:
+ g_value_set_uint (value, priv->shutdown_timeout);
+ break;
+ }
}
-gboolean
-tracker_writeback_update_metadata (TrackerWriteback *writeback,
- GPtrArray *values,
- TrackerSparqlConnection *connection)
+static void
+tracker_controller_set_property (GObject *object,
+ guint param_id,
+ const GValue *value,
+ GParamSpec *pspec)
{
- g_return_val_if_fail (TRACKER_IS_WRITEBACK (writeback), FALSE);
- g_return_val_if_fail (values != NULL, FALSE);
+ TrackerControllerPrivate *priv = TRACKER_CONTROLLER (object)->priv;
- if (TRACKER_WRITEBACK_GET_CLASS (writeback)->update_metadata) {
- return TRACKER_WRITEBACK_GET_CLASS (writeback)->update_metadata (writeback, values, connection);
+ switch (param_id) {
+ case PROP_SHUTDOWN_TIMEOUT:
+ priv->shutdown_timeout = g_value_get_uint (value);
+ break;
}
+}
+
+static void
+tracker_controller_class_init (TrackerControllerClass *klass)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+
+ object_class->finalize = tracker_controller_finalize;
+ object_class->get_property = tracker_controller_get_property;
+ object_class->set_property = tracker_controller_set_property;
+
+ g_object_class_install_property (object_class,
+ PROP_SHUTDOWN_TIMEOUT,
+ g_param_spec_uint ("shutdown-timeout",
+ "Shutdown timeout",
+ "Shutdown timeout, 0 to disable",
+ 0, 1000, 0,
+ G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
+
+ g_type_class_add_private (object_class, sizeof (TrackerControllerPrivate));
+}
+
+static WritebackData *
+writeback_data_new (TrackerController *controller,
+ const gchar *subject,
+ GPtrArray *results,
+ GDBusMethodInvocation *invocation,
+ TrackerDBusRequest *request)
+{
+ WritebackData *data;
+
+ data = g_slice_new (WritebackData);
+ data->cancellable = g_cancellable_new ();
+ data->controller = controller;
+ data->subject = g_strdup (subject);
+ data->results = g_ptr_array_ref (results);
+ data->invocation = invocation;
+ data->request = request;
+
+ return data;
+}
+
+static void
+writeback_data_free (WritebackData *data)
+{
+ /* We rely on data->invocation being freed through
+ * the g_dbus_method_invocation_return_* methods
+ */
+ g_free (data->subject);
+ g_ptr_array_unref (data->results);
+ g_object_unref (data->cancellable);
+ g_slice_free (WritebackData, data);
+}
+
+static void
+cancel_tasks_in_file (TrackerController *controller,
+ GFile *file)
+{
+/*
+ TrackerControllerPrivate *priv;
+ GList *elem;
+
+ priv = controller->priv;
+
+ for (elem = priv->ongoing_tasks; elem; elem = elem->next) {
+ GetMetadataData *data;
+ GFile *task_file;
+
+ data = elem->data;
+
+#warning todo here
+ // todo: the GFile holds the nie:url, not the subject, so this wont work
+
+ task_file = g_file_new_for_uri (data->subject);
+
+ if (g_file_equal (task_file, file) ||
+ g_file_has_prefix (task_file, file)) {
+ / Mount path contains one of the files being processed /
+ if (!elem->next) {
+ * The last element in the list is
+ * the one currently being processed,
+ * so exit abruptly.
+ *
+ g_message ("Cancelled task ('%s') is currently being processed, quitting",
+ data->uri);
+ _exit (0);
+ } else {
+ g_message ("Cancelling not yet processed task ('%s')",
+ data->uri);
+ g_cancellable_cancel (data->cancellable);
+ }
+ }
+
+ g_object_unref (task_file);
+ } */
+}
+
+static void
+mount_point_removed_cb (TrackerStorage *storage,
+ const gchar *uuid,
+ const gchar *mount_point,
+ gpointer user_data)
+{
+ GFile *mount_file;
+
+ mount_file = g_file_new_for_path (mount_point);
+ cancel_tasks_in_file (TRACKER_CONTROLLER (user_data), mount_file);
+ g_object_unref (mount_file);
+}
+
+static gboolean
+reset_shutdown_timeout_cb (gpointer user_data)
+{
+ TrackerControllerPrivate *priv;
+
+#ifdef STAYALIVE_ENABLE_TRACE
+ g_debug ("Stayalive --- time has expired");
+#endif /* STAYALIVE_ENABLE_TRACE */
+
+ g_message ("Shutting down due to no activity");
+
+ priv = TRACKER_CONTROLLER (user_data)->priv;
+ g_main_loop_quit (priv->main_loop);
return FALSE;
}
-TrackerMinerManager*
-tracker_writeback_get_miner_manager (void)
+static void
+reset_shutdown_timeout (TrackerController *controller)
+{
+ TrackerControllerPrivate *priv;
+ GSource *source;
+
+ priv = controller->priv;
+
+ if (priv->shutdown_timeout == 0) {
+ return;
+ }
+
+#ifdef STAYALIVE_ENABLE_TRACE
+ g_debug ("Stayalive --- (Re)setting timeout");
+#endif /* STAYALIVE_ENABLE_TRACE */
+
+ if (priv->shutdown_source) {
+ g_source_destroy (priv->shutdown_source);
+ priv->shutdown_source = NULL;
+ }
+
+ source = g_timeout_source_new_seconds (priv->shutdown_timeout);
+ g_source_set_callback (source,
+ reset_shutdown_timeout_cb,
+ controller, NULL);
+
+ g_source_attach (source, priv->context);
+ priv->shutdown_source = source;
+}
+
+static void
+tracker_controller_init (TrackerController *controller)
+{
+ TrackerControllerPrivate *priv;
+
+ priv = controller->priv = G_TYPE_INSTANCE_GET_PRIVATE (controller,
+ TRACKER_TYPE_CONTROLLER,
+ TrackerControllerPrivate);
+
+ priv->context = g_main_context_new ();
+ priv->main_loop = g_main_loop_new (priv->context, FALSE);
+
+ priv->storage = tracker_storage_new ();
+ g_signal_connect (priv->storage, "mount-point-removed",
+ G_CALLBACK (mount_point_removed_cb), controller);
+
+ priv->initialization_cond = g_cond_new ();
+ priv->initialization_mutex = g_mutex_new ();
+}
+
+static void
+handle_method_call_get_pid (TrackerController *controller,
+ GDBusMethodInvocation *invocation,
+ GVariant *parameters)
+{
+ TrackerDBusRequest *request;
+ pid_t value;
+
+ request = tracker_g_dbus_request_begin (invocation,
+ "%s()",
+ __FUNCTION__);
+
+ reset_shutdown_timeout (controller);
+ value = getpid ();
+ tracker_dbus_request_debug (request,
+ "PID is %d",
+ value);
+
+ tracker_dbus_request_end (request, NULL);
+
+ g_dbus_method_invocation_return_value (invocation,
+ g_variant_new ("(i)", (gint) value));
+}
+
+static void
+perform_writeback_cb (GObject *object,
+ GAsyncResult *res,
+ gpointer user_data)
+{
+ TrackerControllerPrivate *priv;
+ WritebackData *data;
+
+ data = user_data;
+ priv = data->controller->priv;
+ priv->ongoing_tasks = g_list_remove (priv->ongoing_tasks, data);
+// info = g_simple_async_result_get_op_res_gpointer (G_SIMPLE_ASYNC_RESULT (res));
+
+// if (info) {
+ if (TRUE) {
+ g_dbus_method_invocation_return_value (data->invocation, NULL);
+
+ tracker_dbus_request_end (data->request, NULL);
+ } else {
+ GError *error = NULL;
+
+#ifdef THREAD_ENABLE_TRACE
+ g_debug ("Thread:%p (Controller) --> Got error back",
+ g_thread_self ());
+#endif /* THREAD_ENABLE_TRACE */
+
+ g_simple_async_result_propagate_error (G_SIMPLE_ASYNC_RESULT (res), &error);
+ tracker_dbus_request_end (data->request, error);
+ g_dbus_method_invocation_return_gerror (data->invocation, error);
+ g_error_free (error);
+ }
+
+ writeback_data_free (data);
+}
+
+static gboolean
+sparql_rdf_types_match (const gchar * const *module_types,
+ const gchar * const *rdf_types)
+{
+ guint n;
+
+ for (n = 0; rdf_types[n] != NULL; n++) {
+ guint i;
+
+ for (i = 0; module_types[i] != NULL; i++) {
+ if (g_strcmp0 (module_types[i], rdf_types[n]) == 0) {
+ return TRUE;
+ }
+ }
+ }
+
+ return FALSE;
+}
+
+static void
+handle_method_call_perform_writeback (TrackerController *controller,
+ GDBusMethodInvocation *invocation,
+ GVariant *parameters)
+{
+ TrackerControllerPrivate *priv;
+ WritebackData *data;
+ TrackerDBusRequest *request;
+ const gchar *subject;
+ GPtrArray *results = NULL;
+ GHashTableIter iter;
+ gpointer key, value;
+ GVariantIter *iter1, *iter2, *iter3;
+ GArray *rdf_types_array;
+ GStrv rdf_types;
+ gchar *rdf_type = NULL;
+
+ priv = controller->priv;
+
+ results = g_ptr_array_new_with_free_func ((GDestroyNotify) g_strfreev);
+ g_variant_get (parameters, "(&sasaas)", &subject, &iter1, &iter2);
+
+ rdf_types_array = g_array_new (TRUE, TRUE, sizeof (gchar *));
+ while (g_variant_iter_loop (iter1, "&s", &rdf_type)) {
+ g_array_append_val (rdf_types_array, rdf_type);
+ }
+
+ rdf_types = (GStrv) rdf_types_array->data;
+ g_array_free (rdf_types_array, FALSE);
+
+ while (g_variant_iter_loop (iter2, "as", &iter3)) {
+ GArray *row_array = g_array_new (TRUE, TRUE, sizeof (gchar *));
+ gchar *cell = NULL;
+
+ while (g_variant_iter_loop (iter3, "&s", &cell)) {
+ g_array_append_val (row_array, cell);
+ }
+
+ g_ptr_array_add (results, row_array->data);
+ g_array_free (row_array, FALSE);
+ }
+
+ g_variant_iter_free (iter1);
+ g_variant_iter_free (iter2);
+
+ reset_shutdown_timeout (controller);
+ request = tracker_dbus_request_begin (NULL, "%s (%s)", __FUNCTION__, subject);
+
+ g_hash_table_iter_init (&iter, priv->modules);
+
+ data = writeback_data_new (controller, subject, results, invocation, request);
+
+ while (g_hash_table_iter_next (&iter, &key, &value)) {
+ TrackerWritebackModule *module;
+ const gchar * const *module_types;
+
+ module = value;
+ module_types = tracker_writeback_module_get_rdf_types (module);
+
+ if (sparql_rdf_types_match (module_types, (const gchar * const *) rdf_types)) {
+ TrackerWriteback *writeback;
+
+ g_message (" Updating metadata for subject:'%s' using module:'%s'",
+ subject,
+ module->name);
+
+ writeback = tracker_writeback_module_create (module);
+
+#warning todo here
+ // todo: make this really async using ie. g_io_scheduler_push_job
+ tracker_writeback_update_metadata (writeback, results, priv->connection);
+ g_object_unref (writeback);
+ }
+ }
+
+ priv->ongoing_tasks = g_list_prepend (priv->ongoing_tasks, data);
+
+ // todo: make this really async
+ perform_writeback_cb (NULL, NULL, data);
+
+ g_free (rdf_types);
+}
+
+static void
+handle_method_call_cancel_tasks (TrackerController *controller,
+ GDBusMethodInvocation *invocation,
+ GVariant *parameters)
+{
+ TrackerDBusRequest *request;
+ gchar **uris;
+ gint i;
+
+#ifdef THREAD_ENABLE_TRACE
+ g_debug ("Thread:%p (Controller) --> Got Tasks cancellation request",
+ g_thread_self ());
+#endif /* THREAD_ENABLE_TRACE */
+
+
+ g_variant_get (parameters, "(^as)", &uris);
+
+ request = tracker_dbus_request_begin (NULL, "%s (%s, ...)", __FUNCTION__, uris[0]);
+
+ for (i = 0; uris[i] != NULL; i++) {
+ GFile *file;
+
+ file = g_file_new_for_uri (uris[i]);
+ cancel_tasks_in_file (controller, file);
+ g_object_unref (file);
+ }
+
+ g_strfreev (uris);
+ tracker_dbus_request_end (request, NULL);
+ g_dbus_method_invocation_return_value (invocation, NULL);
+}
+
+static void
+handle_method_call (GDBusConnection *connection,
+ const gchar *sender,
+ const gchar *object_path,
+ const gchar *interface_name,
+ const gchar *method_name,
+ GVariant *parameters,
+ GDBusMethodInvocation *invocation,
+ gpointer user_data)
+{
+ TrackerController *controller = user_data;
+
+ if (g_strcmp0 (method_name, "GetPid") == 0) {
+ handle_method_call_get_pid (controller, invocation, parameters);
+ } else if (g_strcmp0 (method_name, "PerformWriteback") == 0) {
+ handle_method_call_perform_writeback (controller, invocation, parameters);
+ } else if (g_strcmp0 (method_name, "CancelTasks") == 0) {
+ handle_method_call_cancel_tasks (controller, invocation, parameters);
+ } else {
+ g_warning ("Unknown method '%s' called", method_name);
+ }
+}
+
+static void
+controller_notify_main_thread (TrackerController *controller,
+ GError *error)
+{
+ TrackerControllerPrivate *priv;
+
+ priv = controller->priv;
+
+ g_mutex_lock (priv->initialization_mutex);
+
+ priv->initialized = TRUE;
+ priv->initialization_error = error;
+
+ /* Notify about the initialization */
+ g_cond_signal (priv->initialization_cond);
+
+ g_mutex_unlock (priv->initialization_mutex);
+}
+
+static void
+bus_name_acquired_cb (GDBusConnection *connection,
+ const gchar *name,
+ gpointer user_data)
+{
+ controller_notify_main_thread (TRACKER_CONTROLLER (user_data), NULL);
+}
+
+static void
+bus_name_vanished_cb (GDBusConnection *connection,
+ const gchar *name,
+ gpointer user_data)
+{
+ TrackerController *controller;
+ TrackerControllerPrivate *priv;
+
+ controller = user_data;
+ priv = controller->priv;
+
+ if (!priv->initialized) {
+ GError *error;
+
+ error = g_error_new_literal (TRACKER_DBUS_ERROR, 0,
+ "Could not acquire bus name, "
+ "perhaps it's already taken?");
+ controller_notify_main_thread (controller, error);
+ } else {
+ /* We're already in control of the program
+ * lifetime, so just quit the mainloop
+ */
+ g_main_loop_quit (priv->main_loop);
+ }
+}
+
+static gboolean
+tracker_controller_dbus_start (TrackerController *controller,
+ GError **error)
{
- if (!manager) {
- manager = tracker_miner_manager_new ();
+ TrackerControllerPrivate *priv;
+ GError *err = NULL;
+ GDBusInterfaceVTable interface_vtable = {
+ handle_method_call,
+ NULL, NULL
+ };
+
+ priv = controller->priv;
+
+ priv->connection = tracker_sparql_connection_get (NULL, &err);
+
+ if (!priv->connection) {
+ g_propagate_error (error, err);
+ return FALSE;
}
- return manager;
+ priv->d_connection = g_bus_get_sync (G_BUS_TYPE_SESSION, NULL, &err);
+
+ if (!priv->d_connection) {
+ g_propagate_error (error, err);
+ return FALSE;
+ }
+
+ priv->introspection_data = g_dbus_node_info_new_for_xml (introspection_xml, &err);
+ if (!priv->introspection_data) {
+ g_propagate_error (error, err);
+ return FALSE;
+ }
+
+ g_message ("Registering D-Bus object...");
+ g_message (" Path:'" TRACKER_WRITEBACK_PATH "'");
+ g_message (" Object Type:'%s'", G_OBJECT_TYPE_NAME (controller));
+
+ priv->bus_name_id =
+ g_bus_own_name_on_connection (priv->d_connection,
+ TRACKER_WRITEBACK_SERVICE,
+ G_BUS_NAME_OWNER_FLAGS_NONE,
+ bus_name_acquired_cb,
+ bus_name_vanished_cb,
+ controller, NULL);
+
+ priv->registration_id =
+ g_dbus_connection_register_object (priv->d_connection,
+ TRACKER_WRITEBACK_PATH,
+ priv->introspection_data->interfaces[0],
+ &interface_vtable,
+ controller,
+ NULL,
+ &err);
+
+ if (err) {
+ g_propagate_error (error, err);
+ return FALSE;
+ }
+
+ return TRUE;
+}
+
+static void
+tracker_controller_dbus_stop (TrackerController *controller)
+{
+ TrackerControllerPrivate *priv;
+
+ priv = controller->priv;
+
+ if (priv->registration_id != 0) {
+ g_dbus_connection_unregister_object (priv->d_connection,
+ priv->registration_id);
+ }
+
+ if (priv->bus_name_id != 0) {
+ g_bus_unown_name (priv->bus_name_id);
+ }
+
+ if (priv->introspection_data) {
+ g_dbus_node_info_unref (priv->introspection_data);
+ }
+
+ if (priv->d_connection) {
+ g_object_unref (priv->d_connection);
+ }
+
+ if (priv->connection) {
+ g_object_unref (priv->connection);
+ }
+}
+
+TrackerController *
+tracker_controller_new (guint shutdown_timeout,
+ GError **error)
+{
+ return g_initable_new (TRACKER_TYPE_CONTROLLER,
+ NULL, error,
+ "shutdown-timeout", shutdown_timeout,
+ NULL);
+}
+
+static gpointer
+tracker_controller_thread_func (gpointer user_data)
+{
+ TrackerController *controller;
+ TrackerControllerPrivate *priv;
+ GError *error = NULL;
+
+#ifdef THREAD_ENABLE_TRACE
+ g_debug ("Thread:%p (Controller) --- Created, dispatching...",
+ g_thread_self ());
+#endif /* THREAD_ENABLE_TRACE */
+
+ controller = user_data;
+ priv = controller->priv;
+ g_main_context_push_thread_default (priv->context);
+
+ reset_shutdown_timeout (controller);
+
+ if (!tracker_controller_dbus_start (controller, &error)) {
+ /* Error has been filled in, so we return
+ * in this thread. The main thread will be
+ * notified about the error and exit.
+ */
+ controller_notify_main_thread (controller, error);
+ return NULL;
+ }
+
+ g_main_loop_run (priv->main_loop);
+
+#ifdef THREAD_ENABLE_TRACE
+ g_debug ("Thread:%p (Controller) --- Shutting down...",
+ g_thread_self ());
+#endif /* THREAD_ENABLE_TRACE */
+
+ g_object_unref (controller);
+
+ /* This is where we exit, be it
+ * either through umount events on monitored
+ * files' volumes or the timeout being reached
+ */
+ exit (0);
+ return NULL;
+}
+
+static gboolean
+tracker_controller_start (TrackerController *controller,
+ GError **error)
+{
+ TrackerControllerPrivate *priv;
+ GList *modules;
+
+ priv = controller->priv;
+
+ priv->modules = g_hash_table_new_full (g_str_hash,
+ g_str_equal,
+ (GDestroyNotify) g_free,
+ NULL);
+
+ modules = tracker_writeback_modules_list ();
+
+ while (modules) {
+ TrackerWritebackModule *module;
+ const gchar *path;
+
+ path = modules->data;
+ module = tracker_writeback_module_get (path);
+
+ if (module) {
+ g_hash_table_insert (priv->modules, g_strdup (path), module);
+ }
+
+ modules = modules->next;
+ }
+
+ if (!g_thread_create (tracker_controller_thread_func,
+ controller, FALSE, error)) {
+ return FALSE;
+ }
+
+
+#ifdef THREAD_ENABLE_TRACE
+ g_debug ("Thread:%p (Controller) --- Waiting for controller thread to initialize...",
+ g_thread_self ());
+#endif /* THREAD_ENABLE_TRACE */
+
+ /* Wait for the controller thread to notify initialization */
+ g_mutex_lock (priv->initialization_mutex);
+
+ while (!priv->initialized) {
+ g_cond_wait (priv->initialization_cond, priv->initialization_mutex);
+ }
+
+ g_mutex_unlock (priv->initialization_mutex);
+
+ /* If there was any error resulting from initialization, propagate it */
+ if (priv->initialization_error != NULL) {
+ g_propagate_error (error, priv->initialization_error);
+ return FALSE;
+ }
+
+#ifdef THREAD_ENABLE_TRACE
+ g_debug ("Thread:%p (Controller) --- Initialized",
+ g_thread_self ());
+#endif /* THREAD_ENABLE_TRACE */
+
+ return TRUE;
}
diff --git a/src/tracker-writeback/tracker-writeback.h b/src/tracker-writeback/tracker-writeback.h
index c56d85e..371a947 100644
--- a/src/tracker-writeback/tracker-writeback.h
+++ b/src/tracker-writeback/tracker-writeback.h
@@ -1,64 +1,56 @@
/*
- * Copyright (C) 2009, Nokia <ivan frade nokia com>
+ * Copyright (C) 2011, Nokia <ivan frade nokia com>
*
* This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public
+ * modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
+ * version 2.1 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.
+ * Lesser General Public License for more details.
*
- * You should have received a copy of the GNU General Public
+ * You should have received a copy of the GNU Lesser 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_WRITEBACK_WRITEBACK_H__
-#define __TRACKER_WRITEBACK_WRITEBACK_H__
+#ifndef __TRACKER_CONTROLLER_H__
+#define __TRACKER_CONTROLLER_H__
-#include <glib-object.h>
+#include <gio/gio.h>
-#include <libtracker-miner/tracker-miner.h>
-#include <libtracker-sparql/tracker-sparql.h>
+/* Not needed, but for now this keeps #include API backward compatible */
+#include "tracker-writeback-module.h"
G_BEGIN_DECLS
-#define TRACKER_TYPE_WRITEBACK (tracker_writeback_get_type())
-#define TRACKER_WRITEBACK(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), TRACKER_TYPE_WRITEBACK, TrackerWriteback))
-#define TRACKER_WRITEBACK_CLASS(c) (G_TYPE_CHECK_CLASS_CAST ((c), TRACKER_TYPE_WRITEBACK, TrackerWritebackClass))
-#define TRACKER_IS_WRITEBACK(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), TRACKER_TYPE_WRITEBACK))
-#define TRACKER_IS_WRITEBACK_CLASS(c) (G_TYPE_CHECK_CLASS_TYPE ((c), TRACKER_TYPE_WRITEBACK))
-#define TRACKER_WRITEBACK_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), TRACKER_TYPE_WRITEBACK, TrackerWritebackClass))
+#define TRACKER_TYPE_CONTROLLER (tracker_controller_get_type ())
+#define TRACKER_CONTROLLER(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), TRACKER_TYPE_CONTROLLER, TrackerController))
+#define TRACKER_CONTROLLER_CLASS(c) (G_TYPE_CHECK_CLASS_CAST ((c), TRACKER_TYPE_CONTROLLER, TrackerControllerClass))
+#define TRACKER_IS_CONTROLLER(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), TRACKER_TYPE_CONTROLLER))
+#define TRACKER_IS_CONTROLLER_CLASS(c) (G_TYPE_CHECK_CLASS_TYPE ((c), TRACKER_TYPE_CONTROLLER))
+#define TRACKER_CONTROLLER_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), TRACKER_TYPE_CONTROLLER, TrackerControllerClass))
-typedef struct TrackerWriteback TrackerWriteback;
-typedef struct TrackerWritebackClass TrackerWritebackClass;
+typedef struct TrackerController TrackerController;
+typedef struct TrackerControllerClass TrackerControllerClass;
-struct TrackerWriteback {
+struct TrackerController {
GObject parent_instance;
+ gpointer priv;
};
-struct TrackerWritebackClass {
+struct TrackerControllerClass {
GObjectClass parent_class;
-
- gboolean (* update_metadata) (TrackerWriteback *writeback,
- GPtrArray *values,
- TrackerSparqlConnection *connection);
};
-GType tracker_writeback_get_type (void) G_GNUC_CONST;
-gboolean tracker_writeback_update_metadata (TrackerWriteback *writeback,
- GPtrArray *values,
- TrackerSparqlConnection *connection);
-TrackerMinerManager* tracker_writeback_get_miner_manager (void);
+GType tracker_controller_get_type (void) G_GNUC_CONST;
-/* Entry functions to be defined by modules */
-TrackerWriteback * writeback_module_create (GTypeModule *module);
-const gchar * const *writeback_module_get_rdf_types (void);
+TrackerController * tracker_controller_new (guint shutdown_timeout,
+ GError **error);
G_END_DECLS
-#endif /* __TRACKER_WRITEBACK_WRITEBACK_H__ */
+#endif /* __TRACKER_CONTROLLER_H__ */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]