[rygel/wip/tracker-3.0] WIP
- From: Jens Georg <jensgeorg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [rygel/wip/tracker-3.0] WIP
- Date: Sun, 24 May 2020 19:56:24 +0000 (UTC)
commit 9018b8bf96e7b7de7079aa1622d0c312a3754d24
Author: Jens Georg <mail jensge org>
Date: Sun May 24 21:56:06 2020 +0200
WIP
.../tracker3/rygel-tracker-category-container.vala | 8 +--
.../tracker3/rygel-tracker-metadata-container.vala | 11 +++-
.../tracker3/rygel-tracker-metadata-values.vala | 7 +-
src/plugins/tracker3/rygel-tracker-music.vala | 4 +-
.../tracker3/rygel-tracker-search-container.vala | 14 +++-
.../tracker3/rygel-tracker-selection-query.vala | 11 ++--
.../tracker3/rygel-tracker-upnp-property-map.vala | 74 +++++++++++++++++++---
7 files changed, 105 insertions(+), 24 deletions(-)
---
diff --git a/src/plugins/tracker3/rygel-tracker-category-container.vala
b/src/plugins/tracker3/rygel-tracker-category-container.vala
index f027397f..d32d7e7b 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-metadata-container.vala
b/src/plugins/tracker3/rygel-tracker-metadata-container.vala
index 1637fef3..c3a46cd7 100644
--- a/src/plugins/tracker3/rygel-tracker-metadata-container.vala
+++ b/src/plugins/tracker3/rygel-tracker-metadata-container.vala
@@ -39,9 +39,13 @@ public abstract class Rygel.Tracker.MetadataContainer : Rygel.SimpleContainer {
private string child_class;
- private Sparql.Connection resources;
+ 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,
@@ -52,6 +56,7 @@ 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) {
@@ -60,6 +65,7 @@ public abstract class Rygel.Tracker.MetadataContainer : Rygel.SimpleContainer {
return;
}
+ #endif
}
internal async void fetch_metadata_values () {
@@ -115,6 +121,9 @@ 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-metadata-values.vala
b/src/plugins/tracker3/rygel-tracker-metadata-values.vala
index b3937742..5a201cdc 100644
--- a/src/plugins/tracker3/rygel-tracker-metadata-values.vala
+++ b/src/plugins/tracker3/rygel-tracker-metadata-values.vala
@@ -48,6 +48,9 @@ public abstract class Rygel.Tracker.MetadataValues : MetadataContainer {
this.triplets.add (new QueryTriplet (SelectionQuery.ITEM_VARIABLE,
"a",
this.item_factory.category));
+ this.triplets.add (new QueryTriplet (SelectionQuery.ITEM_VARIABLE,
+ "nie:isStoredAs",
+ SelectionQuery.STORAGE_VARIABLE));
this.fetch_metadata_values.begin ();
}
@@ -58,7 +61,9 @@ public abstract class Rygel.Tracker.MetadataValues : MetadataContainer {
property_map[this.property] +
" AS ?x");
- return new SelectionQuery (selected, triplets, null, "?x");
+ var q = new SelectionQuery (selected, triplets, null, "?x");
+ critical(q.to_string());
+ return q;
}
protected override SearchContainer create_container (string id,
diff --git a/src/plugins/tracker3/rygel-tracker-music.vala b/src/plugins/tracker3/rygel-tracker-music.vala
index bffacf65..d634eea9 100644
--- a/src/plugins/tracker3/rygel-tracker-music.vala
+++ b/src/plugins/tracker3/rygel-tracker-music.vala
@@ -30,8 +30,8 @@ public class Rygel.Tracker.Music : CategoryContainer {
public Music (string id, MediaContainer parent, string title) {
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 Artists (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);
diff --git a/src/plugins/tracker3/rygel-tracker-search-container.vala
b/src/plugins/tracker3/rygel-tracker-search-container.vala
index b558cb93..197344a7 100644
--- a/src/plugins/tracker3/rygel-tracker-search-container.vala
+++ b/src/plugins/tracker3/rygel-tracker-search-container.vala
@@ -69,17 +69,23 @@ public class Rygel.Tracker.SearchContainer : SimpleContainer {
var variables = new ArrayList<string> ();
variables.add (SelectionQuery.ITEM_VARIABLE);
- QueryTriplets our_triplets;
+ QueryTriplets our_triplets = new QueryTriplets ();
+ #if 0
if (triplets != null) {
our_triplets = triplets;
} else {
our_triplets = new QueryTriplets ();
}
+ #endif
our_triplets.add (new QueryTriplet
(SelectionQuery.ITEM_VARIABLE,
"a",
item_factory.category));
+ our_triplets.add (new QueryTriplet
+ (SelectionQuery.ITEM_VARIABLE,
+ "nie:isStoredAs",
+ SelectionQuery.STORAGE_VARIABLE));
var property_map = UPnPPropertyMap.get_property_map ();
foreach (var property in this.item_factory.properties) {
@@ -88,7 +94,7 @@ public class Rygel.Tracker.SearchContainer : SimpleContainer {
var order_by = MODIFIED_PROPERTY +
"(" +
- SelectionQuery.ITEM_VARIABLE +
+ SelectionQuery.STORAGE_VARIABLE +
")";
this.query = new SelectionQuery (variables,
@@ -284,9 +290,11 @@ public class Rygel.Tracker.SearchContainer : SimpleContainer {
foreach (string s in sort_props) {
var key = key_chain_map[s.substring(1)];
- if (key.index_of (SelectionQuery.ITEM_VARIABLE) == 0) {
+ if (key.index_of (SelectionQuery.ITEM_VARIABLE) == 0 ||
+ key.index_of (SelectionQuery.STORAGE_VARIABLE) == 0) {
continue;
}
+
if (s.has_prefix("-")) {
order += "DESC (" +
diff --git a/src/plugins/tracker3/rygel-tracker-selection-query.vala
b/src/plugins/tracker3/rygel-tracker-selection-query.vala
index 05bd0287..847dd9ee 100644
--- a/src/plugins/tracker3/rygel-tracker-selection-query.vala
+++ b/src/plugins/tracker3/rygel-tracker-selection-query.vala
@@ -29,14 +29,15 @@ using Tracker;
*/
public class Rygel.Tracker.SelectionQuery : Query {
public const string ITEM_VARIABLE = "?item";
+ public const string STORAGE_VARIABLE = "?storage";
- private const string SHARED_FILTER = /*"(!BOUND(nmm:uPnPShared(" +
+ private const string SHARED_FILTER = ""; /*"(!BOUND(nmm:uPnPShared(" +
ITEM_VARIABLE + ")) ||" +
" nmm:uPnPShared(" +
ITEM_VARIABLE +
- ") = true) && " +*/
+ ") = true) && " +
"(BOUND(nie:isStoredAs(" +
- ITEM_VARIABLE + ")))";
+ ITEM_VARIABLE + ")))";*/
private const string STRICT_SHARED_FILTER = "(BOUND(nmm:dlnaProfile(" +
ITEM_VARIABLE + ")))";
private const string AVAILABLE_FILTER = "(tracker:available(nie:isStoredAs(" +
@@ -163,7 +164,7 @@ public class Rygel.Tracker.SelectionQuery : Query {
var filters = new ArrayList<string> ();
filters.add_all (this.filters);
// Make sure we don't expose items that are marked not to be shared
- filters.add (SHARED_FILTER);
+ // filters.add (SHARED_FILTER);
// Make sure we don't expose items on removable media that isn't
// mounted
@@ -173,7 +174,7 @@ public class Rygel.Tracker.SelectionQuery : Query {
// profile set
try {
var config = MetaConfig.get_default ();
- if (config.get_bool ("Tracker", "strict-sharing")) {
+ if (config.get_bool ("Tracker3", "strict-sharing")) {
filters.add (STRICT_SHARED_FILTER);
}
} catch (Error error) {};
diff --git a/src/plugins/tracker3/rygel-tracker-upnp-property-map.vala
b/src/plugins/tracker3/rygel-tracker-upnp-property-map.vala
index eb305dd6..298d0eea 100644
--- a/src/plugins/tracker3/rygel-tracker-upnp-property-map.vala
+++ b/src/plugins/tracker3/rygel-tracker-upnp-property-map.vala
@@ -23,6 +23,16 @@
using Gee;
+internal class Rygel.Tracker.QueryVariable {
+ public string base_variable;
+ public string alias;
+
+ public QueryVariable(string base_variable, string alias) {
+ this.base_variable = base_variable;
+ this.alias = alias;
+ }
+}
+
/**
* A map of UPnP properties to tracker property functions, coalesces,
* subqueries or other custom functions
@@ -30,6 +40,7 @@ using Gee;
public class Rygel.Tracker.UPnPPropertyMap : Object {
HashMap<string, ArrayList<string>> property_map;
HashMap<string, string> functions;
+ HashMap<string, QueryVariable> variables;
private static UPnPPropertyMap instance;
public static UPnPPropertyMap get_property_map () {
@@ -43,45 +54,84 @@ public class Rygel.Tracker.UPnPPropertyMap : Object {
private UPnPPropertyMap () {
this.property_map = new HashMap<string, ArrayList<string>> ();
this.functions = new HashMap<string, string> ();
+ this.variables = new HashMap<string, QueryVariable> ();
+
+ this.add_variable ("upnp:class", SelectionQuery.ITEM_VARIABLE, "?_cls");
// Item
this.add_key_chain ("res", "nie:url");
+ this.add_variable ("res", SelectionQuery.STORAGE_VARIABLE, "?_url");
this.add_function ("place_holder",
"tracker:coalesce((SELECT false WHERE { { %s a ?o } " +
"FILTER (?o IN (nfo:FileDataObject, " +
"nfo:RemoteDataObject)) }), true)");
- this.add_key_chain ("fileName", "nfo:fileName", "nie:isStoredAs");
- this.add_alternative ("dc:title", "nie:title", "nfo:fileName");
+ this.add_variable ("place_holder", SelectionQuery.STORAGE_VARIABLE, "?_ph");
+ this.add_key_chain ("fileName", "nfo:fileName");
+ this.add_variable ("fileName", SelectionQuery.STORAGE_VARIABLE, "?_fn");
+
+ this.add_alternative ("dc:title", "nie:title", "?_fn");
+ this.add_function ("dc:title", "tracker:coalesce(nie:title(%s), nfo:fileName(?storage))");
+ this.add_variable ("dc:title", SelectionQuery.ITEM_VARIABLE, "?_title");
+
this.add_key_chain ("dlnaProfile", "nmm:dlnaProfile");
+ this.add_variable ("dlnaProfile", SelectionQuery.ITEM_VARIABLE, "?_profile");
+
this.add_alternative ("mimeType", "nmm:dlnaMime", "nie:mimeType");
+ this.add_variable ("mimeType", SelectionQuery.ITEM_VARIABLE, "?_mime");
+
this.add_alternative ("res@size", "nfo:fileSize", "nie:byteSize");
- this.add_alternative ("date",
- "nie:contentCreated",
- "nfo:fileLastModified");
+ this.add_variable ("res@size", SelectionQuery.STORAGE_VARIABLE, "?_mime");
+
+ this.add_function ("date", "tracker:coalesce(nie:contentCreated(%s),
nfo:fileLastModified(?storage))");
+ this.add_variable ("date", SelectionQuery.ITEM_VARIABLE, "?_date");
// Music Item
this.add_key_chain ("res@duration", "nfo:duration");
+ this.add_variable ("res@duration", SelectionQuery.ITEM_VARIABLE, "?_duration");
+
this.add_key_chain ("upnp:artist", "nmm:performer", "nmm:artistName");
+ this.add_variable ("upnp:artist", SelectionQuery.ITEM_VARIABLE, "?_artist");
+
this.add_key_chain ("dc:creator", "nmm:performer", "nmm:artistName");
+ this.add_variable ("dc:creator", SelectionQuery.ITEM_VARIABLE, "?_artist");
+
this.add_key_chain ("upnp:album", "nmm:musicAlbum", "nie:title");
+ this.add_variable ("upnp:album", SelectionQuery.ITEM_VARIABLE, "?_album");
+
this.add_key_chain ("upnp:originalTrackNumber", "nmm:trackNumber");
+ this.add_variable ("upnp:originalTrackNumber", SelectionQuery.ITEM_VARIABLE, "?_track");
+
this.add_key_chain ("upnp:genre", "nfo:genre");
+ this.add_variable ("upnp:genre", SelectionQuery.ITEM_VARIABLE, "?_genre");
+
this.add_key_chain ("sampleRate", "nfo:sampleRate");
+ this.add_variable ("sampleRate", SelectionQuery.ITEM_VARIABLE, "?_rate");
+
this.add_key_chain ("upnp:nrAudioChannels", "nfo:channels");
+ this.add_variable ("upnp:nrAudioChannels", SelectionQuery.ITEM_VARIABLE, "?_channels");
+
this.add_key_chain ("upnp:bitsPerSample", "nfo:bitsPerSample");
+ this.add_variable ("upnp:bitsPerSample", SelectionQuery.ITEM_VARIABLE, "?_bps");
+
this.add_key_chain ("upnp:bitrate", "nfo:averageBitrate");
+ this.add_variable ("upnp:bitrate", SelectionQuery.ITEM_VARIABLE, "?_rate");
// Picture & Video Items
this.add_key_chain ("width", "nfo:width");
+ this.add_variable ("width", SelectionQuery.ITEM_VARIABLE, "?_w");
+
this.add_key_chain ("height", "nfo:height");
+ this.add_variable ("height", SelectionQuery.ITEM_VARIABLE, "?_h");
this.add_key_chain ("rygel:originalVolumeNumber",
"nmm:musicAlbumDisc",
"nmm:setNumber");
+ this.add_variable ("rygel:originalVolumeNumber", SelectionQuery.ITEM_VARIABLE, "?_vol");
}
public new string @get (string property) {
- var str = SelectionQuery.ITEM_VARIABLE;
+ var variable = this.variables[property];
+ var str = variable.base_variable;
if (this.property_map.has_key (property)) {
foreach (var key in this.property_map[property]) {
@@ -91,7 +141,11 @@ public class Rygel.Tracker.UPnPPropertyMap : Object {
str = this.functions[property].printf (str);
}
- return str;
+ return str; // + " AS " + variable.alias;
+ }
+
+ private void add_variable (string property, string base_item, string alias) {
+ this.variables[property] = new QueryVariable(base_item, alias);
}
private void add_key_chain (string property, ...) {
@@ -120,7 +174,11 @@ public class Rygel.Tracker.UPnPPropertyMap : Object {
string alternative = list.arg ();
while (alternative != null) {
- str.append_printf ("%s(%%1$s),", alternative);
+ if (alternative.has_prefix ("?")) {
+ str.append (alternative);
+ } else {
+ str.append_printf ("%s(%%1$s),", alternative);
+ }
alternative = list.arg ();
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]