[tracker/wip/carlosg/tracker-3.0-api-breaks: 19/100] libtracker-sparql: Drop TRACKER_NOTIFIER_FLAG_QUERY_LOCATION



commit 8ef48fba96fb6c24279b91cdd748f2a3ffd7ea78
Author: Carlos Garnacho <carlosg gnome org>
Date:   Fri Dec 20 13:25:47 2019 +0100

    libtracker-sparql: Drop TRACKER_NOTIFIER_FLAG_QUERY_LOCATION
    
    This is very tied to nie:url and the Nepomuk ontology, plus it has
    all sorts of oddities with DELETE events, since it can't be queried
    at that time.
    
    Sounds like something the caller can handle better than we do, as
    in most cases it still doesnt' drop the need for additional queries
    in response to notifier events.

 .../reference/libtracker-sparql/migrating-2to3.xml |  7 ++++
 src/libtracker-sparql/tracker-notifier.c           | 46 ++++------------------
 src/libtracker-sparql/tracker-notifier.h           |  3 --
 3 files changed, 14 insertions(+), 42 deletions(-)
---
diff --git a/docs/reference/libtracker-sparql/migrating-2to3.xml 
b/docs/reference/libtracker-sparql/migrating-2to3.xml
index 8f12adec6..3dbb64972 100644
--- a/docs/reference/libtracker-sparql/migrating-2to3.xml
+++ b/docs/reference/libtracker-sparql/migrating-2to3.xml
@@ -120,4 +120,11 @@ ORDER BY DESC ?count
       TrackerNotifier will inform of each.
     </para>
   </section>
+  <section>
+    <title>No TRACKER_NOTIFIER_FLAG_QUERY_LOCATION</title>
+    <para>
+      If using the Nepomuk ontology, It is possible to query for the "nie:url" of
+      those elements in place. Other ontologies might have similar concepts.
+    </para>
+  </section>
 </chapter>
diff --git a/src/libtracker-sparql/tracker-notifier.c b/src/libtracker-sparql/tracker-notifier.c
index d41b4e705..671f7eaaa 100644
--- a/src/libtracker-sparql/tracker-notifier.c
+++ b/src/libtracker-sparql/tracker-notifier.c
@@ -42,20 +42,15 @@
  * }
  * ]|
  *
- * If the flags %TRACKER_NOTIFIER_FLAG_QUERY_URN or
- * %TRACKER_NOTIFIER_FLAG_QUERY_LOCATION are passed, the extra metadata
- * will be available through tracker_notifier_event_get_urn() and/or
- * tracker_notifier_event_get_location(). Note that this metadata can't
- * be obtained for every element and situation, most notably during
- * %TRACKER_NOTIFIER_EVENT_DELETE events.
+ * If the %TRACKER_NOTIFIER_FLAG_QUERY_URN flag is passed, the extra
+ * metadata will be available through tracker_notifier_event_get_urn().
  *
  * # Known caveats # {#trackernotifier-caveats}
  *
- * * If a resource is deleted, the %TRACKER_NOTIFIER_EVENT_DELETE event
- *   emitted will have a %NULL location, even if the notifier was created
- *   with the %TRACKER_NOTIFIER_FLAG_QUERY_LOCATION flag enabled. At the
- *   time of notifying, the resource does not exist anymore, so no
- *   meatadata can be retrieved.
+ * * The %TRACKER_NOTIFIER_EVENT_DELETE events will be received after the
+ *   resource has been deleted. At that time queries on those elements will
+ *   not bring any metadata. Only the ID/URN obtained through the event
+ *   remain meaningful.
  * * Notifications of files being moved across indexed folders will
  *   appear as %TRACKER_NOTIFIER_EVENT_UPDATE events, containing
  *   the new location (if requested). The older location is no longer
@@ -102,7 +97,6 @@ struct _TrackerNotifierEvent {
        gint64 id;
        const gchar *rdf_type; /* Belongs to cache */
        gchar *urn;
-       gchar *location;
        guint ref_count;
 };
 
@@ -195,7 +189,6 @@ tracker_notifier_event_unref (TrackerNotifierEvent *event)
 {
        if (g_atomic_int_dec_and_test (&event->ref_count)) {
                g_free (event->urn);
-               g_free (event->location);
                g_free (event);
        }
 }
@@ -406,8 +399,6 @@ create_extra_info_query (TrackerNotifier *notifier,
 
        if (priv->flags & TRACKER_NOTIFIER_FLAG_QUERY_URN)
                g_string_append (sparql, "?u ");
-       if (priv->flags & TRACKER_NOTIFIER_FLAG_QUERY_LOCATION)
-               g_string_append (sparql, "nie:url(nie:isStoredAs(?u)) ");
 
        g_string_append_printf (sparql,
                                "{ ?u a rdfs:Resource . "
@@ -456,8 +447,6 @@ tracker_notifier_query_extra_info (TrackerNotifier *notifier,
 
                if (priv->flags & TRACKER_NOTIFIER_FLAG_QUERY_URN)
                        event->urn = g_strdup (tracker_sparql_cursor_get_string (cursor, col++, NULL));
-               if (priv->flags & TRACKER_NOTIFIER_FLAG_QUERY_LOCATION)
-                       event->location = g_strdup (tracker_sparql_cursor_get_string (cursor, col++, NULL));
        }
 
        g_object_unref (cursor);
@@ -581,9 +570,7 @@ graph_updated_cb (GDBusConnection *connection,
 
        events = tracker_notifier_event_cache_flush_events (cache);
        if (events) {
-               if (priv->flags &
-                   (TRACKER_NOTIFIER_FLAG_QUERY_URN |
-                    TRACKER_NOTIFIER_FLAG_QUERY_LOCATION))
+               if (priv->flags & TRACKER_NOTIFIER_FLAG_QUERY_URN)
                        tracker_notifier_query_extra_info (notifier, events);
 
                if (priv->flags & TRACKER_NOTIFIER_FLAG_QUERY_URN)
@@ -947,22 +934,3 @@ tracker_notifier_event_get_urn (TrackerNotifierEvent *event)
        g_return_val_if_fail (event != NULL, NULL);
        return event->urn;
 }
-
-/**
- * tracker_notifier_event_get_location:
- * @event: A #TrackerNotifierEvent
- *
- * Returns the location (e.g. an URI) of the element if the notifier
- * has the flag %TRACKER_NOTIFIER_FLAG_QUERY_LOCATION, and it can
- * be obtained at the time of emission.
- *
- * Returns: (nullable): The element location, or %NULL
- *
- * Since: 1.12
- **/
-const gchar *
-tracker_notifier_event_get_location (TrackerNotifierEvent *event)
-{
-       g_return_val_if_fail (event != NULL, NULL);
-       return event->location;
-}
diff --git a/src/libtracker-sparql/tracker-notifier.h b/src/libtracker-sparql/tracker-notifier.h
index 3009cef65..2d8613703 100644
--- a/src/libtracker-sparql/tracker-notifier.h
+++ b/src/libtracker-sparql/tracker-notifier.h
@@ -46,14 +46,12 @@ struct _TrackerNotifierClass {
  * TrackerNotifierFlags:
  * @TRACKER_NOTIFIER_FLAG_NONE: No flags
  * @TRACKER_NOTIFIER_FLAG_QUERY_URN: Query URN of notified elements
- * @TRACKER_NOTIFIER_FLAG_QUERY_LOCATION: Query location of notified elements
  *
  * Flags affecting #TrackerNotifier behavior.
  */
 typedef enum {
        TRACKER_NOTIFIER_FLAG_NONE               = 0,
        TRACKER_NOTIFIER_FLAG_QUERY_URN          = 1 << 1,
-       TRACKER_NOTIFIER_FLAG_QUERY_LOCATION     = 1 << 2,
 } TrackerNotifierFlags;
 
 /**
@@ -80,6 +78,5 @@ TrackerNotifierEventType
 gint64        tracker_notifier_event_get_id         (TrackerNotifierEvent *event);
 const gchar * tracker_notifier_event_get_type       (TrackerNotifierEvent *event);
 const gchar * tracker_notifier_event_get_urn        (TrackerNotifierEvent *event);
-const gchar * tracker_notifier_event_get_location   (TrackerNotifierEvent *event);
 
 #endif /* __TRACKER_NOTIFIER_H__ */


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]