[tracker-miners/wip/carlosg/graphs: 10/18] libtracker-extract: Add infrastructure to keep graph info in extract rules



commit fd1ecdf764903199231c5c50463c184cee2fdfb9
Author: Carlos Garnacho <carlosg gnome org>
Date:   Sun Apr 26 13:38:30 2020 +0200

    libtracker-extract: Add infrastructure to keep graph info in extract rules
    
    This is meant for extraction modules to specify the graph that should
    store the info extracted by them.

 src/libtracker-extract/tracker-module-manager.c | 23 +++++++++++++++++++++++
 src/libtracker-extract/tracker-module-manager.h |  1 +
 2 files changed, 24 insertions(+)
---
diff --git a/src/libtracker-extract/tracker-module-manager.c b/src/libtracker-extract/tracker-module-manager.c
index 7c37892ca..544b51919 100644
--- a/src/libtracker-extract/tracker-module-manager.c
+++ b/src/libtracker-extract/tracker-module-manager.c
@@ -33,6 +33,7 @@ typedef struct {
        GList *allow_patterns;
        GList *block_patterns;
        GStrv fallback_rdf_types;
+       gchar *graph;
 } RuleInfo;
 
 typedef struct {
@@ -120,6 +121,7 @@ load_extractor_rule (GKeyFile    *key_file,
        rule.rule_path = g_strdup (rule_path);
 
        rule.fallback_rdf_types = g_key_file_get_string_list (key_file, "ExtractorRule", "FallbackRdfTypes", 
NULL, NULL);
+       rule.graph = g_key_file_get_string (key_file, "ExtractorRule", "Graph", NULL);
 
        /* Construct the rule */
        rule.module_path = g_intern_string (module_path);
@@ -547,3 +549,24 @@ tracker_module_manager_load_modules (void)
                load_module (rule_info);
        }
 }
+
+const gchar *
+tracker_extract_module_manager_get_graph (const gchar *mimetype)
+{
+       GList *l, *list;
+
+       if (!tracker_extract_module_manager_init ()) {
+               return NULL;
+       }
+
+       list = lookup_rules (mimetype);
+
+       for (l = list; l; l = l->next) {
+               RuleInfo *r_info = l->data;
+
+               if (r_info->graph)
+                       return r_info->graph;
+       }
+
+       return NULL;
+}
diff --git a/src/libtracker-extract/tracker-module-manager.h b/src/libtracker-extract/tracker-module-manager.h
index 9a340ab8c..95954232a 100644
--- a/src/libtracker-extract/tracker-module-manager.h
+++ b/src/libtracker-extract/tracker-module-manager.h
@@ -45,6 +45,7 @@ gboolean  tracker_extract_module_manager_init                (void) G_GNUC_CONST
 GStrv tracker_extract_module_manager_get_all_rdf_types (void);
 
 GStrv     tracker_extract_module_manager_get_rdf_types (const gchar *mimetype);
+const gchar * tracker_extract_module_manager_get_graph (const gchar *mimetype);
 
 GModule * tracker_extract_module_manager_get_module (const gchar                 *mimetype,
                                                      const gchar                **rule_out,


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