add folder size to folder pane, r=cavin, sr=sspitzer, 173825

This commit is contained in:
bienvenu%netscape.com 2002-11-06 00:13:19 +00:00
Родитель 7f656aedc8
Коммит 5e7ac8172b
8 изменённых файлов: 108 добавлений и 15 удалений

Просмотреть файл

@ -268,9 +268,10 @@ const nsMsgBiffState nsMsgBiffState_Unknown = 2; // We dunno whether there is ne
readonly attribute string relativePathName;
/**
* size of this folder (including headers??) on disk
* size of this folder on disk (not including .msf file)
* for imap, it's the sum of the size of the messages
*/
readonly attribute unsigned long sizeOnDisk;
attribute unsigned long sizeOnDisk;
/**
* set the password for this folder (what is this used for?)

Просмотреть файл

@ -88,6 +88,7 @@ nsIRDFResource* nsMsgFolderDataSource::kNC_CanRename = nsnull;
nsIRDFResource* nsMsgFolderDataSource::kNC_CanCompact = nsnull;
nsIRDFResource* nsMsgFolderDataSource::kNC_TotalMessages= nsnull;
nsIRDFResource* nsMsgFolderDataSource::kNC_TotalUnreadMessages= nsnull;
nsIRDFResource* nsMsgFolderDataSource::kNC_FolderSize = nsnull;
nsIRDFResource* nsMsgFolderDataSource::kNC_Charset = nsnull;
nsIRDFResource* nsMsgFolderDataSource::kNC_BiffState = nsnull;
nsIRDFResource* nsMsgFolderDataSource::kNC_HasUnreadMessages = nsnull;
@ -120,10 +121,14 @@ nsIAtom * nsMsgFolderDataSource::kBiffStateAtom = nsnull;
nsIAtom * nsMsgFolderDataSource::kNewMessagesAtom = nsnull;
nsIAtom * nsMsgFolderDataSource::kTotalMessagesAtom = nsnull;
nsIAtom * nsMsgFolderDataSource::kTotalUnreadMessagesAtom = nsnull;
nsIAtom * nsMsgFolderDataSource::kFolderSizeAtom = nsnull;
nsIAtom * nsMsgFolderDataSource::kNameAtom = nsnull;
nsIAtom * nsMsgFolderDataSource::kSynchronizeAtom = nsnull;
nsIAtom * nsMsgFolderDataSource::kOpenAtom = nsnull;
static const PRUint32 kDisplayBlankCount = 0xFFFFFFFE;
static const PRUint32 kDisplayQuestionCount = 0xFFFFFFFF;
nsMsgFolderDataSource::nsMsgFolderDataSource()
{
// one-time initialization here
@ -153,6 +158,7 @@ nsMsgFolderDataSource::nsMsgFolderDataSource()
rdf->GetResource(NC_RDF_CANCOMPACT, &kNC_CanCompact);
rdf->GetResource(NC_RDF_TOTALMESSAGES, &kNC_TotalMessages);
rdf->GetResource(NC_RDF_TOTALUNREADMESSAGES, &kNC_TotalUnreadMessages);
rdf->GetResource(NC_RDF_FOLDERSIZE, &kNC_FolderSize);
rdf->GetResource(NC_RDF_CHARSET, &kNC_Charset);
rdf->GetResource(NC_RDF_BIFFSTATE, &kNC_BiffState);
rdf->GetResource(NC_RDF_HASUNREADMESSAGES, &kNC_HasUnreadMessages);
@ -182,6 +188,7 @@ nsMsgFolderDataSource::nsMsgFolderDataSource()
kTotalMessagesAtom = NS_NewAtom("TotalMessages");
kTotalUnreadMessagesAtom = NS_NewAtom("TotalUnreadMessages");
kFolderSizeAtom = NS_NewAtom("FolderSize");
kBiffStateAtom = NS_NewAtom("BiffState");
kNewMessagesAtom = NS_NewAtom("NewMessages");
kNameAtom = NS_NewAtom("Name");
@ -222,6 +229,7 @@ nsMsgFolderDataSource::~nsMsgFolderDataSource (void)
NS_RELEASE2(kNC_CanCompact, refcnt);
NS_RELEASE2(kNC_TotalMessages, refcnt);
NS_RELEASE2(kNC_TotalUnreadMessages, refcnt);
NS_RELEASE2(kNC_FolderSize, refcnt);
NS_RELEASE2(kNC_Charset, refcnt);
NS_RELEASE2(kNC_BiffState, refcnt);
NS_RELEASE2(kNC_HasUnreadMessages, refcnt);
@ -250,6 +258,7 @@ nsMsgFolderDataSource::~nsMsgFolderDataSource (void)
NS_RELEASE(kTotalMessagesAtom);
NS_RELEASE(kTotalUnreadMessagesAtom);
NS_RELEASE(kFolderSizeAtom);
NS_RELEASE(kBiffStateAtom);
NS_RELEASE(kNewMessagesAtom);
NS_RELEASE(kNameAtom);
@ -558,6 +567,7 @@ nsMsgFolderDataSource::HasArcOut(nsIRDFResource *aSource, nsIRDFResource *aArc,
aArc == kNC_CanCompact ||
aArc == kNC_TotalMessages ||
aArc == kNC_TotalUnreadMessages ||
aArc == kNC_FolderSize ||
aArc == kNC_Charset ||
aArc == kNC_BiffState ||
aArc == kNC_Child ||
@ -625,6 +635,7 @@ nsMsgFolderDataSource::getFolderArcLabelsOut(nsISupportsArray **arcs)
(*arcs)->AppendElement(kNC_CanCompact);
(*arcs)->AppendElement(kNC_TotalMessages);
(*arcs)->AppendElement(kNC_TotalUnreadMessages);
(*arcs)->AppendElement(kNC_FolderSize);
(*arcs)->AppendElement(kNC_Charset);
(*arcs)->AppendElement(kNC_BiffState);
(*arcs)->AppendElement(kNC_Child);
@ -882,13 +893,11 @@ nsMsgFolderDataSource::OnItemIntPropertyChanged(nsISupports *item,
{
if (kTotalMessagesAtom == property)
{
OnTotalMessagePropertyChanged(folder, oldValue, newValue);
}
else if (kTotalUnreadMessagesAtom == property)
{
OnUnreadMessagePropertyChanged(folder, oldValue, newValue);
}
else if (kFolderSizeAtom == property)
OnFolderSizePropertyChanged(folder, oldValue, newValue);
}
return NS_OK;
@ -1040,6 +1049,8 @@ nsresult nsMsgFolderDataSource::createFolderNode(nsIMsgFolder* folder,
rv = createTotalMessagesNode(folder, target);
else if ((kNC_TotalUnreadMessages == property))
rv = createUnreadMessagesNode(folder, target);
else if ((kNC_FolderSize == property))
rv = createFolderSizeNode(folder, target);
else if ((kNC_Charset == property))
rv = createCharsetNode(folder, target);
else if ((kNC_BiffState == property))
@ -1560,7 +1571,7 @@ nsMsgFolderDataSource::createTotalMessagesNode(nsIMsgFolder *folder,
PRInt32 totalMessages;
if(isServer)
totalMessages = -2;
totalMessages = kDisplayBlankCount;
else
{
rv = folder->GetTotalMessages(PR_FALSE, &totalMessages);
@ -1571,6 +1582,26 @@ nsMsgFolderDataSource::createTotalMessagesNode(nsIMsgFolder *folder,
return rv;
}
nsresult
nsMsgFolderDataSource::createFolderSizeNode(nsIMsgFolder *folder, nsIRDFNode **target)
{
PRBool isServer;
nsresult rv = folder->GetIsServer(&isServer);
NS_ENSURE_SUCCESS(rv, rv);
PRInt32 folderSize;
if(isServer)
folderSize = kDisplayBlankCount;
else
{
rv = folder->GetSizeOnDisk((PRUint32 *) &folderSize);
NS_ENSURE_SUCCESS(rv, rv);
}
GetFolderSizeNode(folderSize, target);
return rv;
}
nsresult
nsMsgFolderDataSource::createCharsetNode(nsIMsgFolder *folder, nsIRDFNode **target)
{
@ -1630,7 +1661,7 @@ nsMsgFolderDataSource::createUnreadMessagesNode(nsIMsgFolder *folder,
PRInt32 totalUnreadMessages;
if(isServer)
totalUnreadMessages = -2;
totalUnreadMessages = kDisplayBlankCount;
else
{
rv = folder->GetNumUnread(PR_FALSE, &totalUnreadMessages);
@ -1857,6 +1888,20 @@ nsMsgFolderDataSource::OnUnreadMessagePropertyChanged(nsIMsgFolder *folder, PRIn
**/
nsresult
nsMsgFolderDataSource::OnFolderSizePropertyChanged(nsIMsgFolder *folder, PRInt32 oldValue, PRInt32 newValue)
{
nsCOMPtr<nsIRDFResource> folderResource = do_QueryInterface(folder);
if(folderResource)
{
nsCOMPtr<nsIRDFNode> newNode;
GetFolderSizeNode(newValue, getter_AddRefs(newNode));
NotifyPropertyChanged(folderResource, kNC_FolderSize, newNode);
}
return NS_OK;
}
nsresult
nsMsgFolderDataSource::OnTotalMessagePropertyChanged(nsIMsgFolder *folder, PRInt32 oldValue, PRInt32 newValue)
{
@ -1873,14 +1918,37 @@ nsMsgFolderDataSource::OnTotalMessagePropertyChanged(nsIMsgFolder *folder, PRInt
}
nsresult
nsMsgFolderDataSource::GetNumMessagesNode(PRInt32 numMessages, nsIRDFNode **node)
nsMsgFolderDataSource::GetNumMessagesNode(PRInt32 aNumMessages, nsIRDFNode **node)
{
if(numMessages > 0)
createIntNode(numMessages, node, getRDFService());
else if(numMessages == -1)
PRUint32 numMessages = aNumMessages;
if(numMessages == kDisplayQuestionCount)
createNode(NS_LITERAL_STRING("???").get(), node, getRDFService());
else
else if (numMessages == kDisplayBlankCount || numMessages == 0)
createNode(NS_LITERAL_STRING("").get(), node, getRDFService());
else
createIntNode(numMessages, node, getRDFService());
return NS_OK;
}
nsresult
nsMsgFolderDataSource::GetFolderSizeNode(PRInt32 aFolderSize, nsIRDFNode **aNode)
{
PRUint32 folderSize = aFolderSize;
if (folderSize == kDisplayBlankCount || folderSize == 0)
createNode(NS_LITERAL_STRING("").get(), aNode, getRDFService());
else if(folderSize == kDisplayQuestionCount)
createNode(NS_LITERAL_STRING("???").get(), aNode, getRDFService());
else
{
nsAutoString sizeString;
if (folderSize < 1024)
folderSize = 1024; // make at least 1 k;
folderSize /= 1024; // normalize into k;
PRBool sizeInMB = (folderSize > 1024);
sizeString.AppendInt((sizeInMB) ? folderSize / 1024 : folderSize);
sizeString.Append((sizeInMB) ? NS_LITERAL_STRING(" MB") : NS_LITERAL_STRING(" kb"));
createNode(sizeString.get(), aNode, getRDFService());
}
return NS_OK;
}
@ -2145,6 +2213,7 @@ nsresult nsMsgFolderDataSource::DoFolderHasAssertion(nsIMsgFolder *folder,
(kNC_CanCompact == property) ||
(kNC_TotalMessages == property) ||
(kNC_TotalUnreadMessages == property) ||
(kNC_FolderSize == property) ||
(kNC_Charset == property) ||
(kNC_BiffState == property) ||
(kNC_HasUnreadMessages == property) ||

Просмотреть файл

@ -157,6 +157,7 @@ protected:
nsIRDFNode **target);
nsresult createTotalMessagesNode(nsIMsgFolder *folder, nsIRDFNode **target);
nsresult createUnreadMessagesNode(nsIMsgFolder *folder, nsIRDFNode **target);
nsresult createFolderSizeNode(nsIMsgFolder *folder, nsIRDFNode **target);
nsresult createCharsetNode(nsIMsgFolder *folder, nsIRDFNode **target);
nsresult createBiffStateNodeFromFolder(nsIMsgFolder *folder, nsIRDFNode **target);
nsresult createBiffStateNodeFromFlag(PRUint32 flag, nsIRDFNode **target);
@ -202,11 +203,13 @@ protected:
nsresult OnUnreadMessagePropertyChanged(nsIMsgFolder *folder, PRInt32 oldValue, PRInt32 newValue);
nsresult OnTotalMessagePropertyChanged(nsIMsgFolder *folder, PRInt32 oldValue, PRInt32 newValue);
nsresult OnFolderSizePropertyChanged(nsIMsgFolder *folder, PRInt32 oldValue, PRInt32 newValue);
nsresult NotifyFolderTreeNameChanged(nsIMsgFolder *folder, PRInt32 aUnreadMessages);
nsresult NotifyFolderTreeSimpleNameChanged(nsIMsgFolder *folder);
nsresult NotifyFolderNameChanged(nsIMsgFolder *folder);
nsresult NotifyAncestors(nsIMsgFolder *aFolder, nsIRDFResource *aPropertyResource, nsIRDFNode *aNode);
nsresult GetNumMessagesNode(PRInt32 numMessages, nsIRDFNode **node);
nsresult GetFolderSizeNode(PRInt32 folderSize, nsIRDFNode **node);
nsresult CreateLiterals(nsIRDFService *rdf);
static nsIRDFResource* kNC_Child;
@ -234,6 +237,7 @@ protected:
static nsIRDFResource* kNC_CanCompact;
static nsIRDFResource* kNC_TotalMessages;
static nsIRDFResource* kNC_TotalUnreadMessages;
static nsIRDFResource* kNC_FolderSize;
static nsIRDFResource* kNC_Charset;
static nsIRDFResource* kNC_BiffState;
static nsIRDFResource* kNC_HasUnreadMessages;
@ -267,6 +271,7 @@ protected:
// property atoms
static nsIAtom* kTotalMessagesAtom;
static nsIAtom* kTotalUnreadMessagesAtom;
static nsIAtom* kFolderSizeAtom;
static nsIAtom* kBiffStateAtom;
static nsIAtom* kNewMessagesAtom;
static nsIAtom* kNameAtom;

Просмотреть файл

@ -94,6 +94,7 @@ typedef struct _nsMsgRDFNotification {
#define NC_RDF_CANCOMPACT NC_NAMESPACE_URI "CanCompact"
#define NC_RDF_TOTALMESSAGES NC_NAMESPACE_URI "TotalMessages"
#define NC_RDF_TOTALUNREADMESSAGES NC_NAMESPACE_URI "TotalUnreadMessages"
#define NC_RDF_FOLDERSIZE NC_NAMESPACE_URI "FolderSize"
#define NC_RDF_CHARSET NC_NAMESPACE_URI "Charset"
#define NC_RDF_BIFFSTATE NC_NAMESPACE_URI "BiffState"
#define NC_RDF_HASUNREADMESSAGES NC_NAMESPACE_URI "HasUnreadMessages"

Просмотреть файл

@ -560,6 +560,8 @@ NS_IMETHODIMP nsMsgDBFolder::GetOfflineFileTransport(nsMsgKey msgKey, PRUint32 *
if (NS_SUCCEEDED(rv))
{
nsresult rv = GetDatabase(nsnull);
NS_ENSURE_SUCCESS(rv, NS_OK);
nsCOMPtr<nsIMsgDBHdr> hdr;
rv = mDatabase->GetMsgHdrForKey(msgKey, getter_AddRefs(hdr));
if (hdr && NS_SUCCEEDED(rv))
@ -964,6 +966,7 @@ NS_IMETHODIMP nsMsgDBFolder::ReadFromFolderCacheElem(nsIMsgFolderCacheElement *e
element->GetInt32Property("pendingUnreadMsgs", &mNumPendingUnreadMessages);
element->GetInt32Property("pendingMsgs", &mNumPendingTotalMessages);
element->GetInt32Property("expungedBytes", (PRInt32 *) &mExpungedBytes);
element->GetInt32Property("folderSize", (PRInt32 *) &mFolderSize);
element->GetStringProperty("charset", &charset);
@ -1099,6 +1102,7 @@ NS_IMETHODIMP nsMsgDBFolder::WriteToFolderCacheElem(nsIMsgFolderCacheElement *el
element->SetInt32Property("pendingUnreadMsgs", mNumPendingUnreadMessages);
element->SetInt32Property("pendingMsgs", mNumPendingTotalMessages);
element->SetInt32Property("expungedBytes", mExpungedBytes);
element->SetInt32Property("folderSize", mFolderSize);
nsCAutoString mcharsetC;
mcharsetC.AssignWithConversion(mCharset);

Просмотреть файл

@ -97,6 +97,7 @@ PRUnichar *nsMsgFolder::kLocalizedUnsentName;
PRUnichar *nsMsgFolder::kLocalizedJunkName;
nsIAtom * nsMsgFolder::kTotalMessagesAtom = nsnull;
nsIAtom * nsMsgFolder::kFolderSizeAtom = nsnull;
nsIAtom * nsMsgFolder::kBiffStateAtom = nsnull;
nsIAtom * nsMsgFolder::kNewMessagesAtom = nsnull;
nsIAtom * nsMsgFolder::kNumNewBiffMessagesAtom = nsnull;
@ -134,6 +135,7 @@ nsMsgFolder::nsMsgFolder(void)
mNumPendingUnreadMessages = 0;
mNumPendingTotalMessages = 0;
mFolderSize = 0;
NS_NewISupportsArray(getter_AddRefs(mSubFolders));
mIsCachable = PR_TRUE;
@ -147,6 +149,7 @@ nsMsgFolder::nsMsgFolder(void)
kNameAtom = NS_NewAtom("Name");
kTotalUnreadMessagesAtom = NS_NewAtom("TotalUnreadMessages");
kTotalMessagesAtom = NS_NewAtom("TotalMessages");
kFolderSizeAtom = NS_NewAtom("FolderSize");
kStatusAtom = NS_NewAtom("Status");
kFlaggedAtom = NS_NewAtom("Flagged");
kSynchronizeAtom = NS_NewAtom("Synchronize");
@ -1906,6 +1909,13 @@ NS_IMETHODIMP nsMsgFolder::GetSizeOnDisk(PRUint32 *size)
return NS_OK;
}
NS_IMETHODIMP nsMsgFolder::SetSizeOnDisk(PRUint32 aSizeOnDisk)
{
NotifyIntPropertyChanged(kFolderSizeAtom, mFolderSize, aSizeOnDisk);
mFolderSize = aSizeOnDisk;
return NS_OK;
}
#ifdef HAVE_NET
NS_IMETHODIMP nsMsgFolder::ShouldPerformOperationOffline(PRBool *performOffline)
{

Просмотреть файл

@ -143,6 +143,7 @@ public:
NS_IMETHOD GetDisplayRecipients(PRBool *aDisplayRecipients);
NS_IMETHOD GetRelativePathName(char * *aRelativePathName);
NS_IMETHOD GetSizeOnDisk(PRUint32 *aSizeOnDisk);
NS_IMETHOD SetSizeOnDisk(PRUint32 aSizeOnDisk);
NS_IMETHOD RememberPassword(const char *password);
NS_IMETHOD GetRememberedPassword(char * *aRememberedPassword);
NS_IMETHOD UserNeedsToAuthenticateForFolder(PRBool displayOnly, PRBool *_retval);
@ -294,8 +295,9 @@ protected:
// we don't want to do an expensive select until the user actually opens that folder
PRInt32 mNumPendingUnreadMessages;
PRInt32 mNumPendingTotalMessages;
PRUint32 mFolderSize;
PRInt32 mNumNewBiffMessages;
PRInt32 mNumNewBiffMessages;
PRBool mIsCachable;
//
// stuff from the uri
@ -327,6 +329,7 @@ protected:
static nsIAtom* kNewMessagesAtom;
static nsIAtom* kNumNewBiffMessagesAtom;
static nsIAtom* kTotalMessagesAtom;
static nsIAtom* kFolderSizeAtom;
static nsIAtom* kStatusAtom;
static nsIAtom* kFlaggedAtom;
static nsIAtom* kNameAtom;

Просмотреть файл

@ -904,7 +904,7 @@ NS_IMETHODIMP nsMsgNewsFolder::GetRequiresCleanup(PRBool *requiresCleanup)
NS_IMETHODIMP nsMsgNewsFolder::GetSizeOnDisk(PRUint32 *size)
{
NS_ASSERTION(0, "GetSizeOnDisk not implemented");
// NS_ASSERTION(0, "GetSizeOnDisk not implemented");
return NS_ERROR_NOT_IMPLEMENTED;
}