1) 打开一个新标签页
document.getElementById("tabmail").openTab("chromeTab", {
chromePage: “indexWithGloda.html”,
});
2)该文件indexWithGloda.html
有一个带有onlick的按钮,即使它应该开始索引。
function onClickStartIndexingWithGloda()
{
var inboxFolder = getInboxFolder(); // Find the inbox folder
GlodaMsgIndexer.indexFolder(inboxFolder, ["force"]);
var job = GlodaIndexer._indexQueue.pop();
GlodaMsgIndexer._worker_folderIndex(job);
}
// Adding a messenger lazy getter to the MailServices even though it's not a service
XPCOMUtils.defineLazyGetter(MailServices, "messenger", function () {
return Cc["@mozilla.org/messenger;1"].createInstance(Ci.nsIMessenger);
});
function getInboxFolder() {
var inbox = null;
var accounts = [x for each (x in fixIterator(MailServices.accounts.accounts, Ci.nsIMsgAccount))].filter(function (x) x.incomingServer);
var server = accounts[0].incomingServer;
var folder = server.rootFolder;
var searchForInbox = function(folder) {
var isInbox = folder.getFlag(Ci.nsMsgFolderFlags.Inbox);
if (isInbox) {
inbox = folder;
}
else if (folder.hasSubFolders) {
for each (var subFolder in fixIterator(folder.subFolders, Ci.nsIMsgFolder))
searchForInbox(subFolder);
}
}
searchForInbox(folder);
return inbox;
}
问题是GlodaMsgIndexer._worker_folderIndex(job);
函数调用onClickStartIndexingWithGloda()
并没有真正开始索引。我想它应该以某种异步方式调用,但我不知道如何异步启动它。我非常感谢这里的任何帮助。还有一个问题,如果文件夹已经被索引,这种方法会起作用吗?如果没有,需要做什么来重新索引一个已经建立索引的文件夹?