[rygel/wip/ruih: 2/3] ruih: Port fixes from cablelabs
- From: Jens Georg <jensgeorg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [rygel/wip/ruih: 2/3] ruih: Port fixes from cablelabs
- Date: Thu, 16 Oct 2014 22:43:01 +0000 (UTC)
commit cb43db840d15d424f640c0ba39cf84145cca218b
Author: Jens Georg <mail jensge org>
Date: Fri Oct 17 00:19:51 2014 +0200
ruih: Port fixes from cablelabs
Signed-off-by: Jens Georg <mail jensge org>
src/librygel-ruih/rygel-ruih-servicemanager.vala | 22 ++++++++++++++++------
src/librygel-ruih/rygel-ruih-ui-elem.vala | 9 +++++----
2 files changed, 21 insertions(+), 10 deletions(-)
---
diff --git a/src/librygel-ruih/rygel-ruih-servicemanager.vala
b/src/librygel-ruih/rygel-ruih-servicemanager.vala
index 0ad7963..89c285f 100644
--- a/src/librygel-ruih/rygel-ruih-servicemanager.vala
+++ b/src/librygel-ruih/rygel-ruih-servicemanager.vala
@@ -84,7 +84,6 @@ public class Rygel.RuihServiceManager
public string get_compatible_uis (string deviceProfile, string filter)
throws RuihServiceError {
lock (object) {
- ArrayList<ProtocolElem> protocols = new ArrayList<ProtocolElem> ();
ArrayList<FilterEntry> filter_entries = new ArrayList<FilterEntry> ();
Xml.Node* device_profile_node = null;
Xml.Doc* doc = null;
@@ -138,10 +137,13 @@ public class Rygel.RuihServiceManager
} // outer if
if (filter.length > 0) {
- if (filter == "*" || filter == "\"*\"") {
+ var filter_wildcard = (filter == "*" || filter == "\"*\"");
+
+ // Only enable wildcard if deviceprofile is not available
+ if (device_profile_node == null && filter_wildcard) {
// Wildcard filter entry
filter_entries.add (new WildCardFilterEntry ());
- } else {
+ } else if (!filter_wildcard) {
// Check if the input UIFilter is in the right format.
if ((filter.get_char (0) != '"') ||
((filter.get_char (filter.length - 1) != '"')
@@ -181,14 +183,22 @@ public class Rygel.RuihServiceManager
StringBuilder result = new StringBuilder (PRE_RESULT);
if (this.ui_list != null && this.ui_list.size > 0) {
+ var result_content = new StringBuilder ();
+
foreach (UIElem i in this.ui_list) {
UIElem ui = (UIElem)i;
- if (ui.match (protocols , filter_entries)) {
- result.append (ui.to_ui_listing (filter_entries));
- }
+ result_content.append (ui.to_ui_listing (filter_entries));
}
+
+ // Return empty string if there is no matching UI for a filter
+ if (result_content.str == "") {
+ return "";
+ }
+
+ result.append (result_content.str);
}
result.append (POST_RESULT);
+
return result.str;
}
}
diff --git a/src/librygel-ruih/rygel-ruih-ui-elem.vala b/src/librygel-ruih/rygel-ruih-ui-elem.vala
index 1c737f1..3fbefca 100644
--- a/src/librygel-ruih/rygel-ruih-ui-elem.vala
+++ b/src/librygel-ruih/rygel-ruih-ui-elem.vala
@@ -117,24 +117,25 @@ protected class UIElem : UIListing
HashMap<string, string> elements =
new HashMap<string, string> ();
bool match = false;
+ // Add all mandatory and optional elements
elements.set (UIID, this.id);
elements.set (NAME, this.name);
+ elements.set (DESCRIPTION, this.description);
+ elements.set (FORK, this.fork);
+ elements.set (LIFETIME, this.lifetime);
if ((this.name != null) && (filters_match (filters, NAME, this.name))) {
match = true;
}
if ((this.description != null) && (filters_match (filters, DESCRIPTION,
this.description))) {
- elements.set (DESCRIPTION, this.description);
match = true;
}
if ((this.fork != null) && (filters_match (filters, FORK, this.fork))) {
- elements.set (FORK, this.fork);
match = true;
}
if ((this.lifetime != null) && (filters_match (filters, LIFETIME,
this.lifetime))) {
- elements.set (LIFETIME, this.lifetime);
match = true;
}
@@ -171,4 +172,4 @@ protected class UIElem : UIListing
return "";
}
}
-}
\ No newline at end of file
+}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]