[tracker/writeback-refactor-0.10: 1/64] miner/fs: Add an empty listener class for writeback
- From: Carlos Garnacho <carlosg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [tracker/writeback-refactor-0.10: 1/64] miner/fs: Add an empty listener class for writeback
- Date: Thu, 28 Jul 2011 15:35:32 +0000 (UTC)
commit eadb4a57d39435620df77c285db7cc00eddf8fda
Author: Philip Van Hoof <philip codeminded be>
Date: Thu Jul 7 12:57:43 2011 +0200
miner/fs: Add an empty listener class for writeback
src/miners/fs/Makefile.am | 8 +-
src/miners/fs/tracker-writeback-listener.c | 187 ++++++++++++++++++++++++++
src/miners/fs/tracker-writeback-listener.h | 53 +++++++
src/miners/fs/tracker-writeback.c | 70 ++++++++++
src/miners/fs/tracker-writeback.h | 38 +++++
5 files changed, 355 insertions(+), 1 deletions(-)
---
diff --git a/src/miners/fs/Makefile.am b/src/miners/fs/Makefile.am
index 4c6c9f2..ad4a44c 100644
--- a/src/miners/fs/Makefile.am
+++ b/src/miners/fs/Makefile.am
@@ -39,7 +39,13 @@ tracker_miner_fs_SOURCES = \
tracker-miner-files.c \
tracker-miner-files.h \
tracker-miner-files-index.c \
- tracker-miner-files-index.h
+ tracker-miner-files-index.h \
+ tracker-writeback-listener.c \
+ tracker-writeback-listener.h \
+ tracker-writeback-dispatcher.c \
+ tracker-writeback-dispatcher.h \
+ tracker-writeback.c \
+ tracker-writeback.h
tracker_miner_fs_LDADD = \
$(top_builddir)/src/libtracker-miner/libtracker-miner- TRACKER_API_VERSION@.la \
diff --git a/src/miners/fs/tracker-writeback-dispatcher.c b/src/miners/fs/tracker-writeback-dispatcher.c
new file mode 100644
index 0000000..e69de29
diff --git a/src/miners/fs/tracker-writeback-dispatcher.h b/src/miners/fs/tracker-writeback-dispatcher.h
new file mode 100644
index 0000000..e69de29
diff --git a/src/miners/fs/tracker-writeback-listener.c b/src/miners/fs/tracker-writeback-listener.c
new file mode 100644
index 0000000..b7daf77
--- /dev/null
+++ b/src/miners/fs/tracker-writeback-listener.c
@@ -0,0 +1,187 @@
+/*
+ * Copyright (C) 2010, 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
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#include "config.h"
+
+#include <libtracker-common/tracker-dbus.h>
+#include <libtracker-sparql/tracker-sparql.h>
+#include <libtracker-miner/tracker-miner-dbus.h>
+
+#include "tracker-writeback-listener.h"
+
+
+typedef struct {
+ TrackerMinerFiles *files_miner;
+ GDBusConnection *connection;
+} TrackerWritebackListenerPrivate;
+
+enum {
+ PROP_0,
+ PROP_FILES_MINER
+};
+
+#define TRACKER_WRITEBACK_LISTENER_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), TRACKER_TYPE_WRITEBACK_LISTENER, TrackerWritebackListenerPrivate))
+
+static void writeback_set_property (GObject *object,
+ guint param_id,
+ const GValue *value,
+ GParamSpec *pspec);
+static void writeback_get_property (GObject *object,
+ guint param_id,
+ GValue *value,
+ GParamSpec *pspec);
+static void writeback_finalize (GObject *object);
+static gboolean writeback_initable_init (GInitable *initable,
+ GCancellable *cancellable,
+ GError **error);
+
+static void
+writeback_initable_iface_init (GInitableIface *iface)
+{
+ iface->init = writeback_initable_init;
+}
+
+G_DEFINE_TYPE_WITH_CODE (TrackerWritebackListener, tracker_writeback_listener, G_TYPE_OBJECT,
+ G_IMPLEMENT_INTERFACE (G_TYPE_INITABLE,
+ writeback_initable_iface_init));
+
+static void
+tracker_writeback_listener_class_init (TrackerWritebackListenerClass *klass)
+{
+ GObjectClass *object_class;
+
+ object_class = G_OBJECT_CLASS (klass);
+
+ object_class->finalize = writeback_finalize;
+ object_class->set_property = writeback_set_property;
+ object_class->get_property = writeback_get_property;
+
+ g_object_class_install_property (object_class,
+ PROP_FILES_MINER,
+ g_param_spec_object ("files_miner",
+ "files_miner",
+ "The FS Miner",
+ TRACKER_TYPE_MINER_FILES,
+ G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
+
+ g_type_class_add_private (klass, sizeof (TrackerWritebackListenerPrivate));
+}
+
+static void
+writeback_set_property (GObject *object,
+ guint param_id,
+ const GValue *value,
+ GParamSpec *pspec)
+{
+ TrackerWritebackListenerPrivate *priv;
+
+ priv = TRACKER_WRITEBACK_LISTENER_GET_PRIVATE (object);
+
+ switch (param_id) {
+ case PROP_FILES_MINER:
+ priv->files_miner = g_value_dup_object (value);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
+ break;
+ }
+}
+
+
+static void
+writeback_get_property (GObject *object,
+ guint param_id,
+ GValue *value,
+ GParamSpec *pspec)
+{
+ TrackerWritebackListenerPrivate *priv;
+
+ priv = TRACKER_WRITEBACK_LISTENER_GET_PRIVATE (object);
+
+ switch (param_id) {
+ case PROP_FILES_MINER:
+ g_value_set_object (value, priv->files_miner);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
+ break;
+ }
+}
+
+static void
+writeback_finalize (GObject *object)
+{
+ TrackerWritebackListenerPrivate *priv = TRACKER_WRITEBACK_LISTENER_GET_PRIVATE (object);
+
+ if (priv->connection) {
+ g_object_unref (priv->connection);
+ }
+
+ g_object_unref (priv->files_miner);
+}
+
+
+static void
+tracker_writeback_listener_init (TrackerWritebackListener *object)
+{
+}
+
+static gboolean
+writeback_initable_init (GInitable *initable,
+ GCancellable *cancellable,
+ GError **error)
+{
+ TrackerWritebackListenerPrivate *priv;
+ GError *internal_error = NULL;
+
+ priv = TRACKER_WRITEBACK_LISTENER_GET_PRIVATE (initable);
+
+ priv->connection = g_bus_get_sync (G_BUS_TYPE_SESSION, NULL, &internal_error);
+
+ if (internal_error) {
+ g_propagate_error (error, internal_error);
+ return FALSE;
+ }
+
+ return TRUE;
+}
+
+TrackerWritebackListener *
+tracker_writeback_listener_new (TrackerMinerFiles *miner_files,
+ GError **error)
+{
+ GObject *miner;
+ GError *internal_error = NULL;
+
+ miner = g_initable_new (TRACKER_TYPE_WRITEBACK_LISTENER,
+ NULL,
+ &internal_error,
+ "files-miner", miner_files,
+ NULL);
+
+ if (internal_error) {
+ g_propagate_error (error, internal_error);
+ return NULL;
+ }
+
+ return (TrackerWritebackListener *) miner;
+}
+
+ // tracker_miner_fs_writeback_file (TRACKER_MINER_FS (miner_files), file, ...);
+
diff --git a/src/miners/fs/tracker-writeback-listener.h b/src/miners/fs/tracker-writeback-listener.h
new file mode 100644
index 0000000..ab1a94d
--- /dev/null
+++ b/src/miners/fs/tracker-writeback-listener.h
@@ -0,0 +1,53 @@
+/*
+ * Copyright (C) 2010, 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
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#ifndef __TRACKER_WRITEBACK_LISTENER_H__
+#define __TRACKER_WRITEBACK_LISTENER_H__
+
+#include <glib-object.h>
+
+#include "tracker-miner-files.h"
+
+G_BEGIN_DECLS
+
+#define TRACKER_TYPE_WRITEBACK_LISTENER (tracker_writeback_listener_get_type ())
+#define TRACKER_WRITEBACK_LISTENER(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), TRACKER_TYPE_WRITEBACK_LISTENER, TrackerWritebackListener))
+#define TRACKER_WRITEBACK_LISTENER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TRACKER_TYPE_DBUS_WRITEBACK_LISTENER, TrackerWritebackListenerClass))
+#define TRACKER_IS_WRITEBACK_LISTENER(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), TRACKER_TYPE_WRITEBACK_LISTENER))
+#define TRACKER_IS_WRITEBACK_LISTENER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TRACKER_TYPE_WRITEBACK_LISTENER))
+#define TRACKER_WRITEBACK_LISTENER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TRACKER_TYPE_WRITEBACK_LISTENER, TrackerWritebackListenerClass))
+
+typedef struct TrackerWritebackListener TrackerWritebackListener;
+typedef struct TrackerWritebackListenerClass TrackerWritebackListenerClass;
+
+struct TrackerWritebackListener {
+ GObject parent;
+};
+
+struct TrackerWritebackListenerClass {
+ GObjectClass parent;
+};
+
+GType tracker_writeback_listener_get_type (void);
+TrackerWritebackListener *tracker_writeback_listener_new (TrackerMinerFiles *miner_files,
+ GError **error);
+
+G_END_DECLS
+
+#endif /* __TRACKER_WRITEBACK_LISTENERINDEX_H__ */
diff --git a/src/miners/fs/tracker-writeback.c b/src/miners/fs/tracker-writeback.c
new file mode 100644
index 0000000..4bf4399
--- /dev/null
+++ b/src/miners/fs/tracker-writeback.c
@@ -0,0 +1,70 @@
+/*
+ * Copyright (C) 2008, 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
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#include "config.h"
+
+#include <gio/gio.h>
+
+#include "tracker-writeback.h"
+#include "tracker-writeback-listener.h"
+
+/* Listener listens for the Writeback signal coming from the store, it performs
+ * a few queries to get a set of changed values, and pushes the writeback task
+ * to miner-fs's queues. */
+static TrackerWritebackListener *listener = NULL;
+
+/* That task in miner-fs's queue callsback to the dispatcher. The dispatcher
+ * calls the external tracker-writeback process which does the actual write */
+
+// static void TrackerWritebackDispatcher *dispatcher = NULL;
+
+void
+tracker_writeback_init (TrackerMinerFiles *miner_files,
+ GError **error)
+{
+ GError *internal_error = NULL;
+
+ listener = tracker_writeback_listener_new (miner_files, &internal_error);
+
+// if (!internal_error) {
+// distpatcher = tracker_writeback_listener_new (miner_files, &internal_error);
+// }
+
+ if (internal_error) {
+ if (listener) {
+ g_object_unref (listener);
+ listener = NULL;
+ }
+ g_propagate_error (error, internal_error);
+ }
+}
+
+void
+tracker_writeback_shutdown (void)
+{
+ if (listener) {
+ g_object_unref (listener);
+ listener = NULL;
+ }
+
+// if (dispatcher) {
+// g_object_unref (dispatcher);
+// dispatcher = NULL;
+// }
+}
diff --git a/src/miners/fs/tracker-writeback.h b/src/miners/fs/tracker-writeback.h
new file mode 100644
index 0000000..0f7408f
--- /dev/null
+++ b/src/miners/fs/tracker-writeback.h
@@ -0,0 +1,38 @@
+/*
+ * Copyright (C) 2008, Nokia <ivan frade nokia com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * 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
+ * Lesser General Public License for more details.
+ *
+ * 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_H__
+#define __TRACKER_WRITEBACK_H__
+
+
+#include <libtracker-miner/tracker-miner.h>
+
+#include "tracker-config.h"
+
+#include "tracker-miner-files.h"
+
+G_BEGIN_DECLS
+
+void tracker_writeback_init (TrackerMinerFiles *miner_files,
+ GError **error);
+void tracker_writeback_shutdown (void);
+
+G_END_DECLS
+
+#endif /* __TRACKER_WRITEBACK_H__ */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]