mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Asynchronous bookmark sharing (bug 449113, r=thunder)
This commit is contained in:
parent
691d0bae83
commit
8d3528d073
@ -253,6 +253,14 @@ DAVCollection.prototype = {
|
||||
return this._makeRequest.async(this, onComplete, "POST", path,
|
||||
this._defaultHeaders, data);
|
||||
},
|
||||
|
||||
formPost: function DC_formPOST(path, data, onComplete) {
|
||||
let headers = {'Content-type': 'application/x-www-form-urlencoded'};
|
||||
headers.__proto__ = this._defaultHeaders;
|
||||
|
||||
return this._makeRequest.async(this, onComplete, "POST", path,
|
||||
headers, data);
|
||||
},
|
||||
|
||||
PUT: function DC_PUT(path, data, onComplete) {
|
||||
return this._makeRequest.async(this, onComplete, "PUT", path,
|
||||
|
@ -20,6 +20,7 @@
|
||||
* Contributor(s):
|
||||
* Dan Mills <thunder@mozilla.com>
|
||||
* Jono DiCarlo <jdicarlo@mozilla.org>
|
||||
* Anant Narayanan <anant@kix.in>
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
@ -290,6 +291,34 @@ BookmarksSharingManager.prototype = {
|
||||
self.done( true );
|
||||
},
|
||||
|
||||
/* FIXME! Gets all shares, not just the new ones. Doesn't impact
|
||||
functionality because _incomingShareOffer does not create
|
||||
duplicates, but annoys the user by showing notification of ALL
|
||||
shares on EVERY sync :(
|
||||
*/
|
||||
getNewShares: function BmkSharing_getNewShares(onComplete) {
|
||||
this._getNewShares.async(this, onComplete);
|
||||
},
|
||||
_getNewShares: function BmkSharing__getNewShares() {
|
||||
let self = yield;
|
||||
|
||||
let sharingApi = new Sharing.Api( DAV );
|
||||
let result = yield sharingApi.getShares(self.cb);
|
||||
|
||||
this._log.info("Got Shares: " + result);
|
||||
let shares = result.split(',');
|
||||
if (shares.length > 1) {
|
||||
this._log.info('Found shares');
|
||||
for (var i = 0; i < shares.length - 1; i++) {
|
||||
let share = shares[i].split(':');
|
||||
let name = share[0];
|
||||
let user = share[1];
|
||||
let path = share[2];
|
||||
this._incomingShareOffer(user, '/user/' + user + '/' + path, name);
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
updateAllIncomingShares: function BmkSharing_updateAllIncoming(onComplete) {
|
||||
this._updateAllIncomingShares.async(this, onComplete);
|
||||
},
|
||||
@ -436,8 +465,9 @@ BookmarksSharingManager.prototype = {
|
||||
// Call Atul's js api for setting htaccess:
|
||||
let sharingApi = new Sharing.Api( DAV );
|
||||
let result = yield sharingApi.shareWithUsers( serverPath,
|
||||
[username],
|
||||
[username], folderName,
|
||||
self.cb );
|
||||
this._log.info(result.errorText);
|
||||
// return the server path:
|
||||
self.done( serverPath );
|
||||
},
|
||||
@ -725,6 +755,7 @@ BookmarksEngine.prototype = {
|
||||
/* After syncing the regular bookmark folder contents,
|
||||
* also update both the incoming and outgoing shared folders. */
|
||||
let self = yield;
|
||||
let ret = yield this._sharing.getNewShares(self.cb);
|
||||
this.__proto__.__proto__._sync.async(this, self.cb );
|
||||
yield;
|
||||
this._sharing.updateAllOutgoingShares(self.cb);
|
||||
|
@ -19,6 +19,7 @@
|
||||
*
|
||||
* Contributor(s):
|
||||
* Atul Varma <varmaa@toolness.com>
|
||||
* Anant Narayanan <anant@kix.in>
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
@ -50,14 +51,29 @@ function Api(dav) {
|
||||
}
|
||||
|
||||
Api.prototype = {
|
||||
shareWithUsers: function Api_shareWithUsers(path, users, onComplete) {
|
||||
this._shareGenerator.async(this,
|
||||
shareWithUsers: function Api_shareWithUsers(path, users, folder, onComplete) {
|
||||
return this._shareGenerator.async(this,
|
||||
onComplete,
|
||||
path,
|
||||
users);
|
||||
users, folder);
|
||||
},
|
||||
|
||||
_shareGenerator: function Api__shareGenerator(path, users) {
|
||||
getShares: function Api_getShares(onComplete) {
|
||||
return this._getShareGenerator.async(this, onComplete);
|
||||
},
|
||||
|
||||
_getShareGenerator: function Api__getShareGenerator() {
|
||||
let self = yield;
|
||||
let id = ID.get(this._dav.identity);
|
||||
|
||||
this._dav.formPost("/api/share/get.php", ("uid=" + escape(id.username) +
|
||||
"&password=" + escape(id.password)),
|
||||
self.cb);
|
||||
let xhr = yield;
|
||||
self.done(xhr.responseText);
|
||||
},
|
||||
|
||||
_shareGenerator: function Api__shareGenerator(path, users, folder) {
|
||||
let self = yield;
|
||||
let id = ID.get(this._dav.identity);
|
||||
|
||||
@ -67,10 +83,11 @@ Api.prototype = {
|
||||
let jsonSvc = Cc["@mozilla.org/dom/json;1"].createInstance(Ci.nsIJSON);
|
||||
let json = jsonSvc.encode(cmd);
|
||||
|
||||
this._dav.POST("/api/share/",
|
||||
this._dav.formPost("/api/share/",
|
||||
("cmd=" + escape(json) +
|
||||
"&uid=" + escape(id.username) +
|
||||
"&password=" + escape(id.password)),
|
||||
"&password=" + escape(id.password) +
|
||||
"&name=" + escape(folder)),
|
||||
self.cb);
|
||||
let xhr = yield;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user