Bug 1762688 - Enable test_imapStatusCloseDBs for imap-js. r=mkmelin
Implement nsIMsgProtocolInfo in ImapProtocolInfo.jsm. Differential Revision: https://phabricator.services.mozilla.com/D157192 --HG-- extra : moz-landing-system : lando
This commit is contained in:
Родитель
8bfea5ca02
Коммит
867d68bc49
|
@ -87,9 +87,14 @@ class ImapIncomingServer extends MsgIncomingServer {
|
|||
}
|
||||
|
||||
closeCachedConnections() {
|
||||
// Close all connections.
|
||||
for (let client of [...this._freeConnections, ...this._busyConnections]) {
|
||||
client.logout();
|
||||
}
|
||||
// Cancel all waitings in queue.
|
||||
for (let resolve of this._connectionWaitingQueue) {
|
||||
resolve(false);
|
||||
}
|
||||
this._freeConnections = [];
|
||||
this._busyConnections = [];
|
||||
}
|
||||
|
@ -437,9 +442,14 @@ class ImapIncomingServer extends MsgIncomingServer {
|
|||
this._busyConnections.push(client);
|
||||
return client;
|
||||
}
|
||||
// Wait until a connection is available.
|
||||
await new Promise(resolve => this._connectionWaitingQueue.push(resolve));
|
||||
return this._getNextClient();
|
||||
// Wait until a connection is available. canGetNext is false when
|
||||
// closeCachedConnections is called.
|
||||
let canGetNext = await new Promise(resolve =>
|
||||
this._connectionWaitingQueue.push(resolve)
|
||||
);
|
||||
if (canGetNext) {
|
||||
return this._getNextClient();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -449,13 +459,16 @@ class ImapIncomingServer extends MsgIncomingServer {
|
|||
*/
|
||||
async withClient(handler) {
|
||||
let client = await this._getNextClient();
|
||||
if (!client) {
|
||||
return;
|
||||
}
|
||||
client.onDone = async () => {
|
||||
this._busyConnections = this._busyConnections.filter(c => c != client);
|
||||
this._freeConnections.push(client);
|
||||
let resolve = this._connectionWaitingQueue.shift();
|
||||
if (resolve) {
|
||||
// Resovle the first waiting in queue.
|
||||
resolve();
|
||||
resolve(true);
|
||||
} else if (
|
||||
!this._busyConnections.length &&
|
||||
this.useIdle &&
|
||||
|
|
|
@ -45,6 +45,11 @@ var imapJSModules = [
|
|||
"{ebb06c58-6ccd-4bde-9087-40663e0388ae}",
|
||||
"@mozilla.org/network/protocol;1?name=imap",
|
||||
],
|
||||
[
|
||||
"ImapProtocolInfo",
|
||||
"{1d9473bc-423a-4632-ad5d-802154e80f6f}",
|
||||
"@mozilla.org/messenger/protocol/info;1?type=imap",
|
||||
],
|
||||
];
|
||||
|
||||
ImapModuleLoader.prototype = {
|
||||
|
|
|
@ -0,0 +1,79 @@
|
|||
/* 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 EXPORTED_SYMBOLS = ["ImapProtocolInfo"];
|
||||
|
||||
/**
|
||||
* @implements {nsIMsgProtocolInfo}
|
||||
*/
|
||||
class ImapProtocolInfo {
|
||||
QueryInterface = ChromeUtils.generateQI(["nsIMsgProtocolInfo"]);
|
||||
|
||||
serverIID = Components.ID("{b02a4e1c-0d9e-498c-8b9d-18917ba9f65b}");
|
||||
|
||||
requiresUsername = true;
|
||||
preflightPrettyNameWithEmailAddress = true;
|
||||
canDelete = true;
|
||||
canLoginAtStartUp = true;
|
||||
canDuplicate = true;
|
||||
canGetMessages = true;
|
||||
canGetIncomingMessages = true;
|
||||
defaultDoBiff = true;
|
||||
showComposeMsgLink = true;
|
||||
foldersCreatedAsync = false;
|
||||
|
||||
get defaultLocalPath() {
|
||||
let file = this._getFileValue("mail.root.imap-rel", "mail.root.imap");
|
||||
if (!file) {
|
||||
file = Services.dirsvc.get("MailD", Ci.nsIFile);
|
||||
this._setFileValue("mail.root.imap-rel", "mail.root.imap", file);
|
||||
}
|
||||
if (!file.exists()) {
|
||||
file.createUnique(Ci.nsIFile.DIRECTORY_TYPE, 0o775);
|
||||
}
|
||||
return file;
|
||||
}
|
||||
|
||||
set defaultLocalPath(value) {
|
||||
this._setFileValue("mail.root.imap-rel", "mail.root.imap", value);
|
||||
}
|
||||
|
||||
getDefaultServerPort(isSecure) {
|
||||
return isSecure
|
||||
? Ci.nsIImapUrl.DEFAULT_IMAPS_PORT
|
||||
: Ci.nsIImapUrl.DEFAULT_IMAP_PORT;
|
||||
}
|
||||
|
||||
_getFileValue(relPrefName, absPrefName) {
|
||||
try {
|
||||
return Services.prefs.getComplexValue(relPrefName, Ci.nsIRelativeFilePref)
|
||||
.file;
|
||||
} catch (e) {
|
||||
try {
|
||||
let file = Services.prefs.getComplexValue(absPrefName, Ci.nsIFile);
|
||||
Services.prefs.setComplexValue(relPrefName, Ci.nsIRelativeFilePref, {
|
||||
QueryInterface: ChromeUtils.generateQI(["nsIRelativeFilePref"]),
|
||||
file,
|
||||
relativeToKey: "ProfD",
|
||||
});
|
||||
return file;
|
||||
} catch (e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
_setFileValue(relPrefName, absPrefName, file) {
|
||||
Services.prefs.setComplexValue(relPrefName, Ci.nsIRelativeFilePref, {
|
||||
QueryInterface: ChromeUtils.generateQI(["nsIRelativeFilePref"]),
|
||||
file,
|
||||
relativeToKey: "ProfD",
|
||||
});
|
||||
Services.prefs.setComplexValue(absPrefName, Ci.nsIFile, file);
|
||||
}
|
||||
}
|
||||
|
||||
ImapProtocolInfo.prototype.classID = Components.ID(
|
||||
"{1d9473bc-423a-4632-ad5d-802154e80f6f}"
|
||||
);
|
|
@ -45,6 +45,7 @@ EXTRA_JS_MODULES += [
|
|||
"ImapMessageService.jsm",
|
||||
"ImapModuleLoader.jsm",
|
||||
"ImapProtocolHandler.jsm",
|
||||
"ImapProtocolInfo.jsm",
|
||||
"ImapResponse.jsm",
|
||||
"ImapService.jsm",
|
||||
"ImapUtils.jsm",
|
||||
|
|
|
@ -12,7 +12,6 @@ prefs =
|
|||
[test_imapAutoSync.js]
|
||||
[test_imapHdrChunking.js]
|
||||
[test_imapHighWater.js]
|
||||
[test_imapStatusCloseDBs.js]
|
||||
[test_imapUndo.js]
|
||||
[test_listClosesDB.js]
|
||||
[test_listSubscribed.js]
|
||||
|
|
|
@ -29,6 +29,7 @@
|
|||
[test_imapProxy.js]
|
||||
[test_imapRename.js]
|
||||
[test_imapSearch.js]
|
||||
[test_imapStatusCloseDBs.js]
|
||||
[test_imapStoreMsgOffline.js]
|
||||
[test_imapUrls.js]
|
||||
[test_largeOfflineStore.js]
|
||||
|
|
|
@ -12,7 +12,6 @@ prefs =
|
|||
[test_imapAutoSync.js]
|
||||
[test_imapHdrChunking.js]
|
||||
[test_imapHighWater.js]
|
||||
[test_imapStatusCloseDBs.js]
|
||||
[test_imapUndo.js]
|
||||
[test_listClosesDB.js]
|
||||
[test_listSubscribed.js]
|
||||
|
|
Загрузка…
Ссылка в новой задаче