[rygel/wip/tracker-3.0: 15/17] WIP
- From: Jens Georg <jensgeorg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [rygel/wip/tracker-3.0: 15/17] WIP
- Date: Sun, 31 May 2020 15:44:49 +0000 (UTC)
commit 3cc294e927ddfef04bd51e1f72e3f052fac3a727
Author: Jens Georg <mail jensge org>
Date: Sun May 31 16:52:07 2020 +0200
WIP
.../rygel-tracker-category-all-container.vala | 16 ++++---------
.../tracker3/rygel-tracker-category-container.vala | 8 +++----
.../tracker3/rygel-tracker-insertion-query.vala | 1 +
.../tracker3/rygel-tracker-metadata-container.vala | 23 +++---------------
src/plugins/tracker3/rygel-tracker-music.vala | 4 ++--
src/plugins/tracker3/rygel-tracker-new.vala | 5 ++--
.../tracker3/rygel-tracker-plugin-factory.vala | 13 -----------
src/plugins/tracker3/rygel-tracker-plugin.vala | 1 +
.../tracker3/rygel-tracker-root-container.vala | 13 +++++++++++
.../tracker3/rygel-tracker-search-container.vala | 27 ++++++++--------------
10 files changed, 40 insertions(+), 71 deletions(-)
---
diff --git a/src/plugins/tracker3/rygel-tracker-category-all-container.vala
b/src/plugins/tracker3/rygel-tracker-category-all-container.vala
index 4d295445..996a08e2 100644
--- a/src/plugins/tracker3/rygel-tracker-category-all-container.vala
+++ b/src/plugins/tracker3/rygel-tracker-category-all-container.vala
@@ -40,8 +40,6 @@ public class Rygel.Tracker.CategoryAllContainer : SearchContainer,
public ArrayList<string> create_classes { get; set; }
public ArrayList<string> search_classes { get; set; }
- private Sparql.Connection resources;
-
public CategoryAllContainer (CategoryContainer parent) {
base ("All" + parent.id, parent, "All", parent.item_factory);
@@ -49,13 +47,6 @@ public class Rygel.Tracker.CategoryAllContainer : SearchContainer,
this.create_classes.add (item_factory.upnp_class);
this.search_classes = new ArrayList<string> ();
- try {
- this.resources = Sparql.Connection.bus_new (TRACKER_SERVICE, null);
- } catch (Error io_error) {
- critical (_("Failed to create a Tracker connection: %s"),
- io_error.message);
- }
-
if (item_factory.upload_dir != null) {
try {
var uri = Filename.to_uri (item_factory.upload_dir, null);
@@ -83,7 +74,7 @@ public class Rygel.Tracker.CategoryAllContainer : SearchContainer,
message("RUnnin cleanup query for %s", this.item_factory.category);
var cleanup_query = new CleanupQuery (this.item_factory.category);
- cleanup_query.execute.begin (this.resources);
+ cleanup_query.execute.begin (RootContainer.connection, () => { query.result.close (); } );
}
public async void add_item (MediaFileItem item, Cancellable? cancellable)
@@ -142,7 +133,7 @@ public class Rygel.Tracker.CategoryAllContainer : SearchContainer,
var category = this.item_factory.category;
var query = new InsertionQuery (item, category);
- yield query.execute (this.resources);
+ yield query.execute (RootContainer.connection);
return query.id;
}
@@ -150,6 +141,7 @@ public class Rygel.Tracker.CategoryAllContainer : SearchContainer,
private async void remove_entry_from_store (string id) throws Error {
var query = new DeletionQuery (id);
- yield query.execute (this.resources);
+ yield query.execute (RootContainer.connection);
}
}
+
diff --git a/src/plugins/tracker3/rygel-tracker-category-container.vala
b/src/plugins/tracker3/rygel-tracker-category-container.vala
index d32d7e7b..351df188 100644
--- a/src/plugins/tracker3/rygel-tracker-category-container.vala
+++ b/src/plugins/tracker3/rygel-tracker-category-container.vala
@@ -41,10 +41,10 @@ public abstract class Rygel.Tracker.CategoryContainer : Rygel.SimpleContainer {
this.all_container = new CategoryAllContainer (this);
- //this.add_child_container (this.all_container);
- //this.add_child_container (new Tags (this, item_factory));
- //this.add_child_container (new Titles (this, this.item_factory));
- //this.add_child_container (new New (this, this.item_factory));
+ this.add_child_container (this.all_container);
+ this.add_child_container (new Tags (this, item_factory));
+ this.add_child_container (new Titles (this, this.item_factory));
+ this.add_child_container (new New (this, this.item_factory));
ulong signal_id = 0;
signal_id = this.all_container.container_updated.connect( () => {
diff --git a/src/plugins/tracker3/rygel-tracker-insertion-query.vala
b/src/plugins/tracker3/rygel-tracker-insertion-query.vala
index e062d058..4d5323a6 100644
--- a/src/plugins/tracker3/rygel-tracker-insertion-query.vala
+++ b/src/plugins/tracker3/rygel-tracker-insertion-query.vala
@@ -152,6 +152,7 @@ public class Rygel.Tracker.InsertionQuery : Query {
}
} catch (Error error) {
}
+ cursor.close ();
} else {
var file = File.new_for_uri (this.uri);
if (file.is_native () &&
diff --git a/src/plugins/tracker3/rygel-tracker-metadata-container.vala
b/src/plugins/tracker3/rygel-tracker-metadata-container.vala
index c3a46cd7..72180386 100644
--- a/src/plugins/tracker3/rygel-tracker-metadata-container.vala
+++ b/src/plugins/tracker3/rygel-tracker-metadata-container.vala
@@ -39,13 +39,8 @@ public abstract class Rygel.Tracker.MetadataContainer : Rygel.SimpleContainer {
private string child_class;
- private static Sparql.Connection resources;
protected QueryTriplets triplets;
- static construct {
- resources = Sparql.Connection.bus_new ("org.freedesktop.Tracker3.Miner.Files", null);
- }
-
protected MetadataContainer (string id,
MediaContainer parent,
string title,
@@ -55,17 +50,6 @@ public abstract class Rygel.Tracker.MetadataContainer : Rygel.SimpleContainer {
this.item_factory = item_factory;
this.child_class = child_class;
-
- #if 0
- try {
- this.resources = Sparql.Connection.bus_new ("org.freedesktop.Tracker3.Miner.Files", null);
- } catch (Error error) {
- critical (_("Failed to create Tracker connection: %s"),
- error.message);
-
- return;
- }
- #endif
}
internal async void fetch_metadata_values () {
@@ -80,7 +64,7 @@ public abstract class Rygel.Tracker.MetadataContainer : Rygel.SimpleContainer {
var query = this.create_query ();
try {
- yield query.execute (this.resources);
+ yield query.execute (RootContainer.connection);
/* Iterate through all the values */
while (query.result.next ()) {
@@ -112,6 +96,8 @@ public abstract class Rygel.Tracker.MetadataContainer : Rygel.SimpleContainer {
this.add_child_container (container);
}
+
+ query.result.close ();
} catch (Error error) {
critical (_("Error getting all values for ā%sā: %s"),
this.id,
@@ -121,9 +107,6 @@ public abstract class Rygel.Tracker.MetadataContainer : Rygel.SimpleContainer {
return;
}
- query.result = null;
- query = null;
-
this.updated ();
this.update_in_progress = false;
}
diff --git a/src/plugins/tracker3/rygel-tracker-music.vala b/src/plugins/tracker3/rygel-tracker-music.vala
index bcb76a69..f0f9abb9 100644
--- a/src/plugins/tracker3/rygel-tracker-music.vala
+++ b/src/plugins/tracker3/rygel-tracker-music.vala
@@ -31,8 +31,8 @@ public class Rygel.Tracker.Music : CategoryContainer {
base (id, parent, title, new MusicItemFactory ());
this.add_child_container (new Artists (this));
- /*this.add_child_container (new Albums (this));
- this.add_child_container (new Genre (this));*/
+ //this.add_child_container (new Albums (this));
+ //this.add_child_container (new Genre (this));
this.search_classes.add (AudioItem.UPNP_CLASS);
this.search_classes.add (MusicItem.UPNP_CLASS);
this.add_create_class (AudioItem.UPNP_CLASS);
diff --git a/src/plugins/tracker3/rygel-tracker-new.vala b/src/plugins/tracker3/rygel-tracker-new.vala
index efabcc86..f2055b97 100644
--- a/src/plugins/tracker3/rygel-tracker-new.vala
+++ b/src/plugins/tracker3/rygel-tracker-new.vala
@@ -29,7 +29,6 @@ using Gee;
public class Rygel.Tracker.New : Rygel.Tracker.SearchContainer {
private const string ADDED_PREDICATE = "tracker:added";
private const string ADDED_VARIABLE = "?added";
- private const long THREE_DAYS_AS_SEC = 259200;
public New (MediaContainer parent, ItemFactory item_factory) {
var triplets = new QueryTriplets ();
@@ -42,11 +41,11 @@ public class Rygel.Tracker.New : Rygel.Tracker.SearchContainer {
ADDED_VARIABLE));
var now = new DateTime.now_utc ();
- now.add_days (-3);
+ now = now.add_days (-3);
var three_days_ago = "%sZ".printf (now.format ("%Y-%m-%dT%H:%M:%S"));
var filters = new ArrayList<string> ();
- filters.add (ADDED_VARIABLE + " > \"" + three_days_ago + "\"");
+ filters.add (ADDED_VARIABLE + " > \"" + three_days_ago + "\"^^xsd:dateTime");
base (parent.id + "New",
parent,
diff --git a/src/plugins/tracker3/rygel-tracker-plugin-factory.vala
b/src/plugins/tracker3/rygel-tracker-plugin-factory.vala
index da85cc45..06f8149b 100644
--- a/src/plugins/tracker3/rygel-tracker-plugin-factory.vala
+++ b/src/plugins/tracker3/rygel-tracker-plugin-factory.vala
@@ -38,24 +38,11 @@ public void module_init (PluginLoader loader) {
}
public class Rygel.Tracker.PluginFactory {
- private const string TRACKER_SERVICE = "org.freedesktop.Tracker1";
- private const string STATISTICS_OBJECT =
- "/org/freedesktop/Tracker1/Statistics";
-
- StatsIface stats;
PluginLoader loader;
public PluginFactory (PluginLoader loader) throws IOError, DBusError {
- #if 0
- this.stats = Bus.get_proxy_sync (BusType.SESSION,
- TRACKER_SERVICE,
- STATISTICS_OBJECT,
- DBusProxyFlags.DO_NOT_LOAD_PROPERTIES);
- #endif
this.loader = loader;
- //this.stats.get ();
-
this.loader.add_plugin (new Tracker.Plugin ());
}
}
diff --git a/src/plugins/tracker3/rygel-tracker-plugin.vala b/src/plugins/tracker3/rygel-tracker-plugin.vala
index 5ad627a3..84a29369 100644
--- a/src/plugins/tracker3/rygel-tracker-plugin.vala
+++ b/src/plugins/tracker3/rygel-tracker-plugin.vala
@@ -21,6 +21,7 @@
*/
using Gee;
+using Tracker;
public class Rygel.Tracker.Plugin : Rygel.MediaServerPlugin {
public const string NAME = "Tracker3";
diff --git a/src/plugins/tracker3/rygel-tracker-root-container.vala
b/src/plugins/tracker3/rygel-tracker-root-container.vala
index 98ed3cf3..c5d3b25a 100644
--- a/src/plugins/tracker3/rygel-tracker-root-container.vala
+++ b/src/plugins/tracker3/rygel-tracker-root-container.vala
@@ -24,11 +24,24 @@
using GUPnP;
using Gee;
+using Tracker;
/**
* Represents the root container for Tracker media content hierarchy.
*/
public class Rygel.Tracker.RootContainer : Rygel.SimpleContainer {
+ private const string TRACKER_SERVICE = "org.freedesktop.Tracker3.Miner.Files";
+
+ public static Sparql.Connection connection;
+
+ static construct {
+ try {
+ RootContainer.connection = Sparql.Connection.bus_new (TRACKER_SERVICE, null);
+ } catch (Error err) {
+ error ("Failed to connect to tracker: %s", err.message);
+ }
+ }
+
public RootContainer (string title) {
base.root (title);
diff --git a/src/plugins/tracker3/rygel-tracker-search-container.vala
b/src/plugins/tracker3/rygel-tracker-search-container.vala
index 177ab6df..965d8294 100644
--- a/src/plugins/tracker3/rygel-tracker-search-container.vala
+++ b/src/plugins/tracker3/rygel-tracker-search-container.vala
@@ -38,7 +38,9 @@ public class Rygel.Tracker.SearchContainer : SimpleContainer {
public SelectionQuery query;
public ItemFactory item_factory;
- private Sparql.Connection resources;
+ static construct {
+ update_id_hash = new HashMap<string, uint> ();
+ }
private static HashMap<string, uint> update_id_hash;
@@ -50,10 +52,6 @@ public class Rygel.Tracker.SearchContainer : SimpleContainer {
ArrayList<string>? filters = null) {
base (id, parent, title);
- if (unlikely (update_id_hash == null)) {
- update_id_hash = new HashMap<string, uint> ();
- }
-
if (update_id_hash.has_key (this.id)) {
this.update_id = update_id_hash[this.id];
}
@@ -69,14 +67,12 @@ public class Rygel.Tracker.SearchContainer : SimpleContainer {
var variables = new ArrayList<string> ();
variables.add (SelectionQuery.ITEM_VARIABLE);
- QueryTriplets our_triplets = new QueryTriplets ();
- #if 0
+ QueryTriplets our_triplets;
if (triplets != null) {
our_triplets = triplets;
} else {
our_triplets = new QueryTriplets ();
}
- #endif
our_triplets.add (new QueryTriplet
(SelectionQuery.ITEM_VARIABLE,
@@ -102,13 +98,7 @@ public class Rygel.Tracker.SearchContainer : SimpleContainer {
filters,
order_by);
- try {
- this.resources = Sparql.Connection.bus_new ("org.freedesktop.Tracker3.Miner.Files", null);
-
- this.get_children_count.begin ();
- } catch (Error error) {
- critical (_("Failed to get Tracker connection: %s"), error.message);
- }
+ this.get_children_count.begin ();
}
public override async MediaObjects? get_children (uint offset,
@@ -146,7 +136,7 @@ public class Rygel.Tracker.SearchContainer : SimpleContainer {
sort_criteria);
if (query != null) {
- yield query.execute (this.resources);
+ yield query.execute (RootContainer.connection);
/* Iterate through all items */
while (yield query.result.next_async ()) {
@@ -160,6 +150,8 @@ public class Rygel.Tracker.SearchContainer : SimpleContainer {
query.result);
results.add (item);
}
+
+ query.result.close ();
}
total_matches = results.size;
@@ -223,13 +215,14 @@ public class Rygel.Tracker.SearchContainer : SimpleContainer {
SelectionQuery.ITEM_VARIABLE +
") AS ?x");
- yield query.execute (this.resources);
+ yield query.execute (RootContainer.connection);
if (query.result.next ()) {
this.child_count = int.parse (query.result.get_string (0));
this.updated ();
}
+ query.result.close ();
} catch (GLib.Error error) {
critical (_("Error getting item count under category ā%sā: %s"),
this.item_factory.category,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]