[tracker/wip/carlosg/domain-ontologies: 117/124] libtracker-common: Add domain ontology key/api to get expected miners



commit 3ef88efe157c7013eb5609f6ffca593ec9ed5e75
Author: Carlos Garnacho <carlosg gnome org>
Date:   Thu Jun 22 13:13:46 2017 +0200

    libtracker-common: Add domain ontology key/api to get expected miners
    
    This is purely a hint, and people may still run things manually or perform
    updates against this domain ontology themselves. Will be useful so we don't
    autostart more miners than necessary through the libtracker-control API.

 src/libtracker-common/tracker-domain-ontology.c |   28 +++++++++++++++++++++++
 src/libtracker-common/tracker-domain-ontology.h |    4 +++
 2 files changed, 32 insertions(+), 0 deletions(-)
---
diff --git a/src/libtracker-common/tracker-domain-ontology.c b/src/libtracker-common/tracker-domain-ontology.c
index 2ce03ef..6b962d3 100644
--- a/src/libtracker-common/tracker-domain-ontology.c
+++ b/src/libtracker-common/tracker-domain-ontology.c
@@ -32,6 +32,7 @@ typedef struct {
        gchar *name;
        gchar *domain;
        gchar *ontology_name;
+       gchar **miners;
 } TrackerDomainOntologyPrivate;
 
 enum {
@@ -69,6 +70,7 @@ struct {
 #define ONTOLOGY_KEY "OntologyLocation"
 #define ONTOLOGY_NAME_KEY "OntologyName"
 #define DOMAIN_KEY "Domain"
+#define MINERS_KEY "Miners"
 
 #define DEFAULT_RULE "default.rule"
 
@@ -136,6 +138,7 @@ tracker_domain_ontology_finalize (GObject *object)
        g_clear_object (&priv->ontology_location);
        g_free (priv->name);
        g_free (priv->domain);
+       g_strfreev (priv->miners);
 
        G_OBJECT_CLASS (tracker_domain_ontology_parent_class)->finalize (object);
 }
@@ -346,6 +349,8 @@ tracker_domain_ontology_initable_init (GInitable     *initable,
 
        priv->ontology_name = g_key_file_get_string (key_file, DOMAIN_ONTOLOGY_SECTION,
                                                     ONTOLOGY_NAME_KEY, NULL);
+       priv->miners = g_key_file_get_string_list (key_file, DOMAIN_ONTOLOGY_SECTION,
+                                                  MINERS_KEY, NULL, NULL);
 
        /* Consistency check, we need one of OntologyLocation and OntologyName,
         * no more, no less.
@@ -435,3 +440,26 @@ tracker_domain_ontology_get_domain (TrackerDomainOntology *domain_ontology,
        else
                return g_strconcat (priv->domain, ".Tracker1", NULL);
 }
+
+gboolean
+tracker_domain_ontology_uses_miner (TrackerDomainOntology *domain_ontology,
+                                    const gchar           *suffix)
+{
+       TrackerDomainOntologyPrivate *priv;
+       guint i;
+
+       g_return_val_if_fail (suffix != NULL, FALSE);
+
+       priv = tracker_domain_ontology_get_instance_private (domain_ontology);
+
+       if (!priv->miners)
+               return FALSE;
+
+       for (i = 0; priv->miners[i] != NULL; i++) {
+               if (strcmp (priv->miners[i], suffix) == 0) {
+                       return TRUE;
+               }
+       }
+
+       return FALSE;
+}
diff --git a/src/libtracker-common/tracker-domain-ontology.h b/src/libtracker-common/tracker-domain-ontology.h
index 3787333..befae10 100644
--- a/src/libtracker-common/tracker-domain-ontology.h
+++ b/src/libtracker-common/tracker-domain-ontology.h
@@ -62,4 +62,8 @@ GFile * tracker_domain_ontology_get_ontology (TrackerDomainOntology *domain_onto
 gchar * tracker_domain_ontology_get_domain   (TrackerDomainOntology *domain_ontology,
                                               const gchar           *suffix);
 
+gboolean tracker_domain_ontology_uses_miner  (TrackerDomainOntology *domain_ontology,
+                                              const gchar           *suffix);
+
+
 #endif /* __TRACKER_MINER_PROXY_H__ */


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