[tracker-miners/wip/carlosg/cli-split: 1/23] libtracker-miners-common: Sync back again TrackerDomainOntology from Tracker



commit 241b0d89c59984af49f057618d8fcb3a226cb071
Author: Carlos Garnacho <carlosg gnome org>
Date:   Thu Dec 19 17:20:19 2019 +0100

    libtracker-miners-common: Sync back again TrackerDomainOntology from Tracker
    
    Tracker fixed differently the issue that made them diverge in the first
    place, without dropping the detailed API that will be useful from now on.
    Restore this more complete version of TrackerDomainOntology.

 .../tracker-domain-ontology.c                      | 302 +++++++++++++++++++--
 .../tracker-domain-ontology.h                      |  22 +-
 src/miners/fs/tracker-main.c                       |  19 +-
 src/miners/rss/tracker-main.c                      |  16 +-
 src/miners/rss/tracker-miner-rss.c                 |  13 +-
 src/tracker-extract/tracker-main.c                 |  16 +-
 6 files changed, 336 insertions(+), 52 deletions(-)
---
diff --git a/src/libtracker-miners-common/tracker-domain-ontology.c 
b/src/libtracker-miners-common/tracker-domain-ontology.c
index bff669562..509149a18 100644
--- a/src/libtracker-miners-common/tracker-domain-ontology.c
+++ b/src/libtracker-miners-common/tracker-domain-ontology.c
@@ -21,9 +21,44 @@
 
 #include "config-miners.h"
 
-#include <gio/gio.h>
+#include <string.h>
 #include "tracker-domain-ontology.h"
 
+struct _TrackerDomainOntology {
+       gint ref_count;
+       /* DomainOntologies section */
+       GFile *cache_location;
+       GFile *journal_location;
+       GFile *ontology_location;
+       gchar *name;
+       gchar *domain;
+       gchar *ontology_name;
+       gchar **miners;
+};
+
+struct {
+       const gchar *var;
+       const gchar *(*func) (void);
+} lookup_dirs[] = {
+       { "HOME", g_get_home_dir },
+       { "XDG_CACHE_HOME", g_get_user_cache_dir },
+       { "XDG_DATA_HOME", g_get_user_data_dir },
+       { "XDG_RUNTIME_DIR", g_get_user_runtime_dir },
+};
+
+struct {
+       const gchar *var;
+       GUserDirectory user_directory;
+} lookup_special_dirs[] = {
+       { "XDG_DESKTOP_DIR", G_USER_DIRECTORY_DESKTOP },
+       { "XDG_DOCUMENTS_DIR", G_USER_DIRECTORY_DOCUMENTS },
+       { "XDG_DOWNLOAD_DIR", G_USER_DIRECTORY_DOWNLOAD },
+       { "XDG_MUSIC_DIR", G_USER_DIRECTORY_MUSIC },
+       { "XDG_PICTURES_DIR", G_USER_DIRECTORY_PICTURES },
+       { "XDG_PUBLICSHARE_DIR", G_USER_DIRECTORY_PUBLIC_SHARE },
+       { "XDG_VIDEOS_DIR", G_USER_DIRECTORY_VIDEOS },
+};
+
 #define DOMAIN_ONTOLOGY_SECTION "DomainOntology"
 
 #define CACHE_KEY "CacheLocation"
@@ -35,6 +70,125 @@
 
 #define DEFAULT_RULE "default.rule"
 
+TrackerDomainOntology *
+tracker_domain_ontology_ref (TrackerDomainOntology *domain_ontology)
+{
+       domain_ontology->ref_count++;
+       return domain_ontology;
+}
+
+void
+tracker_domain_ontology_unref (TrackerDomainOntology *domain_ontology)
+{
+       domain_ontology->ref_count--;
+
+       if (domain_ontology->ref_count != 0)
+               return;
+
+       g_clear_object (&domain_ontology->cache_location);
+       g_clear_object (&domain_ontology->journal_location);
+       g_clear_object (&domain_ontology->ontology_location);
+       g_free (domain_ontology->ontology_name);
+       g_free (domain_ontology->name);
+       g_free (domain_ontology->domain);
+       g_strfreev (domain_ontology->miners);
+       g_free (domain_ontology);
+}
+
+static const gchar *
+lookup_dir (const gchar *variable,
+            gsize        variable_len)
+{
+       gint i;
+
+       for (i = 0; i < G_N_ELEMENTS (lookup_dirs); i++) {
+               if (strncmp (lookup_dirs[i].var, variable, variable_len) == 0) {
+                       return lookup_dirs[i].func ();
+               }
+       }
+
+       for (i = 0; i < G_N_ELEMENTS (lookup_special_dirs); i++) {
+               if (strncmp (lookup_special_dirs[i].var, variable, variable_len) == 0) {
+                       return g_get_user_special_dir (lookup_special_dirs[i].user_directory);
+               }
+       }
+
+       return NULL;
+}
+
+static GFile *
+key_file_get_location (GKeyFile     *key_file,
+                       const gchar  *section,
+                       const gchar  *key,
+                       gboolean      essential,
+                       gboolean      must_exist,
+                       GError      **error)
+{
+       GError *inner_error = NULL;
+       gchar *value;
+       GFile *file;
+
+       value = g_key_file_get_string (key_file, section, key, &inner_error);
+       if (inner_error) {
+               if (essential)
+                       g_propagate_error (error, inner_error);
+               else
+                       g_error_free (inner_error);
+
+               return NULL;
+       }
+
+       if (value[0] == '$') {
+               const gchar *var_end, *prefix;
+               gchar *path;
+
+               /* This is a path relative from a xdg dir */
+               var_end = strchr (value, '/');
+               if (!var_end) {
+                       /* We must take $VAR/subdir values */
+                       g_set_error (error,
+                                    G_KEY_FILE_ERROR,
+                                    G_KEY_FILE_ERROR_INVALID_VALUE,
+                                    "Path in key '%s' can not consist solely of a variable",
+                                    key);
+                       g_free (value);
+                       return NULL;
+               }
+
+               prefix = lookup_dir (&value[1], (var_end - &value[1]));
+               if (!prefix) {
+                       g_set_error (error,
+                                    G_KEY_FILE_ERROR,
+                                    G_KEY_FILE_ERROR_INVALID_VALUE,
+                                    "Unrecognized variable in '%s'", key);
+                       g_free (value);
+                       return NULL;
+               }
+
+               path = g_strconcat (prefix, var_end, NULL);
+               file = g_file_new_for_path (path);
+               g_free (path);
+       } else {
+               file = g_file_new_for_uri (value);
+       }
+
+       g_free (value);
+
+       if (must_exist && file &&
+           g_file_query_file_type (file, G_FILE_QUERY_INFO_NOFOLLOW_SYMLINKS,
+                                   NULL) != G_FILE_TYPE_DIRECTORY) {
+               gchar *uri = g_file_get_uri (file);
+               g_set_error (error,
+                            G_KEY_FILE_ERROR,
+                            G_KEY_FILE_ERROR_INVALID_VALUE,
+                            "Uri '%s' is not a directory or does not exist", uri);
+               g_free (uri);
+               return NULL;
+       }
+
+       return file;
+}
+
 static gchar *
 find_rule_in_data_dirs (const gchar *name)
 {
@@ -62,33 +216,38 @@ find_rule_in_data_dirs (const gchar *name)
        return NULL;
 }
 
-gboolean
-tracker_load_domain_config (const gchar  *name,
-                            gchar       **dbus_domain_name,
-                            GError      **error)
+TrackerDomainOntology *
+tracker_domain_ontology_new (const gchar   *domain_name,
+                             GCancellable  *cancellable,
+                             GError       **error)
 {
-       GKeyFile *key_file;
-       gchar *path, *path_for_tests;
+       TrackerDomainOntology *domain_ontology;
        GError *inner_error = NULL;
+       GKeyFile *key_file = NULL;
+       gchar *path, *path_for_tests;
+
+       domain_ontology = g_new0 (TrackerDomainOntology, 1);
+       domain_ontology->name = g_strdup (domain_name);
+       domain_ontology->ref_count = 1;
 
-       if (name && name[0] == '/') {
-               if (!g_file_test (name, G_FILE_TEST_IS_REGULAR)) {
+       if (domain_name && domain_name[0] == '/') {
+               if (!g_file_test (domain_name, G_FILE_TEST_IS_REGULAR)) {
                        inner_error = g_error_new (G_KEY_FILE_ERROR,
                                                   G_KEY_FILE_ERROR_NOT_FOUND,
                                                   "Could not find rule at '%s'",
-                                                  name);
+                                                  domain_name);
                        goto end;
                }
 
-               path = g_strdup (name);
-       } else if (name) {
-               path = find_rule_in_data_dirs (name);
+               path = g_strdup (domain_name);
+       } else if (domain_name) {
+               path = find_rule_in_data_dirs (domain_name);
 
                if (!path) {
                        inner_error = g_error_new (G_KEY_FILE_ERROR,
                                                   G_KEY_FILE_ERROR_NOT_FOUND,
                                                   "Could not find rule '%s' in data dirs",
-                                                  name);
+                                                  domain_name);
                        goto end;
                }
        } else {
@@ -100,11 +259,7 @@ tracker_load_domain_config (const gchar  *name,
                        path_for_tests = g_strdup (g_getenv ("TRACKER_TEST_DOMAIN_ONTOLOGY_RULE"));
 
                        if (path_for_tests == NULL) {
-                               inner_error = g_error_new (G_KEY_FILE_ERROR,
-                                                          G_KEY_FILE_ERROR_NOT_FOUND,
-                                                          "Unable to find default domain ontology rule %s",
-                                                          path);
-                               goto end;
+                               g_error ("Unable to find default domain ontology rule %s", path);
                        }
 
                        g_free (path);
@@ -119,19 +274,122 @@ tracker_load_domain_config (const gchar  *name,
        if (inner_error)
                goto end;
 
-       *dbus_domain_name = g_key_file_get_string (key_file, DOMAIN_ONTOLOGY_SECTION,
-                                                  DOMAIN_KEY, &inner_error);
+       domain_ontology->domain = g_key_file_get_string (key_file, DOMAIN_ONTOLOGY_SECTION,
+                                                        DOMAIN_KEY, &inner_error);
+       if (inner_error)
+               goto end;
+
+       domain_ontology->cache_location =
+               key_file_get_location (key_file, DOMAIN_ONTOLOGY_SECTION,
+                                      CACHE_KEY, TRUE, FALSE, &inner_error);
+       if (inner_error)
+               goto end;
+
+       domain_ontology->journal_location =
+               key_file_get_location (key_file, DOMAIN_ONTOLOGY_SECTION,
+                                      JOURNAL_KEY, FALSE, FALSE, &inner_error);
+       if (inner_error)
+               goto end;
+
+       domain_ontology->ontology_location =
+               key_file_get_location (key_file, DOMAIN_ONTOLOGY_SECTION,
+                                      ONTOLOGY_KEY, FALSE, TRUE, &inner_error);
        if (inner_error)
                goto end;
 
+       domain_ontology->ontology_name = g_key_file_get_string (key_file, DOMAIN_ONTOLOGY_SECTION,
+                                                               ONTOLOGY_NAME_KEY, NULL);
+       domain_ontology->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.
+        */
+       if ((domain_ontology->ontology_name && domain_ontology->ontology_location) ||
+           (!domain_ontology->ontology_name && !domain_ontology->ontology_location)) {
+               inner_error = g_error_new (G_KEY_FILE_ERROR,
+                                          G_KEY_FILE_ERROR_INVALID_VALUE,
+                                          "One of OntologyLocation and OntologyName must be provided");
+       }
+
+       /* Build ontology location from name if necessary */
+       if (!domain_ontology->ontology_location) {
+               gchar *ontology_path;
+
+               if (g_getenv ("TRACKER_DB_ONTOLOGIES_DIR") != NULL) {
+                       /* Override for use only by testcases */
+                       domain_ontology->ontology_location = g_file_new_for_path (g_getenv 
("TRACKER_DB_ONTOLOGIES_DIR"));
+               } else {
+                       ontology_path = g_build_filename (SHAREDIR, "tracker", "ontologies",
+                                                         domain_ontology->ontology_name, NULL);
+
+                       if (!g_file_test (ontology_path, G_FILE_TEST_IS_DIR)) {
+                               g_error ("Unable to find ontologies in the configured location %s", 
ontology_path);
+                       }
+
+                       domain_ontology->ontology_location = g_file_new_for_path (ontology_path);
+
+                       g_free (ontology_path);
+               }
+       }
+
 end:
        if (key_file)
                g_key_file_free (key_file);
 
        if (inner_error) {
                g_propagate_error (error, inner_error);
+               tracker_domain_ontology_unref (domain_ontology);
+               return NULL;
+       }
+
+       return domain_ontology;
+}
+
+GFile *
+tracker_domain_ontology_get_cache (TrackerDomainOntology *domain_ontology)
+{
+       return domain_ontology->cache_location;
+}
+
+GFile *
+tracker_domain_ontology_get_journal (TrackerDomainOntology *domain_ontology)
+{
+       return domain_ontology->journal_location;
+}
+
+GFile *
+tracker_domain_ontology_get_ontology (TrackerDomainOntology *domain_ontology)
+{
+       return domain_ontology->ontology_location;
+}
+
+gchar *
+tracker_domain_ontology_get_domain (TrackerDomainOntology *domain_ontology,
+                                    const gchar           *suffix)
+{
+       if (suffix)
+               return g_strconcat (domain_ontology->domain, ".", suffix, NULL);
+       else
+               return g_strconcat (domain_ontology->domain, NULL);
+}
+
+gboolean
+tracker_domain_ontology_uses_miner (TrackerDomainOntology *domain_ontology,
+                                    const gchar           *suffix)
+{
+       guint i;
+
+       g_return_val_if_fail (suffix != NULL, FALSE);
+
+       if (!domain_ontology->miners)
                return FALSE;
+
+       for (i = 0; domain_ontology->miners[i] != NULL; i++) {
+               if (strcmp (domain_ontology->miners[i], suffix) == 0) {
+                       return TRUE;
+               }
        }
 
-       return TRUE;
+       return FALSE;
 }
diff --git a/src/libtracker-miners-common/tracker-domain-ontology.h 
b/src/libtracker-miners-common/tracker-domain-ontology.h
index 92b985ed3..12434a212 100644
--- a/src/libtracker-miners-common/tracker-domain-ontology.h
+++ b/src/libtracker-miners-common/tracker-domain-ontology.h
@@ -23,11 +23,29 @@
 #define __TRACKER_DOMAIN_ONTOLOGY_H__
 
 #if !defined (__LIBTRACKER_COMMON_INSIDE__) && !defined (TRACKER_COMPILATION)
-#error "only <libtracker-miners-common/tracker-common.h> must be included directly."
+#error "only <libtracker-common/tracker-common.h> must be included directly."
 #endif
 
 #include <glib-object.h>
+#include <gio/gio.h>
 
-gboolean tracker_load_domain_config (const gchar *name, gchar **dbus_domain_name, GError **error);
+typedef struct _TrackerDomainOntology TrackerDomainOntology;
+
+TrackerDomainOntology * tracker_domain_ontology_new      (const gchar   *name,
+                                                          GCancellable  *cancellable,
+                                                          GError       **error);
+TrackerDomainOntology * tracker_domain_ontology_ref      (TrackerDomainOntology *domain_ontology);
+
+void    tracker_domain_ontology_unref        (TrackerDomainOntology *domain_ontology);
+
+GFile * tracker_domain_ontology_get_cache    (TrackerDomainOntology *domain_ontology);
+GFile * tracker_domain_ontology_get_journal  (TrackerDomainOntology *domain_ontology);
+GFile * tracker_domain_ontology_get_ontology (TrackerDomainOntology *domain_ontology);
+
+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_DOMAIN_ONTOLOGY_H__ */
diff --git a/src/miners/fs/tracker-main.c b/src/miners/fs/tracker-main.c
index 72c024858..a42d03555 100644
--- a/src/miners/fs/tracker-main.c
+++ b/src/miners/fs/tracker-main.c
@@ -773,7 +773,8 @@ main (gint argc, gchar *argv[])
        gboolean store_available;
        TrackerMinerProxy *proxy;
        GDBusConnection *connection;
-       gchar *dbus_domain_name, *dbus_name;
+       TrackerDomainOntology *domain_ontology;
+       gchar *domain_name, *dbus_name;
 
        main_loop = NULL;
 
@@ -813,9 +814,8 @@ main (gint argc, gchar *argv[])
 
        tracker_sparql_connection_set_domain (domain_ontology_name);
 
-       tracker_load_domain_config (domain_ontology_name, &dbus_domain_name, &error);
-
-       if (error != NULL) {
+       domain_ontology = tracker_domain_ontology_new (domain_ontology_name, NULL, &error);
+       if (error) {
                g_critical ("Could not load domain ontology '%s': %s",
                            domain_ontology_name, error->message);
                g_error_free (error);
@@ -856,16 +856,18 @@ main (gint argc, gchar *argv[])
 
        main_loop = g_main_loop_new (NULL, FALSE);
 
-       if (domain_ontology_name) {
+       if (domain_ontology && domain_ontology_name) {
                /* If we are running for a specific domain, we tie the lifetime of this
                 * process to the domain. For example, if the domain name is
                 * org.example.MyApp then this tracker-miner-fs process will exit as
                 * soon as org.example.MyApp exits.
                 */
-               g_bus_watch_name_on_connection (connection, dbus_domain_name,
+               domain_name = tracker_domain_ontology_get_domain (domain_ontology, NULL);
+               g_bus_watch_name_on_connection (connection, domain_name,
                                                G_BUS_NAME_WATCHER_FLAGS_NONE,
                                                NULL, on_domain_vanished,
                                                main_loop, NULL);
+               g_free (domain_name);
        }
 
        g_message ("Checking if we're running as a daemon:");
@@ -920,7 +922,7 @@ main (gint argc, gchar *argv[])
        }
 
        /* Request DBus name */
-       dbus_name = g_strconcat (dbus_domain_name, ".", DBUS_NAME_SUFFIX, NULL);
+       dbus_name = tracker_domain_ontology_get_domain (domain_ontology, DBUS_NAME_SUFFIX);
 
        if (!tracker_dbus_request_name (connection, dbus_name, &error)) {
                g_critical ("Could not request DBus name '%s': %s",
@@ -994,8 +996,7 @@ main (gint argc, gchar *argv[])
 
        g_object_unref (proxy);
        g_object_unref (connection);
-
-       g_free (dbus_domain_name);
+       tracker_domain_ontology_unref (domain_ontology);
 
        tracker_writeback_shutdown ();
        tracker_log_shutdown ();
diff --git a/src/miners/rss/tracker-main.c b/src/miners/rss/tracker-main.c
index 228fc3e2b..864cc4d8d 100644
--- a/src/miners/rss/tracker-main.c
+++ b/src/miners/rss/tracker-main.c
@@ -78,7 +78,8 @@ main (int argc, char **argv)
        GError *error = NULL;
        GDBusConnection *connection;
        TrackerMinerProxy *proxy;
-       gchar *dbus_domain_name, *dbus_name;
+       TrackerDomainOntology *domain_ontology;
+       gchar *domain_name, *dbus_name;
 
        setlocale (LC_ALL, "");
 
@@ -171,8 +172,7 @@ main (int argc, char **argv)
                g_free (log_filename);
        }
 
-       tracker_load_domain_config (domain_ontology_name, &dbus_domain_name, &error);
-
+       domain_ontology = tracker_domain_ontology_new (domain_ontology_name, NULL, &error);
        if (error) {
                g_critical ("Could not load domain ontology '%s': %s",
                            domain_ontology_name, error->message);
@@ -203,7 +203,7 @@ main (int argc, char **argv)
                return EXIT_FAILURE;
        }
 
-       dbus_name = g_strconcat (dbus_domain_name, ".", DBUS_NAME_SUFFIX, NULL);
+       dbus_name = tracker_domain_ontology_get_domain (domain_ontology, DBUS_NAME_SUFFIX);
 
        if (!tracker_dbus_request_name (connection, dbus_name, &error)) {
                g_critical ("Could not request DBus name '%s': %s",
@@ -217,16 +217,18 @@ main (int argc, char **argv)
 
        loop = g_main_loop_new (NULL, FALSE);
 
-       if (domain_ontology_name) {
+       if (domain_ontology && domain_ontology_name) {
                /* If we are running for a specific domain, we tie the lifetime of this
                 * process to the domain. For example, if the domain name is
                 * org.example.MyApp then this tracker-miner-rss process will exit as
                 * soon as org.example.MyApp exits.
                 */
-               g_bus_watch_name_on_connection (connection, dbus_domain_name,
+               domain_name = tracker_domain_ontology_get_domain (domain_ontology, NULL);
+               g_bus_watch_name_on_connection (connection, domain_name,
                                                G_BUS_NAME_WATCHER_FLAGS_NONE,
                                                NULL, on_domain_vanished,
                                                loop, NULL);
+               g_free (domain_name);
        }
 
        g_main_loop_run (loop);
@@ -236,7 +238,7 @@ main (int argc, char **argv)
        g_object_unref (miner);
        g_object_unref (connection);
        g_object_unref (proxy);
-       g_free (dbus_domain_name);
+       tracker_domain_ontology_unref (domain_ontology);
 
        return EXIT_SUCCESS;
 }
diff --git a/src/miners/rss/tracker-miner-rss.c b/src/miners/rss/tracker-miner-rss.c
index 0da57573c..e36678d08 100644
--- a/src/miners/rss/tracker-miner-rss.c
+++ b/src/miners/rss/tracker-miner-rss.c
@@ -246,7 +246,8 @@ tracker_miner_rss_init (TrackerMinerRSS *object)
 {
        GError *error = NULL;
        TrackerMinerRSSPrivate *priv;
-       gchar *dbus_domain_name;
+       TrackerDomainOntology *domain_ontology;
+       gchar *dbus_name;
 
        g_message ("Initializing...");
 
@@ -277,11 +278,13 @@ tracker_miner_rss_init (TrackerMinerRSS *object)
        g_message ("Listening for GraphUpdated changes on D-Bus interface...");
        g_message ("  arg0:'%s'", TRACKER_PREFIX_MFO "FeedChannel");
 
-       tracker_load_domain_config (tracker_sparql_connection_get_domain (), &dbus_domain_name, &error);
+       domain_ontology = tracker_domain_ontology_new (tracker_sparql_connection_get_domain (),
+                                                      NULL, NULL);
+       dbus_name = tracker_domain_ontology_get_domain (domain_ontology, NULL);
 
        priv->graph_updated_id =
                g_dbus_connection_signal_subscribe  (priv->connection,
-                                                    dbus_domain_name,
+                                                    dbus_name,
                                                     "org.freedesktop.Tracker1.Resources",
                                                     "GraphUpdated",
                                                     "/org/freedesktop/Tracker1/Resources",
@@ -290,8 +293,8 @@ tracker_miner_rss_init (TrackerMinerRSS *object)
                                                     graph_updated_cb,
                                                     object,
                                                     NULL);
-
-       g_free (dbus_domain_name);
+       g_free (dbus_name);
+       tracker_domain_ontology_unref (domain_ontology);
 }
 
 static void
diff --git a/src/tracker-extract/tracker-main.c b/src/tracker-extract/tracker-main.c
index 4430ddabf..7d5443d37 100644
--- a/src/tracker-extract/tracker-main.c
+++ b/src/tracker-extract/tracker-main.c
@@ -315,7 +315,8 @@ main (int argc, char *argv[])
        GMainLoop *my_main_loop;
        GDBusConnection *connection;
        TrackerMinerProxy *proxy;
-       gchar *dbus_domain_name, *dbus_name;
+       TrackerDomainOntology *domain_ontology;
+       gchar *domain_name, *dbus_name;
 
        bindtextdomain (GETTEXT_PACKAGE, LOCALEDIR);
        bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
@@ -361,8 +362,7 @@ main (int argc, char *argv[])
 
        tracker_sparql_connection_set_domain (domain_ontology_name);
 
-       tracker_load_domain_config (domain_ontology_name, &dbus_domain_name, &error);
-
+       domain_ontology = tracker_domain_ontology_new (domain_ontology_name, NULL, &error);
        if (error) {
                g_critical ("Could not load domain ontology '%s': %s",
                            domain_ontology_name, error->message);
@@ -444,7 +444,7 @@ main (int argc, char *argv[])
        tracker_miner_start (TRACKER_MINER (decorator));
 
        /* Request DBus name */
-       dbus_name = g_strconcat (dbus_domain_name, ".", DBUS_NAME_SUFFIX, NULL);
+       dbus_name = tracker_domain_ontology_get_domain (domain_ontology, DBUS_NAME_SUFFIX);
 
        if (!tracker_dbus_request_name (connection, dbus_name, &error)) {
                g_critical ("Could not request DBus name '%s': %s",
@@ -459,16 +459,18 @@ main (int argc, char *argv[])
        /* Main loop */
        main_loop = g_main_loop_new (NULL, FALSE);
 
-       if (domain_ontology_name) {
+       if (domain_ontology && domain_ontology_name) {
                /* If we are running for a specific domain, we tie the lifetime of this
                 * process to the domain. For example, if the domain name is
                 * org.example.MyApp then this tracker-extract process will exit as
                 * soon as org.example.MyApp exits.
                 */
-               g_bus_watch_name_on_connection (connection, dbus_domain_name,
+               domain_name = tracker_domain_ontology_get_domain (domain_ontology, NULL);
+               g_bus_watch_name_on_connection (connection, domain_name,
                                                G_BUS_NAME_WATCHER_FLAGS_NONE,
                                                NULL, on_domain_vanished,
                                                main_loop, NULL);
+               g_free (domain_name);
        }
 
        g_signal_connect (decorator, "finished",
@@ -494,7 +496,7 @@ main (int argc, char *argv[])
        g_object_unref (controller);
        g_object_unref (proxy);
        g_object_unref (connection);
-       g_free (dbus_domain_name);
+       tracker_domain_ontology_unref (domain_ontology);
 
        tracker_log_shutdown ();
 


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