[tracker/wip/carlosg/writeback-refactor: 1/2] libtracker-sparql: Add API call to list TrackerResource properties



commit 137c3a03d01660b52eb7210814f430dc79e0bdbc
Author: Carlos Garnacho <carlosg gnome org>
Date:   Wed May 20 14:34:19 2020 +0200

    libtracker-sparql: Add API call to list TrackerResource properties
    
    This is a missing piece to allow introspecting a TrackerResource, which
    may be useful to do in some circumstances.

 src/libtracker-sparql/tracker-resource.c | 23 +++++++++++++++++++++++
 src/libtracker-sparql/tracker-resource.h |  3 +++
 2 files changed, 26 insertions(+)
---
diff --git a/src/libtracker-sparql/tracker-resource.c b/src/libtracker-sparql/tracker-resource.c
index 26b2d00a8..efa71273b 100644
--- a/src/libtracker-sparql/tracker-resource.c
+++ b/src/libtracker-sparql/tracker-resource.c
@@ -963,6 +963,29 @@ tracker_resource_compare (TrackerResource *a,
        return strcmp (a_priv->identifier, b_priv->identifier);
 };
 
+/**
+ * tracker_resource_get_properties:
+ * @resource: a #TrackerResource
+ *
+ * Gets the list of properties defined in @resource
+ *
+ * Returns: (transfer container) (element-type utf8): The list of properties.
+ *          The list should be freed with g_list_free().
+ *
+ * Since: 3.0
+ **/
+GList *
+tracker_resource_get_properties (TrackerResource *resource)
+{
+       TrackerResourcePrivate *priv;
+
+       g_return_val_if_fail (TRACKER_IS_RESOURCE (resource), NULL);
+
+       priv = GET_PRIVATE (resource);
+
+       return g_hash_table_get_keys (priv->properties);
+}
+
 /* Helper function for serialization code. This allows you to selectively
  * populate 'interned_namespaces' from 'all_namespaces' based on when a
  * particular prefix is actually used. This is quite inefficient compared
diff --git a/src/libtracker-sparql/tracker-resource.h b/src/libtracker-sparql/tracker-resource.h
index 85a110389..fcc36b3ed 100644
--- a/src/libtracker-sparql/tracker-resource.h
+++ b/src/libtracker-sparql/tracker-resource.h
@@ -96,6 +96,9 @@ void tracker_resource_set_identifier (TrackerResource *self, const char *identif
 TRACKER_AVAILABLE_IN_ALL
 gint tracker_resource_identifier_compare_func (TrackerResource *resource, const char *identifier);
 
+TRACKER_AVAILABLE_IN_ALL
+GList *tracker_resource_get_properties (TrackerResource *resource);
+
 TRACKER_AVAILABLE_IN_ALL
 char *tracker_resource_print_turtle(TrackerResource *self, TrackerNamespaceManager *namespaces);
 


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