[rygel] core: Support search by child count
- From: Zeeshan Ali Khattak <zeeshanak src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [rygel] core: Support search by child count
- Date: Mon, 20 Dec 2010 15:42:08 +0000 (UTC)
commit 84d3ffb604b214b85dcddb8612356e3891ef3bc7
Author: Zeeshan Ali (Khattak) <zeeshanak gnome org>
Date: Sun Dec 19 00:25:27 2010 +0200
core: Support search by child count
Add support for search of media containers by their child count.
src/rygel/rygel-relational-expression.vala | 32 +++++++++++++++++++++++++++-
1 files changed, 31 insertions(+), 1 deletions(-)
---
diff --git a/src/rygel/rygel-relational-expression.vala b/src/rygel/rygel-relational-expression.vala
index 643b6b3..a835008 100644
--- a/src/rygel/rygel-relational-expression.vala
+++ b/src/rygel/rygel-relational-expression.vala
@@ -28,7 +28,7 @@ public class Rygel.RelationalExpression :
Rygel.SearchExpression<SearchCriteriaOp,string,string> {
internal const string CAPS = "@id,@parentID,upnp:class," +
"dc:title,upnp:artist,upnp:album," +
- "dc:creator,upnp:createClass";
+ "dc:creator,upnp:createClass,@childCount";
public override bool satisfied_by (MediaObject media_object) {
switch (this.operand1) {
@@ -65,6 +65,13 @@ public class Rygel.RelationalExpression :
}
return this.compare_string ((media_object as MusicItem).album);
+ case "@childCount":
+ if (!(media_object is MediaContainer)) {
+ return false;
+ }
+
+ var container = media_object as MediaContainer;
+ return this.compare_int (container.child_count);
default:
return false;
}
@@ -101,6 +108,8 @@ public class Rygel.RelationalExpression :
}
case SearchCriteriaOp.EQ:
return up_operand2 == up_str;
+ case SearchCriteriaOp.NEQ:
+ return up_operand2 != up_str;
case SearchCriteriaOp.CONTAINS:
return up_str.contains (up_operand2);
case SearchCriteriaOp.DERIVED_FROM:
@@ -109,4 +118,25 @@ public class Rygel.RelationalExpression :
return false;
}
}
+
+ public bool compare_int (int integer) {
+ var operand2 = this.operand2.to_int ();
+
+ switch (this.op) {
+ case SearchCriteriaOp.EQ:
+ return integer == operand2;
+ case SearchCriteriaOp.NEQ:
+ return integer != operand2;
+ case SearchCriteriaOp.LESS:
+ return integer < operand2;
+ case SearchCriteriaOp.LEQ:
+ return integer <= operand2;
+ case SearchCriteriaOp.GREATER:
+ return integer > operand2;
+ case SearchCriteriaOp.GEQ:
+ return integer >= operand2;
+ default:
+ return false;
+ }
+ }
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]