[tracker/removable-opticals: 9/9] libtracker-miner: New helper macros to work with storage types



commit 0af92d309ef5a40fff8f3b922a0c0ee8fd091b97
Author: Aleksander Morgado <aleksander lanedo com>
Date:   Thu Jun 17 15:27:00 2010 +0200

    libtracker-miner: New helper macros to work with storage types
    
     * TRACKER_STORAGE_TYPE_IS_REMOVABLE
     * TRACKER_STORAGE_TYPE_IS_OPTICAL

 .../libtracker-miner/libtracker-miner-sections.txt |    2 +
 src/libtracker-miner/tracker-storage.h             |   40 +++++++++++++++++---
 src/miners/fs/tracker-miner-files.c                |    8 ++--
 3 files changed, 40 insertions(+), 10 deletions(-)
---
diff --git a/docs/reference/libtracker-miner/libtracker-miner-sections.txt b/docs/reference/libtracker-miner/libtracker-miner-sections.txt
index 09afd7b..8b50b2f 100644
--- a/docs/reference/libtracker-miner/libtracker-miner-sections.txt
+++ b/docs/reference/libtracker-miner/libtracker-miner-sections.txt
@@ -168,6 +168,8 @@ tracker_thumbnailer_cleanup
 TrackerStorage
 TrackerStorageClass
 TrackerStorageType
+TRACKER_STORAGE_TYPE_IS_REMOVABLE
+TRACKER_STORAGE_TYPE_IS_OPTICAL
 tracker_storage_new
 tracker_storage_get_device_roots
 tracker_storage_get_device_uuids
diff --git a/src/libtracker-miner/tracker-storage.h b/src/libtracker-miner/tracker-storage.h
index 27d0e28..3ac584f 100644
--- a/src/libtracker-miner/tracker-storage.h
+++ b/src/libtracker-miner/tracker-storage.h
@@ -29,6 +29,39 @@
 
 G_BEGIN_DECLS
 
+/**
+ * TrackerStorageType:
+ * @TRACKER_STORAGE_REMOVABLE: Storage is a removable media
+ * @TRACKER_STORAGE_OPTICAL: Storage is an optical disc
+ *
+ * Flags specifying properties of the type of storage.
+ */
+typedef enum {
+	TRACKER_STORAGE_REMOVABLE = 1 << 0,
+	TRACKER_STORAGE_OPTICAL   = 1 << 1
+} TrackerStorageType;
+
+/**
+ * TRACKER_STORAGE_TYPE_IS_REMOVABLE:
+ * @type: Mask of TrackerStorageType flags
+ *
+ * Check if the given storage type is marked as being removable media.
+ *
+ * Returns: %TRUE if the storage is marked as removable media, %FALSE otherwise
+ */
+#define TRACKER_STORAGE_TYPE_IS_REMOVABLE(type) ((type & TRACKER_STORAGE_REMOVABLE) ? TRUE : FALSE)
+
+/**
+ * TRACKER_STORAGE_TYPE_IS_OPTICAL:
+ * @type: Mask of TrackerStorageType flags
+ *
+ * Check if the given storage type is marked as being optical disc
+ *
+ * Returns: %TRUE if the storage is marked as optical disc, %FALSE otherwise
+ */
+#define TRACKER_STORAGE_TYPE_IS_OPTICAL(type) ((type & TRACKER_STORAGE_OPTICAL) ? TRUE : FALSE)
+
+
 #define TRACKER_TYPE_STORAGE         (tracker_storage_get_type ())
 #define TRACKER_STORAGE(o)           (G_TYPE_CHECK_INSTANCE_CAST ((o), TRACKER_TYPE_STORAGE, TrackerStorage))
 #define TRACKER_STORAGE_CLASS(k)     (G_TYPE_CHECK_CLASS_CAST ((k), TRACKER_TYPE_STORAGE, TrackerStorageClass))
@@ -47,11 +80,6 @@ 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,
@@ -64,7 +92,7 @@ const gchar *      tracker_storage_get_mount_point_for_uuid (TrackerStorage
                                                              const gchar        *uuid);
 TrackerStorageType tracker_storage_get_type_for_uuid        (TrackerStorage     *storage,
                                                              const gchar        *uuid);
-const gchar*       tracker_storage_get_uuid_for_file        (TrackerStorage     *storage,
+const gchar *      tracker_storage_get_uuid_for_file        (TrackerStorage     *storage,
                                                              GFile              *file);
 
 G_END_DECLS
diff --git a/src/miners/fs/tracker-miner-files.c b/src/miners/fs/tracker-miner-files.c
index da70aa7..499435b 100644
--- a/src/miners/fs/tracker-miner-files.c
+++ b/src/miners/fs/tracker-miner-files.c
@@ -844,8 +844,8 @@ query_mount_points_cb (GObject      *source,
 				/* Set mount point type */
 				set_up_mount_point_type (TRACKER_MINER_FILES (miner),
 				                         urn,
-				                         type & TRACKER_STORAGE_REMOVABLE,
-				                         type & TRACKER_STORAGE_OPTICAL,
+				                         TRACKER_STORAGE_TYPE_IS_REMOVABLE (type),
+				                         TRACKER_STORAGE_TYPE_IS_OPTICAL (type),
 				                         accumulator);
 
 			}
@@ -2319,8 +2319,8 @@ miner_files_remove_by_type (TrackerMinerFiles  *miner,
 	gboolean removable;
 	gboolean optical;
 
-	removable = type & TRACKER_STORAGE_REMOVABLE ? TRUE : FALSE;
-	optical = type & TRACKER_STORAGE_OPTICAL ? TRUE : FALSE;
+	removable = TRACKER_STORAGE_TYPE_IS_REMOVABLE (type);
+	optical = TRACKER_STORAGE_TYPE_IS_OPTICAL (type);
 
 	/* Only remove if any of the flags was TRUE */
 	if (removable || optical) {



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