In URI interest selector for ndn.Exclude, added support for comma-separated list of values
diff --git a/README b/README
index f5c1be0..d82c174 100644
--- a/README
+++ b/README
@@ -153,8 +153,7 @@
ndn.InterestLifetime= non-negative int (milliseconds)
ndn.PublisherPublicKeyDigest= % escaped value
ndn.Nonce= % escaped value
-
-TODO: implement ndn.Exclude.
+ndn.Exclude= comma-separated list of % escaped values or * for ANY
* Multiple segments in the ndn protocol
diff --git a/js/ndnProtocol.xpi b/js/ndnProtocol.xpi
index cdb2110..07d2a39 100644
--- a/js/ndnProtocol.xpi
+++ b/js/ndnProtocol.xpi
Binary files differ
diff --git a/js/ndnProtocol/components/ndnProtocolService.js b/js/ndnProtocol/components/ndnProtocolService.js
index f8ee53b..d76d17a 100644
--- a/js/ndnProtocol/components/ndnProtocolService.js
+++ b/js/ndnProtocol/components/ndnProtocolService.js
@@ -425,21 +425,22 @@
if (key == "ndn.MinSuffixComponents" && nonNegativeInt >= 0)
template.minSuffixComponents = nonNegativeInt;
- if (key == "ndn.MaxSuffixComponents" && nonNegativeInt >= 0)
+ else if (key == "ndn.MaxSuffixComponents" && nonNegativeInt >= 0)
template.maxSuffixComponents = nonNegativeInt;
- if (key == "ndn.ChildSelector" && nonNegativeInt >= 0)
+ else if (key == "ndn.ChildSelector" && nonNegativeInt >= 0)
template.childSelector = nonNegativeInt;
- if (key == "ndn.AnswerOriginKind" && nonNegativeInt >= 0)
+ else if (key == "ndn.AnswerOriginKind" && nonNegativeInt >= 0)
template.answerOriginKind = nonNegativeInt;
- if (key == "ndn.Scope" && nonNegativeInt >= 0)
+ else if (key == "ndn.Scope" && nonNegativeInt >= 0)
template.scope = nonNegativeInt;
- if (key == "ndn.InterestLifetime" && nonNegativeInt >= 0)
+ else if (key == "ndn.InterestLifetime" && nonNegativeInt >= 0)
template.interestLifetime = nonNegativeInt;
- if (key == "ndn.PublisherPublicKeyDigest" && nonNegativeInt >= 0)
+ else if (key == "ndn.PublisherPublicKeyDigest")
template.publisherPublicKeyDigest = DataUtils.toNumbersFromString(unescape(value));
- if (key == "ndn.Nonce" && nonNegativeInt >= 0)
+ else if (key == "ndn.Nonce")
template.nonce = DataUtils.toNumbersFromString(unescape(value));
- // TODO: handle Exclude.
+ else if (key == "ndn.Exclude")
+ template.exclude = parseExclude(value);
}
// Remove the "ndn." term and don't advance i.
@@ -454,3 +455,21 @@
else
return "?" + terms.join('&');
}
+
+/*
+ * Parse the comma-separated list of exclude components and return an Exclude.
+ */
+function parseExclude(value) {
+ var excludeValues = [];
+
+ var splitValue = value.split(',');
+ for (var i = 0; i < splitValue.length; ++i) {
+ var element = splitValue[i].trim();
+ if (element == "*")
+ excludeValues.push("*")
+ else
+ excludeValues.push(Name.fromEscapedString(element));
+ }
+
+ return new Exclude(excludeValues);
+}
diff --git a/js/ndnProtocol/modules/ndn-js-header.txt b/js/ndnProtocol/modules/ndn-js-header.txt
index 3f505d2..648641c 100644
--- a/js/ndnProtocol/modules/ndn-js-header.txt
+++ b/js/ndnProtocol/modules/ndn-js-header.txt
@@ -6,7 +6,7 @@
* See COPYING for copyright and distribution information.
*/
-var EXPORTED_SYMBOLS = ["Closure", "ContentObject", "DataUtils", "Interest", "MimeTypes", "NDN",
+var EXPORTED_SYMBOLS = ["Closure", "ContentObject", "DataUtils", "Exclude", "Interest", "MimeTypes", "NDN",
"Name", "Sha256", "XpcomTransport"];
Components.utils.import("resource://gre/modules/XPCOMUtils.jsm");
diff --git a/js/ndnProtocol/modules/ndn-js.jsm b/js/ndnProtocol/modules/ndn-js.jsm
index 35e47ba..200fc41 100644
--- a/js/ndnProtocol/modules/ndn-js.jsm
+++ b/js/ndnProtocol/modules/ndn-js.jsm
@@ -6,7 +6,7 @@
* See COPYING for copyright and distribution information.
*/
-var EXPORTED_SYMBOLS = ["Closure", "ContentObject", "DataUtils", "Interest", "MimeTypes", "NDN",
+var EXPORTED_SYMBOLS = ["Closure", "ContentObject", "DataUtils", "Exclude", "Interest", "MimeTypes", "NDN",
"Name", "Sha256", "XpcomTransport"];
Components.utils.import("resource://gre/modules/XPCOMUtils.jsm");