Bug 1762688 - Enable test_imapHdrStreaming.js for imap-js. r=mkmelin

Implement ImapMessageService.streamHeaders.

Differential Revision: https://phabricator.services.mozilla.com/D156290

--HG--
extra : amend_source : ba049620bba035e311e0769b3414719f7fb0dbcd
This commit is contained in:
Ping Chen 2022-09-06 20:02:35 +10:00
Родитель 29e3693d47
Коммит d5b368e0ea
4 изменённых файлов: 42 добавлений и 2 удалений

Просмотреть файл

@ -194,6 +194,47 @@ class BaseMessageService {
);
}
streamHeaders(messageUri, consumer, urlListener, localOnly) {
this._logger.debug("streamHeaders", messageUri);
let { host, folderName, key } = this._decomposeMessageUri(messageUri);
let folder = lazy.MailUtils.getOrCreateFolder(
`imap://${host}/${folderName}`
);
let hasMsgOffline = folder.hasMsgOffline(key);
if (!hasMsgOffline) {
return;
}
let localMsgStream = folder.getLocalMsgStream(folder.GetMessageHeader(key));
let sstream = Cc["@mozilla.org/scriptableinputstream;1"].createInstance(
Ci.nsIScriptableInputStream
);
sstream.init(localMsgStream);
let headers = "";
let str = "";
do {
str = sstream.read(4096);
let index = str.indexOf("\r\n\r\n");
if (index != -1) {
headers += str.slice(0, index) + "\r\n";
break;
} else {
headers += str;
}
} while (str.length);
let headersStream = Cc[
"@mozilla.org/io/string-input-stream;1"
].createInstance(Ci.nsIStringInputStream);
headersStream.setData(headers, headers.length);
let pump = Cc["@mozilla.org/network/input-stream-pump;1"].createInstance(
Ci.nsIInputStreamPump
);
pump.init(headersStream, 0, 0, true);
pump.asyncRead(consumer);
}
messageURIToMsgHdr(messageUri) {
let { host, folderName, key } = this._decomposeMessageUri(messageUri);
let folder = lazy.MailUtils.getOrCreateFolder(

Просмотреть файл

@ -12,7 +12,6 @@ prefs =
[test_imapAutoSync.js]
[test_imapClientid.js]
[test_imapHdrChunking.js]
[test_imapHdrStreaming.js]
[test_imapHighWater.js]
[test_imapID.js]
[test_imapMove.js]

Просмотреть файл

@ -20,6 +20,7 @@
[test_imapFilterActionsPostplugin.js]
[test_imapFlagChange.js]
[test_imapFolderCopy.js]
[test_imapHdrStreaming.js]
[test_imapPasswordFailure.js]
[test_mailboxes.js]
[test_starttlsFailure.js]

Просмотреть файл

@ -11,7 +11,6 @@ prefs =
[test_gmailAttributes.js]
[test_imapAutoSync.js]
[test_imapHdrChunking.js]
[test_imapHdrStreaming.js]
[test_imapHighWater.js]
[test_imapID.js]
[test_imapMove.js]