--- a/mail/components/cloudfile/Makefile.in
+++ b/mail/components/cloudfile/Makefile.in
@@ -8,17 +8,16 @@ srcdir = @srcdir@
VPATH = @srcdir@
include $(DEPTH)/config/autoconf.mk
MODULE = cloudfile
EXTRA_COMPONENTS = \
nsYouSendIt.js \
- nsDropbox.js \
nsUbuntuOne.js \
cloudFileComponents.manifest \
$(NULL)
EXTRA_JS_MODULES = \
cloudFileAccounts.js \
$(NULL)
--- a/mail/components/cloudfile/cloudFileAccounts.js
+++ b/mail/components/cloudfile/cloudFileAccounts.js
@@ -90,27 +90,34 @@ var cloudFileAccounts = {
let provider = Cc[className].createInstance(Ci.nsIMsgCloudFileProvider);
return provider;
},
// aExtraPrefs are prefs specific to an account provider.
createAccount: function(aType, aRequestObserver, aExtraPrefs) {
let key = this._createUniqueAccountKey();
- Services.prefs
- .setCharPref(ACCOUNT_ROOT + key + ".type", aType);
- if (aExtraPrefs !== undefined)
- this._processExtraPrefs(key, aExtraPrefs);
+ try {
+ Services.prefs
+ .setCharPref(ACCOUNT_ROOT + key + ".type", aType);
+
+ if (aExtraPrefs !== undefined)
+ this._processExtraPrefs(key, aExtraPrefs);
- let provider = this._getInitedProviderForType(key, aType);
- if (provider)
- provider.createExistingAccount(aRequestObserver);
+ let provider = this._getInitedProviderForType(key, aType);
+ if (provider)
+ provider.createExistingAccount(aRequestObserver);
- return provider;
+ return provider;
+ }
+ catch(e) {
+ Services.prefs.deleteBranch(ACCOUNT_ROOT + key);
+ throw e;
+ }
},
// Set provider-specific prefs
_processExtraPrefs: function CFA__processExtraPrefs(aAccountKey,
aExtraPrefs) {
const kFuncMap = {
"int": "setIntPref",
"bool": "setBoolPref",
--- a/mail/components/cloudfile/cloudFileComponents.manifest
+++ b/mail/components/cloudfile/cloudFileComponents.manifest
@@ -1,11 +1,7 @@
component {32fd439f-9eb6-4907-ac0b-2c88eb14d98d} nsYouSendIt.js
contract @mozilla.org/mail/yousendit;1 {32fd439f-9eb6-4907-ac0b-2c88eb14d98d}
category cloud-files YouSendIt @mozilla.org/mail/yousendit;1
-component {2fd8a64a-a496-4cf4-9d6b-d3f9800c6322} nsDropbox.js
-contract @mozilla.org/mail/dropbox;1 {2fd8a64a-a496-4cf4-9d6b-d3f9800c6322}
-category cloud-files Dropbox @mozilla.org/mail/dropbox;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
deleted file mode 100644
--- a/mail/components/cloudfile/content/Dropbox/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/Dropbox/management.xhtml
+++ /dev/null
@@ -1,49 +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 % dropboxDTD SYSTEM "chrome://messenger/locale/cloudfile/Dropbox/management.dtd"> %dropboxDTD;
-]>
-<html xmlns="http://www.w3.org/1999/xhtml">
- <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/Dropbox/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://www.dropbox.com/terms#privacy">&cloudfileMgmt.privacyPolicy;</a>
- <a href="https://www.dropbox.com/terms#terms">&cloudfileMgmt.termsOfService;</a>
- </div>
- <div id="provider-name">
- <h1>Dropbox</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://www.dropbox.com/plans">&cloudfileMgmt.upgradeOffer;</a></div>
- </div>
- </div>
- <div id="provider-account-settings"><a href="https://www.dropbox.com/account#settings">&dropboxMgmt.viewSettings;</a></div>
- </body>
-</html>
deleted file mode 100644
--- a/mail/components/cloudfile/content/Dropbox/settings.xhtml
+++ /dev/null
@@ -1,21 +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 % dbDTD SYSTEM "chrome://messenger/locale/cloudfile/Dropbox/settings.dtd"> %dbDTD;
-]>
-<html xmlns="http://www.w3.org/1999/xhtml">
- <head>
- <link rel="stylesheet"
- type="text/css"
- href="chrome://messenger/skin/cloudfile/addAccountDialog.css" />
- </head>
- <body id="provider-settings">
- <div id="learn-more">
- <a href="https://www.dropbox.com/">&dropboxSettings.learnMore;</a>
- </div>
- </body>
-</html>
new file mode 100644
--- /dev/null
+++ b/mail/components/cloudfile/content/UbuntuOne/management.js
@@ -0,0 +1,44 @@
+/* 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();
+}
--- a/mail/components/cloudfile/content/UbuntuOne/management.xhtml
+++ b/mail/components/cloudfile/content/UbuntuOne/management.xhtml
@@ -8,17 +8,17 @@
<!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/Dropbox/management.js"/>
+ 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/mail/components/cloudfile/jar.mn
+++ b/mail/components/cloudfile/jar.mn
@@ -2,18 +2,16 @@
# 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/.
messenger.jar:
* content/messenger/cloudfile/addAccountDialog.xul (content/addAccountDialog.xul)
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/Dropbox/management.xhtml (content/Dropbox/management.xhtml)
- content/messenger/cloudfile/Dropbox/management.js (content/Dropbox/management.js)
- content/messenger/cloudfile/Dropbox/settings.xhtml (content/Dropbox/settings.xhtml)
+ 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/YouSendIt/management.xhtml (content/YouSendIt/management.xhtml)
content/messenger/cloudfile/YouSendIt/management.js (content/YouSendIt/management.js)
content/messenger/cloudfile/YouSendIt/settings.js (content/YouSendIt/settings.js)
content/messenger/cloudfile/YouSendIt/settings.xhtml (content/YouSendIt/settings.xhtml)
deleted file mode 100644
--- a/mail/components/cloudfile/nsDropbox.js
+++ /dev/null
@@ -1,628 +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 Dropbox 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:///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 = "Dropbox Auth Secret";
-// According to Dropbox, the kMaxFileSize is a fixed limit.
-const kMaxFileSize = 157286400;
-const kUserInfoPath = "account/info";
-const kDeletePath = "fileops/delete/?root=sandbox";
-const kAppKey = "7xkhuze09iqkghm";
-const kAppSecret = "3i5kwjkt74rkkjc";
-const kSharesPath = "shares/sandbox/";
-const kFilesPutPath = "files_put/sandbox/";
-
-var gServerUrl = "https://api.dropbox.com/1/";
-var gContentUrl = "https://api-content.dropbox.com/1/";
-var gAuthUrl = "https://www.dropbox.com/1/";
-var gLogoutUrl = "https://www.dropbox.com/logout";
-
-function wwwFormUrlEncode(aStr) {
- return encodeURIComponent(aStr).replace(/!/g, '%21')
- .replace(/'/g, '%27')
- .replace(/\(/g, '%28')
- .replace(/\)/g, '%29')
- .replace(/\*/g, '%2A');
-}
-
-
-function nsDropbox() {
- this.log = Log4Moz.getConfiguredLogger("Dropbox");
-}
-
-nsDropbox.prototype = {
- /* nsISupports */
- QueryInterface: XPCOMUtils.generateQI([Ci.nsIMsgCloudFileProvider]),
-
- classID: Components.ID("{2fd8a64a-a496-4cf4-9d6b-d3f9800c6322}"),
-
- get type() "Dropbox",
- get displayName() "Dropbox",
- get serviceURL() "https://www.dropbox.com/",
- get iconClass() "chrome://messenger/skin/icons/dropbox.png",
- get accountKey() this._accountKey,
- get lastError() this._lastErrorText,
- get settingsURL() "chrome://messenger/content/cloudfile/Dropbox/settings.xhtml",
- get managementURL() "chrome://messenger/content/cloudfile/Dropbox/management.xhtml",
-
- _accountKey: false,
- _prefBranch: null,
- _loggedIn: false,
- _authToken: "",
- _userInfo: null,
- _file : null,
- _requestDate: null,
- _successCallback: null,
- _connection: null,
- _request: null,
- _uploadingFile : null,
- _uploader : null,
- _lastErrorStatus : 0,
- _lastErrorText : "",
- _maxFileSize : kMaxFileSize,
- _totalStorage: -1,
- _fileSpaceUsed : -1,
- _uploads: [],
- _urlsForFiles : {},
- _uploadInfo : {}, // upload info keyed on aFiles.
-
- /**
- * Initialize this instance of nsDropbox, setting the accountKey.
- *
- * @param aAccountKey the account key to initialize this provider with
- */
- init: function nsDropbox_init(aAccountKey) {
- this._accountKey = aAccountKey;
- this._prefBranch = Services.prefs.getBranch("mail.cloud_files.accounts." +
- aAccountKey + ".");
- },
-
- /**
- * The callback passed to an nsDropboxFileUploader, which is fired when
- * nsDropboxFileUploader exits.
- *
- * @param aRequestObserver the request observer originally passed to
- * uploadFile for the file associated with the
- * nsDropboxFileUploader
- * @param aStatus the result of the upload
- */
- _uploaderCallback : function nsDropbox__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) {
- nextUpload.callback(nextUpload.requestObserver, Cr.NS_ERROR_FAILURE);
- }
- }
- else
- this._uploader = null;
- },
-
- /**
- * Attempts to upload a file to Dropbox.
- *
- * @param aFile the nsILocalFile to be uploaded
- * @param aCallback an nsIRequestObserver for listening for the starting
- * and ending states of the upload.
- */
- uploadFile: function nsDropbox_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 != aFile) {
- let uploader = new nsDropboxFileUploader(this, aFile,
- this._uploaderCallback
- .bind(this),
- aCallback);
- this._uploads.push(uploader);
- return;
- }
- this._file = aFile;
- 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 nsDropbox__finishUpload(aFile, aCallback) {
- let exceedsFileLimit = Ci.nsIMsgCloudFileProvider.uploadExceedsFileLimit;
- let exceedsQuota = Ci.nsIMsgCloudFileProvider.uploadWouldExceedQuota;
- if (aFile.fileSize > this._maxFileSize)
- return aCallback.onStopRequest(null, null, exceedsFileLimit);
- if (aFile.fileSize > this.remainingFileSpace)
- return aCallback.onStopRequest(null, null, exceedsQuota);
-
- delete this._userInfo; // force us to update userInfo on every upload.
-
- if (!this._uploader) {
- this._uploader = new nsDropboxFileUploader(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 nsDropbox_cancelFileUpload(aFile) {
- 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)) {
- 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 nsDropbox__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);
-
- this._connection.signAndSend(
- gServerUrl + kUserInfoPath, "", "GET", [],
- function(aResponseText, aRequest) {
- this.log.info("user info = " + aResponseText);
- this._userInfo = JSON.parse(aResponseText);
- let quota = this._userInfo.quota_info;
- this._totalStorage = quota.quota;
- this._fileSpaceUsed = quota.normal + quota.shared;
- this.log.info("storage total = " + this._totalStorage);
- this.log.info("storage used = " + this._fileSpaceUsed);
- successCallback();
- }.bind(this),
- 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);
- },
-
- /**
- * 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 nsDropbox_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 nsDropbox_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 nsDropbox_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 Dropbox implementation does not implement the createNewAccount
- * function defined in nsIMsgCloudFileProvider.idl.
- */
- createNewAccount: function nsDropbox_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 nsDropbox_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 Dropbox has a page for handling
- * that particular error.
- *
- * @param aError the error to get the URL for
- */
- providerUrlForError: function nsDropbox_providerUrlForError(aError) {
- if (aError == Ci.nsIMsgCloudFileProvider.uploadWouldExceedQuota)
- return "https://www.dropbox.com/plans";
- return "";
- },
-
- /**
- * If we don't know the limit, this will return -1.
- */
- get fileUploadSizeLimit() this._maxFileSize,
- get remainingFileSpace() this._totalStorage - this._fileSpaceUsed,
- 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 nsDropbox_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 path = wwwFormUrlEncode(uploadInfo.path);
- let url = gServerUrl + kDeletePath + "&path=" + uploadInfo.path;
- this.log.info("Sending delete request to " + url);
- let oauthParams =
- [["root", "sandbox"], ["path", path]];
- this._connection.signAndSend(url, "", "POST", 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, null);
- },
-
- /**
- * This function is used by our testing framework to override the default
- * URL's that nsDropbox connects to.
- */
- overrideUrls : function nsDropbox_overrideUrls(aNumUrls, aUrls) {
- gServerUrl = aUrls[0];
- gContentUrl = aUrls[1];
- gAuthUrl = aUrls[2];
- gLogoutUrl = aUrls[3];
- },
-
- /**
- * logon to the dropbox 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 nsDropbox_logon(successCallback, failureCallback, aWithUI) {
- let authToken = this._cachedAuthToken;
- let authSecret = this._cachedAuthSecret;
- if (!aWithUI && (!authToken.length || !authSecret.length)) {
- failureCallback();
- return;
- }
-
- this._connection = new OAuth(this.displayName, gServerUrl, gAuthUrl,
- authToken, authSecret, kAppKey, kAppSecret);
- this._connection.connect(
- function () {
- this.log.info("success connecting");
- this._loggedIn = true;
- this._cachedAuthToken = this._connection.token;
- this._cachedAuthSecret = this._connection.tokenSecret;
-
- // Attempt to end the session we just opened to get these tokens...
- let xhr = Cc["@mozilla.org/xmlextras/xmlhttprequest;1"]
- .createInstance(Ci.nsIXMLHttpRequest);
- xhr.mozBackgroundRequest = true;
- xhr.open("GET", gLogoutUrl);
- xhr.onerror = function(aProgressEvent) {
- this.log.error("Could not end authorization session!");
- this.log.error("Status was: " + aProgressEvent.target.status);
- this.log.error("Message was: " + aProgressEvent.target.statusText);
- }.bind(this);
-
- xhr.onload = function(aRequest) {
- if (aRequest.target.status == 200)
- this.log.info("Successfully ended authorization session.");
- else {
- this.log.error("Could not end authorization session!");
- this.log.error("Status was: " + aRequest.target.status);
- this.log.error("Message was: " + aRequest.target.statusText);
- }
- }.bind(this);
-
- this.log.info("Sending logout request to: " + gLogoutUrl);
- xhr.send();
-
- successCallback();
- }.bind(this),
- function () {
- this.log.info("failed connecting");
- failureCallback();
- }.bind(this),
- true);
- },
-
- /**
- * 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);
- },
-};
-
-function nsDropboxFileUploader(aDropbox, aFile, aCallback, aRequestObserver) {
- this.dropbox = aDropbox;
- this.log = this.dropbox.log;
- this.log.info("new nsDropboxFileUploader file = " + aFile.leafName);
- this.file = aFile;
- this.callback = aCallback;
- this.requestObserver = aRequestObserver;
-}
-
-nsDropboxFileUploader.prototype = {
- dropbox : null,
- file : null,
- callback : null,
- request : null,
-
- /**
- * Kicks off the upload request for the file associated with this Uploader.
- */
- uploadFile: function nsDFU_uploadFile() {
- this.requestObserver.onStartRequest(null, null);
- this.log.info("ready to upload file " + wwwFormUrlEncode(this.file.leafName));
- let url = gContentUrl + kFilesPutPath +
- wwwFormUrlEncode(this.file.leafName) + "?overwrite=false";
- let fileContents = "";
- 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, this.file.fileSize);
- bufStream = bufStream.QueryInterface(Ci.nsIInputStream);
- let contentLength = fstream.available();
- let oauthParams =
- [["Content-Length", contentLength]];
- this.request = this.dropbox._connection.signAndSend(url, "", "PUT", bufStream,
- function(aResponseText, aRequest) {
- this.request = null;
- this.log.info("success putting file " + aResponseText);
- let putInfo = JSON.parse(aResponseText);
- this.dropbox._uploadInfo[this.file.path] = putInfo;
- this._getShareUrl(this.file, this.callback);
- }.bind(this),
- function(aException, aResponseText, aRequest) {
- this.request = null;
- this.log.info("failed putting file response = " + aResponseText);
- if (this.callback)
- this.callback(this.requestObserver,
- Ci.nsIMsgCloudFileProvider.uploadErr);
- }.bind(this), this, oauthParams);
- },
-
- /**
- * Cancels the upload request for the file associated with this Uploader.
- */
- cancel: function nsDFU_cancel() {
- this.callback(this.requestObserver, Ci.nsIMsgCloudFileProvider.uploadCanceled);
- if (this.request) {
- let req = this.request;
- if (req.channel) {
- this.log.info("canceling channel upload");
- delete this.callback;
- 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 aFile ...
- * @param aCallback an nsIRequestObserver for monitoring the starting and
- * ending states of the URL retrieval request.
- */
- _getShareUrl: function nsDFU__getShareUrl(aFile, aCallback) {
- let url = gServerUrl + kSharesPath + wwwFormUrlEncode(aFile.leafName);
- this.file = aFile;
- this.dropbox._connection.signAndSend(
- url, "", "POST", null,
- function(aResponseText, aRequest) {
- this.log.info("Getting share URL successful with response text: "
- + aResponseText);
- let shareInfo = JSON.parse(aResponseText);
- this.dropbox._urlsForFiles[this.file.path] = shareInfo.url;
- aCallback(this.requestObserver, Cr.NS_OK);
- }.bind(this),
- function(aException, aResponseText, aRequest) {
- this.log.error("Getting share URL failed with response text: "
- + aResponseText);
- aCallback(this.requestObserver, Cr.NS_ERROR_FAILURE);
- }.bind(this), this);
- },
-};
-
-const NSGetFactory = XPCOMUtils.generateNSGetFactory([nsDropbox]);
--- a/mail/installer/package-manifest.in
+++ b/mail/installer/package-manifest.in
@@ -171,17 +171,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/nsYouSendIt.js
-@BINPATH@/components/nsDropbox.js
@BINPATH@/components/nsUbuntuOne.js
@BINPATH@/components/cloudFileAccounts.js
@BINPATH@/components/nsAddrbook.manifest
@BINPATH@/components/nsMailNewsCommandLineHandler.js
@BINPATH@/components/services-crypto-component.xpt
#ifndef XP_OS2
@BINPATH@/components/shellservice.xpt
#endif
--- a/mail/installer/removed-files.in
+++ b/mail/installer/removed-files.in
@@ -55,16 +55,17 @@ components/mozgnome.xpt
components/@DLL_PREFIX@myspell@DLL_SUFFIX@
components/necko_data.xpt
components/aboutRights.js
components/nsAddonRepository.js
components/nsBackgroundUpdateService.js
components/nsCloseAllWindows.js
components/nsComposerCmdLineHandler.js
components/nsDownloadProgressListener.js
+components/nsDropbox.js
components/nsExtensionManager.js
components/nsInterfaceInfoToIDL.js
components/nsLDAPPrefsService.js
#ifdef XP_WIN
components/nsPostUpdateWin.js
#endif
components/nsProgressDialog.js
components/nsScriptableIO.js
@@ -1177,9 +1178,9 @@ components/xmlextras.xpt
#endif
#endif
# ****************************************************************************
# * End of XPTs at the time we started linking them on Linux and Mac. *
# ****************************************************************************
#ifndef MOZ_MAINTENANCE_SERVICE
maintenanceservice.exe
maintenanceservice_installer.exe
-#endif
\ No newline at end of file
+#endif
deleted file mode 100644
--- a/mail/locales/en-US/chrome/messenger/cloudfile/Dropbox/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 dropboxMgmt.viewSettings "View my account settings on dropbox.com">
deleted file mode 100644
--- a/mail/locales/en-US/chrome/messenger/cloudfile/Dropbox/settings.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 dropboxSettings.learnMore "Learn more…">
--- a/mail/locales/jar.mn
+++ b/mail/locales/jar.mn
@@ -122,18 +122,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/Dropbox/management.dtd (%chrome/messenger/cloudfile/Dropbox/management.dtd)
- locale/@AB_CD@/messenger/cloudfile/Dropbox/settings.dtd (%chrome/messenger/cloudfile/Dropbox/settings.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/YouSendIt/management.dtd (%chrome/messenger/cloudfile/YouSendIt/management.dtd)
locale/@AB_CD@/messenger/cloudfile/YouSendIt/settings.dtd (%chrome/messenger/cloudfile/YouSendIt/settings.dtd)
locale/@AB_CD@/messenger/messengercompose/messengercompose.dtd (%chrome/messenger/messengercompose/messengercompose.dtd)
locale/@AB_CD@/messenger/messengercompose/addressingWidgetOverlay.dtd (%chrome/messenger/messengercompose/addressingWidgetOverlay.dtd)
locale/@AB_CD@/messenger/messengercompose/askSendFormat.dtd (%chrome/messenger/messengercompose/askSendFormat.dtd)
locale/@AB_CD@/messenger/messengercompose/askSendFormat.properties (%chrome/messenger/messengercompose/askSendFormat.properties)
deleted file mode 100644
--- a/mail/test/mozmill/cloudfile/test-cloudfile-backend-dropbox.js
+++ /dev/null
@@ -1,296 +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 Dropbox Bigfile backend.
- */
-
-const Cr = Components.results;
-const MODULE_NAME = 'test-cloudfile-backend-dropbox';
-
-const RELATIVE_ROOT = '../shared-modules';
-const MODULE_REQUIRES = ['folder-display-helpers',
- 'compose-helpers',
- 'cloudfile-dropbox-helpers',
- 'observer-helpers',];
-
-Cu.import('resource://gre/modules/Services.jsm');
-
-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-dropbox-helpers');
- cdh.installInto(module);
-
- let oh = collector.getModule('observer-helpers');
- oh.installInto(module);
-
- gObsManager = new cbh.SimpleRequestObserverManager();
-
- // Enable logging for this test.
- Services.prefs.setCharPref("Dropbox.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("Dropbox.logging.dump");
- Services.prefs.clearUserPref("TBOAuth.logging.dump");
-}
-
-function setupTest() {
- gServer = new MockDropboxServer();
- 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.planForUploadFile("testFile1");
- gServer.planForGetFileURL("testFile1", {url: 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("testFile1");
- gServer.planForGetFileURL("testFile1", {url: 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();
-
- for each (let [, filename] in Iterator(kFilenames)) {
- let expectedUrl = kExpectedUrlRoot + filename;
- gServer.planForUploadFile(filename);
- gServer.planForGetFileURL(filename, {url: 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.");
-
- assert_equals(kFilenames.length, obs.numSightings(kUploadFile));
-
- for (let [index, filename] in Iterator(kFilenames)) {
- assert_equals(obs.data[kUploadFile][index], filename);
- 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";
- gServer.setupUser();
- let provider = gServer.getPreparedBackend("someAccountKey");
- // Upload a file
-
- let file = getFile("./data/" + kFilename, __file__);
- gServer.planForUploadFile(kFilename);
- gServer.planForGetFileURL(kFilename,
- {url: "http://www.example.com/someFile"});
- let requestObserver = gObsManager.create("test_deleting_uploads - upload 1");
- 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], kFilename);
- 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() {
- let provider = gServer.getPreparedBackend("someNewAccount");
- 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);
-}
-
-/**
- * Test that cancelling an upload causes onStopRequest to be
- * called with nsIMsgCloudFileProvider.uploadCanceled.
- */
-function test_can_cancel_upload() {
- const kFilename = "testFile1";
- gServer.setupUser();
- let provider = gServer.getPreparedBackend("someNewAccount");
- let file = getFile("./data/" + kFilename, __file__);
- gServer.planForUploadFile(kFilename, 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 = ["testFile2", "testFile3", "testFile4"];
- gServer.setupUser();
- let provider = gServer.getPreparedBackend("someNewAccount");
- let files = [];
- for each (let [, filename] in Iterator(kFiles)) {
- gServer.planForUploadFile(filename, 2000);
- files.push(getFile("./data/" + filename, __file__));
- }
- assert_can_cancel_uploads(mc, provider, files);
-}
-
-/**
- * Test that completing the OAuth procedure results in an attempt to logout.
- */
-function test_oauth_complete_causes_logout() {
- let provider = gServer.getPreparedBackend("someNewAccount");
- let dummyObs = gObsManager.create("test_oauth_complete_causes_logout");
- let obs = new ObservationRecorder();
- obs.planFor(kLogout);
- Services.obs.addObserver(obs, kLogout, false);
- provider.createExistingAccount(dummyObs);
- mc.waitFor(function() dummyObs.success);
- mc.waitFor(function() 1 == obs.numSightings(kLogout));
- Services.obs.removeObserver(obs, kLogout);
-}
-
-/**
- * Test that we calculate the used and remaining storage amounts correctly.
- */
-function test_calculate_used_and_remaining_storage_correctly() {
- const kShared = 12345;
- const kNormal = 67890;
- const kQuota = 31415926535;
-
- let provider = gServer.getPreparedBackend("someNewAccount");
-
- // Override the returned user profile values with the ones we defined
- // above.
- gServer.setupUser({
- quota_info: {
- shared: kShared,
- quota: kQuota,
- normal: kNormal,
- }
- });
-
- let gotUserInfo = false;
- let statusCode = null;
-
- // Make the provider get the user profile from the fake server.
- provider.refreshUserInfo(false, {
- onStartRequest: function(aRequest, aContext) {},
- onStopRequest: function(aRequest, aContext, aStatusCode) {
- gotUserInfo = true;
- statusCode = aStatusCode;
- },
- });
-
- // These are the correct calculations that we should get back.
- const kUsedSpace = kShared + kNormal;
- const kRemainingSpace = kQuota - kUsedSpace;
-
- mc.waitFor(function() gotUserInfo);
- assert_equals(statusCode, Cr.NS_OK);
- assert_equals(provider.fileSpaceUsed, kUsedSpace);
- assert_equals(provider.remainingFileSpace, kRemainingSpace);
-}
deleted file mode 100644
--- a/mail/test/mozmill/shared-modules/test-cloudfile-dropbox-helpers.js
+++ /dev/null
@@ -1,318 +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/. */
-
-let Cu = Components.utils;
-let Cc = Components.classes;
-let Ci = Components.interfaces;
-
-const MODULE_NAME = 'cloudfile-dropbox-helpers';
-
-const RELATIVE_ROOT = '../shared-modules';
-const MODULE_REQUIRES = [];
-
-let httpd = {};
-Cu.import('resource://mozmill/stdlib/httpd.js', httpd);
-Cu.import('resource://gre/modules/Services.jsm');
-
-const kDefaultServerPort = 4444;
-const kServerRoot = "http://localhost:" + kDefaultServerPort;
-const kServerPath = "/server/";
-const kContentPath = "/content/";
-const kAuthPath = "/auth/";
-const kServerURL = kServerRoot + kServerPath;
-const kContentURL = kServerRoot + kContentPath;
-const kAuthURL = kServerRoot + kAuthPath;
-const kOAuthTokenPath = "oauth/request_token";
-const kOAuthAuthorizePath = "oauth/authorize";
-const kOAuthAccessTokenPath = "oauth/access_token";
-const kUserInfoPath = "account/info";
-const kPutFilePath = "files_put/sandbox/";
-const kSharesPath = "shares/sandbox/";
-const kDeletePath = "fileops/delete/";
-const kLogoutPath = "/logout";
-const kLogoutURL = kServerRoot + kLogoutPath;
-
-const kDefaultConfig = {
- port: kDefaultServerPort
-}
-
-const kAuthTokenString = "oauth_token=requestkey&oauth_token_secret=requestsecret";
-
-const kDefaultUser = {
- referral_link: "https://www.dropbox.com/referrals/r1a2n3d4m5s6t7",
- display_name: "John P. User",
- uid: 12345678,
- country: "US",
- quota_info: {
- shared: 253738410565,
- quota: 107374182400000,
- normal: 680031877871
- },
- email: "john@example.com"
-}
-
-const kDefaultFilePutReturn = {
- size: "225.4KB",
- rev: "35e97029684fe",
- thumb_exists: false,
- bytes: 230783,
- modified: "Tue, 19 Jul 2011 21:55:38 +0000",
-// path: "/Getting_Started.pdf",
- is_dir: false,
- icon: "page_white_acrobat",
- root: "dropbox",
- mime_type: "application/pdf",
- revision: 220823
-}
-
-const kDefaultShareReturn = {
- url: "http://db.tt/APqhX1",
- expires: "Wed, 17 Aug 2011 02:34:33 +0000"
-}
-
-const kDefaultReturnHeader = {
- statusCode: 200,
- statusString: "OK",
- contentType: "text/plain",
-}
-
-const kDefaultDeleteReturn = {
- size: "0 bytes",
- is_deleted: true,
- bytes: 0,
- thumb_exists: false,
- rev: "1f33043551f",
- modified: "Wed, 10 Aug 2011 18:21:30 +0000",
-// path: "/test .txt",
- is_dir: false,
- icon: "page_white_text",
- root: "dropbox",
- mime_type: "text/plain",
- revision: 492341,
-}
-
-function installInto(module) {
- module.MockDropboxServer = MockDropboxServer;
-}
-
-function MockDropboxServer() {}
-
-MockDropboxServer.prototype = {
- _server: null,
- _toDelete: [],
- _timers: [],
-
- getPreparedBackend: function MDBS_getPreparedBackend(aAccountKey) {
- let dropbox = Cc["@mozilla.org/mail/dropbox;1"]
- .createInstance(Ci.nsIMsgCloudFileProvider);
-
- let urls = [kServerURL, kContentURL, kAuthURL, kLogoutURL];
- dropbox.overrideUrls(urls.length, urls);
- dropbox.init(aAccountKey);
- return dropbox;
- },
-
- init: function MDBS_init(aConfig) {
- this._config = kDefaultConfig;
-
- for (let param in aConfig) {
- this._config[param] = aConfig[param];
- }
-
- this._server = httpd.getServer(this._config.port, '');
- this._wireOAuth();
- this._wireDeleter();
- },
-
- start: function MDBS_start() {
- this._server.start(this._config.port);
- },
-
- stop: function MDBS_stop(aController) {
- let allDone = false;
- this._server.stop(function() {
- allDone = true;
- });
- aController.waitFor(function () allDone,
- "Timed out waiting for Dropbox server to stop!",
- 10000);
- },
-
- setupUser: function MDBS_wireUser(aData) {
- aData = this._overrideDefault(kDefaultUser, aData);
-
- let userFunc = this._noteAndReturnString("cloudfile:user", "",
- JSON.stringify(aData));
-
- this._server.registerPathHandler(kServerPath + kUserInfoPath,
- userFunc);
- },
-
- /**
- * Plan to upload a file with a particular filename.
- *
- * @param aFilename the name of the file that will be uploaded.
- * @param aMSeconds an optional argument, for how long the upload should
- * last in milliseconds.
- */
- planForUploadFile: function MDBS_planForUploadFile(aFilename, aMSeconds) {
- let data = kDefaultFilePutReturn;
- data.path = aFilename;
-
- // Prepare the function that will receive the upload and respond
- // appropriately.
- let putFileFunc = this._noteAndReturnString("cloudfile:uploadFile",
- aFilename,
- JSON.stringify(data));
-
- // Also prepare a function that will, if necessary, wait aMSeconds before
- // firing putFileFunc.
- let waitWrapperFunc = function(aRequest, aResponse) {
- Services.obs.notifyObservers(null, "cloudfile:uploadStarted",
- aFilename);
-
- 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 + kPutFilePath + aFilename,
- waitWrapperFunc);
- },
-
- planForGetFileURL: function MDBS_planForGetShare(aFileName, aData) {
- aData = this._overrideDefault(kDefaultShareReturn, aData);
-
- let getShareFunc = this._noteAndReturnString("cloudfile:getFileURL",
- aFileName,
- JSON.stringify(aData));
- this._server.registerPathHandler(kServerPath + kSharesPath + aFileName,
- getShareFunc);
- },
-
- planForDeleteFile: function MDBS_planForDeleteFile(aFilename) {
- this._toDelete.push(aFilename);
- },
-
- _wireDeleter: function MDBS__wireDeleter() {
- this._server.registerPathHandler(kServerPath + kDeletePath,
- this._delete.bind(this));
- },
-
- _delete: function MDBS__delete(aRequest, aResponse) {
- // Extract the query params
- let params = parseQueryString(aRequest.queryString);
- let pathIndex = this._toDelete.indexOf(params.path);
-
- if (pathIndex == -1) {
- aResponse.setStatusLine(null, 500, "Bad request");
- aResponse.write("Was not prepared to delete a file at path: "
- + params.path);
- return;
- }
-
- this._toDelete.splice(pathIndex, 1);
-
- Services.obs.notifyObservers(null, "cloudfile:deleteFile",
- params.path);
-
- let data = kDefaultDeleteReturn;
- data.path = params.path;
-
- aResponse.setStatusLine(null, 200, "OK");
- aResponse.setHeader("Content-Type", "text/plain");
- aResponse.write(JSON.stringify(data));
- },
-
- _noteAndReturnString: function MDBS__noteAndReturnString(aKey, aValue,
- aString,
- aOptions) {
-
- aOptions = this._overrideDefault(kDefaultReturnHeader, aOptions);
- let self = this;
-
- 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(e) {
- dump("Failed to generate server response: " + e);
- }
- }
- return func;
- },
-
- _overrideDefault: function MDBS__overrideDefault(aDefault, aData) {
- if (aData === undefined)
- return aDefault;
-
- for (let param in aDefault) {
- if (param in aData)
- aDefault[param] = aData[param];
- }
- return aDefault;
- },
-
- _wireOAuth: function MDBS__wireOAuth() {
- let authFunc = this._noteAndReturnString("cloudfile:auth", "",
- kAuthTokenString);
-
- this._server.registerPathHandler(kServerPath + kOAuthTokenPath,
- authFunc);
- this._server.registerPathHandler(kServerPath + kOAuthAccessTokenPath,
- authFunc);
- this._server.registerPathHandler(kAuthPath + kOAuthAuthorizePath,
- this._authHandler);
-
- let logoutFunc = this._noteAndReturnString("cloudfile:logout", "",
- "Successfully logged out!");
- this._server.registerPathHandler(kLogoutPath, logoutFunc);
- },
-
- _authHandler: function MDBS__authHandler(meta, response) {
- response.setStatusLine(null, 302, "Found");
- response.setHeader("Location", "http://oauthcallback.local/",
- false);
- },
-}
-
-function parseQueryString(str)
-{
- let paramArray = str.split("&");
- let regex = /^([^=]+)=(.*)$/;
- let params = {};
- for (let i = 0; i < paramArray.length; i++)
- {
- let match = regex.exec(paramArray[i]);
- if (!match)
- throw "Bad parameter in queryString! '" + paramArray[i] + "'";
- params[decodeURIComponent(match[1])] = decodeURIComponent(match[2]);
- }
-
- return params;
-}
--- a/mail/test/mozmill/shared-modules/test-cloudfile-ubuntuone-helpers.js
+++ b/mail/test/mozmill/shared-modules/test-cloudfile-ubuntuone-helpers.js
@@ -133,17 +133,17 @@ MockUbuntuOneServer.prototype = {
},
stop: function MU1S_stop(aController) {
let allDone = false;
this._server.stop(function() {
allDone = true;
});
aController.waitFor(function () allDone,
- "Timed out waiting for Dropbox server to stop!",
+ "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));
},
--- a/mail/themes/gnomestripe/jar.mn
+++ b/mail/themes/gnomestripe/jar.mn
@@ -250,11 +250,10 @@ 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/dropbox.png (mail/icons/dropbox.png)
skin/classic/messenger/icons/ubuntuone.png (mail/icons/ubuntuone.png)
skin/classic/messenger/icons/yousendit.png (mail/icons/yousendit.png)
deleted file mode 100644
index 05503833f7114aa1c8efddebc944a35bc3dbb126..0000000000000000000000000000000000000000
GIT binary patch
literal 0
Hc$@<O00001
--- a/mail/themes/pinstripe/jar.mn
+++ b/mail/themes/pinstripe/jar.mn
@@ -295,11 +295,10 @@ 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/dropbox.png (mail/icons/dropbox.png)
skin/classic/messenger/icons/ubuntuone.png (mail/icons/ubuntuone.png)
skin/classic/messenger/icons/yousendit.png (mail/icons/yousendit.png)
deleted file mode 100644
index 05503833f7114aa1c8efddebc944a35bc3dbb126..0000000000000000000000000000000000000000
GIT binary patch
literal 0
Hc$@<O00001
--- a/mail/themes/qute/jar.mn
+++ b/mail/themes/qute/jar.mn
@@ -258,17 +258,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/dropbox.png (mail/icons/dropbox.png)
skin/classic/messenger/icons/ubuntuone.png (mail/icons/ubuntuone.png)
skin/classic/messenger/icons/yousendit.png (mail/icons/yousendit.png)
#ifdef XP_WIN
% skin communicator classic/1.0 %skin/classic/aero/communicator/ os=WINNT osversion>=6
skin/classic/aero/communicator/communicator.css (mail/communicator.css)
skin/classic/aero/communicator/smileys.css (mail/smileys.css)
skin/classic/aero/communicator/icons/smileys/smiley-smile.png (mail/icons/smiley-smile-aero.png)
skin/classic/aero/communicator/icons/smileys/smiley-frown.png (mail/icons/smiley-frown-aero.png)
@@ -511,12 +510,11 @@ 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/dropbox.png (mail/icons/dropbox.png)
skin/classic/aero/messenger/icons/ubuntuone.png (mail/icons/ubuntuone.png)
skin/classic/aero/messenger/icons/yousendit.png (mail/icons/yousendit.png)
#endif
deleted file mode 100644
index 05503833f7114aa1c8efddebc944a35bc3dbb126..0000000000000000000000000000000000000000
GIT binary patch
literal 0
Hc$@<O00001