Bug 311238 ns*SummarySpec.* are no longer required. Part 3 the final removal. r=bienvenu,sr=mscott

This commit is contained in:
bugzilla%standard8.demon.co.uk 2006-01-04 17:16:37 +00:00
parent 79886d0447
commit 455435572c
9 changed files with 76 additions and 56 deletions

View File

@ -43,7 +43,6 @@
#include "nsIFileSpec.h"
#include "nsIStreamListener.h"
#include "nsIMsgMessageService.h"
#include "nsLocalFolderSummarySpec.h"
#include "nsFileStream.h"
#include "nsMsgDBCID.h"
#include "nsMsgUtils.h"
@ -110,9 +109,10 @@ void nsFolderCompactState::CleanupTempFilesAfterError()
CloseOutputStream();
if (m_db)
m_db->ForceClosed();
nsLocalFolderSummarySpec summarySpec(m_fileSpec);
nsFileSpec summaryFile;
GetSummaryFileLocation(m_fileSpec, &summaryFile);
m_fileSpec.Delete(PR_FALSE);
summarySpec.Delete(PR_FALSE);
summaryFile.Delete(PR_FALSE);
}
nsresult nsFolderCompactState::BuildMessageURI(const char *baseURI, PRUint32 key, nsCString& uri)
@ -371,8 +371,9 @@ nsFolderCompactState::FinishCompact()
// All okay time to finish up the compact process
nsresult rv = NS_OK;
nsCOMPtr<nsIFileSpec> pathSpec;
nsCOMPtr<nsIDBFolderInfo> folderInfo;
nsCOMPtr<nsIDBFolderInfo> folderInfo;
nsFileSpec fileSpec;
nsFileSpec summaryFile;
// get leaf name and database name of the folder
rv = m_folder->GetPath(getter_AddRefs(pathSpec));
@ -383,9 +384,10 @@ nsFolderCompactState::FinishCompact()
PRBool ignored;
fileSpec.ResolveSymlink(ignored);
nsLocalFolderSummarySpec summarySpec(fileSpec);
GetSummaryFileLocation(fileSpec, &summaryFile);
nsXPIDLCString leafName;
nsCAutoString dbName(summarySpec.GetLeafName());
nsCAutoString dbName(summaryFile.GetLeafName());
pathSpec->GetLeafName(getter_Copies(leafName));
@ -403,7 +405,8 @@ nsFolderCompactState::FinishCompact()
m_db->ForceClosed();
m_db = nsnull;
nsLocalFolderSummarySpec newSummarySpec(m_fileSpec);
nsFileSpec newSummaryFile;
GetSummaryFileLocation(m_fileSpec, &newSummaryFile);
nsCOMPtr <nsIDBFolderInfo> transferInfo;
m_folder->GetDBTransferInfo(getter_AddRefs(transferInfo));
@ -415,8 +418,8 @@ nsFolderCompactState::FinishCompact()
PRBool folderRenameSucceeded = PR_FALSE;
PRBool msfRenameSucceeded = PR_FALSE;
// remove the old folder and database
summarySpec.Delete(PR_FALSE);
if (!summarySpec.Exists())
summaryFile.Delete(PR_FALSE);
if (!summaryFile.Exists())
{
fileSpec.Delete(PR_FALSE);
if (!fileSpec.Exists())
@ -428,7 +431,7 @@ nsFolderCompactState::FinishCompact()
if (NS_SUCCEEDED(rv))
{
folderRenameSucceeded = PR_TRUE;
rv = newSummarySpec.Rename(dbName.get());
rv = newSummaryFile.Rename(dbName.get());
NS_ASSERTION(NS_SUCCEEDED(rv), "error renaming compacted folder's db");
msfRenameSucceeded = NS_SUCCEEDED(rv);
}
@ -438,7 +441,7 @@ nsFolderCompactState::FinishCompact()
if (!folderRenameSucceeded)
m_fileSpec.Delete(PR_FALSE);
if (!msfRenameSucceeded)
newSummarySpec.Delete(PR_FALSE);
newSummaryFile.Delete(PR_FALSE);
rv = ReleaseFolderLock();
NS_ASSERTION(NS_SUCCEEDED(rv),"folder lock not released successfully");
if (msfRenameSucceeded && folderRenameSucceeded)

View File

@ -99,7 +99,6 @@ CPPSRCS = \
nsUInt32Array.cpp \
nsMsgKeySet.cpp \
nsMsgKeyArray.cpp \
nsLocalFolderSummarySpec.cpp \
nsMsgIdentity.cpp \
nsMsgIncomingServer.cpp \
nsMsgUtils.cpp \
@ -118,7 +117,6 @@ EXPORTS = \
nsMsgKeySet.h \
nsMsgKeyArray.h \
nsMsgDBFolder.h \
nsLocalFolderSummarySpec.h \
nsMsgIdentity.h \
nsMsgIncomingServer.h \
nsMsgUtils.h \

View File

@ -53,7 +53,6 @@
#include "nsIMsgAccountManager.h"
#include "nsXPIDLString.h"
#include "nsEscape.h"
#include "nsLocalFolderSummarySpec.h"
#include "nsMsgI18N.h"
#include "nsIFileStream.h"
#include "nsIChannel.h"
@ -1117,11 +1116,10 @@ nsresult nsMsgDBFolder::GetFolderCacheKey(nsIFileSpec **aFileSpec)
// if it's a server, we don't need the .msf appended to the name
if (!isServer)
{
nsFileSpec folderName;
dbPath->GetFileSpec(&folderName);
nsLocalFolderSummarySpec summarySpec(folderName);
nsFileSpec summaryName;
rv = GetSummaryFileLocation(dbPath, &summaryName);
dbPath->SetFromFileSpec(summarySpec);
dbPath->SetFromFileSpec(summaryName);
// create the .msf file
// see bug #244217 for details
@ -3298,10 +3296,11 @@ NS_IMETHODIMP nsMsgDBFolder::Rename(const PRUnichar *aNewName, nsIMsgWindow *msg
if (NS_FAILED(rv))
return rv;
nsCOMPtr<nsISupports> parentSupport = do_QueryInterface(parentFolder);
nsFileSpec fileSpec;
oldPathSpec->GetFileSpec(&fileSpec);
nsLocalFolderSummarySpec oldSummarySpec(fileSpec);
nsFileSpec oldSummarySpec;
rv = GetSummaryFileLocation(oldPathSpec, &oldSummarySpec);
NS_ENSURE_SUCCESS(rv, rv);
nsFileSpec dirSpec;
PRUint32 cnt = 0;

View File

@ -1179,3 +1179,18 @@ nsresult GetSummaryFileLocation(nsIFileSpec* fileLocation, nsFileSpec* summaryLo
return summaryIFile->GetFileSpec(summaryLocation);
}
void GetSummaryFileLocation(nsFileSpec& fileLocation, nsFileSpec* summaryLocation)
{
nsXPIDLCString fileName;
// First copy all the details across
*summaryLocation = fileLocation;
// Now work out the new file name.
fileName.Adopt(fileLocation.GetLeafName());
fileName.Append(NS_LITERAL_CSTRING(SUMMARY_SUFFIX));
summaryLocation->SetLeafName(fileName);
}

View File

@ -151,6 +151,10 @@ NS_MSG_BASE nsresult GetSummaryFileLocation(nsIFileSpec* fileLocation,
// on bug 33451 to remove nsIFileSpec from mailnews.
NS_MSG_BASE nsresult GetSummaryFileLocation(nsIFileSpec* fileLocation,
nsFileSpec* summaryLocation);
// XXX This function is provided temporarily whilst we are still working
// on bug 33451 to remove nsIFileSpec from mailnews.
NS_MSG_BASE void GetSummaryFileLocation(nsFileSpec& fileLocation,
nsFileSpec* summaryLocation);
#endif

View File

@ -44,7 +44,6 @@
#include "msgCore.h"
#include "nsImapMailDatabase.h"
#include "nsDBFolderInfo.h"
#include "nsLocalFolderSummarySpec.h"
#include "nsIFileSpec.h"
const char *kPendingHdrsScope = "ns:msg:db:row:scope:pending:all"; // scope for all offine ops table

View File

@ -1,4 +1,4 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
@ -41,13 +41,13 @@
#include "nsDBFolderInfo.h"
#include "nsMsgLocalFolderHdrs.h"
#include "nsFileStream.h"
#include "nsLocalFolderSummarySpec.h"
#include "nsFileSpec.h"
#include "nsMsgOfflineImapOperation.h"
#include "nsMsgFolderFlags.h"
#include "prlog.h"
#include "prprf.h"
#include "nsIFileSpec.h"
#include "nsMsgUtils.h"
#ifdef PUTUP_ALERT_ON_INVALID_DB
#include "nsIPrompt.h"
#include "nsIWindowWatcher.h"
@ -676,10 +676,10 @@ NS_IMETHODIMP nsMailDatabase::ListAllOfflineDeletes(nsMsgKeyArray *offlineDelete
/* static */
nsresult nsMailDatabase::SetFolderInfoValid(nsFileSpec *folderName, int num, int numunread)
{
nsLocalFolderSummarySpec summarySpec(*folderName);
nsFileSpec summaryPath(summarySpec);
nsresult err = NS_OK;
PRBool bOpenedDB = PR_FALSE;
nsresult err = NS_OK;
PRBool bOpenedDB = PR_FALSE;
nsFileSpec summaryPath;
GetSummaryFileLocation(*folderName, &summaryPath);
if (!folderName->Exists())
return NS_MSG_ERROR_FOLDER_SUMMARY_MISSING;
@ -692,14 +692,14 @@ nsresult nsMailDatabase::SetFolderInfoValid(nsFileSpec *folderName, int num, int
if(!pMessageDB)
return NS_ERROR_OUT_OF_MEMORY;
pMessageDB->m_folderSpec = new nsLocalFolderSummarySpec();
pMessageDB->m_folderSpec = new nsFileSpec();
if(!pMessageDB->m_folderSpec)
{
delete pMessageDB;
return NS_ERROR_OUT_OF_MEMORY;
}
*(pMessageDB->m_folderSpec) = summarySpec;
*(pMessageDB->m_folderSpec) = summaryPath;
// ### this does later stuff (marks latered messages unread), which may be a problem
err = pMessageDB->OpenMDB(summaryPath, PR_FALSE);
if (err != NS_OK)

View File

@ -52,7 +52,6 @@
#include "nsFileStream.h"
#include "nsMsgDBCID.h"
#include "nsMsgFolderFlags.h"
#include "nsLocalFolderSummarySpec.h"
#include "nsImapFlagAndUidState.h"
#include "nsIEventQueueService.h"
#include "nsIImapUrl.h"
@ -1654,11 +1653,12 @@ NS_IMETHODIMP nsImapMailFolder::RenameLocal(const char *newName, nsIMsgFolder *p
if (cnt > 0)
rv = CreateDirectoryForFolder(dirSpec);
nsFileSpec fileSpec;
oldPathSpec->GetFileSpec(&fileSpec);
nsLocalFolderSummarySpec oldSummarySpec(fileSpec);
nsFileSpec oldSummaryFile;
rv = GetSummaryFileLocation(oldPathSpec, &oldSummaryFile);
NS_ENSURE_SUCCESS(rv, rv);
nsCAutoString newNameStr;
oldSummarySpec.Delete(PR_FALSE);
oldSummaryFile.Delete(PR_FALSE);
if (cnt > 0)
{
newNameStr = leafname;
@ -2662,9 +2662,10 @@ NS_IMETHODIMP nsImapMailFolder::UpdateImapMailboxInfo(
}
mDatabase = nsnull;
nsLocalFolderSummarySpec summarySpec(dbName);
nsFileSpec summaryFile;
GetSummaryFileLocation(dbName, &summaryFile);
// Remove summary file.
summarySpec.Delete(PR_FALSE);
summaryFile.Delete(PR_FALSE);
// Create a new summary file, update the folder message counts, and
// Close the summary file db.
@ -7176,7 +7177,8 @@ nsImapMailFolder::CopyFolder(nsIMsgFolder* srcFolder,
rv = oldPathSpec->GetFileSpec(&oldPath);
NS_ENSURE_SUCCESS(rv,rv);
nsLocalFolderSummarySpec summarySpec(oldPath);
nsFileSpec summaryFile;
GetSummaryFileLocation(oldPath, &summaryFile);
nsCOMPtr<nsIFileSpec> newPathSpec;
rv = GetPath(getter_AddRefs(newPathSpec));
@ -7196,7 +7198,7 @@ nsImapMailFolder::CopyFolder(nsIMsgFolder* srcFolder,
if(NS_FAILED(rv))
return rv;
rv = summarySpec.CopyToDir(newPath);
rv = summaryFile.CopyToDir(newPath);
NS_ENSURE_SUCCESS(rv, rv);
rv = AddSubfolder(safeFolderName, getter_AddRefs(newMsgFolder));

View File

@ -79,7 +79,6 @@
#include "nsIMsgFolderCacheElement.h"
#include "nsReadableUtils.h"
#include "nsUnicharUtils.h"
#include "nsLocalFolderSummarySpec.h"
#include "nsMsgUtils.h"
#include "nsICopyMsgStreamListener.h"
#include "nsIMsgCopyService.h"
@ -570,12 +569,11 @@ NS_IMETHODIMP nsMsgLocalMailFolder::GetDatabaseWithReparse(nsIUrlListener *aRepa
}
mDatabase = nsnull;
nsFileSpec dbName;
rv = pathSpec->GetFileSpec(&dbName);
nsFileSpec summaryFile;
rv = GetSummaryFileLocation(pathSpec, &summaryFile);
NS_ENSURE_SUCCESS(rv, rv);
nsLocalFolderSummarySpec summarySpec(dbName);
// Remove summary file.
summarySpec.Delete(PR_FALSE);
summaryFile.Delete(PR_FALSE);
// if it's out of date then reopen with upgrade.
if (NS_FAILED(rv = msgDBService->OpenFolderDB(this, PR_TRUE, PR_TRUE, getter_AddRefs(mDatabase)))
@ -1050,14 +1048,15 @@ NS_IMETHODIMP nsMsgLocalMailFolder::Delete()
nsFileSpec path;
rv = pathSpec->GetFileSpec(&path);
if (NS_FAILED(rv)) return rv;
nsLocalFolderSummarySpec summarySpec(path);
nsFileSpec summaryFile;
GetSummaryFileLocation(path, &summaryFile);
//Clean up .sbd folder if it exists.
if(NS_SUCCEEDED(rv))
{
// Remove summary file.
summarySpec.Delete(PR_FALSE);
summaryFile.Delete(PR_FALSE);
//Delete mailbox
path.Delete(PR_FALSE);
@ -1145,9 +1144,9 @@ NS_IMETHODIMP nsMsgLocalMailFolder::Rename(const PRUnichar *aNewName, nsIMsgWind
return rv;
nsCOMPtr<nsISupports> parentSupport = do_QueryInterface(parentFolder);
nsFileSpec fileSpec;
oldPathSpec->GetFileSpec(&fileSpec);
nsLocalFolderSummarySpec oldSummarySpec(fileSpec);
nsFileSpec oldSummaryFile;
rv = GetSummaryFileLocation(oldPathSpec, &oldSummaryFile);
NS_ENSURE_SUCCESS(rv, rv);
nsFileSpec dirSpec;
PRUint32 cnt = 0;
@ -1201,7 +1200,7 @@ NS_IMETHODIMP nsMsgLocalMailFolder::Rename(const PRUnichar *aNewName, nsIMsgWind
if (NS_SUCCEEDED(rv))
{
newDiskName += SUMMARY_SUFFIX;
oldSummarySpec.Rename(newDiskName.get());
oldSummaryFile.Rename(newDiskName.get());
}
else
{
@ -1989,8 +1988,9 @@ nsMsgLocalMailFolder::CopyFolderLocal(nsIMsgFolder *srcFolder,
nsFileSpec oldPath;
rv = oldPathSpec->GetFileSpec(&oldPath);
NS_ENSURE_SUCCESS(rv,rv);
nsLocalFolderSummarySpec summarySpec(oldPath);
nsFileSpec summaryFile;
GetSummaryFileLocation(oldPath, &summaryFile);
nsCOMPtr<nsIFileSpec> newPathSpec;
rv = GetPath(getter_AddRefs(newPathSpec));
@ -2019,11 +2019,11 @@ nsMsgLocalMailFolder::CopyFolderLocal(nsIMsgFolder *srcFolder,
// if the filespec exist or not, if it does not that's ok, we continue
// without copying it. If it fails and filespec exist and is not zero sized
// there is real problem
rv = summarySpec.CopyToDir(newPath); // Copy the filespec to the new dir
rv = summaryFile.CopyToDir(newPath); // Copy the filespec to the new dir
if (! NS_SUCCEEDED(rv)) // Test if the copy is successfull
{
// Test if the filespec has data
if (summarySpec.Exists() && (summarySpec.GetFileSize() > 0))
if (summaryFile.Exists() && (summaryFile.GetFileSize() > 0))
NS_ENSURE_SUCCESS(rv, rv); // Yes, it should have worked !
// else case is filespec is zero sized, no need to copy it,
// not an error