--- a/mail/components/cloudfile/cloudFileComponents.manifest
+++ b/mail/components/cloudfile/cloudFileComponents.manifest
@@ -1,12 +1,8 @@
component {dd2bce44-ca71-42ce-b806-6fa4e073919c} nsHightail.js
contract @mozilla.org/mail/hightail;1 {dd2bce44-ca71-42ce-b806-6fa4e073919c}
# Hightail used to be named YouSendIt, which is the constant used in the prefs.
category cloud-files YouSendIt @mozilla.org/mail/hightail;1
-component {9a44742b-a7b1-4f44-919e-6f3b28902c1a} nsUbuntuOne.js
-contract @mozilla.org/mail/ubuntuone;1 {9a44742b-a7b1-4f44-919e-6f3b28902c1a}
-category cloud-files UbuntuOne @mozilla.org/mail/ubuntuone;1
-
component {c06a8707-7463-416c-8b39-e85044a4ff6e} nsBox.js
contract @mozilla.org/mail/box;1 {c06a8707-7463-416c-8b39-e85044a4ff6e}
category cloud-files Box @mozilla.org/mail/box;1
deleted file mode 100644
--- a/mail/components/cloudfile/content/UbuntuOne/management.js
+++ /dev/null
@@ -1,44 +0,0 @@
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-function onLoadProvider(provider) {
- let messenger = Components.classes["@mozilla.org/messenger;1"]
- .createInstance(Components.interfaces.nsIMessenger);
-
- let fileSpaceUsed = document.getElementById("file-space-used");
- fileSpaceUsed.textContent = messenger.formatFileSize(provider.fileSpaceUsed);
- let fileSpaceUsedSwatch = document.getElementById("file-space-used-swatch");
- fileSpaceUsedSwatch.style.backgroundColor = pv.Colors.category20.values[0];
-
- let remainingFileSpace = document.getElementById("remaining-file-space");
- remainingFileSpace.textContent = messenger.formatFileSize(
- provider.remainingFileSpace);
- let remainingFileSpaceSwatch = document.getElementById("remaining-file-space-swatch");
- remainingFileSpaceSwatch.style.backgroundColor = pv.Colors.category20.values[1];
-
- let totalSpace = provider.fileSpaceUsed + provider.remainingFileSpace;
- let pieScale = 2 * Math.PI / totalSpace;
-
- let spaceDiv = document.getElementById("provider-space-visuals");
- let vis = new pv.Panel().canvas(spaceDiv)
- .width(150)
- .height(150);
- vis.add(pv.Wedge)
- .data([provider.fileSpaceUsed, provider.remainingFileSpace])
- .left(75)
- .top(75)
- .innerRadius(30)
- .outerRadius(65)
- .angle(function(d) d * pieScale);
-
- vis.add(pv.Label)
- .left(75)
- .top(75)
- .font("14px Sans-Serif")
- .textAlign("center")
- .textBaseline("middle")
- .text(messenger.formatFileSize(totalSpace));
-
- vis.render();
-}
deleted file mode 100644
--- a/mail/components/cloudfile/content/UbuntuOne/management.xhtml
+++ /dev/null
@@ -1,51 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!-- This Source Code Form is subject to the terms of the Mozilla Public
- - License, v. 2.0. If a copy of the MPL was not distributed with this file,
- - You can obtain one at http://mozilla.org/MPL/2.0/. -->
-
-<!DOCTYPE html [
- <!ENTITY % htmlDTD PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "DTD/xhtml1-strict.dtd"> %htmlDTD;
- <!ENTITY % managementDTD SYSTEM "chrome://messenger/locale/cloudfile/management.dtd"> %managementDTD;
- <!ENTITY % u1DTD SYSTEM "chrome://messenger/locale/cloudfile/UbuntuOne/management.dtd"> %u1DTD;
-]>
-<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
- <head>
- <script type="application/javascript;version=1.8"
- src="chrome://messenger/content/protovis-r2.6-modded.js"/>
- <script type="text/javascript;version=1.8"
- src="chrome://messenger/content/cloudfile/UbuntuOne/management.js"/>
- <link rel="stylesheet"
- type="text/css"
- href="chrome://messenger/skin/preferences/preferences.css" />
- </head>
- <body id="provider-management">
- <div id="provider-header">
- <div id="provider-terms">
- <a href="https://one.ubuntu.com/referrals/referee/2149434/?next=/privacy/">&cloudfileMgmt.privacyPolicy;</a>
- <a href="https://one.ubuntu.com/referrals/referee/2149434/?next=/terms/">&cloudfileMgmt.termsOfService;</a>
- </div>
- <div id="provider-name">
- <h1>Ubuntu One</h1>
- </div>
- </div>
-
- <div id="provider-spacebox">
- <div id="provider-space-visuals"></div>
- <div id="provider-space">
- <div>
- <label>&cloudfileMgmt.usedSpace;</label>
- <span id="file-space-used"/>
- <span id="file-space-used-swatch" class="space-swatch"/>
- </div>
- <div>
- <label>&cloudfileMgmt.unusedSpace;</label>
- <span id="remaining-file-space"/>
- <span id="remaining-file-space-swatch" class="space-swatch"/>
- </div>
- <div id="upgrade"><a href="https://one.ubuntu.com/referrals/referee/2149434/?next=/services/add-storage/">&cloudfileMgmt.upgradeOffer;</a></div>
- </div>
- </div>
- <div id="provider-account-settings"><a href="https://one.ubuntu.com/referrals/referee/2149434/?next=/account/">&ubuntuOneMgmt.viewSettings;</a></div>
- </body>
-
-</html>
deleted file mode 100644
--- a/mail/components/cloudfile/content/UbuntuOne/settings.js
+++ /dev/null
@@ -1,10 +0,0 @@
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this file,
- * You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-function extraArgs() {
- var emailaddressValue = document.getElementById("emailaddress").value;
- return {
- "emailaddress": {type: "char", value: emailaddressValue},
- };
-}
deleted file mode 100644
--- a/mail/components/cloudfile/content/UbuntuOne/settings.xhtml
+++ /dev/null
@@ -1,30 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!-- This Source Code Form is subject to the terms of the Mozilla Public
- - License, v. 2.0. If a copy of the MPL was not distributed with this file,
- - You can obtain one at http://mozilla.org/MPL/2.0/. -->
-
-<!DOCTYPE html [
- <!ENTITY % htmlDTD PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "DTD/xhtml1-strict.dtd"> %htmlDTD;
- <!ENTITY % u1DTD SYSTEM "chrome://messenger/locale/cloudfile/UbuntuOne/settings.dtd"> %u1DTD;
-]>
-<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
- <head>
- <script type="application/javascript"
- src="chrome://messenger/content/cloudfile/UbuntuOne/settings.js"/>
- <link rel="stylesheet"
- type="text/css"
- href="chrome://messenger/skin/cloudfile/addAccountDialog.css" />
- </head>
- <body id="provider-settings">
- <form id="provider-form" onsubmit="return false;">
- <label for="username">&UbuntuOneSettings.emailAddress;</label>
- <input id="emailaddress" type="text" required="true"/>
- <div id="learn-more" class="float-right">
- <a href="https://one.ubuntu.com/referrals/referee/2149434/?next=/">&UbuntuOneSettings.learnMore;</a>
- </div>
- <div>
- <a href="https://one.ubuntu.com/referrals/referee/2149434/?next=/services/">&UbuntuOneSettings.needAnAccount;</a>
- </div>
- </form>
- </body>
-</html>
--- a/mail/components/cloudfile/jar.mn
+++ b/mail/components/cloudfile/jar.mn
@@ -7,20 +7,16 @@ messenger.jar:
content/messenger/cloudfile/addAccountDialog.js (content/addAccountDialog.js)
content/messenger/cloudfile/attachment-24.png (content/attachment-24.png)
content/messenger/cloudfile/emptySettings.xhtml (content/emptySettings.xhtml)
content/messenger/cloudfile/Box/settings.xhtml (content/Box/settings.xhtml)
content/messenger/cloudfile/Box/management.xhtml (content/Box/management.xhtml)
content/messenger/cloudfile/Box/management.js (content/Box/management.js)
content/messenger/cloudfile/Box/auth.xul (content/Box/auth.xul)
content/messenger/cloudfile/Box/auth.js (content/Box/auth.js)
- content/messenger/cloudfile/UbuntuOne/management.js (content/UbuntuOne/management.js)
- content/messenger/cloudfile/UbuntuOne/management.xhtml (content/UbuntuOne/management.xhtml)
- content/messenger/cloudfile/UbuntuOne/settings.js (content/UbuntuOne/settings.js)
- content/messenger/cloudfile/UbuntuOne/settings.xhtml (content/UbuntuOne/settings.xhtml)
content/messenger/cloudfile/Hightail/management.xhtml (content/Hightail/management.xhtml)
content/messenger/cloudfile/Hightail/management.js (content/Hightail/management.js)
content/messenger/cloudfile/Hightail/settings.js (content/Hightail/settings.js)
content/messenger/cloudfile/Hightail/settings.xhtml (content/Hightail/settings.xhtml)
content/messenger/cloudfile/Hightail/fileExceedsLimit.xul (content/Hightail/fileExceedsLimit.xul)
content/messenger/cloudfile/Hightail/fileExceedsLimit.js (content/Hightail/fileExceedsLimit.js)
content/messenger/cloudfile/Hightail/fileExceedsQuota.xul (content/Hightail/fileExceedsQuota.xul)
content/messenger/cloudfile/Hightail/fileExceedsQuota.js (content/Hightail/fileExceedsQuota.js)
--- a/mail/components/cloudfile/moz.build
+++ b/mail/components/cloudfile/moz.build
@@ -8,16 +8,15 @@ XPIDL_SOURCES += [
]
XPIDL_MODULE = 'cloudfile'
EXTRA_COMPONENTS += [
'cloudFileComponents.manifest',
'nsBox.js',
'nsHightail.js',
- 'nsUbuntuOne.js',
]
EXTRA_JS_MODULES += [
'cloudFileAccounts.js',
]
JAR_MANIFESTS += ['jar.mn']
deleted file mode 100644
--- a/mail/components/cloudfile/nsUbuntuOne.js
+++ /dev/null
@@ -1,762 +0,0 @@
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this file,
- * You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-/* This file implements the nsIMsgCloudFileProvider interface.
- *
- * This component handles the UbuntuOne implementation of the
- * nsIMsgCloudFileProvider interface.
- */
-
-const Cc = Components.classes;
-const Ci = Components.interfaces;
-const Cu = Components.utils;
-const Cr = Components.results;
-
-Cu.import("resource://gre/modules/XPCOMUtils.jsm");
-Cu.import("resource://gre/modules/Http.jsm");
-Cu.import("resource:///modules/oauth.jsm");
-Cu.import("resource://gre/modules/Services.jsm");
-Cu.import("resource:///modules/gloda/log4moz.js");
-Cu.import("resource:///modules/cloudFileAccounts.js");
-
-const kBadAccessToken = 401;
-const kAuthSecretRealm = "Ubuntu One Auth Secret";
-const kConsumerKeyRealm = "Ubuntu One Consumer Key";
-const kConsumerSecretRealm = "Ubuntu One Consumer Secret";
-const kAttachmentsVolume = "/~/Thunderbird Attachments";
-const kVolumesPath = "/volumes";
-
-var gServerUrl = "https://one.ubuntu.com/api/file_storage/v1";
-var gContentUrl = "https://files.one.ubuntu.com/content";
-var gSsoUrl = "https://login.ubuntu.com/api/1.0/authentications";
-var gSsoPingUrl = "https://one.ubuntu.com/oauth/sso-finished-so-get-tokens/";
-
-
-function encodePathForURI(aStr) {
- return encodeURIComponent(aStr).replace(/%2F/g, '/');
-}
-
-
-function nsUbuntuOne() {
- this.log = Log4Moz.getConfiguredLogger("UbuntuOne");
-}
-
-nsUbuntuOne.prototype = {
- /* nsISupports */
- QueryInterface: XPCOMUtils.generateQI([Ci.nsIMsgCloudFileProvider]),
-
- classID: Components.ID("{9a44742b-a7b1-4f44-919e-6f3b28902c1a}"),
-
- get type() "UbuntuOne",
- get displayName() "Ubuntu One",
- get serviceURL() "https://one.ubuntu.com/referrals/referee/2149434/?next=/",
- get iconClass() "chrome://messenger/skin/icons/ubuntuone.png",
- get accountKey() this._accountKey,
- get lastError() this._lastErrorText,
- get settingsURL() "chrome://messenger/content/cloudfile/UbuntuOne/settings.xhtml",
- get managementURL() "chrome://messenger/content/cloudfile/UbuntuOne/management.xhtml",
-
- _accountKey: false,
- _prefBranch: null,
- _emailAddress: "",
- _loggedIn: false,
- _userInfo: null,
- _connection: null,
- _uploadingFile : null,
- _uploader : null,
- _availableStorage : -1,
- _fileSpaceUsed : -1,
- _uploads: [],
- _urlsForFiles : {},
- _uploadInfo : {}, // upload info keyed on aFiles.
-
- /**
- * Initialize this instance of nsUbuntuOne, setting the accountKey.
- *
- * @param aAccountKey the account key to initialize this provider with
- */
- init: function nsUbuntuOne_init(aAccountKey) {
- this._accountKey = aAccountKey;
- this._prefBranch = Services.prefs.getBranch("mail.cloud_files.accounts." +
- aAccountKey + ".");
- this._emailAddress = this._prefBranch.getCharPref("emailaddress")
- },
-
- /**
- * The callback passed to an nsUbuntuOneFileUploader, which is fired when
- * nsUbuntuOneFileUploader exits.
- *
- * @param aRequestObserver the request observer originally passed to
- * uploadFile for the file associated with the
- * nsUbuntuOneFileUploader
- * @param aStatus the result of the upload
- */
- _uploaderCallback : function nsUbuntuOne__uploaderCallback(aRequestObserver,
- aStatus) {
- aRequestObserver.onStopRequest(null, null, aStatus);
- this._uploadingFile = null;
- this._uploads.shift();
- if (this._uploads.length > 0) {
- let nextUpload = this._uploads[0];
- this.log.info("chaining upload, file = " + nextUpload.file.leafName);
- this._uploadingFile = nextUpload.file;
- this._uploader = nextUpload;
- try {
- this.uploadFile(nextUpload.file, nextUpload.callback);
- }
- catch (ex) {
- // I'd like to pass ex.result, but that doesn't seem to be defined.
- nextUpload.callback(nextUpload.requestObserver, Cr.NS_ERROR_FAILURE);
- }
- }
- else
- this._uploader = null;
- },
-
- /**
- * Attempts to upload a file to UbuntuOne.
- *
- * @param aFile the nsILocalFile to be uploaded
- * @param aCallback an nsIRequestObserver for listening for the starting
- * and ending states of the upload.
- */
- uploadFile: function nsUbuntuOne_uploadFile(aFile, aCallback) {
- if (Services.io.offline)
- throw Ci.nsIMsgCloudFileProvider.offlineErr;
-
- this.log.info("uploading " + aFile.leafName);
-
- // Some ugliness here - we stash requestObserver here, because we might
- // use it again in _getUserInfo.
- this.requestObserver = aCallback;
-
- // if we're uploading a file, queue this request.
- if (this._uploadingFile && !this._uploadingFile.equals(aFile)) {
- let uploader = new nsUbuntuOneFileUploader(this, aFile,
- this._uploaderCallback
- .bind(this),
- aCallback);
- this._uploads.push(uploader);
- return;
- }
- this._uploadingFile = aFile;
-
- let successCallback = this._finishUpload.bind(this, aFile, aCallback);
- if (!this._loggedIn)
- return this._logonAndGetUserInfo(successCallback, null, true);
- this.log.info("getting user info");
- if (!this._userInfo)
- return this._getUserInfo(successCallback);
- successCallback();
- },
-
- /**
- * A private function used to ensure that we can actually upload the file
- * (we haven't exceeded file size or quota limitations), and then attempts
- * to kick-off the upload.
- *
- * @param aFile the nsILocalFile to upload
- * @param aCallback an nsIRequestObserver for monitoring the starting and
- * ending states of the upload.
- */
- _finishUpload: function nsUbuntuOne__finishUpload(aFile, aCallback) {
- let exceedsFileLimit = Ci.nsIMsgCloudFileProvider.uploadExceedsFileLimit;
- let exceedsQuota = Ci.nsIMsgCloudFileProvider.uploadWouldExceedQuota;
- if (aFile.fileSize > this._availableStorage)
- return aCallback.onStopRequest(null, null, exceedsQuota);
-
- delete this._userInfo; // force us to update userInfo on every upload.
-
- if (!this._uploader) {
- this._uploader = new nsUbuntuOneFileUploader(this, aFile,
- this._uploaderCallback
- .bind(this),
- aCallback);
- this._uploads.unshift(this._uploader);
- }
-
- this._uploadingFile = aFile;
- this._uploader.uploadFile();
- },
-
- /**
- * Attempts to cancel a file upload.
- *
- * @param aFile the nsILocalFile to cancel the upload for.
- */
- cancelFileUpload: function nsUbuntuOne_cancelFileUpload(aFile) {
- this.log.info("Cancelling upload of file " + aFile.leafName);
- if (this._uploadingFile.equals(aFile)) {
- this._uploader.cancel();
- }
- else {
- for (let i = 0; i < this._uploads.length; i++)
- if (this._uploads[i].file.equals(aFile)) {
- // We bypass the cancel() method here so that
- // _uploaderCallback doesn't get called and chain to the
- // next upload.
- this._uploads[i].requestObserver.onStopRequest(
- null, null, Ci.nsIMsgCloudFileProvider.uploadCanceled);
- this._uploads.splice(i, 1);
- return;
- }
- }
- },
-
- /**
- * A private function used to retrieve the profile information for the
- * user account associated with the accountKey.
- *
- * @param successCallback the function called if information retrieval
- * is successful
- * @param failureCallback the function called if information retrieval fails
- */
- _getUserInfo: function nsUbuntuOne__getUserInfo(successCallback,
- failureCallback) {
- if (!successCallback)
- successCallback = function() {
- this.requestObserver
- .onStopRequest(null, null,
- this._loggedIn ? Cr.NS_OK : Ci.nsIMsgCloudFileProvider.authErr);
- }.bind(this);
-
- if (!failureCallback)
- failureCallback = function () {
- this.requestObserver
- .onStopRequest(null, null, Ci.nsIMsgCloudFileProvider.authErr);
- }.bind(this);
-
- let requestFailed = function(aException, aResponseText, aRequest) {
- // Treat bad token specially, and fallback to
- // going through the uploadFiles process
- // again, and getting new tokens.
- if (aRequest.status == kBadAccessToken) {
- this.log.info("got bad token");
- this._loggedIn = false;
- this._cachedAuthToken = "";
- this._cachedAuthSecret = "";
- successCallback();
- return;
- }
- this.log.error("user info failed, status = " + aRequest.status);
- this.log.error("response text = " + aResponseText);
- this.log.error("exception = " + aException);
- failureCallback();
- }.bind(this)
-
- this.log.info("Getting user info")
- this._connection.signAndSend(
- gServerUrl, [], "GET", "",
- function(aResponseText, aRequest) {
- this.log.info("user info = " + aResponseText);
- this._userInfo = JSON.parse(aResponseText);
- this._fileSpaceUsed = this._userInfo.used_bytes;
- this._availableStorage = this._userInfo.max_bytes - this._fileSpaceUsed;
- this.log.info("avail storage = " + this._availableStorage);
-
- // Ensure that the volume where we will store attachments exists.
- if (this._userInfo.user_node_paths.indexOf(kAttachmentsVolume) < 0) {
- this.log.info("Creating attachments volume");
- let volumeUrl = (gServerUrl + kVolumesPath +
- encodePathForURI(kAttachmentsVolume));
- this._connection.signAndSend(
- volumeUrl, [], "PUT", "",
- function(aResponseText, aRequest) {
- this.log.info("Created new volume " + kAttachmentsVolume);
- successCallback();
- }.bind(this),
- requestFailed, this);
- }
- else {
- successCallback();
- }
- }.bind(this),
- requestFailed, this);
- },
-
- /**
- * A private function that first ensures that the user is logged in, and then
- * retrieves the user's profile information.
- *
- * @param aSuccessCallback the function called on successful information
- * retrieval
- * @param aFailureCallback the function called on failed information retrieval
- * @param aWithUI a boolean for whether or not we should display authorization
- * UI if we don't have a valid token anymore, or just fail out.
- */
- _logonAndGetUserInfo: function nsUbuntuOne_logonAndGetUserInfo(aSuccessCallback,
- aFailureCallback,
- aWithUI) {
- if (!aFailureCallback)
- aFailureCallback = function () {
- this.requestObserver
- .onStopRequest(null, null, Ci.nsIMsgCloudFileProvider.authErr);
- }.bind(this);
-
- return this.logon(function() {
- this._getUserInfo(aSuccessCallback, aFailureCallback);
- }.bind(this), aFailureCallback, aWithUI);
- },
-
- /**
- * For some nsILocalFile, return the associated sharing URL.
- *
- * @param aFile the nsILocalFile to retrieve the URL for
- */
- urlForFile: function nsUbuntuOne_urlForFile(aFile) {
- return this._urlsForFiles[aFile.path];
- },
-
- /**
- * Updates the profile information for the account associated with the
- * account key.
- *
- * @param aWithUI a boolean for whether or not we should display authorization
- * UI if we don't have a valid token anymore, or just fail out.
- * @param aCallback an nsIRequestObserver for observing the starting and
- * ending states of the request.
- */
- refreshUserInfo: function nsUbuntuOne_refreshUserInfo(aWithUI, aCallback) {
- if (Services.io.offline)
- throw Ci.nsIMsgCloudFileProvider.offlineErr;
- this.requestObserver = aCallback;
- aCallback.onStartRequest(null, null);
- if (!this._loggedIn)
- return this._logonAndGetUserInfo(null, null, aWithUI);
- if (!this._userInfo)
- return this._getUserInfo();
- return this._userInfo;
- },
-
-
- /**
- * Our UbuntuOne implementation does not implement the createNewAccount
- * function defined in nsIMsgCloudFileProvider.idl.
- */
- createNewAccount: function nsUbuntuOne_createNewAccount(aEmailAddress,
- aPassword, aFirstName,
- aLastName) {
- return Cr.NS_ERROR_NOT_IMPLEMENTED;
- },
-
- /**
- * If the user already has an account, we can get the user to just login
- * to it via OAuth.
- *
- * This function does not appear to be called from the BigFiles UI, and
- * might be excisable.
- */
- createExistingAccount: function nsUbuntuOne_createExistingAccount(aRequestObserver) {
- // XXX: replace this with a better function
- let successCb = function(aResponseText, aRequest) {
- aRequestObserver.onStopRequest(null, this, Cr.NS_OK);
- }.bind(this);
-
- let failureCb = function(aResponseText, aRequest) {
- aRequestObserver.onStopRequest(null, this,
- Ci.nsIMsgCloudFileProvider.authErr);
- }.bind(this);
-
- this.logon(successCb, failureCb, true);
- },
-
- /**
- * If the provider doesn't have an API for creating an account, perhaps
- * there's a url we can load in a content tab that will allow the user
- * to create an account.
- */
- get createNewAccountUrl() "",
-
- /**
- * For a particular error, return a URL if UbuntuOne has a page for handling
- * that particular error.
- *
- * @param aError the error to get the URL for
- */
- providerUrlForError: function nsUbuntuOne_providerUrlForError(aError) {
- if (aError == Ci.nsIMsgCloudFileProvider.uploadWouldExceedQuota)
- return "https://one.ubuntu.com/referrals/referee/2149434/?next=/services/add-storage/";
- return "";
- },
-
- /**
- * If we don't know the limit, this will return -1.
- */
- get fileUploadSizeLimit() -1,
- get remainingFileSpace() this._availableStorage,
- get fileSpaceUsed() this._fileSpaceUsed,
-
- /**
- * Attempt to delete an upload file if we've uploaded it.
- *
- * @param aFile the file that was originall uploaded
- * @param aCallback an nsIRequestObserver for monitoring the starting and
- * ending states of the deletion request.
- */
- deleteFile: function nsUbuntuOne_deleteFile(aFile, aCallback) {
- if (Services.io.offline)
- throw Ci.nsIMsgCloudFileProvider.offlineErr;
-
- let uploadInfo = this._uploadInfo[aFile.path];
- if (!uploadInfo)
- throw Cr.NS_ERROR_FAILURE;
-
- this.requestObserver = aCallback;
- let url = gServerUrl + encodePathForURI(uploadInfo.resource_path);
- this.log.info("Sending delete request to " + url);
- this._connection.signAndSend(url, [], "DELETE", null,
- function(aResponseText, aRequest) {
- this.log.info("success deleting file; response = " + aResponseText);
- aCallback.onStopRequest(null, null, Cr.NS_OK);
- }.bind(this),
- function(aException, aResponseText, aRequest) {
- this.log.error("failed deleting file; response = " + aResponseText);
- aCallback.onStopRequest(null, null, Ci.nsIMsgCloudFileProvider.uploadErr);
- }.bind(this), this);
- },
-
- /**
- * This function is used by our testing framework to override the default
- * URL's that nsUbuntuOne connects to.
- */
- overrideUrls : function nsUbuntuOne_overrideUrls(aNumUrls, aUrls) {
- gServerUrl = aUrls[0];
- gContentUrl = aUrls[1];
- gSsoUrl = aUrls[2];
- gSsoPingUrl = aUrls[3];
- },
-
- _getPassword: function nsUbuntuOne__getPassword(aEmailAddress) {
- this.log.info("Getting password for user: " + aEmailAddress);
-
- // OK, let's prompt for it.
- let win = Services.wm.getMostRecentWindow(null);
- let authPrompter = Services.ww.getNewAuthPrompter(win);
- var password = { value: "" };
- let userPos = gSsoUrl.indexOf("//") + 2;
- let userNamePart = encodeURIComponent(this._emailAddress) + "@";
- let ssoUrl = (gSsoUrl.substr(0, userPos) + userNamePart +
- gSsoUrl.substring(userPos));
- let messengerBundle = Services.strings.createBundle(
- "chrome://messenger/locale/messenger.properties");
- let promptString = messengerBundle.formatStringFromName("passwordPrompt",
- [this._emailAddress,
- this.displayName],
- 2);
- if (authPrompter.promptPassword(this.displayName, promptString, ssoUrl,
- authPrompter.SAVE_PASSWORD_NEVER,
- password))
- return password.value;
-
- return "";
- },
-
- _acquireToken: function nsUbuntuOne__acquireToken(successCallback,
- failureCallback) {
- this.log.info("Acquiring a token");
- let password = this._getPassword(this._emailAddress);
-
- if (!password) {
- this.log.info("No password provided");
- failureCallback();
- }
-
- let userPos = gSsoUrl.indexOf("//") + 2;
- let credentials = "Basic " + btoa(this._emailAddress + ":" + password);
- let dnsService = Cc["@mozilla.org/network/dns-service;1"]
- .getService(Components.interfaces.nsIDNSService);
- let tokenName = "Ubuntu One @ " + dnsService.myHostName + " [thunderbird]";
- let newTokenUrl = gSsoUrl + "?ws.op=authenticate&token_name=" +
- encodeURIComponent(tokenName);
-
- this.log.info("Requesting Authentication token");
- httpRequest(newTokenUrl, {
- headers: [["Authorization", credentials]],
- onLoad: function(aResponseText, aRequest) {
- this.log.info("Retrieved a new token from SSO");
- let tokenInfo = JSON.parse(aResponseText);
-
- // We need to tell Ubuntu One to pull the token from the SSO
- // service now.
- this._connection = new OAuth(this.displayName, null, null,
- tokenInfo.token, tokenInfo.token_secret,
- tokenInfo.consumer_key,
- tokenInfo.consumer_secret,
- "PLAINTEXT");
- this._connection.signAndSend(
- gSsoPingUrl, [], "POST", "",
- function(aResponseText, aRequest) {
- this.log.info("Token transferred to Ubuntu One: " + aResponseText);
- // Now that the token has successfully been transferred,
- // save it locally.
- this._cachedAuthToken = tokenInfo.token;
- this._cachedAuthSecret = tokenInfo.token_secret;
- this._cachedConsumerKey = tokenInfo.consumer_key;
- this._cachedConsumerSecret = tokenInfo.consumer_secret;
- successCallback();
- }.bind(this),
- function(aException, aResponseText, aRequest) {
- this.log.info("Failed to transfer access token to Ubuntu One:" +
- aResponseText);
- failureCallback();
- }.bind(this), this);
- }.bind(this),
- onError: function(aException, aResponseText, aRequest) {
- this.log.info("Failed to acquire an access token:" + aResponseText);
- failureCallback();
- }.bind(this),
- method: "GET"
- });
- },
-
- /**
- * logon to the Ubuntu One account.
- *
- * @param successCallback - called if logon is successful
- * @param failureCallback - called back on error.
- * @param aWithUI if false, logon fails if it would have needed to put up UI.
- * This is used for things like displaying account settings,
- * where we don't want to pop up the oauth ui.
- */
- logon: function nsUbuntuOne_logon(successCallback, failureCallback, aWithUI) {
- let authToken = this._cachedAuthToken;
- let authSecret = this._cachedAuthSecret;
- let consumerKey = this._cachedConsumerKey;
- let consumerSecret = this._cachedConsumerSecret;
- if (!aWithUI && (!authToken.length || !authSecret.length ||
- !consumerKey.length || !consumerSecret.length)) {
- failureCallback();
- return;
- }
-
- let haveTokenCb = function() {
- // Should probably perform a verification step to ensure that
- // the token is still valid.
- this._loggedIn = true;
- successCallback();
- }.bind(this);
-
- if (authToken.length && authSecret.length &&
- consumerKey.length && consumerSecret.length) {
- this._connection = new OAuth(this.displayName, null, null,
- authToken, authSecret,
- consumerKey, consumerSecret,
- "PLAINTEXT");
- haveTokenCb();
- }
- else {
- if (!aWithUI) {
- failureCallback();
- return;
- }
- this._acquireToken(haveTokenCb, failureCallback);
- }
- },
-
- /**
- * Retrieves the cached auth token for this account.
- */
- get _cachedAuthToken() {
- let authToken = cloudFileAccounts.getSecretValue(this.accountKey,
- cloudFileAccounts.kTokenRealm);
- if (!authToken)
- return "";
-
- return authToken;
- },
-
- /**
- * Sets the cached auth token for this account.
- *
- * @param aAuthToken the auth token to cache.
- */
- set _cachedAuthToken(aAuthToken) {
- cloudFileAccounts.setSecretValue(this.accountKey,
- cloudFileAccounts.kTokenRealm,
- aAuthToken);
- },
-
- /**
- * Retrieves the cached auth secret for this account.
- */
- get _cachedAuthSecret() {
- let authSecret = cloudFileAccounts.getSecretValue(this.accountKey,
- kAuthSecretRealm);
-
- if (!authSecret)
- return "";
-
- return authSecret;
- },
-
- /**
- * Sets the cached auth secret for this account.
- *
- * @param aAuthSecret the auth secret to cache.
- */
- set _cachedAuthSecret(aAuthSecret) {
- cloudFileAccounts.setSecretValue(this.accountKey,
- kAuthSecretRealm,
- aAuthSecret);
- },
-
- /**
- * Retrieves the cached consumer key for this account.
- */
- get _cachedConsumerKey() {
- let consumerKey = cloudFileAccounts.getSecretValue(this.accountKey,
- kConsumerKeyRealm);
-
- if (!consumerKey)
- return "";
-
- return consumerKey;
- },
-
- /**
- * Sets the cached consumer key for this account.
- *
- * @param aConsumerKey the consumer key to cache.
- */
- set _cachedConsumerKey(aConsumerKey) {
- cloudFileAccounts.setSecretValue(this.accountKey,
- kConsumerKeyRealm,
- aConsumerKey);
- },
-
- /**
- * Retrieves the cached consumer secret for this account.
- */
- get _cachedConsumerSecret() {
- let consumerSecret = cloudFileAccounts.getSecretValue(this.accountKey,
- kConsumerSecretRealm);
-
- if (!consumerSecret)
- return "";
-
- return consumerSecret;
- },
-
- /**
- * Sets the cached consumer secret for this account.
- *
- * @param aConsumerSecret the auth secret to cache.
- */
- set _cachedConsumerSecret(aConsumerSecret) {
- cloudFileAccounts.setSecretValue(this.accountKey,
- kConsumerSecretRealm,
- aConsumerSecret);
- },
-
-};
-
-function nsUbuntuOneFileUploader(aUbuntuOne, aFile, aCallback,
- aRequestObserver) {
- this.ubuntuone = aUbuntuOne;
- this.log = this.ubuntuone.log;
- this.log.info("new nsUbuntuOneFileUploader file = " + aFile.leafName);
- this.file = aFile;
- this.callback = aCallback;
- this.requestObserver = aRequestObserver;
-}
-
-nsUbuntuOneFileUploader.prototype = {
- ubuntuone: null,
- file: null,
- callback: null,
- request: null,
-
- /**
- * Kicks off the upload request for the file associated with this Uploader.
- */
- uploadFile: function nsU1FU_uploadFile() {
- this.requestObserver.onStartRequest(null, null);
- // XXX: should check to see if there is another file by this name
- // in the folder. Perhaps put attachments in date oriented
- // directories?
- let path = kAttachmentsVolume + "/" + this.file.leafName;
- this.log.info("ready to upload file " + path);
- let url = gContentUrl + encodePathForURI(path);
- let mimeService = Cc["@mozilla.org/mime;1"].getService(Ci.nsIMIMEService);
- let contentType;
- try {
- contentType = mimeService.getTypeFromFile(this.file);
- }
- catch (ex) {
- contentType = "application/octet-stream";
- }
- let headers = [["Content-Type", contentType]];
- let fstream = Cc["@mozilla.org/network/file-input-stream;1"]
- .createInstance(Ci.nsIFileInputStream);
- fstream.init(this.file, -1, 0, 0);
- let bufStream = Cc["@mozilla.org/network/buffered-input-stream;1"].
- createInstance(Ci.nsIBufferedInputStream);
- bufStream.init(fstream, 4096);
- bufStream = bufStream.QueryInterface(Ci.nsIInputStream);
- this.request = this.ubuntuone._connection.signAndSend(
- url, headers, "PUT", bufStream,
- function(aResponseText, aRequest) {
- this.request = null;
- this.log.info("success putting file " + aResponseText);
- let nodeInfo = JSON.parse(aResponseText);
- this._getShareUrl(nodeInfo);
- }.bind(this),
- function(aException, aResponseText, aRequest) {
- this.request = null;
- this.log.info("failed putting file response = " + aException);
- if (this.callback)
- this.callback(this.requestObserver,
- Ci.nsIMsgCloudFileProvider.uploadErr);
- }.bind(this), this);
- },
-
- /**
- * Cancels the upload request for the file associated with this Uploader.
- */
- cancel: function nsU1FU_cancel() {
- this.log.info("Cancelling upload of " + this.file.leafName);
- this.callback(this.requestObserver, Ci.nsIMsgCloudFileProvider.uploadCanceled);
- this.callback = null;
- if (this.request) {
- let req = this.request;
- if (req.channel) {
- this.log.info("canceling channel upload");
- req.channel.cancel(Cr.NS_BINDING_ABORTED);
- }
- this.request = null;
- }
- },
-
- /**
- * Private function that attempts to retrieve the sharing URL for the file
- * uploaded with this Uploader.
- *
- * @param aNodeInfo the node info for the file on the server.
- */
- _getShareUrl: function nsU1FU__getShareUrl(aNodeInfo) {
- this.log.info("Making file " + aNodeInfo.resource_path + " public");
- let url = gServerUrl + encodePathForURI(aNodeInfo.resource_path);
- let headers = [["Content-Type", "application/json"]];
- let body = JSON.stringify({is_public: true});
- this.request = this.ubuntuone._connection.signAndSend(
- url, headers, "PUT", body,
- function(aResponseText, aRequest) {
- this.request = null;
- this.log.info("Successfully made node public with response text: "
- + aResponseText);
- let nodeInfo = JSON.parse(aResponseText);
- this.ubuntuone._uploadInfo[this.file.path] = nodeInfo;
- this.ubuntuone._urlsForFiles[this.file.path] = nodeInfo.public_url;
- this.callback(this.requestObserver, Cr.NS_OK);
- }.bind(this),
- function(aException, aResponseText, aRequest) {
- this.request = null;
- this.log.error("Getting share URL failed: " + aException);
- if (this.callback)
- this.callback(this.requestObserver, Cr.NS_ERROR_FAILURE);
- }.bind(this), this);
- },
-};
-
-const NSGetFactory = XPCOMUtils.generateNSGetFactory([nsUbuntuOne]);
--- a/mail/installer/package-manifest.in
+++ b/mail/installer/package-manifest.in
@@ -181,17 +181,16 @@
@BINPATH@/components/mailview.xpt
@BINPATH@/components/mailprofilemigration.xpt
@BINPATH@/components/messageWakeupService.js
@BINPATH@/components/messageWakeupService.manifest
@BINPATH@/components/nsActivity.js
@BINPATH@/components/nsActivityManager.js
@BINPATH@/components/nsActivityManagerUI.js
@BINPATH@/components/nsHightail.js
-@BINPATH@/components/nsUbuntuOne.js
@BINPATH@/components/nsBox.js
@BINPATH@/components/nsAddrbook.manifest
@BINPATH@/components/nsMailNewsCommandLineHandler.js
@BINPATH@/components/nsNewsAutoCompleteSearch.js
@BINPATH@/components/nsNewsAutoCompleteSearch.manifest
@BINPATH@/components/services-crypto-component.xpt
@BINPATH@/components/shellservice.xpt
@BINPATH@/components/xpcom_base.xpt
deleted file mode 100644
--- a/mail/locales/en-US/chrome/messenger/cloudfile/UbuntuOne/management.dtd
+++ /dev/null
@@ -1,4 +0,0 @@
-<!-- This Source Code Form is subject to the terms of the Mozilla Public
- - License, v. 2.0. If a copy of the MPL was not distributed with this file,
- - You can obtain one at http://mozilla.org/MPL/2.0/. -->
-<!ENTITY ubuntuOneMgmt.viewSettings "View my account settings on one.ubuntu.com">
deleted file mode 100644
--- a/mail/locales/en-US/chrome/messenger/cloudfile/UbuntuOne/settings.dtd
+++ /dev/null
@@ -1,6 +0,0 @@
-<!-- This Source Code Form is subject to the terms of the Mozilla Public
- - License, v. 2.0. If a copy of the MPL was not distributed with this file,
- - You can obtain one at http://mozilla.org/MPL/2.0/. -->
-<!ENTITY UbuntuOneSettings.emailAddress "Email Address:">
-<!ENTITY UbuntuOneSettings.needAnAccount "Need an account?">
-<!ENTITY UbuntuOneSettings.learnMore "Learn more…">
--- a/mail/locales/jar.mn
+++ b/mail/locales/jar.mn
@@ -125,18 +125,16 @@
locale/@AB_CD@/messenger/addressbook/abMailListDialog.dtd (%chrome/messenger/addressbook/abMailListDialog.dtd)
locale/@AB_CD@/messenger/addressbook/addressBook.properties (%chrome/messenger/addressbook/addressBook.properties)
locale/@AB_CD@/messenger/addressbook/ldapAutoCompErrs.properties (%chrome/messenger/addressbook/ldapAutoCompErrs.properties)
locale/@AB_CD@/messenger/addressbook/pref-directory.dtd (%chrome/messenger/addressbook/pref-directory.dtd)
locale/@AB_CD@/messenger/addressbook/pref-directory-add.dtd (%chrome/messenger/addressbook/pref-directory-add.dtd)
locale/@AB_CD@/messenger/addressbook/replicationProgress.properties (%chrome/messenger/addressbook/replicationProgress.properties)
locale/@AB_CD@/messenger/cloudfile/addAccountDialog.dtd (%chrome/messenger/cloudfile/addAccountDialog.dtd)
locale/@AB_CD@/messenger/cloudfile/management.dtd (%chrome/messenger/cloudfile/management.dtd)
- locale/@AB_CD@/messenger/cloudfile/UbuntuOne/management.dtd (%chrome/messenger/cloudfile/UbuntuOne/management.dtd)
- locale/@AB_CD@/messenger/cloudfile/UbuntuOne/settings.dtd (%chrome/messenger/cloudfile/UbuntuOne/settings.dtd)
locale/@AB_CD@/messenger/cloudfile/Hightail/management.dtd (%chrome/messenger/cloudfile/Hightail/management.dtd)
locale/@AB_CD@/messenger/cloudfile/Hightail/settings.dtd (%chrome/messenger/cloudfile/Hightail/settings.dtd)
locale/@AB_CD@/messenger/cloudfile/Hightail/fileExceedsLimit.dtd (%chrome/messenger/cloudfile/Hightail/fileExceedsLimit.dtd)
locale/@AB_CD@/messenger/cloudfile/Hightail/fileExceedsQuota.dtd (%chrome/messenger/cloudfile/Hightail/fileExceedsQuota.dtd)
locale/@AB_CD@/messenger/cloudfile/Hightail/fileExceeds2GB.dtd (%chrome/messenger/cloudfile/Hightail/fileExceeds2GB.dtd)
locale/@AB_CD@/messenger/cloudfile/Box/settings.dtd (%chrome/messenger/cloudfile/Box/settings.dtd)
locale/@AB_CD@/messenger/cloudfile/Box/management.dtd (%chrome/messenger/cloudfile/Box/management.dtd)
locale/@AB_CD@/messenger/cloudfile/Box/auth.dtd (%chrome/messenger/cloudfile/Box/auth.dtd)
deleted file mode 100644
--- a/mail/test/mozmill/cloudfile/test-cloudfile-backend-ubuntuone.js
+++ /dev/null
@@ -1,273 +0,0 @@
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this file,
- * You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-/**
- * Tests the Ubuntu One Bigfile backend.
- */
-
-let Cu = Components.utils;
-let Cc = Components.classes;
-let Ci = Components.interfaces;
-
-const MODULE_NAME = 'test-cloudfile-backend-ubuntuone';
-
-const RELATIVE_ROOT = '../shared-modules';
-const MODULE_REQUIRES = ['folder-display-helpers',
- 'compose-helpers',
- 'cloudfile-ubuntuone-helpers',
- 'observer-helpers',
- 'prompt-helpers',];
-
-const kAttachmentsVolume = '/~/Thunderbird Attachments';
-
-Cu.import('resource://gre/modules/Services.jsm');
-Cu.import('resource:///modules/cloudFileAccounts.js');
-
-var gServer, gObsManager;
-
-function setupModule(module) {
- let fdh = collector.getModule('folder-display-helpers');
- fdh.installInto(module);
-
- let ch = collector.getModule('compose-helpers');
- ch.installInto(module);
-
- let cfh = collector.getModule('cloudfile-helpers');
- cfh.installInto(module);
-
- let cbh = collector.getModule('cloudfile-backend-helpers');
- cbh.installInto(module);
-
- let cdh = collector.getModule('cloudfile-ubuntuone-helpers');
- cdh.installInto(module);
-
- let oh = collector.getModule('observer-helpers');
- oh.installInto(module);
-
- let ph = collector.getModule('prompt-helpers');
- ph.installInto(module);
-
- gObsManager = new cbh.SimpleRequestObserverManager();
-
- // Enable logging for this test.
- Services.prefs.setCharPref("UbuntuOne.logging.dump", "All");
- Services.prefs.setCharPref("TBOAuth.logging.dump", "All");
-};
-
-function teardownModule() {
- Services.prefs.QueryInterface(Ci.nsIPrefBranch)
- .deleteBranch("mail.cloud_files.accounts");
- Services.prefs.clearUserPref("UbuntuOne.logging.dump");
- Services.prefs.clearUserPref("TBOAuth.logging.dump");
-}
-
-function setupTest() {
- gServer = new MockUbuntuOneServer();
- gServer.init();
- gServer.start();
-}
-
-function teardownTest() {
- gObsManager.check();
- gObsManager.reset();
- gServer.stop(mc);
-}
-
-function test_simple_case() {
- const kExpectedUrl = "http://www.example.com/expectedUrl";
- const kTopics = [kUploadFile, kGetFileURL];
-
- gServer.setupUser();
- gServer.planForCreateVolume(kAttachmentsVolume);
- gServer.planForUploadFile(kAttachmentsVolume + "/testFile1");
- gServer.planForMetadataUpdate(kAttachmentsVolume + "/testFile1",
- kExpectedUrl);
-
- let obs = new ObservationRecorder();
- for each (let [, topic] in Iterator(kTopics)) {
- obs.planFor(topic);
- Services.obs.addObserver(obs, topic, false);
- }
-
- let requestObserver = gObsManager.create("test_simple_case - Upload 1");
- let file = getFile("./data/testFile1", __file__);
- let provider = gServer.getPreparedBackend("someAccountKey");
- provider.uploadFile(file, requestObserver);
-
- mc.waitFor(function () requestObserver.success);
-
- let urlForFile = provider.urlForFile(file);
- assert_equals(kExpectedUrl, urlForFile);
- assert_equals(1, obs.numSightings(kUploadFile));
- assert_equals(1, obs.numSightings(kGetFileURL));
-
- gServer.planForUploadFile(kAttachmentsVolume + "/testFile1");
- gServer.planForMetadataUpdate(kAttachmentsVolume + "/testFile1",
- kExpectedUrl);
- requestObserver = gObsManager.create("test_simple_case - Upload 2");
- provider.uploadFile(file, requestObserver);
- mc.waitFor(function () requestObserver.success);
- urlForFile = provider.urlForFile(file);
- assert_equals(kExpectedUrl, urlForFile);
-
- assert_equals(2, obs.numSightings(kUploadFile));
- assert_equals(2, obs.numSightings(kGetFileURL));
-
- for each (let [, topic] in Iterator(kTopics)) {
- Services.obs.removeObserver(obs, topic);
- }
-}
-
-function test_chained_uploads() {
- const kExpectedUrlRoot = "http://www.example.com/";
- const kTopics = [kUploadFile, kGetFileURL];
- const kFilenames = ["testFile1", "testFile2", "testFile3"];
-
- gServer.setupUser();
-
- gServer.planForCreateVolume(kAttachmentsVolume);
- for each (let [, filename] in Iterator(kFilenames)) {
- let path = kAttachmentsVolume + "/" + filename;
- let expectedUrl = kExpectedUrlRoot + filename;
- gServer.planForUploadFile(path);
- gServer.planForMetadataUpdate(path, expectedUrl);
- }
-
- let obs = new ObservationRecorder();
- for each (let [, topic] in Iterator(kTopics)) {
- obs.planFor(topic);
- Services.obs.addObserver(obs, topic, false);
- }
-
- let provider = gServer.getPreparedBackend("someAccountKey");
-
- let files = [];
-
- let observers = kFilenames.map(function(aFilename) {
- let requestObserver = gObsManager.create("test_chained_uploads for filename " + aFilename);
- let file = getFile("./data/" + aFilename, __file__);
- files.push(file);
- provider.uploadFile(file, requestObserver);
- return requestObserver;
- });
-
- mc.waitFor(function() {
- return observers.every(function(aListener) aListener.success);
- }, "Timed out waiting for chained uploads to complete.", 10000);
-
- assert_equals(kFilenames.length, obs.numSightings(kUploadFile));
-
- for (let [index, filename] in Iterator(kFilenames)) {
- let path = kAttachmentsVolume + "/" + filename;
- assert_equals(obs.data[kUploadFile][index], path);
- let file = getFile("./data/" + filename, __file__);
- let expectedUriForFile = kExpectedUrlRoot + filename;
- let uriForFile = provider.urlForFile(files[index]);
- assert_equals(expectedUriForFile, uriForFile);
- }
-
- assert_equals(kFilenames.length, obs.numSightings(kGetFileURL));
-
- for each (let [, topic] in Iterator(kTopics)) {
- Services.obs.removeObserver(obs, topic);
- }
-}
-
-function test_deleting_uploads() {
- const kFilename = "testFile1";
- let path = kAttachmentsVolume + "/" + kFilename;
-
- gServer.setupUser();
- let provider = gServer.getPreparedBackend("someAccountKey");
- // Upload a file
-
- gServer.planForCreateVolume(kAttachmentsVolume);
- gServer.planForUploadFile(path);
- gServer.planForMetadataUpdate(path, "http://www.example.com/someFile");
- let requestObserver = gObsManager.create("test_deleting_uploads - upload 1");
- let file = getFile("./data/" + kFilename, __file__);
- provider.uploadFile(file, requestObserver);
- mc.waitFor(function() requestObserver.success);
-
- // Try deleting a file
- let obs = new ObservationRecorder();
- obs.planFor(kDeleteFile);
- Services.obs.addObserver(obs, kDeleteFile, false);
-
- //gServer.planForDeleteFile(kFilename);
- let deleteObserver = gObsManager.create("test_deleting_uploads - delete 1");
- provider.deleteFile(file, deleteObserver);
- mc.waitFor(function() deleteObserver.success);
-
- // Check to make sure the file was deleted on the server
- assert_equals(1, obs.numSightings(kDeleteFile));
- assert_equals(obs.data[kDeleteFile][0], path);
- Services.obs.removeObserver(obs, kDeleteFile);
-}
-
-/**
- * Test that when we call createExistingAccount, onStopRequest is successfully
- * called, and we pass the correct parameters.
- */
-function test_create_existing_account() {
- gMockAuthPromptReg.register();
- try {
- gMockAuthPrompt.password = "account_password";
- let accountKey = "someNewAccount";
- // Prepare the backend without preloading any token.
- let provider = gServer.getPreparedBackend(accountKey, true);
- let done = false;
- let myObs = {
- onStartRequest: function(aRequest, aContext) {
- },
- onStopRequest: function(aRequest, aContext, aStatusCode) {
- assert_true(aContext instanceof Ci.nsIMsgCloudFileProvider);
- assert_equals(aStatusCode, Components.results.NS_OK);
- done = true;
- },
- }
-
- provider.createExistingAccount(myObs);
- mc.waitFor(function() done);
- let newToken = cloudFileAccounts.getSecretValue(
- accountKey, cloudFileAccounts.kTokenRealm);
- assert_not_equals(newToken, "");
- }
- finally {
- gMockAuthPromptReg.unregister();
- }
-}
-
-/**
- * Test that cancelling an upload causes onStopRequest to be
- * called with nsIMsgCloudFileProvider.uploadCanceled.
- */
-function test_can_cancel_upload() {
- const kFilename = "testFile1";
- let path = kAttachmentsVolume + "/" + kFilename;
- gServer.setupUser();
- let provider = gServer.getPreparedBackend("someNewAccount");
- let file = getFile("./data/" + kFilename, __file__);
- gServer.planForCreateVolume(kAttachmentsVolume);
- gServer.planForUploadFile(path, 2000);
- assert_can_cancel_uploads(mc, provider, [file]);
-}
-
-/**
- * Test that cancelling several uploads causes onStopRequest to be
- * called with nsIMsgCloudFileProvider.uploadCanceled.
- */
-function test_can_cancel_uploads() {
- const kFiles = ["testFile1", "testFile2", "testFile3"];
- gServer.setupUser();
- let provider = gServer.getPreparedBackend("someNewAccount");
- let files = [];
- gServer.planForCreateVolume(kAttachmentsVolume);
- for each (let [, filename] in Iterator(kFiles)) {
- let path = kAttachmentsVolume + "/" + filename;
- gServer.planForUploadFile(path, 2000);
- files.push(getFile("./data/" + filename, __file__));
- }
- assert_can_cancel_uploads(mc, provider, files);
-}
deleted file mode 100644
--- a/mail/test/mozmill/shared-modules/test-cloudfile-ubuntuone-helpers.js
+++ /dev/null
@@ -1,342 +0,0 @@
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this file,
- * You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-const MODULE_NAME = "cloudfile-ubuntuone-helpers";
-
-Cu.import('resource://mozmill/stdlib/httpd.js');
-Cu.import('resource://gre/modules/Services.jsm');
-Cu.import('resource:///modules/cloudFileAccounts.js');
-
-const kDefaultServerPort = 4444;
-const kServerRoot = "http://localhost:" + kDefaultServerPort;
-const kServerPath = "/server";
-const kContentPath = "/content";
-const kSsoPath = "/sso/authentications";
-const kSsoPingPath = "/sso-ping/";
-const kServerURL = kServerRoot + kServerPath;
-const kContentURL = kServerRoot + kContentPath;
-const kSsoURL = kServerRoot + kSsoPath;
-const kSsoPingURL = kServerRoot + kSsoPingPath;
-const kVolumesPath = "/volumes";
-
-const kDefaultConfig = {
- port: kDefaultServerPort
-}
-
-const kAuthToken = {
- token: "oauth_token",
- token_secret: "oauth_token_secret",
- consumer_key: "oauth_consumer_key",
- consumer_secret: "oauth_consumer_secret",
- description: "Ubuntu One @ hostname [thunderbird]"
-};
-
-const kDefaultUser = {
- visible_name: "Example User",
- user_id: 42,
- root_node_path: "/~/Ubuntu One",
- user_node_paths: [
- "/~/.ubuntuone/Purchased from Ubuntu One"
- ],
- resource_path: "",
- max_bytes: 91268055040,
- used_bytes: 134506915
-};
-
-const kDefaultVolume = {
- resource_path: "/volumes/~/Thunderbird Attachments",
- type: "udf",
- when_created: "2012-04-09T05:32:57Z",
- generation: 14,
- path: "~/Thunderbird Attachments",
- content_path: "/content/~/Thunderbird Attachments",
- node_path: "/~/Thunderbird Attachments"
-};
-
-const kDefaultFileInfo = {
- kind: "file",
- resource_path: "/~/Thunderbird Attachments/placeholder.txt",
- content_path: "/content/~/Thunderbird Attachments/placeholder.txt",
- key: "D0b30fjbSs-8oYWplbgi2A:jBK7FHshSCi8rpTRbUUkag",
- hash: "sha1:39e9d7d7689f94b61237a0c5d642331bbec4268c",
- when_created: "2012-04-09T10:51:30Z",
- when_changed: "2012-04-09T10:51:31Z",
- size: 39452,
- volume_path: "/volumes/~/Thunderbird Attachments",
- path: "/placeholder.txt",
- parent_path: "/~/Thunderbird Attachments",
- generation: 10,
- generation_created: 8,
- is_live: true,
- is_public: false,
-};
-
-const kDefaultReturnHeader = {
- statusCode: 200,
- statusString: "OK",
- contentType: "text/plain",
-}
-
-function installInto(module) {
- module.MockUbuntuOneServer = MockUbuntuOneServer;
-}
-
-function MockUbuntuOneServer() {}
-
-MockUbuntuOneServer.prototype = {
- _server: null,
- _toDelete: [],
- _timers: [],
-
- getPreparedBackend: function MU1S_getPreparedBackend(aAccountKey, aDontAuth) {
- let emailaddress = "somebody@example.org";
- Services.prefs.setCharPref("mail.cloud_files.accounts." + aAccountKey
- + ".emailaddress", emailaddress);
- if (!aDontAuth) {
- cloudFileAccounts.setSecretValue(aAccountKey, cloudFileAccounts.kTokenRealm,
- "someAuthToken");
- cloudFileAccounts.setSecretValue(aAccountKey, "Ubuntu One Auth Secret",
- "someAuthSecret");
- cloudFileAccounts.setSecretValue(aAccountKey, "Ubuntu One Consumer Key",
- "someConsumerKey");
- cloudFileAccounts.setSecretValue(aAccountKey, "Ubuntu One Consumer Secret",
- "someConsumerSecret");
- }
-
- let ubuntuone = Cc["@mozilla.org/mail/ubuntuone;1"]
- .createInstance(Ci.nsIMsgCloudFileProvider);
-
- let urls = [kServerURL, kContentURL, kSsoURL, kSsoPingURL];
- ubuntuone.overrideUrls(urls.length, urls);
- ubuntuone.init(aAccountKey);
- return ubuntuone;
- },
-
- init: function MU1S_init(aConfig) {
- this._config = this._overrideDefault(kDefaultConfig, aConfig);
- this._server = new HttpServer();
- this._pathInfo = {}
- this._wireSso();
- },
-
- start: function MU1S_start() {
- this._server.start(this._config.port);
- },
-
- stop: function MU1S_stop(aController) {
- let allDone = false;
- this._server.stop(function() {
- allDone = true;
- });
- aController.waitFor(function () allDone,
- "Timed out waiting for UbuntuOne server to stop!",
- 10000);
- },
-
- setupUser: function MU1S_wireUser(aData) {
- this._userInfo = this._overrideDefault(kDefaultUser, aData);
- this._server.registerPathHandler(kServerPath, this._getUserInfo.bind(this));
- },
-
- _getUserInfo: function MU1S__delete(aRequest, aResponse) {
- Services.obs.notifyObservers(null, "cloudfile:user", "");
- aResponse.setStatusLine(null, 200, "OK");
- aResponse.setHeader("Content-Type", "application/json");
- aResponse.write(JSON.stringify(this._userInfo));
- },
-
- planForCreateVolume: function MU1S_planForCreateVolume(aVolumeName) {
- let volume_info = this._overrideDefault(kDefaultVolume, {
- resource_path: kVolumesPath + aVolumeName,
- path: aVolumeName.substring(1),
- content_path: kContentPath + aVolumeName,
- node_path: aVolumeName
- });
- let putFileFunc = function(aRequest, aResponse) {
- if (aRequest.method != "PUT") {
- returnError(aResponse, "Volume should be created with a PUT request");
- return
- }
- Services.obs.notifyObservers(null, "cloudfile:createvolume", aVolumeName);
- if (this._userInfo.user_node_paths.indexOf(aVolumeName) < 0) {
- this._userInfo.user_node_paths.push(aVolumeName);
- }
-
- aResponse.setStatusLine(null, 200, "OK");
- aResponse.setHeader("Content-Type", "application/json");
- aResponse.write(JSON.stringify(volume_info));
- }.bind(this);
- this._server.registerPathHandler(
- kServerPath + kVolumesPath + encodePathForURI(aVolumeName),
- putFileFunc);
- },
-
- /**
- * Plan to upload a file with a particular filename.
- *
- * @param aPath the path of the file that will be uploaded.
- * @param aMSeconds an optional argument, for how long the upload should
- * last in milliseconds.
- */
- planForUploadFile: function MU1S_planForUploadFile(aPath, aMSeconds) {
- let lastSlash = aPath.lastIndexOf('/');
- let parent = aPath.substring(0, lastSlash);
- let filename = aPath.substring(lastSlash);
- let info = this._overrideDefault(kDefaultFileInfo, {
- resource_path: aPath,
- content_path: kContentPath + aPath,
- volume_path: kVolumesPath + parent,
- path: filename,
- parent_path: parent,
- });
- this._pathInfo[aPath] = info;
-
- // Prepare the function that will receive the upload and respond
- // appropriately.
- let putFileFunc = function(aRequest, aResponse) {
- if (aRequest.method != "PUT") {
- returnError(aResponse, "Files should be created with a PUT request");
- return;
- }
- Services.obs.notifyObservers(null, "cloudfile:uploadFile", aPath);
- info.size = aRequest.getHeader("Content-Length");
- info.is_live = true;
- aResponse.setStatusLine(null, 201, "OK");
- aResponse.setHeader("Content-Type", "application/json");
- aResponse.write(JSON.stringify(info));
- }.bind(this);
-
- // Also prepare a function that will, if necessary, wait aMSeconds before
- // firing putFileFunc.
- let waitWrapperFunc = function(aRequest, aResponse) {
- Services.obs.notifyObservers(null, "cloudfile:uploadStarted", aPath);
-
- if (!aMSeconds) {
- putFileFunc(aRequest, aResponse);
- return;
- }
-
- // Ok, we're waiting a bit. Tell the HTTP server that we're going to
- // generate a response asynchronously, then set a timer to send the
- // response after aMSeconds milliseconds.
- aResponse.processAsync();
- let timer = Cc["@mozilla.org/timer;1"].createInstance(Ci.nsITimer);
- let timerEvent = {
- notify: function(aTimer) {
- putFileFunc(aRequest, aResponse);
- aResponse.finish();
- },
- };
- timer.initWithCallback(timerEvent, aMSeconds,
- Ci.nsITimer.TYPE_ONE_SHOT);
- // We can't let the timer get garbage collected, so we store it.
- this._timers.push(timer);
- }.bind(this);
-
- this._server.registerPathHandler(kContentPath + encodePathForURI(aPath),
- waitWrapperFunc);
- },
-
- planForMetadataUpdate: function MU1S_planForMetadataUpdate(aPath,
- aPublicURL) {
- let fileMetadataFunc = function(aRequest, aResponse) {
- let info = this._pathInfo[aPath];
- if (aRequest.method == "GET") {
- Services.obs.notifyObservers(null, "cloudfile:getMetadata", aPath);
- }
- else if (aRequest.method == "PUT") {
- Services.obs.notifyObservers(null, "cloudfile:getFileURL", aPath);
- let body = JSON.parse(readBody(aRequest));
- info.is_public = body.is_public;
- if (info.is_public) {
- info.public_url = aPublicURL;
- }
- }
- else if (aRequest.method == "DELETE") {
- Services.obs.notifyObservers(null, "cloudfile:deleteFile", aPath);
- info.is_live = false;
- info = "";
- }
- aResponse.setStatusLine(null, 200, "OK");
- aResponse.setHeader("Content-Type", "application/json");
- aResponse.write(JSON.stringify(info));
- }.bind(this);
- this._server.registerPathHandler(kServerPath + encodePathForURI(aPath),
- fileMetadataFunc);
- },
-
- _noteAndReturnString: function MU1S__noteAndReturnString(aKey, aValue,
- aString,
- aOptions) {
-
- aOptions = this._overrideDefault(kDefaultReturnHeader, aOptions);
-
- let subjectString = Cc["@mozilla.org/supports-string;1"]
- .createInstance(Ci.nsISupportsString);
- subjectString.data = aString;
-
- let func = function(aMeta, aResponse) {
- try {
- aResponse.setStatusLine(null, aOptions.statusCode,
- aOptions.statusString);
- aResponse.setHeader("Content-Type", aOptions.contentType);
- aResponse.write(aString);
- Services.obs.notifyObservers(subjectString, aKey, aValue);
- }
- catch(ex) {
- dump("Failed to generate server response: " + ex);
- }
- }
- return func;
- },
-
- _overrideDefault: function MU1S__overrideDefault(aDefault, aData) {
- let result = {}
-
- if (aData === undefined)
- aData = {};
-
- for (let param in aDefault) {
- if (param in aData)
- result[param] = aData[param];
- else
- result[param] = aDefault[param];
- }
- return result;
- },
-
- _wireSso: function MU1S__wireSso() {
- let authFunc = this._noteAndReturnString("cloudfile:auth", "",
- JSON.stringify(kAuthToken),
- {contentType: 'application/json'});
- this._server.registerPathHandler(kSsoPath, authFunc);
-
- let pingFunc = this._noteAndReturnString("cloudfile:ping", "",
- "ok 1/1");
- this._server.registerPathHandler(kSsoPingPath, pingFunc)
- },
-}
-
-function encodePathForURI(aStr) {
- return encodeURIComponent(aStr).replace(/%2F/g, '/');
-}
-
-const ScriptableInputStream = Components.Constructor(
- "@mozilla.org/scriptableinputstream;1",
- "nsIScriptableInputStream",
- "init");
-
-function readBody(aRequest) {
- //let body = Cc['@mozilla.org/scriptableinputstream;1']
- // .createInstance(Ci.nsIScriptableInputStream);
- //body.setInputStream(aRequest.bodyInputStream);
- let body = new ScriptableInputStream(aRequest.bodyInputStream)
- return body.read(-1);
-}
-
-function returnError(aResponse, aMessage) {
- aResponse.setStatusLine(null, 50, "Server Error");
- aResponse.setHeader("Content-Type", "text/plain");
- aResponse.write(aMessage);
-}
--- a/mail/themes/linux/jar.mn
+++ b/mail/themes/linux/jar.mn
@@ -261,17 +261,16 @@ classic.jar:
skin/classic/messenger/newmailaccount/accountProvisioner.css (mail/newmailaccount/accountProvisioner.css)
skin/classic/messenger/newmailaccount/search.gif (mail/newmailaccount/search.gif)
skin/classic/messenger/newmailaccount/spinner.gif (mail/newmailaccount/spinner.gif)
skin/classic/messenger/newmailaccount/success-addons.png (mail/newmailaccount/success-addons.png)
skin/classic/messenger/newmailaccount/success-border.png (mail/newmailaccount/success-border.png)
skin/classic/messenger/newmailaccount/success-compose.png (mail/newmailaccount/success-compose.png)
skin/classic/messenger/newmailaccount/success-signature.png (mail/newmailaccount/success-signature.png)
skin/classic/messenger/newmailaccount/search.png (mail/newmailaccount/search.png)
- skin/classic/messenger/icons/ubuntuone.png (mail/icons/ubuntuone.png)
skin/classic/messenger/icons/hightail.png (mail/icons/hightail.png)
skin/classic/messenger/sanitizeDialog.css (mail/sanitizeDialog.css)
skin/classic/messenger/icons/box-logo.png (mail/icons/box-logo.png)
skin/classic/messenger/sharedPlatform.css (mail/linuxShared.css)
skin/classic/messenger/shared/mailWindow1.css (../shared/mail/mailWindow1.css)
skin/classic/messenger/shared/messenger.css (../shared/mail/messenger.css)
skin/classic/messenger/shared/messageHeader.css (../shared/mail/messageHeader.css)
skin/classic/messenger/shared/tabmail.css (../shared/mail/tabmail.css)
deleted file mode 100644
index bb61a6debea27e6d0f923a0ff8b34ca86e5a5421..0000000000000000000000000000000000000000
GIT binary patch
literal 0
Hc$@<O00001
--- a/mail/themes/osx/jar.mn
+++ b/mail/themes/osx/jar.mn
@@ -334,17 +334,16 @@ classic.jar:
skin/classic/messenger/newmailaccount/accountProvisioner.css (mail/newmailaccount/accountProvisioner.css)
skin/classic/messenger/newmailaccount/search.gif (mail/newmailaccount/search.gif)
skin/classic/messenger/newmailaccount/spinner.gif (mail/newmailaccount/spinner.gif)
skin/classic/messenger/newmailaccount/success-addons.png (mail/newmailaccount/success-addons.png)
skin/classic/messenger/newmailaccount/success-border.png (mail/newmailaccount/success-border.png)
skin/classic/messenger/newmailaccount/success-compose.png (mail/newmailaccount/success-compose.png)
skin/classic/messenger/newmailaccount/success-signature.png (mail/newmailaccount/success-signature.png)
skin/classic/messenger/newmailaccount/search.png (mail/newmailaccount/search.png)
- skin/classic/messenger/icons/ubuntuone.png (mail/icons/ubuntuone.png)
skin/classic/messenger/icons/hightail.png (mail/icons/hightail.png)
skin/classic/messenger/icons/expander-closed.png (mail/icons/expander-closed.png)
skin/classic/messenger/icons/expander-closed-active.png (mail/icons/expander-closed-active.png)
skin/classic/messenger/icons/expander-open.png (mail/icons/expander-open.png)
skin/classic/messenger/icons/expander-open-active.png (mail/icons/expander-open-active.png)
skin/classic/messenger/sanitizeDialog.css (mail/sanitizeDialog.css)
skin/classic/messenger/icons/box-logo.png (mail/icons/box-logo.png)
skin/classic/messenger/sharedPlatform.css (mail/osxShared.css)
deleted file mode 100644
index bb61a6debea27e6d0f923a0ff8b34ca86e5a5421..0000000000000000000000000000000000000000
GIT binary patch
literal 0
Hc$@<O00001
--- a/mail/themes/windows/jar.mn
+++ b/mail/themes/windows/jar.mn
@@ -279,17 +279,16 @@ classic.jar:
skin/classic/messenger/newmailaccount/search.gif (mail/newmailaccount/search.gif)
skin/classic/messenger/newmailaccount/spinner.gif (mail/newmailaccount/spinner.gif)
skin/classic/messenger/newmailaccount/success-addons.png (mail/newmailaccount/success-addons.png)
skin/classic/messenger/newmailaccount/success-border.png (mail/newmailaccount/success-border.png)
skin/classic/messenger/newmailaccount/success-compose.png (mail/newmailaccount/success-compose.png)
skin/classic/messenger/newmailaccount/success-signature.png (mail/newmailaccount/success-signature.png)
skin/classic/messenger/newmailaccount/search.png (mail/newmailaccount/search.png)
skin/classic/messenger/sanitizeDialog.css (mail/sanitizeDialog.css)
- skin/classic/messenger/icons/ubuntuone.png (mail/icons/ubuntuone.png)
skin/classic/messenger/icons/hightail.png (mail/icons/hightail.png)
skin/classic/messenger/icons/box-logo.png (mail/icons/box-logo.png)
skin/classic/messenger/sharedPlatform.css (mail/windowsShared.css)
skin/classic/messenger/shared/mailWindow1.css (../shared/mail/mailWindow1.css)
skin/classic/messenger/shared/messenger.css (../shared/mail/messenger.css)
skin/classic/messenger/shared/messageHeader.css (../shared/mail/messageHeader.css)
skin/classic/messenger/shared/tabmail.css (../shared/mail/tabmail.css)
#ifdef XP_WIN
@@ -557,17 +556,16 @@ classic.jar:
skin/classic/aero/messenger/newmailaccount/accountProvisioner.css (mail/newmailaccount/accountProvisioner-aero.css)
skin/classic/aero/messenger/newmailaccount/search.gif (mail/newmailaccount/search.gif)
skin/classic/aero/messenger/newmailaccount/spinner.gif (mail/newmailaccount/spinner.gif)
skin/classic/aero/messenger/newmailaccount/success-addons.png (mail/newmailaccount/success-addons.png)
skin/classic/aero/messenger/newmailaccount/success-border.png (mail/newmailaccount/success-border.png)
skin/classic/aero/messenger/newmailaccount/success-compose.png (mail/newmailaccount/success-compose.png)
skin/classic/aero/messenger/newmailaccount/success-signature.png (mail/newmailaccount/success-signature.png)
skin/classic/aero/messenger/newmailaccount/search.png (mail/newmailaccount/search.png)
- skin/classic/aero/messenger/icons/ubuntuone.png (mail/icons/ubuntuone.png)
skin/classic/aero/messenger/icons/hightail.png (mail/icons/hightail.png)
skin/classic/aero/messenger/sanitizeDialog.css (mail/sanitizeDialog.css)
skin/classic/aero/messenger/icons/box-logo.png (mail/icons/box-logo.png)
skin/classic/aero/messenger/sharedPlatform.css (mail/windowsShared.css)
skin/classic/aero/messenger/shared/mailWindow1.css (../shared/mail/mailWindow1.css)
skin/classic/aero/messenger/shared/messenger.css (../shared/mail/messenger.css)
skin/classic/aero/messenger/shared/messageHeader.css (../shared/mail/messageHeader.css)
skin/classic/aero/messenger/shared/tabmail.css (../shared/mail/tabmail.css)
deleted file mode 100644
index bb61a6debea27e6d0f923a0ff8b34ca86e5a5421..0000000000000000000000000000000000000000
GIT binary patch
literal 0
Hc$@<O00001