[tracker/wip/carlosg/domain-ontologies: 8/20] tracker-store: Use TrackerDomainOntology helper



commit 1022cb5a2e86970fcb0fa91ffa81e0b2575e14cc
Author: Carlos Garnacho <carlosg gnome org>
Date:   Mon Jun 19 15:39:09 2017 +0200

    tracker-store: Use TrackerDomainOntology helper

 src/libtracker-common/tracker-domain-ontology.c |   23 ++++++-
 src/libtracker-common/tracker-domain-ontology.h |   21 ++++++
 src/tracker-store/tracker-main.vala             |   88 ++++++-----------------
 3 files changed, 63 insertions(+), 69 deletions(-)
---
diff --git a/src/libtracker-common/tracker-domain-ontology.c b/src/libtracker-common/tracker-domain-ontology.c
index 07b4401..122f0b2 100644
--- a/src/libtracker-common/tracker-domain-ontology.c
+++ b/src/libtracker-common/tracker-domain-ontology.c
@@ -1,3 +1,24 @@
+/*
+ * Copyright (C) 2017, Red Hat, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA  02110-1301, USA.
+ *
+ * Authors: Carlos Garnacho <carlosg gnome org>
+ */
+
 #include "config.h"
 
 #include <string.h>
@@ -37,10 +58,8 @@ struct {
        { "XDG_DOWNLOAD_DIR", G_USER_DIRECTORY_DOWNLOAD },
        { "XDG_MUSIC_DIR", G_USER_DIRECTORY_MUSIC },
        { "XDG_PICTURES_DIR", G_USER_DIRECTORY_PICTURES },
-       { "XDG_PICTURES_DIR", G_USER_DIRECTORY_PICTURES },
        { "XDG_PUBLICSHARE_DIR", G_USER_DIRECTORY_PUBLIC_SHARE },
        { "XDG_VIDEOS_DIR", G_USER_DIRECTORY_VIDEOS },
-       { "XDG_VIDEOS_DIR", G_USER_DIRECTORY_VIDEOS },
 };
 
 #define DOMAIN_ONTOLOGY_SECTION "DomainOntology"
diff --git a/src/libtracker-common/tracker-domain-ontology.h b/src/libtracker-common/tracker-domain-ontology.h
index eb65145..8715fb4 100644
--- a/src/libtracker-common/tracker-domain-ontology.h
+++ b/src/libtracker-common/tracker-domain-ontology.h
@@ -1,3 +1,24 @@
+/*
+ * Copyright (C) 2017, Red Hat, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA  02110-1301, USA.
+ *
+ * Authors: Carlos Garnacho <carlosg gnome org>
+ */
+
 #ifndef __TRACKER_DOMAIN_ONTOLOGY_H__
 #define __TRACKER_DOMAIN_ONTOLOGY_H__
 
diff --git a/src/tracker-store/tracker-main.vala b/src/tracker-store/tracker-main.vala
index 41a94dc..000415a 100644
--- a/src/tracker-store/tracker-main.vala
+++ b/src/tracker-store/tracker-main.vala
@@ -47,9 +47,9 @@ License which can be viewed at:
        static bool force_reindex;
        static bool readonly_mode;
        static string domain_ontology;
-       static string cache_location;
-       static string data_location;
-       static string ontology_location;
+       static File cache_location;
+       static File data_location;
+       static File ontology_location;
        static string domain;
        static string ontology_name;
 
@@ -82,11 +82,11 @@ License which can be viewed at:
                        message ("  Ontology name..........................  %s", ontology_name);
 
                if (cache_location != null)
-                       message ("  Cache location.........................  %s", cache_location);
+                       message ("  Cache location.........................  %s", cache_location.get_uri());
                if (data_location != null)
-                       message ("  Data location..........................  %s", data_location);
+                       message ("  Data location..........................  %s", data_location.get_uri());
                if (ontology_location != null)
-                       message ("  Ontology location......................  %s", ontology_location);
+                       message ("  Ontology location......................  %s", 
ontology_location.get_uri());
        }
 
        static void do_shutdown () {
@@ -226,52 +226,20 @@ License which can be viewed at:
                        message ("Using log file:'%s'", log_filename);
                }
 
-               if (domain_ontology != null) {
-                       string keyfile_path = Path.build_filename (SHAREDIR,
-                                                                  "tracker",
-                                                                  "domain-ontologies",
-                                                                  domain_ontology+".rule");
-                       try {
-                               KeyFile keyfile = new KeyFile ( );
-                               keyfile.load_from_file (keyfile_path, GLib.KeyFileFlags.NONE);
-                               
-                               try {
-                                       string? loaded_data_location = keyfile.get_string ("DomainOntology", 
"DataLocation");
-                                       if (data_location == null)
-                                               data_location = loaded_data_location;
-                               } catch (KeyFileError m) {}
-
-                               try {
-                                       string? loaded_cache_location = keyfile.get_string ("DomainOntology", 
"CacheLocation");
-                                       if (cache_location == null)
-                                               cache_location = loaded_cache_location;
-                               } catch (KeyFileError m) {}
-
-                               try {
-                                       string? loaded_ontology_location = keyfile.get_string 
("DomainOntology", "OntologyLocation");
-                                       if (ontology_location == null)
-                                               ontology_location = loaded_ontology_location;
-                               } catch (KeyFileError m) {}
-
-                               try {
-                                       string? loaded_domain = keyfile.get_string ("DomainOntology", 
"Domain");
-                                       if (domain == null)
-                                               domain = loaded_domain;
-                               } catch (KeyFileError m) {}
-
-                               try {
-                                       string? loaded_ontology_name = keyfile.get_string ("DomainOntology", 
"OntologyName");
-                                       if (ontology_name == null)
-                                               ontology_name = loaded_ontology_name;
-                               } catch (KeyFileError m) {}
-
-                       } catch (KeyFileError ke) {
-                               critical("Loading " + keyfile_path + " " + ke.message);
-                       } catch (FileError fe) {
-                               critical("Loading " + keyfile_path + " " + fe.message);
-                       }
+               Tracker.DomainOntology domain_ontology_config;
+
+               try {
+                       domain_ontology_config = new Tracker.DomainOntology (domain_ontology, null);
+               } catch (Error e) {
+                       critical ("Could not load domain ontology definition '%s': %s", domain_ontology, 
e.message);
+                       return -1;
                }
 
+               cache_location = domain_ontology_config.get_cache ();
+               data_location = domain_ontology_config.get_journal ();
+               ontology_location = domain_ontology_config.get_ontology ();
+               domain = domain_ontology_config.get_domain ();
+
                sanity_check_option_values (config);
 
                if (!Tracker.DBus.init (config)) {
@@ -335,24 +303,10 @@ License which can be viewed at:
                }
 
                try {
-                       File final_cache_location = cache_location != null ?
-                               File.new_for_path (cache_location.replace ("%HOME%", 
Environment.get_home_dir()).replace("%SHAREDIR%", SHAREDIR)) :
-                               File.new_for_path (Path.build_filename (Environment.get_user_cache_dir (), 
"tracker"));
-                       File final_data_location = data_location != null ?
-                               File.new_for_path (data_location.replace ("%HOME%", 
Environment.get_home_dir()).replace("%SHAREDIR%", SHAREDIR)) :
-                               File.new_for_path (Path.build_filename (Environment.get_user_data_dir (), 
"tracker", "data"));
-                       File final_ontology_location = ontology_location != null ?
-                               File.new_for_path (ontology_location.replace ("%HOME%", 
Environment.get_home_dir()).replace("%SHAREDIR%", SHAREDIR)) :
-                               File.new_for_path (Path.build_filename (SHAREDIR, "tracker", "ontologies", 
"nepomuk"));
-
-                       var env_ontology = Environment.get_variable ("TRACKER_DB_ONTOLOGIES_DIR");
-                       if (env_ontology != null && env_ontology != "")
-                               final_ontology_location = File.new_for_path (env_ontology);
-
                        data_manager = new Tracker.Data.Manager (flags,
-                                                                final_cache_location,
-                                                                final_data_location,
-                                                                final_ontology_location,
+                                                                cache_location,
+                                                                data_location,
+                                                                ontology_location,
                                                                 true,
                                                                 false,
                                                                 select_cache_size,


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