Pergunta

1) Open a new tab with the

document.getElementById("tabmail").openTab("chromeTab", {
    chromePage: “indexWithGloda.html”,
});

2) The file indexWithGloda.html has a button with an onlick even that should start the indexing.

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;
}

The problem is that the call GlodaMsgIndexer._worker_folderIndex(job); in function onClickStartIndexingWithGloda() does not really start the indexing. I guess it should be called in some asynchronous manner but I do not know how to start it asynchronously. I would very much appreciate any help here. One more question, would this method work if the folder is already indexed? If not, what is necessary to do to re-index an already indexed folder?

Foi útil?

Solução

Whether a folder is indexed or not depends on:

  • the user's global preference (mailnews.database.global.indexer.enabled)
  • the per-folder preferences that are accessible by right-clicking a folder, then hitting properties, and selecting "include this folder in global search results".

So I don't think you should force Gloda into indexing a folder: Gloda is able to automatically figure whenever messages are added to a folder, and index them accordingly.

Could you please tell me a little bit more about what it is that you're trying to achieve?

Edit: the links you're looking for are probably

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top