Added NdnProtocolInfo.jsm to store static info such as the connected host. Updated ndnProtocolService.js to report the hub host and port when connected, and updated the NDN Toolbar to display it.
diff --git a/js/ndnProtocol/modules/NdnProtocolInfo.jsm b/js/ndnProtocol/modules/NdnProtocolInfo.jsm
new file mode 100644
index 0000000..553e1ba
--- /dev/null
+++ b/js/ndnProtocol/modules/NdnProtocolInfo.jsm
@@ -0,0 +1,44 @@
+/*
+ * @author: Jeff Thompson
+ * See COPYING for copyright and distribution information.
+ */
+
+var EXPORTED_SYMBOLS = ["addNdnHubChangedListener", "setConnectedNdnHub"];
+
+const Cc = Components.classes;
+const Ci = Components.interfaces;
+const Cr = Components.results;
+
+Components.utils.import("resource://gre/modules/XPCOMUtils.jsm");
+
+var ndnHubHost = null;
+var ndnHubPort = null;
+var ndnHubChangedListenerList = [];
+
+/*
+ * When the NDN hub host or port is changed, the system calls listener(host, port).
+ */
+function addNdnHubChangedListener(listener) {
+ ndnHubChangedListenerList.push(listener);
+}
+
+/*
+ * If host and port are different than ndnHubHost or ndnHubPort, set them and call each
+ * listener in ndnHubChangedListenerList.
+ */
+function setConnectedNdnHub(host, port) {
+ if (host == ndnHubHost && port == ndnHubPort)
+ // No change.
+ return;
+
+ ndnHubHost = host;
+ ndnHubPort = port;
+ for (var i = 0; i < ndnHubChangedListenerList.length; ++i) {
+ try {
+ ndnHubChangedListenerList[i](host, port);
+ }
+ catch (ex) {
+ // Ignore error from the listener.
+ }
+ }
+}
\ No newline at end of file