/* -*- 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"
#include "nsIFolderListener.idl"
#include "nsIMsgIncomingServer.idl"
#include "nsIMsgCopyServiceListener.idl"
#include "nsIUrlListener.idl"
#include "nsISimpleEnumerator.idl"

interface nsIMsgDBHdr;
interface nsIMsgWindow;
interface nsIMsgDatabase;
interface nsIDBFolderInfo;
interface nsIMsgFilterList;

interface nsIMsgFolderCacheElement;
interface nsITransport;
interface nsIFile;
interface nsIOutputStream;
interface nsIInputStream;
interface nsIFile;
interface nsIMsgIdentity;
interface nsIMsgThread;
interface nsIArray;
interface nsIMutableArray;
interface nsISupportsArray;
interface nsIMsgPluggableStore;

typedef long nsMsgBiffState;

// enumerated type for determining if a message has been replied to, forwarded, etc.
typedef long nsMsgDispositionState;
[scriptable, uuid(bc4c8fff-0352-4e28-abda-db7f86a9e5f6)]
interface nsIMsgFolder : nsISupports {

  const nsMsgBiffState nsMsgBiffState_NewMail = 0; // User has new mail waiting.
  const nsMsgBiffState nsMsgBiffState_NoMail =  1; // No new mail is waiting.
  const nsMsgBiffState nsMsgBiffState_Unknown = 2; // We dunno whether there is new mail.

  /// Returns an enumerator containing the messages within the current database.
  readonly attribute nsISimpleEnumerator messages;

  void startFolderLoading();
  void endFolderLoading();

  /* get new headers for db */
  void updateFolder(in nsIMsgWindow aWindow);

  readonly attribute AString prettiestName;

  /**
   * URL for this folder
   */
  readonly attribute ACString folderURL;

  /**
   * should probably move to the server
   */
  readonly attribute boolean showDeletedMessages;

  /**
   * this folder's parent server
   */
  readonly attribute nsIMsgIncomingServer server;

  /**
   * is this folder the "phantom" server folder?
   */
  readonly attribute boolean isServer;
  readonly attribute boolean canSubscribe;
  readonly attribute boolean canFileMessages;
  readonly attribute boolean noSelect;  // this is an imap no select folder
  readonly attribute boolean imapShared; // this is an imap shared folder
  readonly attribute boolean canDeleteMessages; // can't delete from imap read-only

  /**
   * does this folder allow subfolders?
   * for example, newsgroups cannot have subfolders, and the INBOX
   * on some IMAP servers cannot have subfolders
   */
  readonly attribute boolean canCreateSubfolders;

  /**
   * can you change the name of this folder?
   * for example, newsgroups
   * and some special folders can't be renamed
   */
  readonly attribute boolean canRename;

  readonly attribute boolean canCompact;

  /**
   * the phantom server folder
   */
  readonly attribute nsIMsgFolder rootFolder;

  /**
   * Get the server's list of filters. (Or in the case of news, the 
   * filter list for this newsgroup)
   * This list SHOULD be used for all incoming messages.
   *
   * Since the returned nsIMsgFilterList is mutable, it is not necessary to call
   * setFilterList after the filters have been changed.
   *
   * @param aMsgWindow  @ref msgwindow "The standard message window"
   * @return            The list of filters
   */
  nsIMsgFilterList getFilterList(in nsIMsgWindow msgWindow);

  /**
   * Set the server's list of filters.
   *
   * Note that this does not persist the filter list. To change the contents
   * of the existing filters, use getFilterList and mutate the values as
   * appopriate.
   *
   * @param aFilterList The new list of filters.
   */
  void setFilterList(in nsIMsgFilterList filterList);

  /**
   * Get user editable filter list. This does not have to be the same as
   * the filterlist above, typically depending on the users preferences.
   * The filters in this list are not processed, but only to be edited by
   * the user.
   * @see getFilterList
   *
   * @param aMsgWindow  @ref msgwindow "The standard message window"
   * @return            The list of filters
   */
  nsIMsgFilterList getEditableFilterList(in nsIMsgWindow aMsgWindow);

  /**
   * Set user editable filter list.
   * This does not persist the filterlist, @see setFilterList
   * @see getEditableFilterList
   * @see setFilterList
   *
   * @param aFilterList The new list of filters.
   */
  void setEditableFilterList(in nsIMsgFilterList aFilterList);

  void ForceDBClosed ();
  /**
   * Close and backup a folder database prior to reparsing
   *
   * @param  newName  New name of the corresponding message folder.
   *                  Used in rename to set the file name to match the renamed
   *                  folder. Set to empty to use the existing folder name.
   */
  void closeAndBackupFolderDB(in ACString newName);

  void Delete ();

  void deleteSubFolders(in nsIArray folders, in nsIMsgWindow msgWindow);
  void propagateDelete(in nsIMsgFolder folder, in boolean deleteStorage,
                       in nsIMsgWindow msgWindow);
  void recursiveDelete(in boolean deleteStorage, in nsIMsgWindow msgWindow);

  /**
   * Create a subfolder of the current folder with the passed in name.
   * For IMAP, this will be an async operation and the folder won't exist
   * until it is created on the server.
   *
   * @param folderName name of the folder to create.
   * @param msgWindow msgWindow to display status feedback in.
   *
   * @exception NS_MSG_FOLDER_EXISTS
   */
  void createSubfolder(in AString folderName, in nsIMsgWindow msgWindow);

  /**
   * Adds the subfolder with the passed name to the folder hierarchy.
   * This is used internally during folder discovery; It shouldn't be
   * used to create folders since it won't create storage for the folder,
   * especially for imap. Unless you know exactly what you're doing, you
   * should be using createSubfolder + getChildNamed or createLocalSubfolder.
   *
   * @param aFolderName Name of the folder to add.
   * @returns The folder added.
   */
  nsIMsgFolder addSubfolder(in AString aFolderName);

  /* this method ensures the storage for the folder exists.
    For local folders, it creates the berkeley mailbox if missing.
    For imap folders, it subscribes to the folder if it exists,
    or creates it if it doesn't exist
  */
  void createStorageIfMissing(in nsIUrlListener urlListener);

  /**
   * Compact this folder. For IMAP folders configured for offline use,
   * it will also compact the offline store, and the completed notification
   * will occur when the Expunge is finished, not the offline store compaction.
   *
   * @param aListener   Notified of completion, can be null.
   * @param aMsgWindow  For progress/status, can be null.
   */
  void compact(in nsIUrlListener aListener, in nsIMsgWindow aMsgWindow);
  /**
   * Compact all folders in the account corresponding to this folder/
   * Optionally compact their offline stores as well (imap/news)
   * 
   * @param aListener   Notified of completion, can be null.
   * @param aMsgWindow  For progress/status, can be null.
   * @param aCompactOfflineAlso  This controls whether we compact all 
   *                             offline stores as well.
   */
  void compactAll(in nsIUrlListener aListener, in nsIMsgWindow aMsgWindow,
                  in boolean aCompactOfflineAlso);

  void compactAllOfflineStores(in nsIUrlListener aListener,
                               in nsIMsgWindow aMsgWindow,
                               in nsIArray aOfflineFolderArray);

  void emptyTrash(in nsIMsgWindow aMsgWindow, in nsIUrlListener aListener);

  /**
   * change the name of the folder
   *
   * @param name the new name of the folder
   */
  void rename(in AString name, in nsIMsgWindow msgWindow);
  void renameSubFolders( in nsIMsgWindow msgWindow, in nsIMsgFolder oldFolder);

  AString generateUniqueSubfolderName(in AString prefix,
                                      in nsIMsgFolder otherFolder);

  void updateSummaryTotals(in boolean force);
  void summaryChanged();
  /**
   * get the total number of unread messages in this folder,
   * or in all subfolders
   *
   * @param deep if true, descends into all subfolders and gets a grand total
   */
  long getNumUnread(in boolean deep);

  /**
   * get the total number of messages in this folder,
   * or in all subfolders
   *
   * @param deep if true, descends into all subfolders and gets a grand total
   */
  long getTotalMessages(in boolean deep);

 /**
  * does this folder have new messages
  *
  */
  attribute boolean hasNewMessages;

  /**
   * return the first new message in the folder
   *
   */
  readonly attribute nsIMsgDBHdr firstNewMessage;

  /**
   * clear new status flag of all of the new messages
   */
  void clearNewMessages();

  readonly attribute unsigned long expungedBytes;

  /**
   * Can this folder be deleted?
   * For example, special folders and isServer folders cannot be deleted.
   */
  readonly attribute boolean deletable;

  /**
   * should we be displaying recipients instead of the sender?
   * for example, in the Sent folder, recipients are more relevant
   * than the sender
   */
  readonly attribute boolean displayRecipients;

  /**
   * used to determine if it will take a long time to download all
   * the headers in this folder - so that we can do folder notifications
   * synchronously instead of asynchronously
   */
  readonly attribute boolean manyHeadersToDownload;

  readonly attribute boolean requiresCleanup;
  void clearRequiresCleanup();

  /**
   * this should go into a news-specific interface
   */
  readonly attribute boolean knowsSearchNntpExtension;

  /**
   * this should go into a news-specific interface
   */
  readonly attribute boolean allowsPosting;

  readonly attribute ACString relativePathName;

  /**
   * size of this folder on disk (not including .msf file)
   * for imap, it's the sum of the size of the messages
   */
  attribute unsigned long sizeOnDisk;

  readonly attribute ACString username;
  readonly attribute ACString hostname;

  /**
   * Sets a flag on the folder. The known flags are defined in
   * nsMsgFolderFlags.h.
   *
   * @param flag  The flag to set on the folder.
   */
  void setFlag(in unsigned long flag);

  /**
   * Clears a flag on the folder. The known flags are defined in
   * nsMsgFolderFlags.h.
   *
   * @param flag  The flag to clear on the folder.
   */
  void clearFlag(in unsigned long flag);

  /**
   * Determines if a flag is set on the folder or not. The known flags are
   * defined in nsMsgFolderFlags.h.
   *
   * @param flag  The flag to check on the folder.
   * @return      True if the flag exists.
   */
  boolean getFlag(in unsigned long flag);

  /**
   * Toggles a flag on the folder. The known flags are defined in
   * nsMsgFolderFlags.h.
   *
   * @param flag  The flag to toggle
   */
  void toggleFlag(in unsigned long flag);

  /**
   * Called to notify the database and/or listeners of a change of flag. The
   * known flags are defined in nsMsgFolderFlags.h 
   *
   * @note        This doesn't need to be called for normal flag changes via
   *              the *Flag functions on this interface.
   *
   * @param flag  The flag that was changed.
   */
  void onFlagChange(in unsigned long flag);

  /**
   * Direct access to the set/get all the flags at once.
   */
  attribute unsigned long flags;

  /**
   * Gets the first folder that has the specified flags set.
   *
   * @param flags    The flag(s) to check for.
   * @return         The folder or the first available child folder that has
   *                 the specified flags set, or null if there are none.
   */
  nsIMsgFolder getFolderWithFlags(in unsigned long flags);

  /**
   * Gets the folders that have the specified flag set.
   *
   * @param flags    The flag(s) to check for.
   * @return         An array of folders that have the specified flags set.
   *                 The array may have zero elements.
   */
  nsIArray getFoldersWithFlags(in unsigned long flags);

  /**
   * Lists the folders that have the specified flag set.
   *
   * @param flags    The flag(s) to check for.
   * @param folders  The array in which to append the found folder(s).
   */
  void listFoldersWithFlags(in unsigned long flags,
                            in nsIMutableArray folders);

  /**
   * Check if this folder (or one of its ancestors) is special.
   *
   * @param flags          The "special" flags to check.
   * @param checkAncestors Should ancestors be checked too.
   */
  boolean isSpecialFolder(in unsigned long flags,
                          [optional] in boolean checkAncestors);

  ACString getUriForMsg(in nsIMsgDBHdr msgHdr);

  /**
   * Deletes the messages from the folder.
   *
   * @param messages      The array of nsIMsgDBHdr objects to be deleted.
   * @param msgWindow     The standard message window object, for alerts et al.
   * @param deleteStorage Whether or not the message should be truly deleted, as
                          opposed to moving to trash.
   * @param isMove        Whether or not this is a deletion for moving messages.
   * @param allowUndo     Whether this action should be undoable.
   */
  void deleteMessages(in nsIArray messages,
                      in nsIMsgWindow msgWindow,
                      in boolean deleteStorage, in boolean isMove,
                      in nsIMsgCopyServiceListener listener, in boolean allowUndo);

  void copyMessages(in nsIMsgFolder srcFolder, in nsIArray messages,
                    in boolean isMove, in nsIMsgWindow msgWindow,
                    in nsIMsgCopyServiceListener listener, in boolean isFolder,
                    in boolean allowUndo);

  void copyFolder(in nsIMsgFolder srcFolder, in boolean isMoveFolder,
                  in nsIMsgWindow msgWindow, in nsIMsgCopyServiceListener listener );

  void copyFileMessage(in nsIFile file, in nsIMsgDBHdr msgToReplace,
                       in boolean isDraft, in unsigned long newMsgFlags,
                       in ACString aKeywords,
                       in nsIMsgWindow msgWindow,
                       in nsIMsgCopyServiceListener listener);

  void acquireSemaphore (in nsISupports semHolder);
  void releaseSemaphore (in nsISupports semHolder);
  boolean testSemaphore (in nsISupports semHolder);
  readonly attribute boolean locked;

  void getNewMessages(in nsIMsgWindow aWindow, in nsIUrlListener aListener);

  /**
   * write out summary data for this folder
   * to the given folder cache (i.e. panacea.dat)
   */
  void writeToFolderCache(in nsIMsgFolderCache folderCache, in boolean deep);

  /**
   * the charset of this folder
   */
  attribute ACString charset;
  attribute boolean charsetOverride;
  attribute unsigned long biffState;

  /**
   * the number of new messages since this folder was last visited
   * @param deep if true, descends into all subfolders and gets a grand total
   */

   long getNumNewMessages (in boolean deep);

   void setNumNewMessages(in long numNewMessages);

  /**
   * are we running a url as a result of the user clicking get msg?
   */
  attribute boolean gettingNewMessages;

  /**
   * local path of this folder
   */
  attribute nsIFile filePath;

  readonly attribute ACString baseMessageURI;
  ACString generateMessageURI(in nsMsgKey msgKey);

  const nsMsgDispositionState nsMsgDispositionState_None = -1;
  const nsMsgDispositionState nsMsgDispositionState_Replied = 0;
  const nsMsgDispositionState nsMsgDispositionState_Forwarded = 1;
  void addMessageDispositionState(in nsIMsgDBHdr aMessage,
                                  in nsMsgDispositionState aDispositionFlag);

  void markMessagesRead(in nsIArray messages, in boolean markRead);
  void markAllMessagesRead(in nsIMsgWindow aMsgWindow);
  void markMessagesFlagged(in nsIArray messages, in boolean markFlagged);
  void markThreadRead(in nsIMsgThread thread);
  void setLabelForMessages(in nsIArray messages, in nsMsgLabelValue label);
  /**
   * Gets the message database for the folder.
   *
   * Note that if the database is out of date, the implementation MAY choose to
   * throw an error. For a handle to the database which MAY NOT throw an error,
   * one can use getDBFolderInfoAndDB.
   *
   * @exception NS_MSG_ERROR_FOLDER_SUMMARY_MISSING If the database does not
   *                         exist.
   * @exception NS_MSG_ERROR_FOLDER_SUMMARY_OUT_OF_DATE If the database contains
   *                         out of date information.
   * @see nsIMsgFolder::getDBFolderInfoAndDB.
   */
  attribute nsIMsgDatabase msgDatabase;

  /**
   * Get the backup message database, used in reparsing. This database must
   * be created first using closeAndBackupFolderDB()
   *
   * @return   backup message database
   */
  nsIMsgDatabase getBackupMsgDatabase();
  /**
   * Remove the backup message database file
   */
  void removeBackupMsgDatabase();
  /**
   * Open the backup message database file
   */
  void openBackupMsgDatabase();
  nsIMsgDatabase getDBFolderInfoAndDB(out nsIDBFolderInfo folderInfo);
  nsIMsgDBHdr GetMessageHeader(in nsMsgKey msgKey);

  readonly attribute boolean supportsOffline;
  boolean shouldStoreMsgOffline(in nsMsgKey msgKey);
  boolean hasMsgOffline(in nsMsgKey msgKey);

  /**
   * Get an input stream to read the offline contents of an imap or news
   * message.
   *
   * @param aMsgKey key of message to get input stream for.
   * @param[out] aOffset filled in with the offset into the stream of the message.
   * @param[out] aSize filled in with the size of the message in the offline store.
   *
   * @returns input stream to read the message from.
   */
  nsIInputStream getOfflineFileStream(in nsMsgKey aMsgKey,
                                      out long long aOffset,
                                      out unsigned long aSize);

  /**
   * Get the folder where the msg could be present.
   * @param msgKey  key of the msg for which we are trying to get the folder;
   * @returns aMsgFolder  required folder;
   *
   */
  nsIMsgFolder GetOfflineMsgFolder(in nsMsgKey msgKey);

  /**
   * Get an offline store output stream for the passed message header.
   *
   * @param aHdr hdr of message to get outputstream for
   * @returns An output stream to write to.
   */
  nsIOutputStream getOfflineStoreOutputStream(in nsIMsgDBHdr aHdr);

  /**
   * Get an input stream for the passed message header. The stream will
   * be positioned at the start of the message.
   *
   * @param aHdr hdr of message to get the input stream for.
   * @param[out] aReusable set to true if the stream can be re-used, in which
                           case the caller might not want to close it.
   * @returns an input stream to read the message from
   */
  nsIInputStream getMsgInputStream(in nsIMsgDBHdr aHdr, out boolean aReusable);

  readonly attribute nsIInputStream offlineStoreInputStream;
  void DownloadMessagesForOffline(in nsIArray messages,
                                  in nsIMsgWindow window);
  nsIMsgFolder getChildWithURI(in ACString uri, in boolean deep,
                               in boolean caseInsensitive);
  void downloadAllForOffline(in nsIUrlListener listener, in nsIMsgWindow window);
  /**
   *  Turn notifications on/off for various notification types. Currently only
   *  supporting allMessageCountNotifications which refers to both total and
   *  unread message counts.
   */
  const unsigned long allMessageCountNotifications    = 0;
  void enableNotifications(in long notificationType, in boolean enable,
                           in boolean dbBatching);
  boolean isCommandEnabled(in ACString command);
  boolean matchOrChangeFilterDestination(in nsIMsgFolder folder,
                                         in boolean caseInsensitive);
  boolean confirmFolderDeletionForFilter(in nsIMsgWindow msgWindow);
  void alertFilterChanged(in nsIMsgWindow msgWindow);
  void throwAlertMsg(in string msgName, in nsIMsgWindow msgWindow);
  AString getStringWithFolderNameFromBundle(in string msgName);
  void notifyCompactCompleted();
  long compareSortKeys(in nsIMsgFolder msgFolder);
  /**
   * Returns a sort key that can be used to sort a list of folders.
   *
   * Prefer nsIMsgFolder::compareSortKeys over this function.
   */
  void getSortKey(out unsigned long length, [array, size_is(length), retval] out octet key);

  attribute nsIMsgRetentionSettings retentionSettings;
  attribute nsIMsgDownloadSettings downloadSettings;
  boolean callFilterPlugins(in nsIMsgWindow aMsgWindow);
  /**
   * used for order in the folder pane, folder pickers, etc.
   */
  attribute long sortOrder;

  attribute nsIDBFolderInfo dBTransferInfo;

  ACString getStringProperty(in string propertyName);
  void setStringProperty(in string propertyName, in ACString propertyValue);

  /* does not persist across sessions */
  attribute nsMsgKey lastMessageLoaded;

  /* old nsIFolder properties and methods */
  readonly attribute ACString URI;
  attribute AString name;
  attribute AString prettyName;
  readonly attribute AString abbreviatedName;

  attribute nsIMsgFolder parent;

  /**
   * Returns an enumerator containing a list of nsIMsgFolder items that are
   * subfolders of the instance this is called on.
   */
  readonly attribute nsISimpleEnumerator subFolders;

  /**
   * Returns true if this folder has sub folders.
   */
  readonly attribute boolean hasSubFolders;

  /**
   * Returns the number of sub folders that this folder has.
   */
  readonly attribute unsigned long numSubFolders;

  /**
   * Determines if this folder is an ancestor of the supplied folder.
   *
   * @param folder  The folder that may or may not be a descendent of this
   *                folder.
   */
  boolean isAncestorOf(in nsIMsgFolder folder);

  /**
   * Looks in immediate children of this folder for the given name.
   *
   * @param name the name of the target subfolder
   */
  boolean containsChildNamed(in AString name);

  /**
   * Return the child folder which the specified name.
   *
   * @param aName  The name of the child folder to find
   * @return       The child folder
   * @exception NS_ERROR_FAILURE Thrown if the folder with aName does not exist
   */
  nsIMsgFolder getChildNamed(in AString aName);

  /**
   * Finds the sub folder with the specified name.
   *
   * @param escapedSubFolderName  The name of the sub folder to find.
   * @note                        Even if the folder doesn't currently exist,
   *                              a nsIMsgFolder may be returned.
   */
  nsIMsgFolder findSubFolder(in ACString escapedSubFolderName);

  void AddFolderListener(in nsIFolderListener listener);
  void RemoveFolderListener(in nsIFolderListener listener);
  void NotifyPropertyChanged(in nsIAtom property,
                             in ACString oldValue,
                             in ACString newValue);
  void NotifyIntPropertyChanged(in nsIAtom property,
                                in long oldValue,
                                in long newValue);
  void NotifyBoolPropertyChanged(in nsIAtom property,
                                 in boolean oldValue,
                                 in boolean newValue);
  void NotifyPropertyFlagChanged(in nsIMsgDBHdr item,
                                 in nsIAtom property,
                                 in unsigned long oldValue,
                                 in unsigned long newValue);
  void NotifyUnicharPropertyChanged(in nsIAtom property,
                                    in AString oldValue,
                                    in AString newValue);

  void NotifyItemAdded(in nsISupports item);
  void NotifyItemRemoved(in nsISupports item);

  void NotifyFolderEvent(in nsIAtom event);

  //  void NotifyFolderLoaded();
  //  void NotifyDeleteOrMoveMessagesCompleted(in nsIMsgFolder folder);

  // lists all descendents, not just first level children
  void ListDescendents(in nsISupportsArray descendents);
  void Shutdown(in boolean shutdownChildren);

  readonly attribute boolean inVFEditSearchScope;
  void setInVFEditSearchScope(in boolean aSearchThisFolder, in boolean aSetOnSubFolders);
  void copyDataToOutputStreamForAppend(in nsIInputStream aIStream,
                     in long aLength, in nsIOutputStream outputStream);
  void copyDataDone();
  void setJunkScoreForMessages(in nsIArray aMessages, in ACString aJunkScore);
  void applyRetentionSettings();

  /**
   * Get the beginning of the message bodies for the passed in keys and store
   * them in the msg hdr property "preview". This is intended for
   * new mail alerts, title tips on folders with new messages, and perhaps
   * titletips/message preview in the thread pane.
   *
   * @param aKeysToFetch   keys of msgs to fetch
   * @param aNumKeys       number of keys to fetch
   * @param aLocalOnly     whether to fetch msgs from server (imap msgs might
   *                       be in memory cache from junk filter)
   * @param aUrlListener   url listener to notify if we run url to fetch msgs
   *
   * @result aAsyncResults if true, we ran a url to fetch one or more of msg bodies
   *
   */
  boolean fetchMsgPreviewText([array, size_is (aNumKeys)] in nsMsgKey aKeysToFetch,
                      in unsigned long aNumKeys, in boolean aLocalOnly,
                      in nsIUrlListener aUrlListener);

  // used to set/clear tags - we could have a single method to setKeywords which
  // would figure out the diffs, but these methods might be more convenient.
  // keywords are space delimited, in the case of multiple keywords
  void addKeywordsToMessages(in nsIArray aMessages, in ACString aKeywords);
  void removeKeywordsFromMessages(in nsIArray aMessages, in ACString aKeywords);
  /**
   * Extract the message text from aStream.
   *
   * @param aStream stream to read from
   * @param aCharset character set to use to interpret the body. If an empty string, then the
   *        charset is retrieved from the headers. msgHdr.charset is recommended in case you have it.
   * @param aBytesToRead number of bytes to read from the stream. The function will read till the end
   *        of the line, and there will also be some read ahead due to NS_ReadLine
   * @param aMaxOutputLen desired length of the converted message text. Used to control how many characters
   *        of msg text we want to store.
   * @param aCompressQuotes Replace quotes and citations with " ... " in the preview text
   * @param aStripHTMLTags strip HTML tags from the output, if present
   * @param[out] aContentType the content type of the MIME part that was used to generate the text --
   *             for an HTML part, this will be "text/html" even though aStripHTMLTags might be true
   */
  AUTF8String getMsgTextFromStream(in nsIInputStream aStream, in ACString aCharset,
                                   in unsigned long aBytesToRead, in unsigned long aMaxOutputLen, 
                                   in boolean aCompressQuotes, in boolean aStripHTMLTags,
                                   out ACString aContentType);

  AString convertMsgSnippetToPlainText(in AString aMessageText);

  // this allows a folder to have a special identity. E.g., you might want to
  // associate an identity with a particular newsgroup, or for IMAP shared folders in
  // the other users namespace, you might want to create a delegated identity
  readonly attribute nsIMsgIdentity customIdentity;

  /**
   * @{
   * Processing flags, used to manage message processing.
   *
   * @param msgKey   message key
   * @return         processing flags
   */
  unsigned long getProcessingFlags(in nsMsgKey msgKey);

  /**
   * @param msgKey   message key
   * @param mask     mask to OR into the flags
   */
  void orProcessingFlags(in nsMsgKey msgKey, in unsigned long mask);

  /**
   * @param msgKey   message key
   * @param mask     mask to AND into the flags
   */
  void andProcessingFlags(in nsMsgKey msgKey, in unsigned long mask);
  /** @} */

  /**
   * Gets an inherited string property from the folder.
   *
   * If the forcePropertyEmpty boolean is set (see below), return an
   * empty string.
   *
   * If the specified folder has a non-empty value for the property,
   * return that value. Otherwise, return getInheritedStringProperty
   * for the folder's parent.
   *
   * If a folder is the root folder for a server, then instead of
   * checking the folder property, check the property of the same name
   * for the server using nsIMsgIncomingServer.getCharValue(...)
   *
   * Note nsIMsgIncomingServer.getCharValue for a server inherits from
   * the preference mail.server.default.(propertyName) as a global value
   * 
   * (ex: if propertyName = "IAmAGlobal" and no folder nor server properties
   * are set, then the inherited property will return the preference value
   * mail.server.default.IAmAGlobal)
   *
   * If the propertyName is undefined, returns an empty, void string.
   *
   * @param propertyName  The name of the property for the value to retrieve.
   */
  ACString getInheritedStringProperty(in string propertyName);

  /**
   * Set a boolean to force an inherited propertyName to return empty instead
   * of inheriting from a parent folder, server, or the global
   *
   * @param propertyName         The name of the property
   * @param aForcePropertyEmpty  true if an empty inherited property should be returned
   */
  void setForcePropertyEmpty(in string propertyName, in boolean aForcePropertyEmpty);

  /**
   * Get a boolean to force an inherited propertyName to return empty instead
   * of inheriting from a parent folder, server, or the global
   *
   * @param propertyName      The name of the property
   *
   * @return                  true if an empty inherited property should be returned
   */
  boolean getForcePropertyEmpty(in string propertyName);

  /**
   * Pluggable store for this folder. Currently, this will always be the same
   * as the pluggable store for the server.
   */
  readonly attribute nsIMsgPluggableStore msgStore;
};
