diff --git a/README.md b/README.md
index 242b587..915aee6 100644
--- a/README.md
+++ b/README.md
@@ -6,7 +6,7 @@
[Nextcloud](https://nextcloud.com) is the premiere and safest, Enterprise-ready, Open Source File Sync and Share solution
-["Nextcloud for Filelink"](https://github.com/nextcloud/nextcloud-filelink) is a Thunderbird extension which makes it easy to send large attachments with Thunderbird by uploading them first to a Nextcloud server and by then inserting the link into the body of your email.
+["Nextcloud for Filelink"](https://addons.mozilla.org/thunderbird/addon/nextcloud-filelink/) is a Thunderbird extension which makes it easy to send large attachments with Thunderbird by uploading them first to a Nextcloud server and by then inserting the link into the body of your email.
It is currently possible to upload files as large as 1GB.
diff --git a/src/chrome/content/management.xhtml b/src/chrome/content/management.xhtml
index 00f8d6c..4373044 100644
--- a/src/chrome/content/management.xhtml
+++ b/src/chrome/content/management.xhtml
@@ -31,9 +31,9 @@
]>
-
-
' +
- ' ' +
- ' ' +
- '' +
- '';
- let req = Cc["@mozilla.org/xmlextras/xmlhttprequest;1"].createInstance(
- Ci.nsIXMLHttpRequest);
+ let args = "?format=json";
+ let req = new XMLHttpRequest(Ci.nsIXMLHttpRequest);
+
+ req.open("GET", this._fullUrl + kAuthPath + args, true);
+ req.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
+ req.setRequestHeader("OCS-APIREQUEST", "true");
+ req.setRequestHeader("Authorization",
+ "Basic " + btoa(this._userName + ':' + this._password));
- req.open("PROPFIND", this._fullUrl + kWebDavPath, true,
- this._userName, this._password);
req.onerror = function () {
this.log.info("logon failure");
failureCallback();
@@ -587,40 +589,46 @@ Nextcloud.prototype = {
req.onload = function () {
if (req.status >= 200 && req.status < 400) {
- this._fileSpaceUsed = this._getQuota(req.responseXML, "quota-used-bytes");
- if (this._fileSpaceUsed < 0) {
- this._fileSpaceUsed = -1;
- }
+ try {
+ this.log.info("auth token response = " + req.responseText);
- let spaceAvailable = this._getQuota(req.responseXML, "quota-available-bytes");
+ let docResponse = JSON.parse(req.responseText);
+
+ let statuscode = docResponse.ocs.meta.statuscode;
- if (spaceAvailable && spaceAvailable > -1) { // positive numbers
- this._totalStorage = spaceAvailable + this._fileSpaceUsed;
- } else if (!spaceAvailable && spaceAvailable !== 0) { // 0 and unequal 0
- this._totalStorage = -1;
- } else if (!spaceAvailable || spaceAvailable < 0) { // 0 or negative
- this._totalStorage = 0;
+ this.log.info("statuscode = " + statuscode);
+
+ if (statuscode == 100) {
+ this._fileSpaceUsed = docResponse.ocs.data.quota.used;
+ if (this._fileSpaceUsed < 0) {
+ this._fileSpaceUsed = -1;
+ }
+
+ let spaceAvailable = docResponse.ocs.data.quota.free;
+
+ if (spaceAvailable && spaceAvailable > -1) { // positive numbers
+ this._totalStorage = spaceAvailable + this._fileSpaceUsed;
+ } else if (!spaceAvailable && spaceAvailable !== 0) { // 0 and unequal 0
+ this._totalStorage = -1;
+ } else if (!spaceAvailable || spaceAvailable < 0) { // 0 or negative
+ this._totalStorage = 0;
+ }
+ successCallback();
+ } else {
+ failureCallback();
+ }
+ } catch (e) {
+ this.log.error(e);
+ this._loggedIn = false;
+ failureCallback();
}
- successCallback();
- } else {
+ }
+ else {
failureCallback();
}
}.bind(this);
- req.send(body);
- },
-
- /**
- * Retrieves quota information from a WebDAV response
- *
- * @param req
- * @param davVariable
- * @returns {NodeList|number}
- * @private
- */
- _getQuota: function nsNc_getUserQuota (req, davVariable) {
- let quota = req.documentElement.getElementsByTagNameNS("DAV:", davVariable);
- return quota && quota.length && Number(quota[0].textContent) || -1;
+ req.send();
},
/**
@@ -638,12 +646,14 @@ Nextcloud.prototype = {
'' +
'';
- let req = Cc["@mozilla.org/xmlextras/xmlhttprequest;1"]
- .createInstance(Ci.nsIXMLHttpRequest);
+ let req = new XMLHttpRequest(Object.assign({mozAnon: true}, Ci.nsIXMLHttpRequest));
req.open("PROPFIND", this._fullUrl + kWebDavPath +
- ("/" + this._storageFolder + "/").replace(/\/+/g, '/'), true, this._userName,
- this._password);
+ ("/" + this._storageFolder + "/").replace(/\/+/g, '/'), true);
+
+ req.setRequestHeader("Authorization",
+ "Basic " + btoa(this._userName + ':' + this._password));
+
req.onerror = function () {
this.log.info("Failed to check if folder exists");
callback(false);
@@ -674,12 +684,13 @@ Nextcloud.prototype = {
*/
_createFolder: function createFolder(callback) {
if (this._storageFolder !== '/') {
- let req = Cc["@mozilla.org/xmlextras/xmlhttprequest;1"]
- .createInstance(Ci.nsIXMLHttpRequest);
+ let req = new XMLHttpRequest(Object.assign({mozAnon: true}, Ci.nsIXMLHttpRequest));
req.open("MKCOL", this._fullUrl + kWebDavPath +
- ("/" + this._storageFolder + "/").replace(/\/+/g, '/'), true, this._userName,
- this._password);
+ ("/" + this._storageFolder + "/").replace(/\/+/g, '/'), true);
+
+ req.setRequestHeader("Authorization",
+ "Basic " + btoa(this._userName + ':' + this._password));
req.onload = function () {
if (req.status === 201) {
@@ -778,13 +789,22 @@ NextcloudFileUploader.prototype = {
bufStream = bufStream.QueryInterface(Ci.nsIInputStream);
let contentLength = fstream.available();
- let req = Cc["@mozilla.org/xmlextras/xmlhttprequest;1"].createInstance(
- Ci.nsIXMLHttpRequest);
+ let password = this.nextcloud.getPassword(this.nextcloud._userName, false);
- req.open("PUT", url, true, this._userName, this._password);
+ if (password === "") {
+ this.log.error("Could not upload file. Password is not set");
+ return;
+ }
+
+ let req = new XMLHttpRequest(Object.assign({mozAnon: true}, Ci.nsIXMLHttpRequest));
+
+ req.open("PUT", url, true);
+
+ req.setRequestHeader("Authorization",
+ "Basic " + btoa(this.nextcloud._userName + ':' + password));
req.onerror = function () {
- this.log.info("Could not upload file");
+ this.log.error("Could not upload file");
if (this.callback) {
this.callback(this.requestObserver,
Ci.nsIMsgCloudFileProvider.uploadErr);
@@ -803,7 +823,11 @@ NextcloudFileUploader.prototype = {
}.bind(this);
req.setRequestHeader("Content-Length", contentLength);
- req.send(bufStream);
+ if (req.sendInputStream) { // Fix for old TB
+ req.sendInputStream(bufStream);
+ } else {
+ req.send(bufStream);
+ }
},
/**
@@ -835,8 +859,7 @@ NextcloudFileUploader.prototype = {
this.file = aFile;
let shareType = 3;
let args = "?format=json";
- let req = Cc["@mozilla.org/xmlextras/xmlhttprequest;1"]
- .createInstance(Ci.nsIXMLHttpRequest);
+ let req = new XMLHttpRequest(Ci.nsIXMLHttpRequest);
let path = wwwFormUrlEncode(
("/" + this.nextcloud._storageFolder + "/").replace(/\/+/g, '/') +
this._fileUploadTS[this.file.path] + "_" + this.file.leafName);
diff --git a/src/install.rdf b/src/install.rdf
index c118885..cef9e81 100644
--- a/src/install.rdf
+++ b/src/install.rdf
@@ -6,7 +6,7 @@
owncloud@viguierjust.com
Nextcloud for Filelink
- 1.6
+ 1.8
2
Olivier Paroz
Philipp Kewisch
@@ -21,7 +21,7 @@
{3550f703-e582-4d05-9a08-453d09bdfdc6}
17.0
- 45.*
+ 60.*