[tracker] Added some more fields to the XMP writeback module
- From: Philip Van Hoof <pvanhoof src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [tracker] Added some more fields to the XMP writeback module
- Date: Thu, 26 Nov 2009 15:13:14 +0000 (UTC)
commit 916f37f4d2a6a458446afaed1c6ff85e59349c53
Author: Philip Van Hoof <philip codeminded be>
Date: Wed Nov 25 15:54:46 2009 +0100
Added some more fields to the XMP writeback module
data/ontologies/30-nie.ontology | 9 +-
data/ontologies/32-nco.ontology | 3 +-
data/ontologies/33-nfo.ontology | 3 +-
.../tracker-writeback-dispatcher.c | 2 +-
src/tracker-writeback/tracker-writeback-file.c | 8 +-
src/tracker-writeback/tracker-writeback-file.h | 3 +-
src/tracker-writeback/tracker-writeback-mp3.c | 6 +-
src/tracker-writeback/tracker-writeback-xmp.c | 141 +++++++++++++++++++-
src/tracker-writeback/tracker-writeback.c | 5 +-
src/tracker-writeback/tracker-writeback.h | 7 +-
10 files changed, 164 insertions(+), 23 deletions(-)
---
diff --git a/data/ontologies/30-nie.ontology b/data/ontologies/30-nie.ontology
index 0592cda..f877e43 100644
--- a/data/ontologies/30-nie.ontology
+++ b/data/ontologies/30-nie.ontology
@@ -102,7 +102,8 @@ nie:description a rdf:Property ;
rdfs:domain nie:InformationElement ;
rdfs:range xsd:string ;
tracker:fulltextIndexed true ;
- tracker:weight 3 .
+ tracker:weight 3 ;
+ tracker:writeback true .
# Bug in nepomuk specification. Taking domain from superproperty
nie:disclaimer a rdf:Property ;
@@ -169,7 +170,8 @@ nie:contentCreated a rdf:Property ;
rdfs:subPropertyOf nie:informationElementDate ;
nrl:maxCardinality 1 ;
rdfs:domain nie:InformationElement ;
- rdfs:range xsd:dateTime .
+ rdfs:range xsd:dateTime ;
+ tracker:writeback true .
nie:contentAccessed a rdf:Property ;
rdfs:subPropertyOf nie:informationElementDate ;
@@ -206,7 +208,8 @@ nie:keyword a rdf:Property ;
rdfs:domain nie:InformationElement ;
rdfs:range xsd:string ;
tracker:fulltextIndexed true ;
- tracker:weight 5 .
+ tracker:weight 5 ;
+ tracker:writeback true .
nie:hasLogicalPart a rdf:Property ;
rdfs:domain nie:InformationElement ;
diff --git a/data/ontologies/32-nco.ontology b/data/ontologies/32-nco.ontology
index b181b37..67a139f 100644
--- a/data/ontologies/32-nco.ontology
+++ b/data/ontologies/32-nco.ontology
@@ -216,7 +216,8 @@ nco:creator a rdf:Property ;
rdfs:subPropertyOf dc:creator , nco:contributor ;
rdfs:domain nie:InformationElement ;
rdfs:range nco:Contact ;
- tracker:weight 4 .
+ tracker:weight 4 ;
+ tracker:writeback true .
nco:region a rdf:Property ;
rdfs:label "region" ;
diff --git a/data/ontologies/33-nfo.ontology b/data/ontologies/33-nfo.ontology
index 1718b32..9239c64 100644
--- a/data/ontologies/33-nfo.ontology
+++ b/data/ontologies/33-nfo.ontology
@@ -844,7 +844,8 @@ nfo:orientation-left a nfo:Orientation .
nfo:orientation a rdf:Property ;
rdfs:domain nfo:Image ;
- rdfs:range nfo:Orientation .
+ rdfs:range nfo:Orientation ;
+ tracker:writeback true .
@prefix poi: <http://www.tracker-project.org/ontologies/poi#> .
diff --git a/src/tracker-writeback/tracker-writeback-dispatcher.c b/src/tracker-writeback/tracker-writeback-dispatcher.c
index de5d2dc..d560689 100644
--- a/src/tracker-writeback/tracker-writeback-dispatcher.c
+++ b/src/tracker-writeback/tracker-writeback-dispatcher.c
@@ -327,7 +327,7 @@ sparql_query_cb (GPtrArray *result,
module->name);
writeback = tracker_writeback_module_create (module);
- tracker_writeback_update_metadata (writeback, result);
+ tracker_writeback_update_metadata (writeback, result, priv->client);
g_object_unref (writeback);
}
}
diff --git a/src/tracker-writeback/tracker-writeback-file.c b/src/tracker-writeback/tracker-writeback-file.c
index c84a0e3..ad51c39 100644
--- a/src/tracker-writeback/tracker-writeback-file.c
+++ b/src/tracker-writeback/tracker-writeback-file.c
@@ -25,7 +25,8 @@
#include "tracker-writeback-file.h"
static gboolean tracker_writeback_file_update_metadata (TrackerWriteback *writeback,
- GPtrArray *values);
+ GPtrArray *values,
+ TrackerClient *client);
G_DEFINE_ABSTRACT_TYPE (TrackerWritebackFile, tracker_writeback_file, TRACKER_TYPE_WRITEBACK)
@@ -61,7 +62,8 @@ file_unlock_cb (gpointer user_data)
static gboolean
tracker_writeback_file_update_metadata (TrackerWriteback *writeback,
- GPtrArray *values)
+ GPtrArray *values,
+ TrackerClient *client)
{
TrackerWritebackFileClass *writeback_file_class;
gboolean retval;
@@ -130,7 +132,7 @@ tracker_writeback_file_update_metadata (TrackerWriteback *writeback,
subjects);
retval = (writeback_file_class->update_file_metadata) (TRACKER_WRITEBACK_FILE (writeback),
- file, values);
+ file, values, client);
g_timeout_add_seconds (3, file_unlock_cb, g_object_ref (file));
}
diff --git a/src/tracker-writeback/tracker-writeback-file.h b/src/tracker-writeback/tracker-writeback-file.h
index d557f9c..ac4dabf 100644
--- a/src/tracker-writeback/tracker-writeback-file.h
+++ b/src/tracker-writeback/tracker-writeback-file.h
@@ -46,7 +46,8 @@ struct TrackerWritebackFileClass {
gboolean (* update_file_metadata) (TrackerWritebackFile *writeback_file,
GFile *file,
- GPtrArray *values);
+ GPtrArray *values,
+ TrackerClient *client);
const gchar * const * (* content_types) (TrackerWritebackFile *writeback_file);
};
diff --git a/src/tracker-writeback/tracker-writeback-mp3.c b/src/tracker-writeback/tracker-writeback-mp3.c
index fe4d23c..b2b7f28 100644
--- a/src/tracker-writeback/tracker-writeback-mp3.c
+++ b/src/tracker-writeback/tracker-writeback-mp3.c
@@ -44,7 +44,8 @@ struct TrackerWritebackMP3Class {
static GType tracker_writeback_mp3_get_type (void) G_GNUC_CONST;
static gboolean writeback_mp3_update_file_metadata (TrackerWritebackFile *wbf,
GFile *file,
- GPtrArray *values);
+ GPtrArray *values,
+ TrackerClient *client);
static const gchar * const *writeback_mp3_content_types (TrackerWritebackFile *wbf);
G_DEFINE_DYNAMIC_TYPE (TrackerWritebackMP3, tracker_writeback_mp3, TRACKER_TYPE_WRITEBACK_FILE);
@@ -83,7 +84,8 @@ writeback_mp3_content_types (TrackerWritebackFile *wbf)
static gboolean
writeback_mp3_update_file_metadata (TrackerWritebackFile *writeback_file,
GFile *file,
- GPtrArray *values)
+ GPtrArray *values,
+ TrackerClient *client)
{
gchar *path;
guint n;
diff --git a/src/tracker-writeback/tracker-writeback-xmp.c b/src/tracker-writeback/tracker-writeback-xmp.c
index ed03590..7aedff6 100644
--- a/src/tracker-writeback/tracker-writeback-xmp.c
+++ b/src/tracker-writeback/tracker-writeback-xmp.c
@@ -51,7 +51,8 @@ struct TrackerWritebackXMPClass {
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);
+ GPtrArray *values,
+ TrackerClient *client);
static const gchar * const *writeback_xmp_content_types (TrackerWritebackFile *writeback_file);
G_DEFINE_DYNAMIC_TYPE (TrackerWritebackXMP, tracker_writeback_xmp, TRACKER_TYPE_WRITEBACK_FILE);
@@ -103,8 +104,9 @@ writeback_xmp_content_types (TrackerWritebackFile *wbf)
static gboolean
writeback_xmp_update_file_metadata (TrackerWritebackFile *wbf,
- GFile *file,
- GPtrArray *values)
+ GFile *file,
+ GPtrArray *values,
+ TrackerClient *client)
{
gchar *path;
guint n;
@@ -113,6 +115,7 @@ writeback_xmp_update_file_metadata (TrackerWritebackFile *wbf,
#ifdef DEBUG_XMP
XmpStringPtr str;
#endif
+ GString *keywords = NULL;
path = g_file_get_path (file);
@@ -144,14 +147,138 @@ writeback_xmp_update_file_metadata (TrackerWritebackFile *wbf,
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_delete_property (xmp, NS_DC, "title");
+ xmp_set_property (xmp, NS_DC, "title", row[2], 0);
+ }
+
+ if (g_strcmp0 (row[1], TRACKER_NCO_PREFIX "creator") == 0) {
+ GPtrArray *name_array;
+ GError *error = NULL;
+ gchar *query;
+
+ query = g_strdup_printf ("SELECT ?fullname { "
+ " <%s> nco:fullname ?fullname "
+ "}", row[2]);
+
+ name_array = tracker_resources_sparql_query (client, query, &error);
+
+ g_free (query);
+
+ if (!error) {
+ if (name_array && name_array->len > 0) {
+ GStrv name_row;
+
+ name_row = g_ptr_array_index (name_array, 0);
+
+ if (name_row[0]) {
+ xmp_delete_property (xmp, NS_DC, "creator");
+ xmp_set_property (xmp, NS_DC, "creator", name_row[0], 0);
+ }
+ }
+
+ if (name_array) {
+ g_ptr_array_foreach (name_array, (GFunc) g_strfreev, NULL);
+ g_ptr_array_free (name_array, TRUE);
+ }
+
+ } else {
+ g_clear_error (&error);
+ }
+ }
+
+ if (g_strcmp0 (row[1], TRACKER_NIE_PREFIX "description") == 0) {
+ xmp_delete_property (xmp, NS_DC, "description");
+ xmp_set_property (xmp, NS_DC, "description", row[2], 0);
+ }
+
+ if (g_strcmp0 (row[1], TRACKER_NIE_PREFIX "keyword") == 0) {
+ if (!keywords) {
+ keywords = g_string_new (row[2]);
+ } else {
+ g_string_append_printf (keywords, ", %s", row[2]);
+ }
+ }
+
+ if (g_strcmp0 (row[1], TRACKER_NIE_PREFIX "contentCreated") == 0) {
+ xmp_delete_property (xmp, NS_EXIF, "Date");
+ xmp_set_property (xmp, NS_EXIF, "Date", row[2], 0);
+ }
+
+ if (g_strcmp0 (row[1], TRACKER_NFO_PREFIX "orientation") == 0) {
+ guint i;
+
+ static const gchar *ostr[8] = {
+ /* 0 */ TRACKER_NFO_PREFIX "orientation-top",
+ /* 1 */ TRACKER_NFO_PREFIX "orientation-top-mirror",
+ /* 2 */ TRACKER_NFO_PREFIX "orientation-bottom",
+ /* 3 */ TRACKER_NFO_PREFIX "orientation-bottom-mirror",
+ /* 4 */ TRACKER_NFO_PREFIX "orientation-left-mirror",
+ /* 5 */ TRACKER_NFO_PREFIX "orientation-right",
+ /* 6 */ TRACKER_NFO_PREFIX "orientation-right-mirror",
+ /* 7 */ TRACKER_NFO_PREFIX "orientation-left"
+ };
+
+ xmp_delete_property (xmp, NS_EXIF, "Orientation");
+
+ for (i=0; i < 8; i++) {
+ if (g_strcmp0 (row[2], ostr[i]) == 0) {
+ switch (i) {
+ case 0:
+ xmp_set_property (xmp, NS_EXIF, "Orientation", "top - left", 0);
+ break;
+ case 1:
+ xmp_set_property (xmp, NS_EXIF, "Orientation", "top - right", 0);
+ break;
+ case 2:
+ xmp_set_property (xmp, NS_EXIF, "Orientation", "bottom - right", 0);
+ break;
+ case 3:
+ xmp_set_property (xmp, NS_EXIF, "Orientation", "bottom - left", 0);
+ break;
+ case 4:
+ xmp_set_property (xmp, NS_EXIF, "Orientation", "left - top", 0);
+ break;
+ case 5:
+ xmp_set_property (xmp, NS_EXIF, "Orientation", "right - top", 0);
+ break;
+ case 6:
+ xmp_set_property (xmp, NS_EXIF, "Orientation", "right - bottom", 0);
+ break;
+ case 7:
+ xmp_set_property (xmp, NS_EXIF, "Orientation", "left - bottom", 0);
+ break;
+ default:
+ break;
+ }
+ }
+ }
+ }
+
- /* 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);
+ /*
+ if (g_strcmp0 (row[1], PHOTO_HAS "contact") == 0) {
+ Face recognition on the photos
+ xmp_delete_property (xmp, FACE, "contact");
+ Fetch full name of the contact?
+ xmp_set_array_item (xmp, FACE, "contact", 1, fetched, 0);
+ }
+ if (g_strcmp0 (row[1], LOCATION_PREFIX "country") == 0) {
+ xmp_delete_property (xmp, NS_PHOTOSHOP, "Country");
+ xmp_set_array_item (xmp, NS_PHOTOSHOP, "Country", 1, row[2], 0);
}
- /* TODO: Add more */
+ if (g_strcmp0 (row[1], LOCATION_PREFIX "city") == 0) {
+ xmp_delete_property (xmp, NS_PHOTOSHOP, "City");
+ xmp_set_array_item (xmp, NS_PHOTOSHOP, "City", 1, row[2], 0);
+ } */
+
+ }
+
+ if (keywords) {
+ xmp_delete_property (xmp, NS_DC, "subject");
+ xmp_set_property (xmp, NS_DC, "subject", keywords->str, 0);
+ g_string_free (keywords, TRUE);
}
#ifdef DEBUG_XMP
diff --git a/src/tracker-writeback/tracker-writeback.c b/src/tracker-writeback/tracker-writeback.c
index adb54f1..f85d36b 100644
--- a/src/tracker-writeback/tracker-writeback.c
+++ b/src/tracker-writeback/tracker-writeback.c
@@ -38,13 +38,14 @@ tracker_writeback_init (TrackerWriteback *writeback)
gboolean
tracker_writeback_update_metadata (TrackerWriteback *writeback,
- GPtrArray *values)
+ GPtrArray *values,
+ TrackerClient *client)
{
g_return_val_if_fail (TRACKER_IS_WRITEBACK (writeback), FALSE);
g_return_val_if_fail (values != NULL, FALSE);
if (TRACKER_WRITEBACK_GET_CLASS (writeback)->update_metadata) {
- return TRACKER_WRITEBACK_GET_CLASS (writeback)->update_metadata (writeback, values);
+ return TRACKER_WRITEBACK_GET_CLASS (writeback)->update_metadata (writeback, values, client);
}
return FALSE;
diff --git a/src/tracker-writeback/tracker-writeback.h b/src/tracker-writeback/tracker-writeback.h
index 0c30a1d..4d7b82f 100644
--- a/src/tracker-writeback/tracker-writeback.h
+++ b/src/tracker-writeback/tracker-writeback.h
@@ -24,6 +24,7 @@
#include <glib-object.h>
#include <libtracker-miner/tracker-miner-manager.h>
+#include <libtracker-client/tracker.h>
G_BEGIN_DECLS
@@ -45,12 +46,14 @@ struct TrackerWritebackClass {
GObjectClass parent_class;
gboolean (* update_metadata) (TrackerWriteback *writeback,
- GPtrArray *values);
+ GPtrArray *values,
+ TrackerClient *client);
};
GType tracker_writeback_get_type (void) G_GNUC_CONST;
gboolean tracker_writeback_update_metadata (TrackerWriteback *writeback,
- GPtrArray *values);
+ GPtrArray *values,
+ TrackerClient *client);
TrackerMinerManager* tracker_writeback_get_miner_manager (void);
/* Entry functions to be defined by modules */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]