mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-25 19:25:43 +00:00
Add basic UI for displaying IMAP quota information (bug 178758). Thanks to Lorenzo Colliti <lorenzo@collitti.com> for the patch. r=bienvenu@netscape.com, neil@parkwaycc.co.uk; sr=dmose@mozilla.org
This commit is contained in:
parent
2980583366
commit
c35bd98cd5
@ -51,6 +51,52 @@ var gFolderPropsSink = {
|
||||
if (permissionsLabel)
|
||||
permissionsLabel.setAttribute("hidden", "true");
|
||||
|
||||
},
|
||||
|
||||
setQuotaStatus : function(folderQuotaStatus)
|
||||
{
|
||||
var quotaStatusLabel = document.getElementById("folderQuotaStatus");
|
||||
if(quotaStatusLabel)
|
||||
quotaStatusLabel.setAttribute("value", folderQuotaStatus);
|
||||
},
|
||||
|
||||
showQuotaData : function(showData)
|
||||
{
|
||||
var quotaStatusLabel = document.getElementById("folderQuotaStatus");
|
||||
var folderQuotaData = document.getElementById("folderQuotaData");
|
||||
|
||||
if(quotaStatusLabel && folderQuotaData)
|
||||
{
|
||||
quotaStatusLabel.hidden = showData;
|
||||
folderQuotaData.hidden = ! showData;
|
||||
}
|
||||
},
|
||||
|
||||
setQuotaData : function(root, usedKB, maxKB)
|
||||
{
|
||||
var quotaRoot = document.getElementById("quotaRoot");
|
||||
if (quotaRoot)
|
||||
quotaRoot.setAttribute("value", '"' + root + '"');
|
||||
|
||||
var percentage = (maxKB != 0) ? Math.round(usedKB / maxKB * 100) : 0;
|
||||
|
||||
var quotaPercentageBar = document.getElementById("quotaPercentageBar");
|
||||
if (quotaPercentageBar)
|
||||
quotaPercentageBar.setAttribute("value", percentage);
|
||||
|
||||
var bundle = document.getElementById("bundle_messenger");
|
||||
if(bundle)
|
||||
{
|
||||
var usedFreeCaption = bundle.getFormattedString("quotaUsedFree", [usedKB, maxKB], 2);
|
||||
quotaCaption = document.getElementById("quotaUsedFree");
|
||||
if(quotaCaption)
|
||||
quotaCaption.setAttribute("value", usedFreeCaption);
|
||||
|
||||
var percentUsedCaption = bundle.getFormattedString("quotaPercentUsed", [percentage], 1);
|
||||
var percentUsed = document.getElementById("quotaPercentUsed");
|
||||
if(percentUsed)
|
||||
percentUsed.setAttribute("value", percentUsedCaption);
|
||||
}
|
||||
}
|
||||
|
||||
};
|
||||
|
@ -20,6 +20,7 @@
|
||||
|
||||
- Contributor(s): David Bienvenu <bienvenu@netscape.com>
|
||||
Doron Rosenberg <doronr@naboonline.com>
|
||||
Lorenzo Colitti <lorenzo@colitti.com>
|
||||
-->
|
||||
|
||||
<?xml-stylesheet href="chrome://messenger/skin/dialogs.css" type="text/css"?>
|
||||
@ -34,6 +35,7 @@
|
||||
onload="folderPropsOnLoad()" style="width: 36em;"
|
||||
class="dialog">
|
||||
|
||||
<stringbundle id="bundle_messenger" src="chrome://messenger/locale/messenger.properties"/>
|
||||
<script type="application/x-javascript" src="chrome://global/content/globalOverlay.js"></script>
|
||||
<script type="application/x-javascript" src="chrome://messenger/content/folderProps.js"></script>
|
||||
<script type="application/x-javascript">
|
||||
@ -50,6 +52,7 @@
|
||||
<tab id="GeneralTab" label="&generalInfo.label;"/>
|
||||
<tab hidefor="movemail,pop3,none" hidable="true" id="OfflineTab" label="&folderOfflineTab.label;"/>
|
||||
<tab hidefor="movemail,pop3,none,nntp" hidable="true" id="SharingTab" label="&folderSharingTab.label;"/>
|
||||
<tab hidefor="movemail,pop3,none,nntp" hidable="true" id="QuotaTab" label="&folderQuotaTab.label;"/>
|
||||
</tabs>
|
||||
<tabpanels id="folderPropTabPanel">
|
||||
<vbox>
|
||||
@ -106,6 +109,33 @@
|
||||
oncommand="onFolderPrivileges();"
|
||||
id="imap.FolderPrivileges" hidefor="movemail,pop3,none,nntp" orient="right"/>
|
||||
</vbox>
|
||||
<vbox hidable="true" hidefor="pop3,none,nntp" valign="top">
|
||||
<label id="folderQuotaStatus" flex="1"/>
|
||||
|
||||
<grid id="folderQuotaData" hidden="true" flex="1">
|
||||
<columns>
|
||||
<column/>
|
||||
<column flex="1"/>
|
||||
</columns>
|
||||
<rows>
|
||||
<row align="center">
|
||||
<label value="&folderQuotaRoot.label;"/>
|
||||
<textbox id="quotaRoot" readonly="true"/>
|
||||
</row>
|
||||
<row>
|
||||
<label value="&folderQuotaUsage.label;"/>
|
||||
<description id="quotaUsedFree"/>
|
||||
</row>
|
||||
<row align="center">
|
||||
<label value="&folderQuotaStatus.label;"/>
|
||||
<hbox align="center">
|
||||
<progressmeter id="quotaPercentageBar" mode="determined" value="0%"/>
|
||||
<label id="quotaPercentUsed"/>
|
||||
</hbox>
|
||||
</row>
|
||||
</rows>
|
||||
</grid>
|
||||
</vbox>
|
||||
</tabpanels>
|
||||
</tabbox>
|
||||
|
||||
|
@ -18,14 +18,18 @@
|
||||
-
|
||||
- Contributor(s): David Bienvenu <bienvenu@netscape.com>
|
||||
- Mohan Bhamidipati <mohanb@netscape.com>
|
||||
- Lorenzo Colitti <lorenzo@colitti.com>
|
||||
-->
|
||||
|
||||
<!ENTITY folderProps.windowtitle.label "Properties">
|
||||
|
||||
<!ENTITY generalInfo.label "General Information">
|
||||
<!ENTITY generalInfo.accesskey "G">
|
||||
<!ENTITY folderCharsetTab.label "Default Character Coding:">
|
||||
<!ENTITY folderCharsetOverride.label "Apply default to all messages in the folder (individual message character coding settings and auto-detection will be ignored)">
|
||||
|
||||
<!ENTITY folderOfflineTab.label "Offline">
|
||||
<!ENTITY folderOfflineTab.accesskey "o">
|
||||
<!ENTITY folderOfflineTab.accesskey "O">
|
||||
<!ENTITY folderCheckForNewMessages.label "Check this folder for new messages">
|
||||
|
||||
<!ENTITY offlineFolder.check.label "Select this folder for offline use">
|
||||
@ -39,8 +43,14 @@
|
||||
<!ENTITY folderProps.name.label "Name:">
|
||||
|
||||
<!ENTITY folderSharingTab.label "Sharing">
|
||||
<!ENTITY folderSharingTab.accesskey "s">
|
||||
<!ENTITY folderSharingTab.accesskey "S">
|
||||
<!ENTITY privilegesDesc.label "Share this and other folders with network users and display and set access privileges">
|
||||
<!ENTITY privileges.button.label "Privileges...">
|
||||
<!ENTITY permissionsDesc.label "You have the following permissions:">
|
||||
<!ENTITY folderType.label "Folder Type:">
|
||||
|
||||
<!ENTITY folderQuotaTab.label "Quota">
|
||||
<!ENTITY folderQuotaTab.accesskey "Q">
|
||||
<!ENTITY folderQuotaRoot.label "Quota Root:">
|
||||
<!ENTITY folderQuotaUsage.label "Usage:">
|
||||
<!ENTITY folderQuotaStatus.label "Status:">
|
||||
|
@ -17,6 +17,7 @@
|
||||
#
|
||||
# Contributor(s):
|
||||
# Seth Spitzer <sspitzer@netscape.com>
|
||||
# Lorenzo Colitti <lorenzo@colitti.com>
|
||||
#
|
||||
|
||||
#
|
||||
@ -272,3 +273,7 @@ senderSearchCriteria=Subject or Sender contains:
|
||||
biffNotification_message=%1$S has %2$S new message
|
||||
biffNotification_messages=%1$S has %2$S new messages
|
||||
newMail_Alert_Title=New Messages
|
||||
|
||||
# For the Quota tab in the mail folder properties dialog
|
||||
quotaUsedFree=%S of %S KB used
|
||||
quotaPercentUsed=%S%% full
|
||||
|
@ -20,6 +20,7 @@
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Lorenzo Colitti <lorenzo@colitti.com>
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
@ -69,6 +70,36 @@ interface nsIImapMailFolderSink : nsISupports {
|
||||
attribute boolean folderNeedsSubscribing;
|
||||
attribute boolean folderNeedsAdded;
|
||||
attribute boolean folderVerifiedOnline;
|
||||
|
||||
/**
|
||||
* Whether we have asked the server for this folder's quota information.
|
||||
* If the server supports quotas, this occurs when the folder is opened.
|
||||
*/
|
||||
attribute boolean folderQuotaCommandIssued;
|
||||
|
||||
/**
|
||||
* Indicates whether the server has provided quota information on this folder.
|
||||
* This attribute can be false if the server does not supports quotas, if the folder
|
||||
* has never been opened, or if there are no storage quotas on this folder.
|
||||
* If it is true, the folder has a storage quota and the folderQuotaUsedKB and
|
||||
* folderQuotaMaxKB attributes are set to the values provided by the server.
|
||||
*/
|
||||
attribute boolean folderQuotaDataIsValid;
|
||||
|
||||
/**
|
||||
* The IMAP quota root for this folder, as returned by the GETQUOTAROOT IMAP command.
|
||||
*/
|
||||
attribute ACstring folderQuotaRoot;
|
||||
|
||||
/**
|
||||
* Used space, in kilobytes, on this folder's quota root.
|
||||
*/
|
||||
attribute unsigned long folderQuotaUsedKB;
|
||||
|
||||
/**
|
||||
* Size, in kilobytes, of this folder's quota root.
|
||||
*/
|
||||
attribute unsigned long folderQuotaMaxKB;
|
||||
readonly attribute boolean shouldDownloadAllHeaders;
|
||||
string GetOnlineDelimiter();
|
||||
// Tell mail master about the newly selected mailbox
|
||||
|
@ -20,6 +20,7 @@
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Lorenzo Colitti <lorenzo@colitti.com>
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
@ -43,7 +44,7 @@ interface nsIImapIncomingServer;
|
||||
interface nsIMsgParseMailMsgState;
|
||||
|
||||
// this is a simple interface which allows the imap folder to update some values
|
||||
// that the folder props js code will use to update the sharing tab in the folder props.
|
||||
// that the folder props js code will use to update the sharing and quota tabs in the folder props.
|
||||
|
||||
[scriptable, uuid(239472a2-6e8f-46f0-9507-887998da49e5)]
|
||||
interface nsIMsgImapFolderProps : nsISupports {
|
||||
@ -52,6 +53,26 @@ interface nsIMsgImapFolderProps : nsISupports {
|
||||
void setFolderTypeDescription(in wstring folderTypeDescription);
|
||||
void setFolderPermissions(in wstring permissions);
|
||||
void serverDoesntSupportACL();
|
||||
|
||||
/**
|
||||
* Toggles the display of quota information in the Quota tab of the folder properties.
|
||||
* If on, the quota root, usage, and percentage used are displayed.
|
||||
* If off, a status message is displayed. The status message can be set with setQuotaStatus().
|
||||
* @param showData If true, display the quota root, usage information and usage percentage bar.
|
||||
* If false, display the status message.
|
||||
*/
|
||||
void showQuotaData(in boolean showData);
|
||||
|
||||
/**
|
||||
* Sets the status string displayed in the Quota tab of the folder properties if quota
|
||||
* information is not visible.
|
||||
*/
|
||||
void setQuotaStatus(in AString folderQuotaStatus);
|
||||
|
||||
/**
|
||||
* Updates the quota data displayed in the Quota tab.
|
||||
*/
|
||||
void setQuotaData(in ACString quotaroot, in unsigned long usedKB, in unsigned long maxKB);
|
||||
};
|
||||
|
||||
|
||||
|
@ -16,7 +16,7 @@
|
||||
# Rights Reserved.
|
||||
#
|
||||
# Contributor(s):
|
||||
#
|
||||
# Lorenzo Colitti <lorenzo@colitti.com>
|
||||
|
||||
#
|
||||
# The following are used by the imap code to display progress/status/error messages
|
||||
@ -400,3 +400,15 @@
|
||||
of connections to this server. If so, use the Advanced IMAP Server Settings dialog to \
|
||||
reduce the number of cached connections.
|
||||
|
||||
## @name IMAP_QUOTA_STATUS_FOLDERNOTOPEN
|
||||
## @loc None
|
||||
5095=Quota information is not available because the folder is not open.
|
||||
|
||||
## @name IMAP_QUOTA_STATUS_NOTSUPPORTED
|
||||
## @loc None
|
||||
5096=This server does not support quotas.
|
||||
|
||||
## @name IMAP_QUOTA_STATUS_NOQUOTA
|
||||
## @loc None
|
||||
5097=There are no storage quotas on this folder.
|
||||
|
||||
|
@ -20,6 +20,7 @@
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Lorenzo Colitti <lorenzo@colitti.com>
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
@ -131,7 +132,8 @@ typedef enum {
|
||||
kLiteralPlusCapability = 0x00004000, /* RFC 2088 LITERAL+ extension */
|
||||
kAOLImapCapability = 0x00008000, /* aol imap extensions */
|
||||
kHasLanguageCapability = 0x00010000, /* language extensions */
|
||||
kHasCRAMCapability = 0x00020000 /* CRAM auth extension */
|
||||
kHasCRAMCapability = 0x00020000, /* CRAM auth extension */
|
||||
kQuotaCapability = 0x00040000 /* RFC 2087 quota extension */
|
||||
} eIMAPCapabilityFlag;
|
||||
|
||||
// this used to be part of the connection object class - maybe we should move it into
|
||||
|
@ -22,6 +22,7 @@
|
||||
* Contributor(s):
|
||||
* Pierre Phaneuf <pp@ludusdesign.com>
|
||||
* Seth Spitzer <sspitzer@netscape.com>
|
||||
* Lorenzo Colitti <lorenzo@colitti.com>
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
@ -197,8 +198,12 @@ nsImapMailFolder::nsImapMailFolder() :
|
||||
m_folderNeedsAdded(PR_FALSE),
|
||||
m_folderNeedsACLListed(PR_TRUE),
|
||||
m_performingBiff(PR_FALSE),
|
||||
m_folderQuotaCommandIssued(PR_FALSE),
|
||||
m_folderQuotaDataIsValid(PR_FALSE),
|
||||
m_downloadMessageForOfflineUse(PR_FALSE),
|
||||
m_downloadingFolderForOfflineUse(PR_FALSE)
|
||||
m_downloadingFolderForOfflineUse(PR_FALSE),
|
||||
m_folderQuotaUsedKB(0),
|
||||
m_folderQuotaMaxKB(0)
|
||||
{
|
||||
MOZ_COUNT_CTOR(nsImapMailFolder); // double count these for now.
|
||||
|
||||
@ -4998,15 +5003,15 @@ nsImapMailFolder::FillInFolderProps(nsIMsgImapFolderProps *aFolderProps)
|
||||
NS_ENSURE_ARG(aFolderProps);
|
||||
PRUint32 folderTypeStringID;
|
||||
PRUint32 folderTypeDescStringID = 0;
|
||||
PRUint32 folderQuotaStatusStringID;
|
||||
nsXPIDLString folderType;
|
||||
nsXPIDLString folderTypeDesc;
|
||||
nsXPIDLString folderQuotaStatusDesc;
|
||||
nsCOMPtr<nsIStringBundle> bundle;
|
||||
nsresult rv = IMAPGetStringBundle(getter_AddRefs(bundle));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
// get the host session list and see if this server supports ACL.
|
||||
// If not, just set the folder description to a string that says
|
||||
// the server doesn't support sharing, and return.
|
||||
// get the host session list and get server capabilities.
|
||||
PRUint32 capability = kCapabilityUndefined;
|
||||
|
||||
nsCOMPtr<nsIImapHostSessionList> hostSession = do_GetService(kCImapHostSessionList, &rv);
|
||||
@ -5017,6 +5022,59 @@ nsImapMailFolder::FillInFolderProps(nsIMsgImapFolderProps *aFolderProps)
|
||||
GetServerKey(getter_Copies(serverKey));
|
||||
hostSession->GetCapabilityForHost(serverKey, capability);
|
||||
|
||||
// Figure out what to display in the Quota tab of the folder properties.
|
||||
// Does the server support quotas?
|
||||
if(capability & kQuotaCapability)
|
||||
{
|
||||
// Have we asked the server for quota information?
|
||||
if(m_folderQuotaCommandIssued)
|
||||
{
|
||||
// Has the server replied with storage quota info?
|
||||
if(m_folderQuotaDataIsValid)
|
||||
{
|
||||
// If so, set quota data
|
||||
folderQuotaStatusStringID = 0;
|
||||
aFolderProps->SetQuotaData(m_folderQuotaRoot, m_folderQuotaUsedKB, m_folderQuotaMaxKB);
|
||||
}
|
||||
else
|
||||
{
|
||||
// If not, there is no storage quota set on this folder
|
||||
folderQuotaStatusStringID = IMAP_QUOTA_STATUS_NOQUOTA;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// The folder is not open, so no quota information is available
|
||||
folderQuotaStatusStringID = IMAP_QUOTA_STATUS_FOLDERNOTOPEN;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Either the server doesn't support quotas, or we don't know if it does
|
||||
// (e.g., because we don't have a connection yet). If the latter, we fall back
|
||||
// to saying that no information is available because the folder is not open.
|
||||
folderQuotaStatusStringID = (capability == kCapabilityUndefined) ?
|
||||
IMAP_QUOTA_STATUS_FOLDERNOTOPEN : IMAP_QUOTA_STATUS_NOTSUPPORTED;
|
||||
}
|
||||
|
||||
if(folderQuotaStatusStringID == 0)
|
||||
{
|
||||
// Display quota data
|
||||
aFolderProps->ShowQuotaData(PR_TRUE);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Hide quota data and show reason why it is not available
|
||||
aFolderProps->ShowQuotaData(PR_FALSE);
|
||||
|
||||
rv = IMAPGetStringByID(folderQuotaStatusStringID, getter_Copies(folderQuotaStatusDesc));
|
||||
if (NS_SUCCEEDED(rv))
|
||||
aFolderProps->SetQuotaStatus(folderQuotaStatusDesc);
|
||||
}
|
||||
|
||||
// See if the server supports ACL.
|
||||
// If not, just set the folder description to a string that says
|
||||
// the server doesn't support sharing, and return.
|
||||
if (! (capability & kACLCapability))
|
||||
{
|
||||
rv = IMAPGetStringByID(IMAP_SERVER_DOESNT_SUPPORT_ACL, getter_Copies(folderTypeDesc));
|
||||
@ -6794,6 +6852,70 @@ NS_IMETHODIMP nsImapMailFolder::SetFolderVerifiedOnline(PRBool bVal)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsImapMailFolder::GetFolderQuotaCommandIssued(PRBool *aCmdIssued)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aCmdIssued);
|
||||
*aCmdIssued = m_folderQuotaCommandIssued;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsImapMailFolder::SetFolderQuotaCommandIssued(PRBool aCmdIssued)
|
||||
{
|
||||
m_folderQuotaCommandIssued = aCmdIssued;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsImapMailFolder::GetFolderQuotaDataIsValid(PRBool *aIsValid)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aIsValid);
|
||||
*aIsValid = m_folderQuotaDataIsValid;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsImapMailFolder::SetFolderQuotaDataIsValid(PRBool aIsValid)
|
||||
{
|
||||
m_folderQuotaDataIsValid = aIsValid;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsImapMailFolder::GetFolderQuotaRoot(nsACString &aQuotaRoot)
|
||||
{
|
||||
aQuotaRoot = m_folderQuotaRoot;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsImapMailFolder::SetFolderQuotaRoot(const nsACString &aQuotaRoot)
|
||||
{
|
||||
m_folderQuotaRoot = aQuotaRoot;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsImapMailFolder::GetFolderQuotaUsedKB(PRUint32 *aUsedKB)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aUsedKB);
|
||||
*aUsedKB = m_folderQuotaUsedKB;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsImapMailFolder::SetFolderQuotaUsedKB(PRUint32 aUsedKB)
|
||||
{
|
||||
m_folderQuotaUsedKB = aUsedKB;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsImapMailFolder::GetFolderQuotaMaxKB(PRUint32 *aMaxKB)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aMaxKB);
|
||||
*aMaxKB = m_folderQuotaMaxKB;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsImapMailFolder::SetFolderQuotaMaxKB(PRUint32 aMaxKB)
|
||||
{
|
||||
m_folderQuotaMaxKB = aMaxKB;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsImapMailFolder::PerformExpand(nsIMsgWindow *aMsgWindow)
|
||||
{
|
||||
nsresult rv;
|
||||
|
@ -20,6 +20,7 @@
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Lorenzo Colitti <lorenzo@colitti.com>
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
@ -478,6 +479,8 @@ protected:
|
||||
PRPackedBool m_folderNeedsAdded;
|
||||
PRPackedBool m_folderNeedsACLListed;
|
||||
PRPackedBool m_performingBiff;
|
||||
PRPackedBool m_folderQuotaCommandIssued;
|
||||
PRPackedBool m_folderQuotaDataIsValid;
|
||||
|
||||
nsMsgIMAPFolderACL *m_folderACL;
|
||||
|
||||
@ -488,6 +491,11 @@ protected:
|
||||
// offline imap support
|
||||
PRBool m_downloadMessageForOfflineUse;
|
||||
PRBool m_downloadingFolderForOfflineUse;
|
||||
|
||||
// Quota support
|
||||
nsCString m_folderQuotaRoot;
|
||||
PRUint32 m_folderQuotaUsedKB;
|
||||
PRUint32 m_folderQuotaMaxKB;
|
||||
};
|
||||
|
||||
|
||||
|
@ -22,6 +22,7 @@
|
||||
* Contributor(s):
|
||||
* Pierre Phaneuf <pp@ludusdesign.com>
|
||||
* Henry Jia <Henry.Jia@sun.com>
|
||||
* Lorenzo Colitti <lorenzo@colitti.com>
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
@ -3410,6 +3411,16 @@ void nsImapProtocol::ProcessMailboxUpdate(PRBool handlePossibleUndo)
|
||||
{
|
||||
if (DeathSignalReceived())
|
||||
return;
|
||||
|
||||
// Update quota information
|
||||
if (!DeathSignalReceived())
|
||||
{
|
||||
char *boxName;
|
||||
GetSelectedMailboxName(&boxName);
|
||||
GetQuotaDataIfSupported(boxName);
|
||||
PR_Free(boxName);
|
||||
}
|
||||
|
||||
// fetch the flags and uids of all existing messages or new ones
|
||||
if (!DeathSignalReceived() && GetServerStateParser().NumberOfMessages())
|
||||
{
|
||||
@ -7364,6 +7375,38 @@ PRBool nsImapProtocol::TryToLogon()
|
||||
return loginSucceeded;
|
||||
}
|
||||
|
||||
void nsImapProtocol::UpdateFolderQuotaData(nsCString& aQuotaRoot, PRUint32 aUsed, PRUint32 aMax)
|
||||
{
|
||||
NS_ASSERTION(m_imapMailFolderSink, "m_imapMailFolderSink is null!");
|
||||
|
||||
m_imapMailFolderSink->SetFolderQuotaDataIsValid(PR_TRUE);
|
||||
m_imapMailFolderSink->SetFolderQuotaRoot(aQuotaRoot);
|
||||
m_imapMailFolderSink->SetFolderQuotaUsedKB(aUsed);
|
||||
m_imapMailFolderSink->SetFolderQuotaMaxKB(aMax);
|
||||
}
|
||||
|
||||
void nsImapProtocol::GetQuotaDataIfSupported(const char *aBoxName)
|
||||
{
|
||||
// If server doesn't have quota support, don't do anything
|
||||
if (! (GetServerStateParser().GetCapabilityFlag() & kQuotaCapability))
|
||||
return;
|
||||
|
||||
IncrementCommandTagNumber();
|
||||
|
||||
nsCAutoString quotacommand;
|
||||
quotacommand = nsDependentCString(GetServerCommandTag())
|
||||
+ NS_LITERAL_CSTRING(" getquotaroot \"")
|
||||
+ nsDependentCString(aBoxName)
|
||||
+ NS_LITERAL_CSTRING("\"" CRLF);
|
||||
|
||||
NS_ASSERTION(m_imapMailFolderSink, "m_imapMailFolderSink is null!");
|
||||
m_imapMailFolderSink->SetFolderQuotaCommandIssued(PR_TRUE);
|
||||
|
||||
nsresult quotarv = SendData(quotacommand.get());
|
||||
if (NS_SUCCEEDED(quotarv))
|
||||
ParseIMAPandCheckForNewMail();
|
||||
}
|
||||
|
||||
PRBool
|
||||
nsImapProtocol::GetDeleteIsMoveToTrash()
|
||||
{
|
||||
|
@ -20,6 +20,7 @@
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Lorenzo Colitti <lorenzo@colitti.com>
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
@ -369,6 +370,9 @@ public:
|
||||
void SetCopyResponseUid(nsMsgKeyArray* aKeyArray,
|
||||
const char* msgIdString);
|
||||
|
||||
// Quota support
|
||||
void UpdateFolderQuotaData(nsCString& aQuotaRoot, PRUint32 aUsed, PRUint32 aMax);
|
||||
|
||||
private:
|
||||
// the following flag is used to determine when a url is currently being run. It is cleared when we
|
||||
// finish processng a url and it is set whenever we call Load on a url
|
||||
@ -596,6 +600,9 @@ private:
|
||||
nsresult GetMsgWindow(nsIMsgWindow ** aMsgWindow);
|
||||
// End Process AuthenticatedState Url helper methods
|
||||
|
||||
// Quota support
|
||||
void GetQuotaDataIfSupported(const char *aBoxName);
|
||||
|
||||
PRBool m_trackingTime;
|
||||
PRTime m_startTime;
|
||||
PRTime m_endTime;
|
||||
|
@ -21,6 +21,7 @@
|
||||
*
|
||||
* Contributor(s):
|
||||
* Pierre Phaneuf <pp@ludusdesign.com>
|
||||
* Lorenzo Colitti <lorenzo@colitti.com>
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
@ -713,6 +714,12 @@ void nsImapServerResponseParser::response_data()
|
||||
SetSyntaxError(PR_TRUE);
|
||||
}
|
||||
break;
|
||||
case 'Q':
|
||||
if (!PL_strcasecmp(fNextToken, "QUOTAROOT") || !PL_strcasecmp(fNextToken, "QUOTA"))
|
||||
quota_data();
|
||||
else
|
||||
SetSyntaxError(PR_TRUE);
|
||||
break;
|
||||
default:
|
||||
if (IsNumericString(fNextToken))
|
||||
numeric_mailbox_data();
|
||||
@ -2105,6 +2112,8 @@ void nsImapServerResponseParser::capability_data()
|
||||
fCapabilityFlag |= kLiteralPlusCapability;
|
||||
else if (! PL_strcasecmp(fNextToken, "XAOL-OPTION"))
|
||||
fCapabilityFlag |= kAOLImapCapability;
|
||||
else if (! PL_strcasecmp(fNextToken, "QUOTA"))
|
||||
fCapabilityFlag |= kQuotaCapability;
|
||||
else if (! PL_strcasecmp(fNextToken, "LANGUAGE"))
|
||||
fCapabilityFlag |= kHasLanguageCapability;
|
||||
}
|
||||
@ -2509,6 +2518,57 @@ void nsImapServerResponseParser::bodystructure_data()
|
||||
SetSyntaxError(PR_TRUE);
|
||||
}
|
||||
|
||||
void nsImapServerResponseParser::quota_data()
|
||||
{
|
||||
if (!PL_strcasecmp(fNextToken, "QUOTAROOT"))
|
||||
skip_to_CRLF();
|
||||
else if(!PL_strcasecmp(fNextToken, "QUOTA"))
|
||||
{
|
||||
PRUint32 used, max;
|
||||
nsCString quotaroot;
|
||||
char *parengroup;
|
||||
|
||||
fNextToken = GetNextToken();
|
||||
if (! fNextToken)
|
||||
SetSyntaxError(PR_TRUE);
|
||||
else
|
||||
{
|
||||
quotaroot = CreateAstring();
|
||||
|
||||
if(ContinueParse() && !at_end_of_line())
|
||||
{
|
||||
fNextToken = GetNextToken();
|
||||
if(fNextToken)
|
||||
{
|
||||
if(!PL_strcasecmp(fNextToken, "(STORAGE"))
|
||||
{
|
||||
parengroup = CreateParenGroup();
|
||||
if(parengroup && (PR_sscanf(parengroup, "(STORAGE %lu %lu)", &used, &max) == 2) )
|
||||
{
|
||||
fServerConnection.UpdateFolderQuotaData(quotaroot, used, max);
|
||||
skip_to_CRLF();
|
||||
}
|
||||
else
|
||||
SetSyntaxError(PR_TRUE);
|
||||
|
||||
if(parengroup)
|
||||
PR_Free(parengroup);
|
||||
}
|
||||
else
|
||||
// Ignore other limits, we just check STORAGE for now
|
||||
skip_to_CRLF();
|
||||
}
|
||||
else
|
||||
SetSyntaxError(PR_TRUE);
|
||||
}
|
||||
else
|
||||
HandleMemoryFailure();
|
||||
}
|
||||
}
|
||||
else
|
||||
SetSyntaxError(PR_TRUE);
|
||||
}
|
||||
|
||||
PRBool nsImapServerResponseParser::GetFillingInShell()
|
||||
{
|
||||
return (m_shell != nsnull);
|
||||
|
@ -20,6 +20,7 @@
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Lorenzo Colitti <lorenzo@colitti.com>
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
@ -192,6 +193,7 @@ protected:
|
||||
virtual void mime_data();
|
||||
virtual void mime_part_data();
|
||||
virtual void mime_header_data();
|
||||
virtual void quota_data();
|
||||
virtual void msg_fetch();
|
||||
virtual void msg_obsolete();
|
||||
virtual void msg_fetch_headers(const char *partNum);
|
||||
|
@ -19,6 +19,7 @@
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Lorenzo Colitti <lorenzo@colitti.com>
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
@ -130,4 +131,7 @@ NS_END_EXTERN_C
|
||||
#define IMAP_REDIRECT_LOGIN_FAILED 5091
|
||||
#define IMAP_SUBSCRIBE_PROMPT 5092
|
||||
#define IMAP_SERVER_DROPPED_CONNECTION 5093
|
||||
#define IMAP_QUOTA_STATUS_FOLDERNOTOPEN 5095
|
||||
#define IMAP_QUOTA_STATUS_NOTSUPPORTED 5096
|
||||
#define IMAP_QUOTA_STATUS_NOQUOTA 5097
|
||||
#endif /* _nsImapStringBundle_H__ */
|
||||
|
Loading…
Reference in New Issue
Block a user