fixed bug 10801 -- [Featuure] Save Messages, bug 14794 - message sent from unsent folder display as raw message; we need to pay attention to where we want to save the message as template, if the message goes to the local mail folder we have to add the dummy envelope header plus the x mozilla status lines; when sending unsent messages we need to set from/sender information to pass the sanity check at the send time; reviewed by rhp

This commit is contained in:
jefft%netscape.com 1999-10-07 14:27:11 +00:00
Родитель 4fc5944688
Коммит 33672e6f76
5 изменённых файлов: 100 добавлений и 19 удалений

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

@ -668,24 +668,36 @@ nsMessenger::SaveAs(const char* url, PRBool asFile)
}
else
{
// ** save as Template
nsSaveAsListener *aListener = new nsSaveAsListener(aSpec);
if (aListener)
{
rv = aListener->QueryInterface(
nsCOMTypeInfo<nsIUrlListener>::GetIID(),
getter_AddRefs(urlListener));
if (NS_FAILED(rv))
// ** save as Template
PRBool needDummyHeader = PR_TRUE;
char * templateUri = nsnull;
NS_WITH_SERVICE(nsIPref, prefs, kPrefServiceCID, &rv);
if (NS_FAILED(rv)) goto done;
prefs->CopyCharPref("mail.default_templates_uri", &templateUri);
if (!templateUri || !*templateUri)
return NS_ERROR_FAILURE;
needDummyHeader =
PL_strcasestr(templateUri, "mailbox") != nsnull;
nsCRT::free(templateUri);
nsSaveAsListener *aListener = new nsSaveAsListener(aSpec);
if (aListener)
{
delete aListener;
return rv;
rv = aListener->QueryInterface(
nsCOMTypeInfo<nsIUrlListener>::GetIID(),
getter_AddRefs(urlListener));
if (NS_FAILED(rv))
{
delete aListener;
return rv;
}
NS_ADDREF(aListener);
// nsUrlListenerManager uses nsVoidArray
// to keep trach of all listeners we have
// to manually add refs ourself
messageService->SaveMessageToDisk(url, aSpec,
needDummyHeader,
urlListener, nsnull);
}
NS_ADDREF(aListener); // nsUrlListenerManager uses nsVoidArray
// to keep trach of all listeners we have
// to manually add refs ourself
messageService->SaveMessageToDisk(url, aSpec, PR_TRUE,
urlListener, nsnull);
}
}
}
}

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

@ -473,7 +473,13 @@ nsCOMPtr<nsIMsgSend> pMsgSend = nsnull;
// Since we have already parsed all of the headers, we are simply going to
// set the composition fields and move on.
//
nsString author;
mMessage->GetAuthor(&author);
nsMsgCompFields * fields = (nsMsgCompFields *)compFields.get();
fields->SetFrom(author.ToNewUnicode());
if (m_to)
fields->SetTo(m_to);

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

@ -2259,6 +2259,29 @@ nsImapMailFolder::SetupMsgWriteStream(const char * aNativeString, PRBool addDumm
nsCOMPtr<nsISupports> supports;
NS_NewIOFileStream(getter_AddRefs(supports), fileSpec, PR_WRONLY | PR_CREATE_FILE | PR_TRUNCATE, 00700);
m_tempMessageStream = do_QueryInterface(supports);
if (m_tempMessageStream && addDummyEnvelope)
{
nsCString result;
char *ct;
PRUint32 writeCount;
time_t now = time ((time_t*) 0);
ct = ctime(&now);
ct[24] = 0;
result = "From - ";
result += ct;
result += MSG_LINEBREAK;
m_tempMessageStream->Write(result.GetBuffer(), result.Length(),
&writeCount);
result = "X-Mozilla-Status: 0001";
result += MSG_LINEBREAK;
m_tempMessageStream->Write(result.GetBuffer(), result.Length(),
&writeCount);
result = "X-Mozilla-Status2: 00000000";
result += MSG_LINEBREAK;
m_tempMessageStream->Write(result.GetBuffer(), result.Length(),
&writeCount);
}
return NS_OK;
}

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

@ -259,10 +259,25 @@ nsresult nsMailboxProtocol::LoadUrl(nsIURI * aURL, nsISupports * aConsumer)
// create a temp file to write the message into. We need to do this because
// we don't have pluggable converters yet. We want to let mkfile do the work of
// converting the message from RFC-822 to HTML before displaying it...
if (m_mailboxAction == nsIMailboxUrl::ActionSaveMessageToDisk)
SetFlag(MAILBOX_MSG_PARSE_FIRST_LINE);
if (m_mailboxAction ==
nsIMailboxUrl::ActionSaveMessageToDisk)
{
nsCOMPtr<nsIMsgMessageUrl> messageUrl =
do_QueryInterface(aURL, &rv);
if (NS_SUCCEEDED(rv))
{
PRBool addDummyEnvelope = PR_FALSE;
messageUrl->GetAddDummyEnvelope(&addDummyEnvelope);
if (addDummyEnvelope)
SetFlag(MAILBOX_MSG_PARSE_FIRST_LINE);
else
ClearFlag(MAILBOX_MSG_PARSE_FIRST_LINE);
}
}
else
ClearFlag(MAILBOX_MSG_PARSE_FIRST_LINE);
{
ClearFlag(MAILBOX_MSG_PARSE_FIRST_LINE);
}
m_nextState = MAILBOX_READ_MESSAGE;
break;

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

@ -2057,6 +2057,31 @@ PRInt32 nsNNTPProtocol::BeginArticle()
NS_NewIOFileStream(getter_AddRefs(supports), fileSpec,
PR_WRONLY | PR_CREATE_FILE | PR_TRUNCATE, 00700);
m_tempArticleStream = do_QueryInterface(supports);
PRBool needDummyHeaders = PR_FALSE;
msgurl->GetAddDummyEnvelope(&needDummyHeaders);
if (needDummyHeaders)
{
nsCString result;
char *ct;
PRUint32 writeCount;
time_t now = time ((time_t*) 0);
ct = ctime(&now);
ct[24] = 0;
result = "From - ";
result += ct;
result += MSG_LINEBREAK;
m_tempArticleStream->Write(result.GetBuffer(), result.Length(),
&writeCount);
result = "X-Mozilla-Status: 0001";
result += MSG_LINEBREAK;
m_tempArticleStream->Write(result.GetBuffer(), result.Length(),
&writeCount);
result = "X-Mozilla-Status2: 00000000";
result += MSG_LINEBREAK;
m_tempArticleStream->Write(result.GetBuffer(), result.Length(),
&writeCount);
}
}
}
m_nextState = NNTP_READ_ARTICLE;