summaryrefslogtreecommitdiffstats
path: root/comm/mailnews/base/public/nsIMsgFolderCache.idl
blob: b5ba40afdc2da1ebc2a174375c1b2ea5e2713949 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
/* -*- Mode: IDL; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* 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/. */

#include "nsISupports.idl"

interface nsIFile;
interface nsIMsgFolderCacheElement;

/**
 * nsIMsgFolderCache is a store of values which might be slow for the folder
 * to calculate. For example: the number of unread messages.
 * The account manager holds the cache, and each folder manipulates its cached
 * properties via nsIMsgFolderCacheElement.
 */
[scriptable, uuid(78C2B6A2-E29F-44de-9543-10DBB51E245C)]
interface nsIMsgFolderCache : nsISupports
{
  /**
   * Set up the cache, loading/saving to cacheFile.
   * If a new-style cacheFile isn't found, it looks for an old panacea.dat,
   * specified by legacyFile and migrates it to the new format.
   * Neither file has to exist - it'll just start up with an empty cache.
   * nsMsgFolderCache (the only implementation) will autosave to cacheFile
   * when changes are made.
   *
   * @param cacheFile   File to persist the cache data (folderCache.json).
   * @param legacyFile  Old panacea.dat file to check for and migrate, if
   *                    cacheFile doesn't exist.
   */
  void init(in nsIFile cacheFile, in nsIFile legacyFile);

  /**
   * Return an nsIMsgFolderCacheElement for a given folder.
   * Unless createIfMissing is set, a missing entry will cause failure.
   */
  nsIMsgFolderCacheElement getCacheElement(in ACString key, in boolean createIfMissing);
  void removeElement(in ACString key);

  /**
   * Write immediately to cacheFile if any data has been changed.
   * Write immediately to cacheFile if any data has been changed.
   * This happens in the cache dtor anyway, but we use it during shutdown and
   * in unit testing (so tests don't have to wait for JS garbage collection).
   */
  void flush();
};