Back to index

lightning-sunbird  0.9+nobinonly
Public Member Functions | Static Public Member Functions | Public Attributes | Protected Member Functions | Protected Attributes | Static Protected Attributes
nsImapMailFolder Class Reference

#include <nsImapMailFolder.h>

Inheritance diagram for nsImapMailFolder:
Inheritance graph
[legend]
Collaboration diagram for nsImapMailFolder:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 nsImapMailFolder ()
virtual ~nsImapMailFolder ()
NS_DECL_ISUPPORTS_INHERITED
NS_IMETHOD 
Enumerate (nsIEnumerator **result)
NS_IMETHOD GetSubFolders (nsIEnumerator **result)
NS_IMETHOD GetMessages (nsIMsgWindow *aMsgWindow, nsISimpleEnumerator **result)
NS_IMETHOD UpdateFolder (nsIMsgWindow *aWindow)
NS_IMETHOD CreateSubfolder (const PRUnichar *folderName, nsIMsgWindow *msgWindow)
NS_IMETHOD AddSubfolder (const nsAString &aName, nsIMsgFolder **aChild)
NS_IMETHOD AddSubfolderWithPath (nsAString &name, nsIFileSpec *dbPath, nsIMsgFolder **child)
NS_IMETHODIMP CreateStorageIfMissing (nsIUrlListener *urlListener)
NS_IMETHOD Compact (nsIUrlListener *aListener, nsIMsgWindow *aMsgWindow)
NS_IMETHOD CompactAll (nsIUrlListener *aListener, nsIMsgWindow *aMsgWindow, nsISupportsArray *aFolderArray, PRBool aCompactOfflineAlso, nsISupportsArray *aOfflineFolderArray)
NS_IMETHOD EmptyTrash (nsIMsgWindow *msgWindow, nsIUrlListener *aListener)
NS_IMETHOD CopyDataToOutputStreamForAppend (nsIInputStream *aIStream, PRInt32 aLength, nsIOutputStream *outputStream)
NS_IMETHOD CopyDataDone ()
NS_IMETHOD Delete ()
NS_IMETHOD Rename (const PRUnichar *newName, nsIMsgWindow *msgWindow)
NS_IMETHOD RenameSubFolders (nsIMsgWindow *msgWindow, nsIMsgFolder *oldFolder)
NS_IMETHOD GetNoSelect (PRBool *aResult)
NS_IMETHOD GetPrettyName (PRUnichar **prettyName)
NS_IMETHOD GetFolderURL (char **url)
NS_IMETHOD UpdateSummaryTotals (PRBool force)
NS_IMETHOD GetDeletable (PRBool *deletable)
NS_IMETHOD GetRequiresCleanup (PRBool *requiresCleanup)
NS_IMETHOD GetSizeOnDisk (PRUint32 *size)
NS_IMETHOD GetCanCreateSubfolders (PRBool *aResult)
NS_IMETHOD GetCanSubscribe (PRBool *aResult)
NS_IMETHOD AddMessageDispositionState (nsIMsgDBHdr *aMessage, nsMsgDispositionState aDispositionFlag)
NS_IMETHOD MarkMessagesRead (nsISupportsArray *messages, PRBool markRead)
NS_IMETHOD MarkAllMessagesRead (void)
NS_IMETHOD MarkMessagesFlagged (nsISupportsArray *messages, PRBool markFlagged)
NS_IMETHOD MarkThreadRead (nsIMsgThread *thread)
NS_IMETHOD SetLabelForMessages (nsISupportsArray *aMessages, nsMsgLabelValue aLabel)
NS_IMETHOD SetJunkScoreForMessages (nsISupportsArray *aMessages, const char *aJunkScore)
NS_IMETHOD DeleteSubFolders (nsISupportsArray *folders, nsIMsgWindow *msgWindow)
NS_IMETHOD ReadFromFolderCacheElem (nsIMsgFolderCacheElement *element)
NS_IMETHOD WriteToFolderCacheElem (nsIMsgFolderCacheElement *element)
NS_IMETHOD GetDBFolderInfoAndDB (nsIDBFolderInfo **folderInfo, nsIMsgDatabase **db)
NS_IMETHOD DeleteMessages (nsISupportsArray *messages, nsIMsgWindow *msgWindow, PRBool deleteStorage, PRBool isMove, nsIMsgCopyServiceListener *listener, PRBool allowUndo)
NS_IMETHOD CopyMessages (nsIMsgFolder *srcFolder, nsISupportsArray *messages, PRBool isMove, nsIMsgWindow *msgWindow, nsIMsgCopyServiceListener *listener, PRBool isFolder, PRBool allowUndo)
NS_IMETHOD CopyFolder (nsIMsgFolder *srcFolder, PRBool isMove, nsIMsgWindow *msgWindow, nsIMsgCopyServiceListener *listener)
NS_IMETHOD CopyFileMessage (nsIFileSpec *fileSpec, nsIMsgDBHdr *msgToReplace, PRBool isDraftOrTemplate, PRUint32 aNewMsgFlags, nsIMsgWindow *msgWindow, nsIMsgCopyServiceListener *listener)
NS_IMETHOD GetNewMessages (nsIMsgWindow *aWindow, nsIUrlListener *aListener)
NS_IMETHOD GetPath (nsIFileSpec **aPathName)
NS_IMETHOD SetPath (nsIFileSpec *aPath)
NS_IMETHOD Shutdown (PRBool shutdownChildren)
NS_IMETHOD DownloadMessagesForOffline (nsISupportsArray *messages, nsIMsgWindow *msgWindow)
NS_IMETHOD DownloadAllForOffline (nsIUrlListener *listener, nsIMsgWindow *msgWindow)
NS_IMETHOD GetCanFileMessages (PRBool *aCanFileMessages)
NS_IMETHOD GetCanDeleteMessages (PRBool *aCanDeleteMessages)
NS_IMETHOD FetchMsgPreviewText (nsMsgKey *aKeysToFetch, PRUint32 aNumKeys, PRBool aLocalOnly, nsIUrlListener *aUrlListener, PRBool *aAsyncResults)
NS_IMETHOD AddKeywordsToMessages (nsISupportsArray *aMessages, const char *aKeywords)
NS_IMETHOD RemoveKeywordsFromMessages (nsISupportsArray *aMessages, const char *aKeywords)
NS_DECL_NSIMSGIMAPMAILFOLDER
NS_DECL_NSIIMAPMAILFOLDERSINK
NS_DECL_NSIIMAPMESSAGESINK
NS_DECL_NSICOPYMESSAGELISTENER
NS_DECL_NSIREQUESTOBSERVER
NS_IMETHOD 
OnStartRunningUrl (nsIURI *aUrl)
NS_IMETHOD OnStopRunningUrl (nsIURI *aUrl, nsresult aExitCode)
NS_IMETHOD AddSearchResult (nsIImapProtocol *aProtocol, const char *searchHitLine)
NS_IMETHOD MatchName (nsString *name, PRBool *matches)
NS_DECL_NSIMSGFILTERHITNOTIFY
NS_DECL_NSIJUNKMAILCLASSIFICATIONLISTENER
NS_IMETHOD 
IsCommandEnabled (const char *command, PRBool *result)
NS_IMETHOD SetFilterList (nsIMsgFilterList *aMsgFilterList)
NS_IMETHOD GetCustomIdentity (nsIMsgIdentity **aIdentity)
nsresult MoveIncorporatedMessage (nsIMsgDBHdr *mailHdr, nsIMsgDatabase *sourceDB, const nsACString &destFolder, nsIMsgFilter *filter, nsIMsgWindow *msgWindow)
virtual nsresult SpamFilterClassifyMessage (const char *aURI, nsIMsgWindow *aMsgWindow, nsIJunkMailPlugin *aJunkMailPlugin)
virtual nsresult SpamFilterClassifyMessages (const char **aURIArray, PRUint32 aURICount, nsIMsgWindow *aMsgWindow, nsIJunkMailPlugin *aJunkMailPlugin)
nsresult SetSupportedUserFlags (PRUint32 userFlags)
nsresult GetSupportedUserFlags (PRUint32 *userFlags)
void removeSubFolder (in nsIMsgFolder folder)
void createClientSubfolderInfo (in string folderName, in wchar hierarchyDelimiter, in long flags, in boolean suppressNotification)
void list ()
void renameLocal (in string newname, in nsIMsgFolder parent)
void prepareToRename ()
void performExpand (in nsIMsgWindow aMsgWindow)
void recursiveCloseActiveConnections (in nsIImapIncomingServer aImapServer)
void renameClient (in nsIMsgWindow msgWindow, in nsIMsgFolder msgFolder, in string oldName, in string newName)
void storeImapFlags (in long aFlags, in boolean aAddFlags,[array, size_is(aNumKeys)] in nsMsgKey aKeysToFlag, in unsigned long aNumKeys, in nsIUrlListener aUrlListener)
void setImapFlags (in string uids, in long flags, out nsIURI url)
void replayOfflineMoveCopy ([array, size_is(numKeys)] in nsMsgKey keys, in unsigned long numKeys, in boolean isMove, in nsIMsgFolder aDstFolder, in nsIUrlListener aUrlListener, in nsIMsgWindow aWindow)
void playbackOfflineFolderCreate (in wstring folderName, in nsIMsgWindow aWindow, out nsIURI url)
void liteSelect (in nsIUrlListener aUrlListener)
void fillInFolderProps (in nsIMsgImapFolderProps aFolderProps)
void resetNamespaceReferences ()
void folderPrivileges (in nsIMsgWindow aWindow)
nsIMsgImapMailFolder findOnlineSubFolder (in string onlineName)
void addFolderRights (in string userName, in string rights)
void refreshFolderRights ()
void updateStatus (in nsIUrlListener aListener, in nsIMsgWindow aMsgWindow)
nsIURI issueCommandOnMsgs (in string command, in string uids, in nsIMsgWindow aWindow)
nsIURI fetchCustomMsgAttribute (in string msgAttribute, in string uids, in nsIMsgWindow aWindow)
nsIURI storeCustomKeywords (in nsIMsgWindow aMsgWindow, in string aFlagsToAdd, in string aFlagsToSubtract,[array, size_is(aNumKeys)] in nsMsgKey aKeysToStore, in unsigned long aNumKeys)
void notifyIfNewMail ()
void getQuota (out boolean valid, out unsigned long usedKB, out unsigned long maxKB)
 Quota |valid| indicates whether the server has provided quota information on this folder.
void setFolderQuotaData (in ACString aFolderQuotaRoot, in unsigned long aFolderQuotaUsedKB, in unsigned long aFolderQuotaMaxKB)
 Set FolderQuotaData information.
string GetOnlineDelimiter ()
void OnNewIdleMessages ()
void UpdateImapMailboxInfo (in nsIImapProtocol aProtocol, in nsIMailboxSpec aSpec)
void UpdateImapMailboxStatus (in nsIImapProtocol aProtocol, in nsIMailboxSpec aSpec)
void parseMsgHdrs (in nsIImapProtocol aProtocol, in nsIImapHeaderXferInfo aHdrXferInfo)
void AbortHeaderParseStream (in nsIImapProtocol aProtocol)
void OnlineCopyCompleted (in nsIImapProtocol aProtocol, in ImapOnlineCopyState aCopyState)
void StartMessage (in nsIMsgMailNewsUrl aUrl)
void EndMessage (in nsIMsgMailNewsUrl aUrl, in nsMsgKey uidOfMessage)
void NotifySearchHit (in nsIMsgMailNewsUrl aUrl, in string hitLine)
void copyNextStreamMessage (in boolean copySucceeded, in nsISupports copyState)
void prepareToReleaseObject (in nsISupports aISupports)
void releaseObject ()
void closeMockChannel (in nsIImapMockChannel aChannel)
void setUrlState (in nsIImapProtocol aProtocol, in nsIMsgMailNewsUrl aUrl, in boolean isRunning, in nsresult status)
void releaseUrlCacheEntry (in nsIMsgMailNewsUrl aUrl)
void headerFetchCompleted (in nsIImapProtocol aProtocol)
void setBiffStateAndUpdate (in long biffState)
void progressStatus (in nsIImapProtocol aProtocol, in unsigned long aMsgId, in wstring extraInfo)
void percentProgress (in nsIImapProtocol aProtocol, in wstring aMessage, in long aCurrentProgress, in long aMaxProgressProgressInfo)
void clearFolderRights ()
void setCopyResponseUid (in string msgIdString, in nsIImapUrl aUrl)
void setAppendMsgUid (in nsMsgKey newKey, in nsIImapUrl aUrl)
ACString getMessageId (in nsIImapUrl aUrl)
void SetupMsgWriteStream (in string aNativePath, in boolean appendDummyEnvelope)
void ParseAdoptedMsgLine (in string adoptedMsgLine, in nsMsgKey uidOfMsg)
void normalEndMsgWriteStream (in nsMsgKey uidOfMessage, in boolean markMsgRead, in nsIImapUrl imapUrl)
void AbortMsgWriteStream ()
void BeginMessageUpload ()
void NotifyMessageFlags (in unsigned long flags, in nsMsgKey messageKey)
void NotifyMessageDeleted (in string onlineFolderName, in boolean deleteAllMsgs, in string msgIdString)
void GetMessageSizeFromDB (in string id, in boolean idIsUid, out unsigned long size)
void SetContentModified (in nsIImapUrl aImapUrl, in nsImapContentModifiedType modified)
void SetImageCacheSessionForUrl (in nsIMsgMailNewsUrl aMailUrl)
unsigned long getCurMoveCopyMessageInfo (in nsIImapUrl runningUrl, out PRTime date, out string keywords)
void beginCopy (in nsIMsgDBHdr message)
void startMessage ()
void copyData (in nsIInputStream aIStream, in long aLength)
void endMessage (in nsMsgKey key)
void endCopy (in boolean copySucceeded)
void endMove (in boolean moveSucceeded)
boolean applyFilterHit (in nsIMsgFilter filter, in nsIMsgWindow msgWindow)
void onMessageClassified (in string aMsgURI, in nsMsgJunkStatus aClassification)

Static Public Member Functions

static nsresult AllocateUidStringFromKeys (nsMsgKey *keys, PRUint32 numKeys, nsCString &msgIds)

Public Attributes

attribute boolean verifiedAsOnlineFolder
attribute boolean explicitlyVerify
attribute wchar hierarchyDelimiter
attribute long boxFlags
attribute string onlineName
attribute boolean isNamespace
readonly attribute boolean canIOpenThisFolder
attribute string adminUrl
readonly attribute boolean hasAdminUrl
attribute boolean performingBiff
readonly attribute
nsIMsgParseMailMsgState 
hdrParser
attribute boolean folderNeedsACLListed
attribute boolean folderNeedsSubscribing
attribute boolean folderNeedsAdded
attribute unsigned long aclFlags
attribute long uidValidity
attribute boolean folderQuotaCommandIssued
 Whether we have asked the server for this folder's quota information.
readonly attribute boolean shouldDownloadAllHeaders
attribute boolean notifyDownloadedLines

Protected Member Functions

void FindKeysToAdd (const nsMsgKeyArray &existingKeys, nsMsgKeyArray &keysToFetch, PRUint32 &numNewUnread, nsIImapFlagAndUidState *flagState)
void FindKeysToDelete (const nsMsgKeyArray &existingKeys, nsMsgKeyArray &keysToFetch, nsIImapFlagAndUidState *flagState)
void PrepareToAddHeadersToMailDB (nsIImapProtocol *aProtocol, const nsMsgKeyArray &keysToFetch, nsIMailboxSpec *boxSpec)
void TweakHeaderFlags (nsIImapProtocol *aProtocol, nsIMsgDBHdr *tweakMe)
nsresult SyncFlags (nsIImapFlagAndUidState *flagState)
nsresult HandleCustomFlags (nsMsgKey uidOfMessage, nsIMsgDBHdr *dbHdr, nsXPIDLCString &keywords)
nsresult NotifyMessageFlagsFromHdr (nsIMsgDBHdr *dbHdr, nsMsgKey msgKey, PRUint32 flags)
nsresult SetupHeaderParseStream (PRUint32 size, const char *content_type, nsIMailboxSpec *boxSpec)
nsresult ParseAdoptedHeaderLine (const char *messageLine, PRUint32 msgKey)
nsresult NormalEndHeaderParseStream (nsIImapProtocol *aProtocol, nsIImapUrl *imapUrl)
void EndOfflineDownload ()
nsresult MarkMessagesImapDeleted (nsMsgKeyArray *keyArray, PRBool deleted, nsIMsgDatabase *db)
void UpdatePendingCounts ()
void SetIMAPDeletedFlag (nsIMsgDatabase *mailDB, const nsMsgKeyArray &msgids, PRBool markDeleted)
virtual PRBool ShowDeletedMessages ()
virtual PRBool DeleteIsMoveToTrash ()
nsresult GetFolder (const char *name, nsIMsgFolder **pFolder)
nsresult GetTrashFolder (nsIMsgFolder **pTrashFolder)
PRBool TrashOrDescendentOfTrash (nsIMsgFolder *folder)
nsresult GetServerKey (char **serverKey)
nsresult GetImapIncomingServer (nsIImapIncomingServer **aImapIncomingServer)
nsresult DisplayStatusMsg (nsIImapUrl *aImapUrl, const PRUnichar *msg)
nsresult AddDirectorySeparator (nsFileSpec &path)
nsresult CreateSubFolders (nsFileSpec &path)
nsresult GetDatabase (nsIMsgWindow *aMsgWindow)
virtual const char * GetIncomingServerType ()
nsresult GetFolderOwnerUserName (char **userName)
nsresult GetOwnersOnlineFolderName (char **onlineName)
nsIMAPNamespaceGetNamespaceForFolder ()
void SetNamespaceForFolder (nsIMAPNamespace *ns)
nsresult GetServerAdminUrl (char **aAdminUrl)
nsMsgIMAPFolderACLGetFolderACL ()
nsresult CreateACLRightsStringForFolder (PRUnichar **rightsString)
nsresult GetBodysToDownload (nsMsgKeyArray *keysOfMessagesToDownload)
nsresult CopyMessagesWithStream (nsIMsgFolder *srcFolder, nsISupportsArray *messages, PRBool isMove, PRBool isCrossServerOp, nsIMsgWindow *msgWindow, nsIMsgCopyServiceListener *listener, PRBool allowUndo)
nsresult CopyStreamMessage (nsIMsgDBHdr *message, nsIMsgFolder *dstFolder, nsIMsgWindow *msgWindow, PRBool isMove)
nsresult InitCopyState (nsISupports *srcSupport, nsISupportsArray *messages, PRBool isMove, PRBool selectedState, PRBool acrossServers, PRUint32 newMsgFlags, nsIMsgCopyServiceListener *listener, nsIMsgWindow *msgWindow, PRBool allowUndo)
nsresult OnCopyCompleted (nsISupports *srcSupport, nsresult exitCode)
nsresult BuildIdsAndKeyArray (nsISupportsArray *messages, nsCString &msgIds, nsMsgKeyArray &keyArray)
nsresult GetMoveCoalescer ()
nsresult PlaybackCoalescedOperations ()
virtual nsresult CreateBaseMessageURI (const char *aURI)
nsresult GetClearedOriginalOp (nsIMsgOfflineImapOperation *op, nsIMsgOfflineImapOperation **originalOp, nsIMsgDatabase **originalDB)
nsresult GetOriginalOp (nsIMsgOfflineImapOperation *op, nsIMsgOfflineImapOperation **originalOp, nsIMsgDatabase **originalDB)
nsresult CopyMessagesOffline (nsIMsgFolder *srcFolder, nsISupportsArray *messages, PRBool isMove, nsIMsgWindow *msgWindow, nsIMsgCopyServiceListener *listener)
nsresult CopyOfflineMsgBody (nsIMsgFolder *srcFolder, nsIMsgDBHdr *destHdr, nsIMsgDBHdr *origHdr)
void GetTrashFolderName (nsAString &aFolderName)
PRBool ShowPreviewText ()

Protected Attributes

PRBool m_initialized
PRBool m_haveDiscoveredAllFolders
PRBool m_haveReadNameFromDB
nsCOMPtr< nsIMsgParseMailMsgStatem_msgParser
nsCOMPtr< nsIMsgFilterListm_filterList
nsCOMPtr< nsIMsgFilterPluginm_filterPlugin
PRInt32 m_numFilterClassifyRequests
PRBool m_msgMovedByFilter
nsImapMoveCoalescer * m_moveCoalescer
nsCOMPtr< nsISupportsArraym_junkMessagesToMarkAsRead
nsMsgKey m_curMsgUid
PRUint32 m_uidValidity
PRInt32 m_numStatusRecentMessages
PRInt32 m_numStatusUnseenMessages
PRInt32 m_nextMessageByteLength
nsCOMPtr< nsIEventQueuem_eventQueue
nsCOMPtr< nsIUrlListenerm_urlListener
PRBool m_urlRunning
nsRefPtr< nsMsgTxn > m_pendingUndoTxn
nsCOMPtr< nsImapMailCopyStatem_copyState
PRMonitorm_appendMsgMonitor
PRUnichar m_hierarchyDelimiter
PRInt32 m_boxFlags
nsCString m_onlineFolderName
nsFileSpecm_pathName
nsCString m_ownerUserName
nsCString m_adminUrl
nsIMAPNamespacem_namespace
PRPackedBool m_verifiedAsOnlineFolder
PRPackedBool m_explicitlyVerify
PRPackedBool m_folderIsNamespace
PRPackedBool m_folderNeedsSubscribing
PRPackedBool m_folderNeedsAdded
PRPackedBool m_folderNeedsACLListed
PRPackedBool m_performingBiff
PRPackedBool m_folderQuotaCommandIssued
PRPackedBool m_folderQuotaDataIsValid
PRPackedBool m_updatingFolder
nsMsgIMAPFolderACLm_folderACL
PRUint32 m_aclFlags
PRUint32 m_supportedUserFlags
nsCOMPtr< nsISupports > mSupportsToRelease
PRBool m_downloadMessageForOfflineUse
PRBool m_downloadingFolderForOfflineUse
nsCString m_folderQuotaRoot
PRUint32 m_folderQuotaUsedKB
PRUint32 m_folderQuotaMaxKB

Static Protected Attributes

static nsIAtommImapHdrDownloadedAtom = nsnull

Detailed Description

Definition at line 195 of file nsImapMailFolder.h.


Constructor & Destructor Documentation

Definition at line 201 of file nsImapMailFolder.cpp.

                                   :
    m_initialized(PR_FALSE),m_haveDiscoveredAllFolders(PR_FALSE),
    m_haveReadNameFromDB(PR_FALSE), 
    m_curMsgUid(0), m_nextMessageByteLength(0),
    m_urlRunning(PR_FALSE),
  m_verifiedAsOnlineFolder(PR_FALSE),
  m_explicitlyVerify(PR_FALSE),
  m_folderIsNamespace(PR_FALSE),
    m_folderNeedsSubscribing(PR_FALSE),
    m_folderNeedsAdded(PR_FALSE),
    m_folderNeedsACLListed(PR_TRUE),
    m_performingBiff(PR_FALSE),
    m_folderQuotaCommandIssued(PR_FALSE),
    m_folderQuotaDataIsValid(PR_FALSE),
    m_updatingFolder(PR_FALSE),
    m_downloadMessageForOfflineUse(PR_FALSE),
    m_downloadingFolderForOfflineUse(PR_FALSE),
    m_folderQuotaUsedKB(0),
    m_folderQuotaMaxKB(0)
{
  MOZ_COUNT_CTOR(nsImapMailFolder); // double count these for now.

  if (mImapHdrDownloadedAtom == nsnull)
    mImapHdrDownloadedAtom = NS_NewAtom("ImapHdrDownloaded");
  m_appendMsgMonitor = nsnull;  // since we're not using this (yet?) make it null.
  // if we do start using it, it should be created lazily
  
  nsresult rv;
  
  // Get current thread envent queue
  nsCOMPtr<nsIEventQueueService> pEventQService = 
    do_GetService(kEventQueueServiceCID, &rv); 
  if (NS_SUCCEEDED(rv) && pEventQService)
    pEventQService->GetThreadEventQueue(NS_CURRENT_THREAD,
    getter_AddRefs(m_eventQueue));
  m_moveCoalescer = nsnull;
  m_boxFlags = 0;
  m_uidValidity = kUidUnknown;
  m_numStatusRecentMessages = 0;
  m_numStatusUnseenMessages = 0;
  m_hierarchyDelimiter = kOnlineHierarchySeparatorUnknown;
  m_pathName = nsnull;
  m_folderACL = nsnull;
  m_aclFlags = 0;
  m_supportedUserFlags = 0;
  m_namespace = nsnull;
  m_numFilterClassifyRequests = 0; 
}

Here is the call graph for this function:

Definition at line 250 of file nsImapMailFolder.cpp.

{
  MOZ_COUNT_DTOR(nsImapMailFolder);
    if (m_appendMsgMonitor)
        PR_DestroyMonitor(m_appendMsgMonitor);

  // I think our destructor gets called before the base class...
  if (mInstanceCount == 1)
    NS_IF_RELEASE(mImapHdrDownloadedAtom);
  NS_IF_RELEASE(m_moveCoalescer);
  delete m_pathName;
  delete m_folderACL;
}

Here is the call graph for this function:


Member Function Documentation

Definition at line 294 of file nsImapMailFolder.cpp.

{
  nsresult rv = NS_OK;
  if (mURI.Equals(kImapRootURI)) 
  {
      // don't concat the full separator with .sbd
  }
  else 
  {
      nsAutoString sep;
      rv = nsGetMailFolderSeparator(sep);
      if (NS_FAILED(rv)) return rv;

      // see if there's a dir with the same name ending with .sbd
      // unfortunately we can't just say:
      //          path += sep;
      // here because of the way nsFileSpec concatenates
      nsCAutoString str(path.GetNativePathCString());
      LossyAppendUTF16toASCII(sep, str); 
      path = str.get();
    }

  return rv;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void nsIMsgImapMailFolder::addFolderRights ( in string  userName,
in string  rights 
) [inherited]

Definition at line 8606 of file nsImapMailFolder.cpp.

{
  nsresult rv = nsMsgDBFolder::AddKeywordsToMessages(aMessages, aKeywords);
  if (NS_SUCCEEDED(rv))
  {
    nsCAutoString messageIds;
    nsMsgKeyArray keys;
    rv = BuildIdsAndKeyArray(aMessages, messageIds, keys);
    NS_ENSURE_SUCCESS(rv, rv);
    rv = StoreCustomKeywords(nsnull, aKeywords, nsnull, keys.GetArray(), keys.GetSize(), nsnull);
    if (mDatabase)
      mDatabase->Commit(nsMsgDBCommitType::kLargeCommit);
  }
  return rv;
}

Here is the call graph for this function:

Definition at line 1836 of file nsImapMailFolder.cpp.

{
  nsMsgDBFolder::AddMessageDispositionState(aMessage, aDispositionFlag);

  // set the mark message answered flag on the server for this message...
  if (aMessage)
  {
    nsMsgKeyArray messageIDs;
    nsMsgKey msgKey;
    aMessage->GetMessageKey(&msgKey);
    messageIDs.Add(msgKey);

    if (aDispositionFlag == nsIMsgFolder::nsMsgDispositionState_Replied)
      StoreImapFlags(kImapMsgAnsweredFlag, PR_TRUE, messageIDs.GetArray(), messageIDs.GetSize(), nsnull);
    else if (aDispositionFlag == nsIMsgFolder::nsMsgDispositionState_Forwarded)
      StoreImapFlags(kImapMsgForwardedFlag, PR_TRUE, messageIDs.GetArray(), messageIDs.GetSize(), nsnull);
  }
  return NS_OK;
}
NS_IMETHODIMP nsImapMailFolder::AddSearchResult ( nsIImapProtocol aProtocol,
const char *  searchHitLine 
)

Definition at line 5358 of file nsImapMailFolder.cpp.

{
    return NS_ERROR_FAILURE;
}
NS_IMETHODIMP nsImapMailFolder::AddSubfolder ( const nsAString &  aName,
nsIMsgFolder **  aChild 
)

Definition at line 332 of file nsImapMailFolder.cpp.

{
  NS_ENSURE_ARG_POINTER(aChild);
  
  PRInt32 flags = 0;
  nsresult rv;
  nsCOMPtr<nsIRDFService> rdf = do_GetService("@mozilla.org/rdf/rdf-service;1", &rv);
  NS_ENSURE_SUCCESS(rv,rv);
  
  nsCAutoString uri(mURI);
  uri.Append('/');
  
  // If AddSubFolder starts getting called for folders other than virtual folders, 
  // we'll have to do convert those names to modified utf-7. For now, the account manager code
  // that loads the virtual folders for each account, expects utf8 not modified utf-7. 
  nsCAutoString escapedName;
  rv = NS_MsgEscapeEncodeURLPath(aName, escapedName);
  NS_ENSURE_SUCCESS(rv, rv);
  
  uri += escapedName.get();
  
  nsCOMPtr <nsIMsgFolder> msgFolder;
  rv = GetChildWithURI(uri.get(), PR_FALSE/*deep*/, PR_TRUE /*case Insensitive*/, getter_AddRefs(msgFolder));  
  if (NS_SUCCEEDED(rv) && msgFolder)
    return NS_MSG_FOLDER_EXISTS;
  
  nsCOMPtr<nsIRDFResource> res;
  rv = rdf->GetResource(uri, getter_AddRefs(res));
  if (NS_FAILED(rv))
    return rv;
  
  nsCOMPtr<nsIMsgFolder> folder(do_QueryInterface(res, &rv));
  if (NS_FAILED(rv))
    return rv;

  nsFileSpec path;
  nsMsgDBFolder *dbFolder = NS_STATIC_CAST(nsMsgDBFolder *, NS_STATIC_CAST(nsIMsgFolder *, folder.get()));
  rv = dbFolder->CreateDirectoryForFolder(path);
  NS_ENSURE_SUCCESS(rv, rv);

  folder->GetFlags((PRUint32 *)&flags);
  
  flags |= MSG_FOLDER_FLAG_MAIL;
  
  folder->SetParent(this);
  
  folder->SetFlags(flags);
  
  nsCOMPtr<nsISupports> supports = do_QueryInterface(folder);
  if(folder)
    mSubFolders->AppendElement(supports);
  NS_ADDREF(*aChild = folder);
  
  nsCOMPtr <nsIMsgImapMailFolder> imapChild = do_QueryInterface(*aChild);
  if (imapChild)
  {
    NS_LossyConvertUTF16toASCII folderCName(aName);
    imapChild->SetOnlineName(folderCName.get());
    imapChild->SetHierarchyDelimiter(m_hierarchyDelimiter);
  }
  return rv;
}

Here is the call graph for this function:

Here is the caller graph for this function:

NS_IMETHODIMP nsImapMailFolder::AddSubfolderWithPath ( nsAString &  name,
nsIFileSpec dbPath,
nsIMsgFolder **  child 
)

Definition at line 396 of file nsImapMailFolder.cpp.

{
  if(!child)
    return NS_ERROR_NULL_POINTER;

  nsresult rv = NS_OK;
  nsCOMPtr<nsIRDFService> rdf(do_GetService(kRDFServiceCID, &rv)); 

  if(NS_FAILED(rv))
    return rv;

  PRInt32 flags = 0;

  nsCAutoString uri = mURI + NS_LITERAL_CSTRING("/");
  AppendUTF16toUTF8(name, uri);

  //will make sure mSubFolders does not have duplicates because of bogus msf files.

  nsCOMPtr <nsIMsgFolder> msgFolder;
  rv = GetChildWithURI(uri.get(), PR_FALSE/*deep*/, PR_FALSE /*case Insensitive*/, getter_AddRefs(msgFolder));  
  if (NS_SUCCEEDED(rv) && msgFolder)
  {
    return NS_MSG_FOLDER_EXISTS;
  }
  
  nsCOMPtr<nsIRDFResource> res;
  rv = rdf->GetResource(uri, getter_AddRefs(res));
  if (NS_FAILED(rv))
    return rv;

  nsCOMPtr<nsIMsgFolder> folder(do_QueryInterface(res, &rv));
  if (NS_FAILED(rv))
    return rv;        

  folder->SetPath(dbPath);
    nsCOMPtr<nsIMsgImapMailFolder> imapFolder = do_QueryInterface(folder);

    folder->GetFlags((PRUint32 *)&flags);

    folder->SetParent(this);

  flags |= MSG_FOLDER_FLAG_MAIL;

   PRBool isServer;
   rv = GetIsServer(&isServer);

   PRInt32 pFlags;
   GetFlags ((PRUint32 *) &pFlags);
   PRBool isParentInbox = pFlags & MSG_FOLDER_FLAG_INBOX;
 
   //Only set these if these are top level children or parent is inbox

  if(NS_SUCCEEDED(rv))
  {
    if(isServer &&
       name.LowerCaseEqualsLiteral("inbox"))
      flags |= MSG_FOLDER_FLAG_INBOX;
    else if(isServer || isParentInbox) 
    {
      nsAutoString trashName;
      GetTrashFolderName(trashName);
      if (name.Equals(trashName))
        flags |= MSG_FOLDER_FLAG_TRASH;
    }
#if 0
    else if(name.LowerCaseEqualsLiteral("sent"))
      folder->SetFlag(MSG_FOLDER_FLAG_SENTMAIL);
    else if(name.LowerCaseEqualsLiteral("drafts"))
      folder->SetFlag(MSG_FOLDER_FLAG_DRAFTS);
    else if (name.LowerCaseEqualsLiteral("templates"))
      folder->SetFlag(MSG_FOLDER_FLAG_TEMPLATES);
#endif
  }

    folder->SetFlags(flags);
  //at this point we must be ok and we don't want to return failure in case GetIsServer failed.
  rv = NS_OK;

  nsCOMPtr <nsISupports> supports = do_QueryInterface(folder);
  NS_ASSERTION(supports, "couldn't get isupports from imap folder");
  if (supports)
    mSubFolders->AppendElement(supports);
  *child = folder;
  NS_IF_ADDREF(*child);
  return rv;
}

Here is the call graph for this function:

Here is the caller graph for this function:

nsresult nsImapMailFolder::AllocateUidStringFromKeys ( nsMsgKey keys,
PRUint32  numKeys,
nsCString msgIds 
) [static]

Definition at line 2118 of file nsImapMailFolder.cpp.

{
  if (!numKeys)
    return NS_ERROR_INVALID_ARG;
  nsresult rv = NS_OK;
  PRUint32 startSequence;
  startSequence = keys[0];
  PRUint32 curSequenceEnd = startSequence;
  PRUint32 total = numKeys;
  // sort keys and then generate ranges instead of singletons!
  NS_QuickSort(keys, numKeys, sizeof(nsMsgKey), CompareKey, nsnull);
  for (PRUint32 keyIndex = 0; keyIndex < total; keyIndex++)
  {
    PRUint32 curKey = keys[keyIndex];
    PRUint32 nextKey = (keyIndex + 1 < total) ? keys[keyIndex + 1] : 0xFFFFFFFF;
    PRBool lastKey = (nextKey == 0xFFFFFFFF);

    if (lastKey)
      curSequenceEnd = curKey;
    if (nextKey == (PRUint32) curSequenceEnd + 1 && !lastKey)
    {
      curSequenceEnd = nextKey;
      continue;
    }
    else if (curSequenceEnd > startSequence)
    {
      AppendUid(msgIds, startSequence);
      msgIds += ':';
      AppendUid(msgIds,curSequenceEnd);
      if (!lastKey)
        msgIds += ',';
      startSequence = nextKey;
      curSequenceEnd = startSequence;
    }
    else
    {
      startSequence = nextKey;
      curSequenceEnd = startSequence;
      AppendUid(msgIds, keys[keyIndex]);
      if (!lastKey)
        msgIds += ',';
    }
  }
  return rv;
}

Here is the call graph for this function:

Here is the caller graph for this function:

nsresult nsImapMailFolder::BuildIdsAndKeyArray ( nsISupportsArray messages,
nsCString msgIds,
nsMsgKeyArray &  keyArray 
) [protected]

Definition at line 2082 of file nsImapMailFolder.cpp.

{
    nsresult rv = NS_ERROR_NULL_POINTER;
    PRUint32 count = 0;
    PRUint32 i;

    if (!messages) return rv;

    rv = messages->Count(&count);
    if (NS_FAILED(rv)) return rv;

    // build up message keys.
    for (i = 0; i < count; i++)
    {
      nsMsgKey key;
      nsCOMPtr <nsIMsgDBHdr> msgDBHdr = do_QueryElementAt(messages, i, &rv);
      if (msgDBHdr)
        rv = msgDBHdr->GetMessageKey(&key);
      if (NS_SUCCEEDED(rv))
        keyArray.Add(key);
    }
    
  return AllocateUidStringFromKeys(keyArray.GetArray(), keyArray.GetSize(), msgIds);
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 1246 of file nsImapMailFolder.cpp.

{
  nsresult rv;

  rv = GetDatabase(nsnull);
  // now's a good time to apply the retention settings. If we do delete any
  // messages, the expunge is going to have to wait until the delete to 
  // finish before it can run, but the multiple-connection protection code
  // should handle that.
  if (mDatabase)
    ApplyRetentionSettings();

  // compact offline store, if folder configured for offline use.
  // for now, check aMsgWindow because not having aMsgWindow means
  // we're doing a compact at shut-down. TEMPORARY HACK
  if (aMsgWindow && mFlags & MSG_FOLDER_FLAG_OFFLINE)
    CompactOfflineStore(aMsgWindow);

  nsCOMPtr<nsIImapService> imapService = do_GetService(NS_IMAPSERVICE_CONTRACTID, &rv);
  NS_ENSURE_SUCCESS(rv,rv);
 
  return  imapService->Expunge(m_eventQueue, this, aListener, nsnull);
}

Here is the call graph for this function:

NS_IMETHODIMP nsImapMailFolder::CompactAll ( nsIUrlListener aListener,
nsIMsgWindow aMsgWindow,
nsISupportsArray aFolderArray,
PRBool  aCompactOfflineAlso,
nsISupportsArray aOfflineFolderArray 
)

Definition at line 1270 of file nsImapMailFolder.cpp.

{
  NS_ASSERTION(!aOfflineFolderArray, "compacting automatically compacts offline stores");
  nsresult rv = NS_OK;
  nsCOMPtr<nsISupportsArray> folderArray; 

  if (!aFolderArray)
  {
    nsCOMPtr<nsIMsgFolder> rootFolder;
    nsCOMPtr<nsISupportsArray> allDescendents;
    rv = GetRootFolder(getter_AddRefs(rootFolder));  
    if (NS_SUCCEEDED(rv) && rootFolder)
    {
      NS_NewISupportsArray(getter_AddRefs(allDescendents));
      rootFolder->ListDescendents(allDescendents);
      PRUint32 cnt =0;
      rv = allDescendents->Count(&cnt);
      NS_ENSURE_SUCCESS(rv,rv);
      NS_NewISupportsArray(getter_AddRefs(folderArray));
      for (PRUint32 i=0; i< cnt;i++)
      {
        nsCOMPtr<nsISupports> supports = getter_AddRefs(allDescendents->ElementAt(i));
        nsCOMPtr<nsIMsgFolder> folder = do_QueryInterface(supports, &rv);
        NS_ENSURE_SUCCESS(rv,rv);
        rv = folderArray->AppendElement(supports);

      }
      rv = folderArray->Count(&cnt);
      NS_ENSURE_SUCCESS(rv,rv);
      if (cnt == 0 )
        return NotifyCompactCompleted();
    }
  }
  nsCOMPtr <nsIMsgFolderCompactor> folderCompactor =  do_CreateInstance(NS_MSGLOCALFOLDERCOMPACTOR_CONTRACTID, &rv);
  if (NS_SUCCEEDED(rv) && folderCompactor)
    if (aFolderArray)
       rv = folderCompactor->CompactAll(aFolderArray, aMsgWindow, aCompactOfflineAlso, aOfflineFolderArray);  
    else if (folderArray)
       rv = folderCompactor->CompactAll(folderArray, aMsgWindow, aCompactOfflineAlso, aOfflineFolderArray);  
  return rv;
}

Here is the call graph for this function:

void nsICopyMessageListener::copyData ( in nsIInputStream  aIStream,
in long  aLength 
) [inherited]

Definition at line 3216 of file nsImapMailFolder.cpp.

{
  m_copyState = nsnull;
  return NS_OK;
}

Definition at line 3138 of file nsImapMailFolder.cpp.

{
  PRUint32 readCount;
  PRUint32 writeCount;

  if (!m_copyState)
  {
    nsImapMailCopyState* copyState = new nsImapMailCopyState();
    m_copyState = do_QueryInterface(copyState);
  }
  if ( aLength + m_copyState->m_leftOver > m_copyState->m_dataBufferSize )
  {
    m_copyState->m_dataBuffer = (char *) PR_REALLOC(m_copyState->m_dataBuffer, aLength + m_copyState->m_leftOver+ 1);
    if (!m_copyState->m_dataBuffer)
      return NS_ERROR_OUT_OF_MEMORY;
    m_copyState->m_dataBufferSize = aLength + m_copyState->m_leftOver;
  }

  char *start, *end;
  PRUint32 linebreak_len = 1;

  nsresult rv = aIStream->Read(m_copyState->m_dataBuffer+m_copyState->m_leftOver, aLength, &readCount);
  if (NS_FAILED(rv)) 
    return rv;

  m_copyState->m_leftOver += readCount;
  m_copyState->m_dataBuffer[m_copyState->m_leftOver] = '\0';

  start = m_copyState->m_dataBuffer;
  if (m_copyState->m_eatLF)
  {
    if (*start == nsCRT::LF)
      start++;
    m_copyState->m_eatLF = PR_FALSE;
  }
  end = PL_strpbrk(start, "\r\n");
  if (end && *end == '\r' && *(end+1) == '\n')
    linebreak_len = 2;

  while (start && end)
  {
    if (PL_strncasecmp(start, "X-Mozilla-Status:", 17) &&
        PL_strncasecmp(start, "X-Mozilla-Status2:", 18) &&
        PL_strncmp(start, "From - ", 7))
    {
      rv = outputStream->Write(start,
                                             end-start,
                                             &writeCount);
      rv = outputStream->Write(CRLF, 2, &writeCount);
    }
    start = end+linebreak_len;
    if (start >=
        m_copyState->m_dataBuffer+m_copyState->m_leftOver)
    {
       m_copyState->m_leftOver = 0;
       break;
    }
    linebreak_len = 1;

    end = PL_strpbrk(start, "\r\n");
    if (end && *end == '\r')
    {
      if (*(end+1) == '\n')
        linebreak_len = 2;
      else if (! *(end+1)) // block might have split CRLF so remember if
        m_copyState->m_eatLF = PR_TRUE; // we should eat LF
    }

    if (start && !end)
    {
      m_copyState->m_leftOver -= (start - m_copyState->m_dataBuffer);
      memcpy(m_copyState->m_dataBuffer, start, m_copyState->m_leftOver+1); // including null
    }
  }
  return rv;
}

Here is the call graph for this function:

NS_IMETHODIMP nsImapMailFolder::CopyFileMessage ( nsIFileSpec fileSpec,
nsIMsgDBHdr msgToReplace,
PRBool  isDraftOrTemplate,
PRUint32  aNewMsgFlags,
nsIMsgWindow msgWindow,
nsIMsgCopyServiceListener listener 
)

Definition at line 7391 of file nsImapMailFolder.cpp.

{
    nsresult rv = NS_ERROR_NULL_POINTER;
    nsMsgKey key = 0xffffffff;
    nsCAutoString messageId;
    nsCOMPtr<nsIUrlListener> urlListener;
    nsCOMPtr<nsISupportsArray> messages;
    nsCOMPtr<nsISupports> srcSupport = do_QueryInterface(fileSpec, &rv);

    rv = NS_NewISupportsArray(getter_AddRefs(messages));
    if (NS_FAILED(rv)) 
      return OnCopyCompleted(srcSupport, rv);

    nsCOMPtr<nsIImapService> imapService = do_GetService(NS_IMAPSERVICE_CONTRACTID, &rv);
    if (NS_FAILED(rv)) 
      return OnCopyCompleted(srcSupport, rv);

    rv = QueryInterface(NS_GET_IID(nsIUrlListener), getter_AddRefs(urlListener));

    if (msgToReplace)
    {
        rv = msgToReplace->GetMessageKey(&key);
        if (NS_SUCCEEDED(rv))
            messageId.AppendInt((PRInt32) key);
    }

    rv = InitCopyState(srcSupport, messages, PR_FALSE, isDraftOrTemplate,
                       PR_FALSE, aNewMsgFlags, listener, msgWindow, PR_FALSE);
    if (NS_FAILED(rv)) 
      return OnCopyCompleted(srcSupport, rv);

    m_copyState->m_streamCopy = PR_TRUE;

    nsCOMPtr<nsISupports> copySupport;
    if( m_copyState ) 
        copySupport = do_QueryInterface(m_copyState);
    if (!isDraftOrTemplate)
      m_copyState->m_totalCount = 1;
    rv = imapService->AppendMessageFromFile(m_eventQueue, fileSpec, this,
                                            messageId.get(),
                                            PR_TRUE, isDraftOrTemplate,
                                            urlListener, nsnull,
                                            copySupport,
                                            msgWindow);
    if (NS_FAILED(rv))
      return OnCopyCompleted(srcSupport, rv);

    return rv;
}

Here is the call graph for this function:

NS_IMETHODIMP nsImapMailFolder::CopyFolder ( nsIMsgFolder srcFolder,
PRBool  isMove,
nsIMsgWindow msgWindow,
nsIMsgCopyServiceListener listener 
)

Definition at line 7251 of file nsImapMailFolder.cpp.

{

  NS_ENSURE_ARG_POINTER(srcFolder);
  
  nsresult rv = NS_OK;

  if (isMoveFolder)   //move folder permitted when dstFolder and the srcFolder are on same server
  {
    PRUint32 folderFlags = 0;    
    if (srcFolder)
      srcFolder->GetFlags(&folderFlags);
    
    // if our source folder is a virtual folder
    if (folderFlags & MSG_FOLDER_FLAG_VIRTUAL) 
    {
      nsCOMPtr<nsIMsgFolder> newMsgFolder;
      nsXPIDLString folderName;
      srcFolder->GetName(getter_Copies(folderName));
      
      nsCAutoString tempSafeFolderName;
      tempSafeFolderName.AssignWithConversion(folderName.get());
      NS_MsgHashIfNecessary(tempSafeFolderName);
      
      nsAutoString safeFolderName;
      safeFolderName.AssignWithConversion(tempSafeFolderName);  
      srcFolder->ForceDBClosed();   
  
      nsCOMPtr<nsIFileSpec> oldPathSpec;
      rv = srcFolder->GetPath(getter_AddRefs(oldPathSpec));
      NS_ENSURE_SUCCESS(rv,rv);
  
      nsFileSpec oldPath;
      rv = oldPathSpec->GetFileSpec(&oldPath);
      NS_ENSURE_SUCCESS(rv,rv);
  
      nsLocalFolderSummarySpec  summarySpec(oldPath);
  
      nsCOMPtr<nsIFileSpec> newPathSpec;
      rv = GetPath(getter_AddRefs(newPathSpec));
      NS_ENSURE_SUCCESS(rv,rv);
  
      nsFileSpec newPath;
      rv = newPathSpec->GetFileSpec(&newPath);
      NS_ENSURE_SUCCESS(rv,rv);
  
      if (!newPath.IsDirectory())
      {
        AddDirectorySeparator(newPath);
        newPath.CreateDirectory();
      }
  
      rv = CheckIfFolderExists(folderName.get(), this, msgWindow);
      if(NS_FAILED(rv)) 
        return rv;
  
      rv = summarySpec.CopyToDir(newPath);
      NS_ENSURE_SUCCESS(rv, rv);
  
      rv = AddSubfolder(safeFolderName, getter_AddRefs(newMsgFolder));  
      NS_ENSURE_SUCCESS(rv, rv);

      newMsgFolder->SetPrettyName(folderName.get());
  
      PRUint32 flags;
      srcFolder->GetFlags(&flags);
      newMsgFolder->SetFlags(flags);
      
      NotifyItemAdded(newMsgFolder);

      // now remove the old folder
      nsCOMPtr<nsIMsgFolder> msgParent;
      srcFolder->GetParentMsgFolder(getter_AddRefs(msgParent));
      srcFolder->SetParent(nsnull);
      if (msgParent) 
      {
        msgParent->PropagateDelete(srcFolder, PR_FALSE, msgWindow);  // The files have already been moved, so delete storage PR_FALSE 
        oldPath.Delete(PR_FALSE);  //berkeley mailbox
        nsCOMPtr <nsIMsgDatabase> srcDB; // we need to force closed the source db
        srcFolder->Delete();

        nsCOMPtr<nsIFileSpec> parentPathSpec;
        rv = msgParent->GetPath(getter_AddRefs(parentPathSpec));
        NS_ENSURE_SUCCESS(rv,rv);
  
        nsFileSpec parentPath;
        rv = parentPathSpec->GetFileSpec(&parentPath);
        NS_ENSURE_SUCCESS(rv,rv);

        AddDirectorySeparator(parentPath); 
        nsDirectoryIterator i(parentPath, PR_FALSE);
        // i.Exists() checks if the directory is empty or not 
        if (parentPath.IsDirectory() && !i.Exists())
          parentPath.Delete(PR_TRUE);
      }
    }
    else // non-virtual folder
    {
      nsCOMPtr <nsIImapService> imapService = do_GetService (NS_IMAPSERVICE_CONTRACTID, &rv);
      if (NS_SUCCEEDED(rv))
      {
        nsCOMPtr <nsIUrlListener> urlListener = do_QueryInterface(srcFolder);
        PRBool match = PR_FALSE;
        PRBool confirmed = PR_FALSE;
        if (mFlags & MSG_FOLDER_FLAG_TRASH)
        {
          rv = srcFolder->MatchOrChangeFilterDestination(nsnull, PR_FALSE, &match);
          if (match)
          {
            srcFolder->ConfirmFolderDeletionForFilter(msgWindow, &confirmed);
            // should we return an error to copy service?
            // or send a notification?
            if (!confirmed) 
              return NS_OK;
          }
        }
        rv = imapService->MoveFolder(m_eventQueue,
                                     srcFolder,
                                     this,
                                     urlListener,
                                     msgWindow,
                                     nsnull);
      }
    }
  }
  else // copying folder (should only be across server?)
  {
    nsImapFolderCopyState *folderCopier = new nsImapFolderCopyState(
      this, srcFolder, isMoveFolder, msgWindow, listener);
    NS_ADDREF(folderCopier); // it owns itself.
    return folderCopier->StartNextCopy();
  }
  return rv;
  
}

Here is the call graph for this function:

NS_IMETHODIMP nsImapMailFolder::CopyMessages ( nsIMsgFolder srcFolder,
nsISupportsArray messages,
PRBool  isMove,
nsIMsgWindow msgWindow,
nsIMsgCopyServiceListener listener,
PRBool  isFolder,
PRBool  allowUndo 
)

Definition at line 6861 of file nsImapMailFolder.cpp.

{
  nsresult rv = NS_OK;
  nsCAutoString messageIds;
  nsMsgKeyArray srcKeyArray;
  nsCOMPtr<nsIUrlListener> urlListener;
  nsCOMPtr<nsISupports> srcSupport;
  nsCOMPtr<nsISupports> copySupport;

  if (!(mFlags & (MSG_FOLDER_FLAG_TRASH|MSG_FOLDER_FLAG_JUNK)))
    SetMRUTime();

  if (WeAreOffline())
    return CopyMessagesOffline(srcFolder, messages, isMove, msgWindow, listener);

  nsCOMPtr<nsIImapService> imapService = do_GetService(NS_IMAPSERVICE_CONTRACTID, &rv);
  NS_ENSURE_SUCCESS(rv,rv);

  srcSupport = do_QueryInterface(srcFolder);

  nsCOMPtr <nsIMsgIncomingServer> srcServer;
  nsCOMPtr <nsIMsgIncomingServer> dstServer;

  rv = srcFolder->GetServer(getter_AddRefs(srcServer));
  if(NS_FAILED(rv)) goto done;

  rv = GetServer(getter_AddRefs(dstServer));
  if(NS_FAILED(rv)) goto done;

  NS_ENSURE_TRUE(dstServer, NS_ERROR_NULL_POINTER);
  PRBool sameServer;
  rv = dstServer->Equals(srcServer, &sameServer);
  if (NS_FAILED(rv)) goto done;

   PRUint32 supportedUserFlags;
   GetSupportedUserFlags(&supportedUserFlags);

   if (! (supportedUserFlags & kImapMsgSupportUserFlag))
   {
      PRUint32 count = 0;
      PRUint32 i;

      rv = messages->Count(&count);
      if (NS_FAILED(rv)) return rv;

      // make sure database is open to set special flags below
      if (!mDatabase)
        GetDatabase(nsnull);

      // check if any msg hdr has special flags or properties set
      // that we need to set on the dest hdr
      for (i = 0; i < count; i++)
      {
        nsCOMPtr <nsIMsgDBHdr> msgDBHdr = do_QueryElementAt(messages, i, &rv);
        if (mDatabase && msgDBHdr)
        {
          nsMsgLabelValue label;
          nsXPIDLCString junkScore, junkScoreOrigin;
          nsMsgPriorityValue priority;
          msgDBHdr->GetStringProperty("junkscore", getter_Copies(junkScore));
          msgDBHdr->GetStringProperty("junkscoreorigin", getter_Copies(junkScoreOrigin));
          if (!junkScore.IsEmpty()) // ignore already scored messages.
            mDatabase->SetAttributesOnPendingHdr(msgDBHdr, "junkscore", junkScore.get(), 0);
          if (!junkScoreOrigin.IsEmpty())
            mDatabase->SetAttributesOnPendingHdr(msgDBHdr, "junkscoreorigin", junkScoreOrigin.get(), 0);
          msgDBHdr->GetLabel(&label);
          if (label != 0)
          {
            nsCAutoString labelStr;
            labelStr.AppendInt(label);
            mDatabase->SetAttributesOnPendingHdr(msgDBHdr, "label", labelStr.get(), 0);
          }
         msgDBHdr->GetPriority(&priority);
         if(priority != 0)
          {
            nsCAutoString priorityStr;
            priorityStr.AppendInt(priority);
            mDatabase->SetAttributesOnPendingHdr(msgDBHdr, "priority", priorityStr.get(), 0);
          }
          nsXPIDLCString keywords;
          msgDBHdr->GetStringProperty("keywords", getter_Copies(keywords));
          if (!keywords.IsEmpty())
            mDatabase->SetAttributesOnPendingHdr(msgDBHdr, "keywords", keywords.get(), 0);
        }
      }
   }
  // if the folders aren't on the same server, do a stream base copy
  if (!sameServer) 
  {
    rv = CopyMessagesWithStream(srcFolder, messages, isMove, PR_TRUE, msgWindow, listener, allowUndo);
    goto done;
  }

  rv = BuildIdsAndKeyArray(messages, messageIds, srcKeyArray);
  if(NS_FAILED(rv)) goto done;

  rv = QueryInterface(NS_GET_IID(nsIUrlListener), getter_AddRefs(urlListener));

  rv = InitCopyState(srcSupport, messages, isMove, PR_TRUE, PR_FALSE, 
    /* newMsgFlags, not used */0, listener, msgWindow, allowUndo);
  if (NS_FAILED(rv)) goto done;

  m_copyState->m_curIndex = m_copyState->m_totalCount;

  if (isMove)
    srcFolder->EnableNotifications(allMessageCountNotifications, PR_FALSE, PR_TRUE/* dbBatching*/);  //disable message count notification 

  copySupport = do_QueryInterface(m_copyState);
  if (imapService)
  rv = imapService->OnlineMessageCopy(m_eventQueue,
                                            srcFolder, messageIds.get(),
                                            this, PR_TRUE, isMove,
                                            urlListener, nsnull,
                                            copySupport, msgWindow);
  if (m_copyState->m_allowUndo)
    if (NS_SUCCEEDED(rv))
    {
       nsImapMoveCopyMsgTxn* undoMsgTxn = new nsImapMoveCopyMsgTxn;
       if (!undoMsgTxn || NS_FAILED(undoMsgTxn->Init(srcFolder, &srcKeyArray, 
                                    messageIds.get(), this,
                                    PR_TRUE, isMove, m_eventQueue, urlListener)))
       {
         delete undoMsgTxn;
         return NS_ERROR_OUT_OF_MEMORY;
       }
       if (isMove)
       {
         if (mFlags & MSG_FOLDER_FLAG_TRASH)
           undoMsgTxn->SetTransactionType(nsIMessenger::eDeleteMsg);
         else
           undoMsgTxn->SetTransactionType(nsIMessenger::eMoveMsg);
       }
       else
       {
          undoMsgTxn->SetTransactionType(nsIMessenger::eCopyMsg);
       }
       rv = undoMsgTxn->QueryInterface(
         NS_GET_IID(nsImapMoveCopyMsgTxn), 
         getter_AddRefs(m_copyState->m_undoMsgTxn) );
    }
    else 
      NS_ASSERTION(PR_FALSE, "online copy failed");

done:
    if (NS_FAILED(rv))
    {
      (void) OnCopyCompleted(srcSupport, PR_FALSE);
      if (isMove)
      {
        srcFolder->EnableNotifications(allMessageCountNotifications, PR_TRUE, PR_TRUE/* dbBatching*/);  //enable message count notification 
        NotifyFolderEvent(mDeleteOrMoveMsgFailedAtom);
      }
    }
    return rv;
}

Here is the call graph for this function:

nsresult nsImapMailFolder::CopyMessagesOffline ( nsIMsgFolder srcFolder,
nsISupportsArray messages,
PRBool  isMove,
nsIMsgWindow msgWindow,
nsIMsgCopyServiceListener listener 
) [protected]

Definition at line 6569 of file nsImapMailFolder.cpp.

{
  NS_ENSURE_ARG(messages);
  nsresult rv = NS_OK;
  nsresult stopit = 0;
  nsCOMPtr <nsIMsgDatabase> sourceMailDB;
  nsCOMPtr <nsIDBFolderInfo> srcDbFolderInfo;
  srcFolder->GetDBFolderInfoAndDB(getter_AddRefs(srcDbFolderInfo), getter_AddRefs(sourceMailDB));
  PRBool deleteToTrash = PR_FALSE;
  PRBool deleteImmediately = PR_FALSE;
  PRUint32 srcCount;
  messages->Count(&srcCount);
  nsCOMPtr<nsIImapIncomingServer> imapServer;
  rv = GetImapIncomingServer(getter_AddRefs(imapServer));

  if (NS_SUCCEEDED(rv) && imapServer)
  {
    nsMsgImapDeleteModel deleteModel;
    imapServer->GetDeleteModel(&deleteModel);
    deleteToTrash = (deleteModel == nsMsgImapDeleteModels::MoveToTrash);
    deleteImmediately = (deleteModel == nsMsgImapDeleteModels::DeleteNoTrash);
  }    
  if (sourceMailDB)
  {
    // save the future ops in the source DB, if this is not a imap->local copy/move
    
    nsCOMPtr <nsITransactionManager> txnMgr;
    if (msgWindow)
      msgWindow->GetTransactionManager(getter_AddRefs(txnMgr));
    if (txnMgr)
      txnMgr->BeginBatch();
    GetDatabase(nsnull);
    if (mDatabase) 
    {
      // get the highest key in the dest db, so we can make up our fake keys
      PRBool highWaterDeleted = PR_FALSE;
      nsMsgKey fakeBase = 1;
      nsCOMPtr <nsIDBFolderInfo> folderInfo;
      rv = mDatabase->GetDBFolderInfo(getter_AddRefs(folderInfo));
      NS_ENSURE_SUCCESS(rv, rv);
      nsMsgKey highWaterMark = nsMsgKey_None;
      folderInfo->GetHighWater(&highWaterMark);
      
      fakeBase += highWaterMark;
      
      // put fake message in destination db, delete source if move
      for (PRUint32 sourceKeyIndex=0; !stopit && (sourceKeyIndex < srcCount); sourceKeyIndex++)
      {
        PRBool       messageReturningHome = PR_FALSE;
        nsXPIDLCString sourceFolderURI;
        srcFolder->GetURI(getter_Copies(sourceFolderURI));
        nsXPIDLCString originalSrcFolderURI;
        if (sourceFolderURI.get())
          originalSrcFolderURI.Adopt(nsCRT::strdup(sourceFolderURI.get()));
        nsCOMPtr<nsIMsgDBHdr> message;
        message = do_QueryElementAt(messages, sourceKeyIndex);
        nsMsgKey originalKey;
        if (message)
        {
          rv = message->GetMessageKey(&originalKey);
        }
        else
        {
          NS_ASSERTION(PR_FALSE, "bad msg in src array");
          continue;
        }
        nsCOMPtr <nsIMsgOfflineImapOperation> sourceOp;
        rv = sourceMailDB->GetOfflineOpForKey(originalKey, PR_TRUE, getter_AddRefs(sourceOp));
        if (NS_SUCCEEDED(rv) && sourceOp)
        {
          srcFolder->SetFlag(MSG_FOLDER_FLAG_OFFLINEEVENTS);
          nsCOMPtr <nsIMsgDatabase> originalDB;
          nsOfflineImapOperationType opType;
          sourceOp->GetOperation(&opType);
          // if we already have an offline op for this key, then we need to see if it was
          // moved into the source folder while offline
          if (opType == nsIMsgOfflineImapOperation::kMoveResult) // offline move
          {
            // gracious me, we are moving something we already moved while offline!
            // find the original operation and clear it!
            nsCOMPtr <nsIMsgOfflineImapOperation> originalOp;
            rv = GetClearedOriginalOp(sourceOp, getter_AddRefs(originalOp), getter_AddRefs(originalDB));
            if (originalOp)
            {
              nsXPIDLCString originalString;
              nsXPIDLCString srcFolderURI;
              
              srcFolder->GetURI(getter_Copies(srcFolderURI));
              sourceOp->GetSourceFolderURI(getter_Copies(originalString));
              sourceOp->GetMessageKey(&originalKey);
              originalSrcFolderURI.Adopt(originalString.get() ? nsCRT::strdup(originalString.get()) : 0);
              
              if (isMove)
                sourceMailDB->RemoveOfflineOp(sourceOp);
              
              sourceOp = originalOp;
              if (!nsCRT::strcmp(originalSrcFolderURI, srcFolderURI))
              {
                messageReturningHome = PR_TRUE;
                originalDB->RemoveOfflineOp(originalOp);
              }
            }
          }
          
          if (!messageReturningHome)
          {
            nsXPIDLCString folderURI;
            GetURI(getter_Copies(folderURI));
            
            if (isMove)
            {
              PRUint32 msgSize;
              PRUint32 msgFlags;
              imapMessageFlagsType newImapFlags = 0;
              message->GetMessageSize(&msgSize);
              message->GetFlags(&msgFlags);
              sourceOp->SetDestinationFolderURI(folderURI); // offline move
              sourceOp->SetOperation(nsIMsgOfflineImapOperation::kMsgMoved);
              sourceOp->SetMsgSize(msgSize);
              newImapFlags = msgFlags & 0x7;
              if (msgFlags & MSG_FLAG_FORWARDED)
                newImapFlags |=  kImapMsgForwardedFlag;
              sourceOp->SetNewFlags(newImapFlags);
            }
            else
              sourceOp->AddMessageCopyOperation(folderURI); // offline copy

           nsMsgKeyArray srcKeyArray;
           nsCOMPtr<nsIUrlListener> urlListener;

            sourceOp->GetOperation(&opType);
           srcKeyArray.Add(originalKey);
           rv = QueryInterface(NS_GET_IID(nsIUrlListener), getter_AddRefs(urlListener));
           nsImapOfflineTxn *undoMsgTxn = new 
              nsImapOfflineTxn(srcFolder, &srcKeyArray, this, isMove, opType, message,
                m_eventQueue, urlListener);

            if (undoMsgTxn)
            {
              if (isMove)
                undoMsgTxn->SetTransactionType(nsIMessenger::eMoveMsg);
              else
                undoMsgTxn->SetTransactionType(nsIMessenger::eCopyMsg);
              // we're adding this undo action before the delete is successful. This is evil,
              // but 4.5 did it as well.
              if (txnMgr)
                txnMgr->DoTransaction(undoMsgTxn);
            }
          }
          PRBool hasMsgOffline = PR_FALSE;
          srcFolder->HasMsgOffline(originalKey, &hasMsgOffline);
//          if (hasMsgOffline)
//            CopyOfflineMsgBody(srcFolder, originalKey);

        }
        else
          stopit = NS_ERROR_FAILURE;
        
        
        nsCOMPtr <nsIMsgDBHdr> mailHdr;
        rv = sourceMailDB->GetMsgHdrForKey(originalKey, getter_AddRefs(mailHdr));
        if (NS_SUCCEEDED(rv) && mailHdr)
        {
          PRBool successfulCopy = PR_FALSE;
          nsMsgKey srcDBhighWaterMark;
          srcDbFolderInfo->GetHighWater(&srcDBhighWaterMark);
          highWaterDeleted = !highWaterDeleted && isMove && deleteToTrash &&
            (originalKey == srcDBhighWaterMark);
          
          nsCOMPtr <nsIMsgDBHdr> newMailHdr;
          rv = mDatabase->CopyHdrFromExistingHdr(fakeBase + sourceKeyIndex, mailHdr,
            PR_TRUE, getter_AddRefs(newMailHdr));
          if (!newMailHdr || NS_FAILED(rv))
          {
            NS_ASSERTION(PR_FALSE, "failed to copy hdr");
            stopit = rv;
          }
          
          if (NS_SUCCEEDED(stopit))
          {
            PRBool hasMsgOffline = PR_FALSE;
            srcFolder->HasMsgOffline(originalKey, &hasMsgOffline);
            if (hasMsgOffline)
              CopyOfflineMsgBody(srcFolder, newMailHdr, mailHdr);

            nsCOMPtr <nsIMsgOfflineImapOperation> destOp;
            mDatabase->GetOfflineOpForKey(fakeBase + sourceKeyIndex, PR_TRUE, getter_AddRefs(destOp));
            if (destOp)
            {
              // check if this is a move back to the original mailbox, in which case
              // we just delete the offline operation.
              if (messageReturningHome)
              {
                mDatabase->RemoveOfflineOp(destOp);
              }
              else
              {
                SetFlag(MSG_FOLDER_FLAG_OFFLINEEVENTS);
                destOp->SetSourceFolderURI(originalSrcFolderURI);
                destOp->SetMessageKey(originalKey);
                {
                  nsCOMPtr<nsIUrlListener> urlListener;

                  QueryInterface(NS_GET_IID(nsIUrlListener), getter_AddRefs(urlListener));
                  nsMsgKeyArray keyArray;
                  keyArray.Add(fakeBase + sourceKeyIndex);
                  nsImapOfflineTxn *undoMsgTxn = new 
                    nsImapOfflineTxn(this, &keyArray, this, isMove, nsIMsgOfflineImapOperation::kAddedHeader,
                      newMailHdr, m_eventQueue, urlListener);
                 if (undoMsgTxn)
                 {
                   if (txnMgr)
                     txnMgr->DoTransaction(undoMsgTxn);
                 }
                }
              }
            }
            else
              stopit = NS_ERROR_FAILURE;
          }
          successfulCopy = NS_SUCCEEDED(stopit);
          
          
          nsMsgKey msgKey;
          mailHdr->GetMessageKey(&msgKey);
          if (isMove && successfulCopy)   
          {
           nsMsgKeyArray srcKeyArray;
           nsCOMPtr<nsIUrlListener> urlListener;

           srcKeyArray.Add(msgKey);
           rv = QueryInterface(NS_GET_IID(nsIUrlListener), getter_AddRefs(urlListener));

            nsOfflineImapOperationType opType = nsIMsgOfflineImapOperation::kDeletedMsg;
            if (!deleteToTrash)
              opType = nsIMsgOfflineImapOperation::kMsgMarkedDeleted;
            srcKeyArray.Add(msgKey);
            nsImapOfflineTxn *undoMsgTxn = new 
              nsImapOfflineTxn(srcFolder, &srcKeyArray, this, isMove, opType, mailHdr,
                m_eventQueue, urlListener);
             if (undoMsgTxn)
             {
               if (isMove)
               {
                 if (mFlags & MSG_FOLDER_FLAG_TRASH)
                   undoMsgTxn->SetTransactionType(nsIMessenger::eDeleteMsg);
                 else
                   undoMsgTxn->SetTransactionType(nsIMessenger::eMoveMsg);
               }
               else
               {
                  undoMsgTxn->SetTransactionType(nsIMessenger::eCopyMsg);
               }
               if (txnMgr)
                 txnMgr->DoTransaction(undoMsgTxn);
             }
            if (deleteToTrash || deleteImmediately)
              sourceMailDB->DeleteMessage(msgKey, nsnull, PR_FALSE);
            else
              sourceMailDB->MarkImapDeleted(msgKey,PR_TRUE,nsnull); // offline delete
          }
          
          
          if (!successfulCopy)
            highWaterDeleted = PR_FALSE;
        }
      }
            
      if (isMove)
        sourceMailDB->Commit(nsMsgDBCommitType::kLargeCommit);
      mDatabase->Commit(nsMsgDBCommitType::kLargeCommit);
      SummaryChanged();
      srcFolder->SummaryChanged();
    }
    if (txnMgr)
      txnMgr->EndBatch();
  }

  nsCOMPtr<nsISupports> srcSupport = do_QueryInterface(srcFolder);
  OnCopyCompleted(srcSupport, rv);

  if (NS_SUCCEEDED(rv) && isMove)
    srcFolder->NotifyFolderEvent(mDeleteOrMoveMsgCompletedAtom);

  return rv;
}

Here is the call graph for this function:

Here is the caller graph for this function:

nsresult nsImapMailFolder::CopyMessagesWithStream ( nsIMsgFolder srcFolder,
nsISupportsArray messages,
PRBool  isMove,
PRBool  isCrossServerOp,
nsIMsgWindow msgWindow,
nsIMsgCopyServiceListener listener,
PRBool  allowUndo 
) [protected]

Definition at line 6345 of file nsImapMailFolder.cpp.

{
    nsresult rv = NS_ERROR_NULL_POINTER;
    if (!srcFolder || !messages) return rv;

    nsCOMPtr<nsISupports> aSupport(do_QueryInterface(srcFolder, &rv));
    if (NS_FAILED(rv)) return rv;
    rv = InitCopyState(aSupport, messages, isMove, PR_FALSE, isCrossServerOp, 
      /* new message flags, not used */0, listener, msgWindow, allowUndo);
    if(NS_FAILED(rv)) 
      return rv;

    m_copyState->m_streamCopy = PR_TRUE;

    // ** jt - needs to create server to server move/copy undo msg txn
    if (m_copyState->m_allowUndo)
    {
       nsCAutoString messageIds;
       nsMsgKeyArray srcKeyArray;
       nsCOMPtr<nsIUrlListener> urlListener;

       rv = QueryInterface(NS_GET_IID(nsIUrlListener), getter_AddRefs(urlListener));
       rv = BuildIdsAndKeyArray(messages, messageIds, srcKeyArray);

       nsImapMoveCopyMsgTxn* undoMsgTxn = new nsImapMoveCopyMsgTxn;

       if (!undoMsgTxn || NS_FAILED(undoMsgTxn->Init(srcFolder, &srcKeyArray, messageIds.get(), this,
                                    PR_TRUE, isMove, m_eventQueue, urlListener)))
       {
         delete undoMsgTxn;
         return NS_ERROR_OUT_OF_MEMORY;
       }
       if (isMove)
       {
          if (mFlags & MSG_FOLDER_FLAG_TRASH)
            undoMsgTxn->SetTransactionType(nsIMessenger::eDeleteMsg);
          else
            undoMsgTxn->SetTransactionType(nsIMessenger::eMoveMsg);
       }
       else
       {
          undoMsgTxn->SetTransactionType(nsIMessenger::eCopyMsg);
       }
    
       rv = undoMsgTxn->QueryInterface(
         NS_GET_IID(nsImapMoveCopyMsgTxn), 
         getter_AddRefs(m_copyState->m_undoMsgTxn) );
    }
    nsCOMPtr<nsIMsgDBHdr> aMessage;
    aMessage = do_QueryElementAt(messages, 0, &rv);
    if (NS_SUCCEEDED(rv))
        CopyStreamMessage(aMessage, this, msgWindow, isMove);

    return rv; //we are clearing copy state in CopyMessages on failure
}

Here is the call graph for this function:

Here is the caller graph for this function:

void nsIImapMailFolderSink::copyNextStreamMessage ( in boolean  copySucceeded,
in nsISupports  copyState 
) [inherited]
nsresult nsImapMailFolder::CopyOfflineMsgBody ( nsIMsgFolder srcFolder,
nsIMsgDBHdr destHdr,
nsIMsgDBHdr origHdr 
) [protected]

Definition at line 6495 of file nsImapMailFolder.cpp.

{
  nsCOMPtr<nsIOutputStream> outputStream;
  nsresult rv = GetOfflineStoreOutputStream(getter_AddRefs(outputStream));
  nsCOMPtr <nsISeekableStream> seekable;

  seekable = do_QueryInterface(outputStream);

  if (seekable)
  {

    nsMsgKey messageOffset;
    PRUint32 messageSize;
    origHdr->GetMessageOffset(&messageOffset);
    origHdr->GetOfflineMessageSize(&messageSize);
    if (!messageSize)
    {
      nsCOMPtr<nsIMsgLocalMailFolder> localFolder = do_QueryInterface(srcFolder); 
      if (localFolder)   //can just use regular message size
        origHdr->GetMessageSize(&messageSize);
    }
    PRInt64 tellPos;
    seekable->Tell(&tellPos);
    nsInt64 curStorePos = tellPos;
    destHdr->SetMessageOffset((PRUint32) curStorePos);
    nsCOMPtr <nsIInputStream> offlineStoreInputStream;
    rv = srcFolder->GetOfflineStoreInputStream(getter_AddRefs(offlineStoreInputStream));
    if (NS_SUCCEEDED(rv) && offlineStoreInputStream)
    {
      nsCOMPtr<nsISeekableStream> seekStream = do_QueryInterface(offlineStoreInputStream);
      NS_ASSERTION(seekStream, "non seekable stream - can't read from offline msg");
      if (seekStream)
      {
        rv = seekStream->Seek(nsISeekableStream::NS_SEEK_SET, messageOffset);
        if (NS_SUCCEEDED(rv))
        {
          // now, copy the dest folder offline store msg to the temp file
          PRInt32 inputBufferSize = 10240;
          char *inputBuffer = (char *) PR_Malloc(inputBufferSize);
          PRInt32 bytesLeft;
          PRUint32 bytesRead, bytesWritten;
          bytesLeft = messageSize;
          rv = (inputBuffer) ? NS_OK : NS_ERROR_OUT_OF_MEMORY;
          while (bytesLeft > 0 && NS_SUCCEEDED(rv))
          {
            rv = offlineStoreInputStream->Read(inputBuffer, inputBufferSize, &bytesRead);
            if (NS_SUCCEEDED(rv) && bytesRead > 0)
            {
              rv = outputStream->Write(inputBuffer, PR_MIN((PRInt32) bytesRead, bytesLeft), &bytesWritten);
              NS_ASSERTION((PRInt32) bytesWritten == PR_MIN((PRInt32) bytesRead, bytesLeft), "wrote out incorrect number of bytes");
            }
            else
              break;
            bytesLeft -= bytesRead;
          }
          PR_FREEIF(inputBuffer);
          outputStream->Flush();
        }
      }
    }
    if (NS_SUCCEEDED(rv))
    {
      PRUint32 resultFlags;
      destHdr->OrFlags(MSG_FLAG_OFFLINE, &resultFlags);
      destHdr->SetOfflineMessageSize(messageSize);

    }
  }
  return rv;
}

Here is the call graph for this function:

Here is the caller graph for this function:

nsresult nsImapMailFolder::CopyStreamMessage ( nsIMsgDBHdr message,
nsIMsgFolder dstFolder,
nsIMsgWindow msgWindow,
PRBool  isMove 
) [protected]

Definition at line 7447 of file nsImapMailFolder.cpp.

{
    nsresult rv = NS_ERROR_NULL_POINTER;
    if (!m_copyState) return rv;

    nsCOMPtr<nsICopyMessageStreamListener> copyStreamListener = do_CreateInstance(NS_COPYMESSAGESTREAMLISTENER_CONTRACTID, &rv);
    NS_ENSURE_SUCCESS(rv,rv);

    nsCOMPtr<nsICopyMessageListener>
        copyListener(do_QueryInterface(dstFolder, &rv));
    if (NS_FAILED(rv)) return rv;

    nsCOMPtr<nsIMsgFolder>
        srcFolder(do_QueryInterface(m_copyState->m_srcSupport, &rv));
    if (NS_FAILED(rv)) return rv;
    rv = copyStreamListener->Init(srcFolder, copyListener, nsnull);
    if (NS_FAILED(rv)) return rv;
       
    nsCOMPtr<nsIMsgDBHdr> msgHdr(do_QueryInterface(message));
    if (!msgHdr) return NS_ERROR_FAILURE;

    nsXPIDLCString uri;
    srcFolder->GetUriForMsg(msgHdr, getter_Copies(uri));

    if (!m_copyState->m_msgService)
        rv = GetMessageServiceFromURI(uri, getter_AddRefs(m_copyState->m_msgService));

    if (NS_SUCCEEDED(rv) && m_copyState->m_msgService)
    {
      nsCOMPtr<nsIStreamListener>
              streamListener(do_QueryInterface(copyStreamListener, &rv));
      if(NS_FAILED(rv) || !streamListener)
        return NS_ERROR_NO_INTERFACE;

      // put up status message here, if copying more than one message.
      if (m_copyState->m_totalCount > 1)
      {
        nsXPIDLString dstFolderName, progressText;
        GetName(getter_Copies(dstFolderName));
        nsAutoString curMsgString;
        nsAutoString totalMsgString;
        totalMsgString.AppendInt(m_copyState->m_totalCount);
        curMsgString.AppendInt(m_copyState->m_curIndex + 1);
    
        const PRUnichar *formatStrings[3] = {curMsgString.get(),
                                              totalMsgString.get(),
                                              dstFolderName.get()
                                              };

        nsCOMPtr <nsIStringBundle> bundle;
        rv = IMAPGetStringBundle(getter_AddRefs(bundle));
        NS_ENSURE_SUCCESS(rv, rv);
        rv = bundle->FormatStringFromID(IMAP_COPYING_MESSAGE_OF,
                                          formatStrings, 3,
                                          getter_Copies(progressText));
        nsCOMPtr <nsIMsgStatusFeedback> statusFeedback;
        if (m_copyState->m_msgWindow)
          m_copyState->m_msgWindow->GetStatusFeedback(getter_AddRefs(statusFeedback));
        if (statusFeedback)
        {
          statusFeedback->ShowStatusString(progressText);
          PRInt32 percent;
          percent = (100 * m_copyState->m_curIndex) / (PRInt32) m_copyState->m_totalCount;
          {
            statusFeedback->ShowProgress(percent);
          }
        }
      }
      rv = m_copyState->m_msgService->CopyMessage(uri, streamListener,
                                                     isMove && !m_copyState->m_isCrossServerOp, nsnull, aMsgWindow, nsnull);
  }
  return rv;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 7717 of file nsImapMailFolder.cpp.

{
  NS_ENSURE_ARG_POINTER(rightsString);
  GetFolderACL();    // lazy create
  if (m_folderACL)
  {
    return m_folderACL->CreateACLRightsString(rightsString);
  }
  return NS_ERROR_NULL_POINTER;
}

Here is the call graph for this function:

nsresult nsImapMailFolder::CreateBaseMessageURI ( const char *  aURI) [protected, virtual]

Definition at line 7668 of file nsImapMailFolder.cpp.

{
  return nsCreateImapBaseMessageURI(aURI, &mBaseMessageURI);
}

Here is the call graph for this function:

void nsIMsgImapMailFolder::createClientSubfolderInfo ( in string  folderName,
in wchar  hierarchyDelimiter,
in long  flags,
in boolean  suppressNotification 
) [inherited]

Definition at line 1056 of file nsImapMailFolder.cpp.

{
   nsresult status = NS_OK;
  nsCOMPtr <nsIMsgFolder> msgParent;
  GetParentMsgFolder(getter_AddRefs(msgParent));

  // parent is probably not set because *this* was probably created by rdf
  // and not by folder discovery. So, we have to compute the parent.
  if (!msgParent)
  {
    nsCAutoString folderName(mURI);
      
    PRInt32 leafPos = folderName.RFindChar('/');
    nsCAutoString parentName(folderName);

    if (leafPos > 0)
    {
      // If there is a hierarchy, there is a parent.
      // Don't strip off slash if it's the first character
      parentName.Truncate(leafPos);
      // get the corresponding RDF resource
      // RDF will create the folder resource if it doesn't already exist
      nsCOMPtr<nsIRDFService> rdf(do_GetService(kRDFServiceCID, &status));
      if (NS_FAILED(status)) return status;
      nsCOMPtr<nsIRDFResource> resource;
      status = rdf->GetResource(parentName, getter_AddRefs(resource));
      if (NS_FAILED(status)) return status;

      msgParent = do_QueryInterface(resource, &status);
    }
  }
  if (msgParent)
  {
    nsXPIDLString folderName;
    GetName(getter_Copies(folderName));
    nsresult rv;
    nsCOMPtr<nsIImapService> imapService = do_GetService(NS_IMAPSERVICE_CONTRACTID, &rv); 
    if (NS_SUCCEEDED(rv) && imapService)
    {
      nsCOMPtr <nsIURI> uri;
      imapService->EnsureFolderExists(m_eventQueue, msgParent, folderName.get(), urlListener, getter_AddRefs(uri));
    }
  }

  return status;
}

Here is the call graph for this function:

Definition at line 863 of file nsImapMailFolder.cpp.

{
    nsresult rv = NS_ERROR_NULL_POINTER;
    if (!folderName) 
      return rv;

    nsAutoString trashName;
    GetTrashFolderName(trashName);
    if ( nsDependentString(folderName).Equals(trashName) )   // Trash , a special folder
    {
        ThrowAlertMsg("folderExists", msgWindow);
        return NS_MSG_FOLDER_EXISTS;
    }
    else if (mIsServer && nsDependentString(folderName).LowerCaseEqualsLiteral("inbox") )  // Inbox, a special folder
    {
        ThrowAlertMsg("folderExists", msgWindow);
        return NS_MSG_FOLDER_EXISTS;
    }

    nsCOMPtr<nsIImapService> imapService = do_GetService(NS_IMAPSERVICE_CONTRACTID, &rv);
    NS_ENSURE_SUCCESS(rv,rv);

    rv = imapService->CreateFolder(m_eventQueue, this, 
                                       folderName, this, nsnull);
    return rv;
}

Here is the call graph for this function:

Definition at line 484 of file nsImapMailFolder.cpp.

{
  nsresult rv = NS_OK;
  nsAutoString currentFolderNameStr;    // online name
  nsAutoString currentFolderDBNameStr;  // possibly munged name
  nsCOMPtr<nsIMsgFolder> child;
  nsCOMPtr<nsIMsgIncomingServer> server;
  nsCOMPtr<nsIImapIncomingServer> imapServer;

  if (NS_SUCCEEDED(GetServer(getter_AddRefs(server))) && server)
    imapServer = do_QueryInterface(server);

  PRBool isServer;
  rv = GetIsServer(&isServer);

  nsCAutoString folderName;
  for (nsDirectoryIterator dir(path, PR_FALSE); dir.Exists(); dir++) 
  {
    nsFileSpec currentFolderPath = dir.Spec();
    folderName.Adopt(currentFolderPath.GetLeafName());
    currentFolderNameStr.AssignWithConversion(folderName);
    if (isServer && imapServer)
    {
      PRBool isPFC;
      imapServer->GetIsPFC(folderName.get(), &isPFC);
      if (isPFC)
      {
        nsCOMPtr <nsIMsgFolder> pfcFolder;
        imapServer->GetPFC(PR_TRUE, getter_AddRefs(pfcFolder));
        continue;
      }
      // should check if this is the PFC
    }
    if (nsShouldIgnoreFile(currentFolderNameStr))
      continue;

    // OK, here we need to get the online name from the folder cache if we can.
    // If we can, use that to create the sub-folder

    nsCOMPtr <nsIMsgFolderCacheElement> cacheElement;
    nsCOMPtr <nsIFileSpec> curFolder;
    nsCOMPtr <nsIFileSpec> dbFile;

    NS_NewFileSpecWithSpec(currentFolderPath, getter_AddRefs(dbFile));
    // don't strip off the .msf in currentFolderPath.
    currentFolderPath.SetLeafName(folderName.get());
    rv = NS_NewFileSpecWithSpec(currentFolderPath, getter_AddRefs(curFolder));

    currentFolderDBNameStr = currentFolderNameStr;
    nsAutoString utf7LeafName = currentFolderNameStr;

    if (NS_SUCCEEDED(rv) && curFolder)
    {
      rv = GetFolderCacheElemFromFileSpec(dbFile, getter_AddRefs(cacheElement));

      if (NS_SUCCEEDED(rv) && cacheElement)
      {
        nsXPIDLString unicodeName;
        nsXPIDLCString onlineFullUtf7Name;

        PRUint32 folderFlags;
        rv = cacheElement->GetInt32Property("flags", (PRInt32 *) &folderFlags);
        if (NS_SUCCEEDED(rv) && folderFlags & MSG_FOLDER_FLAG_VIRTUAL) //ignore virtual folders
          continue;
        PRInt32 hierarchyDelimiter;
        rv = cacheElement->GetInt32Property("hierDelim", &hierarchyDelimiter);
        if (NS_SUCCEEDED(rv) && hierarchyDelimiter == kOnlineHierarchySeparatorUnknown)
        {
          currentFolderPath.Delete(PR_FALSE);
          continue; // blow away .msf files for folders with unknown delimiter.
        }
        rv = cacheElement->GetStringProperty("onlineName", getter_Copies(onlineFullUtf7Name));
        if (NS_SUCCEEDED(rv) && onlineFullUtf7Name.get() && strlen(onlineFullUtf7Name.get()))
        {
          // Call ConvertFolderName() and HideFolderName() to do special folder name
          // mapping and hiding, if configured to do so. For example, need to hide AOL's
          // 'RECYCLE_OUT' & convert a few AOL folder names. Regular imap accounts
          // will do no-op in the calls
          if (imapServer)
          {
            PRBool hideFolder;
            rv = imapServer->HideFolderName(onlineFullUtf7Name.get(), &hideFolder);
            if (hideFolder)
              continue;     // skip this folder
            else
            {
              rv = imapServer->ConvertFolderName(onlineFullUtf7Name.get(), getter_Copies(unicodeName));
              if (NS_FAILED(rv)) {
                rv = CopyMUTF7toUTF16(onlineFullUtf7Name, unicodeName);
                if (NS_FAILED(rv))  // XXX Does this make sense? 
                  CopyASCIItoUTF16(onlineFullUtf7Name, unicodeName);
              }
            }
          }

          currentFolderNameStr.Assign(unicodeName);

          PRUnichar delimiter = 0;
          GetHierarchyDelimiter(&delimiter);
          PRInt32 leafPos = currentFolderNameStr.RFindChar(delimiter);
          if (leafPos > 0)
            currentFolderNameStr.Cut(0, leafPos + 1);

          // take the utf7 full online name, and determine the utf7 leaf name
          CopyASCIItoUTF16(onlineFullUtf7Name, utf7LeafName);
          leafPos = utf7LeafName.RFindChar(delimiter);
          if (leafPos > 0)
            utf7LeafName.Cut(0, leafPos + 1);
        }
      }
    }
      // make the imap folder remember the file spec it was created with.
    nsCAutoString leafName; leafName.AssignWithConversion(currentFolderDBNameStr);
    nsCOMPtr <nsIFileSpec> msfFileSpec;
    rv = NS_NewFileSpecWithSpec(currentFolderPath, getter_AddRefs(msfFileSpec));
    if (NS_SUCCEEDED(rv) && msfFileSpec)
    {
      // leaf name is the db name w/o .msf (nsShouldIgnoreFile strips it off)
      // so this trims the .msf off the file spec.
      msfFileSpec->SetLeafName(leafName.get());
    }
    // use the utf7 name as the uri for the folder.
    AddSubfolderWithPath(utf7LeafName, msfFileSpec, getter_AddRefs(child));
    if (child)
    {
      // use the unicode name as the "pretty" name. Set it so it won't be
      // automatically computed from the URI, which is in utf7 form.
      if (!currentFolderNameStr.IsEmpty())
        child->SetPrettyName(currentFolderNameStr.get());
      child->SetMsgDatabase(nsnull);
    }
  }
  return rv;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 1505 of file nsImapMailFolder.cpp.

{
    nsresult rv = NS_ERROR_FAILURE;
    if (mDatabase)
    {
        mDatabase->ForceClosed();
        mDatabase = nsnull;
    }

    nsCOMPtr<nsIFileSpec> pathSpec;
    rv = GetPath(getter_AddRefs(pathSpec));
    if (NS_SUCCEEDED(rv))
    {
        nsFileSpec fileSpec;
        rv = pathSpec->GetFileSpec(&fileSpec);
        if (NS_SUCCEEDED(rv))
        {
            nsLocalFolderSummarySpec summarySpec(fileSpec);
            if (summarySpec.Exists())
                summarySpec.Delete(PR_FALSE);
        }
    }
    if (mPath)
    {
      nsFileSpec fileSpec;
      if (NS_SUCCEEDED(mPath->GetFileSpec(&fileSpec)) && fileSpec.Exists())
        fileSpec.Delete(PR_FALSE);
    }
    // should notify nsIMsgFolderListeners about the folder getting deleted...
    return rv;
}

Here is the call graph for this function:

Definition at line 4647 of file nsImapMailFolder.cpp.

{
  nsresult err;
  nsCOMPtr<nsIImapHostSessionList> hostSession = 
             do_GetService(kCImapHostSessionList, &err);
  PRBool rv = PR_TRUE;

    if (NS_SUCCEEDED(err) && hostSession)
  {
    nsXPIDLCString serverKey;
    GetServerKey(getter_Copies(serverKey));
    err = hostSession->GetDeleteIsMoveToTrashForHost(serverKey.get(), rv);
  }
  return rv;
}

Here is the call graph for this function:

Here is the caller graph for this function:

NS_IMETHODIMP nsImapMailFolder::DeleteMessages ( nsISupportsArray messages,
nsIMsgWindow msgWindow,
PRBool  deleteStorage,
PRBool  isMove,
nsIMsgCopyServiceListener listener,
PRBool  allowUndo 
)

Definition at line 2174 of file nsImapMailFolder.cpp.

{
  // *** jt - assuming delete is move to the trash folder for now
  nsCOMPtr<nsIEnumerator> aEnumerator;
  nsCOMPtr<nsIRDFResource> res;
  nsCAutoString uri;
  PRBool deleteImmediatelyNoTrash = PR_FALSE;
  nsCAutoString messageIds;
  nsMsgKeyArray srcKeyArray;
  PRBool deleteMsgs = PR_TRUE;  //used for toggling delete status - default is true
  nsMsgImapDeleteModel deleteModel = nsMsgImapDeleteModels::MoveToTrash;
  imapMessageFlagsType messageFlags = kImapMsgDeletedFlag;

  nsCOMPtr<nsIImapIncomingServer> imapServer;
  nsresult rv = GetFlag(MSG_FOLDER_FLAG_TRASH, &deleteImmediatelyNoTrash);
  rv = GetImapIncomingServer(getter_AddRefs(imapServer));
  
  if (NS_SUCCEEDED(rv) && imapServer)
  {
    imapServer->GetDeleteModel(&deleteModel);
    if (deleteModel != nsMsgImapDeleteModels::MoveToTrash || deleteStorage)
      deleteImmediatelyNoTrash = PR_TRUE;
    // if we're deleting a message, we should pseudo-interrupt the msg
    //load of the current message.
    PRBool interrupted = PR_FALSE;
    imapServer->PseudoInterruptMsgLoad(this, msgWindow, &interrupted);
  }
  
  rv = BuildIdsAndKeyArray(messages, messageIds, srcKeyArray);
  if (NS_FAILED(rv)) return rv;
  
  
  nsCOMPtr<nsIMsgFolder> rootFolder;
  nsCOMPtr<nsIMsgFolder> trashFolder;
  
  if (!deleteImmediatelyNoTrash)
  {
    rv = GetRootFolder(getter_AddRefs(rootFolder));
    if (NS_SUCCEEDED(rv) && rootFolder)
    {
      PRUint32 numFolders = 0;
      rv = rootFolder->GetFoldersWithFlag(MSG_FOLDER_FLAG_TRASH,
        1, &numFolders,
        getter_AddRefs(trashFolder));

      NS_ASSERTION(NS_SUCCEEDED(rv) && trashFolder != 0, "couldn't find trash");
      
      // if we can't find the trash, we'll just have to do an imap delete and pretend this is the trash
      if (NS_FAILED(rv) || !trashFolder)
        deleteImmediatelyNoTrash = PR_TRUE;
    }
  }
  
  if ((NS_SUCCEEDED(rv) && deleteImmediatelyNoTrash) || deleteModel == nsMsgImapDeleteModels::IMAPDelete )
  {
    if (allowUndo)
    {
      //need to take care of these two delete models
      nsImapMoveCopyMsgTxn* undoMsgTxn = new nsImapMoveCopyMsgTxn;
      if (!undoMsgTxn || NS_FAILED(undoMsgTxn->Init(this, &srcKeyArray, messageIds.get(), nsnull,
                                                      PR_TRUE, isMove, m_eventQueue, nsnull)))
      {
        delete undoMsgTxn;
        return NS_ERROR_OUT_OF_MEMORY;
      }
      undoMsgTxn->SetTransactionType(nsIMessenger::eDeleteMsg);
      // we're adding this undo action before the delete is successful. This is evil,
      // but 4.5 did it as well.
      nsCOMPtr <nsITransactionManager> txnMgr;
      if (msgWindow)
        msgWindow->GetTransactionManager(getter_AddRefs(txnMgr));
      if (txnMgr)
        txnMgr->DoTransaction(undoMsgTxn);
    }
    
    if (deleteModel == nsMsgImapDeleteModels::IMAPDelete && !deleteStorage)
    {
      PRUint32 cnt, flags;
      rv = messages->Count(&cnt);
      NS_ENSURE_SUCCESS(rv, rv);
      deleteMsgs = PR_FALSE;
      for (PRUint32 i=0; i <cnt; i++)
      {
        nsCOMPtr <nsIMsgDBHdr> msgHdr = do_QueryElementAt(messages, i);
        if (msgHdr)
        {
          msgHdr->GetFlags(&flags);
          if (!(flags & MSG_FLAG_IMAP_DELETED))
          {
            deleteMsgs = PR_TRUE;
            break;
          }
        }
      }
    }
    // if copy service listener is also a url listener, pass that
    // url listener into StoreImapFlags.
    nsCOMPtr <nsIUrlListener> urlListener = do_QueryInterface(listener);
    if (deleteMsgs)
      messageFlags |= kImapMsgSeenFlag;
    rv = StoreImapFlags(messageFlags, deleteMsgs, srcKeyArray.GetArray(), 
                        srcKeyArray.GetSize(), urlListener);
    
    if (NS_SUCCEEDED(rv))
    {
      if (mDatabase)
      {
        if (deleteModel == nsMsgImapDeleteModels::IMAPDelete)
        {

          MarkMessagesImapDeleted(&srcKeyArray, deleteMsgs, mDatabase);
        }
        else
        {
          EnableNotifications(allMessageCountNotifications, PR_FALSE, PR_TRUE /*dbBatching*/);  //"remove it immediately" model
          mDatabase->DeleteMessages(&srcKeyArray,nsnull);
          EnableNotifications(allMessageCountNotifications, PR_TRUE, PR_TRUE /*dbBatching*/);
          NotifyFolderEvent(mDeleteOrMoveMsgCompletedAtom);            
        }    
      }   
    }
    return rv;
  }
  else  // have to move the messages to the trash
  {
    if(trashFolder)
    {
      nsCOMPtr<nsIMsgFolder> srcFolder;
      nsCOMPtr<nsISupports>srcSupport;
      PRUint32 count = 0;
      rv = messages->Count(&count);
      
      rv = QueryInterface(NS_GET_IID(nsIMsgFolder),
        getter_AddRefs(srcFolder));
      
      nsCOMPtr<nsIMsgCopyService> copyService = do_GetService(NS_MSGCOPYSERVICE_CONTRACTID, &rv);
      NS_ENSURE_SUCCESS(rv, rv);
      rv = copyService->CopyMessages(srcFolder, messages, trashFolder, PR_TRUE, listener, msgWindow, allowUndo);
    }
  }
  return rv;
}

Here is the call graph for this function:

Definition at line 2350 of file nsImapMailFolder.cpp.

{
    nsCOMPtr<nsIMsgFolder> curFolder;
    nsCOMPtr<nsIUrlListener> urlListener;
    nsCOMPtr<nsIMsgFolder> trashFolder;
    PRInt32 i;
    PRUint32 folderCount = 0;
    nsresult rv;
    // "this" is the folder we're deleting from
    PRBool deleteNoTrash = TrashOrDescendentOfTrash(this) || !DeleteIsMoveToTrash();
    PRBool confirmed = PR_FALSE;
    PRBool confirmDeletion = PR_TRUE;


    (void) folders->Count(&folderCount);

    for (i = folderCount - 1; i >= 0; i--)
    {
      curFolder = do_QueryElementAt(folders, i, &rv);
      if (NS_SUCCEEDED(rv))
      {
        PRUint32 folderFlags;
        curFolder->GetFlags(&folderFlags);
        if (folderFlags & MSG_FOLDER_FLAG_VIRTUAL)
        {
          RemoveSubFolder(curFolder);
          folders->RemoveElementAt(i);
          // since the folder pane only allows single selection, we can do this
          deleteNoTrash = confirmed = PR_TRUE;
          confirmDeletion = PR_FALSE;
        }
      }
    }

    nsCOMPtr<nsIImapService> imapService = do_GetService(NS_IMAPSERVICE_CONTRACTID, &rv);
    if (NS_SUCCEEDED(rv))
    {
      if (!deleteNoTrash)
      {
        rv = GetTrashFolder(getter_AddRefs(trashFolder));

        //If we can't find the trash folder and we are supposed to move it to the trash
        //return failure.
        if(NS_FAILED(rv) || !trashFolder)
          return NS_ERROR_FAILURE;

         PRBool canHaveSubFoldersOfTrash = PR_TRUE;
         trashFolder->GetCanCreateSubfolders(&canHaveSubFoldersOfTrash);
         if (canHaveSubFoldersOfTrash) // UW server doesn't set NOINFERIORS - check dual use pref
         {
           nsCOMPtr<nsIImapIncomingServer> imapServer;
           rv = GetImapIncomingServer(getter_AddRefs(imapServer));

           if (NS_SUCCEEDED(rv) && imapServer) 
           {
             PRBool serverSupportsDualUseFolders;
             imapServer->GetDualUseFolders(&serverSupportsDualUseFolders);
             if (!serverSupportsDualUseFolders)
               canHaveSubFoldersOfTrash = PR_FALSE;
           }
         }
         if (!canHaveSubFoldersOfTrash)
           deleteNoTrash = PR_TRUE;

         nsCOMPtr<nsIPrefBranch> prefBranch(do_GetService(NS_PREFSERVICE_CONTRACTID, &rv));
         if (NS_SUCCEEDED(rv))
           prefBranch->GetBoolPref("mailnews.confirm.moveFoldersToTrash", &confirmDeletion);
      }
      if (!confirmed && (confirmDeletion || deleteNoTrash)) //let us alert the user if we are deleting folder immediately
      {
        nsXPIDLString confirmationStr;
        IMAPGetStringByID(((!deleteNoTrash) ? IMAP_MOVE_FOLDER_TO_TRASH : IMAP_DELETE_NO_TRASH),
        getter_Copies(confirmationStr));

        if (!msgWindow) 
          return NS_ERROR_NULL_POINTER;
        nsCOMPtr<nsIDocShell> docShell;
        msgWindow->GetRootDocShell(getter_AddRefs(docShell));

        nsCOMPtr<nsIPrompt> dialog;
        if (docShell) 
          dialog = do_GetInterface(docShell);

        if (dialog && confirmationStr)
          dialog->Confirm(nsnull, confirmationStr, &confirmed);
      }
      else
        confirmed = PR_TRUE;

      if (confirmed)
      {
        for (i = 0; i < folderCount; i++)
        {
          curFolder = do_QueryElementAt(folders, i, &rv);
          if (NS_SUCCEEDED(rv))
          {
            urlListener = do_QueryInterface(curFolder);
            if (deleteNoTrash)
              rv = imapService->DeleteFolder(m_eventQueue,
                                             curFolder,
                                             urlListener,
                                             nsnull);
            else
            {
              PRBool confirm = PR_FALSE;
              PRBool match = PR_FALSE;
              rv = curFolder->MatchOrChangeFilterDestination(nsnull, PR_FALSE, &match);
              if (match)
              {
                curFolder->ConfirmFolderDeletionForFilter(msgWindow, &confirm);
                if (!confirm) 
                  return NS_OK;
              }
              rv = imapService->MoveFolder(m_eventQueue,
                                           curFolder,
                                           trashFolder,
                                           urlListener,
                                           msgWindow,
                                           nsnull);
            }
          }
        }
      }
    }
    
    if (confirmed && deleteNoTrash)   //delete subfolders only if you are  deleting things from trash
        return nsMsgDBFolder::DeleteSubFolders(folders, msgWindow);
    return rv;
}

Here is the call graph for this function:

nsresult nsImapMailFolder::DisplayStatusMsg ( nsIImapUrl aImapUrl,
const PRUnichar msg 
) [protected]

Definition at line 6171 of file nsImapMailFolder.cpp.

{
  nsCOMPtr<nsIImapMockChannel> mockChannel;
  aImapUrl->GetMockChannel(getter_AddRefs(mockChannel));
  if (mockChannel)
  {
    nsCOMPtr<nsIProgressEventSink> progressSink;
    mockChannel->GetProgressEventSink(getter_AddRefs(progressSink));
    if (progressSink)
    {
        nsCOMPtr<nsIRequest> request = do_QueryInterface(mockChannel);
        if (!request) return NS_ERROR_FAILURE;
      progressSink->OnStatus(request, nsnull, NS_OK, msg);      // XXX i18n message
    }
  }
  return NS_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 4208 of file nsImapMailFolder.cpp.

{
  nsresult rv = NS_OK;
  nsCOMPtr <nsIURI> runningURI;
  PRBool noSelect;
  GetFlag(MSG_FOLDER_FLAG_IMAP_NOSELECT, &noSelect);

  if (!noSelect)
  {
    nsCAutoString messageIdsToDownload;
    nsMsgKeyArray msgsToDownload;

    GetDatabase(msgWindow);
    m_downloadingFolderForOfflineUse = PR_TRUE;

    rv = AcquireSemaphore(NS_STATIC_CAST(nsIMsgImapMailFolder*, this));
    if (NS_FAILED(rv))
    {
      ThrowAlertMsg("operationFailedFolderBusy", msgWindow);
      return rv;
    }
    SetNotifyDownloadedLines(PR_TRUE); 
    nsCOMPtr<nsIImapService> imapService = do_GetService(NS_IMAPSERVICE_CONTRACTID, &rv);
    NS_ENSURE_SUCCESS(rv,rv);

    // selecting the folder with m_downloadingFolderForOfflineUse true will cause
    // us to fetch any message bodies we don't have.
    rv = imapService->SelectFolder(m_eventQueue, this, listener, msgWindow, nsnull);
    if (NS_SUCCEEDED(rv))
      m_urlRunning = PR_TRUE;
  }
  else
    return NS_MSG_FOLDER_UNREADABLE;
  return rv;
}

Here is the call graph for this function:

Definition at line 4187 of file nsImapMailFolder.cpp.

{
  nsCAutoString messageIds;
  nsMsgKeyArray srcKeyArray;
  nsresult rv = BuildIdsAndKeyArray(messages, messageIds, srcKeyArray);
  if (NS_FAILED(rv) || messageIds.IsEmpty()) return rv;

  nsCOMPtr<nsIImapService> imapService = do_GetService(NS_IMAPSERVICE_CONTRACTID, &rv);
  NS_ENSURE_SUCCESS(rv,rv);

  SetNotifyDownloadedLines(PR_TRUE); 
  rv = AcquireSemaphore(NS_STATIC_CAST(nsIMsgImapMailFolder*, this));
  if (NS_FAILED(rv))
  {
    ThrowAlertMsg("operationFailedFolderBusy", window);
    return rv;
  }

  return imapService->DownloadMessagesForOffline(messageIds.get(), this, this, window);
}

Here is the call graph for this function:

Definition at line 1331 of file nsImapMailFolder.cpp.

{
    nsCOMPtr<nsIMsgFolder> trashFolder;
    nsresult rv = GetTrashFolder(getter_AddRefs(trashFolder));
    if (NS_SUCCEEDED(rv))
    {
       nsCOMPtr<nsIMsgAccountManager> accountManager = 
                do_GetService(NS_MSGACCOUNTMANAGER_CONTRACTID, &rv);
       if (accountManager)
       {
         // if we are emptying trash on exit and we are an aol server then don't perform
         // this operation because it's causing a hang that we haven't been able to figure out yet
         // this is an rtm fix and we'll look for the right solution post rtm. 

         PRBool empytingOnExit = PR_FALSE;
         accountManager->GetEmptyTrashInProgress(&empytingOnExit);
         if (empytingOnExit)
         {
            nsCOMPtr<nsIImapIncomingServer> imapServer;
            rv = GetImapIncomingServer(getter_AddRefs(imapServer));

            if (NS_SUCCEEDED(rv) && imapServer) 
            {
              PRBool isAOLServer = PR_FALSE;
              imapServer->GetIsAOLServer(&isAOLServer);
              if (isAOLServer)
                return NS_ERROR_FAILURE;  // we will not be performing an empty trash....
            } // if we fetched an imap server
         } // if emptying trash on exit which is done through the account manager.
       }

        nsCOMPtr<nsIMsgDatabase> trashDB;

        if (WeAreOffline())
        {
          nsCOMPtr <nsIMsgDatabase> trashDB;
          rv = trashFolder->GetMsgDatabase(nsnull, getter_AddRefs(trashDB));
          if (NS_SUCCEEDED(rv) && trashDB)
          {
            nsMsgKey fakeKey;
            trashDB->GetNextFakeOfflineMsgKey(&fakeKey);
    
            nsCOMPtr <nsIMsgOfflineImapOperation> op;
            rv = trashDB->GetOfflineOpForKey(fakeKey, PR_TRUE, getter_AddRefs(op));
            trashFolder->SetFlag(MSG_FOLDER_FLAG_OFFLINEEVENTS);
            op->SetOperation(nsIMsgOfflineImapOperation::kDeleteAllMsgs);
          }
          return rv;
        }
        nsCOMPtr <nsIDBFolderInfo> transferInfo;
        rv = trashFolder->GetDBTransferInfo(getter_AddRefs(transferInfo));
        rv = trashFolder->Delete(); // delete summary spec
        trashFolder->SetDBTransferInfo(transferInfo);

        trashFolder->SetSizeOnDisk(0);
        nsCOMPtr<nsIImapService> imapService = 
                 do_GetService(NS_IMAPSERVICE_CONTRACTID, &rv);
        if (NS_SUCCEEDED(rv))
        {
        PRBool hasSubfolders = PR_FALSE;
        rv = trashFolder->GetHasSubFolders(&hasSubfolders);
        if (hasSubfolders)
        {
            nsCOMPtr<nsIEnumerator> aEnumerator;
            nsCOMPtr<nsISupports> aSupport;
            nsCOMPtr<nsIMsgFolder> aFolder;
            nsCOMPtr<nsISupportsArray> aSupportsArray;
            rv = NS_NewISupportsArray(getter_AddRefs(aSupportsArray));
            if (NS_FAILED(rv)) return rv;
            rv = trashFolder->GetSubFolders(getter_AddRefs(aEnumerator));
            PRBool confirmDeletion;
            nsCOMPtr<nsIPrefBranch> prefBranch(do_GetService(NS_PREFSERVICE_CONTRACTID, &rv));
            if (NS_SUCCEEDED(rv))
              prefBranch->GetBoolPref("mail.imap.confirm_emptyTrashFolderDeletion", &confirmDeletion);

            nsXPIDLString confirmationStr;
            nsCOMPtr<nsIStringBundle> bundle;
            nsCOMPtr<nsIDOMWindowInternal> parentWindow;
            nsCOMPtr<nsIPromptService> promptService;
            if (confirmDeletion)
            {
              IMAPGetStringByID(IMAP_EMPTY_TRASH_CONFIRM, getter_Copies(confirmationStr));
              promptService = do_GetService(NS_PROMPTSERVICE_CONTRACTID);
              nsCOMPtr<nsIDocShell> docShell;
              if (aMsgWindow)
              {
                     (void) aMsgWindow->GetRootDocShell(getter_AddRefs(docShell));
                   parentWindow = do_QueryInterface(docShell);
              }
              rv = IMAPGetStringBundle(getter_AddRefs(bundle));
              NS_ENSURE_SUCCESS(rv, rv);
            rv = aEnumerator->First();
            while(NS_SUCCEEDED(rv))
            {
                PRInt32 dlgResult  = -1;
                rv = aEnumerator->CurrentItem(getter_AddRefs(aSupport));
                if (confirmDeletion)
                {
                  nsXPIDLString statusString, confirmText;
                  nsCOMPtr <nsIMsgFolder> folder = do_QueryInterface(aSupport);
                  nsXPIDLString folderName;
                  folder->GetName(getter_Copies(folderName));
                  const PRUnichar *formatStrings[1] = { folderName.get() };

                  rv = bundle->FormatStringFromID(IMAP_EMPTY_TRASH_CONFIRM,
                                                    formatStrings, 1,
                                                    getter_Copies(confirmText));
                  // Got the text, now show dialog.
                  rv = promptService->ConfirmEx(parentWindow, nsnull, confirmText,
                                              (nsIPromptService::BUTTON_TITLE_OK * nsIPromptService::BUTTON_POS_0) +
                                              (nsIPromptService::BUTTON_TITLE_CANCEL * nsIPromptService::BUTTON_POS_1), 
                                                nsnull, nsnull, nsnull, nsnull, nsnull, &dlgResult);
                }
              if ( NS_SUCCEEDED( rv ) ) 
              {
                  if (dlgResult == 1)
                  return NS_BINDING_ABORTED;
                rv = aEnumerator->Next();
              }
            }
          }
        }
        if (aListener)
        {
            rv = imapService->DeleteAllMessages(m_eventQueue, trashFolder,
                                                aListener, nsnull);
        }
        else
        {
            nsCOMPtr<nsIUrlListener> urlListener = 
                do_QueryInterface(trashFolder);
            rv = imapService->DeleteAllMessages(m_eventQueue, trashFolder,
                                                urlListener, nsnull);
        }
        // return an error if this failed. We want the empty trash on exit code
        // to know if this fails so that it doesn't block waiting for empty trash to finish.
        if (NS_FAILED(rv))
          return rv;
        if (hasSubfolders)
        {
            nsCOMPtr<nsIEnumerator> aEnumerator;
            nsCOMPtr<nsISupports> aSupport;
            nsCOMPtr<nsIMsgFolder> aFolder;
            nsCOMPtr<nsISupportsArray> aSupportsArray;
            rv = NS_NewISupportsArray(getter_AddRefs(aSupportsArray));
            if (NS_FAILED(rv)) return rv;
            rv = trashFolder->GetSubFolders(getter_AddRefs(aEnumerator));

            rv = aEnumerator->First();
            while(NS_SUCCEEDED(rv))
            {
                rv = aEnumerator->CurrentItem(getter_AddRefs(aSupport));
                      aSupportsArray->AppendElement(aSupport);
                  rv = aEnumerator->Next();
              }
              PRUint32 cnt = 0;
              aSupportsArray->Count(&cnt);
              for (PRInt32 i = cnt-1; i >= 0; i--)
              {
                  aFolder = do_QueryElementAt(aSupportsArray, i);
                  aSupportsArray->RemoveElementAt(i);
                  if (aFolder)
                      trashFolder->PropagateDelete(aFolder, PR_TRUE, aMsgWindow);
              }
            }
        }

        return NS_OK;
    }

    return rv;
}

Here is the call graph for this function:

void nsICopyMessageListener::endCopy ( in boolean  copySucceeded) [inherited]
void nsIImapMailFolderSink::EndMessage ( in nsIMsgMailNewsUrl  aUrl,
in nsMsgKey  uidOfMessage 
) [inherited]
void nsICopyMessageListener::endMove ( in boolean  moveSucceeded) [inherited]

Definition at line 4306 of file nsImapMailFolder.cpp.

{
  if (m_tempMessageStream)
  {
    m_tempMessageStream->Close();
    m_tempMessageStream = nsnull;
    if (mDatabase)
      mDatabase->Commit(nsMsgDBCommitType::kLargeCommit);
  }
  m_offlineHeader = nsnull;
}

Here is the caller graph for this function:

Definition at line 277 of file nsImapMailFolder.cpp.

{
#if 0
    nsresult rv = NS_OK;
    nsIEnumerator* folders;
    nsIEnumerator* messages;
    rv = GetSubFolders(&folders);
    if (NS_FAILED(rv)) return rv;
    rv = GetMessages(nsnull, &messages);
    if (NS_FAILED(rv)) return rv;
    return NS_NewConjoiningEnumerator(folders, messages, 
                                      (nsIBidirectionalEnumerator**)result);
#endif
  NS_ASSERTION(PR_FALSE, "obsolete, right?");
  return NS_ERROR_FAILURE;
}
nsIURI nsIMsgImapMailFolder::fetchCustomMsgAttribute ( in string  msgAttribute,
in string  uids,
in nsIMsgWindow  aWindow 
) [inherited]
NS_IMETHODIMP nsImapMailFolder::FetchMsgPreviewText ( nsMsgKey aKeysToFetch,
PRUint32  aNumKeys,
PRBool  aLocalOnly,
nsIUrlListener aUrlListener,
PRBool aAsyncResults 
)

Definition at line 8508 of file nsImapMailFolder.cpp.

{
  NS_ENSURE_ARG_POINTER(aKeysToFetch);
  NS_ENSURE_ARG_POINTER(aAsyncResults);

  nsMsgKeyArray keysToFetchFromServer;

  *aAsyncResults = PR_FALSE;
  nsresult rv = NS_OK;

  for (PRUint32 i = 0; i < aNumKeys; i++)
  {
    nsCOMPtr <nsIMsgDBHdr> msgHdr;
    nsXPIDLCString prevBody;
    rv = GetMessageHeader(aKeysToFetch[i], getter_AddRefs(msgHdr));
    NS_ENSURE_SUCCESS(rv, rv);
    // ignore messages that already have a preview body.
    msgHdr->GetStringProperty("preview", getter_Copies(prevBody));
    if (!prevBody.IsEmpty())
      continue;

    /* check if message is in memory cache or offline store. */
    nsCOMPtr<nsIImapService> imapService = do_GetService(NS_IMAPSERVICE_CONTRACTID, &rv);
    NS_ENSURE_SUCCESS(rv, rv);
    nsCOMPtr <nsIMsgMessageService> msgService = do_QueryInterface(imapService);
    nsCOMPtr <nsIURI> url;
    nsCOMPtr<nsIInputStream> inputStream;

    nsXPIDLCString messageUri;
    rv = GetUriForMsg(msgHdr, getter_Copies(messageUri));
    NS_ENSURE_SUCCESS(rv,rv);
    rv = msgService->GetUrlForUri(messageUri, getter_AddRefs(url), nsnull);
    NS_ENSURE_SUCCESS(rv,rv);
    nsCAutoString urlSpec;
    url->GetAsciiSpec(urlSpec);

    nsCOMPtr<nsICacheSession> cacheSession;
    rv = imapService->GetCacheSession(getter_AddRefs(cacheSession));
    NS_ENSURE_SUCCESS(rv, rv);
    PRInt32 uidValidity;
    GetUidValidity(&uidValidity);
    // stick the uid validity in front of the url, so that if the uid validity
    // changes, we won't re-use the wrong cache entries.
    nsCAutoString cacheKey;
    cacheKey.AppendInt(uidValidity, 16);
    cacheKey.Append(urlSpec);
    nsCOMPtr <nsICacheEntryDescriptor> cacheEntry;

    // if mem cache entry is broken or empty, go to next message.
    rv = cacheSession->OpenCacheEntry(cacheKey, nsICache::ACCESS_READ, PR_FALSE, getter_AddRefs(cacheEntry));
    if (cacheEntry)
    {
      rv = cacheEntry->OpenInputStream(0, getter_AddRefs(inputStream));
      if (NS_SUCCEEDED(rv))
      {
        PRUint32 bytesAvailable = 0;
        rv = inputStream->Available(&bytesAvailable);
        if (!bytesAvailable)
          continue;
        rv = GetMsgPreviewTextFromStream(msgHdr, inputStream);
      }
    }
    else // lets look in the offline store
    {
      PRUint32 msgFlags;
      msgHdr->GetFlags(&msgFlags);
      nsMsgKey msgKey;
      msgHdr->GetMessageKey(&msgKey);
      if (msgFlags & MSG_FLAG_OFFLINE)
      {
        nsMsgKey messageOffset;
        PRUint32 messageSize;
        GetOfflineFileStream(msgKey, &messageOffset, &messageSize, getter_AddRefs(inputStream));
        if (inputStream)
          rv = GetMsgPreviewTextFromStream(msgHdr, inputStream);
      }
      else if (!aLocalOnly)
        keysToFetchFromServer.Add(msgKey);
    }
  }
  if (keysToFetchFromServer.GetSize() > 0)
  {
      nsCOMPtr<nsIImapService> imapService = do_GetService(NS_IMAPSERVICE_CONTRACTID, &rv);
      NS_ENSURE_SUCCESS(rv,rv);
      PRUint32 msgCount = keysToFetchFromServer.GetSize();
      nsCAutoString messageIds;

      AllocateImapUidString(keysToFetchFromServer.GetArray(), msgCount, 
                           nsnull, messageIds);
      rv = imapService->GetBodyStart(m_eventQueue, this, aUrlListener,
                                         messageIds.get(), 2048, nsnull);
      *aAsyncResults = PR_TRUE; // the preview text will be available async...
  }
  return NS_OK;
}

Here is the call graph for this function:

void nsImapMailFolder::FindKeysToAdd ( const nsMsgKeyArray &  existingKeys,
nsMsgKeyArray &  keysToFetch,
PRUint32 numNewUnread,
nsIImapFlagAndUidState flagState 
) [protected]

Definition at line 3999 of file nsImapMailFolder.cpp.

{
  PRBool showDeletedMessages = ShowDeletedMessages();
  int dbIndex=0; // current index into existingKeys
  PRInt32 existTotal, numberOfKnownKeys;
  PRInt32 messageIndex;
 
  numNewUnread = 0;
  existTotal = numberOfKnownKeys = existingKeys.GetSize();
  flagState->GetNumberOfMessages(&messageIndex);
  for (PRInt32 flagIndex=0; flagIndex < messageIndex; flagIndex++)
  {
    PRUint32 uidOfMessage;
    flagState->GetUidOfMessage(flagIndex, &uidOfMessage);
    while ( (flagIndex < numberOfKnownKeys) && (dbIndex < existTotal) &&
        existingKeys[dbIndex] < uidOfMessage) 
      dbIndex++;
    
    if ( (flagIndex >= numberOfKnownKeys)  || 
       (dbIndex >= existTotal) ||
       (existingKeys[dbIndex] != uidOfMessage ) )
    {
      numberOfKnownKeys++;

      imapMessageFlagsType flags;
      flagState->GetMessageFlags(flagIndex, &flags);
      NS_ASSERTION(uidOfMessage != nsMsgKey_None, "got invalid msg key");
      if (uidOfMessage && uidOfMessage != nsMsgKey_None && (showDeletedMessages || ! (flags & kImapMsgDeletedFlag)))
      {
        if (mDatabase)
        {
          PRBool dbContainsKey;
          if (NS_SUCCEEDED(mDatabase->ContainsKey(uidOfMessage, &dbContainsKey)) && dbContainsKey)
          {
            NS_ASSERTION(PR_FALSE, "db has key - flagState messed up?");
            continue;
          }
        }
        keysToFetch.Add(uidOfMessage);
        if (! (flags & kImapMsgSeenFlag))
          numNewUnread++;
      }
    }
  }
}

Here is the call graph for this function:

void nsImapMailFolder::FindKeysToDelete ( const nsMsgKeyArray &  existingKeys,
nsMsgKeyArray &  keysToFetch,
nsIImapFlagAndUidState flagState 
) [protected]

Definition at line 3960 of file nsImapMailFolder.cpp.

{
  PRBool showDeletedMessages = ShowDeletedMessages();
  PRUint32 total = existingKeys.GetSize();
  PRInt32 messageIndex;

  int onlineIndex=0; // current index into flagState
  for (PRUint32 keyIndex=0; keyIndex < total; keyIndex++)
  {
    PRUint32 uidOfMessage;

    flagState->GetNumberOfMessages(&messageIndex);
    while ((onlineIndex < messageIndex) && 
         (flagState->GetUidOfMessage(onlineIndex, &uidOfMessage), (existingKeys[keyIndex] > uidOfMessage) ))
    {
      onlineIndex++;
    }
    
    imapMessageFlagsType flags;
    flagState->GetUidOfMessage(onlineIndex, &uidOfMessage);
    flagState->GetMessageFlags(onlineIndex, &flags);
    // delete this key if it is not there or marked deleted
    if ( (onlineIndex >= messageIndex ) ||
       (existingKeys[keyIndex] != uidOfMessage) ||
       ((flags & kImapMsgDeletedFlag) && !showDeletedMessages) )
    {
      nsMsgKey doomedKey = existingKeys[keyIndex];
      if ((PRInt32) doomedKey <= 0 && doomedKey != nsMsgKey_None)
        continue;
      else
        keysToDelete.Add(existingKeys[keyIndex]);
    }
    
    flagState->GetUidOfMessage(onlineIndex, &uidOfMessage);
    if (existingKeys[keyIndex] == uidOfMessage) 
      onlineIndex++;
  }
}

Here is the call graph for this function:

nsresult nsImapMailFolder::GetBodysToDownload ( nsMsgKeyArray *  keysOfMessagesToDownload) [protected]

Definition at line 2545 of file nsImapMailFolder.cpp.

{
  NS_ENSURE_ARG(keysOfMessagesToDownload);

  nsresult rv = NS_ERROR_NULL_POINTER; // if mDatabase not set

  if (mDatabase)
  {
    nsCOMPtr <nsISimpleEnumerator> enumerator;
    rv = mDatabase->EnumerateMessages(getter_AddRefs(enumerator));
    if (NS_SUCCEEDED(rv) && enumerator)
    {
      PRBool hasMore;

      while (NS_SUCCEEDED(rv = enumerator->HasMoreElements(&hasMore)) && (hasMore == PR_TRUE)) 
      {
        nsCOMPtr <nsIMsgDBHdr> pHeader;
        rv = enumerator->GetNext(getter_AddRefs(pHeader));
        NS_ASSERTION(NS_SUCCEEDED(rv), "nsMsgDBEnumerator broken");
        if (pHeader && NS_SUCCEEDED(rv))
        {
          PRBool shouldStoreMsgOffline = PR_FALSE;
          nsMsgKey msgKey;
          pHeader->GetMessageKey(&msgKey);
          // MsgFitsDownloadCriteria ignores MSG_FOLDER_FLAG_OFFLINE, which we want
          if (m_downloadingFolderForOfflineUse)
            MsgFitsDownloadCriteria(msgKey, &shouldStoreMsgOffline);
          else
            ShouldStoreMsgOffline(msgKey, &shouldStoreMsgOffline);
          if (shouldStoreMsgOffline)
            keysOfMessagesToDownload->Add(msgKey);
        }
      }
    }
  }
  return rv;
}

Here is the call graph for this function:

Definition at line 1771 of file nsImapMailFolder.cpp.

{
  NS_ENSURE_ARG_POINTER(aResult);
  *aResult = !(mFlags & (MSG_FOLDER_FLAG_IMAP_NOINFERIORS | MSG_FOLDER_FLAG_VIRTUAL));

  PRBool isServer = PR_FALSE;
  GetIsServer(&isServer);
  if (!isServer)
  {
      nsCOMPtr<nsIImapIncomingServer> imapServer;
      nsresult rv = GetImapIncomingServer(getter_AddRefs(imapServer));
      PRBool dualUseFolders = PR_TRUE;
      if (NS_SUCCEEDED(rv) && imapServer)
          imapServer->GetDualUseFolders(&dualUseFolders);
      if (!dualUseFolders && *aResult)
          *aResult = (mFlags & MSG_FOLDER_FLAG_IMAP_NOSELECT);
  }
  
  return NS_OK;
}

Here is the call graph for this function:

Definition at line 8200 of file nsImapMailFolder.cpp.

{
  NS_ENSURE_ARG_POINTER(aCanDeleteMessages);
  *aCanDeleteMessages = GetFolderACL()->GetCanIDeleteInFolder();
  return NS_OK;
}

Here is the call graph for this function:

Definition at line 8176 of file nsImapMailFolder.cpp.

{
  nsresult rv;
  *aCanFileMessages = PR_TRUE;
  
  nsCOMPtr<nsIMsgIncomingServer> server;
  rv = GetServer(getter_AddRefs(server));
  if (NS_SUCCEEDED(rv) && server)
    rv = server->GetCanFileMessagesOnServer(aCanFileMessages);

  if (*aCanFileMessages)
    rv = nsMsgDBFolder::GetCanFileMessages(aCanFileMessages);

  if (*aCanFileMessages)
  {
    PRBool noSelect;
    GetFlag(MSG_FOLDER_FLAG_IMAP_NOSELECT, &noSelect);
    *aCanFileMessages = (noSelect) ? PR_FALSE : GetFolderACL()->GetCanIInsertInFolder();
    return NS_OK;
  }
  return rv;
}

Here is the call graph for this function:

Definition at line 1793 of file nsImapMailFolder.cpp.

{
  NS_ENSURE_ARG_POINTER(aResult);
  *aResult = PR_FALSE;

  PRBool isImapServer = PR_FALSE;
  nsresult rv = GetIsServer(&isImapServer);
  if (NS_FAILED(rv)) return rv;
 
  // you can only subscribe to imap servers, not imap folders
  *aResult = isImapServer;
  return NS_OK;
}

Definition at line 6407 of file nsImapMailFolder.cpp.

{
  nsIMsgOfflineImapOperation *returnOp = nsnull;
  nsOfflineImapOperationType opType;
  op->GetOperation(&opType);
  NS_ASSERTION(opType & nsIMsgOfflineImapOperation::kMoveResult, "not an offline move op");
  
  nsXPIDLCString sourceFolderURI;
  op->GetSourceFolderURI(getter_Copies(sourceFolderURI));
  
  nsCOMPtr<nsIRDFResource> res;
  nsresult rv;
  
  nsCOMPtr<nsIRDFService> rdf(do_GetService(kRDFServiceCID, &rv));
  if (NS_FAILED(rv)) 
    return rv; 
  rv = rdf->GetResource(sourceFolderURI, getter_AddRefs(res));
  if (NS_SUCCEEDED(rv))
  {
    nsCOMPtr<nsIMsgFolder> sourceFolder(do_QueryInterface(res, &rv));
    if (NS_SUCCEEDED(rv) && sourceFolder)
    {
      if (sourceFolder)
      {
        nsCOMPtr <nsIDBFolderInfo> folderInfo;
        sourceFolder->GetDBFolderInfoAndDB(getter_AddRefs(folderInfo), originalDB);
        if (*originalDB)
        {
          nsMsgKey originalKey;
          op->GetMessageKey(&originalKey);
          rv = (*originalDB)->GetOfflineOpForKey(originalKey, PR_FALSE, &returnOp);
          if (NS_SUCCEEDED(rv) && returnOp)
          {
            nsXPIDLCString moveDestination;
            nsXPIDLCString thisFolderURI;
            
            GetURI(getter_Copies(thisFolderURI));
            
            returnOp->GetDestinationFolderURI(getter_Copies(moveDestination));
            if (!nsCRT::strcmp(moveDestination, thisFolderURI))
              returnOp->ClearOperation(nsIMsgOfflineImapOperation::kMoveResult);
          }
        }
      }
    }
  }
  NS_IF_ADDREF(returnOp);
  *originalOp = returnOp;
  return rv;
}

Here is the call graph for this function:

Here is the caller graph for this function:

unsigned long nsIImapMessageSink::getCurMoveCopyMessageInfo ( in nsIImapUrl  runningUrl,
out PRTime  date,
out string  keywords 
) [inherited]

Definition at line 8638 of file nsImapMailFolder.cpp.

{
  if (mFlags & MSG_FOLDER_FLAG_IMAP_OTHER_USER)
  {
    nsresult rv;
    PRBool delegateOtherUsersFolders = PR_FALSE;
    nsCOMPtr<nsIPrefBranch> prefBranch(do_GetService(NS_PREFSERVICE_CONTRACTID, &rv));
    if (NS_SUCCEEDED(rv))
     prefBranch->GetBoolPref("mail.imap.delegateOtherUsersFolders", &delegateOtherUsersFolders);
    // if we're automatically delegating other user's folders, we need to 
    // cons up an e-mail address for the other user. We do that by
    // taking the other user's name and the current user's domain name,
    // assuming they'll be the same. So, <otherUsersName>@<ourDomain>
    if (delegateOtherUsersFolders)
    {
      nsCOMPtr<nsIMsgIncomingServer> server = do_QueryReferent(mServer, &rv);
      NS_ENSURE_SUCCESS(rv, rv);

      nsCOMPtr<nsIMsgAccountManager> accountManager = 
               do_GetService(NS_MSGACCOUNTMANAGER_CONTRACTID, &rv);
      NS_ENSURE_SUCCESS(rv, rv);
      nsCOMPtr <nsIMsgIdentity> ourIdentity;
      nsCOMPtr <nsIMsgIdentity> retIdentity;
      nsCOMPtr <nsIMsgAccount> account;
      nsXPIDLCString foldersUserName;
      nsXPIDLCString ourEmailAddress;

      accountManager->FindAccountForServer(server, getter_AddRefs(account));
      NS_ENSURE_SUCCESS(rv, rv);
      account->GetDefaultIdentity(getter_AddRefs(ourIdentity));
      NS_ENSURE_SUCCESS(rv, rv);
      ourIdentity->GetEmail(getter_Copies(ourEmailAddress));
      PRInt32 atPos = ourEmailAddress.FindChar('@');
      if (atPos != -1)
      {
        nsXPIDLCString otherUsersEmailAddress;

        GetFolderOwnerUserName(getter_Copies(otherUsersEmailAddress));
        otherUsersEmailAddress.Append(Substring(ourEmailAddress, atPos, ourEmailAddress.Length()));
        nsCOMPtr <nsISupportsArray> identities;
        rv = accountManager->GetIdentitiesForServer(server, getter_AddRefs(identities));
        NS_ENSURE_SUCCESS(rv, rv);
        PRUint32 numIdentities;
        rv = identities->Count(&numIdentities);
        NS_ENSURE_SUCCESS(rv, rv);
        for (PRUint32 identityIndex = 0; identityIndex < numIdentities; identityIndex++)
        {
          nsCOMPtr<nsIMsgIdentity> identity = do_QueryElementAt(identities, identityIndex);
          if (!identity)
            continue;
          nsXPIDLCString identityEmail;
          identity->GetEmail(getter_Copies(identityEmail));
          if (identityEmail.Equals(otherUsersEmailAddress))
          {
            retIdentity = identity;;
            break;
          }
        }
        if (!retIdentity)
        {
          // create the identity
          rv = accountManager->CreateIdentity(getter_AddRefs(retIdentity));
          NS_ENSURE_SUCCESS(rv, rv);
          retIdentity->SetEmail(otherUsersEmailAddress);
          nsCOMPtr <nsIMsgAccount> account;
          accountManager->FindAccountForServer(server, getter_AddRefs(account));
          NS_ENSURE_SUCCESS(rv, rv);
          account->AddIdentity(retIdentity);

        }
      }
      if (retIdentity)
      {
        NS_ADDREF(*aIdentity = retIdentity);
        return NS_OK;
      }
    }
  }
  return nsMsgDBFolder::GetCustomIdentity(aIdentity);
}

Here is the call graph for this function:

nsresult nsImapMailFolder::GetDatabase ( nsIMsgWindow aMsgWindow) [protected]

Definition at line 675 of file nsImapMailFolder.cpp.

{
  nsresult folderOpen = NS_OK;
  if (!mDatabase)
  {
    nsCOMPtr<nsIFileSpec> pathSpec;
    nsresult rv = GetPath(getter_AddRefs(pathSpec));
    if (NS_FAILED(rv)) return rv;

    nsCOMPtr<nsIMsgDBService> msgDBService = do_GetService(NS_MSGDB_SERVICE_CONTRACTID, &rv);
    NS_ENSURE_SUCCESS(rv, rv);

    folderOpen = msgDBService->OpenFolderDB(this, PR_TRUE, PR_FALSE, getter_AddRefs(mDatabase));
    
    if (NS_FAILED(folderOpen) && folderOpen != NS_MSG_ERROR_FOLDER_SUMMARY_MISSING)
      folderOpen = msgDBService->OpenFolderDB(this, PR_TRUE, PR_TRUE, getter_AddRefs(mDatabase));

    if (NS_FAILED(folderOpen) && folderOpen != NS_MSG_ERROR_FOLDER_SUMMARY_MISSING)
      return folderOpen;

    if(folderOpen == NS_MSG_ERROR_FOLDER_SUMMARY_MISSING)
      folderOpen = NS_OK;

    if(mDatabase)
    {
      UpdateNewMessages();
      if(mAddListener)
        mDatabase->AddListener(this);
      UpdateSummaryTotals(PR_TRUE);
    }
  }
  return folderOpen;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 2031 of file nsImapMailFolder.cpp.

{
  nsresult openErr=NS_ERROR_UNEXPECTED;
  if(!db || !folderInfo)
    return NS_ERROR_NULL_POINTER; //ducarroz: should we use NS_ERROR_INVALID_ARG?
  nsresult rv;

  openErr = GetDatabase(nsnull);

  *db = mDatabase;
  NS_IF_ADDREF(*db);
  if (NS_SUCCEEDED(openErr)&& *db)
  {
    openErr = (*db)->GetDBFolderInfo(folderInfo);
    if (NS_SUCCEEDED(openErr) && folderInfo)
    {
      nsXPIDLCString onlineName;
      if (NS_SUCCEEDED((*folderInfo)->GetCharPtrProperty("onlineName", getter_Copies(onlineName))))
      {
        if (!onlineName.IsEmpty())
          m_onlineFolderName.Assign(onlineName);
        else
        {
          nsAutoString autoOnlineName; 
          // autoOnlineName.AssignWithConversion(name);
          (*folderInfo)->GetMailboxName(autoOnlineName);
          if (autoOnlineName.IsEmpty())
          {
            nsXPIDLCString uri;
            rv = GetURI(getter_Copies(uri));
            if (NS_FAILED(rv)) return rv;
            nsXPIDLCString hostname;
            rv = GetHostname(getter_Copies(hostname));
            if (NS_FAILED(rv)) return rv;
            nsXPIDLCString name;
            rv = nsImapURI2FullName(kImapRootURI, hostname, uri, getter_Copies(name));
            nsCAutoString onlineCName(name);
            if (m_hierarchyDelimiter != '/')
              onlineCName.ReplaceChar('/',  char(m_hierarchyDelimiter));
            m_onlineFolderName.Assign(onlineCName); 
            autoOnlineName.AssignWithConversion(onlineCName.get());
          }
          rv = (*folderInfo)->SetProperty("onlineName", autoOnlineName);
        }
      }
    }
  }
  return openErr;
}

Here is the call graph for this function:

Definition at line 1751 of file nsImapMailFolder.cpp.

{
    nsresult rv = NS_ERROR_FAILURE;
    return rv;
}
nsresult nsImapMailFolder::GetFolder ( const char *  name,
nsIMsgFolder **  pFolder 
) [protected]

Definition at line 7710 of file nsImapMailFolder.cpp.

{
  if (!m_folderACL)
    m_folderACL = new nsMsgIMAPFolderACL(this);
  return m_folderACL;
}

Here is the caller graph for this function:

nsresult nsImapMailFolder::GetFolderOwnerUserName ( char **  userName) [protected]

Definition at line 3682 of file nsImapMailFolder.cpp.

{  
  if ((mFlags & MSG_FOLDER_FLAG_IMAP_PERSONAL) ||
    !(mFlags & (MSG_FOLDER_FLAG_IMAP_PUBLIC | MSG_FOLDER_FLAG_IMAP_OTHER_USER)))
  {
    // this is one of our personal mail folders
    // return our username on this host
  nsCOMPtr<nsIMsgIncomingServer> server;
  nsresult rv = GetServer(getter_AddRefs(server));
  if (NS_SUCCEEDED(rv) && server)
    return server->GetUsername(userName);
  else
    return rv;
  }
  
  // the only other type of owner is if it's in the other users' namespace
  if (!(mFlags & MSG_FOLDER_FLAG_IMAP_OTHER_USER))
    return NS_OK;
  
  if (m_ownerUserName.IsEmpty())
  {
    nsXPIDLCString onlineName;
    GetOnlineName(getter_Copies(onlineName));
    m_ownerUserName = nsIMAPNamespaceList::GetFolderOwnerNameFromPath(GetNamespaceForFolder(), onlineName.get());
  }
  *userName = !m_ownerUserName.IsEmpty() ? ToNewCString(m_ownerUserName) : nsnull;
  return NS_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 7673 of file nsImapMailFolder.cpp.

{
  NS_ENSURE_ARG_POINTER(aFolderURL);
  nsCOMPtr<nsIMsgFolder> rootFolder;
  nsresult rv = GetRootFolder(getter_AddRefs(rootFolder));
  NS_ENSURE_SUCCESS(rv, rv);
  nsXPIDLCString rootURI;
  rootFolder->GetURI(getter_Copies(rootURI));

  NS_ASSERTION(mURI.Length() > rootURI.Length(), "Should match with a folder name!");
  nsAdoptingCString escapedName(nsEscape(mURI.get() + rootURI.Length(),
                                         url_Path));
  if (escapedName.IsEmpty()) 
      return NS_ERROR_OUT_OF_MEMORY;

  *aFolderURL = ToNewCString(rootURI + escapedName);
  if (!*aFolderURL)
      return NS_ERROR_OUT_OF_MEMORY;

  return NS_OK;
}

Here is the call graph for this function:

Definition at line 1817 of file nsImapMailFolder.cpp.

{
  NS_ENSURE_ARG(aImapIncomingServer);

  *aImapIncomingServer = nsnull;

  nsCOMPtr<nsIMsgIncomingServer> server;

  if (NS_SUCCEEDED(GetServer(getter_AddRefs(server))) && server)
  {
    nsCOMPtr <nsIImapIncomingServer> incomingServer = do_QueryInterface(server);
    *aImapIncomingServer = incomingServer;
    NS_IF_ADDREF(*aImapIncomingServer);
    return NS_OK;
  }
  return NS_ERROR_NULL_POINTER;
}

Here is the call graph for this function:

Here is the caller graph for this function:

virtual const char* nsImapMailFolder::GetIncomingServerType ( ) [inline, protected, virtual]

Definition at line 380 of file nsImapMailFolder.h.

{return "imap";}
ACString nsIImapMailFolderSink::getMessageId ( in nsIImapUrl  aUrl) [inherited]

Definition at line 852 of file nsImapMailFolder.cpp.

{
  if (result)
    *result = nsnull;
  if (!mDatabase)
    GetDatabase(nsnull);
  if (mDatabase)
    return mDatabase->EnumerateMessages(result);
  return NS_ERROR_UNEXPECTED;
}

Here is the call graph for this function:

void nsIImapMessageSink::GetMessageSizeFromDB ( in string  id,
in boolean  idIsUid,
out unsigned long  size 
) [inherited]

Definition at line 8231 of file nsImapMailFolder.cpp.

{
   if (!m_moveCoalescer)
   {
      m_moveCoalescer = new nsImapMoveCoalescer(this, nsnull /* msgWindow */);
      NS_ENSURE_TRUE (m_moveCoalescer, NS_ERROR_OUT_OF_MEMORY);
      m_moveCoalescer->AddRef();
   }
   return NS_OK;
}

Here is the caller graph for this function:

Definition at line 3756 of file nsImapMailFolder.cpp.

{
  if (!m_namespace)
  {
#ifdef DEBUG_bienvenu
    // Make sure this isn't causing us to open the database
    NS_ASSERTION(m_hierarchyDelimiter != kOnlineHierarchySeparatorUnknown, "haven't set hierarchy delimiter");
#endif
    nsXPIDLCString serverKey;
    nsXPIDLCString onlineName;
    GetServerKey(getter_Copies(serverKey));
    GetOnlineName(getter_Copies(onlineName));
    PRUnichar hierarchyDelimiter;
    GetHierarchyDelimiter(&hierarchyDelimiter);

    m_namespace = nsIMAPNamespaceList::GetNamespaceForFolder(serverKey.get(), onlineName.get(), (char) hierarchyDelimiter);
    NS_ASSERTION(m_namespace, "didn't get namespace for folder");
    if (m_namespace)
    {
      nsIMAPNamespaceList::SuggestHierarchySeparatorForNamespace(m_namespace, (char) hierarchyDelimiter);
      m_folderIsNamespace = nsIMAPNamespaceList::GetFolderIsNamespace(serverKey.get(), onlineName.get(), (char) hierarchyDelimiter, m_namespace);
    }
  }
  return m_namespace;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 2481 of file nsImapMailFolder.cpp.

{
  nsCOMPtr<nsIMsgFolder> rootFolder;
  nsresult rv = GetRootFolder(getter_AddRefs(rootFolder));

  if(NS_SUCCEEDED(rv) && rootFolder) 
  {

    nsCOMPtr<nsIImapIncomingServer> imapServer;
    GetImapIncomingServer(getter_AddRefs(imapServer));
 
    PRBool performingBiff = PR_FALSE;

    if (imapServer)
    {
      nsCOMPtr<nsIMsgIncomingServer> incomingServer = do_QueryInterface(imapServer, &rv);
      if (incomingServer)
        incomingServer->GetPerformingBiff(&performingBiff);
    }

    // Check preferences to see if we should check all folders for new 
    // messages, or just the inbox and marked ones
    PRBool checkAllFolders = PR_FALSE;

    nsCOMPtr<nsIPrefBranch> prefBranch = do_GetService(NS_PREFSERVICE_CONTRACTID, &rv);
    if (NS_SUCCEEDED(rv) && prefBranch) 
      // This pref might not exist, which is OK. We'll only check inbox and marked ones
      rv = prefBranch->GetBoolPref("mail.check_all_imap_folders_for_new", &checkAllFolders); 

    m_urlListener = aListener;                                                  

    // Get new messages for inbox
    PRUint32 numFolders;
    nsCOMPtr<nsIMsgFolder> inbox;
    rv = rootFolder->GetFoldersWithFlag(MSG_FOLDER_FLAG_INBOX, 1, &numFolders, getter_AddRefs(inbox));
    if (inbox)
    {
      nsCOMPtr<nsIMsgImapMailFolder> imapFolder = do_QueryInterface(inbox, &rv);
      if (imapFolder)
        imapFolder->SetPerformingBiff(performingBiff);

      inbox->SetGettingNewMessages(PR_TRUE);
      rv = inbox->UpdateFolder(aWindow);
    }

    // Get new messages for other folders if marked, or all of them if the pref is set
    if (imapServer)
      rv = imapServer->GetNewMessagesForNonInboxFolders(rootFolder, aWindow, checkAllFolders, performingBiff);
  }

  return rv;
}

Here is the call graph for this function:

Definition at line 1240 of file nsImapMailFolder.cpp.

Definition at line 6458 of file nsImapMailFolder.cpp.

{
  nsIMsgOfflineImapOperation *returnOp = nsnull;
  
  nsXPIDLCString sourceFolderURI;
  op->GetSourceFolderURI(getter_Copies(sourceFolderURI));
       
  nsCOMPtr<nsIRDFResource> res;
  nsresult rv;

  nsCOMPtr<nsIRDFService> rdf(do_GetService(kRDFServiceCID, &rv));
  if (NS_FAILED(rv)) 
    return rv; 
  rv = rdf->GetResource(sourceFolderURI, getter_AddRefs(res));
  if (NS_SUCCEEDED(rv))
  {
    nsCOMPtr<nsIMsgFolder> sourceFolder(do_QueryInterface(res, &rv));
    if (NS_SUCCEEDED(rv) && sourceFolder)
    {
           if (sourceFolder)
           {
        nsCOMPtr <nsIDBFolderInfo> folderInfo;
        sourceFolder->GetDBFolderInfoAndDB(getter_AddRefs(folderInfo), originalDB);
                  if (*originalDB)
                  {
          nsMsgKey originalKey;
          op->GetMessageKey(&originalKey);
          rv = (*originalDB)->GetOfflineOpForKey(originalKey, PR_FALSE, &returnOp);
                  }
      }
    }
       }
  NS_IF_ADDREF(returnOp);
  *originalOp = returnOp;
  return rv;
}

Here is the call graph for this function:

nsresult nsImapMailFolder::GetOwnersOnlineFolderName ( char **  onlineName) [protected]

Definition at line 3713 of file nsImapMailFolder.cpp.

{
  nsXPIDLCString onlineName;

  GetOnlineName(getter_Copies(onlineName));
  if (mFlags & MSG_FOLDER_FLAG_IMAP_OTHER_USER)
  {
    nsXPIDLCString user;
    GetFolderOwnerUserName(getter_Copies(user));
    if (!onlineName.IsEmpty() && !user.IsEmpty())
    {
      const char *where = PL_strstr(onlineName.get(), user.get());
      NS_ASSERTION(where, "user name not in online name");
      if (where)
      {
        const char *relativeFolder = where + strlen(user) + 1;
        if (!relativeFolder)       // root of this user's personal namespace
        {
          *retName = PL_strdup("");
          return NS_OK;
        }
        else
        {
          *retName = PL_strdup(relativeFolder);
          return NS_OK;
        }
      }
    }

    *retName = PL_strdup(onlineName.get());
    return NS_OK;
  }
  else if (!(mFlags & MSG_FOLDER_FLAG_IMAP_PUBLIC))
  {
    // We own this folder.
    *retName = nsIMAPNamespaceList::GetFolderNameWithoutNamespace(GetNamespaceForFolder(), onlineName);
    
  }
  else
    *retName = PL_strdup(onlineName.get());
  return NS_OK;
}

Here is the call graph for this function:

Definition at line 6136 of file nsImapMailFolder.cpp.

{
  nsresult rv;
  if (! m_pathName) 
  {
    m_pathName = new nsNativeFileSpec("");
    if (! m_pathName)
       return NS_ERROR_OUT_OF_MEMORY;

    rv = nsImapURI2Path(kImapRootURI, mURI.get(), *m_pathName);
    //    printf("constructing path %s\n", (const char *) *m_pathName);
    if (NS_FAILED(rv)) return rv;
  }
  rv = NS_NewFileSpecWithSpec(*m_pathName, aPathName);
  return NS_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 1714 of file nsImapMailFolder.cpp.

{
  return GetName(prettyName);
}
void nsIMsgImapMailFolder::getQuota ( out boolean  valid,
out unsigned long  usedKB,
out unsigned long  maxKB 
) [inherited]

Quota |valid| indicates whether the server has provided quota information on this folder.

This can be false

  • if the server does not supports quotas,
  • if there are no storage quotas on this folder, or
  • if the folder has never been opened. If it is true and maxKB > 0, the folder has a storage quota and the usedKB and maxKB attributes are set to the values provided by the server (in kilobytes), for this quota root. Lotus Notes sends us maxKB = 0, usedKB > 0 for unlimited quota.

Definition at line 1757 of file nsImapMailFolder.cpp.

{
    nsresult rv = NS_ERROR_FAILURE;
    return rv;
}
nsresult nsImapMailFolder::GetServerAdminUrl ( char **  aAdminUrl) [protected]

Definition at line 3790 of file nsImapMailFolder.cpp.

{
  nsCOMPtr<nsIImapIncomingServer> imapServer;
  nsresult rv = GetImapIncomingServer(getter_AddRefs(imapServer));

  if (NS_SUCCEEDED(rv) && imapServer) 
    rv = imapServer->GetManageMailAccountUrl(aAdminUrl);
  return rv;
}

Here is the call graph for this function:

nsresult nsImapMailFolder::GetServerKey ( char **  serverKey) [protected]

Definition at line 1807 of file nsImapMailFolder.cpp.

{
  // look for matching imap folders, then pop folders
  nsCOMPtr<nsIMsgIncomingServer> server;
  nsresult rv = GetServer(getter_AddRefs(server));
  if (NS_SUCCEEDED(rv) && server)
    return server->GetKey(serverKey);
  return rv;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 1763 of file nsImapMailFolder.cpp.

{
  NS_ENSURE_ARG_POINTER(size);
  *size = mFolderSize;
  return NS_OK;
}

Definition at line 619 of file nsImapMailFolder.cpp.

{
  PRBool isServer;
  nsresult rv = GetIsServer(&isServer);

  if (!m_initialized)
  {
    nsCOMPtr<nsIFileSpec> pathSpec;
    rv = GetPath(getter_AddRefs(pathSpec));
    if (NS_FAILED(rv)) return rv;

    nsFileSpec path;
    rv = pathSpec->GetFileSpec(&path);
    if (NS_FAILED(rv)) return rv;

    // host directory does not need .sbd tacked on
    if (NS_SUCCEEDED(rv) && !isServer)
      rv = AddDirectorySeparator(path);

    if(NS_FAILED(rv)) return rv;
    
    m_initialized = PR_TRUE;      // need to set this here to avoid infinite recursion from CreateSubfolders.
    // we have to treat the root folder specially, because it's name
    // doesn't end with .sbd

    PRInt32 newFlags = MSG_FOLDER_FLAG_MAIL;
    if (path.IsDirectory()) 
    {
        newFlags |= (MSG_FOLDER_FLAG_DIRECTORY | MSG_FOLDER_FLAG_ELIDED);
        if (!mIsServer)
          SetFlag(newFlags);
        rv = CreateSubFolders(path);
    }
    if (isServer)
    {
      PRUint32 numFolders = 0;
      nsCOMPtr <nsIMsgFolder> inboxFolder;

      rv = GetFoldersWithFlag(MSG_FOLDER_FLAG_INBOX, 1, &numFolders, getter_AddRefs(inboxFolder));
      if (NS_FAILED(rv) || numFolders == 0 || !inboxFolder)
      {
        // create an inbox if we don't have one.
        CreateClientSubfolderInfo("INBOX", kOnlineHierarchySeparatorUnknown,0, PR_TRUE);
      }
    }

    UpdateSummaryTotals(PR_FALSE);

    if (NS_FAILED(rv)) return rv;
  }
  rv = mSubFolders->Enumerate(result);
  return rv;
}

Here is the call graph for this function:

Definition at line 5712 of file nsImapMailFolder.cpp.

{
  NS_ENSURE_ARG_POINTER(userFlags);

  nsresult rv = NS_OK;

  ReadDBFolderInfo(PR_FALSE); // update cache first.
  if (m_supportedUserFlags == 0) // 0 means invalid value, so get it from db.
  {
    nsCOMPtr<nsIDBFolderInfo> dbFolderInfo;
    rv = GetDatabase(nsnull);

    if (mDatabase)
    {
      rv = mDatabase->GetDBFolderInfo(getter_AddRefs(dbFolderInfo));
      if (NS_SUCCEEDED(rv) && dbFolderInfo)
      {
        rv = dbFolderInfo->GetUint32Property("imapFlags", 0, userFlags);
        m_supportedUserFlags = *userFlags;
      }
    }
  }
  else
    *userFlags = m_supportedUserFlags;
  return rv;
}

Here is the call graph for this function:

Here is the caller graph for this function:

nsresult nsImapMailFolder::GetTrashFolder ( nsIMsgFolder **  pTrashFolder) [protected]

Definition at line 4663 of file nsImapMailFolder.cpp.

{
  if (!pTrashFolder)
    return NS_ERROR_NULL_POINTER;

  nsCOMPtr<nsIMsgFolder> rootFolder;
  nsresult rv = GetRootFolder(getter_AddRefs(rootFolder));
  if(NS_SUCCEEDED(rv))
  {
    PRUint32 numFolders;
    rv = rootFolder->GetFoldersWithFlag(MSG_FOLDER_FLAG_TRASH, 1, &numFolders, pTrashFolder);
    if (numFolders != 1)
      rv = NS_ERROR_FAILURE;
  }
  return rv;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void nsImapMailFolder::GetTrashFolderName ( nsAString &  aFolderName) [protected]

Definition at line 8491 of file nsImapMailFolder.cpp.

{
  nsCOMPtr<nsIMsgIncomingServer> server;
  nsCOMPtr<nsIImapIncomingServer> imapServer;
    
  if (NS_SUCCEEDED(GetServer(getter_AddRefs(server))) && server)
    imapServer = do_QueryInterface(server);
    
  if (imapServer)
  {
    nsXPIDLString trashFolderName;
    if (NS_SUCCEEDED(imapServer->GetTrashFolderName(getter_Copies(trashFolderName))))
    {
      aFolderName = trashFolderName;
    }
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:

nsresult nsImapMailFolder::HandleCustomFlags ( nsMsgKey  uidOfMessage,
nsIMsgDBHdr dbHdr,
nsXPIDLCString keywords 
) [protected]

Definition at line 4432 of file nsImapMailFolder.cpp.

{
  ToLowerCase(keywords);
  PRBool messageClassified = PR_TRUE;
  nsXPIDLCString::const_iterator b, e;
  if (FindInReadable(NS_LITERAL_CSTRING("NonJunk"), keywords.BeginReading(b), 
                      keywords.EndReading(e), nsCaseInsensitiveCStringComparator()))
    mDatabase->SetStringProperty(uidOfMessage, "junkscore", "0");
  // Mac Mail uses "NotJunk"
  else if (FindInReadable(NS_LITERAL_CSTRING("NotJunk"), keywords.BeginReading(b), 
                        keywords.EndReading(e), nsCaseInsensitiveCStringComparator()))
    mDatabase->SetStringProperty(uidOfMessage, "junkscore", "0");
  // ### TODO: we really should parse the keywords into space delimited keywords before checking
  else if (FindInReadable(NS_LITERAL_CSTRING("Junk"), keywords.BeginReading(b), 
                          keywords.EndReading(e), nsCaseInsensitiveCStringComparator()))
  {
    PRUint32 newFlags;
    dbHdr->AndFlags(~MSG_FLAG_NEW, &newFlags);
    mDatabase->SetStringProperty(uidOfMessage, "junkscore", "100");
  }
  else
    messageClassified = PR_FALSE;
  if (messageClassified)
  {
    // only set the junkscore origin if it wasn't set before. We assume plugin since we
    // think that's the more common scenario.
    nsXPIDLCString existingProperty;
    dbHdr->GetStringProperty("junkscoreorigin", getter_Copies(existingProperty));
    if (existingProperty.IsEmpty())
      dbHdr->SetStringProperty("junkscoreorigin", "plugin");
  }
  return dbHdr->SetStringProperty("keywords", keywords);
}

Here is the call graph for this function:

Here is the caller graph for this function:

nsresult nsImapMailFolder::InitCopyState ( nsISupports *  srcSupport,
nsISupportsArray messages,
PRBool  isMove,
PRBool  selectedState,
PRBool  acrossServers,
PRUint32  newMsgFlags,
nsIMsgCopyServiceListener listener,
nsIMsgWindow msgWindow,
PRBool  allowUndo 
) [protected]

Definition at line 7561 of file nsImapMailFolder.cpp.

{
    nsresult rv = NS_OK;

    if (!srcSupport || !messages) return NS_ERROR_NULL_POINTER;
    NS_ASSERTION(!m_copyState, "move/copy already in progress");
    if (m_copyState) return NS_ERROR_FAILURE;

    nsImapMailCopyState* copyState = new nsImapMailCopyState();
    m_copyState = do_QueryInterface(copyState);

    if (!m_copyState) 
      return NS_ERROR_OUT_OF_MEMORY;

    m_copyState->m_isCrossServerOp = acrossServers;
    if (srcSupport)
        m_copyState->m_srcSupport = do_QueryInterface(srcSupport, &rv);

    if (NS_SUCCEEDED(rv))
    {
      m_copyState->m_messages = do_QueryInterface(messages, &rv);
      rv = messages->Count(&m_copyState->m_totalCount);
      if (!m_copyState->m_isCrossServerOp)
      {
        if (NS_SUCCEEDED(rv))
        {
            PRUint32 numUnread = 0;
            for (PRUint32 keyIndex=0; keyIndex < m_copyState->m_totalCount; keyIndex++)
            {
              nsCOMPtr<nsIMsgDBHdr> message =
                  do_QueryElementAt(m_copyState->m_messages, keyIndex, &rv);
              // if the key is not there, then assume what the caller tells us to.
              PRBool isRead = PR_FALSE;
              PRUint32 flags;
              if (message )
              {
                message->GetFlags(&flags);
                isRead = flags & MSG_FLAG_READ;
              }

              if (!isRead)
                numUnread++;
            }
            m_copyState->m_unreadCount = numUnread;
        }
      }
      else
      {
        nsCOMPtr<nsIMsgDBHdr> message =
            do_QueryElementAt(m_copyState->m_messages,
                              m_copyState->m_curIndex, &rv);
          // if the key is not there, then assume what the caller tells us to.
        PRBool isRead = PR_FALSE;
        PRUint32 flags;
        if (message )
        {
          message->GetFlags(&flags);
          isRead = flags & MSG_FLAG_READ;
        }

        m_copyState->m_unreadCount = (isRead) ? 0 : 1;
      }
    }
    m_copyState->m_isMove = isMove;
    m_copyState->m_newMsgFlags = newMsgFlags;
    m_copyState->m_allowUndo = allowUndo;
    m_copyState->m_selectedState = selectedState;
    m_copyState->m_msgWindow = msgWindow;
    if (listener)
        m_copyState->m_listener = do_QueryInterface(listener, &rv);
        
    return rv;
}

Here is the call graph for this function:

Here is the caller graph for this function:

NS_IMETHODIMP nsImapMailFolder::IsCommandEnabled ( const char *  command,
PRBool result 
)

Definition at line 8158 of file nsImapMailFolder.cpp.

{
  NS_ENSURE_ARG_POINTER(result);
  NS_ENSURE_ARG_POINTER(command);

  *result = PR_TRUE;

  if(WeAreOffline() &&
     ((nsCRT::strcmp(command, "cmd_renameFolder") == 0) ||
      (nsCRT::strcmp(command, "cmd_compactFolder") == 0) ||
      (nsCRT::strcmp(command, "cmd_delete") == 0) ||
      (nsCRT::strcmp(command, "button_delete") == 0)))
     *result = PR_FALSE;

  return NS_OK;
}

Here is the call graph for this function:

nsIURI nsIMsgImapMailFolder::issueCommandOnMsgs ( in string  command,
in string  uids,
in nsIMsgWindow  aWindow 
) [inherited]
void nsIMsgImapMailFolder::liteSelect ( in nsIUrlListener  aUrlListener) [inherited]

Definition at line 1897 of file nsImapMailFolder.cpp.

{
  nsresult rv = GetDatabase(nsnull);
  
  if(NS_SUCCEEDED(rv))
  {
    nsMsgKeyArray thoseMarked;
    EnableNotifications(allMessageCountNotifications, PR_FALSE, PR_TRUE /*dbBatching*/);
    rv = mDatabase->MarkAllRead(&thoseMarked);
    EnableNotifications(allMessageCountNotifications, PR_TRUE, PR_TRUE /*dbBatching*/);
    if (NS_SUCCEEDED(rv))
    {
      rv = StoreImapFlags(kImapMsgSeenFlag, PR_TRUE, thoseMarked.GetArray(), 
                          thoseMarked.GetSize(), nsnull);
      mDatabase->Commit(nsMsgDBCommitType::kLargeCommit);
    }
  }

  return rv;
}

Here is the call graph for this function:

Definition at line 1975 of file nsImapMailFolder.cpp.

{
  nsresult rv;

  // tell the folder to do it, which will mark them read in the db.
  rv = nsMsgDBFolder::MarkMessagesFlagged(messages, markFlagged);
  if (NS_SUCCEEDED(rv))
  {
    nsCAutoString messageIds;
        nsMsgKeyArray keysToMarkFlagged;
    rv = BuildIdsAndKeyArray(messages, messageIds, keysToMarkFlagged);
    if (NS_FAILED(rv)) return rv;

    rv = StoreImapFlags(kImapMsgFlaggedFlag, markFlagged,  keysToMarkFlagged.GetArray(), 
                        keysToMarkFlagged.GetSize(), nsnull);
    mDatabase->Commit(nsMsgDBCommitType::kLargeCommit);
  }
  return rv;
}

Here is the call graph for this function:

nsresult nsImapMailFolder::MarkMessagesImapDeleted ( nsMsgKeyArray *  keyArray,
PRBool  deleted,
nsIMsgDatabase db 
) [protected]

Definition at line 2164 of file nsImapMailFolder.cpp.

{
  for (PRUint32 kindex = 0; kindex < keyArray->GetSize(); kindex++)
  {
    nsMsgKey key = keyArray->ElementAt(kindex);
    db->MarkImapDeleted(key, deleted, nsnull);
  }
  return NS_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 1857 of file nsImapMailFolder.cpp.

{
  // tell the folder to do it, which will mark them read in the db.
  nsresult rv = nsMsgDBFolder::MarkMessagesRead(messages, markRead);
  if (NS_SUCCEEDED(rv))
  {
    nsCAutoString messageIds;
    nsMsgKeyArray keysToMarkRead;
    rv = BuildIdsAndKeyArray(messages, messageIds, keysToMarkRead);
    if (NS_FAILED(rv)) return rv;

    StoreImapFlags(kImapMsgSeenFlag, markRead,  keysToMarkRead.GetArray(), keysToMarkRead.GetSize(), nsnull);
    rv = GetDatabase(nsnull);
    if (NS_SUCCEEDED(rv))
      mDatabase->Commit(nsMsgDBCommitType::kLargeCommit);
  }
  return rv;
}

Here is the call graph for this function:

Definition at line 1918 of file nsImapMailFolder.cpp.

{

  nsresult rv = GetDatabase(nsnull);
  if(NS_SUCCEEDED(rv))
  {
    nsMsgKeyArray thoseMarked;
              rv = mDatabase->MarkThreadRead(thread, nsnull, &thoseMarked);
    if (NS_SUCCEEDED(rv))
    {
      rv = StoreImapFlags(kImapMsgSeenFlag, PR_TRUE, thoseMarked.GetArray(), 
                          thoseMarked.GetSize(), nsnull);
      mDatabase->Commit(nsMsgDBCommitType::kLargeCommit);
    }
  }
  return rv;
}

Here is the call graph for this function:

Definition at line 7655 of file nsImapMailFolder.cpp.

{
  if (!matches)
    return NS_ERROR_NULL_POINTER;
    PRBool isInbox = mName.LowerCaseEqualsLiteral("inbox");
    if (isInbox)
        *matches = mName.Equals(*name, nsCaseInsensitiveStringComparator());
    else
        *matches = mName.Equals(*name);
        
  return NS_OK;
}
nsresult nsImapMailFolder::MoveIncorporatedMessage ( nsIMsgDBHdr mailHdr,
nsIMsgDatabase sourceDB,
const nsACString &  destFolder,
nsIMsgFilter filter,
nsIMsgWindow msgWindow 
)

Definition at line 3883 of file nsImapMailFolder.cpp.

{
  nsresult err = NS_OK;
  
  if (m_moveCoalescer)
  {

    nsCOMPtr<nsIRDFService> rdf(do_GetService(kRDFServiceCID, &err)); 
    nsCOMPtr<nsIRDFResource> res;
    err = rdf->GetResource(destFolderUri, getter_AddRefs(res));
    if (NS_FAILED(err))
      return err;

    nsCOMPtr<nsIMsgFolder> destIFolder(do_QueryInterface(res, &err));
    if (NS_FAILED(err))
      return err;        

    if (destIFolder)
    {
      // check if the destination is a real folder (by checking for null parent)
      // and if it can file messages (e.g., servers or news folders can't file messages).
      // Or read only imap folders...
      PRBool canFileMessages = PR_TRUE;
      nsCOMPtr<nsIMsgFolder> parentFolder;
      destIFolder->GetParent(getter_AddRefs(parentFolder));
      if (parentFolder)
        destIFolder->GetCanFileMessages(&canFileMessages);
      if (filter && (!parentFolder || !canFileMessages))
      {
        filter->SetEnabled(PR_FALSE);
        m_filterList->SaveToDefaultFile();
        destIFolder->ThrowAlertMsg("filterDisabled",msgWindow);
        return NS_MSG_NOT_A_MAIL_FOLDER;
      }
      // put the header into the source db, since it needs to be there when we copy it
      // and we need a valid header to pass to StartAsyncCopyMessagesInto
      nsMsgKey keyToFilter;
      mailHdr->GetMessageKey(&keyToFilter);

      if (sourceDB && destIFolder)
      {
        PRBool imapDeleteIsMoveToTrash = DeleteIsMoveToTrash();

        m_moveCoalescer->AddMove (destIFolder, keyToFilter);
        // For each folder, we need to keep track of the ids we want to move to that
        // folder - we used to store them in the MSG_FolderInfo and then when we'd finished
        // downloading headers, we'd iterate through all the folders looking for the ones
        // that needed messages moved into them - perhaps instead we could
        // keep track of nsIMsgFolder, nsMsgKeyArray pairs here in the imap code.
//        nsMsgKeyArray *idsToMoveFromInbox = msgFolder->GetImapIdsToMoveFromInbox();
//        idsToMoveFromInbox->Add(keyToFilter);
        if (imapDeleteIsMoveToTrash)
        {
        }
        PRBool isRead = PR_FALSE;
        mailHdr->GetIsRead(&isRead);
        if (!isRead)
          destIFolder->SetFlag(MSG_FOLDER_FLAG_GOT_NEW);
        
        if (imapDeleteIsMoveToTrash)  
          err = 0;
      }
    }
  }
  
  
  // we have to return an error because we do not actually move the message
  // it is done async and that can fail
  return err;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 2948 of file nsImapMailFolder.cpp.

{
  nsCOMPtr<nsIMsgDBHdr> newMsgHdr;
  nsresult rv = NS_OK;

  if (m_msgParser)
  {
    nsMailboxParseState parseState;
    m_msgParser->GetState(&parseState);
    if (parseState == nsIMsgParseMailMsgState::ParseHeadersState)
    m_msgParser->ParseAFolderLine(CRLF, 2);
    m_msgParser->GetNewMsgHdr(getter_AddRefs(newMsgHdr));
  }
  if (NS_SUCCEEDED(rv) && newMsgHdr)
  {
    char *headers;
    PRInt32 headersSize;

    nsCOMPtr <nsIMsgWindow> msgWindow;
    nsCOMPtr <nsIMsgMailNewsUrl> msgUrl;
    if (imapUrl)
    {
      msgUrl = do_QueryInterface(imapUrl);
      if (msgUrl)
        msgUrl->GetMsgWindow(getter_AddRefs(msgWindow));
    }
    nsCOMPtr<nsIMsgIncomingServer> server;
    rv = GetServer(getter_AddRefs(server));
    if (NS_SUCCEEDED(rv)) // don't use NS_ENSURE_SUCCESS here; it's not a fatal error
    {
      nsXPIDLCString redirectorType;
      server->GetRedirectorType(getter_Copies(redirectorType));

      // only notify redirected type servers of new hdrs for performance
      if (!redirectorType.IsEmpty())
        NotifyFolderEvent(mImapHdrDownloadedAtom);
    }
    newMsgHdr->SetMessageKey(m_curMsgUid);
    TweakHeaderFlags(aProtocol, newMsgHdr);
    PRUint32 messageSize;
    if (NS_SUCCEEDED(newMsgHdr->GetMessageSize(&messageSize)))
      mFolderSize += messageSize;
    m_msgMovedByFilter = PR_FALSE;
    // If this is the inbox, try to apply filters.
    if (mFlags & MSG_FOLDER_FLAG_INBOX)
    {
      PRUint32 msgFlags;

      newMsgHdr->GetFlags(&msgFlags);
      if (!(msgFlags & (MSG_FLAG_READ | MSG_FLAG_IMAP_DELETED))) // only fire on unread msgs that haven't been deleted
      {
        PRInt32 duplicateAction = nsIMsgIncomingServer::keepDups;
        if (server)
          server->GetIncomingDuplicateAction(&duplicateAction);
        if (duplicateAction != nsIMsgIncomingServer::keepDups)
        {
          PRBool isDup;
          server->IsNewHdrDuplicate(newMsgHdr, &isDup);
          if (isDup)
          {
            // we want to do something similar to applying filter hits.
            // if a dup is marked read, it shouldn't trigger biff.
            // Same for deleting it or moving it to trash.
            switch (duplicateAction)
            {
              case nsIMsgIncomingServer::deleteDups:
                {
                  PRUint32 newFlags;
                  newMsgHdr->OrFlags(MSG_FLAG_READ | MSG_FLAG_IMAP_DELETED, &newFlags);
                  nsMsgKeyArray keysToFlag;

                  keysToFlag.Add(m_curMsgUid);
                  StoreImapFlags(kImapMsgSeenFlag | kImapMsgDeletedFlag, PR_TRUE, keysToFlag.GetArray(), 
                                keysToFlag.GetSize(), nsnull);
                  m_msgMovedByFilter = PR_TRUE;

                }
                break;
              case nsIMsgIncomingServer::moveDupsToTrash:
                {
                  nsCOMPtr <nsIMsgFolder> trash;
                  GetTrashFolder(getter_AddRefs(trash));
                  if (trash)
                  {
                    nsXPIDLCString trashUri;
                    trash->GetURI(getter_Copies(trashUri));
                    nsresult err = MoveIncorporatedMessage(newMsgHdr, mDatabase, trashUri, nsnull, msgWindow);
                    if (NS_SUCCEEDED(err))
                      m_msgMovedByFilter = PR_TRUE;
                  }
                }
                break;
              case nsIMsgIncomingServer::markDupsRead:
                {
                  PRUint32 newFlags;
                  nsMsgKeyArray keysToFlag;
                  keysToFlag.Add(m_curMsgUid);
                  newMsgHdr->OrFlags(MSG_FLAG_READ, &newFlags);
                  StoreImapFlags(kImapMsgSeenFlag, PR_TRUE, keysToFlag.GetArray(), keysToFlag.GetSize(), nsnull);
                }
                break;
            }
            PRInt32 numNewMessages;
            GetNumNewMessages(PR_FALSE, &numNewMessages);
            SetNumNewMessages(numNewMessages - 1);

          }
        }
        rv = m_msgParser->GetAllHeaders(&headers, &headersSize);

        if (NS_SUCCEEDED(rv) && headers && !m_msgMovedByFilter)
        {
          if (m_filterList)
          {
            GetMoveCoalescer();  // not sure why we're doing this here.
            m_filterList->ApplyFiltersToHdr(nsMsgFilterType::InboxRule, newMsgHdr, this, mDatabase, 
                                            headers, headersSize, this, msgWindow, nsnull);
          }
        }
      }
    }
    // here we need to tweak flags from uid state..
    if (mDatabase && (!m_msgMovedByFilter || ShowDeletedMessages()))
    {
      mDatabase->AddNewHdrToDB(newMsgHdr, PR_TRUE);
      nsCOMPtr <nsIMsgFolderNotificationService> notifier = do_GetService(NS_MSGNOTIFICATIONSERVICE_CONTRACTID);
      if (notifier)
        notifier->NotifyItemAdded(newMsgHdr);    
      
    }
    m_msgParser->Clear(); // clear out parser, because it holds onto a msg hdr.
    m_msgParser->SetMailDB(nsnull); // tell it to let go of the db too.
    // I don't think we want to do this - it does bad things like set the size incorrectly.
//    m_msgParser->FinishHeader();
  }
    return NS_OK;
}

Here is the call graph for this function:

void nsIImapMessageSink::normalEndMsgWriteStream ( in nsMsgKey  uidOfMessage,
in boolean  markMsgRead,
in nsIImapUrl  imapUrl 
) [inherited]
void nsIImapMessageSink::NotifyMessageDeleted ( in string  onlineFolderName,
in boolean  deleteAllMsgs,
in string  msgIdString 
) [inherited]
void nsIImapMessageSink::NotifyMessageFlags ( in unsigned long  flags,
in nsMsgKey  messageKey 
) [inherited]
nsresult nsImapMailFolder::NotifyMessageFlagsFromHdr ( nsIMsgDBHdr dbHdr,
nsMsgKey  msgKey,
PRUint32  flags 
) [protected]

Definition at line 4517 of file nsImapMailFolder.cpp.

{
    mDatabase->MarkHdrRead(dbHdr, (flags & kImapMsgSeenFlag) != 0, nsnull);
    mDatabase->MarkHdrReplied(dbHdr, (flags & kImapMsgAnsweredFlag) != 0, nsnull);
    mDatabase->MarkHdrMarked(dbHdr, (flags & kImapMsgFlaggedFlag) != 0, nsnull);
    mDatabase->MarkImapDeleted(msgKey, (flags & kImapMsgDeletedFlag) != 0, nsnull);
    // this turns on labels, but it doesn't handle the case where the user
    // unlabels a message on one machine, and expects it to be unlabeled
    // on their other machines. If I turn that on, I'll be removing all the labels
    // that were assigned before we started storing them on the server, which will
    // make some people very unhappy.
    if (flags & kImapMsgLabelFlags)
      mDatabase->SetLabel(msgKey, (flags & kImapMsgLabelFlags) >> 9);
    else
    {
      PRUint32 supportedFlags;
      GetSupportedUserFlags(&supportedFlags);
      if (supportedFlags & kImapMsgLabelFlags)
        mDatabase->SetLabel(msgKey, 0);
    }
    if (flags & kImapMsgMDNSentFlag)
      mDatabase->MarkMDNSent(msgKey, PR_TRUE, nsnull);
  
    return NS_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function:

nsresult nsImapMailFolder::OnCopyCompleted ( nsISupports *  srcSupport,
nsresult  exitCode 
) [protected]

Definition at line 7644 of file nsImapMailFolder.cpp.

{
  m_copyState = nsnull;
  nsresult result;
  nsCOMPtr<nsIMsgCopyService> copyService = 
    do_GetService(NS_MSGCOPYSERVICE_CONTRACTID, &result);
  if (NS_SUCCEEDED(result))
    copyService->NotifyCompletion(srcSupport, this, rv);    
  return NS_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 4779 of file nsImapMailFolder.cpp.

{
  NS_PRECONDITION(aUrl, "sanity check - need to be be running non-null url");
  nsCOMPtr<nsIMsgMailNewsUrl> mailUrl = do_QueryInterface(aUrl);
  if (mailUrl)
  {
    PRBool updatingFolder;
    mailUrl->GetUpdatingFolder(&updatingFolder);
    m_updatingFolder = updatingFolder;
  }
  m_urlRunning = PR_TRUE;
  return NS_OK;
}

Here is the call graph for this function:

Definition at line 4794 of file nsImapMailFolder.cpp.

{
  nsresult rv = NS_OK;
  PRBool endedOfflineDownload = PR_FALSE;
  m_urlRunning = PR_FALSE;
  m_updatingFolder = PR_FALSE;
  if (m_downloadingFolderForOfflineUse)
  {
    ReleaseSemaphore(NS_STATIC_CAST(nsIMsgImapMailFolder*, this));
    m_downloadingFolderForOfflineUse = PR_FALSE;
    endedOfflineDownload = PR_TRUE;
    EndOfflineDownload();
  }
  nsCOMPtr<nsIMsgMailSession> session = 
           do_GetService(NS_MSGMAILSESSION_CONTRACTID, &rv);
  if (aUrl)
  {
    nsCOMPtr<nsIMsgWindow> msgWindow;
    nsCOMPtr<nsIMsgMailNewsUrl> mailUrl = do_QueryInterface(aUrl);
    nsCOMPtr<nsIImapUrl> imapUrl = do_QueryInterface(aUrl);
    PRBool folderOpen = PR_FALSE;
    if (mailUrl)
      mailUrl->GetMsgWindow(getter_AddRefs(msgWindow));
    if (session)
      session->IsFolderOpenInWindow(this, &folderOpen);
#ifdef DEBUG_bienvenu1
    nsXPIDLCString urlSpec;
    aUrl->GetSpec(getter_Copies(urlSpec));
   printf("stop running url %s\n", (const char *) urlSpec);
#endif

   if (imapUrl)
   {
        DisplayStatusMsg(imapUrl, NS_LITERAL_STRING("").get());
        nsImapAction imapAction = nsIImapUrl::nsImapTest;
        imapUrl->GetImapAction(&imapAction);
        if (imapAction == nsIImapUrl::nsImapMsgFetch || imapAction == nsIImapUrl::nsImapMsgDownloadForOffline)
        {
          ReleaseSemaphore(NS_STATIC_CAST(nsIMsgImapMailFolder*, this));
          SetNotifyDownloadedLines(PR_FALSE);
          if (!endedOfflineDownload)
            EndOfflineDownload();
        }

        switch(imapAction)
        {
        case nsIImapUrl::nsImapDeleteMsg:
        case nsIImapUrl::nsImapOnlineMove:
        case nsIImapUrl::nsImapOnlineCopy:
          if (NS_SUCCEEDED(aExitCode))
          {
              if (folderOpen)
                UpdateFolder(msgWindow);
              else
                UpdatePendingCounts();
          }
          if (m_copyState)
          {
            nsCOMPtr<nsIMsgFolder> srcFolder = do_QueryInterface(m_copyState->m_srcSupport, &rv);
            if (m_copyState->m_isMove && !m_copyState->m_isCrossServerOp)
            {
              if (NS_SUCCEEDED(aExitCode))
              {
                nsCOMPtr<nsIMsgDatabase> srcDB;
                if (srcFolder)
                    rv = srcFolder->GetMsgDatabase(msgWindow,
                        getter_AddRefs(srcDB));
                if (NS_SUCCEEDED(rv) && srcDB)
                {
                  nsRefPtr<nsImapMoveCopyMsgTxn> msgTxn;
                  nsMsgKeyArray srcKeyArray;
                  if (m_copyState->m_allowUndo)
                  {
                     rv = m_copyState->m_undoMsgTxn->QueryInterface(NS_GET_IID(nsImapMoveCopyMsgTxn), getter_AddRefs(msgTxn)); 
                     if (msgTxn)
                       msgTxn->GetSrcKeyArray(srcKeyArray);
                  }
                  else
                  {
                     nsCAutoString messageIds;
                     rv = BuildIdsAndKeyArray(m_copyState->m_messages, messageIds, srcKeyArray);
                     NS_ENSURE_SUCCESS(rv,rv);
                  }
                 
                  if (!ShowDeletedMessages())
                    srcDB->DeleteMessages(&srcKeyArray, nsnull);  
                  else
                    MarkMessagesImapDeleted(&srcKeyArray, PR_TRUE, srcDB);
                }
                srcFolder->EnableNotifications(allMessageCountNotifications, PR_TRUE, PR_TRUE/* dbBatching*/);
                // even if we're showing deleted messages, 
                // we still need to notify FE so it will show the imap deleted flag
                srcFolder->NotifyFolderEvent(mDeleteOrMoveMsgCompletedAtom);
                // is there a way to see that we think we have new msgs?
                nsCOMPtr<nsIPrefBranch> prefBranch(do_GetService(NS_PREFSERVICE_CONTRACTID, &rv));
                if (NS_SUCCEEDED(rv))
                {
                  PRBool showPreviewText;
                  prefBranch->GetBoolPref("mail.biff.alert.show_preview", &showPreviewText);
                  // if we're showing preview text, update ourselves if we got a new unread
                  // message copied so that we can download the new headers and have a chance
                  // to preview the msg bodies.
                  if (!folderOpen && showPreviewText && m_copyState->m_unreadCount > 0
                      && ! (mFlags & (MSG_FOLDER_FLAG_TRASH | MSG_FOLDER_FLAG_JUNK)))
                    UpdateFolder(msgWindow);
                }
              }
              else
              {
                srcFolder->EnableNotifications(allMessageCountNotifications, PR_TRUE, PR_TRUE/* dbBatching*/);
                srcFolder->NotifyFolderEvent(mDeleteOrMoveMsgFailedAtom);  
              }
                
            }
            if (m_copyState->m_msgWindow && NS_SUCCEEDED(aExitCode)) //we should do this only if move/copy succeeds
            {
              nsCOMPtr<nsITransactionManager> txnMgr;
              m_copyState->m_msgWindow->GetTransactionManager(getter_AddRefs(txnMgr));
              if (txnMgr)
              {
                nsresult rv2 = txnMgr->DoTransaction(m_copyState->m_undoMsgTxn);
                NS_ASSERTION(NS_SUCCEEDED(rv2), "doing transaction failed");
              }
            }
             (void) OnCopyCompleted(m_copyState->m_srcSupport, aExitCode);
          }
          // we're the dest folder of a move/copy - if we're not open in the ui,
          // then we should clear our nsMsgDatabase pointer. Otherwise, the db would
          // be open until the user selected it and then selected another folder.
          // but don't do this for the trash or inbox - we'll leave them open
          if (!folderOpen && ! (mFlags & (MSG_FOLDER_FLAG_TRASH | MSG_FOLDER_FLAG_INBOX)))
            SetMsgDatabase(nsnull);
          break;
        case nsIImapUrl::nsImapSubtractMsgFlags:
          {
          // this isn't really right - we'd like to know we were 
          // deleting a message to start with, but it probably
          // won't do any harm.
            imapMessageFlagsType flags = 0;
            imapUrl->GetMsgFlags(&flags);
            //we need to subtract the delete flag in db only in case when we show deleted msgs
            if (flags & kImapMsgDeletedFlag && ShowDeletedMessages())
            {
              nsCOMPtr<nsIMsgDatabase> db;
              rv = GetMsgDatabase(nsnull, getter_AddRefs(db));
              if (NS_SUCCEEDED(rv) && db)
              {
                nsMsgKeyArray keyArray;
                char *keyString;
                imapUrl->CreateListOfMessageIdsString(&keyString);
                if (keyString)
                {
                  ParseUidString(keyString, keyArray);
                  MarkMessagesImapDeleted(&keyArray, PR_FALSE, db);
                  db->Commit(nsMsgDBCommitType::kLargeCommit);
                  nsCRT::free(keyString);
                }
              }
            }
          }
          break;
        case nsIImapUrl::nsImapAddMsgFlags:
          {
            imapMessageFlagsType flags = 0;
            imapUrl->GetMsgFlags(&flags);
            if (flags & kImapMsgDeletedFlag)
            {
              // we need to delete headers from db only when we don't show deleted msgs
              if (!ShowDeletedMessages()) 
              {
                nsCOMPtr<nsIMsgDatabase> db;
                rv = GetMsgDatabase(nsnull, getter_AddRefs(db));
                if (NS_SUCCEEDED(rv) && db)
                {
                  nsMsgKeyArray keyArray;
                  char *keyString = nsnull;
                  imapUrl->CreateListOfMessageIdsString(&keyString);
                  if (keyString)
                  {
                    ParseUidString(keyString, keyArray);
                    db->DeleteMessages(&keyArray, nsnull);
                    db->SetSummaryValid(PR_TRUE);
                    db->Commit(nsMsgDBCommitType::kLargeCommit);
                    nsCRT::free(keyString);
                  }
                }
              }
              // see bug #188051
              // only send the folder event only if we are deleting
              // (and not for other flag changes)
              NotifyFolderEvent(mDeleteOrMoveMsgCompletedAtom);
            }
          }
          break;
        case nsIImapUrl::nsImapAppendMsgFromFile:
        case nsIImapUrl::nsImapAppendDraftFromFile:
            if (m_copyState)
            {
              if (NS_SUCCEEDED(aExitCode))
              {
                UpdatePendingCounts();

                m_copyState->m_curIndex++;
                if (m_copyState->m_curIndex >= m_copyState->m_totalCount)
                {
                  if (folderOpen)
                  {
                    // This gives a way for the caller to get notified 
                    // when the UpdateFolder url is done.
                    nsCOMPtr <nsIUrlListener> saveUrlListener = m_urlListener;
                    if (m_copyState->m_listener)
                      m_urlListener = do_QueryInterface(m_copyState->m_listener);

                    UpdateFolder(msgWindow);
                    m_urlListener = saveUrlListener;
                  }
                  if (m_copyState->m_msgWindow && m_copyState->m_undoMsgTxn)
                  {
                    nsCOMPtr<nsITransactionManager> txnMgr;
                    m_copyState->m_msgWindow->GetTransactionManager(getter_AddRefs(txnMgr));
                    if (txnMgr)
                      txnMgr->DoTransaction(m_copyState->m_undoMsgTxn);
                  }
                  (void) OnCopyCompleted(m_copyState->m_srcSupport, aExitCode);
                }
              }
              else
                //clear the copyState if copy has failed
                (void) OnCopyCompleted(m_copyState->m_srcSupport, aExitCode);              
            }
            break;
        case nsIImapUrl::nsImapRenameFolder:
          if (NS_FAILED(aExitCode))
          {
            nsCOMPtr <nsIAtom> folderRenameAtom;
            folderRenameAtom = do_GetAtom("RenameCompleted");
            NotifyFolderEvent(folderRenameAtom);
          }
          break;
        case nsIImapUrl::nsImapDeleteAllMsgs:
            if (NS_SUCCEEDED(aExitCode))
            {
              if (folderOpen)
                UpdateFolder(msgWindow);
              else
              {
                ChangeNumPendingTotalMessages(-mNumPendingTotalMessages);
                ChangeNumPendingUnread(-mNumPendingUnreadMessages);
                m_numStatusUnseenMessages = 0;
              }

            }
            break;
        case nsIImapUrl::nsImapListFolder:
            // check if folder is now verified - if not,
            // we should remove it?
            if (NS_SUCCEEDED(aExitCode) && !m_verifiedAsOnlineFolder)
            {
              nsCOMPtr<nsIMsgFolder> parent;
              rv = GetParent(getter_AddRefs(parent));

              if (NS_SUCCEEDED(rv) && parent)
              {
                nsCOMPtr<nsIMsgImapMailFolder> imapParent = do_QueryInterface(parent);
                if (imapParent)
                  imapParent->RemoveSubFolder(this);
              }
            }
          break;
        case nsIImapUrl::nsImapRefreshFolderUrls:
          // we finished getting an admin url for the folder.
            if (!m_adminUrl.IsEmpty())
              FolderPrivileges(msgWindow);
            break;
        case nsIImapUrl::nsImapCreateFolder:
          if (NS_FAILED(aExitCode))  //if success notification already done
          {
            nsCOMPtr <nsIAtom> folderCreateAtom;
            folderCreateAtom = do_GetAtom("FolderCreateFailed");
            NotifyFolderEvent(folderCreateAtom);
          }
          break;
        case nsIImapUrl::nsImapSubscribe:
          if (NS_SUCCEEDED(aExitCode) && msgWindow)
          {
            nsXPIDLCString canonicalFolderName;
            imapUrl->CreateCanonicalSourceFolderPathString(getter_Copies(canonicalFolderName));
            nsCOMPtr <nsIMsgFolder> rootFolder;
            nsresult rv = GetRootFolder(getter_AddRefs(rootFolder));
            if(NS_SUCCEEDED(rv) && rootFolder)
            {
              nsCOMPtr <nsIMsgImapMailFolder> imapRoot = do_QueryInterface(rootFolder);
              if (imapRoot)
              {
                nsCOMPtr <nsIMsgImapMailFolder> foundFolder;
                rv = imapRoot->FindOnlineSubFolder(canonicalFolderName, getter_AddRefs(foundFolder));
                if (NS_SUCCEEDED(rv) && foundFolder)
                {
                  nsXPIDLCString uri;
                  nsCOMPtr <nsIMsgFolder> msgFolder = do_QueryInterface(foundFolder);
                  if (msgFolder)
                  {
                    msgFolder->GetURI(getter_Copies(uri));
                    msgWindow->SelectFolder(uri.get());
                  }
                }
              }
            }
          }
          break;
        default:
            break;
        }
    }
    // give base class a chance to send folder loaded notification...
    rv = nsMsgDBFolder::OnStopRunningUrl(aUrl, aExitCode);
    // query it for a mailnews interface for now....
    if (mailUrl)
      rv = mailUrl->UnRegisterListener(this);

  }
  SetGettingNewMessages(PR_FALSE); // if we're not running a url, we must not be getting new mail :-)

  if (m_urlListener)
  {
    m_urlListener->OnStopRunningUrl(aUrl, aExitCode);
    m_urlListener = nsnull;
  }
  return rv;
}

Here is the call graph for this function:

nsresult nsImapMailFolder::ParseAdoptedHeaderLine ( const char *  messageLine,
PRUint32  msgKey 
) [protected]

Definition at line 2916 of file nsImapMailFolder.cpp.

{
  // we can get blocks that contain more than one line, 
  // but they never contain partial lines
  const char *str = aMessageLine;
  m_curMsgUid = aMsgKey;
  m_msgParser->SetEnvelopePos(m_curMsgUid);
  // m_envelope_pos, for local folders, 
  // is the msg key. Setting this will set the msg key for the new header.
  
  PRInt32 len = strlen(str);
  char *currentEOL  = PL_strstr(str, MSG_LINEBREAK);
  const char *currentLine = str;
  while (currentLine < (str + len))
  {
    if (currentEOL)
    {
      m_msgParser->ParseAFolderLine(currentLine, 
        (currentEOL + MSG_LINEBREAK_LEN) -
        currentLine);
      currentLine = currentEOL + MSG_LINEBREAK_LEN;
      currentEOL  = PL_strstr(currentLine, MSG_LINEBREAK);
    }
    else
    {
      m_msgParser->ParseAFolderLine(currentLine, PL_strlen(currentLine));
      currentLine = str + len + 1;
    }
  }
  return NS_OK;
}

Here is the call graph for this function:

void nsIImapMessageSink::ParseAdoptedMsgLine ( in string  adoptedMsgLine,
in nsMsgKey  uidOfMsg 
) [inherited]
void nsIImapMailFolderSink::parseMsgHdrs ( in nsIImapProtocol  aProtocol,
in nsIImapHeaderXferInfo  aHdrXferInfo 
) [inherited]
void nsIImapMailFolderSink::percentProgress ( in nsIImapProtocol  aProtocol,
in wstring  aMessage,
in long  aCurrentProgress,
in long  aMaxProgressProgressInfo 
) [inherited]

Definition at line 8306 of file nsImapMailFolder.cpp.

{
  if (m_moveCoalescer)
  {
    nsMsgKeyArray *junkKeysToClassify = m_moveCoalescer->GetKeyBucket(0);
    nsMsgKeyArray *nonJunkKeysToClassify = m_moveCoalescer->GetKeyBucket(1);

    if (junkKeysToClassify && junkKeysToClassify->GetSize() > 0)
      StoreCustomKeywords(m_moveCoalescer->GetMsgWindow(), "Junk", "", junkKeysToClassify->GetArray(), junkKeysToClassify->GetSize(), nsnull);
    if (nonJunkKeysToClassify && nonJunkKeysToClassify->GetSize() > 0)
      StoreCustomKeywords(m_moveCoalescer->GetMsgWindow(), "NonJunk", "", nonJunkKeysToClassify->GetArray(), nonJunkKeysToClassify->GetSize(), nsnull);
    junkKeysToClassify->RemoveAll();
    nonJunkKeysToClassify->RemoveAll();
    return m_moveCoalescer->PlaybackMoves(ShowPreviewText());
  }
  return NS_OK; // must not be any coalesced operations
}

Here is the call graph for this function:

void nsIMsgImapMailFolder::playbackOfflineFolderCreate ( in wstring  folderName,
in nsIMsgWindow  aWindow,
out nsIURI  url 
) [inherited]
void nsImapMailFolder::PrepareToAddHeadersToMailDB ( nsIImapProtocol aProtocol,
const nsMsgKeyArray &  keysToFetch,
nsIMailboxSpec boxSpec 
) [protected]

Definition at line 4045 of file nsImapMailFolder.cpp.

{
  PRUint32 *theKeys = (PRUint32 *) PR_Malloc( keysToFetch.GetSize() * sizeof(PRUint32) );
  if (theKeys)
  {
    PRUint32 total = keysToFetch.GetSize();
    
    for (PRUint32 keyIndex=0; keyIndex < total; keyIndex++)
      theKeys[keyIndex] = keysToFetch[keyIndex];
    
    // tell the imap thread which hdrs to download
    if (aProtocol)
    {
      aProtocol->NotifyHdrsToDownload(theKeys, total /*keysToFetch.GetSize() */);
      // now, tell it we don't need any bodies.
      aProtocol->NotifyBodysToDownload(nsnull, 0);
    }
  }
  else
  {
    if (aProtocol)
      aProtocol->NotifyHdrsToDownload(nsnull, 0);
  }
}

Here is the call graph for this function:

void nsIImapMailFolderSink::prepareToReleaseObject ( in nsISupports  aISupports) [inherited]
void nsIImapMailFolderSink::progressStatus ( in nsIImapProtocol  aProtocol,
in unsigned long  aMsgId,
in wstring  extraInfo 
) [inherited]

Definition at line 1937 of file nsImapMailFolder.cpp.

{
  nsresult rv = nsMsgDBFolder::ReadFromFolderCacheElem(element);
  PRInt32 hierarchyDelimiter = kOnlineHierarchySeparatorUnknown;
  nsXPIDLCString onlineName;

  element->GetInt32Property("boxFlags", &m_boxFlags);
  if (NS_SUCCEEDED(element->GetInt32Property("hierDelim", &hierarchyDelimiter)) 
      && hierarchyDelimiter != kOnlineHierarchySeparatorUnknown)
    m_hierarchyDelimiter = (PRUnichar) hierarchyDelimiter;
  rv = element->GetStringProperty("onlineName", getter_Copies(onlineName));
  if (NS_SUCCEEDED(rv) && (const char *) onlineName && strlen((const char *) onlineName))
    m_onlineFolderName.Assign(onlineName);

  m_aclFlags = -1; // init to invalid value.
  element->GetInt32Property("aclFlags", (PRInt32 *) &m_aclFlags);
#ifdef DEBUG_bienvenu
  if (!nsCRT::strcasecmp((const char *) onlineName, "Sent"))
    printf("loading folder cache elem for %s flags = %lx", (const char *) onlineName, mFlags);
  else if (!nsCRT::strcasecmp((const char *) onlineName, "INBOX"))
    printf("loading folder cache elem for %s flags = %lx", (const char *) onlineName, mFlags);
#endif
  return rv;
}

Here is the call graph for this function:

Definition at line 8622 of file nsImapMailFolder.cpp.

{
  nsresult rv = nsMsgDBFolder::RemoveKeywordsFromMessages(aMessages, aKeywords);
  if (NS_SUCCEEDED(rv))
  {
    nsCAutoString messageIds;
    nsMsgKeyArray keys;
    nsresult rv = BuildIdsAndKeyArray(aMessages, messageIds, keys);
    NS_ENSURE_SUCCESS(rv, rv);
    rv = StoreCustomKeywords(nsnull, nsnull, aKeywords, keys.GetArray(), keys.GetSize(), nsnull);
    if (mDatabase)
      mDatabase->Commit(nsMsgDBCommitType::kLargeCommit);
  }
  return rv;
}

Here is the call graph for this function:

Definition at line 1537 of file nsImapMailFolder.cpp.

{
    if (mFlags & MSG_FOLDER_FLAG_VIRTUAL)
      return nsMsgDBFolder::Rename(newName, msgWindow);
    nsresult rv = NS_ERROR_FAILURE;
    nsAutoString newNameStr(newName);
    if (newNameStr.FindChar(m_hierarchyDelimiter,0) != -1)
    {
      nsCOMPtr<nsIDocShell> docShell;
      if (msgWindow)
        msgWindow->GetRootDocShell(getter_AddRefs(docShell));
      if (docShell)
      {
        nsCOMPtr<nsIStringBundle> bundle;
        rv = IMAPGetStringBundle(getter_AddRefs(bundle));
        if (NS_SUCCEEDED(rv) && bundle)
        {
          const PRUnichar *formatStrings[] =
          {
             (const PRUnichar*) m_hierarchyDelimiter
          };
          nsXPIDLString alertString;
          rv = bundle->FormatStringFromID(IMAP_SPECIAL_CHAR,
                                        formatStrings, 1,
                                        getter_Copies(alertString));
          nsCOMPtr<nsIPrompt> dialog(do_GetInterface(docShell));
          if (dialog && alertString)
            dialog->Alert(nsnull, alertString);
        }
      }
      return NS_ERROR_FAILURE;
    }
    nsCOMPtr <nsIImapIncomingServer> incomingImapServer;

    GetImapIncomingServer(getter_AddRefs(incomingImapServer));
    if (incomingImapServer)
      RecursiveCloseActiveConnections(incomingImapServer);

    nsCOMPtr<nsIImapService> imapService = do_GetService(NS_IMAPSERVICE_CONTRACTID, &rv);
    NS_ENSURE_SUCCESS(rv,rv);

    return imapService->RenameLeaf(m_eventQueue, this, newName, this, msgWindow,
                                     nsnull);
}

Here is the call graph for this function:

void nsIMsgImapMailFolder::renameClient ( in nsIMsgWindow  msgWindow,
in nsIMsgFolder  msgFolder,
in string  oldName,
in string  newName 
) [inherited]
void nsIMsgImapMailFolder::renameLocal ( in string  newname,
in nsIMsgFolder  parent 
) [inherited]

Definition at line 8057 of file nsImapMailFolder.cpp.

{
  nsresult rv = NS_OK;
  m_initialized = PR_TRUE;
  nsCOMPtr<nsIEnumerator> aEnumerator;
  oldFolder->GetSubFolders(getter_AddRefs(aEnumerator));
  nsCOMPtr<nsISupports> aSupport;
  rv = aEnumerator->First();
  while (NS_SUCCEEDED(rv))
  {
     rv = aEnumerator->CurrentItem(getter_AddRefs(aSupport));
                     
     nsCOMPtr<nsIMsgFolder>msgFolder = do_QueryInterface(aSupport);
     nsCOMPtr<nsIMsgImapMailFolder> folder = do_QueryInterface(msgFolder, &rv);
     if (NS_FAILED(rv)) return rv;

     PRUnichar hierarchyDelimiter = '/';
     folder->GetHierarchyDelimiter(&hierarchyDelimiter);
                            
     PRInt32 boxflags;
     folder->GetBoxFlags(&boxflags);

     PRBool verified;
     folder->GetVerifiedAsOnlineFolder(&verified);
                            
     nsCOMPtr<nsIFileSpec> oldPathSpec;
     rv = msgFolder->GetPath(getter_AddRefs(oldPathSpec));
     if (NS_FAILED(rv)) return rv;

     nsFileSpec oldPath;
     rv = oldPathSpec->GetFileSpec(&oldPath);
     if (NS_FAILED(rv)) return rv;

     nsCOMPtr<nsIFileSpec> newParentPathSpec;
     rv = GetPath(getter_AddRefs(newParentPathSpec));
     if (NS_FAILED(rv)) return rv;

     nsFileSpec newParentPath;
     rv = newParentPathSpec->GetFileSpec(&newParentPath);
     if (NS_FAILED(rv)) return rv;

     rv = AddDirectorySeparator(newParentPath);
     newParentPath += oldPath.GetLeafName();
     nsCString newPathStr(newParentPath.GetNativePathCString());
     nsCOMPtr<nsIFileSpec> newPathSpec;
     rv = NS_NewFileSpec(getter_AddRefs(newPathSpec));
     if (NS_FAILED(rv)) return rv;
     rv = newPathSpec->SetNativePath(newPathStr.get());
                
     nsFileSpec newPath;
     rv = newPathSpec->GetFileSpec(&newPath);
     if (NS_FAILED(rv)) return rv;

     nsCOMPtr<nsIFileSpec> dbFileSpec;
     NS_NewFileSpecWithSpec(newPath, getter_AddRefs(dbFileSpec));

     nsCOMPtr<nsIMsgFolder> child;
                            
     nsXPIDLString folderName;
     rv = msgFolder->GetName(getter_Copies(folderName));
     if (folderName.IsEmpty() || NS_FAILED(rv)) return rv;

     nsXPIDLCString utf7LeafName;
     rv = CopyUTF16toMUTF7(folderName, utf7LeafName);
     NS_ENSURE_SUCCESS(rv, rv);

     // XXX : Fix this non-sense by fixing AddSubfolderWithPath
     nsAutoString unicodeLeafName;
     CopyASCIItoUTF16(utf7LeafName, unicodeLeafName);

     rv = AddSubfolderWithPath(unicodeLeafName, dbFileSpec, getter_AddRefs(child));
     
     if (!child || NS_FAILED(rv)) return rv;

     child->SetName(folderName);
     nsCOMPtr <nsIMsgImapMailFolder> imapFolder = do_QueryInterface(child);
     nsXPIDLCString onlineName;
     GetOnlineName(getter_Copies(onlineName));
     nsCAutoString onlineCName(onlineName);
     onlineCName.Append(char(hierarchyDelimiter));
     onlineCName.Append(utf7LeafName.get());
     if (imapFolder)
     {
       imapFolder->SetVerifiedAsOnlineFolder(verified);
       imapFolder->SetOnlineName(onlineCName.get());
       imapFolder->SetHierarchyDelimiter(hierarchyDelimiter);
       imapFolder->SetBoxFlags(boxflags);

       PRBool changed = PR_FALSE;
       msgFolder->MatchOrChangeFilterDestination(child, PR_FALSE /*caseInsensitive*/, &changed);
       if (changed)
         msgFolder->AlertFilterChanged(msgWindow);
       
       child->RenameSubFolders(msgWindow, msgFolder);
     }
     rv = aEnumerator->Next();

  }
  return rv;
}

Here is the call graph for this function:

void nsIMsgImapMailFolder::replayOfflineMoveCopy ( [array, size_is(numKeys)] in nsMsgKey  keys,
in unsigned long  numKeys,
in boolean  isMove,
in nsIMsgFolder  aDstFolder,
in nsIUrlListener  aUrlListener,
in nsIMsgWindow  aWindow 
) [inherited]
void nsIImapMailFolderSink::setCopyResponseUid ( in string  msgIdString,
in nsIImapUrl  aUrl 
) [inherited]

Definition at line 8225 of file nsImapMailFolder.cpp.

{
  m_filterList = aMsgFilterList;
  return nsMsgDBFolder::SetFilterList(aMsgFilterList);
}
void nsIImapMailFolderSink::setFolderQuotaData ( in ACString  aFolderQuotaRoot,
in unsigned long  aFolderQuotaUsedKB,
in unsigned long  aFolderQuotaMaxKB 
) [inherited]

Set FolderQuotaData information.

Parameters:
aFolderQuotaRootThe IMAP quota root for this folder, as returned by the GETQUOTAROOT IMAP command.
aFolderQuotaUsedKBUsed space, in KB, on this folder's quota root.
aFolderQuotaMaxKBSize, in KB, of this folder's quota root.
void nsImapMailFolder::SetIMAPDeletedFlag ( nsIMsgDatabase mailDB,
const nsMsgKeyArray &  msgids,
PRBool  markDeleted 
) [protected]

Definition at line 4682 of file nsImapMailFolder.cpp.

{
  nsresult markStatus = 0;
  PRUint32 total = msgids.GetSize();

  for (PRUint32 msgIndex=0; !markStatus && (msgIndex < total); msgIndex++)
  {
    markStatus = mailDB->MarkImapDeleted(msgids[msgIndex], markDeleted, nsnull);
  }
}

Here is the call graph for this function:

void nsIMsgImapMailFolder::setImapFlags ( in string  uids,
in long  flags,
out nsIURI  url 
) [inherited]

Definition at line 8325 of file nsImapMailFolder.cpp.

{
  NS_ENSURE_ARG(aMessages);

  nsresult rv = nsMsgDBFolder::SetJunkScoreForMessages(aMessages, aJunkScore);
  if (NS_SUCCEEDED(rv))
  {
    nsCAutoString messageIds;
    nsMsgKeyArray keys;
    nsresult rv = BuildIdsAndKeyArray(aMessages, messageIds, keys);
    NS_ENSURE_SUCCESS(rv, rv);
    StoreCustomKeywords(nsnull, (*aJunkScore == '0') ? "NonJunk" : "Junk", "", keys.GetArray(), 
      keys.GetSize(), nsnull);
    if (mDatabase)
      mDatabase->Commit(nsMsgDBCommitType::kLargeCommit);
  }
  return rv;
}

Here is the call graph for this function:

Definition at line 1877 of file nsImapMailFolder.cpp.

{
  NS_ENSURE_ARG(aMessages);

  nsresult rv = nsMsgDBFolder::SetLabelForMessages(aMessages, aLabel);
  if (NS_SUCCEEDED(rv))
  {
    nsCAutoString messageIds;
    nsMsgKeyArray keysToLabel;
    nsresult rv = BuildIdsAndKeyArray(aMessages, messageIds, keysToLabel);
    NS_ENSURE_SUCCESS(rv, rv);
    StoreImapFlags((aLabel << 9), PR_TRUE, keysToLabel.GetArray(), keysToLabel.GetSize(), nsnull);
    rv = GetDatabase(nsnull);
    if (NS_SUCCEEDED(rv))
      mDatabase->Commit(nsMsgDBCommitType::kLargeCommit);
  }
  return rv;
}

Here is the call graph for this function:

Definition at line 3782 of file nsImapMailFolder.cpp.

{
#ifdef DEBUG_bienvenu
  NS_ASSERTION(ns, "null namespace");
#endif
  m_namespace = ns;
}

Definition at line 6154 of file nsImapMailFolder.cpp.

{                                                                               
  nsMsgDBFolder::SetPath(aPathName);   // call base class so mPath will get set too
  if (!aPathName)
     return NS_ERROR_NULL_POINTER;

  // not sure why imap has m_pathName and doesn't just use mPath.
  if (!m_pathName)
  {
    m_pathName = new nsFileSpec("");
    if (! m_pathName)
      return NS_ERROR_OUT_OF_MEMORY;
  }
  return aPathName->GetFileSpec(m_pathName);                                  
}                                                                               

Here is the call graph for this function:

Definition at line 5695 of file nsImapMailFolder.cpp.

{
  nsCOMPtr<nsIDBFolderInfo> dbFolderInfo;
  nsresult rv = GetDatabase(nsnull);

  m_supportedUserFlags = userFlags;
  if (mDatabase)
  {
    rv = mDatabase->GetDBFolderInfo(getter_AddRefs(dbFolderInfo));
    if (NS_SUCCEEDED(rv) && dbFolderInfo)
      dbFolderInfo->SetUint32Property("imapFlags", userFlags);
  }


  return rv;
}

Here is the call graph for this function:

nsresult nsImapMailFolder::SetupHeaderParseStream ( PRUint32  size,
const char *  content_type,
nsIMailboxSpec boxSpec 
) [protected]

Definition at line 2895 of file nsImapMailFolder.cpp.

{
  if (!mDatabase)
    GetDatabase(nsnull);
  
  m_nextMessageByteLength = aSize;
  if (!m_msgParser)
    m_msgParser = do_CreateInstance(kParseMailMsgStateCID);
  else
    m_msgParser->Clear();
  
  if (m_msgParser)
  {
    m_msgParser->SetMailDB(mDatabase);
    return m_msgParser->SetState(nsIMsgParseMailMsgState::ParseHeadersState);
  }

  return NS_ERROR_OUT_OF_MEMORY;
}

Here is the call graph for this function:

void nsIImapMessageSink::SetupMsgWriteStream ( in string  aNativePath,
in boolean  appendDummyEnvelope 
) [inherited]
void nsIImapMailFolderSink::setUrlState ( in nsIImapProtocol  aProtocol,
in nsIMsgMailNewsUrl  aUrl,
in boolean  isRunning,
in nsresult  status 
) [inherited]

Definition at line 4603 of file nsImapMailFolder.cpp.

{
  nsresult err;
  nsCOMPtr<nsIImapHostSessionList> hostSession = 
      do_GetService(kCImapHostSessionList, &err);
  PRBool showDeleted = PR_FALSE;

  if (NS_SUCCEEDED(err) && hostSession)
  {
    nsXPIDLCString serverKey;
    GetServerKey(getter_Copies(serverKey));
    err = hostSession->GetShowDeletedMessagesForHost(serverKey, showDeleted);
  }
  // check for special folders that need to show deleted messages
  if (!showDeleted)
  {
    nsCOMPtr<nsIImapIncomingServer> imapServer;
    nsresult rv = GetImapIncomingServer(getter_AddRefs(imapServer));

    if (NS_SUCCEEDED(rv) && imapServer) 
    {
      // See if the redirector type has a different trash folder name (ie, not 'TRASH').
      // If so then convert it to the beautified name (if configured) and compare it 
      // against the current folder name.
      nsXPIDLCString specialTrashName;
      rv = imapServer->GetTrashFolderByRedirectorType(getter_Copies(specialTrashName));
      if (NS_SUCCEEDED(rv))
      {
        nsXPIDLString convertedName;
        rv = imapServer->ConvertFolderName(specialTrashName.get(), getter_Copies(convertedName));
        if (NS_SUCCEEDED(rv))
        {
          nsXPIDLString folderName;
          GetName(getter_Copies(folderName));
          if (StringBeginsWith(folderName, convertedName, nsCaseInsensitiveStringComparator()))
            showDeleted = PR_TRUE;
        }
      }
    }
  }
  return showDeleted;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 8296 of file nsImapMailFolder.cpp.

{
  PRBool showPreviewText = PR_FALSE;
  nsCOMPtr<nsIPrefBranch> prefBranch(do_GetService(NS_PREFSERVICE_CONTRACTID));
  if (prefBranch)
    prefBranch->GetBoolPref("mail.biff.alert.show_preview", &showPreviewText);
  return showPreviewText;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 2534 of file nsImapMailFolder.cpp.

{
  m_filterList = nsnull;
  m_initialized = PR_FALSE;
  // m_pathName is used to decide if folder pathname needs to be reconstructed in GetPath().
  delete m_pathName;
  m_pathName = nsnull; 
  NS_IF_RELEASE(m_moveCoalescer);
  return nsMsgDBFolder::Shutdown(shutdownChildren);
}
nsresult nsImapMailFolder::SpamFilterClassifyMessage ( const char *  aURI,
nsIMsgWindow aMsgWindow,
nsIJunkMailPlugin aJunkMailPlugin 
) [virtual]

Definition at line 8243 of file nsImapMailFolder.cpp.

{
  ++m_numFilterClassifyRequests;
  return aJunkMailPlugin->ClassifyMessage(aURI, aMsgWindow, this);   
}
nsresult nsImapMailFolder::SpamFilterClassifyMessages ( const char **  aURIArray,
PRUint32  aURICount,
nsIMsgWindow aMsgWindow,
nsIJunkMailPlugin aJunkMailPlugin 
) [virtual]

Definition at line 8251 of file nsImapMailFolder.cpp.

{
  m_numFilterClassifyRequests += aURICount;
  return aJunkMailPlugin->ClassifyMessages(aURICount, aURIArray, aMsgWindow, this);   
}
nsIURI nsIMsgImapMailFolder::storeCustomKeywords ( in nsIMsgWindow  aMsgWindow,
in string  aFlagsToAdd,
in string  aFlagsToSubtract,
[array, size_is(aNumKeys)] in nsMsgKey  aKeysToStore,
in unsigned long  aNumKeys 
) [inherited]
void nsIMsgImapMailFolder::storeImapFlags ( in long  aFlags,
in boolean  aAddFlags,
[array, size_is(aNumKeys)] in nsMsgKey  aKeysToFlag,
in unsigned long  aNumKeys,
in nsIUrlListener  aUrlListener 
) [inherited]

Definition at line 4467 of file nsImapMailFolder.cpp.

{
  nsresult rv = GetDatabase(nsnull); // we need a database for this
  NS_ENSURE_SUCCESS(rv, rv);
    // update all of the database flags
  PRInt32 messageIndex;
  PRUint32 messageSize;
  PRUint32 oldFolderSize = mFolderSize;
  // take this opportunity to recalculate the folder size:
  mFolderSize = 0;
  flagState->GetNumberOfMessages(&messageIndex);

  for (PRInt32 flagIndex=0; flagIndex < messageIndex; flagIndex++)
  {
    PRUint32 uidOfMessage;
    flagState->GetUidOfMessage(flagIndex, &uidOfMessage);
    imapMessageFlagsType flags;
    flagState->GetMessageFlags(flagIndex, &flags);
    nsCOMPtr<nsIMsgDBHdr> dbHdr;
    PRBool containsKey;
    rv = mDatabase->ContainsKey(uidOfMessage , &containsKey);
    // if we don't have the header, don't diddle the flags.
    // GetMsgHdrForKey will create the header if it doesn't exist.
    if (NS_FAILED(rv) || !containsKey)
      continue;

    rv = mDatabase->GetMsgHdrForKey(uidOfMessage, getter_AddRefs(dbHdr));
    if (NS_SUCCEEDED(dbHdr->GetMessageSize(&messageSize)))
      mFolderSize += messageSize;

    if (flags & kImapMsgCustomKeywordFlag)
    {
      nsXPIDLCString keywords;
      if (NS_SUCCEEDED(flagState->GetCustomFlags(uidOfMessage, getter_Copies(keywords))))
      {
        if (!keywords.IsEmpty() && dbHdr && NS_SUCCEEDED(rv))
        {
          HandleCustomFlags(uidOfMessage, dbHdr, keywords);
        }
      }
    }
    NotifyMessageFlagsFromHdr(dbHdr, uidOfMessage, flags);
  }
  if (oldFolderSize != mFolderSize)
    NotifyIntPropertyChanged(kFolderSizeAtom, oldFolderSize, mFolderSize);

  return NS_OK;
}

Here is the call graph for this function:

Definition at line 2325 of file nsImapMailFolder.cpp.

{
    nsCOMPtr<nsIMsgFolder> parent;
    nsCOMPtr<nsIMsgFolder> curFolder;
    nsresult rv;
    PRUint32 flags = 0;

    if (!folder) return PR_FALSE;
    curFolder = do_QueryInterface(folder, &rv);
    if (NS_FAILED(rv)) return PR_FALSE;

    do 
    {
        rv = curFolder->GetFlags(&flags);
        if (NS_FAILED(rv)) return PR_FALSE;
        if (flags & MSG_FOLDER_FLAG_TRASH)
            return PR_TRUE;
        rv = curFolder->GetParentMsgFolder(getter_AddRefs(parent));
        if (NS_FAILED(rv)) return PR_FALSE;
        curFolder = do_QueryInterface(parent, &rv);
    } while (NS_SUCCEEDED(rv) && curFolder);

    return PR_FALSE;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void nsImapMailFolder::TweakHeaderFlags ( nsIImapProtocol aProtocol,
nsIMsgDBHdr tweakMe 
) [protected]

Definition at line 4072 of file nsImapMailFolder.cpp.

{
  if (mDatabase && aProtocol && tweakMe)
  {
    tweakMe->SetMessageKey(m_curMsgUid);
    tweakMe->SetMessageSize(m_nextMessageByteLength);
    
    PRBool foundIt = PR_FALSE;
    imapMessageFlagsType imap_flags;

    nsXPIDLCString customFlags;
    nsresult res = aProtocol->GetFlagsForUID(m_curMsgUid, &foundIt, &imap_flags, getter_Copies(customFlags));
    if (NS_SUCCEEDED(res) && foundIt)
    {
      // make a mask and clear these message flags
      PRUint32 mask = MSG_FLAG_READ | MSG_FLAG_REPLIED | MSG_FLAG_MARKED | MSG_FLAG_IMAP_DELETED | MSG_FLAG_LABELS;
      PRUint32 dbHdrFlags;

      tweakMe->GetFlags(&dbHdrFlags);
      tweakMe->AndFlags(~mask, &dbHdrFlags);
      
      // set the new value for these flags
      PRUint32 newFlags = 0;
      if (imap_flags & kImapMsgSeenFlag)
        newFlags |= MSG_FLAG_READ;
      else // if (imap_flags & kImapMsgRecentFlag)
        newFlags |= MSG_FLAG_NEW;

      // Okay here is the MDN needed logic (if DNT header seen):
      /* if server support user defined flag:
          MDNSent flag set => clear kMDNNeeded flag
          MDNSent flag not set => do nothing, leave kMDNNeeded on
         else if 
          not MSG_FLAG_NEW => clear kMDNNeeded flag
          MSG_FLAG_NEW => do nothing, leave kMDNNeeded on
       */
      PRUint16 userFlags;
      res = aProtocol->GetSupportedUserFlags(&userFlags);
      if (NS_SUCCEEDED(res) && (userFlags & (kImapMsgSupportUserFlag |
                            kImapMsgSupportMDNSentFlag)))
      {
        if (imap_flags & kImapMsgMDNSentFlag)
        {
          newFlags |= MSG_FLAG_MDN_REPORT_SENT;
          if (dbHdrFlags & MSG_FLAG_MDN_REPORT_NEEDED)
            tweakMe->AndFlags(~MSG_FLAG_MDN_REPORT_NEEDED, &dbHdrFlags);
        }
      }

      if (imap_flags & kImapMsgAnsweredFlag)
        newFlags |= MSG_FLAG_REPLIED;
      if (imap_flags & kImapMsgFlaggedFlag)
        newFlags |= MSG_FLAG_MARKED;
      if (imap_flags & kImapMsgDeletedFlag)
        newFlags |= MSG_FLAG_IMAP_DELETED;
      if (imap_flags & kImapMsgForwardedFlag)
        newFlags |= MSG_FLAG_FORWARDED;

      // db label flags are 0x0E000000 and imap label flags are 0x0E00
      // so we need to shift 16 bits to the left to convert them.
      if (imap_flags & kImapMsgLabelFlags)
      {
        // we need to set label attribute on header because the dbview code 
        // does msgHdr->GetLabel when asked to paint a row
        tweakMe->SetLabel((imap_flags & kImapMsgLabelFlags) >> 9);
        newFlags |= (imap_flags & kImapMsgLabelFlags) << 16;
      }

      if (newFlags)
        tweakMe->OrFlags(newFlags, &dbHdrFlags);
      if (!customFlags.IsEmpty())
        (void) HandleCustomFlags(m_curMsgUid, tweakMe, customFlags);
    }
  }
}    

Here is the call graph for this function:

Here is the caller graph for this function: