[tracker/writeback: 13/23] TrackerWritebackFile: Added base implementation for local files.
- From: Philip Van Hoof <pvanhoof src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [tracker/writeback: 13/23] TrackerWritebackFile: Added base implementation for local files.
- Date: Sun, 22 Nov 2009 12:40:37 +0000 (UTC)
commit 201e624714b061533d83aa36314536bc6f403932
Author: Carlos Garnacho <carlos lanedo com>
Date: Tue Nov 17 15:55:36 2009 +0100
TrackerWritebackFile: Added base implementation for local files.
This object implements file locking for local files, and provides an
specialized vmethod as well.
src/libtracker-common/tracker-file-utils.c | 4 +-
src/tracker-writeback/Makefile.am | 2 +
src/tracker-writeback/tracker-writeback-file.c | 74 ++++++++++++++++++++++++
src/tracker-writeback/tracker-writeback-file.h | 56 ++++++++++++++++++
src/tracker-writeback/tracker-writeback.h | 3 +-
5 files changed, 135 insertions(+), 4 deletions(-)
---
diff --git a/src/libtracker-common/tracker-file-utils.c b/src/libtracker-common/tracker-file-utils.c
index c61c941..5c5a36d 100644
--- a/src/libtracker-common/tracker-file-utils.c
+++ b/src/libtracker-common/tracker-file-utils.c
@@ -699,7 +699,7 @@ flock_file (GFile *file,
g_return_val_if_fail (G_IS_FILE (file), -1);
- if (g_file_is_native (file)) {
+ if (!g_file_is_native (file)) {
return -1;
}
@@ -777,7 +777,7 @@ tracker_file_is_locked (GFile *file)
g_return_val_if_fail (G_IS_FILE (file), FALSE);
- if (g_file_is_native (file)) {
+ if (!g_file_is_native (file)) {
return FALSE;
}
diff --git a/src/tracker-writeback/Makefile.am b/src/tracker-writeback/Makefile.am
index 3c20f99..bc47048 100644
--- a/src/tracker-writeback/Makefile.am
+++ b/src/tracker-writeback/Makefile.am
@@ -37,6 +37,8 @@ tracker_writeback_SOURCES = \
$(dbus_sources) \
tracker-writeback-dispatcher.c \
tracker-writeback-dispatcher.h \
+ tracker-writeback-file.c \
+ tracker-writeback-file.h \
tracker-writeback-module.c \
tracker-writeback-module.h \
tracker-writeback.c \
diff --git a/src/tracker-writeback/tracker-writeback-file.c b/src/tracker-writeback/tracker-writeback-file.c
new file mode 100644
index 0000000..6233a76
--- /dev/null
+++ b/src/tracker-writeback/tracker-writeback-file.c
@@ -0,0 +1,74 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+/*
+ * Copyright (C) 2008, Nokia
+ *
+ * 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.
+ */
+
+#include <libtracker-common/tracker-file-utils.h>
+#include "tracker-writeback-file.h"
+
+static gboolean tracker_writeback_file_update_metadata (TrackerWriteback *writeback,
+ GPtrArray *values);
+
+G_DEFINE_ABSTRACT_TYPE (TrackerWritebackFile, tracker_writeback_file, TRACKER_TYPE_WRITEBACK)
+
+static void
+tracker_writeback_file_class_init (TrackerWritebackFileClass *klass)
+{
+ TrackerWritebackClass *writeback_class = TRACKER_WRITEBACK_CLASS (klass);
+
+ writeback_class->update_metadata = tracker_writeback_file_update_metadata;
+}
+
+static void
+tracker_writeback_file_init (TrackerWritebackFile *writeback_file)
+{
+
+}
+
+static gboolean
+tracker_writeback_file_update_metadata (TrackerWriteback *writeback,
+ GPtrArray *values)
+{
+ TrackerWritebackFileClass *writeback_file_class;
+ gboolean retval;
+ GFile *file;
+ GStrv row;
+
+ writeback_file_class = TRACKER_WRITEBACK_FILE_GET_CLASS (writeback);
+
+ if (!writeback_file_class->update_file_metadata) {
+ g_critical ("%s doesn't implement update_file_metadata()",
+ G_OBJECT_TYPE_NAME (writeback));
+ return FALSE;
+ }
+
+ /* Get the file from the first row */
+ row = g_ptr_array_index (values, 0);
+ file = g_file_new_for_uri (row[0]);
+
+ tracker_file_lock (file);
+
+ retval = (writeback_file_class->update_file_metadata) (TRACKER_WRITEBACK_FILE (writeback),
+ file, values);
+
+ tracker_file_unlock (file);
+
+ g_object_unref (file);
+
+ return retval;
+}
diff --git a/src/tracker-writeback/tracker-writeback-file.h b/src/tracker-writeback/tracker-writeback-file.h
new file mode 100644
index 0000000..3e7f539
--- /dev/null
+++ b/src/tracker-writeback/tracker-writeback-file.h
@@ -0,0 +1,56 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+/*
+ * Copyright (C) 2008, Nokia
+ *
+ * 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.
+ */
+
+#include <gio/gio.h>
+#include "tracker-writeback.h"
+
+#ifndef __TRACKER_WRITEBACK_FILE_H__
+#define __TRACKER_WRITEBACK_FILE_H__
+
+G_BEGIN_DECLS
+
+#define TRACKER_TYPE_WRITEBACK_FILE (tracker_writeback_file_get_type())
+#define TRACKER_WRITEBACK_FILE(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), TRACKER_TYPE_WRITEBACK_FILE, TrackerWritebackFile))
+#define TRACKER_WRITEBACK_FILE_CLASS(c) (G_TYPE_CHECK_CLASS_CAST ((c), TRACKER_TYPE_WRITEBACK_FILE, TrackerWritebackFileClass))
+#define TRACKER_IS_WRITEBACK_FILE(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), TRACKER_TYPE_WRITEBACK_FILE))
+#define TRACKER_IS_WRITEBACK_FILE_CLASS(c) (G_TYPE_CHECK_CLASS_TYPE ((c), TRACKER_TYPE_WRITEBACK_FILE))
+#define TRACKER_WRITEBACK_FILE_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), TRACKER_TYPE_WRITEBACK_FILE, TrackerWritebackFileClass))
+
+typedef struct TrackerWritebackFile TrackerWritebackFile;
+typedef struct TrackerWritebackFileClass TrackerWritebackFileClass;
+
+struct TrackerWritebackFile {
+ TrackerWriteback parent_instance;
+};
+
+struct TrackerWritebackFileClass {
+ TrackerWritebackClass parent_class;
+
+ gboolean (* update_file_metadata) (TrackerWritebackFile *writeback_file,
+ GFile *file,
+ GPtrArray *values);
+};
+
+GType tracker_writeback_file_get_type (void) G_GNUC_CONST;
+
+
+G_END_DECLS
+
+#endif /* __TRACKER_WRITEBACK_FILE_H__ */
diff --git a/src/tracker-writeback/tracker-writeback.h b/src/tracker-writeback/tracker-writeback.h
index e971b39..74bb6b6 100644
--- a/src/tracker-writeback/tracker-writeback.h
+++ b/src/tracker-writeback/tracker-writeback.h
@@ -19,7 +19,6 @@
*/
#include <glib-object.h>
-#include <gio/gio.h>
#ifndef __TRACKER_WRITEBACK_H__
#define __TRACKER_WRITEBACK_H__
@@ -27,7 +26,7 @@
G_BEGIN_DECLS
#define TRACKER_TYPE_WRITEBACK (tracker_writeback_get_type())
-#define TRACKER_WRITEBACK(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), TRACKER_TYPE_WRITEBAK, TrackerWriteback))
+#define TRACKER_WRITEBACK(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), TRACKER_TYPE_WRITEBACK, TrackerWriteback))
#define TRACKER_WRITEBACK_CLASS(c) (G_TYPE_CHECK_CLASS_CAST ((c), TRACKER_TYPE_WRITEBACK, TrackerWritebackClass))
#define TRACKER_IS_WRITEBACK(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), TRACKER_TYPE_WRITEBACK))
#define TRACKER_IS_WRITEBACK_CLASS(c) (G_TYPE_CHECK_CLASS_TYPE ((c), TRACKER_TYPE_WRITEBACK))
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]