[tracker/miner-fs-dbus-api: 11/22] TrackerMinerManager: Add GError infrastructure.



commit 9f72c4034c9b71a45647a103323be6187f7c65f5
Author: Carlos Garnacho <carlosg gnome org>
Date:   Mon Aug 23 15:20:50 2010 +0200

    TrackerMinerManager: Add GError infrastructure.

 src/libtracker-miner/tracker-miner-manager.c |   29 ++++++++++++++++++++++++++
 src/libtracker-miner/tracker-miner-manager.h |    9 ++++++++
 2 files changed, 38 insertions(+), 0 deletions(-)
---
diff --git a/src/libtracker-miner/tracker-miner-manager.c b/src/libtracker-miner/tracker-miner-manager.c
index 868a459..596f2ca 100644
--- a/src/libtracker-miner/tracker-miner-manager.c
+++ b/src/libtracker-miner/tracker-miner-manager.c
@@ -982,6 +982,18 @@ tracker_miner_manager_ignore_next_update (TrackerMinerManager *manager,
 	return TRUE;
 }
 
+GQuark
+tracker_miner_manager_error_quark (void)
+{
+	static GQuark error_quark = 0;
+
+	if (G_UNLIKELY (error_quark == 0)) {
+		error_quark = g_quark_from_static_string ("tracker-miner-manager-error-quark");
+	}
+
+	return error_quark;
+}
+
 gboolean
 tracker_miner_manager_index_file (TrackerMinerManager  *manager,
                                   GFile                *file,
@@ -995,6 +1007,23 @@ tracker_miner_manager_index_file (TrackerMinerManager  *manager,
 	g_return_val_if_fail (TRACKER_IS_MINER_MANAGER (manager), FALSE);
 	g_return_val_if_fail (G_IS_FILE (file), FALSE);
 
+	if (!g_file_query_exists (file, NULL)) {
+		g_set_error_literal (error,
+		                     TRACKER_MINER_MANAGER_ERROR,
+		                     TRACKER_MINER_MANAGER_ERROR_NOENT,
+		                     "File or directory does not exist");
+		return FALSE;
+	}
+
+	if (!tracker_miner_manager_is_active (manager,
+	                                      "org.freedesktop.Tracker1.Miner.Files")) {
+		g_set_error_literal (error,
+		                     TRACKER_MINER_MANAGER_ERROR,
+		                     TRACKER_MINER_MANAGER_ERROR_NOT_AVAILABLE,
+		                     "Filesystem miner is not active");
+		return FALSE;
+	}
+
 	priv = TRACKER_MINER_MANAGER_GET_PRIVATE (manager);
 
 	if (G_UNLIKELY (!proxy)) {
diff --git a/src/libtracker-miner/tracker-miner-manager.h b/src/libtracker-miner/tracker-miner-manager.h
index 2ce9e62..82b8d5f 100644
--- a/src/libtracker-miner/tracker-miner-manager.h
+++ b/src/libtracker-miner/tracker-miner-manager.h
@@ -35,8 +35,16 @@ G_BEGIN_DECLS
 #define TRACKER_IS_MINER_MANAGER_CLASS(c)  (G_TYPE_CHECK_CLASS_TYPE ((c),    TRACKER_TYPE_MINER_MANAGER))
 #define TRACKER_MINER_MANAGER_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o),  TRACKER_TYPE_MINER_MANAGER, TrackerMinerManagerClass))
 
+#define TRACKER_MINER_MANAGER_ERROR tracker_miner_manager_error_quark ()
+
 typedef struct TrackerMinerManager TrackerMinerManager;
 typedef struct TrackerMinerManagerClass TrackerMinerManagerClass;
+typedef enum TrackerMinerManagerError TrackerMinerManagerError;
+
+enum TrackerMinerManagerError {
+	TRACKER_MINER_MANAGER_ERROR_NOT_AVAILABLE,
+	TRACKER_MINER_MANAGER_ERROR_NOENT
+};
 
 /**
  * TrackerMinerManager:
@@ -70,6 +78,7 @@ struct TrackerMinerManagerClass {
 };
 
 GType                tracker_miner_manager_get_type           (void) G_GNUC_CONST;
+GQuark               tracker_miner_manager_error_quark        (void) G_GNUC_CONST;
 
 TrackerMinerManager *tracker_miner_manager_new                (void);
 GSList *             tracker_miner_manager_get_running        (TrackerMinerManager  *manager);



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