зеркало из https://github.com/mozilla/pjs.git
get imap message display working
This commit is contained in:
Родитель
73e664331f
Коммит
adffb355e6
|
@ -39,6 +39,7 @@
|
|||
|
||||
class nsIURL;
|
||||
class nsIImapHostSessionList;
|
||||
class nsIWebShell;
|
||||
|
||||
class nsIImapProtocol : public nsIStreamListener
|
||||
{
|
||||
|
@ -72,6 +73,10 @@ public:
|
|||
// methods to get data from the imap parser flag state.
|
||||
NS_IMETHOD GetFlagsForUID(PRUint32 uid, PRBool *foundIt, imapMessageFlagsType *flags) = 0;
|
||||
NS_IMETHOD GetSupportedUserFlags(PRUint16 *flags) = 0;
|
||||
|
||||
// this is for the temp message display hack
|
||||
NS_IMETHOD GetDisplayStream (nsIWebShell **webShell) = 0;
|
||||
|
||||
};
|
||||
|
||||
#endif /* nsIImapProtocol_h___ */
|
||||
|
|
|
@ -83,6 +83,7 @@ public:
|
|||
nsIMsgFolder * aImapMailFolder,
|
||||
nsIImapMessageSink * aImapMessage,
|
||||
nsIUrlListener * aUrlListener, nsIURL ** aURL,
|
||||
nsISupports *aConsumer,
|
||||
const char *messageIdentifierList,
|
||||
PRBool messageIdsAreUID) = 0;
|
||||
NS_IMETHOD Noop(PLEventQueue * aClientEventQueue,
|
||||
|
|
|
@ -37,6 +37,7 @@
|
|||
#include "nsMsgUtils.h"
|
||||
#include "nsIMsgMailSession.h"
|
||||
#include "nsImapMessage.h"
|
||||
#include "nsIWebShell.h"
|
||||
|
||||
// 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
|
||||
|
@ -52,6 +53,18 @@ static NS_DEFINE_CID(kEventQueueServiceCID, NS_EVENTQUEUESERVICE_CID);
|
|||
static NS_DEFINE_CID(kMsgMailSessionCID, NS_MSGMAILSESSION_CID);
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// for temp message hack
|
||||
#ifdef XP_UNIX
|
||||
#define MESSAGE_PATH "/usr/tmp/tempMessage.eml"
|
||||
#endif
|
||||
|
||||
#ifdef XP_PC
|
||||
#define MESSAGE_PATH "c:\\temp\\tempMessage.eml"
|
||||
#endif
|
||||
|
||||
#ifdef XP_MAC
|
||||
#define MESSAGE_PATH "tempMessage.eml"
|
||||
#endif
|
||||
|
||||
nsImapMailFolder::nsImapMailFolder() :
|
||||
nsMsgFolder(), m_pathName(""), m_mailDatabase(nsnull),
|
||||
|
@ -65,7 +78,7 @@ nsImapMailFolder::nsImapMailFolder() :
|
|||
|
||||
nsIRDFService* rdfService = nsnull;
|
||||
nsIRDFDataSource* datasource = nsnull;
|
||||
|
||||
m_tempMessageFile = nsnull;
|
||||
nsresult rv = nsServiceManager::GetService(kRDFServiceCID,
|
||||
nsIRDFService::GetIID(),
|
||||
(nsISupports**) &rdfService);
|
||||
|
@ -1424,22 +1437,51 @@ NS_IMETHODIMP
|
|||
nsImapMailFolder::SetupMsgWriteStream(nsIImapProtocol* aProtocol,
|
||||
StreamInfo* aStreamInfo)
|
||||
{
|
||||
return NS_ERROR_FAILURE;
|
||||
// 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...
|
||||
PR_Delete(MESSAGE_PATH);
|
||||
m_tempMessageFile = PR_Open(MESSAGE_PATH, PR_WRONLY | PR_CREATE_FILE | PR_TRUNCATE, 00700);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsImapMailFolder::ParseAdoptedMsgLine(nsIImapProtocol* aProtocol,
|
||||
msg_line_info* aMsgLineInfo)
|
||||
{
|
||||
return NS_ERROR_FAILURE;
|
||||
if (m_tempMessageFile)
|
||||
PR_Write(m_tempMessageFile,(void *) aMsgLineInfo->adoptedMessageLine,
|
||||
PL_strlen(aMsgLineInfo->adoptedMessageLine));
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsImapMailFolder::NormalEndMsgWriteStream(nsIImapProtocol* aProtocol)
|
||||
{
|
||||
return NS_ERROR_FAILURE;
|
||||
nsresult res = NS_OK;
|
||||
if (m_tempMessageFile)
|
||||
{
|
||||
nsIWebShell *webShell;
|
||||
|
||||
PR_Close(m_tempMessageFile);
|
||||
m_tempMessageFile = nsnull;
|
||||
res = aProtocol->GetDisplayStream(&webShell);
|
||||
if (NS_SUCCEEDED(res) && webShell)
|
||||
{
|
||||
nsFilePath filePath(MESSAGE_PATH);
|
||||
nsFileURL fileURL(filePath);
|
||||
char * message_path_url = PL_strdup(fileURL.GetAsString());
|
||||
|
||||
res = webShell->LoadURL(nsAutoString(message_path_url).GetUnicode(), nsnull, PR_TRUE, nsURLReload, 0);
|
||||
|
||||
PR_FREEIF(message_path_url);
|
||||
}
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsImapMailFolder::AbortMsgWriteStream(nsIImapProtocol* aProtocol)
|
||||
{
|
||||
|
|
|
@ -270,6 +270,12 @@ protected:
|
|||
PRInt32 m_nextMessageByteLength;
|
||||
PLEventQueue* m_eventQueue;
|
||||
PRBool m_urlRunning;
|
||||
|
||||
// part of temporary libmime converstion trick......these should go away once MIME uses a new stream
|
||||
// converter interface...
|
||||
PRFileDesc* m_tempMessageFile;
|
||||
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -30,6 +30,7 @@
|
|||
#include "nsImapServerResponseParser.h"
|
||||
#include "nspr.h"
|
||||
#include "plbase64.h"
|
||||
#include "nsIWebShell.h"
|
||||
|
||||
PRLogModuleInfo *IMAP;
|
||||
|
||||
|
@ -43,11 +44,26 @@ PRLogModuleInfo *IMAP;
|
|||
|
||||
#include "nsIMsgIncomingServer.h"
|
||||
|
||||
// for temp message hack
|
||||
#ifdef XP_UNIX
|
||||
#define MESSAGE_PATH "/usr/tmp/tempMessage.eml"
|
||||
#endif
|
||||
|
||||
#ifdef XP_PC
|
||||
#define MESSAGE_PATH "c:\\temp\\tempMessage.eml"
|
||||
#endif
|
||||
|
||||
#ifdef XP_MAC
|
||||
#define MESSAGE_PATH "tempMessage.eml"
|
||||
#endif
|
||||
|
||||
|
||||
#define ONE_SECOND ((PRUint32)1000) // one second
|
||||
|
||||
const char *kImapTrashFolderName = "Trash"; // **** needs to be localized ****
|
||||
|
||||
static NS_DEFINE_CID(kNetServiceCID, NS_NETSERVICE_CID);
|
||||
static NS_DEFINE_IID(kIWebShell, NS_IWEB_SHELL_IID);
|
||||
|
||||
#define OUTPUT_BUFFER_SIZE (4096*2) // mscott - i should be able to remove this if I can use nsMsgLineBuffer???
|
||||
|
||||
|
@ -235,6 +251,7 @@ nsresult nsImapProtocol::Initialize(nsIImapHostSessionList * aHostSessionList, P
|
|||
if (!aSinkEventQueue || !aHostSessionList)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
m_displayConsumer = nsnull;
|
||||
m_sinkEventQueue = aSinkEventQueue;
|
||||
m_hostSessionList = aHostSessionList;
|
||||
m_parser.SetHostSessionList(aHostSessionList);
|
||||
|
@ -888,6 +905,16 @@ NS_IMETHODIMP nsImapProtocol::OnStopBinding(nsIURL* aURL, nsresult aStatus, cons
|
|||
// End of nsIStreamListenerSupport
|
||||
//////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
NS_IMETHODIMP nsImapProtocol::GetDisplayStream (nsIWebShell **webShell)
|
||||
{
|
||||
if (webShell)
|
||||
{
|
||||
*webShell = m_displayConsumer;
|
||||
return NS_OK;
|
||||
}
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
}
|
||||
|
||||
/*
|
||||
* Writes the data contained in dataBuffer into the current output stream. It also informs
|
||||
* the transport layer that this data is now available for transmission.
|
||||
|
@ -939,6 +966,9 @@ nsresult nsImapProtocol::LoadUrl(nsIURL * aURL, nsISupports * aConsumer)
|
|||
nsIImapUrl * imapUrl = nsnull;
|
||||
if (aURL)
|
||||
{
|
||||
if (aConsumer)
|
||||
rv = aConsumer->QueryInterface(kIWebShell, (void **) &m_displayConsumer);
|
||||
|
||||
if (m_transport == nsnull) // i.e. we haven't been initialized yet....
|
||||
SetupWithUrl(aURL);
|
||||
|
||||
|
|
|
@ -38,6 +38,7 @@
|
|||
|
||||
class nsIMAPMessagePartIDArray;
|
||||
class nsIMsgIncomingServer;
|
||||
class nsIWebShell;
|
||||
|
||||
// State Flags (Note, I use the word state in terms of storing
|
||||
// state information about the connection (authentication, have we sent
|
||||
|
@ -97,6 +98,8 @@ public:
|
|||
|
||||
NS_IMETHOD GetFlagsForUID(PRUint32 uid, PRBool *foundIt, imapMessageFlagsType *flags);
|
||||
NS_IMETHOD GetSupportedUserFlags(PRUint16 *flags);
|
||||
|
||||
NS_IMETHOD GetDisplayStream (nsIWebShell **webShell);
|
||||
////////////////////////////////////////////////////////////////////////////////////////
|
||||
// End of nsIStreamListenerSupport
|
||||
////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -264,6 +267,7 @@ private:
|
|||
nsIOutputStream * m_outputStream; // this will be obtained from the transport interface
|
||||
nsIStreamListener * m_outputConsumer; // this will be obtained from the transport interface
|
||||
|
||||
nsIWebShell * m_displayConsumer; // if we are displaying an article this is the rfc-822 display sink...
|
||||
|
||||
// this is a method designed to buffer data coming from the input stream and efficiently extract out
|
||||
// a line on each call. We read out as much of the stream as we can and store the extra that doesn't
|
||||
|
|
|
@ -265,7 +265,7 @@ NS_IMETHODIMP nsImapService::DisplayMessage(const char* aMessageURI, nsISupports
|
|||
|
||||
messageIdString.Append(msgKey, 10);
|
||||
rv = FetchMessage(queue, folder, imapMessageSink, aUrlListener,
|
||||
aURL, messageIdString.GetBuffer(), PR_TRUE);
|
||||
aURL, aDisplayConsumer, messageIdString.GetBuffer(), PR_TRUE);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -296,6 +296,7 @@ nsImapService::FetchMessage(PLEventQueue * aClientEventQueue,
|
|||
nsIMsgFolder * aImapMailFolder,
|
||||
nsIImapMessageSink * aImapMessage,
|
||||
nsIUrlListener * aUrlListener, nsIURL ** aURL,
|
||||
nsISupports * aDisplayConsumer,
|
||||
const char *messageIdentifierList,
|
||||
PRBool messageIdsAreUID)
|
||||
{
|
||||
|
@ -335,7 +336,7 @@ nsImapService::FetchMessage(PLEventQueue * aClientEventQueue,
|
|||
delete [] folderName;
|
||||
rv = imapUrl->SetSpec(urlSpec.GetBuffer());
|
||||
imapUrl->RegisterListener(aUrlListener); // register listener if there is one.
|
||||
protocolInstance->LoadUrl(imapUrl, nsnull);
|
||||
protocolInstance->LoadUrl(imapUrl, aDisplayConsumer);
|
||||
if (aURL)
|
||||
*aURL = imapUrl;
|
||||
else
|
||||
|
|
|
@ -56,6 +56,7 @@ public:
|
|||
nsIImapMessageSink * aImapMessage,
|
||||
nsIUrlListener * aUrlListener,
|
||||
nsIURL ** aURL,
|
||||
nsISupports *aConsumer,
|
||||
const char *messageIdentifierList,
|
||||
PRBool messageIdsAreUID);
|
||||
NS_IMETHOD Noop(PLEventQueue * aClientEventQueue,
|
||||
|
|
Загрузка…
Ссылка в новой задаче