Permalink
Browse files

Fix some issues with review comments for pull request #134

  • Loading branch information...
anantn committed Nov 22, 2011
1 parent b53a1cc commit 49073f91449e88d79aa1bb400582d92d9b86d254
View
@@ -4,3 +4,5 @@ site/tools/yuicompressor-2.4.2.jar
site/tools/yuicompressor-2.4.2.zip
site/tools/build-compressor
deps/
+addons/jetpack/mac/foxlauncher.o
+openwebapps.xpi
View
@@ -2,6 +2,12 @@ APPNAME = fx-share-addon
DEPS = github:addon-sdk,github:oauthorizer
PYTHON = python
+MAKELAUNCHER =
+SYS := $(shell uname -s)
+ifeq ($(SYS), Darwin)
+ MAKELAUNCHER := ${MAKE} -C addons/jetpack/mac/
+endif
+
ifeq ($(TOPSRCDIR),)
export TOPSRCDIR = $(shell pwd)
endif
@@ -43,8 +49,8 @@ endif
all: xpi
-xpi: pull
- ${MAKE} -C addons/jetpack/mac/
+xpi: pull
+ $(MAKELAUNCHER)
$(addon_sdk)/cfx xpi $(cfx_args)
pull:
@@ -54,7 +60,7 @@ test:
$(addon_sdk)/cfx test $(cfx_args) $(test_args)
run:
- ${MAKE} -C addons/jetpack/mac/
+ $(MAKELAUNCHER)
$(addon_sdk)/cfx run $(cfx_args)
.PHONY: xpi clean pull test run
@@ -312,32 +312,4 @@ function checkNativeIdentityDaemon(callingLocation, options, success, failure)
attemptConnection();
}
-/*
-window.appinjector.register({
- apibase: "navigator.id",
- name: "getVerifiedEmail",
- script: null,
- getapi: function(contentWindowRef) {
- return function(callback, options) { // XXX what is the options API going to be?
- checkNativeIdentityDaemon(contentWindowRef.location, options, function(assertion) {
- // success: return to caller
- var assert = JSON.parse(assertion);
- if (assert.status == "ok" && assert.assertion) {
- callback(assert.assertion);
- } else {
- // failure
- callback(null);
- }
- }, function() {
- // failure: need to present BrowserID dialog
- if (!options || !options.silent) {
- dump("OpenBrowserIDDialog\n");
- openBrowserIDDialog(callback, options);
- } else {
- callback(null);
- }
- });
- }
- }
-});
-*/
+/* TODO: Add navigator.id.getVerifiedEmail */
@@ -39,12 +39,6 @@
const { Cc, Ci, Cu, Cr, components } = require("chrome");
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
-var { TypedStorage } = require("typed_storage");
-
-//don't remove this please!
-var { NativeShell } = require("./nativeshell");
-
-
if (!console || !console.log) {
var console = {
log: function(s) {
@@ -56,6 +50,7 @@ if (!console || !console.log) {
var { Manifest } = require("./manifest");
var { URLParse } = require("./urlmatch");
var { NativeShell } = require("./nativeshell");
+var { TypedStorage } = require("typed_storage");
// We want to use as much from the cross-platform repo implementation
// as possible, but we do need to override a few methods.
@@ -477,6 +477,10 @@ function startup(getUrlCB) { /* Initialize simple storage */
// We don't have an assertion from BrowserID, so let's ask the user to login
setupLogin(service);
+ // Setup socket server
+ // TODO: Add stopServer method to unloaders
+ require("socketserver").startServer();
+
// Broadcast that we're done, in case anybody is listening
Services.obs.notifyObservers(tmp.FFRepoImplService, "openwebapps-startup-complete", "");
@@ -493,8 +497,5 @@ function shutdown(why) {
// Let's go!
startup(addon.data.url);
-const socketserver = require("socketserver");
-socketserver.startServer();
-
// Hook up unloaders
unload.when(shutdown);
@@ -242,6 +242,7 @@ function copyFile(srcFile, destFile, fileProperties, substitutions) {
}
}
+/* TODO: Convert all file operations to be async */
function writeFile(fileContents, destFile, fileProperties, substitutions) {
try {
var openProps = fileProperties?fileProperties["mode"]:"";
@@ -265,63 +266,6 @@ function writeFile(fileContents, destFile, fileProperties, substitutions) {
}
}
-//ASYNC file reading/writing/copying code. unable to evaluate the issues that might occur during a file
-// tree copy, so putting on hold for now.
-// function asyncReadFile(inFile, callback) {
-// //passes the string contents of the file to the callback for you to do with as you like.
-
-// NetUtil.asyncFetch(inFile, function(inputStream, status) {
-// if (!Components.isSuccessCode(status)) {
-// // should probably throw instead
-// console.log("ERROR: " + status + " failed to read file: " + inFile);
-// return;
-// }
-// var data = NetUtil.readInputStreamToString(inputStream, inputStream.available());
-// inputStream.close();
-// callback(data);
-// });
-// }
-
-// //make it into an inputstream and then send it to copy
-// function asyncWriteFile(strData, outFile) {
-// var outStream = FileUtils.openSafeFileOutputStream(outFile);
-// var converter = Components.classes["@mozilla.org/intl/scriptableunicodeconverter"].createInstance(Components.interfaces.nsIScriptableUnicodeConverter);
-// converter.charset = "UTF-8";
-// var inStream = converter.convertToInputStream(strData);
-
-// // The last argument (the callback) is optional.
-// NetUtil.asyncCopy(inStream, outStream, function(status) {
-// if (!Components.isSuccessCode(status)) {
-// // should probably throw instead
-// console.log("ERROR: " + status + " failed to write file: " + outFile.path);
-// return;
-// }
-// });
-// }
-
-// // NOTE: both inFile and outFile are nsIFile objects
-// // NOTE: this code should probably throw, and get caught up at the top, where we can cancel the creation of the native app
-// function asyncCopyFile(inFile, outFile, options) {
-
-// NetUtil.asyncFetch(inFile, function(inputStream, status) {
-// if (!Components.isSuccessCode(status)) {
-// // should probably throw instead
-// console.log("ERROR: " + status + " failed to read file: " + inFile.path);
-// return;
-// }
-
-// var outputStream = FileUtils.openSafeFileOutputStream(outFile);
-
-// NetUtil.asyncCopy(inputStream, outputStream, function(status) {
-// if (!Components.isSuccessCode(status)) {
-// // should probably throw instead
-// console.log("ERROR: " + status + " failed to write file: " + outFile.path);
-// return;
-// }
-// });
-// });
-// }
-
function recursiveFileCopy(srcDir,
leaf,
dstDir,
@@ -895,8 +839,6 @@ MacNativeShell.prototype = {
}
}
-
-
/* Jetpack specific export */
if (typeof exports !== "undefined")
exports.NativeShell = NativeShell;
@@ -1,3 +1,43 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is Open Web Apps for Firefox.
+ *
+ * The Initial Developer of the Original Code is The Mozilla Foundation.
+ * Portions created by the Initial Developer are Copyright (C) 2011
+ * the Initial Developer. All Rights Reserved.
+ *
+ * Contributor(s):
+ * Michael Hanson <mhanson@mozilla.com>
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 2 or later (the "GPL"), or
+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+ * in which case the provisions of the GPL or the LGPL are applicable instead
+ * of those above. If you wish to allow use of your version of this file only
+ * under the terms of either the GPL or the LGPL, and not to allow others to
+ * use your version of this file under the terms of the MPL, indicate your
+ * decision by deleting the provisions above and replace them with the notice
+ * and other provisions required by the GPL or the LGPL. If you do not delete
+ * the provisions above, a recipient may use your version of this file under
+ * the terms of any one of the MPL, the GPL or the LGPL.
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+/* The socket server is used to serve BrowserID assertions to whoever asks it
+ * Primarily used by generated XUL "native" apps to provide a 0-click login
+ * and receipt verification
+ */
const {Cc, Ci} = require("chrome");
var pageWorkers = require("page-worker");

0 comments on commit 49073f9

Please sign in to comment.