mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-10 20:05:49 +00:00
94968 r=bienvenu sr=sspitzer. Add error messages in cases where filter disables itself because it cannot
find the folder or filtering fails due to some other reasons.
This commit is contained in:
parent
0e84f2c2c0
commit
d9dc0205f3
@ -384,6 +384,8 @@ const nsMsgBiffState nsMsgBiffState_Unknown = 2; // We dunno whether there is ne
|
||||
boolean matchOrChangeFilterDestination(in nsIMsgFolder folder, in boolean caseInsensitive);
|
||||
boolean confirmFolderDeletionForFilter(in nsIMsgWindow msgWindow);
|
||||
void alertFilterChanged(in nsIMsgWindow msgWindow);
|
||||
void throwAlertMsg(in string msgName, in nsIMsgWindow msgWindow);
|
||||
wstring getStringWithFolderNameFromBundle(in string msgName);
|
||||
void notifyCompactCompleted();
|
||||
|
||||
attribute nsIMsgRetentionSettings retentionSettings;
|
||||
|
@ -66,9 +66,12 @@ compactingFolder=Compacting folder %S...
|
||||
autoCompactAllFolders=Do you wish to compact all local and offline folders to save disk space?
|
||||
confirmFolderDeletionForFilter=Deleting the folder '%S' will disable its associated filter(s). Are you sure you want to delete the folder?
|
||||
alertFilterChanged=Filters associated with this folder will be updated.
|
||||
filterDisabled=The folder '%S' could not be found, so filter(s) associated with this folder will be disabled. Verify that the folder exists, and that filters point to a valid destination folder.
|
||||
filterFolderDeniedLocked=The messages could not be filtered to folder '%S' because another operation is in progress.
|
||||
alertFilterCheckbox=Do not warn me again.
|
||||
compactFolderDeniedLock=The folder '%S' cannot be compacted because another operation is in progress. Please try again later.
|
||||
compactFolderWriteFailed=The folder '%S' could not be compacted because writing to folder failed. Verify that you have enough disk space, and that you have write privileges to the file system, then try again.
|
||||
filterFolderWriteFailed=The messages could not be filtered to folder '%S' because writing to folder failed. Verify that you have enough disk space, and that you have write privileges to the file system, then try again.
|
||||
|
||||
# LOCALIZATION NOTES(verboseFolderFormat): %1$S is folder name, %2$S is server name
|
||||
verboseFolderFormat=%1$S on %2$S
|
||||
|
@ -38,6 +38,7 @@
|
||||
#include "nsISupports.idl"
|
||||
#include "nsMsgFilterCore.idl"
|
||||
#include "nsIMsgFilter.idl"
|
||||
interface nsIMsgWindow;
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// nsIMsgFilterHitNotify is an interface designed to make evaluating filters
|
||||
@ -54,6 +55,6 @@
|
||||
[scriptable, uuid(c9f15174-1f3f-11d3-a51b-0060b0fc04b7)]
|
||||
interface nsIMsgFilterHitNotify : nsISupports {
|
||||
|
||||
boolean ApplyFilterHit(in nsIMsgFilter filter);
|
||||
boolean applyFilterHit(in nsIMsgFilter filter, in nsIMsgWindow msgWindow);
|
||||
};
|
||||
|
||||
|
@ -166,7 +166,7 @@ nsMsgFilterList::ApplyFiltersToHdr(nsMsgFilterTypeType filterType,
|
||||
{
|
||||
PRBool applyMore;
|
||||
|
||||
ret = listener->ApplyFilterHit(filter, &applyMore);
|
||||
ret = listener->ApplyFilterHit(filter, msgWindow, &applyMore);
|
||||
if (!NS_SUCCEEDED(ret) || !applyMore)
|
||||
break;
|
||||
}
|
||||
|
@ -216,38 +216,6 @@ nsFolderCompactState::CompactHelper(nsIMsgFolder *folder)
|
||||
return rv;
|
||||
}
|
||||
|
||||
|
||||
|
||||
#define MESSENGER_STRING_URL "chrome://messenger/locale/messenger.properties"
|
||||
|
||||
nsresult nsFolderCompactState::GetStringBundle(nsIStringBundle **aBundle)
|
||||
{
|
||||
nsCOMPtr<nsIStringBundle> stringBundle;
|
||||
nsresult res = NS_OK;
|
||||
|
||||
nsCOMPtr<nsIStringBundleService> sBundleService =
|
||||
do_GetService(kStringBundleServiceCID, &res);
|
||||
if (NS_SUCCEEDED(res) && (nsnull != sBundleService))
|
||||
{
|
||||
res = sBundleService->CreateBundle(MESSENGER_STRING_URL, getter_AddRefs(stringBundle));
|
||||
}
|
||||
*aBundle = stringBundle;
|
||||
NS_IF_ADDREF(*aBundle);
|
||||
return res;
|
||||
}
|
||||
|
||||
nsresult nsFolderCompactState::GetStatusFromMsgName(const char *statusMsgName, PRUnichar ** retval)
|
||||
{
|
||||
nsCOMPtr<nsIStringBundle> stringBundle;
|
||||
nsresult res = NS_OK;
|
||||
res = GetStringBundle(getter_AddRefs(stringBundle));
|
||||
if (stringBundle && NS_SUCCEEDED(res))
|
||||
{
|
||||
res = stringBundle->GetStringFromName(NS_ConvertASCIItoUCS2(statusMsgName).get(), retval);
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
nsresult nsFolderCompactState::ShowStatusMsg(const PRUnichar *aMsg)
|
||||
{
|
||||
nsCOMPtr <nsIMsgStatusFeedback> statusFeedback;
|
||||
@ -300,49 +268,10 @@ nsFolderCompactState::Init(nsIMsgFolder *folder, const char *baseMsgUri, nsIMsgD
|
||||
|
||||
void nsFolderCompactState::ShowCompactingStatusMsg()
|
||||
{
|
||||
nsXPIDLString formatString;
|
||||
|
||||
nsresult rv = GetStatusFromMsgName("compactingFolder", getter_Copies(formatString));
|
||||
if (NS_SUCCEEDED(rv))
|
||||
{
|
||||
nsXPIDLString folderName;
|
||||
m_folder->GetName(getter_Copies(folderName));
|
||||
PRUnichar *u = nsTextFormatter::smprintf((const PRUnichar *) formatString, (const PRUnichar *) folderName);
|
||||
if (u)
|
||||
ShowStatusMsg(u);
|
||||
PR_FREEIF(u);
|
||||
}
|
||||
}
|
||||
|
||||
void nsFolderCompactState::ThrowAlertMsg(const char *alertMsgName)
|
||||
{
|
||||
nsresult rv=NS_OK;
|
||||
nsXPIDLString folderName;
|
||||
m_folder->GetName(getter_Copies(folderName));
|
||||
nsCOMPtr<nsIDocShell> docShell;
|
||||
if (m_window)
|
||||
m_window->GetRootDocShell(getter_AddRefs(docShell));
|
||||
if (docShell)
|
||||
{
|
||||
nsCOMPtr<nsIStringBundle> bundle;
|
||||
rv = GetStringBundle(getter_AddRefs(bundle));
|
||||
if (NS_SUCCEEDED(rv) && bundle)
|
||||
{
|
||||
const PRUnichar *formatStrings[] =
|
||||
{
|
||||
folderName
|
||||
};
|
||||
nsXPIDLString alertString;
|
||||
nsAutoString alertTemplate;
|
||||
alertTemplate.AssignWithConversion(alertMsgName);
|
||||
rv = bundle->FormatStringFromName(alertTemplate.get(),
|
||||
formatStrings, 1,
|
||||
getter_Copies(alertString));
|
||||
nsCOMPtr<nsIPrompt> dialog(do_GetInterface(docShell));
|
||||
if (dialog && alertString)
|
||||
dialog->Alert(nsnull, alertString);
|
||||
}
|
||||
}
|
||||
nsXPIDLString statusString;
|
||||
nsresult rv = m_folder->GetStringWithFolderNameFromBundle("compactingFolder", getter_Copies(statusString));
|
||||
if (statusString && NS_SUCCEEDED(rv))
|
||||
ShowStatusMsg(statusString);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsFolderCompactState::StartCompacting()
|
||||
@ -355,9 +284,8 @@ NS_IMETHODIMP nsFolderCompactState::StartCompacting()
|
||||
m_folder->AcquireSemaphore(supports);
|
||||
else
|
||||
{
|
||||
NS_ASSERTION(0, "Some other operation is in progress on this folder");
|
||||
m_folder->NotifyCompactCompleted();
|
||||
ThrowAlertMsg("compactFolderDeniedLock");
|
||||
m_folder->ThrowAlertMsg("compactFolderDeniedLock", m_window);
|
||||
if (m_compactAll)
|
||||
CompactNextFolder();
|
||||
else
|
||||
@ -579,11 +507,9 @@ nsFolderCompactState::OnDataAvailable(nsIRequest *request, nsISupports *ctxt,
|
||||
{
|
||||
writeCount = m_fileStream->write(m_dataBuffer, readCount);
|
||||
count -= readCount;
|
||||
NS_ASSERTION (writeCount == readCount,
|
||||
"Oops, write fail, folder can be corrupted!\n");
|
||||
if (writeCount != readCount)
|
||||
{
|
||||
ThrowAlertMsg("compactFolderWriteFailed");
|
||||
m_folder->ThrowAlertMsg("compactFolderWriteFailed", m_window);
|
||||
return NS_MSG_ERROR_WRITING_MAIL_FOLDER;
|
||||
}
|
||||
}
|
||||
|
@ -70,9 +70,6 @@ public:
|
||||
|
||||
nsresult GetMessage(nsIMsgDBHdr **message);
|
||||
nsresult BuildMessageURI(const char *baseURI, PRUint32 key, nsCString& uri);
|
||||
nsresult GetStatusFromMsgName(const char *statusMsgName, PRUnichar ** retval);
|
||||
nsresult GetStringBundle(nsIStringBundle **stringBundle);
|
||||
void ThrowAlertMsg(const char* alertMsgName);
|
||||
nsresult ShowStatusMsg(const PRUnichar *aMsg);
|
||||
nsresult ReleaseFolderLock();
|
||||
void ShowCompactingStatusMsg();
|
||||
|
@ -2673,8 +2673,8 @@ nsMsgFolder::ThrowConfirmationPrompt(nsIMsgWindow *msgWindow, const PRUnichar *c
|
||||
return rv;
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP nsMsgFolder::ConfirmFolderDeletionForFilter(nsIMsgWindow *msgWindow, PRBool *confirmed)
|
||||
NS_IMETHODIMP
|
||||
nsMsgFolder::GetStringWithFolderNameFromBundle(const char *msgName, PRUnichar **aResult)
|
||||
{
|
||||
nsCOMPtr <nsIStringBundle> bundle;
|
||||
nsresult rv = GetBaseStringBundle(getter_AddRefs(bundle));
|
||||
@ -2686,18 +2686,41 @@ NS_IMETHODIMP nsMsgFolder::ConfirmFolderDeletionForFilter(nsIMsgWindow *msgWindo
|
||||
{
|
||||
folderName
|
||||
};
|
||||
nsXPIDLString confirmString;
|
||||
rv = bundle->FormatStringFromName(NS_ConvertASCIItoUCS2("confirmFolderDeletionForFilter").get(),
|
||||
formatStrings, 1,
|
||||
getter_Copies(confirmString));
|
||||
rv = bundle->FormatStringFromName(NS_ConvertASCIItoUCS2(msgName).get(),
|
||||
formatStrings, 1, aResult);
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsMsgFolder::ConfirmFolderDeletionForFilter(nsIMsgWindow *msgWindow, PRBool *confirmed)
|
||||
{
|
||||
nsXPIDLString confirmString;
|
||||
nsresult rv = GetStringWithFolderNameFromBundle("confirmFolderDeletionForFilter", getter_Copies(confirmString));
|
||||
if (NS_SUCCEEDED(rv) && confirmString)
|
||||
rv = ThrowConfirmationPrompt(msgWindow, confirmString.get(), confirmed);
|
||||
return rv;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsMsgFolder::ThrowAlertMsg(const char*msgName, nsIMsgWindow *msgWindow)
|
||||
{
|
||||
nsXPIDLString alertString;
|
||||
nsresult rv = GetStringWithFolderNameFromBundle(msgName, getter_Copies(alertString));
|
||||
if (NS_SUCCEEDED(rv) && alertString && msgWindow)
|
||||
{
|
||||
nsCOMPtr <nsIDocShell> docShell;
|
||||
msgWindow->GetRootDocShell(getter_AddRefs(docShell));
|
||||
if (docShell)
|
||||
{
|
||||
nsCOMPtr<nsIPrompt> dialog(do_GetInterface(docShell));
|
||||
if (dialog && alertString)
|
||||
dialog->Alert(nsnull, alertString);
|
||||
}
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsMsgFolder::AlertFilterChanged(nsIMsgWindow *msgWindow)
|
||||
{
|
||||
{ //this is a different alert i.e alert w/ checkbox.
|
||||
nsresult rv = NS_OK;
|
||||
PRBool checkBox=PR_FALSE;
|
||||
GetWarnFilterChanged(&checkBox);
|
||||
|
@ -194,6 +194,8 @@ public:
|
||||
NS_IMETHOD NotifyCompactCompleted();
|
||||
NS_IMETHOD ConfirmFolderDeletionForFilter(nsIMsgWindow *msgWindow, PRBool *confirmed);
|
||||
NS_IMETHOD AlertFilterChanged(nsIMsgWindow *msgWindow);
|
||||
NS_IMETHOD ThrowAlertMsg(const char* msgName, nsIMsgWindow *msgWindow);
|
||||
NS_IMETHOD GetStringWithFolderNameFromBundle(const char* msgName, PRUnichar **aResult);
|
||||
|
||||
// end NS_DECL_NSIMSGFOLDER
|
||||
|
||||
|
@ -2693,7 +2693,7 @@ NS_IMETHODIMP nsImapMailFolder::EndMessage(nsMsgKey key)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsImapMailFolder::ApplyFilterHit(nsIMsgFilter *filter, PRBool *applyMore)
|
||||
NS_IMETHODIMP nsImapMailFolder::ApplyFilterHit(nsIMsgFilter *filter, nsIMsgWindow *msgWindow, PRBool *applyMore)
|
||||
{
|
||||
nsMsgRuleActionType actionType;
|
||||
nsXPIDLCString actionTargetFolderUri;
|
||||
@ -2808,7 +2808,7 @@ NS_IMETHODIMP nsImapMailFolder::ApplyFilterHit(nsIMsgFilter *filter, PRBool *app
|
||||
PR_FREEIF(tmp);
|
||||
#endif
|
||||
}
|
||||
nsresult err = MoveIncorporatedMessage(msgHdr, mDatabase, actionTargetFolderUri, filter);
|
||||
nsresult err = MoveIncorporatedMessage(msgHdr, mDatabase, actionTargetFolderUri, filter, msgWindow);
|
||||
if (NS_SUCCEEDED(err))
|
||||
m_msgMovedByFilter = PR_TRUE;
|
||||
}
|
||||
@ -2979,7 +2979,8 @@ NS_IMETHODIMP nsImapMailFolder::LiteSelect(nsIUrlListener *aUrlListener)
|
||||
nsresult nsImapMailFolder::MoveIncorporatedMessage(nsIMsgDBHdr *mailHdr,
|
||||
nsIMsgDatabase *sourceDB,
|
||||
const char *destFolderUri,
|
||||
nsIMsgFilter *filter)
|
||||
nsIMsgFilter *filter,
|
||||
nsIMsgWindow *msgWindow)
|
||||
{
|
||||
nsresult err = NS_OK;
|
||||
|
||||
@ -3008,6 +3009,7 @@ nsresult nsImapMailFolder::MoveIncorporatedMessage(nsIMsgDBHdr *mailHdr,
|
||||
if (!parentFolder || !canFileMessages)
|
||||
{
|
||||
filter->SetEnabled(PR_FALSE);
|
||||
destIFolder->ThrowAlertMsg("filterDisabled",msgWindow);
|
||||
return NS_MSG_NOT_A_MAIL_FOLDER;
|
||||
}
|
||||
// put the header into the source db, since it needs to be there when we copy it
|
||||
|
@ -274,13 +274,14 @@ public:
|
||||
PRBool copySucceeded);
|
||||
NS_IMETHOD MatchName(nsString *name, PRBool *matches);
|
||||
// nsIMsgFilterHitNotification method(s)
|
||||
NS_IMETHOD ApplyFilterHit(nsIMsgFilter *filter, PRBool *applyMore);
|
||||
NS_IMETHOD ApplyFilterHit(nsIMsgFilter *filter, nsIMsgWindow *msgWindow, PRBool *applyMore);
|
||||
NS_IMETHOD IsCommandEnabled(const char *command, PRBool *result);
|
||||
|
||||
nsresult MoveIncorporatedMessage(nsIMsgDBHdr *mailHdr,
|
||||
nsIMsgDatabase *sourceDB,
|
||||
const char *destFolder,
|
||||
nsIMsgFilter *filter);
|
||||
nsIMsgFilter *filter,
|
||||
nsIMsgWindow *msgWindow);
|
||||
static nsresult AllocateUidStringFromKeys(nsMsgKey *keys, PRInt32 numKeys, nsCString &msgIds);
|
||||
protected:
|
||||
// Helper methods
|
||||
|
@ -1648,7 +1648,7 @@ void nsParseNewMailState::ApplyFilters(PRBool *pMoved, nsIMsgWindow *msgWindow)
|
||||
*pMoved = m_msgMovedByFilter;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsParseNewMailState::ApplyFilterHit(nsIMsgFilter *filter, PRBool *applyMore)
|
||||
NS_IMETHODIMP nsParseNewMailState::ApplyFilterHit(nsIMsgFilter *filter, nsIMsgWindow *msgWindow, PRBool *applyMore)
|
||||
{
|
||||
nsMsgRuleActionType actionType;
|
||||
nsXPIDLCString actionTargetFolderUri;
|
||||
@ -1739,7 +1739,7 @@ NS_IMETHODIMP nsParseNewMailState::ApplyFilterHit(nsIMsgFilter *filter, PRBool *
|
||||
tmp = (char*) cc.value;
|
||||
PR_FREEIF(tmp);
|
||||
}
|
||||
nsresult err = MoveIncorporatedMessage(msgHdr, m_mailDB, (const char *) actionTargetFolderUri, filter);
|
||||
nsresult err = MoveIncorporatedMessage(msgHdr, m_mailDB, (const char *) actionTargetFolderUri, filter, msgWindow);
|
||||
if (NS_SUCCEEDED(err))
|
||||
m_msgMovedByFilter = PR_TRUE;
|
||||
|
||||
@ -1793,7 +1793,8 @@ int nsParseNewMailState::MarkFilteredMessageRead(nsIMsgDBHdr *msgHdr)
|
||||
nsresult nsParseNewMailState::MoveIncorporatedMessage(nsIMsgDBHdr *mailHdr,
|
||||
nsIMsgDatabase *sourceDB,
|
||||
const char *destFolderUri,
|
||||
nsIMsgFilter *filter)
|
||||
nsIMsgFilter *filter,
|
||||
nsIMsgWindow *msgWindow)
|
||||
{
|
||||
nsresult err = 0;
|
||||
nsIOFileStream *destFile;
|
||||
@ -1818,6 +1819,7 @@ nsresult nsParseNewMailState::MoveIncorporatedMessage(nsIMsgDBHdr *mailHdr,
|
||||
if (!parentFolder || !canFileMessages)
|
||||
{
|
||||
filter->SetEnabled(PR_FALSE);
|
||||
destIFolder->ThrowAlertMsg("filterDisabled", msgWindow);
|
||||
return NS_MSG_NOT_A_MAIL_FOLDER;
|
||||
}
|
||||
|
||||
@ -1836,7 +1838,7 @@ nsresult nsParseNewMailState::MoveIncorporatedMessage(nsIMsgDBHdr *mailHdr,
|
||||
// Make sure no one else is writing into this folder
|
||||
if (destIFolder && (err = destIFolder->AcquireSemaphore (myISupports)) != 0)
|
||||
{
|
||||
NS_ASSERTION(PR_FALSE, "why is this folder busy?");
|
||||
destIFolder->ThrowAlertMsg("filterFolderDeniedLocked", msgWindow);
|
||||
return err;
|
||||
}
|
||||
|
||||
@ -1867,6 +1869,7 @@ nsresult nsParseNewMailState::MoveIncorporatedMessage(nsIMsgDBHdr *mailHdr,
|
||||
#endif
|
||||
if (destIFolder)
|
||||
destIFolder->ReleaseSemaphore (myISupports);
|
||||
destIFolder->ThrowAlertMsg("filterFolderWriteFailed", msgWindow);
|
||||
return NS_MSG_ERROR_WRITING_MAIL_FOLDER;
|
||||
}
|
||||
|
||||
@ -1916,7 +1919,7 @@ nsresult nsParseNewMailState::MoveIncorporatedMessage(nsIMsgDBHdr *mailHdr,
|
||||
|
||||
if (destMailDB)
|
||||
destMailDB->Close(PR_TRUE);
|
||||
|
||||
destIFolder->ThrowAlertMsg("filterFolderWriteFailed", msgWindow);
|
||||
return NS_MSG_ERROR_WRITING_MAIL_FOLDER; // caller (ApplyFilters) currently ignores error conditions
|
||||
}
|
||||
|
||||
|
@ -251,7 +251,7 @@ public:
|
||||
PRBool *pMoved);
|
||||
#endif
|
||||
// nsIMsgFilterHitNotification method(s)
|
||||
NS_IMETHOD ApplyFilterHit(nsIMsgFilter *filter, PRBool *applyMore);
|
||||
NS_IMETHOD ApplyFilterHit(nsIMsgFilter *filter, nsIMsgWindow *msgWindow, PRBool *applyMore);
|
||||
|
||||
nsOutputFileStream *GetLogFile();
|
||||
virtual PRInt32 PublishMsgHeader(nsIMsgWindow *msgWindow);
|
||||
@ -263,7 +263,8 @@ protected:
|
||||
virtual nsresult MoveIncorporatedMessage(nsIMsgDBHdr *mailHdr,
|
||||
nsIMsgDatabase *sourceDB,
|
||||
const char *destFolder,
|
||||
nsIMsgFilter *filter);
|
||||
nsIMsgFilter *filter,
|
||||
nsIMsgWindow *msgWindow);
|
||||
virtual int MarkFilteredMessageRead(nsIMsgDBHdr *msgHdr);
|
||||
void LogRuleHit(nsIMsgFilter *filter, nsIMsgDBHdr *msgHdr);
|
||||
nsCOMPtr <nsIMsgFilterList> m_filterList;
|
||||
|
Loading…
Reference in New Issue
Block a user