[tracker/writeback: 13/16] TrackerWritebackMP3: Make it inherit from TrackerWritebackFile.
- From: Philip Van Hoof <pvanhoof src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [tracker/writeback: 13/16] TrackerWritebackMP3: Make it inherit from TrackerWritebackFile.
- Date: Sun, 22 Nov 2009 13:28:59 +0000 (UTC)
commit d3c373666953e5a4b2611e586de048ff8e0fdc96
Author: Carlos Garnacho <carlos lanedo com>
Date: Wed Nov 18 11:38:03 2009 +0100
TrackerWritebackMP3: Make it inherit from TrackerWritebackFile.
src/libtracker-miner/tracker-miner-fs.c | 12 ++++
src/tracker-writeback/tracker-writeback-mp3.c | 75 ++++++++++--------------
2 files changed, 43 insertions(+), 44 deletions(-)
---
diff --git a/src/libtracker-miner/tracker-miner-fs.c b/src/libtracker-miner/tracker-miner-fs.c
index f0b35c1..c821b69 100644
--- a/src/libtracker-miner/tracker-miner-fs.c
+++ b/src/libtracker-miner/tracker-miner-fs.c
@@ -21,6 +21,7 @@
#include "config.h"
#include <libtracker-common/tracker-dbus.h>
+#include <libtracker-common/tracker-file-utils.h>
#include "tracker-crawler.h"
#include "tracker-marshal.h"
@@ -1251,6 +1252,17 @@ item_queue_handlers_cb (gpointer user_data)
fs = user_data;
queue = item_queue_get_next_file (fs, &file, &source_file);
+ if (file && tracker_file_is_locked (file)) {
+ /* File is locked, ignore any updates on it */
+ g_object_unref (file);
+
+ if (source_file) {
+ g_object_unref (source_file);
+ }
+
+ return TRUE;
+ }
+
if (!fs->private->timer) {
fs->private->timer = g_timer_new ();
}
diff --git a/src/tracker-writeback/tracker-writeback-mp3.c b/src/tracker-writeback/tracker-writeback-mp3.c
index ef4cb03..b67d43e 100644
--- a/src/tracker-writeback/tracker-writeback-mp3.c
+++ b/src/tracker-writeback/tracker-writeback-mp3.c
@@ -24,7 +24,7 @@
#include <libtracker-common/tracker-ontology.h>
-#include "tracker-writeback.h"
+#include "tracker-writeback-file.h"
#define TRACKER_TYPE_WRITEBACK_MP3 (tracker_writeback_mp3_get_type ())
@@ -32,25 +32,26 @@ typedef struct TrackerWritebackMP3 TrackerWritebackMP3;
typedef struct TrackerWritebackMP3Class TrackerWritebackMP3Class;
struct TrackerWritebackMP3 {
- TrackerWriteback parent_instance;
+ TrackerWritebackFile parent_instance;
};
struct TrackerWritebackMP3Class {
- TrackerWritebackClass parent_class;
+ TrackerWritebackFileClass parent_class;
};
static GType tracker_writeback_mp3_get_type (void) G_GNUC_CONST;
-static gboolean tracker_writeback_mp3_update_metadata (TrackerWriteback *writeback,
- GPtrArray *values);
+static gboolean tracker_writeback_mp3_update_file_metadata (TrackerWritebackFile *writeback_file,
+ GFile *file,
+ GPtrArray *values);
-G_DEFINE_DYNAMIC_TYPE (TrackerWritebackMP3, tracker_writeback_mp3, TRACKER_TYPE_WRITEBACK);
+G_DEFINE_DYNAMIC_TYPE (TrackerWritebackMP3, tracker_writeback_mp3, TRACKER_TYPE_WRITEBACK_FILE);
static void
tracker_writeback_mp3_class_init (TrackerWritebackMP3Class *klass)
{
- TrackerWritebackClass *writeback_class = TRACKER_WRITEBACK_CLASS (klass);
+ TrackerWritebackFileClass *writeback_file_class = TRACKER_WRITEBACK_FILE_CLASS (klass);
- writeback_class->update_metadata = tracker_writeback_mp3_update_metadata;
+ writeback_file_class->update_file_metadata = tracker_writeback_mp3_update_file_metadata;
}
static void
@@ -64,45 +65,35 @@ tracker_writeback_mp3_init (TrackerWritebackMP3 *mp3)
}
static gboolean
-tracker_writeback_mp3_update_metadata (TrackerWriteback *writeback,
- GPtrArray *values)
+tracker_writeback_mp3_update_file_metadata (TrackerWritebackFile *writeback_file,
+ GFile *file,
+ GPtrArray *values)
{
+ GFileInfo *file_info;
+ const gchar *mime_type;
+ gchar *path;
guint n;
- const gchar *uri = NULL;
- GFile *file = NULL;
- gchar *path = NULL;
- for (n = 0; n < values->len; n++) {
- const GStrv row = g_ptr_array_index (values, n);
-
- if (uri == NULL) {
- GFileInfo *file_info;
- const gchar *mime_type;
+ file_info = g_file_query_info (file, G_FILE_ATTRIBUTE_STANDARD_CONTENT_TYPE,
+ G_FILE_QUERY_INFO_NOFOLLOW_SYMLINKS,
+ NULL, NULL);
- uri = row[0];
- file = g_file_new_for_uri (uri);
+ if (!file_info) {
+ return FALSE;
+ }
- file_info = g_file_query_info (file, G_FILE_ATTRIBUTE_STANDARD_CONTENT_TYPE,
- G_FILE_QUERY_INFO_NOFOLLOW_SYMLINKS,
- NULL, NULL);
+ mime_type = g_file_info_get_content_type (file_info);
+ g_object_unref (file_info);
- if (!file_info) {
- g_object_unref (file);
- return FALSE;
- }
+ if (g_strcmp0 (mime_type, "audio/mpeg") != 0 &&
+ g_strcmp0 (mime_type, "audio/x-mp3") != 0) {
+ return FALSE;
+ }
- mime_type = g_file_info_get_content_type (file_info);
+ path = g_file_get_path (file);
- if (g_strcmp0 (mime_type, "audio/mpeg") == 0 ||
- g_strcmp0 (mime_type, "audio/x-mp3") == 0) {
- g_object_unref (file_info);
- path = g_file_get_path (file);
- } else {
- g_object_unref (file);
- g_object_unref (file_info);
- return FALSE;
- }
- }
+ for (n = 0; n < values->len; n++) {
+ const GStrv row = g_ptr_array_index (values, n);
if (g_strcmp0 (row[1], TRACKER_NIE_PREFIX "title") == 0) {
ID3Tag *tag = ID3Tag_New ();
@@ -129,11 +120,7 @@ tracker_writeback_mp3_update_metadata (TrackerWriteback *writeback,
}
}
- if (path)
- g_free (path);
-
- if (file)
- g_object_unref (file);
+ g_free (path);
return TRUE;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]