[tracker/tracker-store] Added pausing back for the miner-fs for the applet
- From: Martyn James Russell <mr src gnome org>
- To: svn-commits-list gnome org
- Subject: [tracker/tracker-store] Added pausing back for the miner-fs for the applet
- Date: Mon, 29 Jun 2009 16:58:23 +0000 (UTC)
commit a1e3f2e25daa90859731b3f0333122c5a17ca796
Author: Martyn Russell <martyn imendio com>
Date: Mon Jun 29 17:36:08 2009 +0100
Added pausing back for the miner-fs for the applet
data/dbus/Makefile.am | 7 +-
data/dbus/tracker-miner.xml | 12 ++
src/tracker-miner-fs/Makefile.am | 3 +-
src/tracker-miner-fs/tracker-dbus.c | 2 +-
src/tracker-miner-fs/tracker-indexer.c | 91 +----------------
src/tracker-miner-fs/tracker-indexer.h | 12 +--
src/tracker-miner-fs/tracker-main.c | 12 ++-
src/tracker-miner-fs/tracker-miner.c | 182 ++++++++++++++++++++++++++++++++
src/tracker-miner-fs/tracker-miner.h | 74 +++++++++++++
9 files changed, 287 insertions(+), 108 deletions(-)
---
diff --git a/data/dbus/Makefile.am b/data/dbus/Makefile.am
index e547901..7aabdd2 100644
--- a/data/dbus/Makefile.am
+++ b/data/dbus/Makefile.am
@@ -5,10 +5,11 @@ configdir = $(datadir)/tracker
config_DATA = \
tracker-backup.xml \
tracker-daemon.xml \
- tracker-resources.xml \
- tracker-search.xml \
tracker-extract.xml \
- tracker-resources-class.xml
+ tracker-miner.xml \
+ tracker-resources.xml \
+ tracker-resources-class.xml \
+ tracker-search.xml
# Services
servicedir = $(DBUS_SERVICES_DIR)
diff --git a/data/dbus/tracker-miner.xml b/data/dbus/tracker-miner.xml
new file mode 100644
index 0000000..a44183d
--- /dev/null
+++ b/data/dbus/tracker-miner.xml
@@ -0,0 +1,12 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<node name="/">
+ <interface name="org.freedesktop.Tracker.Miner.FS">
+ <method name="Pause">
+ <annotation name="org.freedesktop.DBus.GLib.Async" value="true"/>
+ </method>
+ <method name="Continue">
+ <annotation name="org.freedesktop.DBus.GLib.Async" value="true"/>
+ </method>
+ </interface>
+</node>
diff --git a/src/tracker-miner-fs/Makefile.am b/src/tracker-miner-fs/Makefile.am
index 8c7581f..9cdd82d 100644
--- a/src/tracker-miner-fs/Makefile.am
+++ b/src/tracker-miner-fs/Makefile.am
@@ -53,6 +53,7 @@ tracker_miner_fs_SOURCES = \
tracker-indexer-module.h \
tracker-main.c \
tracker-marshal-main.c \
+ tracker-miner.c \
tracker-monitor.c \
tracker-monitor.h \
tracker-processor.c \
@@ -94,7 +95,7 @@ marshal_sources = \
tracker-marshal.c
dbus_sources = \
- tracker-indexer-glue.h \
+ tracker-miner-glue.h \
tracker-extract-client.h
%-glue.h: $(top_srcdir)/data/dbus/%.xml
diff --git a/src/tracker-miner-fs/tracker-dbus.c b/src/tracker-miner-fs/tracker-dbus.c
index 938f8f0..b87068b 100644
--- a/src/tracker-miner-fs/tracker-dbus.c
+++ b/src/tracker-miner-fs/tracker-dbus.c
@@ -146,7 +146,7 @@ dbus_register_names (void)
DBUS_INTERFACE_DBUS);
/* Register the service name for org.freedesktop.Tracker */
- if (!dbus_register_service (gproxy, "org.freedesktop.Tracker.Indexer")) {
+ if (!dbus_register_service (gproxy, "org.freedesktop.Tracker.Miner.FS")) {
return FALSE;
}
diff --git a/src/tracker-miner-fs/tracker-indexer.c b/src/tracker-miner-fs/tracker-indexer.c
index 52615f0..973731e 100644
--- a/src/tracker-miner-fs/tracker-indexer.c
+++ b/src/tracker-miner-fs/tracker-indexer.c
@@ -1864,106 +1864,19 @@ tracker_indexer_stop (TrackerIndexer *indexer)
}
void
-tracker_indexer_pause (TrackerIndexer *indexer,
- DBusGMethodInvocation *context,
- GError **error)
+tracker_indexer_pause (TrackerIndexer *indexer)
{
- guint request_id;
-
- request_id = tracker_dbus_get_next_request_id ();
-
- tracker_dbus_async_return_if_fail (TRACKER_IS_INDEXER (indexer), context);
-
- tracker_dbus_request_new (request_id,
- "DBus request to pause the indexer");
-
if (tracker_indexer_get_running (indexer)) {
- tracker_dbus_request_comment (request_id,
- "Pausing indexing");
-
tracker_indexer_set_running (indexer, FALSE);
}
-
- dbus_g_method_return (context);
-
- tracker_dbus_request_success (request_id);
-}
-
-static gboolean
-pause_for_duration_cb (gpointer user_data)
-{
- TrackerIndexer *indexer;
-
- indexer = TRACKER_INDEXER (user_data);
-
- tracker_indexer_set_running (indexer, TRUE);
- indexer->private->pause_for_duration_id = 0;
-
- return FALSE;
}
void
-tracker_indexer_pause_for_duration (TrackerIndexer *indexer,
- guint seconds,
- DBusGMethodInvocation *context,
- GError **error)
+tracker_indexer_continue (TrackerIndexer *indexer)
{
- guint request_id;
-
- request_id = tracker_dbus_get_next_request_id ();
-
- tracker_dbus_async_return_if_fail (TRACKER_IS_INDEXER (indexer), context);
-
- tracker_dbus_request_new (request_id,
- "DBus request to pause the indexer for %d seconds",
- seconds);
-
- if (tracker_indexer_get_running (indexer)) {
- if (indexer->private->in_transaction) {
- tracker_dbus_request_comment (request_id,
- "Committing transactions");
- }
-
- tracker_dbus_request_comment (request_id,
- "Pausing indexing");
-
- tracker_indexer_set_running (indexer, FALSE);
-
- indexer->private->pause_for_duration_id =
- g_timeout_add_seconds (seconds,
- pause_for_duration_cb,
- indexer);
- }
-
- dbus_g_method_return (context);
-
- tracker_dbus_request_success (request_id);
-}
-
-void
-tracker_indexer_continue (TrackerIndexer *indexer,
- DBusGMethodInvocation *context,
- GError **error)
-{
- guint request_id;
-
- request_id = tracker_dbus_get_next_request_id ();
-
- tracker_dbus_async_return_if_fail (TRACKER_IS_INDEXER (indexer), context);
-
- tracker_dbus_request_new (request_id,
- "DBus request to continue the indexer");
-
if (tracker_indexer_get_running (indexer) == FALSE) {
- tracker_dbus_request_comment (request_id,
- "Continuing indexing");
-
tracker_indexer_set_running (indexer, TRUE);
}
-
- dbus_g_method_return (context);
-
- tracker_dbus_request_success (request_id);
}
void
diff --git a/src/tracker-miner-fs/tracker-indexer.h b/src/tracker-miner-fs/tracker-indexer.h
index d52734d..58c4505 100644
--- a/src/tracker-miner-fs/tracker-indexer.h
+++ b/src/tracker-miner-fs/tracker-indexer.h
@@ -91,18 +91,10 @@ void tracker_indexer_process_modules (TrackerIndexer *ind
gchar **modules);
void tracker_indexer_transaction_commit (TrackerIndexer *indexer);
void tracker_indexer_transaction_open (TrackerIndexer *indexer);
+void tracker_indexer_pause (TrackerIndexer *indexer);
+void tracker_indexer_continue (TrackerIndexer *indexer);
/* DBus methods */
-void tracker_indexer_pause (TrackerIndexer *indexer,
- DBusGMethodInvocation *context,
- GError **error);
-void tracker_indexer_pause_for_duration (TrackerIndexer *indexer,
- guint seconds,
- DBusGMethodInvocation *context,
- GError **error);
-void tracker_indexer_continue (TrackerIndexer *indexer,
- DBusGMethodInvocation *context,
- GError **error);
void tracker_indexer_files_check (TrackerIndexer *indexer,
const gchar *module,
GStrv files);
diff --git a/src/tracker-miner-fs/tracker-main.c b/src/tracker-miner-fs/tracker-main.c
index 9f7cd7d..3cb5c14 100644
--- a/src/tracker-miner-fs/tracker-main.c
+++ b/src/tracker-miner-fs/tracker-main.c
@@ -50,7 +50,8 @@
#include "tracker-dbus.h"
#include "tracker-indexer.h"
-#include "tracker-indexer-glue.h"
+#include "tracker-miner.h"
+#include "tracker-miner-glue.h"
#define ABOUT \
"Tracker " PACKAGE_VERSION "\n"
@@ -236,6 +237,7 @@ main (gint argc, gchar *argv[])
TrackerConfig *config;
TrackerLanguage *language;
TrackerIndexer *indexer;
+ TrackerMiner *miner;
GOptionContext *context;
GError *error = NULL;
gchar *filename;
@@ -325,11 +327,12 @@ main (gint argc, gchar *argv[])
}
indexer = tracker_indexer_new ();
+ miner = tracker_miner_new (indexer);
/* Make Tracker available for introspection */
- if (!tracker_dbus_register_object (G_OBJECT (indexer),
- &dbus_glib_tracker_indexer_object_info,
- TRACKER_INDEXER_PATH)) {
+ if (!tracker_dbus_register_object (G_OBJECT (miner),
+ &dbus_glib_tracker_miner_object_info,
+ TRACKER_MINER_PATH)) {
return EXIT_FAILURE;
}
@@ -366,6 +369,7 @@ main (gint argc, gchar *argv[])
g_main_loop_unref (main_loop);
g_object_unref (indexer);
+ g_object_unref (miner);
g_object_unref (config);
g_object_unref (language);
diff --git a/src/tracker-miner-fs/tracker-miner.c b/src/tracker-miner-fs/tracker-miner.c
new file mode 100644
index 0000000..ee5fa2c
--- /dev/null
+++ b/src/tracker-miner-fs/tracker-miner.c
@@ -0,0 +1,182 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+/*
+ * Copyright (C) 2009, Nokia
+
+ * 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 "tracker-miner.h"
+
+#define TRACKER_MINER_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), TRACKER_TYPE_MINER, TrackerMinerPrivate))
+
+struct TrackerMinerPrivate {
+ TrackerIndexer *indexer;
+};
+
+enum {
+ PROP_0,
+ PROP_RUNNING,
+};
+
+enum {
+ PAUSED,
+ CONTINUED,
+ LAST_SIGNAL
+};
+
+static guint signals[LAST_SIGNAL] = { 0, };
+
+G_DEFINE_TYPE (TrackerMiner, tracker_miner, G_TYPE_OBJECT)
+
+static void
+tracker_miner_init (TrackerMiner *miner)
+{
+}
+
+static void
+tracker_miner_finalize (GObject *object)
+{
+ TrackerMinerPrivate *priv;
+
+ priv = TRACKER_MINER_GET_PRIVATE (object);
+
+ if (priv->indexer) {
+ g_object_unref (priv->indexer);
+ }
+
+ G_OBJECT_CLASS (tracker_miner_parent_class)->finalize (object);
+}
+
+static void
+tracker_miner_get_property (GObject *object,
+ guint prop_id,
+ GValue *value,
+ GParamSpec *pspec)
+{
+ switch (prop_id) {
+ case PROP_RUNNING:
+ g_value_set_boolean (value, TRUE);
+ /* tracker_miner_get_running (TRACKER_MINER (object))); */
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ }
+}
+
+static void
+tracker_miner_class_init (TrackerMinerClass *class)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS (class);
+
+ object_class->finalize = tracker_miner_finalize;
+ object_class->get_property = tracker_miner_get_property;
+
+ signals[PAUSED] =
+ g_signal_new ("paused",
+ G_OBJECT_CLASS_TYPE (object_class),
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (TrackerMinerClass, paused),
+ NULL, NULL,
+ g_cclosure_marshal_VOID__STRING,
+ G_TYPE_NONE,
+ 0);
+ signals[CONTINUED] =
+ g_signal_new ("continued",
+ G_OBJECT_CLASS_TYPE (object_class),
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (TrackerMinerClass, continued),
+ 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",
+ "Running",
+ "Whether the miner is running",
+ TRUE,
+ G_PARAM_READABLE));
+
+ g_type_class_add_private (object_class, sizeof (TrackerMinerPrivate));
+}
+
+TrackerMiner *
+tracker_miner_new (TrackerIndexer *indexer)
+{
+ TrackerMiner *miner;
+ TrackerMinerPrivate *priv;
+
+ g_return_val_if_fail (TRACKER_IS_INDEXER (indexer), NULL);
+
+ miner = g_object_new (TRACKER_TYPE_MINER, NULL);
+
+ priv = TRACKER_MINER_GET_PRIVATE (miner);
+
+ priv->indexer = g_object_ref (indexer);
+
+ return miner;
+}
+
+void
+tracker_miner_pause (TrackerMiner *miner,
+ DBusGMethodInvocation *context,
+ GError **error)
+{
+ TrackerMinerPrivate *priv;
+ guint request_id;
+
+ priv = TRACKER_MINER_GET_PRIVATE (miner);
+
+ request_id = tracker_dbus_get_next_request_id ();
+
+ tracker_dbus_async_return_if_fail (TRACKER_IS_MINER (miner), context);
+
+ tracker_dbus_request_new (request_id, "%s", __FUNCTION__);
+
+ tracker_indexer_pause (priv->indexer);
+
+ dbus_g_method_return (context);
+
+ tracker_dbus_request_success (request_id);
+}
+
+void
+tracker_miner_continue (TrackerMiner *miner,
+ DBusGMethodInvocation *context,
+ GError **error)
+{
+ TrackerMinerPrivate *priv;
+ guint request_id;
+
+ priv = TRACKER_MINER_GET_PRIVATE (miner);
+
+ request_id = tracker_dbus_get_next_request_id ();
+
+ tracker_dbus_async_return_if_fail (TRACKER_IS_MINER (miner), context);
+
+ tracker_dbus_request_new (request_id, "%s", __FUNCTION__);
+
+ tracker_indexer_continue (priv->indexer);
+
+ dbus_g_method_return (context);
+
+ tracker_dbus_request_success (request_id);
+}
diff --git a/src/tracker-miner-fs/tracker-miner.h b/src/tracker-miner-fs/tracker-miner.h
new file mode 100644
index 0000000..7b044e4
--- /dev/null
+++ b/src/tracker-miner-fs/tracker-miner.h
@@ -0,0 +1,74 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+/*
+ * Copyright (C) 2009, Nokia
+
+ * 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_MINER_H__
+#define __TRACKER_MINER_H__
+
+#include <glib-object.h>
+#include <dbus/dbus-glib.h>
+
+#include "tracker-indexer.h"
+
+#define TRACKER_MINER_SERVICE "org.freedesktop.Tracker.Miner.FS"
+#define TRACKER_MINER_PATH "/org/freedesktop/Tracker/Miner/FS"
+#define TRACKER_MINER_INTERFACE "org.freedesktop.Tracker.Miner.FS"
+
+G_BEGIN_DECLS
+
+#define TRACKER_TYPE_MINER (tracker_miner_get_type())
+#define TRACKER_MINER(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), TRACKER_TYPE_MINER, TrackerMiner))
+#define TRACKER_MINER_CLASS(c) (G_TYPE_CHECK_CLASS_CAST ((c), TRACKER_TYPE_MINER, TrackerMinerClass))
+#define TRACKER_IS_MINER(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), TRACKER_TYPE_MINER))
+#define TRACKER_IS_MINER_CLASS(c) (G_TYPE_CHECK_CLASS_TYPE ((c), TRACKER_TYPE_MINER))
+#define TRACKER_MINER_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), TRACKER_TYPE_MINER, TrackerMinerClass))
+
+typedef struct TrackerMiner TrackerMiner;
+typedef struct TrackerMinerClass TrackerMinerClass;
+typedef struct TrackerMinerPrivate TrackerMinerPrivate;
+
+struct TrackerMiner {
+ GObject parent_instance;
+
+ /* Private struct */
+ TrackerMinerPrivate *private;
+};
+
+struct TrackerMinerClass {
+ GObjectClass parent_class;
+
+ void (*paused) (TrackerMiner *miner);
+ void (*continued)(TrackerMiner *miner);
+};
+
+GType tracker_miner_get_type (void) G_GNUC_CONST;
+TrackerMiner *tracker_miner_new (TrackerIndexer *indexer);
+
+
+/* DBus methods */
+void tracker_miner_pause (TrackerMiner *miner,
+ DBusGMethodInvocation *context,
+ GError **error);
+void tracker_miner_continue (TrackerMiner *miner,
+ DBusGMethodInvocation *context,
+ GError **error);
+
+G_END_DECLS
+
+#endif /* __TRACKER_MINER_H__ */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]