[tracker/index-optical-discs] TrackerStorage: Add flag set to determine storage type.
- From: Carlos Garnacho <carlosg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [tracker/index-optical-discs] TrackerStorage: Add flag set to determine storage type.
- Date: Thu, 4 Mar 2010 17:57:53 +0000 (UTC)
commit c3ea8bbb7623b2498b33dc9008ec2295d29d5047
Author: Carlos Garnacho <carlos lanedo com>
Date: Thu Mar 4 18:48:57 2010 +0100
TrackerStorage: Add flag set to determine storage type.
now get_device_roots() and get_device_uuids() have a
TrackerStorageType parameter to pass (removable|optical) flags.
If exact_match is TRUE, only devices that fully match the passed
flags are returned.
src/libtracker-miner/tracker-storage.c | 63 ++++++++++++++++-----------
src/libtracker-miner/tracker-storage.h | 19 +++++----
src/tracker-extract/tracker-albumart.c | 3 +-
src/tracker-miner-fs/tracker-miner-files.c | 22 +++++----
4 files changed, 61 insertions(+), 46 deletions(-)
---
diff --git a/src/libtracker-miner/tracker-storage.c b/src/libtracker-miner/tracker-storage.c
index 2de4f5c..11fcdbe 100644
--- a/src/libtracker-miner/tracker-storage.c
+++ b/src/libtracker-miner/tracker-storage.c
@@ -52,9 +52,8 @@ typedef struct {
typedef struct {
GSList *roots;
- guint either_condition : 1;
- guint removable : 1;
- guint optical : 1;
+ TrackerStorageType type;
+ gboolean exact_match;
} GetRoots;
static void tracker_storage_finalize (GObject *object);
@@ -258,6 +257,22 @@ mount_info_find (GNode *root,
return (node) ? node->data : NULL;
}
+static TrackerStorageType
+mount_info_get_type (MountInfo *info)
+{
+ TrackerStorageType mount_type = 0;
+
+ if (info->removable) {
+ mount_type |= TRACKER_STORAGE_REMOVABLE;
+ }
+
+ if (info->optical) {
+ mount_type |= TRACKER_STORAGE_OPTICAL;
+ }
+
+ return mount_type;
+}
+
static gchar *
mount_point_normalize (const gchar *mount_point)
{
@@ -719,18 +734,17 @@ get_mount_point_by_uuid_foreach (gpointer key,
const gchar *uuid;
GNode *node;
MountInfo *info;
+ TrackerStorageType mount_type;
gr = user_data;
uuid = key;
node = value;
info = node->data;
+ mount_type = mount_info_get_type (info);
- if ((gr->either_condition == TRUE &&
- (!gr->removable || info->removable) &&
- (!gr->optical || info->optical)) ||
- (gr->either_condition == FALSE &&
- gr->removable == info->removable &&
- gr->optical == info->optical)) {
+ /* is mount of the type we're looking for? */
+ if ((gr->exact_match && mount_type == gr->type) ||
+ (!gr->exact_match && ((mount_type & gr->type) == gr->type))) {
gchar *normalized_mount_point;
gint len;
@@ -759,10 +773,9 @@ get_mount_point_by_uuid_foreach (gpointer key,
* Returns: The list of root directories.
**/
GSList *
-tracker_storage_get_device_roots (TrackerStorage *storage,
- gboolean either_condition,
- gboolean removable,
- gboolean optical)
+tracker_storage_get_device_roots (TrackerStorage *storage,
+ TrackerStorageType type,
+ gboolean exact_match)
{
TrackerStoragePrivate *priv;
GetRoots gr;
@@ -772,9 +785,8 @@ tracker_storage_get_device_roots (TrackerStorage *storage,
priv = TRACKER_STORAGE_GET_PRIVATE (storage);
gr.roots = NULL;
- gr.either_condition = either_condition;
- gr.removable = removable;
- gr.optical = optical;
+ gr.type = type;
+ gr.exact_match = exact_match;
g_hash_table_foreach (priv->mounts_by_uuid,
get_mount_point_by_uuid_foreach,
@@ -794,10 +806,9 @@ tracker_storage_get_device_roots (TrackerStorage *storage,
* Returns: The list of UUIDs.
**/
GSList *
-tracker_storage_get_device_uuids (TrackerStorage *storage,
- gboolean either_condition,
- gboolean removable,
- gboolean optical)
+tracker_storage_get_device_uuids (TrackerStorage *storage,
+ TrackerStorageType type,
+ gboolean exact_match)
{
TrackerStoragePrivate *priv;
GHashTableIter iter;
@@ -816,17 +827,17 @@ tracker_storage_get_device_uuids (TrackerStorage *storage,
const gchar *uuid;
GNode *node;
MountInfo *info;
+ TrackerStorageType mount_type;
uuid = key;
node = value;
info = node->data;
- if ((either_condition == TRUE &&
- (!removable || info->removable) &&
- (!optical || info->optical)) ||
- (either_condition == FALSE &&
- removable == info->removable &&
- optical == info->optical)) {
+ mount_type = mount_info_get_type (info);
+
+ /* is mount of the type we're looking for? */
+ if ((exact_match && mount_type == type) ||
+ (!exact_match && ((mount_type & type) == type))) {
uuids = g_slist_prepend (uuids, g_strdup (uuid));
}
}
diff --git a/src/libtracker-miner/tracker-storage.h b/src/libtracker-miner/tracker-storage.h
index f65d5b6..dc2a92e 100644
--- a/src/libtracker-miner/tracker-storage.h
+++ b/src/libtracker-miner/tracker-storage.h
@@ -43,16 +43,19 @@ struct _TrackerStorageClass {
GObjectClass parent_class;
};
+typedef enum {
+ TRACKER_STORAGE_REMOVABLE = 1 << 0,
+ TRACKER_STORAGE_OPTICAL = 1 << 1
+} TrackerStorageType;
+
GType tracker_storage_get_type (void) G_GNUC_CONST;
TrackerStorage *tracker_storage_new (void);
-GSList * tracker_storage_get_device_roots (TrackerStorage *storage,
- gboolean either_condition,
- gboolean removable,
- gboolean optical);
-GSList * tracker_storage_get_device_uuids (TrackerStorage *storage,
- gboolean either_condition,
- gboolean removable,
- gboolean optical);
+GSList * tracker_storage_get_device_roots (TrackerStorage *storage,
+ TrackerStorageType type,
+ gboolean exact_match);
+GSList * tracker_storage_get_device_uuids (TrackerStorage *storage,
+ TrackerStorageType type,
+ gboolean exact_match);
const gchar * tracker_storage_get_mount_point_for_uuid (TrackerStorage *storage,
const gchar *uuid);
const gchar* tracker_storage_get_uuid_for_file (TrackerStorage *storage,
diff --git a/src/tracker-extract/tracker-albumart.c b/src/tracker-extract/tracker-albumart.c
index 8cf2293..5cce241 100644
--- a/src/tracker-extract/tracker-albumart.c
+++ b/src/tracker-extract/tracker-albumart.c
@@ -613,8 +613,7 @@ albumart_copy_to_local (TrackerStorage *storage,
return;
}
- roots = tracker_storage_get_device_roots (storage, TRUE, TRUE, FALSE);
-
+ roots = tracker_storage_get_device_roots (storage, TRACKER_STORAGE_REMOVABLE, FALSE);
flen = strlen (filename);
for (l = roots; l; l = l->next) {
diff --git a/src/tracker-miner-fs/tracker-miner-files.c b/src/tracker-miner-fs/tracker-miner-files.c
index 9c3211b..bdd96e3 100644
--- a/src/tracker-miner-fs/tracker-miner-files.c
+++ b/src/tracker-miner-fs/tracker-miner-files.c
@@ -326,6 +326,7 @@ miner_files_constructed (GObject *object)
GSList *mounts = NULL, *m;
gboolean index_removable_devices;
gboolean index_optical_discs;
+ TrackerStorageType type = 0;
G_OBJECT_CLASS (tracker_miner_files_parent_class)->constructed (object);
@@ -337,13 +338,17 @@ miner_files_constructed (GObject *object)
g_assert_not_reached ();
}
- index_removable_devices = tracker_config_get_index_removable_devices (mf->private->config);
- index_optical_discs = tracker_config_get_index_optical_discs (mf->private->config);
+ if (tracker_config_get_index_removable_devices (mf->private->config)) {
+ index_removable_devices = TRUE;
+ type |= TRACKER_STORAGE_REMOVABLE;
+ }
+
+ if (tracker_config_get_index_optical_discs (mf->private->config)) {
+ index_optical_discs = TRUE;
+ type |= TRACKER_STORAGE_OPTICAL;
+ }
- mounts = tracker_storage_get_device_roots (mf->private->storage,
- FALSE,
- index_removable_devices,
- index_optical_discs);
+ mounts = tracker_storage_get_device_roots (mf->private->storage, type, TRUE);
#if defined(HAVE_DEVKIT_POWER) || defined(HAVE_HAL)
check_battery_status (mf);
@@ -677,10 +682,7 @@ query_mount_points_cb (GObject *source,
g_hash_table_replace (volumes, g_strdup (TRACKER_NON_REMOVABLE_MEDIA_DATASOURCE_URN),
GINT_TO_POINTER (VOLUME_MOUNTED));
- uuids = tracker_storage_get_device_uuids (priv->storage,
- TRUE,
- TRUE,
- FALSE);
+ uuids = tracker_storage_get_device_uuids (priv->storage, TRACKER_STORAGE_REMOVABLE, FALSE);
/* Then, get all currently mounted volumes, according to GIO */
for (u = uuids; u; u = u->next) {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]