Back to index

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

#include <nsLocalMailFolder.h>

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

List of all members.

Public Member Functions

 nsMsgLocalMailFolder (void)
virtual ~nsMsgLocalMailFolder (void)
NS_DECL_NSICOPYMESSAGELISTENER
NS_DECL_NSIMSGLOCALMAILFOLDER
NS_DECL_NSIJUNKMAILCLASSIFICATIONLISTENER
NS_DECL_ISUPPORTS_INHERITED
NS_IMETHOD 
Init (const char *aURI)
NS_IMETHOD Enumerate (nsIEnumerator **result)
NS_IMETHOD OnStartRunningUrl (nsIURI *aUrl)
NS_IMETHOD OnStopRunningUrl (nsIURI *aUrl, nsresult aExitCode)
NS_IMETHOD GetSubFolders (nsIEnumerator **result)
NS_IMETHOD GetMsgDatabase (nsIMsgWindow *aMsgWindow, nsIMsgDatabase **aMsgDatabase)
NS_IMETHOD OnAnnouncerGoingAway (nsIDBChangeAnnouncer *instigator)
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 &folderName, nsIMsgFolder **newFolder)
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 Delete ()
NS_IMETHOD DeleteSubFolders (nsISupportsArray *folders, nsIMsgWindow *msgWindow)
NS_IMETHOD CreateStorageIfMissing (nsIUrlListener *urlListener)
NS_IMETHOD Rename (const PRUnichar *aNewName, nsIMsgWindow *msgWindow)
NS_IMETHOD RenameSubFolders (nsIMsgWindow *msgWindow, nsIMsgFolder *oldFolder)
NS_IMETHOD GetPrettyName (PRUnichar **prettyName)
NS_IMETHOD SetPrettyName (const PRUnichar *aName)
NS_IMETHOD GetFolderURL (char **url)
NS_IMETHOD UpdateSummaryTotals (PRBool force)
NS_IMETHOD GetManyHeadersToDownload (PRBool *retval)
NS_IMETHOD GetDeletable (PRBool *deletable)
NS_IMETHOD GetRequiresCleanup (PRBool *requiresCleanup)
NS_IMETHOD GetSizeOnDisk (PRUint32 *size)
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 isMoveFolder, nsIMsgWindow *msgWindow, nsIMsgCopyServiceListener *listener)
NS_IMETHOD CopyFileMessage (nsIFileSpec *fileSpec, nsIMsgDBHdr *msgToReplace, PRBool isDraftOrTemplate, PRUint32 newMsgFlags, nsIMsgWindow *msgWindow, nsIMsgCopyServiceListener *listener)
NS_IMETHOD GetNewMessages (nsIMsgWindow *aWindow, nsIUrlListener *aListener)
NS_IMETHOD NotifyCompactCompleted ()
NS_IMETHOD Shutdown (PRBool shutdownChildren)
NS_IMETHOD WriteToFolderCacheElem (nsIMsgFolderCacheElement *element)
NS_IMETHOD ReadFromFolderCacheElem (nsIMsgFolderCacheElement *element)
NS_IMETHOD GetName (PRUnichar **aName)
NS_IMETHOD DownloadMessagesForOffline (nsISupportsArray *aMessages, nsIMsgWindow *aWindow)
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)
void setFlagsOnDefaultMailboxes (in unsigned long flags)
 set the default flags on the subfolders of this folder, such as Drafts, Templates, etc you should bitwise OR all the flags all mailboxes you want to flag, this function will be smart and find the right names.
nsIMsgDatabase getDatabaseWOReparse ()
nsIMsgDatabase getDatabaseWithReparse (in nsIUrlListener aReparseUrlListener, in nsIMsgWindow aMsgWindow)
void parseFolder (in nsIMsgWindow aMsgWindow, in nsIUrlListener listener)
void copyFolderLocal (in nsIMsgFolder srcFolder, in boolean isMove, in nsIMsgWindow msgWindow, in nsIMsgCopyServiceListener listener)
void copyAllSubFolders (in nsIMsgFolder srcFolder, in nsIMsgWindow msgWindow, in nsIMsgCopyServiceListener listener)
void onCopyCompleted (in nsISupports aSrcSupport, in boolean aMoveCopySucceeded)
void markMsgsOnPop3Server (in nsISupportsArray aMessages, in PRInt32 aMark)
void refreshSizeOnDisk ()
void addMessage (in string aMessage)
void deleteDownloadMsg (in nsIMsgDBHdr aMsgHdr, out boolean aDoSelect)
 functions for updating the UI while running DownloadMessagesForOffline: delete the old message before adding its newly downloaded body, and select the new message after it has replaced the old one
void selectDownloadMsg ()
void notifyDelete ()
void getFolderScanState (in nsLocalFolderScanState aState)
 functions for grubbing thru a folder to find the Uidl for a given msgDBHdr
void getUidlFromFolder (in nsLocalFolderScanState aState, in nsIMsgDBHdr aMsgHdr)
boolean warnIfLocalFileTooBig (in nsIMsgWindow aWindow)
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)
void onMessageClassified (in string aMsgURI, in nsMsgJunkStatus aClassification)

Public Attributes

attribute boolean checkForNewMessagesAfterParsing

Protected Member Functions

nsresult CopyFolderAcrossServer (nsIMsgFolder *srcFolder, nsIMsgWindow *msgWindow, nsIMsgCopyServiceListener *listener)
nsresult CreateSubFolders (nsFileSpec &path)
nsresult GetTrashFolder (nsIMsgFolder **trashFolder)
nsresult WriteStartOfNewMessage ()
nsresult IsChildOfTrash (PRBool *result)
nsresult RecursiveSetDeleteIsMoveTrash (PRBool bVal)
nsresult ConfirmFolderDeletion (nsIMsgWindow *aMsgWindow, PRBool *aResult)
nsresult DeleteMessage (nsISupports *message, nsIMsgWindow *msgWindow, PRBool deleteStorage, PRBool commit)
nsresult GetDatabase (nsIMsgWindow *msgWindow)
nsresult DisplayMoveCopyStatusMsg ()
nsresult SortMessagesBasedOnKey (nsISupportsArray *messages, nsMsgKeyArray *aKeyArray, nsIMsgFolder *srcFolder)
nsresult CopyMessageTo (nsISupports *message, nsIMsgFolder *dstFolder, nsIMsgWindow *msgWindow, PRBool isMove)
nsresult CopyMessagesTo (nsISupportsArray *messages, nsIMsgWindow *aMsgWindow, nsIMsgFolder *dstFolder, PRBool isMove)
virtual const char * GetIncomingServerType ()
nsresult InitCopyState (nsISupports *aSupport, nsISupportsArray *messages, PRBool isMove, nsIMsgCopyServiceListener *listener, nsIMsgWindow *msgWindow, PRBool isMoveFolder, PRBool allowUndo)
void CopyPropertiesToMsgHdr (nsIMsgDBHdr *destHdr, nsIMsgDBHdr *srcHdr)
virtual nsresult CreateBaseMessageURI (const char *aURI)
virtual nsresult SpamFilterClassifyMessage (const char *aURI, nsIMsgWindow *aMsgWindow, nsIJunkMailPlugin *aJunkMailPlugin)
virtual nsresult SpamFilterClassifyMessages (const char **aURIArray, PRUint32 aURICount, nsIMsgWindow *aMsgWindow, nsIJunkMailPlugin *aJunkMailPlugin)
nsresult ChangeKeywordForMessages (nsISupportsArray *aMessages, const char *aKeyword, PRBool add)
PRBool GetDeleteFromServerOnMove ()
nsresult setSubfolderFlag (const PRUnichar *aFolderName, PRUint32 flags)

Protected Attributes

nsLocalMailCopyStatemCopyState
const char * mType
PRPackedBool mHaveReadNameFromDB
PRPackedBool mInitialized
PRPackedBool mCheckForNewMessagesAfterParsing
PRPackedBool m_parsingFolder
nsCOMPtr< nsIMsgStringServicemMsgStringService
nsCOMPtr< nsIUrlListenermReparseListener
PRInt32 mNumFilterClassifyRequests
nsMsgKeyArray mSpamKeysToMove
nsCString mSpamFolderURI
nsCOMPtr< nsISupportsArraymDownloadMessages
nsCOMPtr< nsIMsgWindowmDownloadWindow
nsMsgKey mDownloadSelectKey
PRUint32 mDownloadState

Detailed Description

Definition at line 116 of file nsLocalMailFolder.h.


Constructor & Destructor Documentation

Definition at line 172 of file nsLocalMailFolder.cpp.

{
}

Member Function Documentation

Definition at line 4004 of file nsLocalMailFolder.cpp.

{
  return ChangeKeywordForMessages(aMessages, aKeywords, PR_TRUE /* add */);
}

Here is the call graph for this function:

void nsIMsgLocalMailFolder::addMessage ( in string  aMessage) [inherited]
NS_IMETHODIMP nsMsgLocalMailFolder::AddSubfolder ( const nsAString &  folderName,
nsIMsgFolder **  newFolder 
)

Definition at line 273 of file nsLocalMailFolder.cpp.

{
  nsresult rv = nsMsgDBFolder::AddSubfolder(name, child);
  NS_ENSURE_SUCCESS(rv, rv);
  nsCOMPtr <nsIFileSpec> path;
  // need to make sure folder exists...
  (*child)->GetPath(getter_AddRefs(path));
  if (path)
  {
    PRBool exists;
    rv = path->Exists(&exists);
    if (!exists) 
        rv = path->Touch();
  }
  return rv;
}

Here is the call graph for this function:

Here is the caller graph for this function:

nsresult nsMsgLocalMailFolder::ChangeKeywordForMessages ( nsISupportsArray aMessages,
const char *  aKeyword,
PRBool  add 
) [protected]

Definition at line 4008 of file nsLocalMailFolder.cpp.

{
  nsresult rv = (add) ? nsMsgDBFolder::AddKeywordsToMessages(aMessages, aKeywords)
                      : nsMsgDBFolder::RemoveKeywordsFromMessages(aMessages, aKeywords);

  if (NS_SUCCEEDED(rv))
  {
    rv = GetDatabase(nsnull);
    NS_ENSURE_SUCCESS(rv, rv);
    // this will fail if the folder is locked.
    rv = mDatabase->StartBatch();
    NS_ENSURE_SUCCESS(rv, rv);
    nsIOFileStream *fileStream;
    rv = mDatabase->GetFolderStream(&fileStream);
    NS_ENSURE_SUCCESS(rv, rv);
    PRUint32 count;
    NS_ENSURE_ARG(aMessages);
    nsresult rv = aMessages->Count(&count);
    NS_ENSURE_SUCCESS(rv, rv);
    nsXPIDLCString keywords;
    // for each message, we seek to the beginning of the x-mozilla-status header, and 
    // start reading lines, looking for x-mozilla-keys: headers; If we're adding
    // the keyword and we find
    // a header with the desired keyword already in it, we don't need to 
    // do anything. Likewise, if removing keyword and we don't find it,
    // we don't need to do anything. Otherwise, if adding, we need to 
    // see if there's an x-mozilla-keys
    // header with room for the new keyword. If so, we replace the 
    // corresponding number of spaces with the keyword. If no room,
    // we can't do anything until the folder is compacted and another
    // x-mozilla-keys header is added. In that case, we set a property
    // on the header, which the compaction code will check.

    // don't return out of the for loop - otherwise, we won't call EndBatch();
    for(PRUint32 i = 0; i < count; i++) // for each message
    {
      char lineBuff[500];

      nsCOMPtr<nsIMsgDBHdr> message = do_QueryElementAt(aMessages, i, &rv);
      NS_ENSURE_SUCCESS(rv, rv);
      PRUint32 messageOffset;
      message->GetMessageOffset(&messageOffset);
      PRUint32 statusOffset = 0;
      (void)message->GetStatusOffset(&statusOffset);
      PRUint32 desiredOffset = messageOffset + statusOffset;

      nsCStringArray keywordArray;
      keywordArray.ParseString(aKeywords, " ");
      for (PRInt32 j = 0; j < keywordArray.Count(); j++)
      {
        nsCAutoString header;
        nsCAutoString keywords;
        PRBool done = PR_FALSE;
        PRUint32 len = 0;
        nsCAutoString keywordToWrite(" ");

        keywordToWrite.Append(*(keywordArray[j]));
        fileStream->seek(PR_SEEK_SET, desiredOffset);
        PRBool inKeywordHeader = PR_FALSE;
        PRBool foundKeyword = PR_FALSE;
        PRUint32 offsetToAddKeyword = 0;
        message->GetMessageSize(&len);
        // loop through 
        while (!done)
        {
          lineBuff[0] = '\0';
          PRInt32 lineStartPos = fileStream->tell();
          // readLine won't return line termination chars.
          if (fileStream->readline(lineBuff, sizeof(lineBuff)))
          {
            if (EMPTY_MESSAGE_LINE(lineBuff))
              break; // passed headers; no x-mozilla-keywords header; give up.
            nsCString keywordHeaders;
            if (!strncmp(lineBuff, HEADER_X_MOZILLA_KEYWORDS, sizeof(HEADER_X_MOZILLA_KEYWORDS) - 1))
            {
              inKeywordHeader = PR_TRUE;
              keywordHeaders = lineBuff;
            }
            else if (inKeywordHeader && (lineBuff[0] == ' ' || lineBuff[0] == '\t'))
              keywordHeaders = lineBuff;
            else if (inKeywordHeader)
              break;
            else
              continue;

            PRInt32 keywordHdrLength = keywordHeaders.Length();
            nsACString::const_iterator start, end;
            nsACString::const_iterator keywordHdrStart;
            keywordHeaders.BeginReading(keywordHdrStart);
            // check if we have the keyword
            if (MsgFindKeyword(*(keywordArray[j]), keywordHeaders, start, end))
            {
              foundKeyword = PR_TRUE;
              if (!add) // if we're removing, remove it, and break;
              {
                PRInt32 keywordStartOffset = Distance(keywordHdrStart, start);
                keywordHeaders.Cut(keywordStartOffset, Distance(start, end));
                for (PRInt32 i = Distance(start, end); i > 0; i--)
                  keywordHeaders.Append(' ');
                fileStream->seek(PR_SEEK_SET, lineStartPos);
                fileStream->write(keywordHeaders.get(), keywordHeaders.Length());
              }
              offsetToAddKeyword = 0;
              // if adding and we already have the keyword, done
              done = PR_TRUE;
              break;
            }
            // argh, we need to check all the lines to see if we already have the
            // keyword, but if we don't find it, we want to remember the line and
            // position where we have room to add the keyword.
            if (add)
            {
              nsCAutoString curKeywordHdr(lineBuff);
              // strip off line ending spaces.
              curKeywordHdr.Trim(" ", PR_FALSE, PR_TRUE);
              if (!offsetToAddKeyword && curKeywordHdr.Length() + keywordToWrite.Length() < keywordHdrLength)
                offsetToAddKeyword = lineStartPos + curKeywordHdr.Length();
            }
          }
        }
        if (add && !foundKeyword)
        {
          if (!offsetToAddKeyword)
           message->SetUint32Property("growKeywords", 1);
          else
          {
            fileStream->seek(PR_SEEK_SET, offsetToAddKeyword);
            fileStream->write(keywordToWrite.get(), keywordToWrite.Length());
          }
        }
      }
    }
    mDatabase->EndBatch();
  }
  return rv;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 905 of file nsLocalMailFolder.cpp.

{
  nsresult rv;
  nsCOMPtr <nsIMsgFolderCompactor> folderCompactor =  do_CreateInstance(NS_MSGLOCALFOLDERCOMPACTOR_CONTRACTID, &rv);
  if (NS_SUCCEEDED(rv) && folderCompactor)
  {
    PRUint32 expungedBytes = 0;

    GetExpungedBytes(&expungedBytes);
    // check if we need to compact the folder

    if (expungedBytes > 0)
      rv = folderCompactor->Compact(this, PR_FALSE, aMsgWindow);
    else
      rv = NotifyCompactCompleted();
  }
  return rv;
}

Here is the call graph for this function:

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

Definition at line 857 of file nsLocalMailFolder.cpp.

{
  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));
      PRUint32 expungedBytes=0;
      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);
    
        expungedBytes=0;
        if (folder)
          rv = folder->GetExpungedBytes(&expungedBytes);
    
        NS_ENSURE_SUCCESS(rv,rv);
    
        if (expungedBytes > 0)
          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:

nsresult nsMsgLocalMailFolder::ConfirmFolderDeletion ( nsIMsgWindow aMsgWindow,
PRBool aResult 
) [protected]

Definition at line 1093 of file nsLocalMailFolder.cpp.

{
  NS_ENSURE_ARG(aResult);
  NS_ENSURE_ARG(aMsgWindow);
  nsCOMPtr<nsIDocShell> docShell;
  aMsgWindow->GetRootDocShell(getter_AddRefs(docShell));
  if (docShell)
  {
    PRBool confirmDeletion = PR_TRUE;
    nsresult rv;
    nsCOMPtr<nsIPrefBranch> pPrefBranch(do_GetService(NS_PREFSERVICE_CONTRACTID, &rv));
    if (pPrefBranch)
       pPrefBranch->GetBoolPref("mailnews.confirm.moveFoldersToTrash", &confirmDeletion);
    if (confirmDeletion)
    {
      if (!mMsgStringService)
        mMsgStringService = do_GetService(NS_MSG_POPSTRINGSERVICE_CONTRACTID);
      if (!mMsgStringService) 
        return NS_ERROR_FAILURE;
      nsXPIDLString alertString;
      mMsgStringService->GetStringByID(POP3_MOVE_FOLDER_TO_TRASH, getter_Copies(alertString));
      nsCOMPtr<nsIPrompt> dialog(do_GetInterface(docShell));
      if (dialog)
        dialog->Confirm(nsnull, alertString.get(), aResult);
    }
    else
      *aResult = PR_TRUE;
  }
  return NS_OK;
}

Here is the call graph for this function:

void nsICopyMessageListener::copyData ( in nsIInputStream  aIStream,
in long  aLength 
) [inherited]
NS_IMETHODIMP nsMsgLocalMailFolder::CopyFileMessage ( nsIFileSpec fileSpec,
nsIMsgDBHdr msgToReplace,
PRBool  isDraftOrTemplate,
PRUint32  newMsgFlags,
nsIMsgWindow msgWindow,
nsIMsgCopyServiceListener listener 
)

Definition at line 2194 of file nsLocalMailFolder.cpp.

{
  nsresult rv = NS_ERROR_NULL_POINTER;
  nsCOMPtr<nsIInputStream> inputStream;
  nsParseMailMessageState* parseMsgState = nsnull;
  PRUint32 fileSize = 0;
  nsCOMPtr<nsISupports> fileSupport(do_QueryInterface(fileSpec, &rv));

  nsCOMPtr<nsISupportsArray> messages;
  rv = NS_NewISupportsArray(getter_AddRefs(messages));
  
  if (msgToReplace)
  {
    nsCOMPtr<nsISupports> msgSupport(do_QueryInterface(msgToReplace, &rv));
    if (NS_SUCCEEDED(rv))
      messages->AppendElement(msgSupport);
  }

  rv = InitCopyState(fileSupport, messages, msgToReplace ? PR_TRUE:PR_FALSE,
                     listener, msgWindow, PR_FALSE, PR_FALSE);
  if (NS_FAILED(rv)) goto done;

  parseMsgState = new nsParseMailMessageState();
  if (parseMsgState)
  {
    nsCOMPtr<nsIMsgDatabase> msgDb;
    mCopyState->m_parseMsgState = do_QueryInterface(parseMsgState, &rv);
    GetDatabaseWOReparse(getter_AddRefs(msgDb));
    if (msgDb)
      parseMsgState->SetMailDB(msgDb);
  }

  rv = fileSpec->OpenStreamForReading();
  if (NS_FAILED(rv)) goto done;

  rv = fileSpec->GetInputStream(getter_AddRefs(inputStream));
  if (NS_FAILED(rv)) goto done;
  
  rv = NS_ERROR_NULL_POINTER;
  if (inputStream)
    rv = inputStream->Available(&fileSize);
  if (NS_FAILED(rv)) goto done;
  rv = BeginCopy(nsnull);
  if (NS_FAILED(rv)) goto done;
  rv = CopyData(inputStream, (PRInt32) fileSize);
  if (NS_FAILED(rv)) goto done;
  rv = EndCopy(PR_TRUE);
  if (NS_FAILED(rv)) goto done;

  if (msgToReplace && mDatabase)  //mDatabase should have been initialized above - if we got msgDb
    rv = DeleteMessage(msgToReplace, msgWindow, PR_TRUE, PR_TRUE);

done:
  if(NS_FAILED(rv))
    (void) OnCopyCompleted(fileSupport, PR_FALSE);

  fileSpec->CloseStream();
  return rv;
}

Here is the call graph for this function:

NS_IMETHODIMP nsMsgLocalMailFolder::CopyFolder ( nsIMsgFolder srcFolder,
PRBool  isMoveFolder,
nsIMsgWindow msgWindow,
nsIMsgCopyServiceListener listener 
)

Definition at line 1941 of file nsLocalMailFolder.cpp.

{
  nsresult rv;
  NS_ENSURE_ARG_POINTER(srcFolder);
  
  if (isMoveFolder)   // isMoveFolder == true when "this" and srcFolder are on same server
    rv = CopyFolderLocal(srcFolder, isMoveFolder, msgWindow, listener );
  else
    rv = CopyFolderAcrossServer(srcFolder, msgWindow, listener );
    
  return rv;
}

Here is the call graph for this function:

Definition at line 1856 of file nsLocalMailFolder.cpp.

{
  mInitialized = PR_TRUE;
    
  nsXPIDLString folderName;
  srcFolder->GetName(getter_Copies(folderName));
  
  nsresult rv = CreateSubfolder(folderName, msgWindow);
  if (NS_FAILED(rv)) return rv;

  nsCAutoString escapedFolderName;
  rv = NS_MsgEscapeEncodeURLPath(folderName, escapedFolderName);
  NS_ENSURE_SUCCESS(rv,rv);

  nsCOMPtr<nsIMsgFolder> newFolder;
  nsCOMPtr<nsIMsgFolder> newMsgFolder;

  rv = FindSubFolder(escapedFolderName, getter_AddRefs(newMsgFolder));
  NS_ENSURE_SUCCESS(rv,rv);
  
  nsCOMPtr<nsISimpleEnumerator> messages;
  rv = srcFolder->GetMessages(msgWindow, getter_AddRefs(messages));

  nsCOMPtr<nsISupportsArray> msgSupportsArray;
  NS_NewISupportsArray(getter_AddRefs(msgSupportsArray));

  PRBool hasMoreElements;
  nsCOMPtr<nsISupports> aSupport;

  if (messages)
    messages->HasMoreElements(&hasMoreElements);
  
  while (hasMoreElements && NS_SUCCEEDED(rv))
  {
    rv = messages->GetNext(getter_AddRefs(aSupport));
    rv = msgSupportsArray->AppendElement(aSupport);
    messages->HasMoreElements(&hasMoreElements);
  }
  
  PRUint32 numMsgs=0;
  msgSupportsArray->Count(&numMsgs);

  if (numMsgs > 0 )   //if only srcFolder has messages..
    newMsgFolder->CopyMessages(srcFolder, msgSupportsArray, PR_FALSE, msgWindow, listener, PR_TRUE /* is folder*/, PR_FALSE /* allowUndo */);
  else
  {
    nsCOMPtr <nsIMsgLocalMailFolder> localFolder = do_QueryInterface(newMsgFolder);
    if (localFolder)
    {
      // normally these would get called from ::EndCopy when the last message
      // was finished copying. But since there are no messages, we have to call
      // them explicitly.
      nsCOMPtr<nsISupports> srcSupports = do_QueryInterface(newMsgFolder);
      localFolder->CopyAllSubFolders(srcFolder, msgWindow, listener);
      return localFolder->OnCopyCompleted(srcSupports, PR_TRUE);
    }
  }     
  return NS_OK;  // otherwise the front-end will say Exception::CopyFolder
}

Here is the call graph for this function:

Here is the caller graph for this function:

void nsIMsgLocalMailFolder::copyFolderLocal ( in nsIMsgFolder  srcFolder,
in boolean  isMove,
in nsIMsgWindow  msgWindow,
in nsIMsgCopyServiceListener  listener 
) [inherited]
NS_IMETHODIMP nsMsgLocalMailFolder::CopyMessages ( nsIMsgFolder srcFolder,
nsISupportsArray messages,
PRBool  isMove,
nsIMsgWindow msgWindow,
nsIMsgCopyServiceListener listener,
PRBool  isFolder,
PRBool  allowUndo 
)

Definition at line 1698 of file nsLocalMailFolder.cpp.

{
  nsCOMPtr<nsISupports> srcSupport = do_QueryInterface(srcFolder);
  PRBool isServer;
  nsresult rv = GetIsServer(&isServer);
  if (NS_SUCCEEDED(rv) && isServer)
  {
    NS_ASSERTION(0, "Destination is the root folder. Cannot move/copy here");
    if (isMove)
      srcFolder->NotifyFolderEvent(mDeleteOrMoveMsgFailedAtom);
    return OnCopyCompleted(srcSupport, PR_FALSE);
  }
  
  PRBool mailboxTooLarge;

  (void) WarnIfLocalFileTooBig(msgWindow, &mailboxTooLarge);
  if (mailboxTooLarge)
  {
    if (isMove)
      srcFolder->NotifyFolderEvent(mDeleteOrMoveMsgFailedAtom);
    return OnCopyCompleted(srcSupport, PR_FALSE);
  }

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

  nsXPIDLCString uri;
  rv = srcFolder->GetURI(getter_Copies(uri));
  nsCAutoString protocolType(uri);
  protocolType.SetLength(protocolType.FindChar(':'));
  
  if (WeAreOffline() && (protocolType.LowerCaseEqualsLiteral("imap") || protocolType.LowerCaseEqualsLiteral("news")))
  {
    PRUint32 numMessages = 0;
    messages->Count(&numMessages);
    for (PRUint32 i = 0; i < numMessages; i++)
    {
      nsCOMPtr<nsIMsgDBHdr> message;
      messages->QueryElementAt(i, NS_GET_IID(nsIMsgDBHdr),(void **)getter_AddRefs(message));
      if(NS_SUCCEEDED(rv) && message)
      {
        nsMsgKey key;
        PRBool hasMsgOffline = PR_FALSE;
        message->GetMessageKey(&key);
        srcFolder->HasMsgOffline(key, &hasMsgOffline);
        if (!hasMsgOffline)
        {
          if (isMove)
            srcFolder->NotifyFolderEvent(mDeleteOrMoveMsgFailedAtom);
          ThrowAlertMsg("cantMoveMsgWOBodyOffline", msgWindow);
          return OnCopyCompleted(srcSupport, PR_FALSE);
        }
      }
    }
  }
  
  // don't update the counts in the dest folder until it is all over
  EnableNotifications(allMessageCountNotifications, PR_FALSE, PR_FALSE /*dbBatching*/);  //dest folder doesn't need db batching
  
  rv = InitCopyState(srcSupport, messages, isMove, listener, msgWindow, isFolder, allowUndo);
  if (NS_FAILED(rv))
  {
    ThrowAlertMsg("operationFailedFolderBusy", msgWindow);
    (void) OnCopyCompleted(srcSupport, PR_FALSE);
    return rv;
  }

  if (!protocolType.LowerCaseEqualsLiteral("mailbox"))
  {
    mCopyState->m_dummyEnvelopeNeeded = PR_TRUE;
    nsParseMailMessageState* parseMsgState = new nsParseMailMessageState();
    if (parseMsgState)
    {
      nsCOMPtr<nsIMsgDatabase> msgDb;
      mCopyState->m_parseMsgState = do_QueryInterface(parseMsgState, &rv);
      GetDatabaseWOReparse(getter_AddRefs(msgDb));   
      if (msgDb)
        parseMsgState->SetMailDB(msgDb);
    }
  }
  
  // undo stuff
  if (allowUndo)    //no undo for folder move/copy or or move/copy from search window
  {
    nsLocalMoveCopyMsgTxn* msgTxn = nsnull;
    
    msgTxn = new nsLocalMoveCopyMsgTxn;
    
    if (msgTxn && NS_SUCCEEDED(msgTxn->Init(srcFolder, this, isMove)))
      rv = msgTxn->QueryInterface(NS_GET_IID(nsLocalMoveCopyMsgTxn),
                                  getter_AddRefs(mCopyState->m_undoMsgTxn));
    else
    {
      delete msgTxn;
      rv = NS_ERROR_OUT_OF_MEMORY;
    }
    if (NS_FAILED(rv))
    {
      (void) OnCopyCompleted(srcSupport, PR_FALSE);
    }
    else
    {
      msgTxn->SetMsgWindow(msgWindow);
      if (isMove)
      {
        if (mFlags & MSG_FOLDER_FLAG_TRASH)
          msgTxn->SetTransactionType(nsIMessenger::eDeleteMsg);
        else
          msgTxn->SetTransactionType(nsIMessenger::eMoveMsg);
      }
      else
      {
        msgTxn->SetTransactionType(nsIMessenger::eCopyMsg);
      }
    }
  }
  PRUint32 numMsgs = 0;
  mCopyState->m_messages->Count(&numMsgs);
  if (numMsgs > 1 && ((protocolType.LowerCaseEqualsLiteral("imap") && !WeAreOffline()) || protocolType.LowerCaseEqualsLiteral("mailbox")))
  {
    mCopyState->m_copyingMultipleMessages = PR_TRUE;
    rv = CopyMessagesTo(mCopyState->m_messages, msgWindow, this, isMove);
    if (NS_FAILED(rv))
    {
      NS_ERROR("copy message failed");
      (void) OnCopyCompleted(srcSupport, PR_FALSE);
    }
  }
  else
  {
    nsCOMPtr<nsISupports> msgSupport;
    msgSupport = getter_AddRefs(mCopyState->m_messages->ElementAt(0));
    if (msgSupport)
    {
      rv = CopyMessageTo(msgSupport, this, msgWindow, isMove);
      if (NS_FAILED(rv))
      {
        NS_ASSERTION(PR_FALSE, "copy message failed");
        (void) OnCopyCompleted(srcSupport, PR_FALSE);
      }
    }
  }
  // if this failed immediately, need to turn back on notifications and inform FE.
  if (NS_FAILED(rv))
  {
    if (isMove)
      srcFolder->NotifyFolderEvent(mDeleteOrMoveMsgFailedAtom);
    EnableNotifications(allMessageCountNotifications, PR_TRUE, PR_FALSE /*dbBatching*/);  //dest folder doesn't need db batching
  }
  return rv;
}

Here is the call graph for this function:

nsresult nsMsgLocalMailFolder::CopyMessagesTo ( nsISupportsArray messages,
nsIMsgWindow aMsgWindow,
nsIMsgFolder dstFolder,
PRBool  isMove 
) [protected]

Definition at line 2957 of file nsLocalMailFolder.cpp.

{
  if (!mCopyState) return NS_ERROR_OUT_OF_MEMORY;
   
  nsresult rv;

  nsCOMPtr<nsICopyMessageStreamListener> copyStreamListener = do_CreateInstance(NS_COPYMESSAGESTREAMLISTENER_CONTRACTID, &rv);
  NS_ENSURE_SUCCESS(rv,rv);
  
  nsCOMPtr<nsICopyMessageListener> copyListener(do_QueryInterface(dstFolder));
  if(!copyListener)
    return NS_ERROR_NO_INTERFACE;
  
  nsCOMPtr<nsIMsgFolder> srcFolder(do_QueryInterface(mCopyState->m_srcSupport));
  if(!srcFolder)
    return NS_ERROR_NO_INTERFACE;
  
  rv = copyStreamListener->Init(srcFolder, copyListener, nsnull);
  if(NS_FAILED(rv))
    return rv;
  
  if (!mCopyState->m_messageService)
  {
    nsXPIDLCString uri;
    srcFolder->GetURI(getter_Copies(uri));
    rv = GetMessageServiceFromURI(uri, getter_AddRefs(mCopyState->m_messageService));
  }
  
  if (NS_SUCCEEDED(rv) && mCopyState->m_messageService)
  {
    nsMsgKeyArray keyArray;
    PRUint32 numMessages = 0;
    messages->Count(&numMessages);
    for (PRUint32 i = 0; i < numMessages; i++)
    {
      nsCOMPtr<nsIMsgDBHdr> aMessage = do_QueryElementAt(messages, i, &rv);
      if(NS_SUCCEEDED(rv) && aMessage)
      {
        nsMsgKey key;
        aMessage->GetMessageKey(&key);
        keyArray.Add(key);
      }
    }
    keyArray.QuickSort();
    rv = SortMessagesBasedOnKey(messages, &keyArray, srcFolder);
    NS_ENSURE_SUCCESS(rv,rv);
    
    nsCOMPtr<nsIStreamListener> streamListener(do_QueryInterface(copyStreamListener));
    if(!streamListener)
      return NS_ERROR_NO_INTERFACE;
    mCopyState->m_curCopyIndex = 0; 
    // we need to kick off the first message - subsequent messages
    // are kicked off by nsMailboxProtocol when it finishes a message
    // before starting the next message. Only do this if the source folder
    // is a local folder, however. IMAP will handle calling StartMessage for
    // each message that gets downloaded, and news doesn't go through here
    // because news only downloads one message at a time, and this routine
    // is for multiple message copy.
    nsCOMPtr <nsIMsgLocalMailFolder> srcLocalFolder = do_QueryInterface(srcFolder);
    if (srcLocalFolder)
      StartMessage();
    mCopyState->m_messageService->CopyMessages(&keyArray, srcFolder, streamListener, isMove,
      nsnull, aMsgWindow, nsnull);
  }
  
  return rv;
}

Here is the call graph for this function:

Here is the caller graph for this function:

nsresult nsMsgLocalMailFolder::CopyMessageTo ( nsISupports *  message,
nsIMsgFolder dstFolder,
nsIMsgWindow msgWindow,
PRBool  isMove 
) [protected]

Definition at line 3027 of file nsLocalMailFolder.cpp.

{
  if (!mCopyState) return NS_ERROR_OUT_OF_MEMORY;
  
  nsresult rv;
  nsCOMPtr<nsIMsgDBHdr> msgHdr(do_QueryInterface(message));
  if(!msgHdr)
    return NS_ERROR_FAILURE;
  
  mCopyState->m_message = do_QueryInterface(msgHdr, &rv);
  
  nsCOMPtr<nsIMsgFolder> srcFolder(do_QueryInterface(mCopyState->m_srcSupport));
  if(!srcFolder)
    return NS_ERROR_NO_INTERFACE;
  nsXPIDLCString uri;
  srcFolder->GetUriForMsg(msgHdr, getter_Copies(uri));
  
  nsCOMPtr<nsICopyMessageStreamListener> copyStreamListener = do_CreateInstance(NS_COPYMESSAGESTREAMLISTENER_CONTRACTID, &rv);
  NS_ENSURE_SUCCESS(rv,rv);
  
  nsCOMPtr<nsICopyMessageListener> copyListener(do_QueryInterface(dstFolder));
  if(!copyListener)
    return NS_ERROR_NO_INTERFACE;
  
  rv = copyStreamListener->Init(srcFolder, copyListener, nsnull);
  if(NS_FAILED(rv))
    return rv;
  
  if (!mCopyState->m_messageService)
  {
    rv = GetMessageServiceFromURI(uri, getter_AddRefs(mCopyState->m_messageService));
  }
  
  if (NS_SUCCEEDED(rv) && mCopyState->m_messageService)
  {
    nsCOMPtr<nsIStreamListener>
      streamListener(do_QueryInterface(copyStreamListener));
    if(!streamListener)
      return NS_ERROR_NO_INTERFACE;
    mCopyState->m_messageService->CopyMessage(uri, streamListener, isMove,
      nsnull, aMsgWindow, nsnull);
  }
  
  return rv;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void nsMsgLocalMailFolder::CopyPropertiesToMsgHdr ( nsIMsgDBHdr destHdr,
nsIMsgDBHdr srcHdr 
) [protected]

Definition at line 2541 of file nsLocalMailFolder.cpp.

{
  nsXPIDLCString sourceString;
  srcHdr->GetStringProperty("junkscore", getter_Copies(sourceString));
  destHdr->SetStringProperty("junkscore", sourceString);
  srcHdr->GetStringProperty("junkscoreorigin", getter_Copies(sourceString));
  destHdr->SetStringProperty("junkscoreorigin", sourceString);
  srcHdr->GetStringProperty("keywords", getter_Copies(sourceString));
  destHdr->SetStringProperty("keywords", sourceString);
  
  nsMsgLabelValue label = 0;
  srcHdr->GetLabel(&label);
  destHdr->SetLabel(label);
}

Here is the call graph for this function:

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

Definition at line 3377 of file nsLocalMailFolder.cpp.

{
  return nsCreateLocalBaseMessageURI(aURI, &mBaseMessageURI);
}

Here is the call graph for this function:

Definition at line 726 of file nsLocalMailFolder.cpp.

{
  nsresult rv = 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);
    
    nsCAutoString uri;
    
    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("@mozilla.org/rdf/rdf-service;1", &rv);
      NS_ENSURE_SUCCESS(rv,rv);
      
      nsCOMPtr<nsIRDFResource> resource;
      rv = rdf->GetResource(parentName, getter_AddRefs(resource));
      NS_ENSURE_SUCCESS(rv,rv);
      
      msgParent = do_QueryInterface(resource, &rv);
      NS_ENSURE_SUCCESS(rv,rv);
    }
  }
  
  if (msgParent)
  {
    nsXPIDLString folderName;
    GetName(getter_Copies(folderName));
    rv = msgParent->CreateSubfolder(folderName, nsnull);
  }
  return rv;
}

Here is the call graph for this function:

Definition at line 774 of file nsLocalMailFolder.cpp.

{
  nsresult rv = CheckIfFolderExists(folderName, this, msgWindow);
  if(NS_FAILED(rv))  //we already throw an alert - no need for an assertion
    return rv;
  
  nsFileSpec path;
  nsCOMPtr<nsIMsgFolder> child;
  //Get a directory based on our current path.
  rv = CreateDirectoryForFolder(path);
  if(NS_FAILED(rv))
    return rv;
  
  //Now we have a valid directory or we have returned.
  //Make sure the new folder name is valid
  nsAutoString safeFolderName(folderName);
  NS_MsgHashIfNecessary(safeFolderName);
  nsCAutoString nativeFolderName;
  rv = NS_CopyUnicodeToNative(safeFolderName, nativeFolderName);
  if (NS_FAILED(rv) || nativeFolderName.IsEmpty()) {
    ThrowAlertMsg("folderCreationFailed", msgWindow);
    // I'm returning this value so the dialog stays up
    return NS_MSG_FOLDER_EXISTS;
  }
  
  path += nativeFolderName.get();   
  if (path.Exists()) //check this because localized names are different from disk names
  {
    ThrowAlertMsg("folderExists", msgWindow);
    return NS_MSG_FOLDER_EXISTS;
  }
  
  nsOutputFileStream outputStream(path, PR_WRONLY | PR_CREATE_FILE, 00600); 
  if (outputStream.is_open())
  {
    outputStream.flush();
    outputStream.close();
  }
  
  //GetFlags and SetFlags in AddSubfolder will fail because we have no db at this point but mFlags is set.
  rv = AddSubfolder(safeFolderName, getter_AddRefs(child));
  if (!child || NS_FAILED(rv))
  {
    path.Delete(PR_FALSE);
    return rv;
  }
    
  // Create an empty database for this mail folder, set its name from the user  
  nsCOMPtr<nsIMsgDBService> msgDBService = do_GetService(NS_MSGDB_SERVICE_CONTRACTID, &rv);
  if (msgDBService)
  {
    nsCOMPtr<nsIMsgDatabase> unusedDB;
    rv = msgDBService->OpenFolderDB(child, PR_TRUE, PR_TRUE, getter_AddRefs(unusedDB));
    
    if ((NS_SUCCEEDED(rv) || rv == NS_MSG_ERROR_FOLDER_SUMMARY_MISSING 
      || rv == NS_MSG_ERROR_FOLDER_SUMMARY_OUT_OF_DATE) && unusedDB)
    {
      //need to set the folder name
      nsCOMPtr<nsIDBFolderInfo> folderInfo;
      rv = unusedDB->GetDBFolderInfo(getter_AddRefs(folderInfo));
      if(NS_SUCCEEDED(rv))
      {
        folderInfo->SetMailboxName(safeFolderName);
      }
      unusedDB->SetSummaryValid(PR_TRUE);
      unusedDB->Close(PR_TRUE);
    }
    else
    {
      path.Delete(PR_FALSE);
      rv = NS_MSG_CANT_CREATE_FOLDER;
    }
  }
  if(NS_SUCCEEDED(rv))
  {
    //we need to notify explicitly the flag change because it failed when we did AddSubfolder
    child->OnFlagChange(mFlags);
    child->SetPrettyName(folderName);  //because empty trash will create a new trash folder
    NotifyItemAdded(child);
  }
  return rv;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 242 of file nsLocalMailFolder.cpp.

{
  nsresult rv = NS_OK;
  nsAutoString currentFolderNameStr;
  nsCOMPtr<nsIMsgFolder> child;

  for (nsDirectoryIterator dir(path, PR_FALSE); dir.Exists(); dir++) 
  {
    nsFileSpec currentFolderPath = dir.Spec();

    char *leafName = currentFolderPath.GetLeafName();
    NS_CopyNativeToUnicode(nsDependentCString(leafName), currentFolderNameStr);
    PR_Free(leafName);

    // here we should handle the case where the current file is a .sbd directory w/o
    // a matching folder file, or a directory w/o the name .sbd
    if (nsShouldIgnoreFile(currentFolderNameStr))
      continue;

    rv = AddSubfolder(currentFolderNameStr, getter_AddRefs(child));  
    if (child)
    { 
      nsXPIDLString folderName;
      child->GetName(getter_Copies(folderName));  // try to get it from cache/db
      if (folderName.IsEmpty())
        child->SetPrettyName(currentFolderNameStr.get());
    }
  }
  return rv;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 1025 of file nsLocalMailFolder.cpp.

{
  nsresult rv;
  
  if(mDatabase)
  {
    mDatabase->ForceClosed();
    mDatabase = nsnull;
  }
  
  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;
  
  nsLocalFolderSummarySpec summarySpec(path);

  //Clean up .sbd folder if it exists.
  if(NS_SUCCEEDED(rv))
  {
    // Remove summary file.
    summarySpec.Delete(PR_FALSE);
      
    //Delete mailbox
    path.Delete(PR_FALSE);
      
    if (!path.IsDirectory())
      AddDirectorySeparator(path);
      
    //If this is a directory, then remove it.
    if (path.IsDirectory())
      path.Delete(PR_TRUE);
  }
  return rv;
}

Here is the call graph for this function:

void nsIMsgLocalMailFolder::deleteDownloadMsg ( in nsIMsgDBHdr  aMsgHdr,
out boolean  aDoSelect 
) [inherited]

functions for updating the UI while running DownloadMessagesForOffline: delete the old message before adding its newly downloaded body, and select the new message after it has replaced the old one

nsresult nsMsgLocalMailFolder::DeleteMessage ( nsISupports *  message,
nsIMsgWindow msgWindow,
PRBool  deleteStorage,
PRBool  commit 
) [protected]

Definition at line 2258 of file nsLocalMailFolder.cpp.

{
  nsresult rv = NS_OK;
  if (deleteStorage)
  {
    nsCOMPtr <nsIMsgDBHdr> msgDBHdr(do_QueryInterface(message, &rv));
    
    if(NS_SUCCEEDED(rv))
      rv = mDatabase->DeleteHeader(msgDBHdr, nsnull, commit, PR_TRUE);
  }
  return rv;
}

Here is the call graph for this function:

Here is the caller graph for this function:

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

Definition at line 1483 of file nsLocalMailFolder.cpp.

{
  NS_ENSURE_ARG_POINTER(messages);

  PRUint32 messageCount;
  nsresult rv = messages->Count(&messageCount);
  if (!messageCount)
    return rv;
    
  // shift delete case - (delete to trash is handled in EndMove)
  // this is also the case when applying retention settings.
  if (deleteStorage && !isMove)
  {
    MarkMsgsOnPop3Server(messages, POP3_DELETE);
    nsCOMPtr <nsIMsgFolderNotificationService> notifier = do_GetService(NS_MSGNOTIFICATIONSERVICE_CONTRACTID);
    if (notifier)
        notifier->NotifyItemDeleted(messages);    
  }
  
  PRBool isTrashFolder = mFlags & MSG_FOLDER_FLAG_TRASH;
  if (!deleteStorage && !isTrashFolder)
  {
      nsCOMPtr<nsIMsgFolder> trashFolder;
      rv = GetTrashFolder(getter_AddRefs(trashFolder));
      if (NS_SUCCEEDED(rv))
      {
          nsCOMPtr<nsIMsgCopyService> copyService = 
                   do_GetService(NS_MSGCOPYSERVICE_CONTRACTID, &rv);
          if (NS_SUCCEEDED(rv))
          {
            return copyService->CopyMessages(this, messages, trashFolder,
                                      PR_TRUE, listener, msgWindow, allowUndo);
          }
      }
      return rv;
  }
  else
  {   
      nsCOMPtr <nsIMsgDatabase> msgDB;
      rv = GetDatabaseWOReparse(getter_AddRefs(msgDB));
      if(NS_SUCCEEDED(rv))
      {
        if (deleteStorage && isMove && GetDeleteFromServerOnMove())
            MarkMsgsOnPop3Server(messages, POP3_DELETE);

        nsCOMPtr<nsISupports> msgSupport;
        rv = EnableNotifications(allMessageCountNotifications, PR_FALSE, PR_TRUE /*dbBatching*/);
        if (NS_SUCCEEDED(rv))
        {
          for(PRUint32 i = 0; i < messageCount; i++)
          {
            msgSupport = getter_AddRefs(messages->ElementAt(i));
            if (msgSupport)
              DeleteMessage(msgSupport, msgWindow, PR_TRUE, PR_FALSE);
          }
        }
        else if (rv == NS_MSG_FOLDER_BUSY)
          ThrowAlertMsg("deletingMsgsFailed", msgWindow);

        // we are the source folder here for a move or shift delete
        //enable notifications because that will close the file stream
        // we've been caching, mark the db as valid, and commit it.
        EnableNotifications(allMessageCountNotifications, PR_TRUE, PR_TRUE /*dbBatching*/);
        if(!isMove)
          NotifyFolderEvent(NS_SUCCEEDED(rv) ? mDeleteOrMoveMsgCompletedAtom : mDeleteOrMoveMsgFailedAtom);
        if (msgWindow && !isMove)
          AutoCompact(msgWindow);
      }
  }
  return rv;
}

Here is the call graph for this function:

Definition at line 1064 of file nsLocalMailFolder.cpp.

{
  nsresult rv = NS_ERROR_FAILURE;
  PRBool isChildOfTrash;
  rv = IsChildOfTrash(&isChildOfTrash);

  // we don't allow multiple folder selection so this is ok.
  nsCOMPtr<nsIMsgFolder> folder = do_QueryElementAt(folders, 0);
  PRUint32 folderFlags = 0;
  if (folder)
    folder->GetFlags(&folderFlags);
  // when deleting from trash, or virtual folder, just delete it.
  if (isChildOfTrash || folderFlags & MSG_FOLDER_FLAG_VIRTUAL)
    return nsMsgDBFolder::DeleteSubFolders(folders, msgWindow);

  if (!msgWindow) 
    return NS_ERROR_NULL_POINTER;
 
  nsCOMPtr<nsIMsgFolder> trashFolder;
  rv = GetTrashFolder(getter_AddRefs(trashFolder));
  if (NS_SUCCEEDED(rv))
  {
    if (folder)
      trashFolder->CopyFolder(folder, PR_TRUE, msgWindow, nsnull);
  }
  return rv;
}

Here is the call graph for this function:

Definition at line 3499 of file nsLocalMailFolder.cpp.

{
  nsresult rv = NS_OK;
  if (mCopyState)
  {
    if (!mCopyState->m_statusFeedback)
    {
      // get msgWindow from undo txn
      nsCOMPtr<nsIMsgWindow> msgWindow;
      nsresult rv;

      if (mCopyState->m_undoMsgTxn)
      {
        nsRefPtr<nsLocalMoveCopyMsgTxn> localUndoTxn;
        rv = mCopyState->m_undoMsgTxn->QueryInterface(NS_GET_IID(nsLocalMoveCopyMsgTxn), getter_AddRefs(localUndoTxn));
        if (NS_SUCCEEDED(rv))
          localUndoTxn->GetMsgWindow(getter_AddRefs(msgWindow));
      NS_ASSERTION(msgWindow, "no msg window");
      }
      if (!msgWindow)
        return NS_OK; // not a fatal error.
      msgWindow->GetStatusFeedback(getter_AddRefs(mCopyState->m_statusFeedback));
    }

    if (!mCopyState->m_stringBundle)
    {
      nsCOMPtr <nsIMsgStringService> stringService = do_GetService(NS_MSG_MAILBOXSTRINGSERVICE_CONTRACTID);

      rv = stringService->GetBundle(getter_AddRefs(mCopyState->m_stringBundle));

      NS_ASSERTION(NS_SUCCEEDED(rv), "GetBundle failed");
      NS_ENSURE_SUCCESS(rv, rv);
    }
    if (mCopyState->m_statusFeedback && mCopyState->m_stringBundle)
    {
      nsXPIDLString finalString;
      nsXPIDLString folderName;
      GetName(getter_Copies(folderName));
      PRInt32 statusMsgId = (mCopyState->m_isMove) ? MOVING_MSGS_STATUS : COPYING_MSGS_STATUS;
      nsAutoString numMsgSoFarString;
      numMsgSoFarString.AppendInt((mCopyState->m_copyingMultipleMessages) ? mCopyState->m_curCopyIndex : 1);

      nsAutoString totalMessagesString;
      totalMessagesString.AppendInt(mCopyState->m_totalMsgCount);

      const PRUnichar * stringArray[] = { numMsgSoFarString.get(), totalMessagesString.get(), folderName.get() };
      rv = mCopyState->m_stringBundle->FormatStringFromID(statusMsgId, stringArray, 3,
                                               getter_Copies(finalString));
      PRInt64 minIntervalBetweenProgress;
      PRInt64 nowMS = LL_ZERO;

      // only update status/progress every half second
      LL_I2L(minIntervalBetweenProgress, 500);
      PRInt64 diffSinceLastProgress;
      LL_I2L(nowMS, PR_IntervalToMilliseconds(PR_IntervalNow()));
      LL_SUB(diffSinceLastProgress, nowMS, mCopyState->m_lastProgressTime); // r = a - b
      LL_SUB(diffSinceLastProgress, diffSinceLastProgress, minIntervalBetweenProgress); // r = a - b
      if (!LL_GE_ZERO(diffSinceLastProgress) && mCopyState->m_curCopyIndex < mCopyState->m_totalMsgCount)
        return NS_OK;

      mCopyState->m_lastProgressTime = nowMS;
      mCopyState->m_statusFeedback->ShowStatusString(finalString);
      mCopyState->m_statusFeedback->ShowProgress(mCopyState->m_curCopyIndex * 100 / mCopyState->m_totalMsgCount);
    }
  }
  return rv;
}

Here is the call graph for this function:

Definition at line 3259 of file nsLocalMailFolder.cpp.

{
  if (mDownloadState != DOWNLOAD_STATE_NONE) 
    return NS_ERROR_FAILURE; // already has a download in progress

  // We're starting a download...
  mDownloadState = DOWNLOAD_STATE_INITED;

  MarkMsgsOnPop3Server(aMessages, POP3_FETCH_BODY);

  // Pull out all the PARTIAL messages into a new array
  PRUint32 srcCount;
  aMessages->Count(&srcCount);

  NS_NewISupportsArray(getter_AddRefs(mDownloadMessages));
  for (PRUint32 i = 0; i < srcCount; i++)
  {
    nsresult rv;
    nsCOMPtr<nsIMsgDBHdr> msgDBHdr (do_QueryElementAt(aMessages, i, &rv));
    if (msgDBHdr)
    {
      PRUint32 flags = 0;
      msgDBHdr->GetFlags(&flags);
      if (flags & MSG_FLAG_PARTIAL)
      {
        mDownloadMessages->AppendElement(msgDBHdr);
      }
    }
  }
  mDownloadWindow = aWindow;

  nsCOMPtr<nsIMsgIncomingServer> server;
  nsresult rv = GetServer(getter_AddRefs(server)); 
  if (NS_FAILED(rv)) return rv;
  if (!server) return NS_MSG_INVALID_OR_MISSING_SERVER;
  
  nsCOMPtr<nsILocalMailIncomingServer> localMailServer = do_QueryInterface(server);
  if (!localMailServer) 
      return NS_MSG_INVALID_OR_MISSING_SERVER;
  
  return localMailServer->GetNewMail(aWindow, this, this, nsnull); 
}

Here is the call graph for this function:

Definition at line 924 of file nsLocalMailFolder.cpp.

{
    nsresult rv;
    nsCOMPtr<nsIMsgFolder> trashFolder;
    rv = GetTrashFolder(getter_AddRefs(trashFolder));
    if (NS_SUCCEEDED(rv))
    {
        PRUint32 flags;
        nsXPIDLCString trashUri;
        trashFolder->GetURI(getter_Copies(trashUri));
        trashFolder->GetFlags(&flags);
        PRInt32 totalMessages = 0;
        rv = trashFolder->GetTotalMessages(PR_TRUE, &totalMessages);
                  
        if (totalMessages <= 0) 
        {
          nsCOMPtr<nsIEnumerator> aEnumerator;
          rv =trashFolder->GetSubFolders(getter_AddRefs(aEnumerator));
          NS_ENSURE_SUCCESS(rv,rv);
          rv = aEnumerator->First();    //will fail if no subfolders 
          if (NS_FAILED(rv)) return NS_OK;
        }
        nsCOMPtr<nsIMsgFolder> parentFolder;
        rv = trashFolder->GetParentMsgFolder(getter_AddRefs(parentFolder));
        if (NS_SUCCEEDED(rv) && parentFolder)
        {
          nsCOMPtr <nsIDBFolderInfo> transferInfo;
          trashFolder->GetDBTransferInfo(getter_AddRefs(transferInfo)); 

          trashFolder->SetParent(nsnull);
          parentFolder->PropagateDelete(trashFolder, PR_TRUE, msgWindow);
          parentFolder->CreateSubfolder(NS_LITERAL_STRING("Trash").get(),nsnull);
          nsCOMPtr<nsIMsgFolder> newTrashFolder;
          rv = GetTrashFolder(getter_AddRefs(newTrashFolder));
          if (NS_SUCCEEDED(rv) && newTrashFolder) 
          {
            nsCOMPtr <nsIMsgLocalMailFolder> localTrash = do_QueryInterface(newTrashFolder);
            newTrashFolder->SetDBTransferInfo(transferInfo);
            if (localTrash)
              localTrash->RefreshSizeOnDisk();
            // update the summary totals so the front end will
            // show the right thing for the new trash folder
            // see bug #161999
            nsCOMPtr<nsIDBFolderInfo> dbFolderInfo;
            nsCOMPtr<nsIMsgDatabase> db; 
            newTrashFolder->GetDBFolderInfoAndDB(getter_AddRefs(dbFolderInfo), getter_AddRefs(db));
            if (dbFolderInfo)
            {
              dbFolderInfo->SetNumUnreadMessages(0);
              dbFolderInfo->SetNumMessages(0);
            }
            newTrashFolder->UpdateSummaryTotals(PR_TRUE);
          }
        }
    }
    return rv;
}

Here is the call graph for this function:

void nsICopyMessageListener::endCopy ( in boolean  copySucceeded) [inherited]
void nsICopyMessageListener::endMove ( in boolean  moveSucceeded) [inherited]

Definition at line 359 of file nsLocalMailFolder.cpp.

{
#if 0
  nsresult rv; 

  // local mail folders contain both messages and folders:
  nsCOMPtr<nsIEnumerator> folders;
  nsCOMPtr<nsIEnumerator> messages;
  rv = GetSubFolders(getter_AddRefs(folders));
  if (NS_FAILED(rv)) return rv;
  rv = GetMessages(nsnull, getter_AddRefs(messages));
  if (NS_FAILED(rv)) return rv;
  return NS_NewConjoiningEnumerator(folders, messages, 
                                    (nsIBidirectionalEnumerator**)result);
#endif
  NS_ASSERTION(PR_FALSE, "isn't this obsolete?");
  return NS_ERROR_FAILURE;
}

Here is the call graph for this function:

NS_IMETHODIMP nsMsgLocalMailFolder::FetchMsgPreviewText ( nsMsgKey aKeysToFetch,
PRUint32  aNumKeys,
PRBool  aLocalOnly,
nsIUrlListener aUrlListener,
PRBool aAsyncResults 
)

Definition at line 3962 of file nsLocalMailFolder.cpp.

{
  NS_ENSURE_ARG_POINTER(aKeysToFetch);
  NS_ENSURE_ARG_POINTER(aAsyncResults);

  *aAsyncResults = PR_FALSE;
  nsXPIDLCString nativePath;
  mPath->GetNativePath(getter_Copies(nativePath));

  nsCOMPtr <nsILocalFile> localStore;
  nsCOMPtr <nsIInputStream> inputStream;

  nsresult rv = NS_NewNativeLocalFile(nativePath, PR_TRUE, getter_AddRefs(localStore));
  NS_ENSURE_SUCCESS(rv, rv);
  rv = NS_NewLocalFileInputStream(getter_AddRefs(inputStream), localStore);
  NS_ENSURE_SUCCESS(rv, rv);

  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;
    PRUint32 messageOffset;

    msgHdr->GetMessageOffset(&messageOffset);
    nsCOMPtr <nsISeekableStream> seekableStream = do_QueryInterface(inputStream);
    if (seekableStream)
      rv = seekableStream->Seek(nsISeekableStream::NS_SEEK_CUR, messageOffset);
    NS_ENSURE_SUCCESS(rv,rv);
    rv = GetMsgPreviewTextFromStream(msgHdr, inputStream);

  }
  return rv;
}

Here is the call graph for this function:

Definition at line 468 of file nsLocalMailFolder.cpp.

{
  nsCOMPtr <nsIMsgDatabase> msgDB;
  return GetDatabaseWOReparse(getter_AddRefs(msgDB));
}

Here is the call graph for this function:

Here is the caller graph for this function:

nsIMsgDatabase nsIMsgLocalMailFolder::getDatabaseWithReparse ( in nsIUrlListener  aReparseUrlListener,
in nsIMsgWindow  aMsgWindow 
) [inherited]

Definition at line 1308 of file nsLocalMailFolder.cpp.

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

  nsresult rv;
  if (mDatabase)
  {
    openErr = NS_OK;
  }
  else
  {
    nsCOMPtr<nsIMsgDBService> msgDBService = do_GetService(NS_MSGDB_SERVICE_CONTRACTID, &rv);
    if (msgDBService)
    {
      PRBool folderEmpty = PR_FALSE;
      nsCOMPtr <nsIFileSpec> fileSpec;
      rv = GetPath(getter_AddRefs(fileSpec));
      // check for case of trying to open db for 0 byte folder (i.e., new folder), 
      // and in that case, tell msg db to create a new db and set it valid after opening it.
      if (fileSpec)
      {
        PRUint32 mailboxSize;
        if (NS_SUCCEEDED(fileSpec->GetFileSize(&mailboxSize)))
          folderEmpty = !mailboxSize;
      }

      openErr = msgDBService->OpenFolderDB(this, folderEmpty, PR_FALSE, getter_AddRefs(mDatabase));
      if (folderEmpty)
      {
        if (openErr == NS_MSG_ERROR_FOLDER_SUMMARY_MISSING)
        {
          if (mDatabase)
            mDatabase->SetSummaryValid(PR_TRUE);
          openErr = NS_OK;
        }
        else if (NS_FAILED(openErr))
        {
          mDatabase = nsnull;
        }
      }
    }
  }

  *db = mDatabase;
  NS_IF_ADDREF(*db);
  if (NS_SUCCEEDED(openErr)&& *db)
    openErr = (*db)->GetDBFolderInfo(folderInfo);
  return openErr;
}

Here is the call graph for this function:

Definition at line 1403 of file nsLocalMailFolder.cpp.

{
  if(!deletable)
    return NS_ERROR_NULL_POINTER;

  PRBool isServer;
  GetIsServer(&isServer);
  // These are specified in the "Mail/News Windows" UI spe 
  if (isServer)
    *deletable = PR_FALSE;
  else if (mFlags & MSG_FOLDER_FLAG_INBOX || 
    mFlags & MSG_FOLDER_FLAG_DRAFTS || 
    mFlags & MSG_FOLDER_FLAG_TRASH ||
    mFlags & MSG_FOLDER_FLAG_TEMPLATES ||
    mFlags & MSG_FOLDER_FLAG_JUNK)
    *deletable = PR_FALSE;
  else *deletable =  PR_TRUE;

  return NS_OK;
}

Definition at line 2784 of file nsLocalMailFolder.cpp.

{
  PRBool deleteFromServerOnMove = PR_FALSE;
  if (!gGotGlobalPrefs)
  {
    nsCOMPtr<nsIPrefBranch> pPrefBranch(do_GetService(NS_PREFSERVICE_CONTRACTID));
    if (pPrefBranch)
    {
      pPrefBranch->GetBoolPref("mail.pop3.deleteFromServerOnMove", &gDeleteFromServerOnMove);
      gGotGlobalPrefs = PR_TRUE;
    }   
  }
  return gDeleteFromServerOnMove;
}

Here is the call graph for this function:

Here is the caller graph for this function:

functions for grubbing thru a folder to find the Uidl for a given msgDBHdr

Definition at line 699 of file nsLocalMailFolder.cpp.

{
  const char *urlScheme = "mailbox:";
  
  if(!url)
    return NS_ERROR_NULL_POINTER;
  
  nsresult rv;
  
  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;
  
  nsCAutoString tmpPath((nsFilePath)path);
  
  nsCAutoString urlStr(urlScheme);
  urlStr.Append(tmpPath);
  
  *url = ToNewCString(urlStr);
  return NS_OK;
  
}

Here is the call graph for this function:

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

Definition at line 3314 of file nsLocalMailFolder.cpp.

{
  nsresult rv;

  if (mType) return mType;

  nsCOMPtr<nsIURL> url = do_CreateInstance(NS_STANDARDURL_CONTRACTID, &rv);
  if (NS_FAILED(rv)) return "";

  rv = url->SetSpec(nsDependentCString(mURI));
  if (NS_FAILED(rv)) return "";

  nsCOMPtr<nsIMsgAccountManager> accountManager = 
           do_GetService(NS_MSGACCOUNTMANAGER_CONTRACTID, &rv);
  if (NS_FAILED(rv)) return "";

  nsCOMPtr<nsIMsgIncomingServer> server;

  // try "none" first
  url->SetScheme(NS_LITERAL_CSTRING("none"));
  rv = accountManager->FindServerByURI(url, PR_FALSE,
                                  getter_AddRefs(server));
  if (NS_SUCCEEDED(rv) && server) 
  {
    mType = "none";
    return mType;
  }

  // next try "pop3"
  url->SetScheme(NS_LITERAL_CSTRING("pop3"));
  rv = accountManager->FindServerByURI(url, PR_FALSE,
                                  getter_AddRefs(server));
  if (NS_SUCCEEDED(rv) && server) 
  {
    mType = "pop3";
    return mType;
  }

  // next try "rss"
  url->SetScheme(NS_LITERAL_CSTRING("rss"));
  rv = accountManager->FindServerByURI(url, PR_FALSE,
                                  getter_AddRefs(server));
  if (NS_SUCCEEDED(rv) && server) 
  {
    mType = "rss";
    return mType;
  }

#ifdef HAVE_MOVEMAIL
  // next try "movemail"
  url->SetScheme(NS_LITERAL_CSTRING("movemail"));
  rv = accountManager->FindServerByURI(url, PR_FALSE,
                                  getter_AddRefs(server));
  if (NS_SUCCEEDED(rv) && server) 
  {
    mType = "movemail";
    return mType;
  }
#endif /* HAVE_MOVEMAIL */

  return "";
}

Here is the call graph for this function:

Definition at line 291 of file nsLocalMailFolder.cpp.

{
  PRBool isLocked;
  // if the folder is locked, we're probably reparsing - let's build the
  // view when we've finished reparsing.
  GetLocked(&isLocked);
  if (isLocked)
  {
    *retval = PR_TRUE;
    return NS_OK;
  }
  else
  {
    return nsMsgDBFolder::GetManyHeadersToDownload(retval);
  }

}

Definition at line 688 of file nsLocalMailFolder.cpp.

{
  nsCOMPtr <nsIMsgDatabase> msgDB;
  nsresult rv = GetDatabaseWOReparse(getter_AddRefs(msgDB));

  if(NS_SUCCEEDED(rv))
    return msgDB->EnumerateMessages(result);
  return rv;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 351 of file nsLocalMailFolder.cpp.

{
  return GetDatabaseWOReparse(aMsgDatabase);
}

Definition at line 1301 of file nsLocalMailFolder.cpp.

{
  ReadDBFolderInfo(PR_FALSE);
  return nsMsgDBFolder::GetName(aName);
}

Here is the caller graph for this function:

Definition at line 2273 of file nsLocalMailFolder.cpp.

{
  nsCOMPtr<nsIMsgIncomingServer> server;
  nsresult rv = GetServer(getter_AddRefs(server)); 
  if (NS_FAILED(rv)) return rv;
  if (!server) return NS_MSG_INVALID_OR_MISSING_SERVER;
  
  nsCOMPtr<nsILocalMailIncomingServer> localMailServer = do_QueryInterface(server);
  if (!localMailServer) 
      return NS_MSG_INVALID_OR_MISSING_SERVER;
  
  // XXX todo, move all this into nsILocalMailIncomingServer's GetNewMail
  // so that we don't have to have RSS foo here.
  nsCOMPtr<nsIRssIncomingServer> rssServer = do_QueryInterface(server);
  if (rssServer)
  {
      return localMailServer->GetNewMail(aWindow, aListener, this, nsnull); 
  }
  
  nsCOMPtr<nsIMsgFolder> inbox;
  nsCOMPtr<nsIMsgFolder> rootFolder;
  rv = server->GetRootMsgFolder(getter_AddRefs(rootFolder));
  if(NS_SUCCEEDED(rv) && rootFolder)
  {
    PRUint32 numFolders;
    rv = rootFolder->GetFoldersWithFlag(MSG_FOLDER_FLAG_INBOX, 1, &numFolders, getter_AddRefs(inbox));
  }
  nsCOMPtr<nsIMsgLocalMailFolder> localInbox = do_QueryInterface(inbox, &rv);
  if (NS_SUCCEEDED(rv) && localInbox)
  {
    PRBool valid = PR_FALSE;
    nsCOMPtr <nsIMsgDatabase> db;
    // this will kick off a reparse if the db is out of date.
    rv = localInbox->GetDatabaseWithReparse(nsnull, aWindow, getter_AddRefs(db));
    if (NS_SUCCEEDED(rv) && db)
    {
      rv = db->GetSummaryValid(&valid);
      if (valid)
        rv = localMailServer->GetNewMail(aWindow, aListener, inbox, nsnull); 
      else
        rv = localInbox->SetCheckForNewMessagesAfterParsing(PR_TRUE);
    }
  }
  return rv;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 1282 of file nsLocalMailFolder.cpp.

{
  return nsMsgDBFolder::GetPrettyName(prettyName);
}

Definition at line 1424 of file nsLocalMailFolder.cpp.

{
#ifdef HAVE_PORT
  if (m_expungedBytes > 0)
  {
    PRInt32 purgeThreshhold = m_master->GetPrefs()->GetPurgeThreshhold();
    PRBool purgePrompt = m_master->GetPrefs()->GetPurgeThreshholdEnabled();
    return (purgePrompt && m_expungedBytes / 1000L > purgeThreshhold);
  }
  return PR_FALSE;
#endif
  return NS_OK;
}

Definition at line 1447 of file nsLocalMailFolder.cpp.

{
    NS_ENSURE_ARG_POINTER(aSize);
    nsresult rv = NS_OK;
    if (!mFolderSize)
    {
      nsCOMPtr <nsIFileSpec> fileSpec;
      rv = GetPath(getter_AddRefs(fileSpec));
      NS_ENSURE_SUCCESS(rv, rv);
      rv = fileSpec->GetFileSize(&mFolderSize);
    }
    *aSize = mFolderSize;
    return rv;
}

Here is the call graph for this function:

Definition at line 379 of file nsLocalMailFolder.cpp.

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

  if (!mInitialized) {
    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;
    
    if (!path.Exists())
      path.CreateDirectory();
    if (!path.IsDirectory())
      AddDirectorySeparator(path);
    
    mInitialized = PR_TRUE;      // need to set this flag here to avoid infinite recursion
    // 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);
      SetFlag(newFlags);

      PRBool createdDefaultMailboxes = PR_FALSE;
      nsCOMPtr<nsILocalMailIncomingServer> localMailServer;

      if (isServer) 
      {
          nsCOMPtr<nsIMsgIncomingServer> server;
          rv = GetServer(getter_AddRefs(server));
          if (NS_FAILED(rv)) return rv;
          if (!server) return NS_MSG_INVALID_OR_MISSING_SERVER;

          localMailServer = do_QueryInterface(server, &rv);
          if (NS_FAILED(rv)) return rv;
          if (!localMailServer) return NS_MSG_INVALID_OR_MISSING_SERVER;
          
          nsCOMPtr<nsIFileSpec> spec;
          rv = NS_NewFileSpecWithSpec(path, getter_AddRefs(spec));
          if (NS_FAILED(rv)) return rv;
          
          // first create the folders on disk (as empty files)
          rv = localMailServer->CreateDefaultMailboxes(spec);
          NS_ENSURE_SUCCESS(rv, rv);
          if (NS_FAILED(rv)) return rv;
          createdDefaultMailboxes = PR_TRUE;
      }

      // now, discover those folders
      rv = CreateSubFolders(path);
      if (NS_FAILED(rv)) return rv;

      // must happen after CreateSubFolders, or the folders won't exist.
      if (createdDefaultMailboxes && isServer) 
      {
        rv = localMailServer->SetFlagsOnDefaultMailboxes();
        if (NS_FAILED(rv)) return rv;
      }
      /*we need to create all the folders at start-up because if a folder having subfolders is
      closed then the datasource will not ask for subfolders. For IMAP logging onto the 
      server will create imap folders and for news we don't have any 2nd level newsgroup */

      PRUint32 cnt;
      rv = mSubFolders->Count(&cnt);
      if (NS_SUCCEEDED(rv))
      {
        nsCOMPtr<nsIEnumerator> enumerator;
        for (PRUint32 i=0; i< cnt;i++)
        {
          nsCOMPtr<nsIMsgFolder> folder = do_QueryElementAt(mSubFolders, i, &rv);
          if (folder && NS_SUCCEEDED(rv))
          {
            rv = folder->GetSubFolders(getter_AddRefs(enumerator));
            NS_ASSERTION(NS_SUCCEEDED(rv),"GetSubFolders failed");
          }
        }
      }
    }
    UpdateSummaryTotals(PR_FALSE);
  }
  rv = mSubFolders->Enumerate(result);
  return rv;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 1463 of file nsLocalMailFolder.cpp.

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

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 230 of file nsLocalMailFolder.cpp.

{
  nsresult rv;
  rv = nsMsgDBFolder::Init(aURI);
  if (NS_FAILED(rv)) return rv;

  // XXX - DEADCODE - we don't need to override this, do we?
  return rv;

}
nsresult nsMsgLocalMailFolder::InitCopyState ( nsISupports *  aSupport,
nsISupportsArray messages,
PRBool  isMove,
nsIMsgCopyServiceListener listener,
nsIMsgWindow msgWindow,
PRBool  isMoveFolder,
PRBool  allowUndo 
) [protected]

Definition at line 1559 of file nsLocalMailFolder.cpp.

{
  nsresult rv = NS_OK;
  nsFileSpec path;
  nsCOMPtr<nsIFileSpec> pathSpec;
  
  NS_ASSERTION(!mCopyState, "already copying a msg into this folder");
  if (mCopyState) 
    return NS_ERROR_FAILURE; // already has a  copy in progress
  
  // get mDatabase set, so we can use it to add new hdrs to this db.
  // calling GetDatabase will set mDatabase - we use the comptr
  // here to avoid doubling the refcnt on mDatabase. We don't care if this
  // fails - we just want to give it a chance. It will definitely fail in
  // nsLocalMailFolder::EndCopy because we will have written data to the folder
  // and changed its size.
  nsCOMPtr <nsIMsgDatabase> msgDB;
  GetDatabaseWOReparse(getter_AddRefs(msgDB));
  PRBool isLocked;
  
  GetLocked(&isLocked);
  if(!isLocked)
    AcquireSemaphore(NS_STATIC_CAST(nsIMsgLocalMailFolder*, this));
  else
    return NS_MSG_FOLDER_BUSY;
  
  rv = GetPath(getter_AddRefs(pathSpec));
  NS_ENSURE_SUCCESS(rv, rv);
  
  rv = pathSpec->GetFileSpec(&path);
  NS_ENSURE_SUCCESS(rv, rv);
  
  mCopyState = new nsLocalMailCopyState();
  if(!mCopyState)
    return NS_ERROR_OUT_OF_MEMORY;
  
  mCopyState->m_dataBuffer = (char*) PR_CALLOC(COPY_BUFFER_SIZE+1);
  if (!mCopyState->m_dataBuffer)
    return NS_ERROR_OUT_OF_MEMORY;
  
  mCopyState->m_dataBufferSize = COPY_BUFFER_SIZE;
  mCopyState->m_destDB = msgDB;
  
  //Before we continue we should verify that there is enough diskspace.
  //XXX How do we do this?
  mCopyState->m_fileStream = new nsOutputFileStream(path, PR_WRONLY |
    PR_CREATE_FILE);
  if(!mCopyState->m_fileStream)
    return NS_ERROR_OUT_OF_MEMORY;
  
  //The new key is the end of the file
  mCopyState->m_fileStream->seek(PR_SEEK_END, 0);
  mCopyState->m_srcSupport = do_QueryInterface(aSupport, &rv);
  NS_ENSURE_SUCCESS(rv, rv);
  mCopyState->m_messages = do_QueryInterface(messages, &rv);
  NS_ENSURE_SUCCESS(rv, rv);
  mCopyState->m_curCopyIndex = 0;
  mCopyState->m_isMove = isMove;
  mCopyState->m_isFolder = isFolder;
  mCopyState->m_allowUndo = allowUndo;
  mCopyState->m_msgWindow = msgWindow;
  rv = messages->Count(&mCopyState->m_totalMsgCount);
  if (listener)
    mCopyState->m_listener = do_QueryInterface(listener, &rv);
  mCopyState->m_copyingMultipleMessages = PR_FALSE;
  return rv;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 983 of file nsLocalMailFolder.cpp.

{
  nsresult rv = NS_ERROR_NULL_POINTER;
  PRBool isServer = PR_FALSE;
  PRUint32 parentFlags = 0;

  if (!result) return rv;
  *result = PR_FALSE;

  rv = GetIsServer(&isServer);
  if (NS_FAILED(rv) || isServer) return rv;

  rv= GetFlags(&parentFlags);  //this is the parent folder
  if (parentFlags & MSG_FOLDER_FLAG_TRASH) 
  {
      *result = PR_TRUE;
      return rv;
  }

  nsCOMPtr<nsIMsgFolder> parentFolder;
  nsCOMPtr<nsIMsgFolder> thisFolder;
  rv = QueryInterface(NS_GET_IID(nsIMsgFolder), (void **)
                      getter_AddRefs(thisFolder));

  while (!isServer && thisFolder) 
  {
    rv = thisFolder->GetParentMsgFolder(getter_AddRefs(parentFolder));
    if (NS_FAILED(rv)) return rv;
    rv = parentFolder->GetIsServer(&isServer);
    if (NS_FAILED(rv) || isServer) return rv;
    rv = parentFolder->GetFlags(&parentFlags);
    if (NS_FAILED(rv)) return rv;
    if (parentFlags & MSG_FOLDER_FLAG_TRASH) 
    {
      *result = PR_TRUE;
      return rv;
    }
    thisFolder = parentFolder;
  }
  return rv;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 3644 of file nsLocalMailFolder.cpp.

{
  mExpungedBytes = 0;
  m_newMsgs.RemoveAll(); // if compacted, m_newMsgs probably aren't valid.
  (void) RefreshSizeOnDisk();
  (void) CloseDBIfFolderNotOpen();
  nsCOMPtr <nsIAtom> compactCompletedAtom;
  compactCompletedAtom = do_GetAtom("CompactCompleted");
  NotifyFolderEvent(compactCompletedAtom);
  return NS_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 1632 of file nsLocalMailFolder.cpp.

void nsIMsgLocalMailFolder::onCopyCompleted ( in nsISupports  aSrcSupport,
in boolean  aMoveCopySucceeded 
) [inherited]

Definition at line 3383 of file nsLocalMailFolder.cpp.

{
  nsresult rv;
  nsCOMPtr<nsIPop3URL> popurl = do_QueryInterface(aUrl, &rv);
  if (NS_SUCCEEDED(rv))
  {
    nsCAutoString aSpec;
    aUrl->GetSpec(aSpec);
    if (strstr(aSpec.get(), "uidl="))
    {
      nsCOMPtr<nsIPop3Sink> popsink;
      rv = popurl->GetPop3Sink(getter_AddRefs(popsink));
      if (NS_SUCCEEDED(rv))
        popsink->SetBaseMessageUri(mBaseMessageURI);
    }
  }
  return nsMsgDBFolder::OnStartRunningUrl(aUrl);
}

Here is the call graph for this function:

Definition at line 3403 of file nsLocalMailFolder.cpp.

{
  // If we just finished a DownloadMessages call, reset...
  if (mDownloadState != DOWNLOAD_STATE_NONE)
  {
    mDownloadState = DOWNLOAD_STATE_NONE;
    mDownloadMessages = nsnull;
    mDownloadWindow = nsnull;
    return nsMsgDBFolder::OnStopRunningUrl(aUrl, aExitCode);
  }
  nsresult rv;
  if (NS_SUCCEEDED(aExitCode))
  {
    nsCOMPtr<nsIMsgMailSession> mailSession = do_GetService(NS_MSGMAILSESSION_CONTRACTID, &rv);
    if (NS_FAILED(rv)) return rv; 
    nsCOMPtr<nsIMsgWindow> msgWindow;
    rv = mailSession->GetTopmostMsgWindow(getter_AddRefs(msgWindow));
    nsCAutoString aSpec;
    aUrl->GetSpec(aSpec);
    
    if (strstr(aSpec.get(), "uidl="))
    {
      nsCOMPtr<nsIPop3URL> popurl = do_QueryInterface(aUrl, &rv);
      if (NS_SUCCEEDED(rv))
      {
        nsXPIDLCString messageuri;
        rv = popurl->GetMessageUri(getter_Copies(messageuri));
        if (NS_SUCCEEDED(rv))
        {
          nsCOMPtr<nsIRDFService> rdfService = 
                   do_GetService("@mozilla.org/rdf/rdf-service;1", &rv); 
          if(NS_SUCCEEDED(rv))
          {
            nsCOMPtr <nsIMsgDBHdr> msgDBHdr;
            rv = GetMsgDBHdrFromURI(messageuri, getter_AddRefs(msgDBHdr));
            if(NS_SUCCEEDED(rv))
                rv = mDatabase->DeleteHeader(msgDBHdr, nsnull, PR_TRUE,
                                             PR_TRUE);
            nsCOMPtr<nsIPop3Sink> pop3sink;
            nsXPIDLCString newMessageUri;
            rv = popurl->GetPop3Sink(getter_AddRefs(pop3sink));
            if (NS_SUCCEEDED(rv))
            {
              pop3sink->GetMessageUri(getter_Copies(newMessageUri));
              if(msgWindow)
              {
                msgWindow->SelectMessage(newMessageUri);
              }
            }
          }
        }
      }
    }
    
    if (mFlags & MSG_FOLDER_FLAG_INBOX)
    {
      if (mDatabase)
      {
        if (mCheckForNewMessagesAfterParsing)
        {
          PRBool valid;
          mDatabase->GetSummaryValid(&valid);
          if (valid)
          {
            if (msgWindow)
             rv = GetNewMessages(msgWindow, nsnull);
          }
          mCheckForNewMessagesAfterParsing = PR_FALSE;
        }
      }
    }
  }

  if (m_parsingFolder && mReparseListener)
  {
    nsCOMPtr<nsIUrlListener> saveReparseListener = mReparseListener;
    mReparseListener = nsnull;
    saveReparseListener->OnStopRunningUrl(aUrl, aExitCode);
  }
  if (mFlags & MSG_FOLDER_FLAG_INBOX)
  {
    // if we are the inbox and running pop url 
    nsCOMPtr<nsIPop3URL> popurl = do_QueryInterface(aUrl, &rv);
    if (NS_SUCCEEDED(rv))
    {
      nsCOMPtr<nsIMsgIncomingServer> server;
      GetServer(getter_AddRefs(server));
      // this is the deferred to account, in the global inbox case
      if (server)
        server->SetPerformingBiff(PR_FALSE);  //biff is over
    }
  }
  m_parsingFolder = PR_FALSE;
  return nsMsgDBFolder::OnStopRunningUrl(aUrl, aExitCode);
}

Here is the call graph for this function:

void nsIMsgLocalMailFolder::parseFolder ( in nsIMsgWindow  aMsgWindow,
in nsIUrlListener  listener 
) [inherited]

Definition at line 1360 of file nsLocalMailFolder.cpp.

{
  NS_ENSURE_ARG_POINTER(element);
  nsresult rv = nsMsgDBFolder::ReadFromFolderCacheElem(element);
  NS_ENSURE_SUCCESS(rv, rv);
  nsXPIDLCString utf8Name;
  rv = element->GetStringProperty("folderName", getter_Copies(utf8Name));
  NS_ENSURE_SUCCESS(rv, rv);
  CopyUTF8toUTF16(utf8Name, mName);
  return rv;
}

Here is the call graph for this function:

Definition at line 4145 of file nsLocalMailFolder.cpp.

{
  return ChangeKeywordForMessages(aMessages, aKeywords, PR_FALSE /* remove */);
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 1124 of file nsLocalMailFolder.cpp.

{
  nsCOMPtr<nsIFileSpec> oldPathSpec;
  nsCOMPtr<nsIAtom> folderRenameAtom;
  nsresult rv = GetPath(getter_AddRefs(oldPathSpec));
  if (NS_FAILED(rv)) 
    return rv;
  nsCOMPtr<nsIMsgFolder> parentFolder;
  rv = GetParentMsgFolder(getter_AddRefs(parentFolder));
  if (NS_FAILED(rv)) 
    return rv;
  nsCOMPtr<nsISupports> parentSupport = do_QueryInterface(parentFolder);
  
  nsFileSpec fileSpec;
  oldPathSpec->GetFileSpec(&fileSpec);
  nsLocalFolderSummarySpec oldSummarySpec(fileSpec);
  nsFileSpec dirSpec;
  
  PRUint32 cnt = 0;
  if (mSubFolders)
    mSubFolders->Count(&cnt);
  
  if (cnt > 0)
    rv = CreateDirectoryForFolder(dirSpec);
  
  // convert from PRUnichar* to char* due to not having Rename(PRUnichar*)
  // function in nsIFileSpec
  
  nsAutoString safeName(aNewName);
  NS_MsgHashIfNecessary(safeName);
  nsCAutoString newDiskName;
  if (NS_FAILED(NS_CopyUnicodeToNative(safeName, newDiskName)))
    return NS_ERROR_FAILURE;
  
  nsXPIDLCString oldLeafName;
  oldPathSpec->GetLeafName(getter_Copies(oldLeafName));
  
  if (mName.Equals(aNewName, nsCaseInsensitiveStringComparator()))
  {
    if(msgWindow)
      rv = ThrowAlertMsg("folderExists", msgWindow);
    return NS_MSG_FOLDER_EXISTS;
  }
  else
  {
    nsCOMPtr <nsIFileSpec> parentPathSpec;
    parentFolder->GetPath(getter_AddRefs(parentPathSpec));
    NS_ENSURE_SUCCESS(rv,rv);
    
    nsFileSpec parentPath;
    parentPathSpec->GetFileSpec(&parentPath);
    NS_ENSURE_SUCCESS(rv,rv);
    
    if (!parentPath.IsDirectory())
      AddDirectorySeparator(parentPath);
    
    rv = CheckIfFolderExists(aNewName, parentFolder, msgWindow);
    if (NS_FAILED(rv)) 
      return rv;
  }
  
  ForceDBClosed();
  
  nsCAutoString newNameDirStr(newDiskName.get());  //save of dir name before appending .msf 
  
  rv = oldPathSpec->Rename(newDiskName.get());
  if (NS_SUCCEEDED(rv))
  {
    newDiskName += ".msf";
    oldSummarySpec.Rename(newDiskName.get());
  }
  else
  {
    ThrowAlertMsg("folderRenameFailed", msgWindow);
    return rv;
  }
  
  if (NS_SUCCEEDED(rv) && cnt > 0) 
  {
    // rename "*.sbd" directory
    newNameDirStr += ".sbd";
    dirSpec.Rename(newNameDirStr.get());
  }
  
  nsCOMPtr<nsIMsgFolder> newFolder;
  if (parentSupport)
  {
    rv = parentFolder->AddSubfolder(safeName, getter_AddRefs(newFolder));
    if (newFolder) 
    {
      // Because we just renamed the db, w/o setting the pretty name in it, 
      // we need to force the pretty name to be correct. 
      // SetPrettyName won't write the name to the db if it doesn't think the 
      // name has changed. This hack forces the pretty name to get set in the db.
      // We could set the new pretty name on the db before renaming the .msf file,
      // but if the rename failed, it would be out of sync.
      newFolder->SetPrettyName(NS_LITERAL_STRING("").get());
      newFolder->SetPrettyName(aNewName);
      PRBool changed = PR_FALSE;
      MatchOrChangeFilterDestination(newFolder, PR_TRUE /*caseInsenstive*/, &changed);
      if (changed)
        AlertFilterChanged(msgWindow);
      
      if (cnt > 0)
        newFolder->RenameSubFolders(msgWindow, this);
      
      // the newFolder should have the same flags
      newFolder->SetFlags(mFlags);
      if (parentFolder)
      {
        SetParent(nsnull);
        parentFolder->PropagateDelete(this, PR_FALSE, msgWindow);
        parentFolder->NotifyItemAdded(newFolder);
      }
      SetPath(nsnull); // forget our path, since this folder object renamed itself
      folderRenameAtom = do_GetAtom("RenameCompleted");
      newFolder->NotifyFolderEvent(folderRenameAtom);
    }
  }
  return rv;
}

Here is the call graph for this function:

Definition at line 1246 of file nsLocalMailFolder.cpp.

{
  nsresult rv =NS_OK;
  mInitialized = PR_TRUE;

  PRUint32 flags;
  oldFolder->GetFlags(&flags);
  SetFlags(flags);

  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);
     nsXPIDLString folderName;
     rv = msgFolder->GetName(getter_Copies(folderName));
     nsCOMPtr <nsIMsgFolder> newFolder;
     AddSubfolder(folderName, getter_AddRefs(newFolder));
     if (newFolder)
     {
       newFolder->SetPrettyName(folderName.get());
       PRBool changed = PR_FALSE;
       msgFolder->MatchOrChangeFilterDestination(newFolder, PR_TRUE /*caseInsenstive*/, &changed);
       if (changed)
         msgFolder->AlertFilterChanged(msgWindow);

       newFolder->RenameSubFolders(msgWindow, msgFolder);
     }
     rv = aEnumerator->Next();
  }
  return NS_OK;
}

Here is the call graph for this function:

set the default flags on the subfolders of this folder, such as Drafts, Templates, etc you should bitwise OR all the flags all mailboxes you want to flag, this function will be smart and find the right names.

like MSG_FOLDER_FLAG_INBOX | MSG_FOLDER_FLAG_DRAFTS | etc

Definition at line 1287 of file nsLocalMailFolder.cpp.

{
  NS_ENSURE_ARG_POINTER(aName);
  nsresult rv = nsMsgDBFolder::SetPrettyName(aName);
  NS_ENSURE_SUCCESS(rv, rv);
  nsXPIDLCString folderName;
  rv = GetStringProperty("folderName", getter_Copies(folderName));
  NS_ConvertUCS2toUTF8 utf8FolderName(mName);
  if (!NS_SUCCEEDED(rv) || !folderName.Equals(utf8FolderName.get()))
    return SetStringProperty("folderName", utf8FolderName.get());
  else
    return rv;
}

Here is the call graph for this function:

nsresult nsMsgLocalMailFolder::setSubfolderFlag ( const PRUnichar aFolderName,
PRUint32  flags 
) [protected]

Definition at line 3595 of file nsLocalMailFolder.cpp.

{
  // FindSubFolder() expects the folder name to be escaped
  // see bug #192043
  nsCAutoString escapedFolderName;
  nsresult rv = NS_MsgEscapeEncodeURLPath(nsDependentString(aFolderName), escapedFolderName);
  NS_ENSURE_SUCCESS(rv,rv);
  nsCOMPtr<nsIMsgFolder> msgFolder;
  rv = FindSubFolder(escapedFolderName, getter_AddRefs(msgFolder));
  
  if (NS_FAILED(rv)) 
    return rv;
  if (!msgFolder) 
    return NS_ERROR_FAILURE;

  // we only want to do this if the folder *really* exists, 
  // so check if it has a parent. Otherwise, we'll create the
  // .msf file when we don't want to.
  nsCOMPtr <nsIMsgFolder> parent;
  msgFolder->GetParent(getter_AddRefs(parent));
  if (!parent)
    return NS_ERROR_FAILURE;

  rv = msgFolder->SetFlag(flags);
  if (NS_FAILED(rv)) 
    return rv;
  
  msgFolder->SetPrettyName(aFolderName);
  
  return NS_OK;
}

Here is the call graph for this function:

Definition at line 3656 of file nsLocalMailFolder.cpp.

{
  mInitialized = PR_FALSE;
  return nsMsgDBFolder::Shutdown(shutdownChildren);
}
nsresult nsMsgLocalMailFolder::SortMessagesBasedOnKey ( nsISupportsArray messages,
nsMsgKeyArray *  aKeyArray,
nsIMsgFolder srcFolder 
) [protected]

Definition at line 1673 of file nsLocalMailFolder.cpp.

{
  nsresult rv = NS_OK;
  PRUint32 numMessages = 0;
  rv = messages->Count(&numMessages);
  NS_ENSURE_SUCCESS(rv,rv);
  NS_ASSERTION ((numMessages == aKeyArray->GetSize()), "message array and key array size are not same");
  rv = messages->Clear();
  NS_ENSURE_SUCCESS(rv,rv);
  nsCOMPtr <nsIMsgDBHdr> msgHdr;
  nsCOMPtr<nsIDBFolderInfo> folderInfo;
  nsCOMPtr<nsIMsgDatabase> db; 
  rv = srcFolder->GetDBFolderInfoAndDB(getter_AddRefs(folderInfo), getter_AddRefs(db));
  if (NS_SUCCEEDED(rv) && db)
    for (PRUint32 i=0;i < numMessages; i++)
    {
      rv = db->GetMsgHdrForKey(aKeyArray->GetAt(i), getter_AddRefs(msgHdr));
      NS_ENSURE_SUCCESS(rv,rv);
      if (msgHdr)
        messages->AppendElement(msgHdr);
    }
  return rv;
}

Here is the call graph for this function:

Here is the caller graph for this function:

nsresult nsMsgLocalMailFolder::SpamFilterClassifyMessage ( const char *  aURI,
nsIMsgWindow aMsgWindow,
nsIJunkMailPlugin aJunkMailPlugin 
) [protected, virtual]

Definition at line 3663 of file nsLocalMailFolder.cpp.

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

Definition at line 3670 of file nsLocalMailFolder.cpp.

{
  NS_ASSERTION(!mNumFilterClassifyRequests, "shouldn't call this when already classifying messages");
  mNumFilterClassifyRequests = aURICount;
  return aJunkMailPlugin->ClassifyMessages(aURICount, aURIArray, aMsgWindow, this);   
}

Definition at line 615 of file nsLocalMailFolder.cpp.

{
  (void) RefreshSizeOnDisk();
  nsresult rv;

  nsCOMPtr<nsIMsgAccountManager> accountManager = 
           do_GetService(NS_MSGACCOUNTMANAGER_CONTRACTID, &rv);
  NS_ENSURE_SUCCESS(rv, rv);
  PRBool userNeedsToAuthenticate = PR_FALSE;
  // if we're PasswordProtectLocalCache, then we need to find out if the server is authenticated.
  (void) accountManager->GetUserNeedsToAuthenticate(&userNeedsToAuthenticate);
  if (userNeedsToAuthenticate)
  {
    nsCOMPtr<nsIMsgIncomingServer> server;
    rv = GetServer(getter_AddRefs(server)); 
    if (NS_FAILED(rv)) return rv;
    if (!server) 
      return NS_MSG_INVALID_OR_MISSING_SERVER;
    // need to check if this is a pop3 or no mail server to determine which password
    // we should challenge the user with.
    nsCOMPtr<nsIMsgIncomingServer> serverToAuthenticateAgainst;
    nsCOMPtr<nsINoIncomingServer> noIncomingServer = do_QueryInterface(server, &rv);
    if (noIncomingServer)
    {
      nsCOMPtr<nsIMsgAccount> defaultAccount;
      accountManager->GetDefaultAccount(getter_AddRefs(defaultAccount));
      if (defaultAccount)
        defaultAccount->GetIncomingServer(getter_AddRefs(serverToAuthenticateAgainst));
    }
    else
    {
      GetServer(getter_AddRefs(serverToAuthenticateAgainst));
    }
    if (serverToAuthenticateAgainst)
    {
      PRBool passwordMatches = PR_FALSE;
      rv = PromptForCachePassword(serverToAuthenticateAgainst, aWindow, passwordMatches);
      if (!passwordMatches)
        return NS_ERROR_FAILURE;
    }
  }
  //If we don't currently have a database, get it.  Otherwise, the folder has been updated (presumably this
  //changes when we download headers when opening inbox).  If it's updated, send NotifyFolderLoaded.
  if(!mDatabase)
    rv = GetDatabaseWithReparse(this, aWindow, getter_AddRefs(mDatabase)); 
  else
  {
    PRBool valid;
    rv = mDatabase->GetSummaryValid(&valid);
    // don't notify folder loaded or try compaction if db isn't valid
    // (we're probably reparsing or copying msgs to it)
    if (NS_SUCCEEDED(rv) && valid)
    {
      NotifyFolderEvent(mFolderLoadedAtom);
      NS_ENSURE_SUCCESS(rv,rv);
    }
    else if (mCopyState)
      mCopyState->m_notifyFolderLoaded = PR_TRUE; //defer folder loaded notification
    else if (!m_parsingFolder)// if the db was already open, it's probably OK to load it if not parsing
      NotifyFolderEvent(mFolderLoadedAtom);
  }
  PRBool filtersRun;
  PRBool hasNewMessages;
  GetHasNewMessages(&hasNewMessages);
  if (mDatabase)
    ApplyRetentionSettings();
  // if we have new messages, try the filter plugins.
  if (NS_SUCCEEDED(rv) && hasNewMessages)
    (void) CallFilterPlugins(aWindow, &filtersRun);
  return rv;
}

Here is the call graph for this function:

Definition at line 1379 of file nsLocalMailFolder.cpp.

{
  if (!mNotifyCountChanges)
    return NS_OK;
  PRInt32 oldUnreadMessages = mNumUnreadMessages;
  PRInt32 oldTotalMessages = mNumTotalMessages;
  //We need to read this info from the database
  ReadDBFolderInfo(force);
  
  //Need to notify listeners that total count changed.
  if(oldTotalMessages != mNumTotalMessages)
  {
    NotifyIntPropertyChanged(kTotalMessagesAtom, oldTotalMessages, mNumTotalMessages);
  }
  
  if(oldUnreadMessages != mNumUnreadMessages)
  {
    NotifyIntPropertyChanged(kTotalUnreadMessagesAtom, oldUnreadMessages, mNumUnreadMessages);
  }
  
  FlushToFolderCache();
  return NS_OK;
}

Here is the caller graph for this function:

Definition at line 2319 of file nsLocalMailFolder.cpp.

{
  mCopyState->m_curDstKey = mCopyState->m_fileStream->tell();
  
  // CopyFileMessage() and CopyMessages() from servers other than pop3
  if (mCopyState->m_parseMsgState)
  {
    mCopyState->m_parseMsgState->SetEnvelopePos(mCopyState->m_curDstKey);
    mCopyState->m_parseMsgState->SetState(nsIMsgParseMailMsgState::ParseHeadersState);
  }
  if (mCopyState->m_dummyEnvelopeNeeded)
  {
    nsCString result;
    nsCAutoString nowStr;
    MsgGenerateNowStr(nowStr);
    result.Append("From - ");
    result.Append(nowStr);
    result.Append(MSG_LINEBREAK);

    // *** jt - hard code status line for now; come back later

    nsresult rv;
    nsCOMPtr <nsIMsgDBHdr> curSourceMessage; 
    curSourceMessage = do_QueryElementAt(mCopyState->m_messages,
                                         mCopyState->m_curCopyIndex, &rv);

    char statusStrBuf[50];
    if (curSourceMessage)
    {
      PRUint32 dbFlags = 0;
      curSourceMessage->GetFlags(&dbFlags);

      // write out x-mozilla-status, but make sure we don't write out MSG_FLAG_OFFLINE
      PR_snprintf(statusStrBuf, sizeof(statusStrBuf), X_MOZILLA_STATUS_FORMAT MSG_LINEBREAK, 
        dbFlags & ~(MSG_FLAG_RUNTIME_ONLY | MSG_FLAG_OFFLINE) & 0x0000FFFF);
      // need to carry the new flag over to the new header.
      if (dbFlags & MSG_FLAG_NEW)
      {
      }
    }
    else
    {
      strcpy(statusStrBuf, "X-Mozilla-Status: 0001" MSG_LINEBREAK);
    }
    *(mCopyState->m_fileStream) << result.get();
    if (mCopyState->m_parseMsgState)
        mCopyState->m_parseMsgState->ParseAFolderLine(
          result.get(), result.Length());
    *(mCopyState->m_fileStream) << statusStrBuf;
    if (mCopyState->m_parseMsgState)
        mCopyState->m_parseMsgState->ParseAFolderLine(
        statusStrBuf, strlen(statusStrBuf));
    result = "X-Mozilla-Status2: 00000000" MSG_LINEBREAK;
    *(mCopyState->m_fileStream) << result.get();
    if (mCopyState->m_parseMsgState)
        mCopyState->m_parseMsgState->ParseAFolderLine(
          result.get(), result.Length());
    mCopyState->m_fromLineSeen = PR_TRUE;
  }
  else 
  {
    mCopyState->m_fromLineSeen = PR_FALSE;
  }

  mCopyState->m_curCopyIndex++;

  return NS_OK;
}

Here is the call graph for this function:

Definition at line 1372 of file nsLocalMailFolder.cpp.

{
  NS_ENSURE_ARG_POINTER(element);
  nsMsgDBFolder::WriteToFolderCacheElem(element);
  return element->SetStringProperty("folderName", NS_ConvertUCS2toUTF8(mName).get());
}

Here is the call graph for this function:


Member Data Documentation

Definition at line 85 of file nsIMsgLocalMailFolder.idl.

Definition at line 246 of file nsLocalMailFolder.h.

Definition at line 245 of file nsLocalMailFolder.h.

Definition at line 241 of file nsLocalMailFolder.h.

Definition at line 266 of file nsLocalMailFolder.h.

Definition at line 268 of file nsLocalMailFolder.h.

Definition at line 269 of file nsLocalMailFolder.h.

Definition at line 267 of file nsLocalMailFolder.h.

Definition at line 243 of file nsLocalMailFolder.h.

Definition at line 244 of file nsLocalMailFolder.h.

Definition at line 247 of file nsLocalMailFolder.h.

Definition at line 249 of file nsLocalMailFolder.h.

Definition at line 248 of file nsLocalMailFolder.h.

Definition at line 251 of file nsLocalMailFolder.h.

nsMsgKeyArray nsMsgLocalMailFolder::mSpamKeysToMove [protected]

Definition at line 250 of file nsLocalMailFolder.h.

Definition at line 242 of file nsLocalMailFolder.h.


The documentation for this class was generated from the following files: