Bug #8076/9836 --> use specialDirectory::OS_TemporaryDirectory to determine the directory to write tempMessage.eml out to.

This commit is contained in:
mscott%netscape.com 1999-09-01 04:09:07 +00:00
Родитель fcda51a538
Коммит 4aa8c8a125
10 изменённых файлов: 36 добавлений и 87 удалений

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

@ -21,6 +21,7 @@
#include "nsIMsgMailNewsUrl.h"
#include "nsISocketTransportService.h"
#include "nsXPIDLString.h"
#include "nsSpecialSystemDirectory.h"
#include "nsIIOService.h"
static NS_DEFINE_CID(kSocketTransportServiceCID, NS_SOCKETTRANSPORTSERVICE_CID);
@ -35,6 +36,9 @@ nsMsgProtocol::nsMsgProtocol()
m_startPosition = 0;
m_readCount = 0;
m_socketIsOpen = PR_FALSE;
m_tempMsgFileSpec = nsSpecialSystemDirectory(nsSpecialSystemDirectory::OS_TemporaryDirectory);
m_tempMsgFileSpec += "tempMessage.eml";
}
nsMsgProtocol::~nsMsgProtocol()

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

@ -96,6 +96,8 @@ protected:
PRUint32 m_flags; // used to store flag information
PRUint32 m_startPosition;
PRInt32 m_readCount;
nsFileSpec m_tempMsgFileSpec; // we currently have a hack where displaying a msg involves writing it to a temp file first
};
#endif /* nsMsgProtocol_h__ */

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

@ -36,6 +36,7 @@
#include "CNavDTD.h"
#include "nsMsgCompUtils.h"
#include "nsMsgComposeStringBundle.h"
#include "nsSpecialSystemDirectory.h"
#include "nsMsgSend.h"
// XXX temporary so we can use the current identity hack -alecf
@ -43,19 +44,7 @@
#include "nsMsgBaseCID.h"
static NS_DEFINE_CID(kMsgMailSessionCID, NS_MSGMAILSESSION_CID);
#if defined(XP_UNIX) || defined(XP_BEOS)
#define TEMP_PATH_DIR "/tmp/"
#elif defined(XP_PC)
#define TEMP_PATH_DIR "c:\\temp\\"
#elif defined(XP_MAC)
#define TEMP_PATH_DIR ""
#else
#error TEMP_PATH_DIR_NOT_DEFINED
#endif
#define TEMP_MESSAGE_IN "tempMessage.eml"
#define TEMP_MESSAGE_OUT "tempMessage.html"
#define TEMP_MESSAGE_OUT_TEXT "tempMessage.txt"
// Defines....
static NS_DEFINE_CID(kMsgQuoteCID, NS_MSGQUOTE_CID);
@ -931,10 +920,9 @@ void nsMsgCompose::HackToGetBody(PRInt32 what)
char *buffer = (char *) PR_CALLOC(16384);
if (buffer)
{
nsString fileName(TEMP_PATH_DIR);
fileName += TEMP_MESSAGE_IN;
nsFileSpec fileSpec = nsSpecialSystemDirectory(nsSpecialSystemDirectory::OS_TemporaryDirectory);
fileSpec += TEMP_MESSAGE_IN;
nsFileSpec fileSpec(fileName);
nsInputFileStream fileStream(fileSpec);
nsString msgBody = (what == 2 && !m_composeHTML) ? "--------Original Message--------\r\n" : "";

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

@ -53,15 +53,10 @@
#include "nsImapMoveCoalescer.h"
#include "nsIPrompt.h"
#include "nsINetSupportDialogService.h"
#include "nsSpecialSystemDirectory.h"
static NS_DEFINE_CID(kNetSupportDialogCID, NS_NETSUPPORTDIALOG_CID);
static NS_DEFINE_CID(kMsgFilterServiceCID, NS_MSGFILTERSERVICE_CID);
// we need this because of an egcs 1.0 (and possibly gcc) compiler bug
// that doesn't allow you to call ::nsISupports::GetIID() inside of a class
// that multiply inherits from nsISupports
static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID);
static NS_DEFINE_CID(kRDFServiceCID, NS_RDFSERVICE_CID);
static NS_DEFINE_CID(kCMailDB, NS_MAILDB_CID);
static NS_DEFINE_CID(kImapProtocolCID, NS_IMAPPROTOCOL_CID);
@ -74,23 +69,13 @@ static NS_DEFINE_CID(kCImapHostSessionList, NS_IIMAPHOSTSESSIONLIST_CID);
static NS_DEFINE_CID(kMsgCopyServiceCID, NS_MSGCOPYSERVICE_CID);
static NS_DEFINE_CID(kCopyMessageStreamListenerCID, NS_COPYMESSAGESTREAMLISTENER_CID);
////////////////////////////////////////////////////////////////////////////////
// for temp message hack
#if defined(XP_UNIX) || defined(XP_BEOS)
#define MESSAGE_PATH "/tmp/tempMessage.eml"
#elif defined(XP_PC)
#define MESSAGE_PATH "c:\\temp\\tempMessage.eml"
#elif defined(XP_MAC)
#define MESSAGE_PATH "tempMessage.eml"
#endif
#define FOUR_K 4096
nsImapMailFolder::nsImapMailFolder() :
m_initialized(PR_FALSE),m_haveDiscoveredAllFolders(PR_FALSE),
m_haveReadNameFromDB(PR_FALSE),
m_curMsgUid(0), m_nextMessageByteLength(0),
m_urlRunning(PR_FALSE), m_tempMessageFile(MESSAGE_PATH),
m_urlRunning(PR_FALSE),
m_verifiedAsOnlineFolder(PR_FALSE),
m_explicitlyVerify(PR_FALSE)
{
@ -107,6 +92,8 @@ nsImapMailFolder::nsImapMailFolder() :
pEventQService->GetThreadEventQueue(PR_GetCurrentThread(),
getter_AddRefs(m_eventQueue));
m_moveCoalescer = nsnull;
m_tempMsgFileSpec = nsSpecialSystemDirectory(nsSpecialSystemDirectory::OS_TemporaryDirectory);
m_tempMsgFileSpec += "tempMessage.eml";
}
@ -2260,9 +2247,9 @@ nsImapMailFolder::SetupMsgWriteStream(nsIImapProtocol* aProtocol,
// 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...
m_tempMessageFile.Delete(PR_FALSE);
m_tempMsgFileSpec.Delete(PR_FALSE);
nsISupports * supports;
NS_NewIOFileStream(&supports, m_tempMessageFile, PR_WRONLY | PR_CREATE_FILE | PR_TRUNCATE, 00700);
NS_NewIOFileStream(&supports, m_tempMsgFileSpec, PR_WRONLY | PR_CREATE_FILE | PR_TRUNCATE, 00700);
m_tempMessageStream = do_QueryInterface(supports);
NS_IF_RELEASE(supports);
return NS_OK;
@ -2295,11 +2282,10 @@ nsImapMailFolder::NormalEndMsgWriteStream(nsIImapProtocol* aProtocol)
if (NS_SUCCEEDED(res))
{
nsCOMPtr<nsIWebShell> webShell;
nsFilePath filePath(MESSAGE_PATH);
webShell = do_QueryInterface(aSupport, &res);
if (NS_SUCCEEDED(res) && webShell)
{
nsFileURL fileURL(filePath);
nsFileURL fileURL(m_tempMsgFileSpec);
char * message_path_url = PL_strdup(fileURL.GetAsString());
res = webShell->LoadURL(nsAutoString(message_path_url).GetUnicode(), nsnull, PR_TRUE);
if (NS_SUCCEEDED(res))
@ -2323,10 +2309,9 @@ nsImapMailFolder::NormalEndMsgWriteStream(nsIImapProtocol* aProtocol)
nsCOMPtr<nsIURI> aUrl;
res = aProtocol->GetRunningUrl(getter_AddRefs(aUrl));
nsCOMPtr<nsISupports> aCtxt = do_QueryInterface(aUrl);
nsFileSpec fileSpec(filePath);
nsInputFileStream *inputFileStream = nsnull;
nsCOMPtr<nsIInputStream> inputStream;
inputFileStream = new nsInputFileStream(fileSpec);
inputFileStream = new nsInputFileStream(m_tempMsgFileSpec);
if (!inputFileStream) return NS_ERROR_OUT_OF_MEMORY;
inputStream =
do_QueryInterface(inputFileStream->GetIStream(), &res);

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

@ -376,7 +376,7 @@ protected:
// part of temporary libmime converstion trick......these should go away once MIME uses a new stream
// converter interface...
nsCOMPtr<nsIOutputStream> m_tempMessageStream;
nsFileSpec m_tempMessageFile;
nsFileSpec m_tempMsgFileSpec;
// *** jt - undo move/copy trasaction support
nsCOMPtr<nsITransactionManager> m_transactionManager;

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

@ -55,18 +55,6 @@ PRLogModuleInfo *IMAP;
#include "nsProxyObjectManager.h"
// for temp message hack
#if defined(XP_UNIX) || defined(XP_BEOS)
#define MESSAGE_PATH "/tmp/tempMessage.eml"
#elif defined(XP_PC)
#define MESSAGE_PATH "c:\\temp\\tempMessage.eml"
#elif defined(XP_MAC)
#define MESSAGE_PATH "tempMessage.eml"
#endif
#define ONE_SECOND ((PRUint32)1000) // one second
#define FOUR_K ((PRUint32)4096)

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

@ -33,6 +33,7 @@
#include "prlog.h"
#include "prerror.h"
#include "prprf.h"
#include "nsFileStream.h"
#define ENABLE_SMOKETEST 1
@ -101,8 +102,7 @@ void nsMailboxProtocol::Initialize(nsIURI * aURL)
m_nextState = MAILBOX_READ_FOLDER;
m_initialState = MAILBOX_READ_FOLDER;
nsFileSpec fileSpec(MESSAGE_PATH);
NS_NewFileSpecWithSpec(fileSpec, getter_AddRefs(m_tempMessageFile));
NS_NewFileSpecWithSpec(m_tempMsgFileSpec, getter_AddRefs(m_tempMessageFile));
}
/////////////////////////////////////////////////////////////////////////////////////////////
@ -188,8 +188,7 @@ PRInt32 nsMailboxProtocol::DoneReadingMessage()
// disply hack: run a file url on the temp file
if (m_mailboxAction == nsIMailboxUrl::ActionDisplayMessage && m_displayConsumer)
{
nsFilePath filePath(MESSAGE_PATH);
nsFileURL fileURL(filePath);
nsFileURL fileURL(m_tempMsgFileSpec);
char * message_path_url = PL_strdup(fileURL.GetAsString());
rv = m_displayConsumer->LoadURL(nsAutoString(message_path_url).GetUnicode(), nsnull, PR_TRUE);

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

@ -30,14 +30,6 @@
#include "nsIWebShell.h" // mscott - this dependency should only be temporary!
#if defined(XP_UNIX) || defined(XP_BEOS)
#define MESSAGE_PATH "/tmp/tempMessage.eml"
#elif defined(XP_PC)
#define MESSAGE_PATH "c:\\temp\\tempMessage.eml"
#elif defined(XP_MAC)
#define MESSAGE_PATH "tempMessage.eml"
#endif
// State Flags (Note, I use the word state in terms of storing
// state information about the connection (authentication, have we sent
// commands, etc. I do not intend it to refer to protocol state)

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

@ -437,7 +437,7 @@ nsDummyBufferStream::QueryInterface(REFNSIID aIID, void** result)
return NS_ERROR_NO_INTERFACE;
}
nsNNTPProtocol::nsNNTPProtocol() : m_tempArticleFile(ARTICLE_PATH), m_tempErrorFile(ERROR_PATH)
nsNNTPProtocol::nsNNTPProtocol()
{
m_messageID = nsnull;
m_cancelFromHdr = nsnull;
@ -445,6 +445,8 @@ nsNNTPProtocol::nsNNTPProtocol() : m_tempArticleFile(ARTICLE_PATH), m_tempErrorF
m_cancelDistribution = nsnull;
m_cancelID = nsnull;
m_cancelMessageFile = nsnull;
m_tempErrorFileSpec = nsSpecialSystemDirectory(nsSpecialSystemDirectory::OS_TemporaryDirectory);
m_tempErrorFileSpec += "errorMessage.htm";
}
nsNNTPProtocol::~nsNNTPProtocol()
@ -1853,9 +1855,9 @@ PRInt32 nsNNTPProtocol::SendFirstNNTPCommandResponse()
char *group_name = nsnull;
char outputBuffer[OUTPUT_BUFFER_SIZE];
m_tempErrorFile.Delete(PR_FALSE);
m_tempErrorFileSpec.Delete(PR_FALSE);
nsCOMPtr <nsISupports> supports;
NS_NewIOFileStream(getter_AddRefs(supports), m_tempErrorFile, PR_WRONLY | PR_CREATE_FILE | PR_TRUNCATE, 00700);
NS_NewIOFileStream(getter_AddRefs(supports), m_tempErrorFileSpec, PR_WRONLY | PR_CREATE_FILE | PR_TRUNCATE, 00700);
m_tempErrorStream = do_QueryInterface(supports);
if (m_newsgroup) {
@ -1898,14 +1900,15 @@ PRInt32 nsNNTPProtocol::SendFirstNNTPCommandResponse()
/* cut and paste from below */
if (m_displayConsumer)
{
nsFilePath filePath(ERROR_PATH);
nsFileURL fileURL(filePath);
nsFileURL fileURL(m_tempErrorFileSpec);
char * error_path_url = PL_strdup(fileURL.GetAsString());
#ifdef DEBUG_NEWS
printf("load this url to display the error message: %s\n", error_path_url);
#endif
#ifdef DEBUG_mscott
printf ("mscott fix me...as part of necko...we don't have stream converters hooked up...");
#endif
m_displayConsumer->LoadURL(nsAutoString(error_path_url).GetUnicode(), nsnull, PR_TRUE);
PR_FREEIF(error_path_url);
@ -2041,16 +2044,16 @@ PRInt32 nsNNTPProtocol::BeginArticle()
// article...
if (m_copyStreamListener)
{
m_tempArticleFile.Delete(PR_FALSE);
m_tempMsgFileSpec.Delete(PR_FALSE);
m_tempArticleStream = null_nsCOMPtr();
nsCOMPtr<nsISupports> aURL(do_QueryInterface(m_runningURL));
m_copyStreamListener->OnStartRequest(nsnull, aURL);
}
else
{
m_tempArticleFile.Delete(PR_FALSE);
m_tempMsgFileSpec.Delete(PR_FALSE);
nsCOMPtr <nsISupports> supports;
NS_NewIOFileStream(getter_AddRefs(supports), m_tempArticleFile,
NS_NewIOFileStream(getter_AddRefs(supports), m_tempMsgFileSpec,
PR_WRONLY | PR_CREATE_FILE | PR_TRUNCATE, 00700);
m_tempArticleStream = do_QueryInterface(supports);
}
@ -2113,8 +2116,7 @@ PRInt32 nsNNTPProtocol::ReadArticle(nsIInputStream * inputStream, PRUint32 lengt
if (m_displayConsumer)
{
nsFilePath filePath(ARTICLE_PATH);
nsFileURL fileURL(filePath);
nsFileURL fileURL(m_tempMsgFileSpec);
char * article_path_url = PL_strdup(fileURL.GetAsString());
#ifdef DEBUG_NEWS

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

@ -35,23 +35,13 @@
#include "nsIMsgOfflineNewsState.h"
#include "nsMsgLineBuffer.h"
#include "nsSpecialSystemDirectory.h"
#include "nsCOMPtr.h"
#include "nsXPIDLString.h"
// this is only needed as long as our libmime hack is in place
#include "prio.h"
#if defined(XP_UNIX) || defined (XP_BEOS)
#define ARTICLE_PATH "/tmp/tempMessage.eml"
#define ERROR_PATH "/tmp/errorMessage.htm"
#elif defined(XP_PC)
#define ARTICLE_PATH "c:\\temp\\tempMessage.eml"
#define ERROR_PATH "c:\\temp\\errorMessage.htm"
#elif defined(XP_MAC)
#define ARTICLE_PATH "tempMessage.eml"
#define ERROR_PATH "errorMessage.htm"
#endif
// State Flags (Note, I use the word state in terms of storing
// state information about the connection (authentication, have we sent
// commands, etc. I do not intend it to refer to protocol state)
@ -183,11 +173,10 @@ private:
// part of temporary libmime converstion trick......these should go away once MIME uses a new stream
// converter interface...
nsCOMPtr<nsIOutputStream> m_tempArticleStream;
nsFileSpec m_tempArticleFile;
// same trick as above, but used for showing error message in the
// message pane.
nsCOMPtr<nsIOutputStream> m_tempErrorStream;
nsFileSpec m_tempErrorFile;
nsFileSpec m_tempErrorFileSpec;
// uber copy service support
nsCOMPtr<nsIStreamListener> m_copyStreamListener; // per message