[rygel] core: implement AtomicExpression.satisfied_by()
- From: Zeeshan Ali Khattak <zeeshanak src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [rygel] core: implement AtomicExpression.satisfied_by()
- Date: Mon, 9 Nov 2009 18:46:06 +0000 (UTC)
commit bd0ffff9747f811aa072dddc18ad268a2e124677
Author: Zeeshan Ali (Khattak) <zeeshanak gnome org>
Date: Wed Nov 4 03:50:47 2009 +0200
core: implement AtomicExpression.satisfied_by()
Basic implementation of AtomicExpression.satisfied_by().
src/rygel/rygel-search-expression.vala | 60 +++++++++++++++++++++++++++++++-
1 files changed, 59 insertions(+), 1 deletions(-)
---
diff --git a/src/rygel/rygel-search-expression.vala b/src/rygel/rygel-search-expression.vala
index ab47c8f..4b65da7 100644
--- a/src/rygel/rygel-search-expression.vala
+++ b/src/rygel/rygel-search-expression.vala
@@ -44,12 +44,70 @@ public abstract class Rygel.SearchExpression<G,H,I> {
public class Rygel.AtomicExpression :
Rygel.SearchExpression<SearchCriteriaOp,string,string> {
public override async bool satisfied_by (MediaObject media_object) {
- return true;
+ switch (this.operand1) {
+ case "@id":
+ return this.compare_string (media_object.id);
+ case "@parentID":
+ return this.compare_string (media_object.parent.id);
+ case "@refID":
+ return false; // We don't have refIDs yet
+ case "upnp:class":
+ return this.compare_string (media_object.upnp_class);
+ case "dc:title":
+ return this.compare_string (media_object.title);
+ case "dc:creator":
+ if (!(media_object is MediaItem)) {
+ return false;
+ }
+
+ var item = media_object as MediaItem;
+ return this.compare_string (item.author);
+ default:
+ if (this.operand1.has_prefix ("res")) {
+ return this.compare_resource (media_object);
+ } else {
+ return false;
+ }
+ }
}
public override string to_string () {
return "%s %d %s".printf (this.operand1, this.op, this.operand2);
}
+
+ private bool compare_resource (MediaObject media_object) {
+ bool ret = false;
+
+ foreach (var uri in media_object.uris) {
+ if (this.operand1 == "res" && this.compare_string (uri)) {
+ ret = true;
+ break;
+ } else if (this.operand1 == "res protocolInfo") {
+ // FIXME: Implement
+ }
+ }
+
+ return ret;
+ }
+
+ private bool compare_string (string? str) {
+ switch (this.op) {
+ case SearchCriteriaOp.EXISTS:
+ if (this.operand2 == "true") {
+ return str != null;
+ } else {
+ return str == null;
+ }
+ case SearchCriteriaOp.EQ:
+ return this.operand2 == str;
+ case SearchCriteriaOp.CONTAINS:
+ return this.operand2.contains (str);
+ case SearchCriteriaOp.DERIVED_FROM:
+ return this.operand2.has_prefix (str);
+ default:
+ return false;
+ }
+ }
}
public class Rygel.LogicalExpression :
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]