[tracker/writeback: 22/23] tracker-writeback: Some code clean ups from initial review
- From: Philip Van Hoof <pvanhoof src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [tracker/writeback: 22/23] tracker-writeback: Some code clean ups from initial review
- Date: Wed, 25 Nov 2009 10:05:02 +0000 (UTC)
commit e5488f29c0161558633c0b4d45530e31c1ad9afc
Author: Martyn Russell <martyn lanedo com>
Date: Wed Nov 25 09:12:42 2009 +0000
tracker-writeback: Some code clean ups from initial review
Added some debugging too, so I could see what was going on.
docs/reference/libtracker-miner/Makefile.am | 1 +
.../libtracker-miner/tmpl/tracker-miner-fs.sgml | 12 ++
.../libtracker-miner/tmpl/tracker-miner.sgml | 9 ++
src/tracker-store/tracker-dbus.c | 11 +-
src/tracker-store/tracker-main.c | 18 ++-
src/tracker-store/tracker-push.c | 8 +-
src/tracker-store/tracker-resources.c | 1 -
src/tracker-store/tracker-writeback.c | 91 ++++++-------
src/tracker-store/tracker-writeback.h | 26 ++--
src/tracker-writeback/Makefile.am | 54 ++++----
src/tracker-writeback/tracker-main.c | 6 +-
.../tracker-writeback-dispatcher.c | 144 +++++++++++---------
.../tracker-writeback-dispatcher.h | 9 +-
src/tracker-writeback/tracker-writeback-file.c | 23 ++-
src/tracker-writeback/tracker-writeback-file.h | 17 +--
src/tracker-writeback/tracker-writeback-module.c | 50 ++++---
src/tracker-writeback/tracker-writeback-module.h | 22 ++--
src/tracker-writeback/tracker-writeback-mp3.c | 58 +++++----
src/tracker-writeback/tracker-writeback-xmp.c | 92 ++++++------
src/tracker-writeback/tracker-writeback.c | 6 +-
src/tracker-writeback/tracker-writeback.h | 23 ++--
21 files changed, 371 insertions(+), 310 deletions(-)
---
diff --git a/docs/reference/libtracker-miner/Makefile.am b/docs/reference/libtracker-miner/Makefile.am
index bdbe041..ccd1ef5 100644
--- a/docs/reference/libtracker-miner/Makefile.am
+++ b/docs/reference/libtracker-miner/Makefile.am
@@ -44,6 +44,7 @@ INCLUDES = \
GTKDOC_LIBS = \
$(top_builddir)/src/libtracker-miner/libtracker-miner.la \
+ $(top_builddir)/src/libtracker-common/libtracker-common.la \
$(HAL_LIBS) \
$(DBUS_LIBS) \
$(UNAC_LIBS) \
diff --git a/docs/reference/libtracker-miner/tmpl/tracker-miner-fs.sgml b/docs/reference/libtracker-miner/tmpl/tracker-miner-fs.sgml
index 801e88e..893df79 100644
--- a/docs/reference/libtracker-miner/tmpl/tracker-miner-fs.sgml
+++ b/docs/reference/libtracker-miner/tmpl/tracker-miner-fs.sgml
@@ -83,6 +83,17 @@ Tracker Filesystem Miner
@arg3:
@Returns:
+<!-- ##### SIGNAL TrackerMinerFS::writeback-file ##### -->
+<para>
+
+</para>
+
+ trackerminerfs: the object which received the signal.
+ arg1:
+ arg2:
+ arg3:
+ Returns:
+
<!-- ##### ARG TrackerMinerFS:process-pool-limit ##### -->
<para>
@@ -103,6 +114,7 @@ Tracker Filesystem Miner
@check_directory:
@check_directory_contents:
@process_file:
+ writeback_file:
@monitor_directory:
@finished:
diff --git a/docs/reference/libtracker-miner/tmpl/tracker-miner.sgml b/docs/reference/libtracker-miner/tmpl/tracker-miner.sgml
index 3f0e415..980b3af 100644
--- a/docs/reference/libtracker-miner/tmpl/tracker-miner.sgml
+++ b/docs/reference/libtracker-miner/tmpl/tracker-miner.sgml
@@ -75,6 +75,14 @@ Tracker Miner
@trackerminer: the object which received the signal.
+<!-- ##### SIGNAL TrackerMiner::writeback ##### -->
+<para>
+
+</para>
+
+ trackerminer: the object which received the signal.
+ arg1:
+
<!-- ##### ARG TrackerMiner:name ##### -->
<para>
@@ -103,6 +111,7 @@ Tracker Miner
@terminated:
@progress:
@error:
+ writeback:
<!-- ##### FUNCTION tracker_miner_error_quark ##### -->
<para>
diff --git a/src/tracker-store/tracker-dbus.c b/src/tracker-store/tracker-dbus.c
index 9c7b975..310bfcc 100644
--- a/src/tracker-store/tracker-dbus.c
+++ b/src/tracker-store/tracker-dbus.c
@@ -170,10 +170,10 @@ tracker_dbus_shutdown (void)
static void
name_owner_changed_cb (DBusGProxy *proxy,
- gchar *name,
- gchar *old_owner,
- gchar *new_owner,
- gpointer user_data)
+ gchar *name,
+ gchar *old_owner,
+ gchar *new_owner,
+ gpointer user_data)
{
if (tracker_is_empty_string (new_owner) && !tracker_is_empty_string (old_owner)) {
/* This means that old_owner got removed */
@@ -182,7 +182,8 @@ name_owner_changed_cb (DBusGProxy *proxy,
}
static void
-name_owner_changed_closure (gpointer data, GClosure *closure)
+name_owner_changed_closure (gpointer data,
+ GClosure *closure)
{
}
diff --git a/src/tracker-store/tracker-main.c b/src/tracker-store/tracker-main.c
index b12f546..5a5b28c 100644
--- a/src/tracker-store/tracker-main.c
+++ b/src/tracker-store/tracker-main.c
@@ -277,12 +277,17 @@ get_notifiable_classes (void)
TrackerDBResultSet *result_set;
GStrv classes_to_signal = NULL;
- result_set = tracker_data_query_sparql ("SELECT ?class WHERE { ?class tracker:notify true }", NULL);
+ result_set = tracker_data_query_sparql ("SELECT ?class WHERE { "
+ " ?class tracker:notify true "
+ "}",
+ NULL);
if (result_set) {
guint count = 0;
- classes_to_signal = tracker_dbus_query_result_to_strv (result_set, 0, &count);
+ classes_to_signal = tracker_dbus_query_result_to_strv (result_set,
+ 0,
+ &count);
g_object_unref (result_set);
}
@@ -296,12 +301,17 @@ get_writeback_predicates (void)
TrackerDBResultSet *result_set;
GStrv predicates_to_signal = NULL;
- result_set = tracker_data_query_sparql ("SELECT ?predicate WHERE { ?predicate tracker:writeback true }", NULL);
+ result_set = tracker_data_query_sparql ("SELECT ?predicate WHERE { "
+ " ?predicate tracker:writeback true "
+ "}",
+ NULL);
if (result_set) {
guint count = 0;
- predicates_to_signal = tracker_dbus_query_result_to_strv (result_set, 0, &count);
+ predicates_to_signal = tracker_dbus_query_result_to_strv (result_set,
+ 0,
+ &count);
g_object_unref (result_set);
}
diff --git a/src/tracker-store/tracker-push.c b/src/tracker-store/tracker-push.c
index e23c952..afc73b8 100644
--- a/src/tracker-store/tracker-push.c
+++ b/src/tracker-store/tracker-push.c
@@ -97,10 +97,10 @@ load_modules (PushSupportPrivate *private)
static void
name_owner_changed_cb (DBusGProxy *proxy,
- gchar *name,
- gchar *old_owner,
- gchar *new_owner,
- gpointer user_data)
+ gchar *name,
+ gchar *old_owner,
+ gchar *new_owner,
+ gpointer user_data)
{
GList *copy;
PushSupportPrivate *private;
diff --git a/src/tracker-store/tracker-resources.c b/src/tracker-store/tracker-resources.c
index b9d37f5..0456d46 100644
--- a/src/tracker-store/tracker-resources.c
+++ b/src/tracker-store/tracker-resources.c
@@ -426,7 +426,6 @@ on_statements_committed (gpointer user_data)
if (writebacks) {
g_signal_emit (resources, signals[WRITEBACK], 0, writebacks);
- g_hash_table_unref (writebacks);
}
diff --git a/src/tracker-store/tracker-writeback.c b/src/tracker-store/tracker-writeback.c
index 5b19796..e679587 100644
--- a/src/tracker-store/tracker-writeback.c
+++ b/src/tracker-store/tracker-writeback.c
@@ -1,6 +1,6 @@
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
/*
- * Copyright (C) 2008, Nokia
+ * Copyright (C) 2009, Nokia
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public
@@ -34,31 +34,14 @@ typedef struct {
static GStaticPrivate private_key = G_STATIC_PRIVATE_INIT;
-static void
-tracker_writeback_add_allow (const gchar *predicate)
-{
- WritebackPrivate *private;
-
- private = g_static_private_get (&private_key);
- g_return_if_fail (private != NULL);
-
- g_hash_table_insert (private->allowances, g_strdup (predicate),
- GINT_TO_POINTER (TRUE));
-}
-
-static gboolean
-is_allowed (WritebackPrivate *private, const gchar *rdf_predicate)
-{
- return (g_hash_table_lookup (private->allowances, rdf_predicate) != NULL) ? TRUE : FALSE;
-}
-
-
static GStrv
copy_rdf_types (GPtrArray *rdf_types)
{
- GStrv new_types = g_new0 (gchar*, rdf_types->len + 1);
+ GStrv new_types;
guint n;
+ new_types = g_new0 (gchar *, rdf_types->len + 1);
+
for (n = 0; n < rdf_types->len; n++) {
new_types[n] = g_strdup (rdf_types->pdata[n]);
}
@@ -66,37 +49,40 @@ copy_rdf_types (GPtrArray *rdf_types)
return new_types;
}
-
void
tracker_writeback_check (const gchar *graph,
const gchar *subject,
const gchar *predicate,
const gchar *object,
- GPtrArray *rdf_types)
+ GPtrArray *rdf_types)
{
WritebackPrivate *private;
/* When graph is NULL, the graph is the default one. We only do
* writeback reporting in the default graph (update queries that
- * aren't coming from the miner) */
+ * aren't coming from the miner)
+ */
if (graph != NULL) {
+ g_debug ("Not doing writeback check, no graph");
return;
}
private = g_static_private_get (&private_key);
g_return_if_fail (private != NULL);
- if (is_allowed (private, predicate)) {
-
+ if (g_hash_table_lookup (private->allowances, predicate)) {
if (!private->events) {
private->events = g_hash_table_new_full (g_str_hash, g_str_equal,
(GDestroyNotify) g_free,
(GDestroyNotify) g_strfreev);
}
- g_hash_table_insert (private->events, g_strdup (subject),
+ g_hash_table_insert (private->events,
+ g_strdup (subject),
copy_rdf_types (rdf_types));
+ } else {
+ g_debug ("No predicates to notify for writeback");
}
}
@@ -122,47 +108,58 @@ tracker_writeback_get_pending (void)
private = g_static_private_get (&private_key);
g_return_val_if_fail (private != NULL, NULL);
- return private->events ? g_hash_table_ref (private->events) : NULL;
+ return private->events;
}
static void
-free_private (WritebackPrivate *private)
+free_private (gpointer user_data)
{
+ WritebackPrivate *private;
+
+ private = user_data;
g_hash_table_unref (private->allowances);
g_free (private);
}
void
-tracker_writeback_init (TrackerWritebackPredicateGetter callback)
+tracker_writeback_init (TrackerWritebackGetPredicatesFunc func)
{
WritebackPrivate *private;
- GStrv predicates_to_signal;
- gint i, count;
+ GStrv predicates_to_signal;
+ gint i, count;
+
+ private = g_static_private_get (&private_key);
+ g_return_if_fail (private == NULL);
private = g_new0 (WritebackPrivate, 1);
- g_static_private_set (&private_key,
- private,
- (GDestroyNotify) free_private);
+ g_static_private_set (&private_key, private, free_private);
- private->allowances = g_hash_table_new_full (g_str_hash, g_str_equal,
+ private->allowances = g_hash_table_new_full (g_str_hash,
+ g_str_equal,
(GDestroyNotify) g_free,
- (GDestroyNotify) NULL);
+ NULL);
- private->events = NULL;
+ g_message ("Setting up predicates for writeback notification...");
- if (!callback) {
+ if (!func) {
+ g_message (" No predicates set, no TrackerWritebackGetPredicatesFunc");
return;
}
- predicates_to_signal = (*callback)();
+ predicates_to_signal = (*func)();
- if (!predicates_to_signal)
+ if (!predicates_to_signal) {
+ g_message (" No predicates set, none are configured in ontology");
return;
+ }
count = g_strv_length (predicates_to_signal);
for (i = 0; i < count; i++) {
- tracker_writeback_add_allow (predicates_to_signal[i]);
+ g_message (" Adding:'%s'", predicates_to_signal[i]);
+ g_hash_table_insert (private->allowances,
+ g_strdup (predicates_to_signal[i]),
+ GINT_TO_POINTER (TRUE));
}
g_strfreev (predicates_to_signal);
@@ -174,10 +171,8 @@ tracker_writeback_shutdown (void)
WritebackPrivate *private;
private = g_static_private_get (&private_key);
- if (private != NULL) {
- tracker_writeback_reset ();
- g_static_private_set (&private_key, NULL, NULL);
- } else {
- g_warning ("tracker_writeback already shutdown");
- }
+ g_return_if_fail (private != NULL);
+
+ tracker_writeback_reset ();
+ g_static_private_set (&private_key, NULL, NULL);
}
diff --git a/src/tracker-store/tracker-writeback.h b/src/tracker-store/tracker-writeback.h
index 31c2f00..3c12ff5 100644
--- a/src/tracker-store/tracker-writeback.h
+++ b/src/tracker-store/tracker-writeback.h
@@ -21,25 +21,25 @@
* Philip Van Hoof <philip codeminded be>
*/
-#ifndef __TRACKER_WRITEBACK_H__
-#define __TRACKER_WRITEBACK_H__
+#ifndef __TRACKER_STORE_WRITEBACK_H__
+#define __TRACKER_STORE_WRITEBACK_H__
#include <libtracker-common/tracker-dbus.h>
G_BEGIN_DECLS
-typedef GStrv (*TrackerWritebackPredicateGetter) (void);
+typedef GStrv (*TrackerWritebackGetPredicatesFunc) (void);
-void tracker_writeback_init (TrackerWritebackPredicateGetter callback);
-void tracker_writeback_shutdown (void);
-void tracker_writeback_check (const gchar *graph,
- const gchar *subject,
- const gchar *predicate,
- const gchar *object,
- GPtrArray *rdf_types);
-GHashTable* tracker_writeback_get_pending (void);
-void tracker_writeback_reset (void);
+void tracker_writeback_init (TrackerWritebackGetPredicatesFunc callback);
+void tracker_writeback_shutdown (void);
+void tracker_writeback_check (const gchar *graph,
+ const gchar *subject,
+ const gchar *predicate,
+ const gchar *object,
+ GPtrArray *rdf_types);
+GHashTable* tracker_writeback_get_pending (void);
+void tracker_writeback_reset (void);
G_END_DECLS
-#endif /* __TRACKER_WRITEBACK_H__ */
+#endif /* __TRACKER_STORE_WRITEBACK_H__ */
diff --git a/src/tracker-writeback/Makefile.am b/src/tracker-writeback/Makefile.am
index 1354efa..ff0c7b6 100644
--- a/src/tracker-writeback/Makefile.am
+++ b/src/tracker-writeback/Makefile.am
@@ -3,20 +3,20 @@ include $(top_srcdir)/Makefile.decl
module_flags = -module -avoid-version -no-undefined
modulesdir = $(libdir)/tracker-$(TRACKER_API_VERSION)/writeback-modules
-INCLUDES = \
- -DLOCALEDIR=\""$(localedir)"\" \
- -DMODULESDIR=\"$(modulesdir)\" \
- -DG_LOG_DOMAIN=\"Tracker\" \
- -DTRACKER_COMPILATION \
- -DWRITEBACK_MODULES_DIR=\""$(modulesdir)"\" \
- -I$(top_srcdir)/src \
- $(TRACKER_APPS_CFLAGS) \
- $(WARN_CFLAGS) \
- $(GLIB2_CFLAGS) \
- $(GCOV_CFLAGS) \
- $(GMODULE_CFLAGS) \
- $(DBUS_CFLAGS) \
- $(ID3LIB_CFLAGS) \
+INCLUDES = \
+ -DLOCALEDIR=\""$(localedir)"\" \
+ -DMODULESDIR=\"$(modulesdir)\" \
+ -DG_LOG_DOMAIN=\"Tracker\" \
+ -DTRACKER_COMPILATION \
+ -DWRITEBACK_MODULES_DIR=\""$(modulesdir)"\" \
+ -I$(top_srcdir)/src \
+ $(TRACKER_APPS_CFLAGS) \
+ $(WARN_CFLAGS) \
+ $(GLIB2_CFLAGS) \
+ $(GCOV_CFLAGS) \
+ $(GMODULE_CFLAGS) \
+ $(DBUS_CFLAGS) \
+ $(ID3LIB_CFLAGS) \
$(EXEMPI_CFLAGS)
modules_LTLIBRARIES =
@@ -42,23 +42,23 @@ endif
#
libexec_PROGRAMS = tracker-writeback
-tracker_writeback_SOURCES = \
- $(marshal_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 \
- tracker-writeback.h \
+tracker_writeback_SOURCES = \
+ $(marshal_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 \
+ tracker-writeback.h \
tracker-main.c
tracker_writeback_LDADD = \
- $(top_builddir)/src/libtracker-common/libtracker-common.la \
- $(top_builddir)/src/libtracker-client/libtracker-client- TRACKER_API_VERSION@.la \
$(top_builddir)/src/libtracker-miner/libtracker-miner.la \
+ $(top_builddir)/src/libtracker-client/libtracker-client- TRACKER_API_VERSION@.la \
+ $(top_builddir)/src/libtracker-common/libtracker-common.la \
$(TRACKER_APPS_LIBS) \
$(DBUS_LIBS) \
$(GMODULE_LIBS) \
diff --git a/src/tracker-writeback/tracker-main.c b/src/tracker-writeback/tracker-main.c
index e84833c..5629061 100644
--- a/src/tracker-writeback/tracker-main.c
+++ b/src/tracker-writeback/tracker-main.c
@@ -1,6 +1,6 @@
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
/*
- * Copyright (C) 2008, Nokia
+ * Copyright (C) 2009, Nokia
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public
@@ -19,9 +19,11 @@
*/
#include "config.h"
-#include "tracker-writeback-dispatcher.h"
+
#include <stdlib.h>
+#include "tracker-writeback-dispatcher.h"
+
int
main (int argc,
char *argv[])
diff --git a/src/tracker-writeback/tracker-writeback-dispatcher.c b/src/tracker-writeback/tracker-writeback-dispatcher.c
index 3a380db..de5d2dc 100644
--- a/src/tracker-writeback/tracker-writeback-dispatcher.c
+++ b/src/tracker-writeback/tracker-writeback-dispatcher.c
@@ -1,6 +1,6 @@
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
/*
- * Copyright (C) 2008, Nokia
+ * Copyright (C) 2009, Nokia
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public
@@ -17,6 +17,9 @@
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
+
+#include "config.h"
+
#include <stdlib.h>
#include <libtracker-common/tracker-dbus.h>
@@ -28,39 +31,38 @@
#include "tracker-writeback-module.h"
#include "tracker-marshal.h"
+#define TRACKER_WRITEBACK_DISPATCHER_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), TRACKER_TYPE_WRITEBACK_DISPATCHER, TrackerWritebackDispatcherPrivate))
+
+#define TRACKER_SERVICE "org.freedesktop.Tracker1"
+#define TRACKER_RESOURCES_OBJECT "/org/freedesktop/Tracker1/Resources"
+#define TRACKER_INTERFACE_RESOURCES "org.freedesktop.Tracker1.Resources"
+
typedef struct {
DBusGConnection *connection;
- DBusGProxy *gproxy, *tproxy;
+ DBusGProxy *proxy_dbus;
+ DBusGProxy *proxy_resources;
} DBusData;
typedef struct {
+ TrackerWritebackDispatcher *dispatcher;
+ GStrv rdf_types;
+} QueryData;
+
+typedef struct {
GHashTable *modules;
DBusData *dbus_data;
TrackerClient *client;
TrackerMinerManager *manager;
} TrackerWritebackDispatcherPrivate;
-typedef struct {
- TrackerWritebackDispatcher *dispatcher;
- GStrv rdf_types;
-} QueryData;
-
-#define TRACKER_WRITEBACK_DISPATCHER_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), TRACKER_TYPE_WRITEBACK_DISPATCHER, TrackerWritebackDispatcherPrivate))
-
-#define TRACKER_SERVICE "org.freedesktop.Tracker1"
-#define TRACKER_RESOURCES_OBJECT "/org/freedesktop/Tracker1/Resources"
-#define TRACKER_INTERFACE_RESOURCES "org.freedesktop.Tracker1.Resources"
-
static void tracker_writeback_dispatcher_finalize (GObject *object);
static void tracker_writeback_dispatcher_constructed (GObject *object);
-static void on_writeback_cb (DBusGProxy *proxy,
+static void sparql_writeback_cb (DBusGProxy *proxy,
GHashTable *subjects,
TrackerWritebackDispatcher *object);
-
G_DEFINE_TYPE (TrackerWritebackDispatcher, tracker_writeback_dispatcher, G_TYPE_OBJECT)
-
static void
tracker_writeback_dispatcher_class_init (TrackerWritebackDispatcherClass *klass)
{
@@ -77,7 +79,7 @@ dbus_register_service (DBusGProxy *proxy,
const gchar *name)
{
GError *error = NULL;
- guint result;
+ guint result;
g_message ("Registering D-Bus service '%s'...", name);
@@ -94,9 +96,9 @@ dbus_register_service (DBusGProxy *proxy,
}
if (result != DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER) {
- g_message ("D-Bus service name:'%s' is already taken, "
- "perhaps the application is already running?",
- name);
+ g_critical ("D-Bus service name:'%s' is already taken, "
+ "perhaps the application is already running?",
+ name);
return FALSE;
}
@@ -121,7 +123,7 @@ dbus_register_object (GObject *object,
}
static DBusData *
-dbus_data_create (GObject *object)
+dbus_data_new (GObject *object)
{
DBusData *data;
DBusGConnection *connection;
@@ -132,7 +134,7 @@ dbus_data_create (GObject *object)
if (!connection) {
g_critical ("Could not connect to the D-Bus session bus, %s",
- error ? error->message : "no error given.");
+ error ? error->message : "no error given.");
g_error_free (error);
return NULL;
}
@@ -164,7 +166,7 @@ dbus_data_create (GObject *object)
/* Now we're successfully connected and registered, create the data */
data = g_new0 (DBusData, 1);
data->connection = dbus_g_connection_ref (connection);
- data->gproxy = gproxy;
+ data->proxy_dbus = gproxy;
return data;
}
@@ -174,11 +176,13 @@ dbus_data_free (DBusData *data)
{
dbus_g_connection_unref (data->connection);
- if (data->gproxy)
- g_object_unref (data->gproxy);
+ if (data->proxy_dbus) {
+ g_object_unref (data->proxy_dbus);
+ }
- if (data->tproxy)
- g_object_unref (data->tproxy);
+ if (data->proxy_resources) {
+ g_object_unref (data->proxy_resources);
+ }
g_free (data);
}
@@ -191,7 +195,7 @@ tracker_writeback_dispatcher_init (TrackerWritebackDispatcher *dispatcher)
priv = TRACKER_WRITEBACK_DISPATCHER_GET_PRIVATE (dispatcher);
priv->client = tracker_connect (TRUE, 0);
- priv->dbus_data = dbus_data_create (G_OBJECT (dispatcher));
+ priv->dbus_data = dbus_data_new (G_OBJECT (dispatcher));
if (!priv->dbus_data) {
tracker_disconnect (priv->client);
@@ -203,17 +207,20 @@ tracker_writeback_dispatcher_init (TrackerWritebackDispatcher *dispatcher)
(GDestroyNotify) g_free,
NULL);
- priv->dbus_data->tproxy = dbus_g_proxy_new_for_name (priv->dbus_data->connection,
- TRACKER_SERVICE,
- TRACKER_RESOURCES_OBJECT,
- TRACKER_INTERFACE_RESOURCES);
+ priv->dbus_data->proxy_resources =
+ dbus_g_proxy_new_for_name (priv->dbus_data->connection,
+ TRACKER_SERVICE,
+ TRACKER_RESOURCES_OBJECT,
+ TRACKER_INTERFACE_RESOURCES);
- dbus_g_proxy_add_signal (priv->dbus_data->tproxy, "Writeback",
+ dbus_g_proxy_add_signal (priv->dbus_data->proxy_resources,
+ "Writeback",
TRACKER_TYPE_STR_STRV_MAP,
G_TYPE_INVALID);
- dbus_g_proxy_connect_signal (priv->dbus_data->tproxy, "Writeback",
- G_CALLBACK (on_writeback_cb),
+ dbus_g_proxy_connect_signal (priv->dbus_data->proxy_resources,
+ "Writeback",
+ G_CALLBACK (sparql_writeback_cb),
dispatcher,
NULL);
@@ -241,8 +248,8 @@ tracker_writeback_dispatcher_finalize (GObject *object)
static void
tracker_writeback_dispatcher_constructed (GObject *object)
{
- GList *modules;
TrackerWritebackDispatcherPrivate *priv;
+ GList *modules;
priv = TRACKER_WRITEBACK_DISPATCHER_GET_PRIVATE (object);
modules = tracker_writeback_modules_list ();
@@ -255,19 +262,19 @@ tracker_writeback_dispatcher_constructed (GObject *object)
module = tracker_writeback_module_get (path);
g_hash_table_insert (priv->modules, g_strdup (path), module);
-
modules = modules->next;
}
}
TrackerWritebackDispatcher *
-tracker_writeback_dispatcher_new ()
+tracker_writeback_dispatcher_new (void)
{
return g_object_new (TRACKER_TYPE_WRITEBACK_DISPATCHER, NULL);
}
static gboolean
-types_match (const gchar **module_types, gchar **rdf_types)
+sparql_rdf_types_match (const gchar * const *module_types,
+ const gchar * const *rdf_types)
{
guint n;
@@ -285,40 +292,47 @@ types_match (const gchar **module_types, gchar **rdf_types)
}
static void
-on_sparql_result_received (GPtrArray *result,
- GError *error,
- gpointer user_data)
+sparql_query_cb (GPtrArray *result,
+ GError *error,
+ gpointer user_data)
{
TrackerWritebackDispatcherPrivate *priv;
- TrackerWritebackModule *module;
- GHashTableIter iter;
- gpointer key, value;
QueryData *data;
- const gchar **module_types;
- gchar **rdf_types;
data = user_data;
if (result && result->len > 0) {
- rdf_types = data->rdf_types;
+ GHashTableIter iter;
+ gpointer key, value;
+ GStrv rdf_types;
+
priv = TRACKER_WRITEBACK_DISPATCHER_GET_PRIVATE (data->dispatcher);
+ rdf_types = data->rdf_types;
+
g_hash_table_iter_init (&iter, priv->modules);
while (g_hash_table_iter_next (&iter, &key, &value)) {
- module = value;
+ TrackerWritebackModule *module;
+ const gchar * const *module_types;
- module_types = tracker_writeback_module_get_rdftypes (module);
+ module = value;
+ module_types = tracker_writeback_module_get_rdf_types (module);
- if (types_match (module_types, rdf_types)) {
+ if (sparql_rdf_types_match (module_types, (const gchar * const *) rdf_types)) {
TrackerWriteback *writeback;
+ g_message (" Updating metadata for file:'%s' using module:'%s'",
+ "unknown",
+ module->name);
+
writeback = tracker_writeback_module_create (module);
tracker_writeback_update_metadata (writeback, result);
g_object_unref (writeback);
}
-
}
+ } else {
+ g_message (" No files qualify for updates");
}
g_strfreev (data->rdf_types);
@@ -326,9 +340,9 @@ on_sparql_result_received (GPtrArray *result,
}
static void
-on_writeback_cb (DBusGProxy *proxy,
- GHashTable *subjects,
- TrackerWritebackDispatcher *object)
+sparql_writeback_cb (DBusGProxy *proxy,
+ GHashTable *subjects,
+ TrackerWritebackDispatcher *object)
{
TrackerWritebackDispatcherPrivate *priv;
QueryData *data;
@@ -337,26 +351,30 @@ on_writeback_cb (DBusGProxy *proxy,
priv = TRACKER_WRITEBACK_DISPATCHER_GET_PRIVATE (object);
+ g_message ("Writeback signalled with %d subjects...",
+ g_hash_table_size (subjects));
+
g_hash_table_iter_init (&iter, subjects);
while (g_hash_table_iter_next (&iter, &key, &value)) {
const gchar *subject = key;
- const GStrv rdf_types = value;
+ const gchar * const *rdf_types = value;
gchar *query;
- query = g_strdup_printf ("SELECT ?url ?predicate ?object { "
- "<%s> ?predicate ?object ; "
- "nie:isStoredAs ?url . "
- "?predicate tracker:writeback true "
- "}", subject);
+ query = g_strdup_printf ("SELECT ?url ?predicate ?object {"
+ " <%s> ?predicate ?object ;"
+ " nie:isStoredAs ?url ."
+ " ?predicate tracker:writeback true "
+ "}",
+ subject);
data = g_slice_new (QueryData);
data->dispatcher = object;
- data->rdf_types = g_strdupv (rdf_types);
+ data->rdf_types = g_strdupv ((gchar **) rdf_types);
tracker_resources_sparql_query_async (priv->client,
query,
- on_sparql_result_received,
+ sparql_query_cb,
data);
g_free (query);
diff --git a/src/tracker-writeback/tracker-writeback-dispatcher.h b/src/tracker-writeback/tracker-writeback-dispatcher.h
index f34ba9d..2ebecdf 100644
--- a/src/tracker-writeback/tracker-writeback-dispatcher.h
+++ b/src/tracker-writeback/tracker-writeback-dispatcher.h
@@ -1,6 +1,6 @@
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
/*
- * Copyright (C) 2008, Nokia
+ * Copyright (C) 2009, Nokia
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public
@@ -21,9 +21,9 @@
#ifndef __TRACKER_WRITEBACK_DISPATCHER_H__
#define __TRACKER_WRITEBACK_DISPATCHER_H__
-
#include <glib-object.h>
#include <gio/gio.h>
+
#include <libtracker-client/tracker.h>
G_BEGIN_DECLS
@@ -46,9 +46,8 @@ struct TrackerWritebackDispatcherClass {
GObjectClass parent_class;
};
-GType tracker_writeback_dispatcher_get_type (void) G_GNUC_CONST;
-
-TrackerWritebackDispatcher * tracker_writeback_dispatcher_new (void);
+GType tracker_writeback_dispatcher_get_type (void) G_GNUC_CONST;
+TrackerWritebackDispatcher * tracker_writeback_dispatcher_new (void);
G_END_DECLS
diff --git a/src/tracker-writeback/tracker-writeback-file.c b/src/tracker-writeback/tracker-writeback-file.c
index 5ce1ef7..c84a0e3 100644
--- a/src/tracker-writeback/tracker-writeback-file.c
+++ b/src/tracker-writeback/tracker-writeback-file.c
@@ -1,6 +1,6 @@
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
/*
- * Copyright (C) 2008, Nokia
+ * Copyright (C) 2009, Nokia
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public
@@ -18,17 +18,17 @@
* Boston, MA 02110-1301, USA.
*/
+#include "config.h"
+
#include <libtracker-common/tracker-file-utils.h>
#include "tracker-writeback-file.h"
static gboolean tracker_writeback_file_update_metadata (TrackerWriteback *writeback,
- GPtrArray *values);
+ GPtrArray *values);
G_DEFINE_ABSTRACT_TYPE (TrackerWritebackFile, tracker_writeback_file, TRACKER_TYPE_WRITEBACK)
-
-
static void
tracker_writeback_file_class_init (TrackerWritebackFileClass *klass)
{
@@ -43,10 +43,12 @@ tracker_writeback_file_init (TrackerWritebackFile *writeback_file)
}
static gboolean
-unlock_file_cb (GFile *file)
+file_unlock_cb (gpointer user_data)
{
+ GFile *file;
gchar *path;
+ file = user_data;
path = g_file_get_path (file);
g_message ("Unlocking file '%s'", path);
g_free (path);
@@ -68,7 +70,7 @@ tracker_writeback_file_update_metadata (TrackerWriteback *writeback,
const gchar *subjects[2] = { NULL, NULL };
GStrv row;
TrackerWritebackFile *self;
- const gchar **content_types;
+ const gchar * const *content_types;
const gchar *mime_type;
guint n;
@@ -91,11 +93,16 @@ tracker_writeback_file_update_metadata (TrackerWriteback *writeback,
row = g_ptr_array_index (values, 0);
file = g_file_new_for_uri (row[0]);
- file_info = g_file_query_info (file, G_FILE_ATTRIBUTE_STANDARD_CONTENT_TYPE,
+ file_info = g_file_query_info (file,
+ G_FILE_ATTRIBUTE_STANDARD_CONTENT_TYPE,
G_FILE_QUERY_INFO_NOFOLLOW_SYMLINKS,
NULL, NULL);
if (!file_info) {
+ if (file) {
+ g_object_unref (file);
+ }
+
return FALSE;
}
@@ -125,7 +132,7 @@ tracker_writeback_file_update_metadata (TrackerWriteback *writeback,
retval = (writeback_file_class->update_file_metadata) (TRACKER_WRITEBACK_FILE (writeback),
file, values);
- g_timeout_add_seconds (3, (GSourceFunc) unlock_file_cb, g_object_ref (file));
+ g_timeout_add_seconds (3, file_unlock_cb, g_object_ref (file));
}
g_object_unref (file);
diff --git a/src/tracker-writeback/tracker-writeback-file.h b/src/tracker-writeback/tracker-writeback-file.h
index 140951e..d557f9c 100644
--- a/src/tracker-writeback/tracker-writeback-file.h
+++ b/src/tracker-writeback/tracker-writeback-file.h
@@ -1,6 +1,6 @@
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
/*
- * Copyright (C) 2008, Nokia
+ * Copyright (C) 2009, Nokia
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public
@@ -18,13 +18,13 @@
* Boston, MA 02110-1301, USA.
*/
+#ifndef __TRACKER_WRITEBACK_FILE_H__
+#define __TRACKER_WRITEBACK_FILE_H__
+
#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())
@@ -44,16 +44,15 @@ struct TrackerWritebackFile {
struct TrackerWritebackFileClass {
TrackerWritebackClass parent_class;
- gboolean (* update_file_metadata) (TrackerWritebackFile *writeback_file,
- GFile *file,
- GPtrArray *values);
- const gchar** (* content_types) (TrackerWritebackFile *writeback_file);
+ gboolean (* update_file_metadata) (TrackerWritebackFile *writeback_file,
+ GFile *file,
+ GPtrArray *values);
+ const gchar * const * (* content_types) (TrackerWritebackFile *writeback_file);
};
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-module.c b/src/tracker-writeback/tracker-writeback-module.c
index ee21b08..bdfb3ee 100644
--- a/src/tracker-writeback/tracker-writeback-module.c
+++ b/src/tracker-writeback/tracker-writeback-module.c
@@ -1,7 +1,6 @@
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
/*
- * Copyright (C) 2008, Mr Jamie McCracken (jamiemcc gnome org)
- * Copyright (C) 2008, Nokia
+ * Copyright (C) 2009, Nokia
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public
@@ -19,23 +18,24 @@
* Boston, MA 02110-1301, USA.
*/
-#include <gmodule.h>
-#include "tracker-writeback-module.h"
+#include "config.h"
+#include <gmodule.h>
-static gboolean tracker_writeback_module_load (GTypeModule *module);
-static void tracker_writeback_module_unload (GTypeModule *module);
+#include "tracker-writeback-module.h"
+static gboolean writeback_module_load (GTypeModule *module);
+static void writeback_module_unload (GTypeModule *module);
G_DEFINE_TYPE (TrackerWritebackModule, tracker_writeback_module, G_TYPE_TYPE_MODULE)
static void
tracker_writeback_module_class_init (TrackerWritebackModuleClass *klass)
{
- GTypeModuleClass *module_class = G_TYPE_MODULE_CLASS (klass);
+ GTypeModuleClass *module_class = G_TYPE_MODULE_CLASS (klass);
- module_class->load = tracker_writeback_module_load;
- module_class->unload = tracker_writeback_module_unload;
+ module_class->load = writeback_module_load;
+ module_class->unload = writeback_module_unload;
}
static void
@@ -44,7 +44,7 @@ tracker_writeback_module_init (TrackerWritebackModule *module)
}
static gboolean
-tracker_writeback_module_load (GTypeModule *module)
+writeback_module_load (GTypeModule *module)
{
TrackerWritebackModule *writeback_module;
gchar *path;
@@ -57,8 +57,8 @@ tracker_writeback_module_load (GTypeModule *module)
if (G_UNLIKELY (!writeback_module->module)) {
g_warning ("Could not load writeback module '%s': %s\n",
- writeback_module->name,
- g_module_error ());
+ writeback_module->name,
+ g_module_error ());
return FALSE;
}
@@ -66,21 +66,23 @@ tracker_writeback_module_load (GTypeModule *module)
g_module_make_resident (writeback_module->module);
if (!g_module_symbol (writeback_module->module, "writeback_module_create",
- (gpointer *) &writeback_module->create) ||
- !g_module_symbol (writeback_module->module, "writeback_module_get_rdftypes",
- (gpointer *) &writeback_module->get_rdftypes)) {
+ (gpointer *) &writeback_module->create) ||
+ !g_module_symbol (writeback_module->module, "writeback_module_get_rdf_types",
+ (gpointer *) &writeback_module->get_rdf_types)) {
g_warning ("Could not load module symbols for '%s': %s",
- writeback_module->name,
- g_module_error ());
+ writeback_module->name,
+ g_module_error ());
return FALSE;
}
+ g_message ("Loaded module:'%s'", writeback_module->name);
+
return TRUE;
}
static void
-tracker_writeback_module_unload (GTypeModule *module)
+writeback_module_unload (GTypeModule *module)
{
TrackerWritebackModule *writeback_module;
@@ -88,12 +90,14 @@ tracker_writeback_module_unload (GTypeModule *module)
g_module_close (writeback_module->module);
writeback_module->module = NULL;
+
+ g_message ("Unloaded module:'%s'", writeback_module->name);
}
TrackerWritebackModule *
tracker_writeback_module_get (const gchar *name)
{
- static GHashTable *modules;
+ static GHashTable *modules = NULL;
TrackerWritebackModule *module;
g_return_val_if_fail (name != NULL, NULL);
@@ -145,7 +149,7 @@ tracker_writeback_modules_list (void)
g_dir_close (dir);
- return list;
+ return g_list_reverse (list);
}
TrackerWriteback *
@@ -154,8 +158,8 @@ tracker_writeback_module_create (TrackerWritebackModule *module)
return (module->create) (G_TYPE_MODULE (module));
}
-const gchar**
-tracker_writeback_module_get_rdftypes (TrackerWritebackModule *module)
+const gchar * const *
+tracker_writeback_module_get_rdf_types (TrackerWritebackModule *module)
{
- return (module->get_rdftypes) ();
+ return (module->get_rdf_types) ();
}
diff --git a/src/tracker-writeback/tracker-writeback-module.h b/src/tracker-writeback/tracker-writeback-module.h
index 7f40ec0..11f4b61 100644
--- a/src/tracker-writeback/tracker-writeback-module.h
+++ b/src/tracker-writeback/tracker-writeback-module.h
@@ -1,7 +1,6 @@
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
/*
- * Copyright (C) 2008, Mr Jamie McCracken (jamiemcc gnome org)
- * Copyright (C) 2008, Nokia
+ * Copyright (C) 2009, Nokia
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public
@@ -24,6 +23,7 @@
#include <glib.h>
#include <glib-object.h>
+
#include "tracker-writeback.h"
G_BEGIN_DECLS
@@ -40,24 +40,20 @@ struct TrackerWritebackModule {
GModule *module;
gchar *name;
- TrackerWriteback * (* create) (GTypeModule *module);
- const gchar ** (* get_rdftypes) (void);
+ TrackerWriteback * (* create) (GTypeModule *module);
+ const gchar * const * (* get_rdf_types) (void);
};
struct TrackerWritebackModuleClass {
GTypeModuleClass parent_class;
};
+GType tracker_writeback_module_get_type (void) G_GNUC_CONST;
-GType tracker_writeback_module_get_type (void) G_GNUC_CONST;
-
-TrackerWritebackModule * tracker_writeback_module_get (const gchar *name);
-
-TrackerWriteback * tracker_writeback_module_create (TrackerWritebackModule *module);
-const gchar** tracker_writeback_module_get_rdftypes (TrackerWritebackModule *module);
-
-GList * tracker_writeback_modules_list (void);
-
+TrackerWritebackModule *tracker_writeback_module_get (const gchar *name);
+TrackerWriteback * tracker_writeback_module_create (TrackerWritebackModule *module);
+const gchar * const * tracker_writeback_module_get_rdf_types (TrackerWritebackModule *module);
+GList * tracker_writeback_modules_list (void);
G_END_DECLS
diff --git a/src/tracker-writeback/tracker-writeback-mp3.c b/src/tracker-writeback/tracker-writeback-mp3.c
index 58702c6..fe4d23c 100644
--- a/src/tracker-writeback/tracker-writeback-mp3.c
+++ b/src/tracker-writeback/tracker-writeback-mp3.c
@@ -1,6 +1,6 @@
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
/*
- * Copyright (C) 2008, Nokia
+ * Copyright (C) 2009, Nokia
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public
@@ -20,13 +20,15 @@
* Authors: Philip Van Hoof <philip codeminded be>
*/
+#include "config.h"
+
#include <id3.h>
#include <libtracker-common/tracker-ontology.h>
#include "tracker-writeback-file.h"
-#define TRACKER_TYPE_WRITEBACK_MP3 (tracker_writeback_mp3_get_type ())
+#define TRACKER_TYPE_WRITEBACK_MP3 (tracker_writeback_mp3_get_type ())
typedef struct TrackerWritebackMP3 TrackerWritebackMP3;
typedef struct TrackerWritebackMP3Class TrackerWritebackMP3Class;
@@ -39,11 +41,11 @@ struct TrackerWritebackMP3Class {
TrackerWritebackFileClass parent_class;
};
-static GType tracker_writeback_mp3_get_type (void) G_GNUC_CONST;
-static gboolean tracker_writeback_mp3_update_file_metadata (TrackerWritebackFile *writeback_file,
- GFile *file,
- GPtrArray *values);
-static const gchar** tracker_writeback_mp3_content_types (TrackerWritebackFile *writeback_file);
+static GType tracker_writeback_mp3_get_type (void) G_GNUC_CONST;
+static gboolean writeback_mp3_update_file_metadata (TrackerWritebackFile *wbf,
+ GFile *file,
+ GPtrArray *values);
+static const gchar * const *writeback_mp3_content_types (TrackerWritebackFile *wbf);
G_DEFINE_DYNAMIC_TYPE (TrackerWritebackMP3, tracker_writeback_mp3, TRACKER_TYPE_WRITEBACK_FILE);
@@ -52,8 +54,8 @@ tracker_writeback_mp3_class_init (TrackerWritebackMP3Class *klass)
{
TrackerWritebackFileClass *writeback_file_class = TRACKER_WRITEBACK_FILE_CLASS (klass);
- writeback_file_class->update_file_metadata = tracker_writeback_mp3_update_file_metadata;
- writeback_file_class->content_types = tracker_writeback_mp3_content_types;
+ writeback_file_class->update_file_metadata = writeback_mp3_update_file_metadata;
+ writeback_file_class->content_types = writeback_mp3_content_types;
}
static void
@@ -62,24 +64,26 @@ tracker_writeback_mp3_class_finalize (TrackerWritebackMP3Class *klass)
}
static void
-tracker_writeback_mp3_init (TrackerWritebackMP3 *mp3)
+tracker_writeback_mp3_init (TrackerWritebackMP3 *wbm)
{
}
-static const gchar**
-tracker_writeback_mp3_content_types (TrackerWritebackFile *writeback_file)
+static const gchar * const *
+writeback_mp3_content_types (TrackerWritebackFile *wbf)
{
- static const gchar *content_types[] = { "audio/mpeg",
- "audio/x-mp3",
- NULL };
+ static const gchar *content_types[] = {
+ "audio/mpeg",
+ "audio/x-mp3",
+ NULL
+ };
return content_types;
}
static gboolean
-tracker_writeback_mp3_update_file_metadata (TrackerWritebackFile *writeback_file,
- GFile *file,
- GPtrArray *values)
+writeback_mp3_update_file_metadata (TrackerWritebackFile *writeback_file,
+ GFile *file,
+ GPtrArray *values)
{
gchar *path;
guint n;
@@ -90,18 +94,21 @@ tracker_writeback_mp3_update_file_metadata (TrackerWritebackFile *writeback_file
const GStrv row = g_ptr_array_index (values, n);
if (g_strcmp0 (row[1], TRACKER_NIE_PREFIX "title") == 0) {
- ID3Tag *tag = ID3Tag_New ();
+ ID3Tag *tag;
ID3Frame *frame;
+ tag = ID3Tag_New ();
ID3Tag_Link (tag, path);
frame = ID3Tag_FindFrameWithID (tag, ID3FID_TITLE);
if (frame) {
ID3Field *field;
+
field = ID3Frame_GetField (frame, ID3FN_TEXT);
ID3Field_SetASCII (field, row[2]);
} else {
ID3Field *field;
+
frame = ID3Frame_NewID (ID3FID_TITLE);
field = ID3Frame_GetField (frame, ID3FN_TEXT);
ID3Field_SetASCII (field, row[2]);
@@ -110,7 +117,8 @@ tracker_writeback_mp3_update_file_metadata (TrackerWritebackFile *writeback_file
ID3Tag_Update (tag);
/* Apparently this ain't needed (and crashes)
- * ID3Frame_Delete (frame); */
+ * ID3Frame_Delete (frame);
+ */
ID3Tag_Delete (tag);
}
@@ -130,11 +138,13 @@ writeback_module_create (GTypeModule *module)
return g_object_new (TRACKER_TYPE_WRITEBACK_MP3, NULL);
}
-const gchar**
-writeback_module_get_rdftypes (void)
+const gchar * const *
+writeback_module_get_rdf_types (void)
{
- static const gchar *rdftypes[] = { TRACKER_NFO_PREFIX "Audio",
- NULL };
+ static const gchar *rdftypes[] = {
+ TRACKER_NFO_PREFIX "Audio",
+ NULL
+ };
return rdftypes;
}
diff --git a/src/tracker-writeback/tracker-writeback-xmp.c b/src/tracker-writeback/tracker-writeback-xmp.c
index 974ef0e..9c7aa6d 100644
--- a/src/tracker-writeback/tracker-writeback-xmp.c
+++ b/src/tracker-writeback/tracker-writeback-xmp.c
@@ -1,6 +1,6 @@
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
/*
- * Copyright (C) 2008, Nokia
+ * Copyright (C) 2009, Nokia
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public
@@ -25,7 +25,8 @@
#include <locale.h>
#include <string.h>
-#include <glib.h>
+#include <exempi/xmp.h>
+#include <exempi/xmpconsts.h>
#include <glib-object.h>
#include <gio/gio.h>
@@ -34,12 +35,9 @@
#include "tracker-writeback-file.h"
-#ifdef HAVE_EXEMPI
-
-#include <exempi/xmp.h>
-#include <exempi/xmpconsts.h>
+#define TRACKER_TYPE_WRITEBACK_XMP (tracker_writeback_xmp_get_type ())
-#define TRACKER_TYPE_WRITEBACK_XMP (tracker_writeback_xmp_get_type ())
+#define DEBUG_XMP
typedef struct TrackerWritebackXMP TrackerWritebackXMP;
typedef struct TrackerWritebackXMPClass TrackerWritebackXMPClass;
@@ -52,12 +50,11 @@ struct TrackerWritebackXMPClass {
TrackerWritebackFileClass parent_class;
};
-
-static GType tracker_writeback_xmp_get_type (void) G_GNUC_CONST;
-static gboolean tracker_writeback_xmp_update_file_metadata (TrackerWritebackFile *writeback_file,
- GFile *file,
- GPtrArray *values);
-static const gchar** tracker_writeback_xmp_content_types (TrackerWritebackFile *writeback_file);
+static GType tracker_writeback_xmp_get_type (void) G_GNUC_CONST;
+static gboolean writeback_xmp_update_file_metadata (TrackerWritebackFile *writeback_file,
+ GFile *file,
+ GPtrArray *values);
+static const gchar * const *writeback_xmp_content_types (TrackerWritebackFile *writeback_file);
G_DEFINE_DYNAMIC_TYPE (TrackerWritebackXMP, tracker_writeback_xmp, TRACKER_TYPE_WRITEBACK_FILE);
@@ -67,8 +64,9 @@ tracker_writeback_xmp_class_init (TrackerWritebackXMPClass *klass)
TrackerWritebackFileClass *writeback_file_class = TRACKER_WRITEBACK_FILE_CLASS (klass);
xmp_init ();
- writeback_file_class->update_file_metadata = tracker_writeback_xmp_update_file_metadata;
- writeback_file_class->content_types = tracker_writeback_xmp_content_types;
+
+ writeback_file_class->update_file_metadata = writeback_xmp_update_file_metadata;
+ writeback_file_class->content_types = writeback_xmp_content_types;
}
static void
@@ -78,18 +76,20 @@ tracker_writeback_xmp_class_finalize (TrackerWritebackXMPClass *klass)
}
static void
-tracker_writeback_xmp_init (TrackerWritebackXMP *xmp)
+tracker_writeback_xmp_init (TrackerWritebackXMP *wbx)
{
}
-static const gchar**
-tracker_writeback_xmp_content_types (TrackerWritebackFile *writeback_file)
+static const gchar * const *
+writeback_xmp_content_types (TrackerWritebackFile *wbf)
{
- static const gchar *content_types[] = { "image/png", /* .png files */
- "sketch/png", /* .sketch.png files on Maemo*/
- "image/jpeg", /* .jpg & .jpeg files */
- "image/tiff", /* .tiff & .tif files */
- NULL };
+ static const gchar *content_types[] = {
+ "image/png", /* .png files */
+ "sketch/png", /* .sketch.png files on Maemo*/
+ "image/jpeg", /* .jpg & .jpeg files */
+ "image/tiff", /* .tiff & .tif files */
+ NULL
+ };
/* "image/gif" .gif files
"application/pdf" .pdf files
@@ -104,9 +104,9 @@ tracker_writeback_xmp_content_types (TrackerWritebackFile *writeback_file)
}
static gboolean
-tracker_writeback_xmp_update_file_metadata (TrackerWritebackFile *writeback_file,
- GFile *file,
- GPtrArray *values)
+writeback_xmp_update_file_metadata (TrackerWritebackFile *wbf,
+ GFile *file,
+ GPtrArray *values)
{
gchar *path;
guint n;
@@ -133,10 +133,10 @@ tracker_writeback_xmp_update_file_metadata (TrackerWritebackFile *writeback_file
}
#ifdef DEBUG_XMP
- str = xmp_string_new();
+ str = xmp_string_new ();
g_print ("\nBEFORE: ---- \n");
- xmp_serialize_and_format(xmp, str, 0, 0, "\n", "\t", 1);
- printf ("%s\n", xmp_string_cstr (str));
+ xmp_serialize_and_format (xmp, str, 0, 0, "\n", "\t", 1);
+ g_print ("%s\n", xmp_string_cstr (str));
xmp_string_free (str);
#endif
@@ -145,11 +145,11 @@ tracker_writeback_xmp_update_file_metadata (TrackerWritebackFile *writeback_file
if (g_strcmp0 (row[1], TRACKER_NIE_PREFIX "title") == 0) {
xmp_delete_property (xmp, NS_EXIF, "Title");
- xmp_set_property(xmp, NS_EXIF, "Title", row[2], 0);
+ xmp_set_property (xmp, NS_EXIF, "Title", row[2], 0);
/* I have no idea why I have to set this, but without
* it seems that exiftool doesn't see the change */
- xmp_set_array_item(xmp, NS_DC, "title", 1, row[2], 0);
+ xmp_set_array_item (xmp, NS_DC, "title", 1, row[2], 0);
}
@@ -158,15 +158,15 @@ tracker_writeback_xmp_update_file_metadata (TrackerWritebackFile *writeback_file
#ifdef DEBUG_XMP
g_print ("\nAFTER: ---- \n");
- str = xmp_string_new();
- xmp_serialize_and_format(xmp, str, 0, 0, "\n", "\t", 1);
- printf ("%s\n", xmp_string_cstr (str));
+ str = xmp_string_new ();
+ xmp_serialize_and_format (xmp, str, 0, 0, "\n", "\t", 1);
+ g_print ("%s\n", xmp_string_cstr (str));
xmp_string_free (str);
g_print ("\n --------- \n");
#endif
- if (xmp_files_can_put_xmp(xmp_files, xmp)) {
- xmp_files_put_xmp(xmp_files, xmp);
+ if (xmp_files_can_put_xmp (xmp_files, xmp)) {
+ xmp_files_put_xmp (xmp_files, xmp);
}
xmp_files_close (xmp_files, XMP_CLOSE_SAFEUPDATE);
@@ -186,15 +186,15 @@ writeback_module_create (GTypeModule *module)
return g_object_new (TRACKER_TYPE_WRITEBACK_XMP, NULL);
}
-const gchar**
-writeback_module_get_rdftypes (void)
+const gchar * const *
+writeback_module_get_rdf_types (void)
{
- static const gchar *rdftypes[] = { TRACKER_NFO_PREFIX "Image",
- TRACKER_NFO_PREFIX "Audio",
- TRACKER_NFO_PREFIX "Video",
- NULL };
-
- return rdftypes;
+ static const gchar *rdf_types[] = {
+ TRACKER_NFO_PREFIX "Image",
+ TRACKER_NFO_PREFIX "Audio",
+ TRACKER_NFO_PREFIX "Video",
+ NULL
+ };
+
+ return rdf_types;
}
-
-#endif /* HAVE_EXEMPI */
diff --git a/src/tracker-writeback/tracker-writeback.c b/src/tracker-writeback/tracker-writeback.c
index eb878a7..adb54f1 100644
--- a/src/tracker-writeback/tracker-writeback.c
+++ b/src/tracker-writeback/tracker-writeback.c
@@ -1,6 +1,6 @@
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
/*
- * Copyright (C) 2008, Nokia
+ * Copyright (C) 2009, Nokia
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public
@@ -18,6 +18,8 @@
* Boston, MA 02110-1301, USA.
*/
+#include "config.h"
+
#include "tracker-writeback.h"
G_DEFINE_ABSTRACT_TYPE (TrackerWriteback, tracker_writeback, G_TYPE_OBJECT)
@@ -27,13 +29,11 @@ static TrackerMinerManager *manager = NULL;
static void
tracker_writeback_class_init (TrackerWritebackClass *klass)
{
-
}
static void
tracker_writeback_init (TrackerWriteback *writeback)
{
-
}
gboolean
diff --git a/src/tracker-writeback/tracker-writeback.h b/src/tracker-writeback/tracker-writeback.h
index 26a842f..0c30a1d 100644
--- a/src/tracker-writeback/tracker-writeback.h
+++ b/src/tracker-writeback/tracker-writeback.h
@@ -1,6 +1,6 @@
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
/*
- * Copyright (C) 2008, Nokia
+ * Copyright (C) 2009, Nokia
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public
@@ -18,13 +18,13 @@
* Boston, MA 02110-1301, USA.
*/
+#ifndef __TRACKER_WRITEBACK_WRITEBACK_H__
+#define __TRACKER_WRITEBACK_WRITEBACK_H__
+
#include <glib-object.h>
#include <libtracker-miner/tracker-miner-manager.h>
-#ifndef __TRACKER_WRITEBACK_H__
-#define __TRACKER_WRITEBACK_H__
-
G_BEGIN_DECLS
#define TRACKER_TYPE_WRITEBACK (tracker_writeback_get_type())
@@ -48,16 +48,15 @@ struct TrackerWritebackClass {
GPtrArray *values);
};
-GType tracker_writeback_get_type (void) G_GNUC_CONST;
+GType tracker_writeback_get_type (void) G_GNUC_CONST;
+gboolean tracker_writeback_update_metadata (TrackerWriteback *writeback,
+ GPtrArray *values);
+TrackerMinerManager* tracker_writeback_get_miner_manager (void);
/* Entry functions to be defined by modules */
-TrackerWriteback * writeback_module_create (GTypeModule *module);
-const gchar** writeback_module_get_rdftypes (void);
-
-gboolean tracker_writeback_update_metadata (TrackerWriteback *writeback,
- GPtrArray *values);
-TrackerMinerManager* tracker_writeback_get_miner_manager (void);
+TrackerWriteback * writeback_module_create (GTypeModule *module);
+const gchar * const *writeback_module_get_rdf_types (void);
G_END_DECLS
-#endif /* __TRACKER_WRITEBACK_H__ */
+#endif /* __TRACKER_WRITEBACK_WRITEBACK_H__ */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]