Adding pref to disable copy operations

This commit is contained in:
rhp%netscape.com 1999-07-03 15:53:08 +00:00
Родитель fdbdc456c5
Коммит 0d33f5862f
2 изменённых файлов: 49 добавлений и 16 удалений

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

@ -221,6 +221,7 @@ LocateMessageFolder(nsIMsgIdentity *userIdentity,
PRUint32 subCnt = 0;
PRUint32 i;
PRBool fixed = PR_FALSE;
char *savePref = "";
//
// get the current mail session....
@ -245,13 +246,21 @@ LocateMessageFolder(nsIMsgIdentity *userIdentity,
if (NS_FAILED(rv))
return nsnull;
// Make a working copy to avoid compiler problems with const...
if ( (aSavePref) && (*aSavePref) )
savePref = PL_strdup(aSavePref);
for (i=0; i<cnt; i++)
{
// Now that we have the server...we need to get the named message folder
nsCOMPtr<nsIMsgIncomingServer> inServer;
inServer = do_QueryInterface(retval->ElementAt(i));
if(NS_FAILED(rv) || (!inServer))
{
if (*savePref)
PR_FREEIF(savePref);
return nsnull;
}
//
// If aSavePref is passed in, then the user has chosen a specific
@ -262,22 +271,22 @@ LocateMessageFolder(nsIMsgIdentity *userIdentity,
// mailbox://rhp@netscape.com
// newsgroup://news.mozilla.org
//
if ( (aSavePref) && (*aSavePref) )
if ( (savePref) && (*savePref) )
{
char *anyServer = "anyfolder://";
if (PL_strncasecmp(anyServer, aSavePref, PL_strlen(aSavePref)) != 0)
if (PL_strncasecmp(anyServer, savePref, PL_strlen(savePref)) != 0)
{
char *serverURI = nsnull;
nsresult res = inServer->GetServerURI(&serverURI);
if ( NS_FAILED(res) || (!serverURI) || !(*serverURI) )
continue;
// First, make sure that aSavePref is only the protocol://server
// First, make sure that savePref is only the protocol://server
// for this comparison...not the file path if any...
//
if (!fixed)
{
char *ptr1 = PL_strstr(aSavePref, "//");
char *ptr1 = PL_strstr(savePref, "//");
if ( (ptr1) && (*ptr1) )
{
ptr1 = ptr1 + 2;
@ -289,7 +298,7 @@ LocateMessageFolder(nsIMsgIdentity *userIdentity,
}
// Now check to see if this URI is the same as the
// server pref
if (PL_strncasecmp(serverURI, aSavePref, PL_strlen(aSavePref)) != 0)
if (PL_strncasecmp(serverURI, savePref, PL_strlen(savePref)) != 0)
continue;
}
}
@ -304,7 +313,7 @@ LocateMessageFolder(nsIMsgIdentity *userIdentity,
NS_RELEASE(aFolder);
if(NS_FAILED(rv) || (!rootFolder))
return nsnull;
continue;
PRUint32 numFolders = 0;
msgFolder = nsnull;
@ -329,6 +338,9 @@ LocateMessageFolder(nsIMsgIdentity *userIdentity,
break;
}
if (*savePref)
PR_FREEIF(savePref);
return msgFolder;
}

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

@ -1115,19 +1115,39 @@ nsMsgComposeAndSend::InitCompositionFields(nsMsgCompFields *fields)
HJ41792
}
// Now, we will look for a URI defined as the default FCC pref. If this is set,
// then SetFcc will use this value. The FCC field is a URI for the server that
// will hold the "Sent" folder...the
//
char *uri = "mailbox://";
NS_WITH_SERVICE(nsIPref, prefs, kPrefCID, &rv);
if (NS_SUCCEEDED(rv) && prefs)
// First, look at what was passed in via the "fields" structure...if that was
// set then use it, otherwise, fall back to what is set in the prefs...
//
const char *fieldsFCC = fields->GetFcc();
if (fieldsFCC && *fieldsFCC)
{
rv = prefs->CopyCharPref("mail.default_fcc_server", &uri);
if (PL_strcasecmp(fieldsFCC, "nocopy://") == 0)
mCompFields->SetFcc("", nsnull);
else
mCompFields->SetFcc(fieldsFCC, nsnull);
}
else
{
char *uri = "mailbox://";
NS_WITH_SERVICE(nsIPref, prefs, kPrefCID, &rv);
if (NS_SUCCEEDED(rv) && prefs)
rv = prefs->CopyCharPref("mail.default_fcc_server", &uri);
fields->SetFcc(uri, nsnull);
mCompFields->SetFcc(uri, nsnull);
if ( (uri) || (*uri) )
{
if (PL_strcasecmp(uri, "nocopy://") == 0)
mCompFields->SetFcc("", nsnull);
else
mCompFields->SetFcc(uri, nsnull);
}
else
mCompFields->SetFcc("", nsnull);
}
mCompFields->SetNewspostUrl((char *) fields->GetNewspostUrl(), nsnull);
mCompFields->SetDefaultBody((char *) fields->GetDefaultBody(), nsnull);
@ -1530,16 +1550,13 @@ nsMsgComposeAndSend::DoDeliveryExitProcessing(nsresult aExitCode, PRBool aCheckF
if (NS_FAILED(retCode))
{
#ifdef NS_DEBUG
printf("\nSTARTING Copy Operation Failed!\n");
printf("\nDoDeliveryExitProcessing(): DoFcc() call Failed!\n");
#endif
// Everything already cleaned up...just return.
return;
}
else
{
#ifdef NS_DEBUG
printf("\nStarting Copy Operation SUCCEEDED!\n");
#endif
// Either we started the copy...cleanup happens later...or cleanup was
// already taken care of for us.
return;
@ -1571,6 +1588,10 @@ nsMsgComposeAndSend::DoFcc()
//
if (!mCompFields->GetFcc() || !*mCompFields->GetFcc())
{
#ifdef NS_DEBUG
printf("\nCopy operation disabled by user!\n");
#endif
NotifyListenersOnStopSending(nsnull, NS_OK, nsnull, nsnull);
// SHERRY: for now, we are going to let the destructor do the Clear();
return NS_OK;