Made xmppClient, transportLayer, and authenticationLayer into proper modules using Components.Utils. Also renamed the JabberClient class to XMPPClient, which is more accurate (as it implements XMPP which is a newer protocol than Jabber.)
authorjonathandicarlo@jonathan-dicarlos-macbook-pro.local
Wed, 30 Apr 2008 16:55:34 -0700
changeset 44437 07dae2e49eac84b1b67598f4a15a966c537a1a84
parent 44436 7b022ef274adbc27c27362d9c4bfa40ee6ec909b
child 44438 3e8344c981544d60f7373a9bc4a31e6f3b2e260d
push id1
push userroot
push dateTue, 26 Apr 2011 22:38:44 +0000
treeherdermozilla-beta@bfdb6e623a36 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
Made xmppClient, transportLayer, and authenticationLayer into proper modules using Components.Utils. Also renamed the JabberClient class to XMPPClient, which is more accurate (as it implements XMPP which is a newer protocol than Jabber.)
services/sync/modules/xmpp/authenticationLayer.js
services/sync/modules/xmpp/transportLayer.js
services/sync/modules/xmpp/xmppClient.js
--- a/services/sync/modules/xmpp/authenticationLayer.js
+++ b/services/sync/modules/xmpp/authenticationLayer.js
@@ -1,8 +1,10 @@
+const EXPORTED_SYMBOLS = ['PlainAuthenticator', 'Md5DigestAuthenticator'];
+
 if(typeof(atob) == 'undefined') {
 // This code was written by Tyler Akins and has been placed in the
 // public domain.  It would be nice if you left this header intact.
 // Base64 code from Tyler Akins -- http://rumkin.com
 
 var keyStr = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
 
 function btoa(input) {
--- a/services/sync/modules/xmpp/transportLayer.js
+++ b/services/sync/modules/xmpp/transportLayer.js
@@ -1,8 +1,10 @@
+const EXPORTED_SYMBOLS = ['HTTPPollingTransport'];
+
 var Cc = Components.classes;
 var Ci = Components.interfaces;
 
 function InputStreamBuffer() {
 }
 InputStreamBuffer.prototype = {
  _data: "",
  append: function( stuff ) {
@@ -12,16 +14,20 @@ InputStreamBuffer.prototype = {
     this._data = "";
   },
  getData: function() {
     return this._data;
   }
 }
 
 function SocketClient( host, port ) {
+  /* A transport layer that uses raw sockets.
+     Not recommended for use; currently fails when trying to negotiate
+     TLS.
+     Use HTTPPollingTransport instead. */
   this._init( host, port );
 }
 SocketClient.prototype = {
   __threadManager: null,
   get _threadManager() {
     if (!this.__threadManager)
       this.__threadManager = Cc["@mozilla.org/thread-manager;1"].getService();
     return this.__threadManager;
@@ -123,20 +129,16 @@ SocketClient.prototype = {
     return output;
   },
 
   startTLS: function() {
     this._transport.securityInfo.QueryInterface(Ci.nsISSLSocketControl);
     this._transport.securityInfo.StartTLS();
   },
 
-  // TODO have a variant of waitForResponse that gets binary data
-  // binaryInStream = Cc["@mozilla.org/binaryinputstream;1].createInstance( Ci.nsIBinaryInputStream );
-  // binaryInStream.setInputStream( this._rawInputStream );
-
 };
 
 
 /* The interface that should be implemented by any Transport object: 
    send( messageXml );
    setCallbackObject( object with .onIncomingData and .onTransportError );
    connect();
    disconnect();
@@ -325,12 +327,8 @@ HTTPPollingTransport.prototype = {
     dump( this._key + "\n" );
     for ( var x = 1; x < 7; x++ ) {
       this._advanceKey();
       dump( this._key + "\n" );
     }
   },
 
 };
-
-
-//transport = new HTTPPollingTransport( "http://127.0.0.1:5280/http-poll" );
-//transport.testKeys();
--- a/services/sync/modules/xmpp/xmppClient.js
+++ b/services/sync/modules/xmpp/xmppClient.js
@@ -1,24 +1,28 @@
+const EXPORTED_SYMBOLS = ['XMPPClient', 'HTTPPollingTransport', 'PlainAuthenticator', 'Md5DigestAuthenticator'];
 
 // See www.xulplanet.com/tutorials/mozsdk/sockets.php
 // http://www.xmpp.org/specs/rfc3920.html
 // http://www.process-one.net/docs/ejabberd/guide_en.html
 // http://www.xulplanet.com/tutorials/mozsdk/xmlparse.php
 // http://developer.mozilla.org/en/docs/xpcshell
 // http://developer.mozilla.org/en/docs/Writing_xpcshell-based_unit_tests
 
 var Cc = Components.classes;
 var Ci = Components.interfaces;
-
+var Cu = Components.utils;
 
-function JabberClient( clientName, realm, clientPassword, transport, authenticator ) {
+Cu.import("resource://weave/xmpp/transportLayer.js");
+Cu.import("resource://weave/xmpp/authenticationLayer.js");
+
+function XmppClient( clientName, realm, clientPassword, transport, authenticator ) {
   this._init( clientName, realm, clientPassword, transport, authenticator );
 }
-JabberClient.prototype = {
+XmppClient.prototype = {
  //connection status codes:
  NOT_CONNECTED: 0,
  CALLED_SERVER: 1,
  AUTHENTICATING: 2,
  CONNECTED: 3,
  FAILED: -1,
 
  // IQ stanza status codes: