Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Plaintext is working with some kludges.

- Had to disable Traits wrapper; it was not doing what I hoped it would do.
- XPConnect did not like our send typed array buffer, it's not immediately clear why.
  • Loading branch information...
commit e000fbe8a67d02e11030a9b070c8546a30e76b45 1 parent e28281f
@asutherland asutherland authored
View
10 data/checkImap.html
@@ -84,11 +84,13 @@
function sendNextCommand() {
var curImapCommand = imapCommands[idxImapCommand],
- buffer = new ArrayBuffer(curImapCommand.send.length),
- u8View = new Uint8Array(buffer);
+ //buffer = new ArrayBuffer(curImapCommand.send.length),
+ //u8View = new Uint8Array(buffer);
+ u8View = [];
// We are only sending 7-bit ASCII, so this is fine.
for (var i = 0; i < u8View.length; i++) {
- u8View[i] = curImapCommand.send.charCodeAt(i);
+ //u8View[i] = curImapCommand.send.charCodeAt(i);
+ u8View.push(curImapCommand.send.charCodeAt(i));
}
socket.send(u8View);
}
@@ -103,7 +105,7 @@
}
var dataAsStr = dataAsChars.join("");
- logResults("data", dataAsStr);
+ logResult("data", dataAsStr);
if (idxImapCommand < imapCommands.length) {
buffered += dataAsStr;
View
52 lib/TCPSocket.js
@@ -63,11 +63,10 @@ TCPSocketEvent.prototype = {
};
-function createTransport(host, port, ssl) {
- let options = ssl ? ["ssl"] : [""];
+function createTransport(host, port, sslMode) {
return Cc["@mozilla.org/network/socket-transport-service;1"]
.getService(Ci.nsISocketTransportService)
- .createTransport(options, options.length, host, port, null);
+ .createTransport(sslMode, sslMode.length, host, port, null);
}
@@ -128,7 +127,6 @@ function TCPSocket(ownerInfo) {
*/
this.oncertoverride = null;
-console.log("saving off ownerInfo", ownerInfo);
this._ownerInfo = ownerInfo;
this.host = "";
@@ -152,43 +150,59 @@ TCPSocket.prototype = {
return null;
let event = new TCPSocketEvent(type, data || "");
+ /*B2G
this[type].handleEvent(event);
+ */
+ /*Jetpack*/
+ this[type](event);
+ /**/
return event;
},
// nsITCPSocket
- open: function ts_open(host, port, ssl) {
+ open: function ts_open(host, port, ssl, sslOptions) {
if (this.readyState !== 'closed') {
this.dispatchEvent("onerror", "Socket is already opened");
return;
}
+ switch (ssl) {
+ case 'ssl':
+ case 'starttls':
+ break;
+ default:
+ ssl = false;
+ }
+
this.readyState = 'authorizing';
let self = this;
PermissionChecker.checkTCPConnectionAllowed(
this._ownerInfo, host, port, Boolean(ssl),
function allowed() {
- self._open(host, port, ssl);
+ self._open(host, port, ssl, sslOptions);
});
},
- _open: function(host, port, ssl) {
+ _open: function(host, port, ssl, sslOptions) {
LOG("startup called\n");
LOG("Host info: " + host + ":" + port + "\n");
this.readyState = 'connecting';
this.host = host;
this.port = port;
- if (ssl) {
- this.ssl = true;
- if (typeof(ssl) === 'object')
- this._sslSettings = ssl;
- else
- this._sslSettings = {};
- }
-
- let transport = this._transport = createTransport(host, port, this.ssl);
+ this.ssl = ssl;
+ let sslMode;
+ if (ssl)
+ sslMode = [ssl];
+ else
+ sslMode = [];
+ if (ssl && sslOptions && typeof(sslOptions) === 'object')
+ this._sslSettings = sslOptions;
+ else
+ this._sslSettings = {};
+
+ let transport = this._transport = createTransport(host, port, sslMode);
transport.securityCallbacks = new SecurityCallbacks(this);
// - Output Stream
@@ -242,7 +256,7 @@ TCPSocket.prototype = {
},
send: function ts_send(data) {
- if (this.readyState !== OPEN) {
+ if (this.readyState !== 'open') {
this.dispatchEvent("onerror", "Socket is not opened");
return;
}
@@ -285,14 +299,14 @@ TCPSocket.prototype = {
// nsIStreamListener
onStartRequest: function ts_onStartRequest(request, context) {
- this.readyState = OPEN;
+ this.readyState = 'open';
this._request = request;
this.dispatchEvent("onopen");
},
onStopRequest: function ts_onStopRequest(request, context, status) {
- this.readyState = CLOSED;
+ this.readyState = 'closed';
this._request = null;
if (status) {
View
17 lib/main.js
@@ -56,11 +56,16 @@ let PAGES = [
let gTracker;
+// XXX er, traits doesn't do the membrane thing we want either.
+/*
let TCPSocket = $traits.Trait.compose(
{
constructor: $tcpsocket.TCPSocket,
},
$tcpsocket.TCPSocket.prototype);
+*/
+// XXX for now, just expose
+let TCPSocket = $tcpsocket.TCPSocket;
exports.main = function() {
@@ -95,9 +100,19 @@ exports.main = function() {
}
}
+ let useLocation;
+ if (domWindow.location.protocol === 'about:') {
+ useLocation = 'http://' + domWindow.location.href.substring(6) +
+ '.about.internal';
+ console.log("adjusted location to", useLocation);
+ }
+ //else if (domWindow.location.protocol === 'resource')
+ // useLocation = 'resource:
+ else
+ useLocation = domWindow.location;
let ownerInfo = {
// For aliased things like about: URLs, this will be the about: URL
- uri: Services.io.newURI(domWindow.location, null, null),
+ uri: Services.io.newURI(useLocation, null, null),
// Favor the host:port if available, but in the case of about: URLs,
// we net nothing, so fallback to the entire URL.
host: domWindow.location.host || domWindow.location.toString(),
View
47 lib/tcp_permissions.js
@@ -89,46 +89,6 @@ let PERMISSION_ANCHOR_ID = "webapi-tcp-notification-icon",
// positioning. We could probably fix-up the panel afterwards, but that's
// also ugly.
-/**
- * Dynamically create the anchor element (since we can't use an overlay) and
- * provide a function that will clean it up.
- */
-function makeAnchorElementAndCleanupLogic(document, elemId, iconUrl) {
-console.log("creating element...");
- let box = document.getElementById("notification-popup-box"),
- // we may already exist in this window...
- img = document.getElementById(elemId);
- if (img) {
- img.refCount++;
- }
- else {
- img = document.createElement("image");
- img.setAttribute("id", elemId);
- img.setAttribute("class", "notification-anchor-icon");
- img.setAttribute("role", "button");
- // We have to force the icon to visible because of a CSS snafu. All the
- //
- img.setAttribute(
- "style", "list-style-image: url(" + iconUrl + "); display: -moz-box;");
- img.style.display = "-moz-box;";
- img.refCount = 1;
- box.appendChild(img);
- }
-
- // super-frown... we need to create a CSS rule for the dude.
-
- return function cleanupFunc() {
- if (!img)
- return;
- if (--img.refCount) {
- img = null;
- return;
- }
- img.parentNode.removeChild(img);
- imgStyle.parentNode.removeChild(imgStyle);
- };
-}
-
function showPopup(contentWin,
anchorId, anchorIconUrl, popupIconUrl,
message, primaryAction, secondaryActions) {
@@ -142,12 +102,8 @@ function showPopup(contentWin,
contentWin.document),
PopupNotifications = browserWin.PopupNotifications;
- let anchorCleanup = makeAnchorElementAndCleanupLogic(
- browserWin.document, anchorId, anchorIconUrl);
-
let unloadHelper = {
unload: function() {
- anchorCleanup();
if (notification) {
PopupNotifications.remove(notification);
notification = null;
@@ -156,7 +112,7 @@ function showPopup(contentWin,
};
let notification = PopupNotifications.show(
- browserNode, anchorId, message, anchorId,
+ browserNode, anchorId, message, "notification-popup-box",
primaryAction, secondaryActions,
{
popupIconURL: popupIconUrl,
@@ -215,6 +171,7 @@ console.log("checkTCPConnectionAllowed", ownerInfo, host, port, useSSL);
label: gStringBundle.getString("webapi.permission.allow"),
accessKey: gStringBundle.getString("webapi.permission.allowAccessKey"),
callback: function allowCallback() {
+console.log("Adding permission:",ownerInfo.uri.spec, "host:",ownerInfo.uri.host, permType, nsIPermissionManager.ALLOW_ACTION);
Services.perms.add(ownerInfo.uri, permType,
nsIPermissionManager.ALLOW_ACTION);
allowedCallback();
View
2  xpi-template/chrome.manifest
@@ -1,3 +1 @@
content jetpack-tcp-imap-demo chrome/content/
-overlay chrome://browser/content/browser.xul chrome://jetpack-tcp-imap-demo/content/browser-overlay.xul
-style chrome://browser/content/browser.xul chrome://jetpack-tcp-imap-demo/content/browser-overlay.css
View
7 xpi-template/chrome/content/browser-overlay.css
@@ -1,7 +0,0 @@
-#webapi-tcp-notification-icon {
- list-style-image: url(chrome://global/skin/icons/question-16.png);
-}
-.popup-notification-icon[popupid="webapi-tcp-permission-prompt"],
-.popup-notification-icon[popupid="webapi-tcp-exception-prompt"] {
- list-style-image: url(chrome://global/skin/icons/question-64.png);
-}
View
7 xpi-template/chrome/content/browser-overlay.xul
@@ -1,7 +0,0 @@
-<?xml version="1.0"?>
-<overlay id="sample"
- xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
- <box id="notification-popup-box">
- <image id="webapi-tcp-notification-icon" class="notification-anchor-icon" role="button"/>
- </box>
-</overlay>
Please sign in to comment.
Something went wrong with that request. Please try again.