From 563324c47c1d168d74169dd26ad603f9b5818964 Mon Sep 17 00:00:00 2001 From: "cavin%netscape.com" Date: Wed, 13 Feb 2002 23:55:45 +0000 Subject: [PATCH] Fix for bugscape 10163. Disallowed saving sent msgs to folders in AOL accounts. r=ducarroz, sr=mscott. --- mailnews/compose/src/nsMsgSend.cpp | 35 +++++++++++++++++++++++++++--- mailnews/compose/src/nsMsgSend.h | 3 +++ 2 files changed, 35 insertions(+), 3 deletions(-) diff --git a/mailnews/compose/src/nsMsgSend.cpp b/mailnews/compose/src/nsMsgSend.cpp index e79760a1f9ef..05d63096cb5c 100644 --- a/mailnews/compose/src/nsMsgSend.cpp +++ b/mailnews/compose/src/nsMsgSend.cpp @@ -97,6 +97,7 @@ #include "nsMsgSimulateError.h" #include "nsNetCID.h" #include "nsMsgUtils.h" +#include "nsIRDFService.h" // use these macros to define a class IID for our component. Our object currently // supports two interfaces (nsISupports and nsIMsgCompose) so we want to define constants @@ -3012,7 +3013,7 @@ nsMsgComposeAndSend::DeliverMessage() { return SaveAsDraft(); } - else if (m_deliver_mode == nsMsgSaveAsTemplate) + else if (m_deliver_mode == nsMsgSaveAsTemplate) { return SaveAsTemplate(); } @@ -3396,6 +3397,34 @@ nsMsgComposeAndSend::DeliverAsNewsExit(nsIURI *aUrl, nsresult aExitCode) return NS_OK; } +PRBool nsMsgComposeAndSend::CanSaveMessagesToFolder(const char *folderURL) +{ + nsresult rv; + nsCOMPtr rdf(do_GetService("@mozilla.org/rdf/rdf-service;1", &rv)); + if (NS_FAILED(rv)) + return PR_FALSE; + + nsCOMPtr resource; + rv = rdf->GetResource(folderURL, getter_AddRefs(resource)); + if (NS_FAILED(rv)) + return PR_FALSE; + + nsCOMPtr thisFolder; + thisFolder = do_QueryInterface(resource, &rv); + if (NS_FAILED(rv) || !thisFolder) + return PR_FALSE; + + nsCOMPtr server; + rv = thisFolder->GetServer(getter_AddRefs(server)); + if (NS_FAILED(rv) || !server) + return PR_FALSE; + + // See if we are allowed to save/file msgs to this folder. + PRBool canSave; + rv = server->GetCanFileMessagesOnServer(&canSave); + return canSave; +} + // // Now, start the appropriate copy operation. // @@ -3403,9 +3432,9 @@ nsresult nsMsgComposeAndSend::DoFcc() { // - // Just cleanup and return success if no FCC is necessary + // Just cleanup and return success if we're not allowed to save msgs to FCC folder. // - if (!mCompFields->GetFcc() || !*mCompFields->GetFcc()) + if (! CanSaveMessagesToFolder(mCompFields->GetFcc())) { #ifdef NS_DEBUG printf("\nCopy operation disabled by user!\n"); diff --git a/mailnews/compose/src/nsMsgSend.h b/mailnews/compose/src/nsMsgSend.h index c954eb9782f2..fcb53db14e0d 100644 --- a/mailnews/compose/src/nsMsgSend.h +++ b/mailnews/compose/src/nsMsgSend.h @@ -225,6 +225,9 @@ public: nsresult SaveInSentFolder(); nsresult SaveAsTemplate(); + // Check to see if it's ok to save msgs to the configured folder. + PRBool CanSaveMessagesToFolder(const char *folderURL); + // // FCC operations... //