[tracker/property-changes: 2/3] libtracker-data: Support for ontology change tracker:notify
- From: Philip Van Hoof <pvanhoof src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [tracker/property-changes: 2/3] libtracker-data: Support for ontology change tracker:notify
- Date: Wed, 31 Mar 2010 11:14:18 +0000 (UTC)
commit ec19ee50e18c16ea311fd20a59bdac29036da448
Author: Philip Van Hoof <philip codeminded be>
Date: Wed Mar 31 11:40:57 2010 +0200
libtracker-data: Support for ontology change tracker:notify
src/libtracker-data/tracker-class.c | 26 ++++++++++++++++++++
src/libtracker-data/tracker-class.h | 3 ++
src/libtracker-data/tracker-data-manager.c | 35 +++++++++++++++++++++++++++-
3 files changed, 63 insertions(+), 1 deletions(-)
---
diff --git a/src/libtracker-data/tracker-class.c b/src/libtracker-data/tracker-class.c
index b2375e6..4deee5b 100644
--- a/src/libtracker-data/tracker-class.c
+++ b/src/libtracker-data/tracker-class.c
@@ -39,6 +39,7 @@ struct _TrackerClassPriv {
gint count;
gint id;
gboolean is_new;
+ gboolean notify;
GArray *super_classes;
};
@@ -165,6 +166,18 @@ tracker_class_get_is_new (TrackerClass *service)
return priv->is_new;
}
+gboolean
+tracker_class_get_notify (TrackerClass *service)
+{
+ TrackerClassPriv *priv;
+
+ g_return_val_if_fail (TRACKER_IS_CLASS (service), FALSE);
+
+ priv = GET_PRIV (service);
+
+ return priv->notify;
+}
+
void
tracker_class_set_uri (TrackerClass *service,
const gchar *value)
@@ -260,3 +273,16 @@ tracker_class_set_is_new (TrackerClass *service,
priv->is_new = value;
}
+
+void
+tracker_class_set_notify (TrackerClass *service,
+ gboolean value)
+{
+ TrackerClassPriv *priv;
+
+ g_return_if_fail (TRACKER_IS_CLASS (service));
+
+ priv = GET_PRIV (service);
+
+ priv->notify = value;
+}
diff --git a/src/libtracker-data/tracker-class.h b/src/libtracker-data/tracker-class.h
index c6c0acd..571b87d 100644
--- a/src/libtracker-data/tracker-class.h
+++ b/src/libtracker-data/tracker-class.h
@@ -54,6 +54,7 @@ const gchar * tracker_class_get_name (TrackerClass *service);
gint tracker_class_get_count (TrackerClass *service);
gint tracker_class_get_id (TrackerClass *service);
gboolean tracker_class_get_is_new (TrackerClass *service);
+gboolean tracker_class_get_notify (TrackerClass *service);
TrackerClass **tracker_class_get_super_classes (TrackerClass *service);
void tracker_class_set_uri (TrackerClass *service,
@@ -66,6 +67,8 @@ void tracker_class_set_id (TrackerClass *service,
gint id);
void tracker_class_set_is_new (TrackerClass *service,
gboolean value);
+void tracker_class_set_notify (TrackerClass *service,
+ gboolean value);
G_END_DECLS
diff --git a/src/libtracker-data/tracker-data-manager.c b/src/libtracker-data/tracker-data-manager.c
index ef29b66..33f6f38 100644
--- a/src/libtracker-data/tracker-data-manager.c
+++ b/src/libtracker-data/tracker-data-manager.c
@@ -198,6 +198,36 @@ tracker_data_ontology_load_statement (const gchar *ontology_path,
}
tracker_class_add_super_class (class, super_class);
+ } else if (g_strcmp0 (predicate, TRACKER_PREFIX "notify") == 0) {
+ TrackerClass *class;
+ gboolean wanted_value;
+
+ class = tracker_ontologies_get_class_by_uri (subject);
+ if (class == NULL) {
+ g_critical ("%s: Unknown class %s", ontology_path, subject);
+ return;
+ }
+
+ if (strcmp (object, "true") == 0) {
+ wanted_value = TRUE;
+ }
+
+ if (tracker_class_get_is_new (class) != in_update) {
+ if (tracker_class_get_notify (class) != wanted_value) {
+ GError *error = NULL;
+
+ tracker_data_insert_statement_with_string (NULL, subject,
+ predicate, object,
+ &error);
+
+ if (error) {
+ g_critical ("Can't update tracker:notify for class %s: %s", subject, error->message);
+ g_error_free (error);
+ }
+ }
+ }
+
+ tracker_class_set_notify (class, wanted_value);
} else if (g_strcmp0 (predicate, RDFS_SUB_PROPERTY_OF) == 0) {
TrackerProperty *property, *super_property;
@@ -349,6 +379,10 @@ tracker_data_ontology_load_statement (const gchar *ontology_path,
return;
}
+ if (tracker_property_get_is_new (property) != in_update) {
+ return;
+ }
+
if (strcmp (object, "true") == 0) {
tracker_property_set_fulltext_no_limit (property, TRUE);
}
@@ -381,7 +415,6 @@ tracker_data_ontology_load_statement (const gchar *ontology_path,
tracker_ontology_set_last_modified (ontology, tracker_string_to_date (object, NULL, NULL));
}
-
}
static void
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]