[Pkg-privacy-commits] [xul-ext-monkeysphere] 259/296: add context menu option to interrogate the version of the validation agent (MS # 2565)

Ximin Luo infinity0 at moszumanska.debian.org
Mon Aug 24 07:39:46 UTC 2015


This is an automated email from the git hooks/post-receive script.

infinity0 pushed a commit to branch debian
in repository xul-ext-monkeysphere.

commit ae0ef1edd9942dd5f88fd624f58a0249e2670b7d
Author: Daniel Kahn Gillmor <dkg at fifthhorseman.net>
Date:   Tue Dec 14 15:43:36 2010 -0500

    add context menu option to interrogate the version of the validation agent (MS # 2565)
---
 chrome/content/monkeysphere.js   | 60 ++++++++++++++++++++++++++++++++++++++++
 chrome/content/monkeysphere.xul  |  3 ++
 chrome/locale/en-US/messages     |  4 ++-
 chrome/locale/en-US/messages.dtd |  2 ++
 chrome/locale/fr-FR/messages     |  2 ++
 chrome/locale/fr-FR/messages.dtd |  2 ++
 6 files changed, 72 insertions(+), 1 deletion(-)

diff --git a/chrome/content/monkeysphere.js b/chrome/content/monkeysphere.js
index 113b33c..ef717fa 100644
--- a/chrome/content/monkeysphere.js
+++ b/chrome/content/monkeysphere.js
@@ -152,6 +152,33 @@ var monkeysphere = (function() {
      , monkeysphere.messages.GetStringFromName('statusINPROGRESS') );
   };
 
+  //////////////////////////////////////////////////////////
+  // get validation agent info
+  var getAgentInfo = function() {
+    ms.log("#### getting validation agent info ####");
+    var socket = ms.agent_socket();
+    // make the client request object
+    var client = new XMLHttpRequest();
+    var query = '';
+
+    var request_url = socket + "/";
+    ms.log("creating http request to " + request_url);
+    client.open("GET", request_url, true);
+
+    // set headers
+    client.setRequestHeader("Connection", "close");
+    client.setRequestHeader("Accept", "application/json");
+
+    // setup the state change function
+    client.onreadystatechange = function() {
+      monkeysphere.onAgentInfoStateChange(client);
+    };
+
+    ms.log("sending agent info query...");
+    client.send(query);
+    ms.log("agent info query sent");
+  };
+
 ////////////////////////////////////////////////////////////
 // UPDATE DISPLAY
 ////////////////////////////////////////////////////////////
@@ -338,6 +365,34 @@ var monkeysphere = (function() {
       }
     },
 
+    onAgentInfoStateChange: function(client) {
+      ms.log("agent info query state change: " + client.readyState);
+      ms.log("  status: " + client.status);
+      ms.log("  response: " + client.responseText);
+
+      if (client.readyState == 4) {
+        var msg = "";
+        if (client.status == 200) {
+          var response = JSON.parse(client.responseText);
+          if (response['available']) {
+            // display protoversion and server to user:
+            msg = monkeysphere.messages.formatStringFromName( "agentAvailable"
+                                                              , [ response['server'] ,
+                                                                  response['protoversion'] ]
+                                                              , 2 );
+          } else {
+            // tell user that the server is responding but currently uavailable
+            msg = monkeysphere.GetStringFromName("agentResponsiveButUnavailable");
+          }
+        } else {
+          // tell the user that the server is not responding
+          ms.log("validation agent did not respond.");
+          msg = monkeysphere.GetStringFromName("noResponseFromAgent");
+        }
+        alert(msg);
+      }
+    },
+
     ////////////////////////////////////////////////////////
     // CONTEXT MENU FUNCTIONS
     ////////////////////////////////////////////////////////
@@ -391,6 +446,11 @@ var monkeysphere = (function() {
          , 4 ));
       },
 
+      getAgentInfo: function() {
+        ms.log("context menu function: get agent info");
+        getAgentInfo();
+      },
+
       certs: function() {
         openDialog("chrome://pippki/content/certManager.xul", "Certificate Manager");
       },
diff --git a/chrome/content/monkeysphere.xul b/chrome/content/monkeysphere.xul
index 62d2567..6a475a7 100644
--- a/chrome/content/monkeysphere.xul
+++ b/chrome/content/monkeysphere.xul
@@ -51,6 +51,9 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.
         <menuitem id="monkeysphere-status-showCache"
                   label="&statusbar.popup.menuitem.label.showCache;"
 		  oncommand="monkeysphere.contextMenuFunctions.showCache()" />
+	<menuitem id="monkeysphere-status-agentinfo"
+                  label="&statusbar.popup.menuitem.label.getAgentInfo;"
+		  oncommand="monkeysphere.contextMenuFunctions.getAgentInfo()" />
 	<menuitem id="monkeysphere-status-help"
                   label="&statusbar.popup.menuitem.label.help;"
 		  oncommand="monkeysphere.contextMenuFunctions.help()" />
diff --git a/chrome/locale/en-US/messages b/chrome/locale/en-US/messages
index 40de572..09b31b1 100644
--- a/chrome/locale/en-US/messages
+++ b/chrome/locale/en-US/messages
@@ -12,5 +12,7 @@ statusNOLONGERCACHED=%S [NO LONGER CACHED]
 xulError=Monkeysphere error: could not determine status message.
 noResponseFromAgent=Monkeysphere Validation Agent did not respond.
 msErrorOverrideCertNotCleared=Monkeysphere error: override cert not cleared!
+agentResponsiveButUnavailable=The Monkeysphere Validation Agent is present, but currently unavailable.
+agentAvailable=Monkeysphere Validation Agent: %S\nSupported Protocol Version: %S\n
 
-showCache=Monkeysphere cache information:\n\ncontext: %S\n peer: %S\n pkc type: %S\n agent response: %S\n
+showCache=Monkeysphere cache information:\n\ncontext: %S\npeer: %S\npkc type: %S\nagent response: %S\n
diff --git a/chrome/locale/en-US/messages.dtd b/chrome/locale/en-US/messages.dtd
index 6b479f9..0202e1c 100644
--- a/chrome/locale/en-US/messages.dtd
+++ b/chrome/locale/en-US/messages.dtd
@@ -4,3 +4,5 @@
 	"Help">
 <!ENTITY statusbar.popup.menuitem.label.showCache
 	"Show exception information">
+<!ENTITY statusbar.popup.menuitem.label.getAgentInfo
+	"Validation Agent info…">
diff --git a/chrome/locale/fr-FR/messages b/chrome/locale/fr-FR/messages
index f8fddcf..0c80e33 100644
--- a/chrome/locale/fr-FR/messages
+++ b/chrome/locale/fr-FR/messages
@@ -12,5 +12,7 @@ statusNOLONGERCACHED=%S [N’EST PLUS EN CACHE]
 xulError=Monkeysphere erreur : ne peut pas déterminer le message de statut.
 noResponseFromAgent=l’agent de validation Monkeysphere n’a pas répondu.
 msErrorOverrideCertNotCleared=Erreur Monkeysphere : le certificat écrasé n’a pas été effacé !
+agentResponsiveButUnavailable=L'agent de validation est présent, mais il ne function pas maintenant.
+agentAvailable=L'Agent de Validation: %S\nSupported Protocol Version: %S\n
 
 showCache=Informations du cache Monkeysphere :\n\ncontexte : %S\npair : %S\ntype de pkc : %S\nréponse de l’agent : %S
diff --git a/chrome/locale/fr-FR/messages.dtd b/chrome/locale/fr-FR/messages.dtd
index 6d3ca9f..a19ae29 100644
--- a/chrome/locale/fr-FR/messages.dtd
+++ b/chrome/locale/fr-FR/messages.dtd
@@ -4,3 +4,5 @@
 	"Aide">
 <!ENTITY statusbar.popup.menuitem.label.showCache
 	"Afficher les informations de l’exception">
+<!ENTITY statusbar.popup.menuitem.label.getAgentInfo
+	"Info de l'agent de validation…">

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-privacy/packages/xul-ext-monkeysphere.git



More information about the Pkg-privacy-commits mailing list