Publish Vulpes Preview 15 sources for desktop, Android and Tundra

Share Gaia assets and adapters, keep private profiles and development documents local, and update both public READMEs.
This commit is contained in:
OverSu 2026-09-30 23:13:03 +02:00
commit b38dea0597
25901 changed files with 9982925 additions and 369 deletions

View file

@ -0,0 +1,45 @@
define([], function () {
function BodyFetcher(connection, parserClass, list) {
this.connection = connection;
this.parserClass = parserClass;
this.list = list;
this.pending = list.length;
this.onparsed = null;
this.onend = null;
list.forEach(this._fetch, this);
}
BodyFetcher.prototype = {
_fetch: function (request) {
this.connection.listMessages(request.uid, ['BODY.PEEK[' + (request.partInfo.partID || '1') + ']' + (request.bytes ? '<' + request.bytes[0] + '.' + request.bytes[1] + '>' : '')], { byUid: true }, function (err, messages) {
if (err) {
this._resolve(err, request, null);
} else {
var parser = new this.parserClass(request.partInfo);
var msg = messages[0];
var body = null;
for (var key in msg) {
if (/^body/.test(key)) {
body = msg[key];
break;
}
}
if (!body) {
this.resolve('no body', request);
} else {
parser.parse(body);
this._resolve(null, request, parser.complete());
}
}
}.bind(this));
},
_resolve: function (err, req, result) {
if (this.onparsed) {
this.onparsed(err, req, result);
}
if (!--this.pending && this.onend) {
this.onend();
}
}
};
return { BodyFetcher: BodyFetcher };
});

View file

@ -0,0 +1,29 @@
define(['./textparser'], function ($textparser) {
var TextParser = $textparser.TextParser;
function bufferAppend(buffer1, buffer2) {
var tmp = new Uint8Array(buffer1.byteLength + buffer2.byteLength);
tmp.set(new Uint8Array(buffer1), 0);
tmp.set(new Uint8Array(buffer2), buffer1.byteLength);
return tmp.buffer;
}
;
function SnippetParser(partDef) {
TextParser.apply(this, arguments);
}
SnippetParser.prototype = {
parse: function (buffer) {
if (!this._buffer) {
this._buffer = buffer;
} else {
this._buffer = bufferAppend(this._buffer, buffer);
}
TextParser.prototype.parse.apply(this, arguments);
},
complete: function () {
var content = TextParser.prototype.complete.apply(this, arguments);
content.buffer = this._buffer;
return content;
}
};
return { SnippetParser: SnippetParser };
});

View file

@ -0,0 +1,122 @@
define([
'../imapchew',
'../../allback',
'exports'
], function ($imapchew, allback, exports) {
var INITIAL_FETCH_PARAMS = [
'BODYSTRUCTURE',
'INTERNALDATE',
'FLAGS',
'BODY.PEEK[HEADER.FIELDS (FROM TO CC BCC SUBJECT REPLY-TO MESSAGE-ID REFERENCES)]'
];
var FLAG_FETCH_PARAMS = ['FLAGS'];
var SNIPPET_BYTES = 256;
var KNOWN_HEADERS_AGGR_COST = 20, KNOWN_HEADERS_PER_COST = 1, NEW_HEADERS_AGGR_COST = 20, NEW_HEADERS_PER_COST = 5, NEW_BODIES_PER_COST = 30;
function Sync(options) {
this.storage = options.storage;
this.connection = options.connection;
this.knownHeaders = options.knownHeaders || [];
this.knownUIDs = options.knownUIDs || [];
this.newUIDs = options.newUIDs || [];
this._progress = options.initialProgress || 0.25;
this._progressCost = (this.knownUIDs.length ? KNOWN_HEADERS_AGGR_COST : 0) + KNOWN_HEADERS_PER_COST * this.knownUIDs.length + (this.newUIDs.length ? NEW_HEADERS_AGGR_COST : 0) + NEW_HEADERS_PER_COST * this.newUIDs.length;
this.onprogress = null;
this.oncomplete = null;
this._beginSync();
}
Sync.prototype = {
_updateProgress: function (newProgress) {
this._progress += newProgress;
if (this.onprogress) {
this.onprogress(0.25 + 0.75 * (this._progress / this._progressCost));
}
},
_beginSync: function () {
var latch = allback.latch();
if (this.newUIDs.length) {
this._handleNewUids(latch.defer('new'));
}
if (this.knownUIDs.length) {
this._handleKnownUids(latch.defer('known'));
}
latch.then(function () {
if (!this.oncomplete) {
return;
}
this.oncomplete(this.newUIDs.length, this.knownUIDs.length);
}.bind(this));
},
_handleNewUids: function (callback) {
var pendingSnippets = [];
var self = this;
this.connection.listMessages(this.newUIDs, INITIAL_FETCH_PARAMS, { byUid: true }, function (err, messages) {
if (err) {
console.warn('New UIDs fetch error, ideally harmless:', err);
callback();
return;
}
var latch = allback.latch();
messages.forEach(function (msg) {
var recentIdx = msg.flags.indexOf('\\Recent');
if (recentIdx !== -1) {
msg.flags.splice(recentIdx, 1);
}
try {
var chewRep = $imapchew.chewHeaderAndBodyStructure(msg, self.storage.folderId, self.storage._issueNewHeaderId());
chewRep.header.bytesToDownloadForBodyDisplay = $imapchew.calculateBytesToDownloadForImapBodyDisplay(chewRep.bodyInfo);
pendingSnippets.push(chewRep);
self.storage.addMessageHeader(chewRep.header, chewRep.bodyInfo, latch.defer());
self.storage.addMessageBody(chewRep.header, chewRep.bodyInfo, latch.defer());
} catch (ex) {
console.warn('message problem, skipping message', ex, '\n', ex.stack);
}
}.bind(this));
latch.then(callback);
}.bind(this));
},
_handleKnownUids: function (callback) {
var self = this;
this.connection.listMessages(self.knownUIDs, FLAG_FETCH_PARAMS, { byUid: true }, function (err, messages) {
if (err) {
console.warn('Known UIDs fetch error, ideally harmless:', err);
callback();
return;
}
var latch = allback.latch();
messages.forEach(function (msg, i) {
console.log('FETCHED', i, 'known id', self.knownHeaders[i].id, 'known srvid', self.knownHeaders[i].srvid, 'actual id', msg.uid);
var recentIdx = msg.flags.indexOf('\\Recent');
if (recentIdx !== -1) {
msg.flags.splice(recentIdx, 1);
}
if (self.knownHeaders[i].srvid !== msg.uid) {
i = self.knownUIDs.indexOf(msg.uid);
if (i === -1) {
console.warn('Server fetch reports unexpected message:', msg.uid);
return;
}
}
var header = self.knownHeaders[i];
var sortedExistingFlags = header.flags.slice();
sortedExistingFlags.sort();
msg.flags.sort();
if (header.flags.indexOf('\\Seen') === -1 && msg.flags.indexOf('\\Seen') !== -1) {
self.storage.folderMeta.unreadCount--;
} else if (header.flags.indexOf('\\Seen') !== -1 && msg.flags.indexOf('\\Seen') === -1) {
self.storage.folderMeta.unreadCount++;
}
if (header.flags.toString() !== msg.flags.toString()) {
console.warn(' FLAGS: "' + header.flags.toString() + '" VS "' + msg.flags.toString() + '"');
header.flags = msg.flags;
self.storage.updateMessageHeader(header.date, header.id, true, header, null, latch.defer());
} else {
self.storage.unchangedMessageHeader(header);
}
});
self._updateProgress(KNOWN_HEADERS_AGGR_COST + KNOWN_HEADERS_PER_COST * self.knownUIDs.length);
latch.then(callback);
}.bind(this));
}
};
exports.Sync = Sync;
});

View file

@ -0,0 +1,41 @@
define([
'mimeparser',
'mimefuncs',
'exports'
], function (MimeParser, mimefuncs, exports) {
function TextParser(partDef) {
this._partDef = partDef;
var parser = this._parser = new MimeParser();
this._totalBytes = 0;
var charsetPart = '', formatPart = '';
if (partDef.params && partDef.params.charset) {
charsetPart = '; charset="' + partDef.params.charset.toLowerCase() + '"';
}
if (partDef.params && partDef.params.format) {
formatPart = '; format="' + partDef.params.format.toLowerCase() + '"';
}
parser.write('Content-Type: ' + partDef.type.toLowerCase() + '/' + partDef.subtype.toLowerCase() + charsetPart + formatPart + '\r\n');
if (partDef.encoding) {
parser.write('Content-Transfer-Encoding: ' + partDef.encoding + '\r\n');
}
parser.write('\r\n');
if (partDef.pendingBuffer) {
this.parse(partDef.pendingBuffer);
}
}
TextParser.prototype = {
parse: function (buffer) {
this._totalBytes += buffer.length;
this._parser.write(buffer);
},
complete: function () {
this._parser.end();
var str = mimefuncs.charset.decode(this._parser.node.content, 'utf-8');
return {
bytesFetched: this._totalBytes,
text: str
};
}
};
exports.TextParser = TextParser;
});