[tracker/domain-ontologies] Allow loading domain ontology from .desktop file
- From: Philip Van Hoof <pvanhoof src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [tracker/domain-ontologies] Allow loading domain ontology from .desktop file
- Date: Sun, 29 Jan 2017 09:18:03 +0000 (UTC)
commit 8e74dc1f6c8d4ff831eed4a1ade7b2f516b74b22
Author: Philip Van Hoof <philip codeminded be>
Date: Sun Jan 29 10:14:15 2017 +0100
Allow loading domain ontology from .desktop file
src/tracker-store/tracker-dbus.vala | 104 ++++++++++++++++++++++-------------
src/tracker-store/tracker-main.vala | 61 +++++++++++++-------
2 files changed, 104 insertions(+), 61 deletions(-)
---
diff --git a/src/tracker-store/tracker-dbus.vala b/src/tracker-store/tracker-dbus.vala
index 6eb5faf..dd9b665 100644
--- a/src/tracker-store/tracker-dbus.vala
+++ b/src/tracker-store/tracker-dbus.vala
@@ -77,7 +77,7 @@ public class Tracker.DBus {
}
}
- public static bool register_names (string? domain, string? ontology_name) {
+ public static bool register_names (string? domain, string? dbus_path, string? ontology_name) {
/* Register the service name for org.freedesktop.Tracker */
if (domain != null) {
@@ -126,10 +126,10 @@ public class Tracker.DBus {
}
}
- static void set_available (bool available, string? domain, string? ontology_name) {
+ static void set_available (bool available, string? domain, string? dbus_path, string? ontology_name) {
if (available) {
if (resources_id == 0) {
- register_objects (domain, ontology_name);
+ register_objects (domain, dbus_path, ontology_name);
}
} else {
if (resources_id != 0) {
@@ -147,8 +147,8 @@ public class Tracker.DBus {
}
}
- public static void shutdown (string? domain, string? ontology_name) {
- set_available (false, domain, ontology_name);
+ public static void shutdown (string? domain, string? dbus_path, string? ontology_name) {
+ set_available (false, domain, dbus_path, ontology_name);
if (backup != null) {
connection.unregister_object (backup_id);
@@ -165,7 +165,7 @@ public class Tracker.DBus {
connection = null;
}
- public static Tracker.Status? register_notifier (string? domain, string? ontology_name) {
+ public static Tracker.Status? register_notifier (string? domain, string? dbus_path, string?
ontology_name) {
if (connection == null) {
critical ("D-Bus support must be initialized before registering objects!");
return null;
@@ -178,18 +178,23 @@ public class Tracker.DBus {
return null;
}
- if (domain != null)
- if (ontology_name != null)
- notifier_id = register_object (connection, notifier,
"/"+domain+"/"+ontology_name+"/Status");
- else
- notifier_id = register_object (connection, notifier, "/"+domain+"/Status");
- else
+ if (domain != null) {
+ if (dbus_path != null ) {
+ notifier_id = register_object (connection, notifier, dbus_path+"/Status");
+ } else {
+ if (ontology_name != null)
+ notifier_id = register_object (connection, notifier,
"/"+domain+"/"+ontology_name+"/Status");
+ else
+ notifier_id = register_object (connection, notifier,
"/"+domain+"/Status");
+ }
+ } else {
notifier_id = register_object (connection, notifier, Tracker.Status.PATH);
+ }
return notifier;
}
- public static bool register_objects (string? domain, string? ontology_name) {
+ public static bool register_objects (string? domain, string? dbus_path, string? ontology_name) {
//gpointer object, resources;
if (connection == null) {
@@ -204,14 +209,19 @@ public class Tracker.DBus {
return false;
}
- if (domain != null)
- if (ontology_name != null)
- notifier_id = register_object (connection, notifier,
"/"+domain+"/"+ontology_name+"/Statistics");
- else
- notifier_id = register_object (connection, notifier,
"/"+domain+"/Statistics");
- else
+ if (domain != null) {
+ if (dbus_path != null ) {
+ statistics_id = register_object (connection, notifier,
dbus_path+"/Statistics");
+ } else {
+ if (ontology_name != null)
+ statistics_id = register_object (connection, notifier,
"/"+domain+"/"+ontology_name+"/Statistics");
+ else
+ statistics_id = register_object (connection, notifier,
"/"+domain+"/Statistics");
+ }
+ } else {
statistics_id = register_object (connection, statistics, Tracker.Statistics.PATH);
-
+ }
+
/* Add org.freedesktop.Tracker1.Resources */
resources = new Tracker.Resources (connection, config);
if (resources == null) {
@@ -226,13 +236,18 @@ public class Tracker.DBus {
0,
name_owner_changed_cb);
- if (domain != null)
- if (ontology_name != null)
- notifier_id = register_object (connection, notifier,
"/"+domain+"/"+ontology_name+"/Resources");
- else
- notifier_id = register_object (connection, notifier, "/"+domain+"/Resources");
- else
+ if (domain != null) {
+ if (dbus_path != null ) {
+ resources_id = register_object (connection, notifier, dbus_path+"/Resources");
+ } else {
+ if (ontology_name != null)
+ resources_id = register_object (connection, notifier,
"/"+domain+"/"+ontology_name+"/Resources");
+ else
+ resources_id = register_object (connection, notifier,
"/"+domain+"/Resources");
+ }
+ } else {
resources_id = register_object (connection, resources, Tracker.Resources.PATH);
+ }
/* Add org.freedesktop.Tracker1.Steroids */
steroids = new Tracker.Steroids ();
@@ -241,13 +256,18 @@ public class Tracker.DBus {
return false;
}
- if (domain != null)
- if (ontology_name != null)
- notifier_id = register_object (connection, notifier,
"/"+domain+"/"+ontology_name+"/Steroids");
- else
- notifier_id = register_object (connection, notifier, "/"+domain+"/Steroids");
- else
+ if (domain != null) {
+ if (dbus_path != null ) {
+ steroids_id = register_object (connection, notifier, dbus_path+"/Steroids");
+ } else {
+ if (ontology_name != null)
+ steroids_id = register_object (connection, notifier,
"/"+domain+"/"+ontology_name+"/Steroids");
+ else
+ steroids_id = register_object (connection, notifier,
"/"+domain+"/Steroids");
+ }
+ } else {
steroids_id = register_object (connection, steroids, Tracker.Steroids.PATH);
+ }
if (backup == null) {
/* Add org.freedesktop.Tracker1.Backup */
@@ -257,13 +277,19 @@ public class Tracker.DBus {
return false;
}
- if (domain != null)
- if (ontology_name != null)
- notifier_id = register_object (connection, notifier,
"/"+domain+"/"+ontology_name+"/Backup");
- else
- notifier_id = register_object (connection, notifier, "/"+domain+"/Backup");
- else
- backup_id = register_object (connection, backup, Tracker.Backup.PATH);
+
+ if (domain != null) {
+ if (dbus_path != null ) {
+ backup_id = register_object (connection, notifier,
dbus_path+"/Backup");
+ } else {
+ if (ontology_name != null)
+ backup_id = register_object (connection, notifier,
"/"+domain+"/"+ontology_name+"/Backup");
+ else
+ backup_id = register_object (connection, notifier,
"/"+domain+"/Backup");
+ }
+ } else {
+ backup_id = register_object (connection, backup, Tracker.Backup.PATH);
+ }
}
return true;
diff --git a/src/tracker-store/tracker-main.vala b/src/tracker-store/tracker-main.vala
index 65b71de..c08d90d 100644
--- a/src/tracker-store/tracker-main.vala
+++ b/src/tracker-store/tracker-main.vala
@@ -48,6 +48,7 @@ License which can be viewed at:
static string cache_location;
static string domain;
static string ontology_name;
+ static string dbus_path;
const OptionEntry entries[] = {
/* Daemon options */
@@ -61,6 +62,7 @@ License which can be viewed at:
{ "cache-location", 'd', 0, OptionArg.STRING, ref cache_location, N_("Override cache location
to be used"), null },
{ "domain", 'd', 0, OptionArg.STRING, ref domain, N_("Override domain to be used"), null },
{ "ontology-name", 0, 0, OptionArg.STRING, ref ontology_name, N_("Override ontology to be
used"), null },
+ { "dbus-path", 0, 0, OptionArg.STRING, ref dbus_path, N_("Override DBus path to be used"),
null },
{ null }
};
@@ -219,28 +221,43 @@ License which can be viewed at:
}
if (domain_ontology != null) {
- string? loaded_domain;
- string? loaded_cache_location;
- string? loaded_ontology_name;
-
string keyfile_path = Path.build_filename (SHAREDIR,
"tracker",
- "domains",
- domain_ontology+".desktop");
+ "domain-ontologies",
+ domain_ontology+".rule");
try {
- GLib.KeyFile keyfile = new GLib.KeyFile ( );
+ KeyFile keyfile = new KeyFile ( );
keyfile.load_from_file (keyfile_path, GLib.KeyFileFlags.NONE);
- loaded_domain = keyfile.get_string ("DomainOntology", "Domain");
- loaded_cache_location = keyfile.get_string ("DomainOntology",
"CacheLocation");
- loaded_ontology_name = keyfile.get_string ("DomainOntology", "OntologyName");
-
- if (domain == null)
- domain = loaded_domain;
- if (cache_location == null)
- cache_location = loaded_cache_location;
- if (ontology_name == null)
- ontology_name = loaded_ontology_name;
- } catch { }
+
+ try {
+ string? loaded_domain = keyfile.get_string ("DomainOntology",
"Domain");
+ if (domain == null)
+ domain = loaded_domain;
+ } 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_name = keyfile.get_string ("DomainOntology",
"OntologyName");
+ if (ontology_name == null)
+ ontology_name = loaded_ontology_name;
+ } catch (KeyFileError m) {}
+
+ try {
+ string? loaded_dbus_path = keyfile.get_string ("DomainOntology",
"DBusPath");
+ if (dbus_path == null)
+ dbus_path = loaded_dbus_path;
+ } catch (KeyFileError m) {}
+
+ } catch (KeyFileError ke) {
+ critical("Loading " + keyfile_path + " " + ke.message);
+ } catch (FileError fe) {
+ critical("Loading " + keyfile_path + " " + fe.message);
+ }
}
sanity_check_option_values (config);
@@ -262,17 +279,17 @@ License which can be viewed at:
flags |= DBManagerFlags.FORCE_REINDEX;
}
- var notifier = Tracker.DBus.register_notifier (domain, ontology_name);
+ var notifier = Tracker.DBus.register_notifier (domain, dbus_path, ontology_name);
var busy_callback = notifier.get_callback ();
Tracker.Store.init ();
/* Make Tracker available for introspection */
- if (!Tracker.DBus.register_objects (domain, ontology_name)) {
+ if (!Tracker.DBus.register_objects (domain, dbus_path, ontology_name)) {
return 1;
}
- if (!Tracker.DBus.register_names (domain, ontology_name)) {
+ if (!Tracker.DBus.register_names (domain, dbus_path, ontology_name)) {
return 1;
}
@@ -361,7 +378,7 @@ License which can be viewed at:
Tracker.Writeback.shutdown ();
Tracker.Events.shutdown ();
- Tracker.DBus.shutdown (domain, ontology_name);
+ Tracker.DBus.shutdown (domain, dbus_path, ontology_name);
Tracker.Data.Manager.shutdown ();
Tracker.Log.shutdown ();
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]