[tracker/miner-userguide: 1/15] tracker-miner-fs: Added initial boiler plate for userguide miner



commit 540478bbfc2201ba78e9e5f20e3a094608b8e1e1
Author: Martyn Russell <martyn lanedo com>
Date:   Tue Nov 22 13:14:32 2011 +0000

    tracker-miner-fs: Added initial boiler plate for userguide miner
    
    This requires --enable-maemo to build.

 data/dbus/Makefile.am                              |    7 +
 ...reedesktop.Tracker1.Miner.Userguides.service.in |    3 +
 data/miners/Makefile.am                            |    6 +
 data/miners/tracker-miner-userguides.desktop.in.in |    6 +
 src/miners/fs/Makefile.am                          |    6 +
 src/miners/fs/tracker-main.c                       |   52 +++-
 src/miners/fs/tracker-miner-userguides.c           |  470 ++++++++++++++++++++
 src/miners/fs/tracker-miner-userguides.h           |   54 +++
 8 files changed, 603 insertions(+), 1 deletions(-)
---
diff --git a/data/dbus/Makefile.am b/data/dbus/Makefile.am
index a809137..d43d5da 100644
--- a/data/dbus/Makefile.am
+++ b/data/dbus/Makefile.am
@@ -26,6 +26,10 @@ service_in_files = \
 	org.freedesktop.Tracker1.Extract.service.in \
 	org.freedesktop.Tracker1.Writeback.service.in
 
+if HAVE_MAEMO
+service_in_files += org.freedesktop.Tracker1.Miner.Userguides.service.in
+endif
+
 %.service: %.service.in
 	@sed -e "s|@libexecdir[ ]|${libexecdir}|" $< > $@
 
@@ -38,6 +42,9 @@ service_DATA = \
 	org.freedesktop.Tracker1.Extract.service \
 	org.freedesktop.Tracker1.Writeback.service
 
+if HAVE_MAEMO
+service_DATA += org.freedesktop.Tracker1.Miner.Userguides.service
+endif
 
 if HAVE_TRACKER_MINER_EVOLUTION
 service_DATA += org.freedesktop.Tracker1.Miner.EMails.service
diff --git a/data/dbus/org.freedesktop.Tracker1.Miner.Userguides.service.in b/data/dbus/org.freedesktop.Tracker1.Miner.Userguides.service.in
new file mode 100644
index 0000000..423d865
--- /dev/null
+++ b/data/dbus/org.freedesktop.Tracker1.Miner.Userguides.service.in
@@ -0,0 +1,3 @@
+[D-BUS Service]
+Name=org.freedesktop.Tracker1.Miner.Userguides
+Exec= libexecdir@/tracker-miner-fs
diff --git a/data/miners/Makefile.am b/data/miners/Makefile.am
index be36aa4..0bfbb6c 100644
--- a/data/miners/Makefile.am
+++ b/data/miners/Makefile.am
@@ -1,6 +1,7 @@
 include $(top_srcdir)/Makefile.decl
 
 desktop_in_in_files =                                  \
+	tracker-miner-userguides.desktop.in.in         \
 	tracker-miner-applications.desktop.in.in       \
 	tracker-miner-evolution.desktop.in.in          \
 	tracker-miner-files.desktop.in.in              \
@@ -8,6 +9,7 @@ desktop_in_in_files =                                  \
 	tracker-miner-rss.desktop.in.in
 
 desktop_in_files =                                     \
+	tracker-miner-userguides.desktop.in            \
 	tracker-miner-applications.desktop.in          \
 	tracker-miner-evolution.desktop.in             \
 	tracker-miner-files.desktop.in                 \
@@ -20,6 +22,10 @@ tracker_miners_DATA =                                  \
 	tracker-miner-applications.desktop             \
 	tracker-miner-files.desktop
 
+if HAVE_MAEMO
+tracker_miners_DATA += tracker-miner-userguides.desktop
+endif
+
 if HAVE_TRACKER_MINER_EVOLUTION
 tracker_miners_DATA += tracker-miner-evolution.desktop
 endif
diff --git a/data/miners/tracker-miner-userguides.desktop.in.in b/data/miners/tracker-miner-userguides.desktop.in.in
new file mode 100644
index 0000000..16634bd
--- /dev/null
+++ b/data/miners/tracker-miner-userguides.desktop.in.in
@@ -0,0 +1,6 @@
+[Desktop Entry]
+_Name=Userguides
+_Comment=Userguide data miner
+Icon=system-installer
+DBusName=org.freedesktop.Tracker1.Miner.Userguides
+DBusPath=/org/freedesktop/Tracker1/Miner/Userguides
diff --git a/src/miners/fs/Makefile.am b/src/miners/fs/Makefile.am
index ad4a44c..c49560e 100644
--- a/src/miners/fs/Makefile.am
+++ b/src/miners/fs/Makefile.am
@@ -47,6 +47,12 @@ tracker_miner_fs_SOURCES =                             \
 	tracker-writeback.c                            \
 	tracker-writeback.h
 
+if HAVE_MAEMO
+tracker_miner_fs_SOURCES += \
+	tracker-miner-userguides.c \
+	tracker-mienr-userguides.h
+endif
+
 tracker_miner_fs_LDADD =                               \
 	$(top_builddir)/src/libtracker-miner/libtracker-miner- TRACKER_API_VERSION@.la \
 	$(top_builddir)/src/libtracker-sparql-backend/libtracker-sparql- TRACKER_API_VERSION@.la \
diff --git a/src/miners/fs/tracker-main.c b/src/miners/fs/tracker-main.c
index 251bf8a..e082988 100644
--- a/src/miners/fs/tracker-main.c
+++ b/src/miners/fs/tracker-main.c
@@ -46,6 +46,7 @@
 
 #include "tracker-config.h"
 #include "tracker-marshal.h"
+#include "tracker-miner-userguides.h"
 #include "tracker-miner-applications.h"
 #include "tracker-miner-files.h"
 #include "tracker-miner-files-index.h"
@@ -647,6 +648,11 @@ miner_needs_check (TrackerMiner *miner,
 			return TRUE;
 		}
 
+		/* FIXME: We currently don't check the applications
+		 *  miner OR the userguides miner if we are finished
+		 * before returning TRUE/FALSE here, should we?
+		 */
+
 		/* We consider the miner finished */
 		return FALSE;
 	} else {
@@ -668,6 +674,9 @@ main (gint argc, gchar *argv[])
 	TrackerConfig *config;
 	TrackerMiner *miner_applications, *miner_files;
 	TrackerMinerFilesIndex *miner_files_index;
+#ifdef HAVE_MAEMO
+	TrackerMiner *miner_userguides;
+#endif /* HAVE_MAEMO */
 	GOptionContext *context;
 	GError *error = NULL;
 	gchar *log_filename = NULL;
@@ -788,6 +797,22 @@ main (gint argc, gchar *argv[])
 		return EXIT_FAILURE;
 	}
 
+#ifdef HAVE_MAEMO
+	/* Create miner for userguides */
+	miner_userguides = tracker_miner_userguides_new (&error);
+	if (!miner_userguides) {
+		g_critical ("Couldn't create new User Guides miner: '%s'",
+		            error ? error->message : "unknown error");
+		g_object_unref (miner_applications);
+		g_object_unref (miner_files);
+		g_object_unref (miner_files_index);
+		tracker_writeback_shutdown ();
+		g_object_unref (config);
+		tracker_log_shutdown ();
+		return EXIT_FAILURE;
+	}
+#endif /* HAVE_MAEMO */
+
 	/* Check if we should crawl and if we should force mtime
 	 * checking based on the config.
 	 */
@@ -828,20 +853,44 @@ main (gint argc, gchar *argv[])
 	/* Configure applications miner */
 	tracker_miner_fs_set_initial_crawling (TRACKER_MINER_FS (miner_applications), do_crawling);
 
+#ifdef HAVE_MAEMO
+	/* Configure userguides miner */
+	tracker_miner_fs_set_initial_crawling (TRACKER_MINER_FS (miner_userguides), do_crawling);
+#endif /* HAVE_MAEMO */
+
 	/* If a locale change was detected, always do mtime checks */
 	if (tracker_miner_applications_detect_locale_changed (miner_applications)) {
 		if (!do_mtime_checking)
 			g_debug ("Forcing mtime check in applications miner as locale change was detected");
 		tracker_miner_fs_set_mtime_checking (TRACKER_MINER_FS (miner_applications), TRUE);
+
+#ifdef HAVE_MAEMO
+		if (!do_mtime_checking)
+			g_debug ("Forcing mtime check in userguides miner as locale change was detected");
+		tracker_miner_fs_set_mtime_checking (TRACKER_MINER_FS (miner_userguides), TRUE);
+#endif /* HAVE_MAEMO */
 	} else {
 		tracker_miner_fs_set_mtime_checking (TRACKER_MINER_FS (miner_applications), do_mtime_checking);
+#ifdef HAVE_MAEMO
+		tracker_miner_fs_set_mtime_checking (TRACKER_MINER_FS (miner_userguides), do_mtime_checking);
+#endif /* HAVE_MAEMO */
 	}
 
 	g_signal_connect (miner_applications, "finished",
 	                  G_CALLBACK (miner_finished_cb),
 	                  NULL);
 
+#ifdef HAVE_MAEMO
+	g_signal_connect (miner_userguides, "finished",
+			  G_CALLBACK (miner_finished_cb),
+			  NULL);
+#endif /* HAVE_MAEMO */
+
 	/* Setup miners, applications first in list */
+#ifdef HAVE_MAEMO
+	miners = g_slist_prepend (miners, miner_userguides);
+#endif /* HAVE_MAEMO */
+
 	miners = g_slist_prepend (miners, miner_files);
 	miners = g_slist_prepend (miners, miner_applications);
 
@@ -858,7 +907,8 @@ main (gint argc, gchar *argv[])
 
 	if (miners_timeout_id == 0 &&
 	    !miner_needs_check (miner_files, store_available) &&
-	    !miner_needs_check (miner_applications, store_available)) {
+	    !miner_needs_check (miner_applications, store_available) && 
+	    !miner_needs_check (miner_userguides, store_available)) {
 		tracker_db_manager_set_need_mtime_check (FALSE);
 	}
 
diff --git a/src/miners/fs/tracker-miner-userguides.c b/src/miners/fs/tracker-miner-userguides.c
new file mode 100644
index 0000000..14548b5
--- /dev/null
+++ b/src/miners/fs/tracker-miner-userguides.c
@@ -0,0 +1,470 @@
+/*
+ * 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.
+ *
+ * Author: Martyn Russell <martyn lanedo com>
+ */
+
+#include "config.h"
+
+#include <libtracker-common/tracker-utils.h>
+#include <libtracker-common/tracker-ontologies.h>
+#include <libtracker-common/tracker-locale.h>
+
+#include "tracker-miner-userguides.h"
+
+/* FIXME: Should we rename this to just -locale not -applications-locale ? */
+#include "tracker-miner-applications-locale.h"
+
+static void     miner_userguides_initable_iface_init     (GInitableIface       *iface);
+static gboolean miner_userguides_initable_init           (GInitable            *initable,
+                                                          GCancellable         *cancellable,
+                                                          GError              **error);
+static gboolean miner_userguides_check_file              (TrackerMinerFS       *fs,
+                                                          GFile                *file);
+static gboolean miner_userguides_check_directory         (TrackerMinerFS       *fs,
+                                                          GFile                *file);
+static gboolean miner_userguides_process_file            (TrackerMinerFS       *fs,
+                                                          GFile                *file,
+                                                          TrackerSparqlBuilder *sparql,
+                                                          GCancellable         *cancellable);
+static gboolean miner_userguides_process_file_attributes (TrackerMinerFS       *fs,
+                                                          GFile                *file,
+                                                          TrackerSparqlBuilder *sparql,
+                                                          GCancellable         *cancellable);
+static gboolean miner_userguides_monitor_directory       (TrackerMinerFS       *fs,
+                                                          GFile                *file);
+static void     miner_userguides_finalize                (GObject              *object);
+
+
+static GQuark miner_userguides_error_quark = 0;
+
+typedef struct ProcessUserguideData ProcessUserguideData;
+
+struct ProcessUserguideData {
+	TrackerMinerFS *miner;
+	GFile *file;
+	TrackerSparqlBuilder *sparql;
+	GCancellable *cancellable;
+	GKeyFile *key_file;
+	gchar *type;
+};
+
+static GInitableIface* miner_userguides_initable_parent_iface;
+
+G_DEFINE_TYPE_WITH_CODE (TrackerMinerUserguides, tracker_miner_userguides, TRACKER_TYPE_MINER_FS,
+                         G_IMPLEMENT_INTERFACE (G_TYPE_INITABLE,
+                                                miner_userguides_initable_iface_init));
+
+static void
+tracker_miner_userguides_class_init (TrackerMinerUserguidesClass *klass)
+{
+	GObjectClass *object_class = G_OBJECT_CLASS (klass);
+	TrackerMinerFSClass *miner_fs_class = TRACKER_MINER_FS_CLASS (klass);
+
+	object_class->finalize = miner_userguides_finalize;
+
+	miner_fs_class->check_file = miner_userguides_check_file;
+	miner_fs_class->check_directory = miner_userguides_check_directory;
+	miner_fs_class->monitor_directory = miner_userguides_monitor_directory;
+	miner_fs_class->process_file = miner_userguides_process_file;
+	miner_fs_class->process_file_attributes = miner_userguides_process_file_attributes;
+
+	miner_userguides_error_quark = g_quark_from_static_string ("TrackerMinerUserguides");
+}
+
+static void
+tracker_miner_userguides_init (TrackerMinerUserguides *ma)
+{
+}
+
+static void
+miner_userguides_initable_iface_init (GInitableIface *iface)
+{
+	miner_userguides_initable_parent_iface = g_type_interface_peek_parent (iface);
+	iface->init = miner_userguides_initable_init;
+}
+
+static void
+miner_userguides_basedir_add (TrackerMinerFS *fs,
+                              const gchar    *basedir)
+{
+	GFile *file;
+	gchar *path;
+
+	/* Add $dir/userguide/contents */
+	path = g_build_filename (basedir, "userguide", "contents", NULL);
+	file = g_file_new_for_path (path);
+	g_message ("  Adding:'%s'", path);
+	tracker_miner_fs_directory_add (fs, file, TRUE);
+	g_object_unref (file);
+	g_free (path);
+}
+
+static void
+miner_userguides_add_directories (TrackerMinerFS *fs)
+{
+	const gchar * const *xdg_dirs;
+	gint i;
+
+	g_message ("Setting up userguides to iterate from XDG system directories");
+
+	/* Add all XDG system and local dirs */
+	xdg_dirs = g_get_system_data_dirs ();
+
+	for (i = 0; xdg_dirs[i]; i++) {
+		miner_userguides_basedir_add (fs, xdg_dirs[i]);
+	}
+}
+
+static void
+tracker_locale_notify_cb (TrackerLocaleID id,
+                          gpointer        user_data)
+{
+	TrackerMiner *miner = user_data;
+
+	if (tracker_miner_userguides_detect_locale_changed (miner)) {
+		tracker_miner_fs_set_mtime_checking (TRACKER_MINER_FS (miner), TRUE);
+
+		miner_userguides_add_directories (TRACKER_MINER_FS (miner));
+	}
+}
+
+static void
+miner_finished_cb (TrackerMinerFS *fs,
+                   gdouble         seconds_elapsed,
+                   guint           total_directories_found,
+                   guint           total_directories_ignored,
+                   guint           total_files_found,
+                   guint           total_files_ignored,
+                   gpointer        user_data)
+{
+	/* Update locale file if necessary */
+	if (tracker_miner_applications_locale_changed ()) {
+		tracker_miner_applications_locale_set_current ();
+	}
+}
+
+static gboolean
+miner_userguides_initable_init (GInitable     *initable,
+                                GCancellable  *cancellable,
+                                GError       **error)
+{
+	TrackerMinerFS *fs;
+	TrackerMinerUserguides *app;
+	GError *inner_error = NULL;
+
+	fs = TRACKER_MINER_FS (initable);
+	app = TRACKER_MINER_USERGUIDES (initable);
+
+	/* Chain up parent's initable callback before calling child's one */
+	if (!miner_userguides_initable_parent_iface->init (initable, cancellable, &inner_error)) {
+		g_propagate_error (error, inner_error);
+		return FALSE;
+	}
+
+	g_signal_connect (fs, "finished",
+	                  G_CALLBACK (miner_finished_cb),
+	                  NULL);
+
+	miner_userguides_add_directories (fs);
+
+	app->locale_notification_id = tracker_locale_notify_add (TRACKER_LOCALE_LANGUAGE,
+	                                                         tracker_locale_notify_cb,
+	                                                         app,
+	                                                         NULL);
+
+	return TRUE;
+}
+
+static void
+miner_userguides_finalize (GObject *object)
+{
+	TrackerMinerUserguides *app;
+
+	app = TRACKER_MINER_USERGUIDES (object);
+
+	tracker_locale_notify_remove (app->locale_notification_id);
+
+	G_OBJECT_CLASS (tracker_miner_userguides_parent_class)->finalize (object);
+}
+
+static gboolean
+miner_userguides_check_file (TrackerMinerFS *fs,
+                             GFile          *file)
+{
+	gboolean retval = FALSE;
+	gchar *basename;
+
+	basename = g_file_get_basename (file);
+
+	/* FIXME: What do we ignore and what don't we? */
+	if (g_str_has_suffix (basename, ".html") ||
+	    g_str_has_suffix (basename, ".ini")) {
+		retval = TRUE;
+	}
+
+	g_free (basename);
+
+	return retval;
+}
+
+static gboolean
+miner_userguides_check_directory (TrackerMinerFS *fs,
+                                  GFile          *file)
+{
+	gboolean retval = TRUE;
+	gchar *basename;
+
+	/* We want to inspect all the passed dirs and their children except one:
+	 * $prefix/userguide/contents/images/
+	 */
+	basename = g_file_get_basename (file);
+
+	/* FIXME: Perhaps this is too broad? */
+	if (strcmp (basename, "images") == 0) {
+		g_message ("  Ignoring:'%s'", basename);
+		retval = FALSE;
+	}
+
+	g_free (basename);
+
+	return retval;
+}
+
+static gboolean
+miner_userguides_monitor_directory (TrackerMinerFS *fs,
+                                    GFile          *file)
+{
+	/* We want to monitor all the passed dirs and their children */
+	return TRUE;
+}
+
+static void
+process_directory (ProcessUserguideData  *data,
+                   GFileInfo             *file_info,
+                   GError               **error)
+{
+	TrackerSparqlBuilder *sparql;
+	gchar *urn, *path, *uri;
+
+	sparql = data->sparql;
+
+	path = g_file_get_path (data->file);
+	uri = g_file_get_uri (data->file);
+	urn = tracker_sparql_escape_uri_printf ("urn:userguides-dir:%s", path);
+
+	tracker_sparql_builder_insert_silent_open (sparql, TRACKER_MINER_FS_GRAPH_URN);
+
+	tracker_sparql_builder_subject_iri (sparql, urn);
+
+	tracker_sparql_builder_predicate (sparql, "a");
+	tracker_sparql_builder_object (sparql, "nfo:FileDataObject");
+	tracker_sparql_builder_object (sparql, "nie:DataObject");
+	tracker_sparql_builder_object (sparql, "nie:Folder");
+
+	tracker_sparql_builder_predicate (sparql, "tracker:available");
+	tracker_sparql_builder_object_boolean (sparql, TRUE);
+
+	tracker_sparql_builder_predicate (sparql, "nie:isStoredAs");
+	tracker_sparql_builder_object_iri (sparql, urn);
+
+	tracker_sparql_builder_predicate (sparql, "nie:url");
+	tracker_sparql_builder_object_string (sparql, uri);
+
+	if (file_info) {
+		guint64 time;
+
+		time = g_file_info_get_attribute_uint64 (file_info, G_FILE_ATTRIBUTE_TIME_MODIFIED);
+		tracker_sparql_builder_predicate (sparql, "nfo:fileLastModified");
+		tracker_sparql_builder_object_date (sparql, (time_t *) &time);
+	}
+
+	tracker_sparql_builder_insert_close (data->sparql);
+
+	g_free (path);
+	g_free (urn);
+	g_free (uri);
+}
+
+static void
+process_userguide_file (ProcessUserguideData  *data,
+                        GFileInfo             *file_info,
+                        GError               **error)
+{
+	/* TODO: Insert SPARQL per user guide */
+}
+
+static void
+process_userguide_data_free (ProcessUserguideData *data)
+{
+	g_object_unref (data->miner);
+	g_object_unref (data->file);
+	g_object_unref (data->sparql);
+	g_object_unref (data->cancellable);
+	g_free (data->type);
+
+	if (data->key_file) {
+		g_key_file_free (data->key_file);
+	}
+
+	g_slice_free (ProcessUserguideData, data);
+}
+
+static void
+process_file_cb (GObject      *object,
+                 GAsyncResult *result,
+                 gpointer      user_data)
+{
+	ProcessUserguideData *data;
+	GFileInfo *file_info;
+	GError *error = NULL;
+	GFile *file;
+
+	data = user_data;
+	file = G_FILE (object);
+	file_info = g_file_query_info_finish (file, result, &error);
+
+	if (error) {
+		tracker_miner_fs_file_notify (TRACKER_MINER_FS (data->miner), file, error);
+		process_userguide_data_free (data);
+		g_error_free (error);
+		return;
+	}
+
+	if (g_file_info_get_file_type (file_info) == G_FILE_TYPE_DIRECTORY) {
+		process_directory (data, file_info, &error);
+	} else {
+		process_userguide_file (data, file_info, &error);
+	}
+
+	tracker_miner_fs_file_notify (TRACKER_MINER_FS (data->miner), data->file, error);
+	process_userguide_data_free (data);
+
+	if (error) {
+		g_error_free (error);
+	}
+
+	if (file_info) {
+		g_object_unref (file_info);
+	}
+}
+
+static gboolean
+miner_userguides_process_file (TrackerMinerFS       *fs,
+                               GFile                *file,
+                               TrackerSparqlBuilder *sparql,
+                               GCancellable         *cancellable)
+{
+	ProcessUserguideData *data;
+	const gchar *attrs;
+
+	data = g_slice_new0 (ProcessUserguideData);
+	data->miner = g_object_ref (fs);
+	data->sparql = g_object_ref (sparql);
+	data->file = g_object_ref (file);
+	data->cancellable = g_object_ref (cancellable);
+
+	attrs = G_FILE_ATTRIBUTE_TIME_MODIFIED ","
+		G_FILE_ATTRIBUTE_STANDARD_TYPE;
+
+	g_file_query_info_async (file,
+	                         attrs,
+	                         G_FILE_QUERY_INFO_NOFOLLOW_SYMLINKS,
+	                         G_PRIORITY_DEFAULT,
+	                         cancellable,
+	                         process_file_cb,
+	                         data);
+
+	return TRUE;
+}
+
+static gboolean
+miner_userguides_process_file_attributes (TrackerMinerFS       *fs,
+                                          GFile                *file,
+                                          TrackerSparqlBuilder *sparql,
+                                          GCancellable         *cancellable)
+{
+	gchar *uri;
+
+	/* We don't care about file attribute changes here */
+	uri = g_file_get_uri (file);
+	g_debug ("Ignoring file attribute changes in '%s'", uri);
+	g_free (uri);
+
+	return FALSE;
+}
+
+/* If a reset is requested, we will remove from the store all items previously
+ * inserted by the tracker-miner-userguides, this is:
+ *  (a) ... FIXME: What needs doing here?
+ *  (b) ... FIXME: What needs doing here?
+ *  (c) ... FIXME: What needs doing here?
+ */
+static void
+miner_userguides_reset (TrackerMiner *miner)
+{
+	GError *error = NULL;
+	TrackerSparqlBuilder *sparql;
+
+	sparql = tracker_sparql_builder_new_update ();
+
+	/* FIXME: Add necessary SPARQL to clean up */
+
+	/* Execute a sync update, we don't want the userguides miner to start before
+	 * we finish this. */
+	tracker_sparql_connection_update (tracker_miner_get_connection (miner),
+	                                  tracker_sparql_builder_get_result (sparql),
+	                                  G_PRIORITY_HIGH,
+	                                  NULL,
+	                                  &error);
+
+	if (error) {
+		/* Some error happened performing the query, not good */
+		g_critical ("Couldn't reset mined userguides: %s",
+		            error ? error->message : "unknown error");
+		g_error_free (error);
+	}
+
+	g_object_unref (sparql);
+}
+
+gboolean
+tracker_miner_userguides_detect_locale_changed (TrackerMiner *miner)
+{
+	gboolean changed;
+
+	changed = tracker_miner_applications_locale_changed ();
+	if (changed) {
+		g_message ("Locale change detected, so resetting miner to "
+		           "remove all previously created items...");
+		miner_userguides_reset (miner);
+	}
+	return changed;
+}
+
+TrackerMiner *
+tracker_miner_userguides_new (GError **error)
+{
+	return g_initable_new (TRACKER_TYPE_MINER_USERGUIDES,
+	                       NULL,
+	                       error,
+	                       "name", "Userguides",
+	                       "processing-pool-wait-limit", 10,
+	                       "processing-pool-ready-limit", 100,
+	                       NULL);
+}
diff --git a/src/miners/fs/tracker-miner-userguides.h b/src/miners/fs/tracker-miner-userguides.h
new file mode 100644
index 0000000..aeb5b7a
--- /dev/null
+++ b/src/miners/fs/tracker-miner-userguides.h
@@ -0,0 +1,54 @@
+/*
+ * 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.
+ *
+ * Author: Martyn Russell <martyn lanedo com>
+ */
+
+#ifndef __TRACKER_MINER_FS_USERGUIDES_H__
+#define __TRACKER_MINER_FS_USERGUIDES_H__
+
+#include <libtracker-miner/tracker-miner.h>
+
+G_BEGIN_DECLS
+
+#define TRACKER_TYPE_MINER_USERGUIDES         (tracker_miner_userguides_get_type())
+#define TRACKER_MINER_USERGUIDES(o)           (G_TYPE_CHECK_INSTANCE_CAST ((o), TRACKER_TYPE_MINER_USERGUIDES, TrackerMinerUserguides))
+#define TRACKER_MINER_USERGUIDES_CLASS(c)     (G_TYPE_CHECK_CLASS_CAST ((c), TRACKER_TYPE_MINER_USERGUIDES, TrackerMinerUserguidesClass))
+#define TRACKER_IS_MINER_USERGUIDES(o)        (G_TYPE_CHECK_INSTANCE_TYPE ((o), TRACKER_TYPE_MINER_USERGUIDES))
+#define TRACKER_IS_MINER_USERGUIDES_CLASS(c)  (G_TYPE_CHECK_CLASS_TYPE ((c),  TRACKER_TYPE_MINER_USERGUIDES))
+#define TRACKER_MINER_USERGUIDES_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), TRACKER_TYPE_MINER_USERGUIDES, TrackerMinerUserguidesClass))
+
+typedef struct _TrackerMinerUserguides TrackerMinerUserguides;
+typedef struct _TrackerMinerUserguidesClass TrackerMinerUserguidesClass;
+
+struct _TrackerMinerUserguides {
+	TrackerMinerFS parent_instance;
+	gpointer locale_notification_id;
+};
+
+struct _TrackerMinerUserguidesClass {
+	TrackerMinerFSClass parent_class;
+};
+
+GType         tracker_miner_userguides_get_type              (void) G_GNUC_CONST;
+TrackerMiner *tracker_miner_userguides_new                   (GError       **error);
+gboolean      tracker_miner_userguides_detect_locale_changed (TrackerMiner  *miner);
+
+G_END_DECLS
+
+#endif /* __TRACKER_MINER_FS_USERGUIDES_H__ */



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]