Landing the MailNews_Necko_BRANCH. These are the changes that will enable mailnews to run with necko.

git-svn-id: svn://10.0.0.236/trunk@41503 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
mscott%netscape.com 1999-07-29 00:42:25 +00:00
parent 5c585b0b2e
commit e842ae2afa
161 changed files with 4985 additions and 5693 deletions

View File

@ -30,6 +30,7 @@ XPIDLSRCS = \
nsIAddrDBListener.idl \
nsIAddrDatabase.idl \
nsIAddressBook.idl \
nsIAbBase.idl \
nsIAddrBookSession.idl \
nsIAutoCompleteListener.idl \
nsIAutoCompleteSession.idl \

View File

@ -20,6 +20,7 @@ MODULE=addrbook
XPIDLSRCS = \
.\nsIAbListener.idl \
.\nsIAbBase.idl \
.\nsIAbDirectory.idl \
.\nsIAbCard.idl \
.\nsIAddrDBAnnouncer.idl \

View File

@ -33,14 +33,13 @@ CPP_OBJS= \
.\$(OBJDIR)\nsMsgFactory.obj \
$(NULL)
LLIBS= \
LLIBS= \
$(DIST)\lib\xpcom.lib \
$(DIST)\lib\msgbaseutil.lib \
$(DIST)\lib\msgbase_s.lib \
$(DIST)\lib\msgsearch_s.lib \
$(DIST)\lib\netlib.lib \
$(DIST)\lib\timer_s.lib \
$(LIBNSPR) \
$(LIBNSPR) \
$(NULL)
include <$(DEPTH)/config/rules.mak>

View File

@ -54,19 +54,19 @@ public:
NS_IMETHOD SetSubject(const char *subject) = 0;
NS_IMETHOD SetStatusOffset(PRUint32 statusOffset) = 0;
NS_IMETHOD GetAuthor(nsString &resultAuthor) = 0;
NS_IMETHOD GetSubject(nsString &resultSubject) = 0;
NS_IMETHOD GetRecipients(nsString &resultRecipients) = 0;
NS_IMETHOD GetCCList(nsString &ccList) = 0;
NS_IMETHOD GetMessageId(nsString &resultMessageId) = 0;
NS_IMETHOD GetAuthor(nsString *resultAuthor) = 0;
NS_IMETHOD GetSubject(nsString *resultSubject) = 0;
NS_IMETHOD GetRecipients(nsString *resultRecipients) = 0;
NS_IMETHOD GetCCList(nsString *ccList) = 0;
NS_IMETHOD GetMessageId(nsString *resultMessageId) = 0;
NS_IMETHOD GetMime2EncodedAuthor(nsString &resultAuthor) = 0;
NS_IMETHOD GetMime2EncodedSubject(nsString &resultSubject) = 0;
NS_IMETHOD GetMime2EncodedRecipients(nsString &resultRecipients) = 0;
NS_IMETHOD GetMime2DecodedAuthor(nsString *resultAuthor) = 0;
NS_IMETHOD GetMime2DecodedSubject(nsString *resultSubject) = 0;
NS_IMETHOD GetMime2DecodedRecipients(nsString *resultRecipients) = 0;
NS_IMETHOD GetAuthorCollationKey(nsString &resultAuthor) = 0;
NS_IMETHOD GetSubjectCollationKey(nsString &resultSubject) = 0;
NS_IMETHOD GetRecipientsCollationKey(nsString &resultRecipients) = 0;
NS_IMETHOD GetAuthorCollationKey(nsString *resultAuthor) = 0;
NS_IMETHOD GetSubjectCollationKey(nsString *resultSubject) = 0;
NS_IMETHOD GetRecipientsCollationKey(nsString *resultRecipients) = 0;
// flag handling routines
NS_IMETHOD GetFlags(PRUint32 *result) = 0;
@ -89,7 +89,7 @@ public:
NS_IMETHOD SetPriority(const char *priority) = 0;
NS_IMETHOD GetMessageOffset(PRUint32 *result) = 0;
NS_IMETHOD GetStatusOffset(PRUint32 *result) = 0;
NS_IMETHOD GetCharSet(nsString &result) = 0;
NS_IMETHOD GetCharSet(nsString *result) = 0;
NS_IMETHOD GetPriority(nsMsgPriority *msgPriority) = 0;
NS_IMETHOD GetThreadParent(nsMsgKey *result) = 0;
NS_IMETHOD SetThreadParent(nsMsgKey inKey) = 0;

View File

@ -41,7 +41,7 @@
// to add to the list =).
//////////////////////////////////////////////////////////////////////////////////
class nsIMsgMailNewsUrl : public nsIURI
class nsIMsgMailNewsUrl : public nsIURL
{
public:
static const nsIID& GetIID() { static nsIID iid = NS_IMSGMAILNEWSURL_IID; return iid; }

View File

@ -77,7 +77,7 @@ treeitem[SpecialFolder="Inbox"] > treerow > treecell > titledbutton.folderIcon {
vertical-align: bottom;
height: 16px;
width: 16px;
list-style-image: url("chrome:/messenger/skin/closedInbox.gif");
list-style-image: url("chrome://messenger/skin/closedInbox.gif");
}
treeitem[SpecialFolder="Trash"] > treerow > treecell > titledbutton.folderIcon {

View File

@ -217,8 +217,8 @@ NS_IMETHODIMP nsMsgFilter::LogRuleHit(nsOutputStream *stream, nsIMsgDBHdr *msgHd
PR_ExplodeTime(date, PR_LocalTimeParameters, &exploded);
PR_FormatTimeUSEnglish(dateStr, 100, "%m/%d/%Y %I:%M %p", &exploded);
msgHdr->GetAuthor(author);
msgHdr->GetSubject(subject);
msgHdr->GetAuthor(&author);
msgHdr->GetSubject(&subject);
if (stream)
{
*stream << "Applied filter \"";
@ -243,7 +243,7 @@ NS_IMETHODIMP nsMsgFilter::LogRuleHit(nsOutputStream *stream, nsIMsgDBHdr *msgHd
if (actionType == nsMsgFilterAction::MoveToFolder)
{
nsString msgId;
msgHdr->GetMessageId(msgId);
msgHdr->GetMessageId(&msgId);
*stream << "mailbox:";
*stream << (char *) value;
*stream << "id = ";

View File

@ -505,12 +505,12 @@ nsresult nsMsgSearchOfflineMail::MatchTerms(nsIMsgDBHdr *msgToMatch,
switch (pTerm->m_attribute)
{
case nsMsgSearchAttrib::Sender:
msgToMatch->GetAuthor(matchString);
err = pTerm->MatchRfc822String (nsAutoCString(matchString), charset);
msgToMatch->GetAuthor(&matchString);
err = pTerm->MatchRfc822String (nsAutoString(matchString,eOneByte).GetBuffer(), charset);
break;
case nsMsgSearchAttrib::Subject:
{
msgToMatch->GetSubject(matchString /* , TRUE */);
msgToMatch->GetSubject(&matchString /* , TRUE */);
nsString2 singleByteString(matchString, eOneByte);
err = pTerm->MatchString (&singleByteString, charset);
}
@ -518,12 +518,12 @@ nsresult nsMsgSearchOfflineMail::MatchTerms(nsIMsgDBHdr *msgToMatch,
case nsMsgSearchAttrib::ToOrCC:
{
nsresult errKeepGoing = pTerm->MatchAllBeforeDeciding() ? NS_OK : NS_COMFALSE;
msgToMatch->GetRecipients(recipients);
err = pTerm->MatchRfc822String (nsAutoCString(recipients), charset);
msgToMatch->GetRecipients(&recipients);
err = pTerm->MatchRfc822String (nsAutoString(recipients,eOneByte).GetBuffer(), charset);
if (errKeepGoing == err)
{
msgToMatch->GetCCList(ccList);
err = pTerm->MatchRfc822String (nsAutoCString(ccList), charset);
msgToMatch->GetCCList(&ccList);
err = pTerm->MatchRfc822String (nsAutoString(ccList,eOneByte).GetBuffer(), charset);
}
}
break;
@ -561,12 +561,12 @@ nsresult nsMsgSearchOfflineMail::MatchTerms(nsIMsgDBHdr *msgToMatch,
}
break;
case nsMsgSearchAttrib::To:
msgToMatch->GetRecipients(recipients);
err = pTerm->MatchRfc822String(nsAutoCString(recipients), charset);
msgToMatch->GetRecipients(&recipients);
err = pTerm->MatchRfc822String(nsAutoString(recipients,eOneByte).GetBuffer(), charset);
break;
case nsMsgSearchAttrib::CC:
msgToMatch->GetCCList(ccList);
err = pTerm->MatchRfc822String (nsAutoCString(ccList), charset);
msgToMatch->GetCCList(&ccList);
err = pTerm->MatchRfc822String (nsAutoString(ccList,eOneByte).GetBuffer(), charset);
break;
case nsMsgSearchAttrib::AgeInDays:
{
@ -701,7 +701,7 @@ nsresult nsMsgSearchOfflineMail::AddResultElement (nsIMsgDBHdr *pHeaders)
pHeaders->GetFlags(&msgFlags);
pValue->attribute = nsMsgSearchAttrib::Subject;
char *reString = (msgFlags & MSG_FLAG_HAS_RE) ? "Re: " : "";
pHeaders->GetSubject(subject);
pHeaders->GetSubject(&subject);
pValue->u.string = PR_smprintf ("%s%s", reString, (const char*) nsAutoCString(subject)); // hack. invoke cast operator by force
newResult->AddValue (pValue);
}
@ -710,7 +710,7 @@ nsresult nsMsgSearchOfflineMail::AddResultElement (nsIMsgDBHdr *pHeaders)
{
pValue->attribute = nsMsgSearchAttrib::Sender;
nsString author;
pHeaders->GetAuthor(author);
pHeaders->GetAuthor(&author);
pValue->u.string = PL_strdup((const char *) nsAutoCString(author));
newResult->AddValue (pValue);
err = NS_ERROR_OUT_OF_MEMORY;

View File

@ -43,7 +43,6 @@ LLIBS= \
$(DIST)\lib\raptorgfxwin.lib \
$(DIST)\lib\raptorwidget.lib \
$(DIST)\lib\msgcore.lib \
$(DIST)\lib\xplib.lib \
$(NULL)
LLFLAGS= -SUBSYSTEM:CONSOLE

View File

@ -64,6 +64,8 @@ CPP_OBJS= \
.\$(OBJDIR)\nsMsgAccountManager.obj \
.\$(OBJDIR)\nsMsgAccount.obj \
.\$(OBJDIR)\nsMsgFolderDataSource.obj \
.\$(OBJDIR)\nsMsgFolderCache.obj \
.\$(OBJDIR)\nsMsgFolderCacheElement.obj \
.\$(OBJDIR)\nsMsgMessageDataSource.obj \
.\$(OBJDIR)\nsMsgRDFUtils.obj \
.\$(OBJDIR)\nsMsgRDFDataSource.obj \
@ -74,8 +76,6 @@ CPP_OBJS= \
.\$(OBJDIR)\nsMsgBiffManager.obj \
.\$(OBJDIR)\nsMsgNotificationManager.obj \
.\$(OBJDIR)\nsMsgCopyService.obj \
.\$(OBJDIR)\nsMsgFolderCache.obj \
.\$(OBJDIR)\nsMsgFolderCacheElement.obj \
$(NULL)

View File

@ -157,54 +157,43 @@ NS_IMETHODIMP nsCopyMessageStreamListener::Init(nsIMsgFolder *srcFolder, nsICopy
return NS_OK;
}
NS_IMETHODIMP nsCopyMessageStreamListener::GetBindInfo(nsIURI* aURL, nsStreamBindingInfo* aInfo)
{
return NS_OK;
}
NS_IMETHODIMP nsCopyMessageStreamListener::OnDataAvailable(nsIURI* aURL, nsIInputStream *aIStream,
PRUint32 aLength)
NS_IMETHODIMP nsCopyMessageStreamListener::OnDataAvailable(nsIChannel * /* aChannel */, nsISupports *ctxt, nsIInputStream *aIStream, PRUint32 sourceOffset, PRUint32 aLength)
{
nsresult rv;
rv = mDestination->CopyData(aIStream, aLength);
return rv;
}
NS_IMETHODIMP nsCopyMessageStreamListener::OnStartRequest(nsIURI* aURL, const char *aContentType)
NS_IMETHODIMP nsCopyMessageStreamListener::OnStartRequest(nsIChannel * aChannel, nsISupports *ctxt)
{
nsCOMPtr<nsIMessage> message;
nsresult rv;
rv = GetMessage(aURL, getter_AddRefs(message));
nsresult rv = NS_OK;
nsCOMPtr<nsIURI> uri = do_QueryInterface(ctxt, &rv);
if (NS_SUCCEEDED(rv))
rv = GetMessage(uri, getter_AddRefs(message));
if(NS_SUCCEEDED(rv))
rv = mDestination->BeginCopy(message);
return rv;
}
NS_IMETHODIMP nsCopyMessageStreamListener::OnProgress(nsIURI* aURL, PRUint32 aProgress, PRUint32 aProgressMax)
{
return NS_OK;
}
NS_IMETHODIMP nsCopyMessageStreamListener::OnStatus(nsIURI* aURL, const PRUnichar* aMsg)
{
return NS_OK;
}
NS_IMETHODIMP nsCopyMessageStreamListener::OnStopRequest(nsIURI* aURL, nsresult aStatus, const PRUnichar* aMsg)
NS_IMETHODIMP nsCopyMessageStreamListener::OnStopRequest(nsIChannel * aChannel, nsISupports *ctxt, nsresult aStatus, const PRUnichar *aMsg)
{
nsresult rv = NS_OK;
nsCOMPtr<nsIURI> uri = do_QueryInterface(ctxt, &rv);
if (NS_FAILED(rv)) return rv;
PRBool copySucceeded = (aStatus == NS_BINDING_SUCCEEDED);
rv = mDestination->EndCopy(copySucceeded);
//If this is a move and we finished the copy, delete the old message.
if(copySucceeded)
{
PRBool moveMessage;
IsMoveMessage(aURL, &moveMessage);
IsMoveMessage(uri, &moveMessage);
if(moveMessage)
{
rv = DeleteMessage(aURL, mSrcFolder);
rv = DeleteMessage(uri, mSrcFolder);
}
}
//Even if the above actions failed we probably still want to return NS_OK. There should probably

View File

@ -24,6 +24,7 @@
#include "nsIMsgFolder.h"
#include "nsICopyMessageListener.h"
#include "nsCOMPtr.h"
#include "nsIURI.h"
class nsCopyMessageStreamListener : public nsIStreamListener, public nsICopyMessageStreamListener {
@ -37,16 +38,9 @@ public:
NS_IMETHOD Init(nsIMsgFolder *srcFolder, nsICopyMessageListener *destination, nsISupports *listenerData);
//nsIStreamListener implementation
NS_IMETHOD GetBindInfo(nsIURI* aURL, nsStreamBindingInfo* aInfo);
NS_IMETHOD OnDataAvailable(nsIURI* aURL, nsIInputStream *aIStream,
PRUint32 aLength);
NS_IMETHOD OnStartRequest(nsIURI* aURL, const char *aContentType);
NS_IMETHOD OnProgress(nsIURI* aURL, PRUint32 aProgress, PRUint32 aProgressMax);
NS_IMETHOD OnStatus(nsIURI* aURL, const PRUnichar* aMsg);
NS_IMETHOD OnStopRequest(nsIURI* aURL, nsresult aStatus, const PRUnichar* aMsg);
NS_IMETHOD OnDataAvailable(nsIChannel * aChannel, nsISupports *ctxt, nsIInputStream *inStr, PRUint32 sourceOffset, PRUint32 count);
NS_IMETHOD OnStartRequest(nsIChannel * aChannel, nsISupports *ctxt);
NS_IMETHOD OnStopRequest(nsIChannel * aChannel, nsISupports *ctxt, nsresult status, const PRUnichar *errorMsg);
protected:
nsCOMPtr<nsICopyMessageListener> mDestination;

View File

@ -53,10 +53,10 @@
#include "nsRDFCID.h"
#include "nsIAppShell.h"
#include "nsIAppShellService.h"
#include "nsIIOService.h"
#include "nsAppShellCIDs.h"
#include "nsMsgRDFUtils.h"
#include "nsINetService.h"
#include "nsICopyMsgStreamListener.h"
#include "nsICopyMessageListener.h"
@ -74,11 +74,11 @@
#include "nsMsgCompCID.h"
#include "nsIMsgSendLaterListener.h"
static NS_DEFINE_CID(kIOServiceCID, NS_IOSERVICE_CID);
static NS_DEFINE_CID(kCMsgMailSessionCID, NS_MSGMAILSESSION_CID);
static NS_DEFINE_CID(kCPop3ServiceCID, NS_POP3SERVICE_CID);
static NS_DEFINE_CID(kRDFServiceCID, NS_RDFSERVICE_CID);
static NS_DEFINE_IID(kIDocumentViewerIID, NS_IDOCUMENT_VIEWER_IID);
static NS_DEFINE_CID(kNetServiceCID, NS_NETSERVICE_CID);
static NS_DEFINE_IID(kIDocumentViewerIID, NS_IDOCUMENT_VIEWER_IID);
static NS_DEFINE_IID(kAppShellServiceCID, NS_APPSHELL_SERVICE_CID);
static NS_DEFINE_CID(kTransactionManagerCID, NS_TRANSACTIONMANAGER_CID);
static NS_DEFINE_CID(kComponentManagerCID, NS_COMPONENTMANAGER_CID);
@ -256,7 +256,7 @@ NS_IMPL_ISUPPORTS(nsMessenger, nsCOMTypeInfo<nsIMessenger>::GetIID())
NS_IMETHODIMP
nsMessenger::Open3PaneWindow()
{
char * urlstr=nsnull;
const char * urlstr=nsnull;
nsresult rv = NS_OK;
nsCOMPtr<nsIWebShellWindow> newWindow;
@ -264,17 +264,15 @@ nsMessenger::Open3PaneWindow()
urlstr = "resource:/res/samples/messenger.html";
NS_WITH_SERVICE(nsIAppShellService, appShell, kAppShellServiceCID, &rv);
nsIURI* url = nsnull;
NS_WITH_SERVICE(nsINetService, pNetService, kNetServiceCID, &rv);
if (NS_SUCCEEDED(rv) && pNetService) {
rv = pNetService->CreateURL(&url, urlstr);
if (NS_FAILED(rv))
goto done; // goto in C++ is evil!
}
else
goto done; // goto in C++ is evil!
nsCOMPtr<nsIURI> url;
NS_WITH_SERVICE(nsIIOService, pNetService, kIOServiceCID, &rv);
appShell->CreateTopLevelWindow(nsnull, // parent
if (NS_SUCCEEDED(rv) && pNetService)
rv = pNetService->NewURI(urlstr, nsnull, getter_AddRefs(url));
if (NS_SUCCEEDED(rv))
rv = appShell->CreateTopLevelWindow(nsnull, // parent
url,
PR_TRUE,
NS_CHROME_ALL_CHROME,
@ -282,9 +280,7 @@ nsMessenger::Open3PaneWindow()
NS_SIZETOCONTENT, // width
NS_SIZETOCONTENT, // height
getter_AddRefs(newWindow)); // result widget
done:
NS_IF_RELEASE(url);
return NS_OK;
return rv;
}
nsresult

View File

@ -495,11 +495,11 @@ nsMsgMessageDataSource::createMessageNameNode(nsIMessage *message,
nsAutoString subject;
if(sort)
{
rv = message->GetSubjectCollationKey(subject);
rv = message->GetSubjectCollationKey(&subject);
}
else
{
rv = message->GetMime2EncodedSubject(subject);
rv = message->GetMime2DecodedSubject(&subject);
if(NS_FAILED(rv))
return rv;
PRUint32 flags;
@ -526,13 +526,13 @@ nsMsgMessageDataSource::createMessageSenderNode(nsIMessage *message,
nsAutoString sender, senderUserName;
if(sort)
{
rv = message->GetAuthorCollationKey(sender);
rv = message->GetAuthorCollationKey(&sender);
if(NS_SUCCEEDED(rv))
rv = createNode(sender, target);
}
else
{
rv = message->GetMime2EncodedAuthor(sender);
rv = message->GetMime2DecodedAuthor(&sender);
if(NS_SUCCEEDED(rv))
rv = GetSenderName(sender, &senderUserName);
if(NS_SUCCEEDED(rv))

View File

@ -188,7 +188,7 @@ NS_IMETHODIMP nsMessage::SetStatusOffset(PRUint32 statusOffset)
}
NS_IMETHODIMP nsMessage::GetAuthor(nsString &resultAuthor)
NS_IMETHODIMP nsMessage::GetAuthor(nsString *resultAuthor)
{
if(mMsgHdr)
return mMsgHdr->GetAuthor(resultAuthor);
@ -196,7 +196,7 @@ NS_IMETHODIMP nsMessage::GetAuthor(nsString &resultAuthor)
return NS_ERROR_FAILURE;
}
NS_IMETHODIMP nsMessage::GetSubject(nsString &resultSubject)
NS_IMETHODIMP nsMessage::GetSubject(nsString *resultSubject)
{
if(mMsgHdr)
return mMsgHdr->GetSubject(resultSubject);
@ -204,7 +204,7 @@ NS_IMETHODIMP nsMessage::GetSubject(nsString &resultSubject)
return NS_ERROR_FAILURE;
}
NS_IMETHODIMP nsMessage::GetRecipients(nsString &resultRecipients)
NS_IMETHODIMP nsMessage::GetRecipients(nsString *resultRecipients)
{
if(mMsgHdr)
return mMsgHdr->GetRecipients(resultRecipients);
@ -212,7 +212,7 @@ NS_IMETHODIMP nsMessage::GetRecipients(nsString &resultRecipients)
return NS_ERROR_FAILURE;
}
NS_IMETHODIMP nsMessage::GetCCList(nsString &ccList)
NS_IMETHODIMP nsMessage::GetCCList(nsString *ccList)
{
if(mMsgHdr)
return mMsgHdr->GetCCList(ccList);
@ -220,7 +220,7 @@ NS_IMETHODIMP nsMessage::GetCCList(nsString &ccList)
return NS_ERROR_FAILURE;
}
NS_IMETHODIMP nsMessage::GetMessageId(nsString &resultMessageId)
NS_IMETHODIMP nsMessage::GetMessageId(nsString *resultMessageId)
{
if(mMsgHdr)
return mMsgHdr->GetMessageId(resultMessageId);
@ -229,32 +229,32 @@ NS_IMETHODIMP nsMessage::GetMessageId(nsString &resultMessageId)
}
NS_IMETHODIMP nsMessage::GetMime2EncodedAuthor(nsString &resultAuthor)
NS_IMETHODIMP nsMessage::GetMime2DecodedAuthor(nsString *resultAuthor)
{
if(mMsgHdr)
return mMsgHdr->GetMime2EncodedAuthor(resultAuthor);
return mMsgHdr->GetMime2DecodedAuthor(resultAuthor);
else
return NS_ERROR_FAILURE;
}
NS_IMETHODIMP nsMessage::GetMime2EncodedSubject(nsString &resultSubject)
NS_IMETHODIMP nsMessage::GetMime2DecodedSubject(nsString *resultSubject)
{
if(mMsgHdr)
return mMsgHdr->GetMime2EncodedSubject(resultSubject);
return mMsgHdr->GetMime2DecodedSubject(resultSubject);
else
return NS_ERROR_FAILURE;
}
NS_IMETHODIMP nsMessage::GetMime2EncodedRecipients(nsString &resultRecipients)
NS_IMETHODIMP nsMessage::GetMime2DecodedRecipients(nsString *resultRecipients)
{
if(mMsgHdr)
return mMsgHdr->GetMime2EncodedRecipients(resultRecipients);
return mMsgHdr->GetMime2DecodedRecipients(resultRecipients);
else
return NS_ERROR_FAILURE;
}
NS_IMETHODIMP nsMessage::GetAuthorCollationKey(nsString &resultAuthor)
NS_IMETHODIMP nsMessage::GetAuthorCollationKey(nsString *resultAuthor)
{
if(mMsgHdr)
return mMsgHdr->GetAuthorCollationKey(resultAuthor);
@ -262,7 +262,7 @@ NS_IMETHODIMP nsMessage::GetAuthorCollationKey(nsString &resultAuthor)
return NS_ERROR_FAILURE;
}
NS_IMETHODIMP nsMessage::GetSubjectCollationKey(nsString &resultSubject)
NS_IMETHODIMP nsMessage::GetSubjectCollationKey(nsString *resultSubject)
{
if(mMsgHdr)
return mMsgHdr->GetSubjectCollationKey(resultSubject);
@ -270,7 +270,7 @@ NS_IMETHODIMP nsMessage::GetSubjectCollationKey(nsString &resultSubject)
return NS_ERROR_FAILURE;
}
NS_IMETHODIMP nsMessage::GetRecipientsCollationKey(nsString &resultRecipients)
NS_IMETHODIMP nsMessage::GetRecipientsCollationKey(nsString *resultRecipients)
{
if(mMsgHdr)
return mMsgHdr->GetRecipientsCollationKey(resultRecipients);
@ -424,7 +424,7 @@ NS_IMETHODIMP nsMessage::GetStatusOffset(PRUint32 *result)
return NS_ERROR_FAILURE;
}
NS_IMETHODIMP nsMessage::GetCharSet(nsString &result)
NS_IMETHODIMP nsMessage::GetCharSet(nsString *result)
{
if(mMsgHdr)
return mMsgHdr->GetCharSet(result);

View File

@ -58,19 +58,19 @@ public:
NS_IMETHOD SetSubject(const char *subject);
NS_IMETHOD SetStatusOffset(PRUint32 statusOffset);
NS_IMETHOD GetAuthor(nsString &resultAuthor);
NS_IMETHOD GetSubject(nsString &resultSubject);
NS_IMETHOD GetRecipients(nsString &resultRecipients);
NS_IMETHOD GetCCList(nsString &ccList);
NS_IMETHOD GetMessageId(nsString &resultMessageId);
NS_IMETHOD GetAuthor(nsString *resultAuthor);
NS_IMETHOD GetSubject(nsString *resultSubject);
NS_IMETHOD GetRecipients(nsString *resultRecipients);
NS_IMETHOD GetCCList(nsString *ccList);
NS_IMETHOD GetMessageId(nsString *resultMessageId);
NS_IMETHOD GetMime2EncodedAuthor(nsString &resultAuthor);
NS_IMETHOD GetMime2EncodedSubject(nsString &resultSubject);
NS_IMETHOD GetMime2EncodedRecipients(nsString &resultRecipients);
NS_IMETHOD GetMime2DecodedAuthor(nsString *resultAuthor);
NS_IMETHOD GetMime2DecodedSubject(nsString *resultSubject);
NS_IMETHOD GetMime2DecodedRecipients(nsString *resultRecipients);
NS_IMETHOD GetAuthorCollationKey(nsString &resultAuthor);
NS_IMETHOD GetSubjectCollationKey(nsString &resultSubject);
NS_IMETHOD GetRecipientsCollationKey(nsString &resultRecipients);
NS_IMETHOD GetAuthorCollationKey(nsString *resultAuthor);
NS_IMETHOD GetSubjectCollationKey(nsString *resultSubject);
NS_IMETHOD GetRecipientsCollationKey(nsString *resultRecipients);
// flag handling routines
NS_IMETHOD GetFlags(PRUint32 *result);
@ -93,7 +93,7 @@ public:
NS_IMETHOD SetPriority(const char *priority);
NS_IMETHOD GetMessageOffset(PRUint32 *result);
NS_IMETHOD GetStatusOffset(PRUint32 *result);
NS_IMETHOD GetCharSet(nsString &result);
NS_IMETHOD GetCharSet(nsString *result);
NS_IMETHOD GetPriority(nsMsgPriority *result);
NS_IMETHOD GetThreadParent(nsMsgKey *result);
NS_IMETHOD SetThreadParent(nsMsgKey inKey);

View File

@ -20,49 +20,28 @@
#include "nsMsgMailNewsUrl.h"
#include "nsMsgBaseCID.h"
#ifdef XP_PC
#include <windows.h> // for InterlockedIncrement
#endif
static NS_DEFINE_CID(kUrlListenerManagerCID, NS_URLLISTENERMANAGER_CID);
static NS_DEFINE_CID(kStandardUrlCID, NS_STANDARDURL_CID);
nsMsgMailNewsUrl::nsMsgMailNewsUrl()
{
NS_INIT_REFCNT();
// nsINetLibUrl specific state
m_URL_s = nsnull;
// nsIURI specific state
m_protocol = nsnull;
m_host = nsnull;
m_file = nsnull;
m_ref = nsnull;
m_port = 0;
m_spec = nsnull;
m_search = nsnull;
m_errorMessage = nsnull;
m_runningUrl = PR_FALSE;
nsComponentManager::CreateInstance(kUrlListenerManagerCID, nsnull, nsCOMTypeInfo<nsIUrlListenerManager>::GetIID(), (void **) getter_AddRefs(m_urlListeners));
m_container = nsnull;
nsComponentManager::CreateInstance(kStandardUrlCID, nsnull, nsCOMTypeInfo<nsIURL>::GetIID(), (void **) getter_AddRefs(m_baseURL));
}
nsMsgMailNewsUrl::~nsMsgMailNewsUrl()
{
NS_IF_RELEASE(m_container);
PR_FREEIF(m_errorMessage);
PR_FREEIF(m_spec);
PR_FREEIF(m_protocol);
PR_FREEIF(m_host);
PR_FREEIF(m_file);
PR_FREEIF(m_ref);
PR_FREEIF(m_search);
}
NS_IMPL_THREADSAFE_ADDREF(nsMsgMailNewsUrl);
NS_IMPL_THREADSAFE_RELEASE(nsMsgMailNewsUrl);
NS_IMPL_ADDREF(nsMsgMailNewsUrl);
NS_IMPL_RELEASE(nsMsgMailNewsUrl);
nsresult nsMsgMailNewsUrl::QueryInterface(const nsIID &aIID, void** aInstancePtr)
{
@ -71,25 +50,25 @@ nsresult nsMsgMailNewsUrl::QueryInterface(const nsIID &aIID, void** aInstancePtr
}
if (aIID.Equals(nsCOMTypeInfo<nsIURI>::GetIID())) {
*aInstancePtr = (void*) ((nsIURI*)this);
AddRef();
NS_ADDREF_THIS();
return NS_OK;
}
if (aIID.Equals(nsCOMTypeInfo<nsINetlibURL>::GetIID())) {
*aInstancePtr = (void*) ((nsINetlibURL*)this);
AddRef();
if (aIID.Equals(nsCOMTypeInfo<nsIURL>::GetIID())) {
*aInstancePtr = (void*) ((nsIURL*)this);
NS_ADDREF_THIS();
return NS_OK;
}
if (aIID.Equals(nsCOMTypeInfo<nsIMsgMailNewsUrl>::GetIID()))
{
*aInstancePtr = (void *) ((nsIMsgMailNewsUrl*) this);
AddRef();
NS_ADDREF_THIS();
return NS_OK;
}
if (aIID.Equals(nsCOMTypeInfo<nsISupports>::GetIID()))
if (aIID.Equals(nsCOMTypeInfo<nsISupports>::GetIID()))
{
*aInstancePtr = (void *) ((nsIMsgMailNewsUrl*) this);
AddRef();
NS_ADDREF_THIS();
return NS_OK;
}
#if defined(NS_DEBUG)
@ -146,20 +125,16 @@ nsresult nsMsgMailNewsUrl::UnRegisterListener (nsIUrlListener * aUrlListener)
nsresult nsMsgMailNewsUrl::SetErrorMessage (char * errorMessage)
{
NS_LOCK_INSTANCE();
if (errorMessage)
{
PR_FREEIF(m_errorMessage);
m_errorMessage = errorMessage;
}
NS_UNLOCK_INSTANCE();
return NS_OK;
}
// caller must free using PR_FREE
nsresult nsMsgMailNewsUrl::GetErrorMessage (char ** errorMessage) const
{
NS_LOCK_INSTANCE();
if (errorMessage)
{
if (m_errorMessage)
@ -167,7 +142,6 @@ nsresult nsMsgMailNewsUrl::GetErrorMessage (char ** errorMessage) const
else
*errorMessage = nsnull;
}
NS_UNLOCK_INSTANCE();
return NS_OK;
}
@ -175,281 +149,130 @@ nsresult nsMsgMailNewsUrl::GetErrorMessage (char ** errorMessage) const
// End nsIMsgMailNewsUrl specific support
////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////
// Begin nsINetlibURL support
////////////////////////////////////////////////////////////////////////////////////
NS_METHOD nsMsgMailNewsUrl::SetURLInfo(URL_Struct *URL_s)
{
nsresult result = NS_OK;
/* Hook us up with the world. */
m_URL_s = URL_s;
return result;
}
NS_METHOD nsMsgMailNewsUrl::GetURLInfo(URL_Struct_** aResult) const
{
nsresult rv;
if (nsnull == aResult)
rv = NS_ERROR_NULL_POINTER;
else
{
*aResult = m_URL_s;
rv = NS_OK;
}
return rv;
}
////////////////////////////////////////////////////////////////////////////////////
// End nsINetlibURL support
////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////
// Begin nsIURI support
////////////////////////////////////////////////////////////////////////////////////
nsresult nsMsgMailNewsUrl::GetProtocol(const char* *result) const
NS_IMETHODIMP nsMsgMailNewsUrl::GetSpec(char * *aSpec)
{
NS_LOCK_INSTANCE();
*result = m_protocol;
NS_UNLOCK_INSTANCE();
return NS_OK;
return m_baseURL->GetSpec(aSpec);
}
nsresult nsMsgMailNewsUrl::SetProtocol(const char *aNewProtocol)
NS_IMETHODIMP nsMsgMailNewsUrl::SetSpec(char * aSpec)
{
NS_ASSERTION(m_URL_s == nsnull, "URL has already been opened");
NS_LOCK_INSTANCE();
m_protocol = nsCRT::strdup(aNewProtocol);
ReconstructSpec();
NS_UNLOCK_INSTANCE();
return NS_OK;
return m_baseURL->SetSpec(aSpec);
}
nsresult nsMsgMailNewsUrl::GetHost(const char* *result) const
NS_IMETHODIMP nsMsgMailNewsUrl::GetScheme(char * *aScheme)
{
NS_LOCK_INSTANCE();
*result = m_host;
NS_UNLOCK_INSTANCE();
return NS_OK;
return m_baseURL->GetScheme(aScheme);
}
nsresult nsMsgMailNewsUrl::SetHost(const char *aNewHost)
NS_IMETHODIMP nsMsgMailNewsUrl::SetScheme(char * aScheme)
{
NS_ASSERTION(m_URL_s == nsnull, "URL has already been opened");
NS_LOCK_INSTANCE();
m_host = nsCRT::strdup(aNewHost);
ReconstructSpec();
NS_UNLOCK_INSTANCE();
return NS_OK;
}
nsresult nsMsgMailNewsUrl::GetFile(const char* *result) const
{
NS_LOCK_INSTANCE();
*result = m_file;
NS_UNLOCK_INSTANCE();
return NS_OK;
}
nsresult nsMsgMailNewsUrl::SetFile(const char *aNewFile)
{
NS_ASSERTION(m_URL_s == nsnull, "URL has already been opened");
NS_LOCK_INSTANCE();
m_file = nsCRT::strdup(aNewFile);
ReconstructSpec();
NS_UNLOCK_INSTANCE();
return NS_OK;
}
nsresult nsMsgMailNewsUrl::GetSpec(const char* *result) const
{
NS_LOCK_INSTANCE();
*result = m_spec;
NS_UNLOCK_INSTANCE();
return NS_OK;
}
nsresult nsMsgMailNewsUrl::SetSpec(const char *aNewSpec)
{
// XXX is this right, or should we call ParseURL?
nsresult rv = NS_OK;
// NS_ASSERTION(m_URL_s == nsnull, "URL has already been opened");
NS_LOCK_INSTANCE();
rv = ParseUrl(aNewSpec);
#if 0
PR_FREEIF(m_spec);
m_spec = nsCRT::strdup(aNewSpec);
#endif
NS_UNLOCK_INSTANCE();
return rv;
}
nsresult nsMsgMailNewsUrl::GetRef(const char* *result) const
{
NS_LOCK_INSTANCE();
*result = m_ref;
NS_UNLOCK_INSTANCE();
return NS_OK;
}
nsresult nsMsgMailNewsUrl::SetRef(const char *aNewRef)
{
NS_ASSERTION(m_URL_s == nsnull, "URL has already been opened");
NS_LOCK_INSTANCE();
m_ref = nsCRT::strdup(aNewRef);
ReconstructSpec();
NS_UNLOCK_INSTANCE();
return NS_OK;
}
nsresult nsMsgMailNewsUrl::GetHostPort(PRUint32 *result) const
{
NS_LOCK_INSTANCE();
*result = m_port;
NS_UNLOCK_INSTANCE();
return NS_OK;
}
nsresult nsMsgMailNewsUrl::SetHostPort(PRUint32 aNewPort)
{
NS_ASSERTION(m_URL_s == nsnull, "URL has already been opened");
NS_LOCK_INSTANCE();
m_port = aNewPort;
ReconstructSpec();
NS_UNLOCK_INSTANCE();
return NS_OK;
}
nsresult nsMsgMailNewsUrl::GetSearch(const char* *result) const
{
NS_LOCK_INSTANCE();
*result = m_search;
NS_UNLOCK_INSTANCE();
return NS_OK;
}
nsresult nsMsgMailNewsUrl::SetSearch(const char *aNewSearch)
{
NS_ASSERTION(m_URL_s == nsnull, "URL has already been opened");
NS_LOCK_INSTANCE();
m_search = nsCRT::strdup(aNewSearch);
ReconstructSpec();
NS_UNLOCK_INSTANCE();
return NS_OK;
}
nsresult nsMsgMailNewsUrl::GetContainer(nsISupports* *result) const
{
NS_LOCK_INSTANCE();
*result = m_container;
NS_IF_ADDREF(m_container);
NS_UNLOCK_INSTANCE();
return NS_OK;
}
nsresult nsMsgMailNewsUrl::SetContainer(nsISupports* container)
{
NS_ASSERTION(m_URL_s == nsnull, "URL has already been opened");
NS_LOCK_INSTANCE();
NS_IF_RELEASE(m_container);
m_container = container;
NS_IF_ADDREF(m_container);
NS_UNLOCK_INSTANCE();
return NS_OK;
}
nsresult nsMsgMailNewsUrl::GetContentLength(PRInt32 *len)
{
NS_LOCK_INSTANCE();
*len = m_URL_s->content_length;
NS_UNLOCK_INSTANCE();
return NS_OK;
}
nsresult nsMsgMailNewsUrl::SetPostHeader(const char* name, const char* value)
{
NS_LOCK_INSTANCE();
// XXX
PR_ASSERT(0);
NS_UNLOCK_INSTANCE();
return NS_OK;
}
nsresult nsMsgMailNewsUrl::SetPostData(nsIInputStream* input)
{
return NS_OK;
return m_baseURL->SetScheme(aScheme);
}
PRBool nsMsgMailNewsUrl::Equals(const nsIURI* aURL) const
NS_IMETHODIMP nsMsgMailNewsUrl::GetPreHost(char * *aPreHost)
{
PRBool bIsEqual;
nsIMsgMailNewsUrl * other;
NS_LOCK_INSTANCE();
// for now just compare the pointers until
// I figure out if we need to check any of the guts for equality....
if (((nsIURI*)aURL)->QueryInterface(nsCOMTypeInfo<nsIMsgMailNewsUrl>::GetIID(), (void**)&other) == NS_OK) {
bIsEqual = other == (nsIMsgMailNewsUrl *) this; // compare the pointers...
}
else
bIsEqual = PR_FALSE;
NS_UNLOCK_INSTANCE();
return bIsEqual;
return m_baseURL->GetPreHost(aPreHost);
}
////////////////////////////////////////////////////////////////////////////////////
// End of nsIURI support
////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////
// The following set of functions should become obsolete once we take them out of
// nsIURI.....
////////////////////////////////////////////////////////////////////////////////////
nsresult nsMsgMailNewsUrl::GetLoadAttribs(nsILoadAttribs* *result) const
NS_IMETHODIMP nsMsgMailNewsUrl::SetPreHost(char * aPreHost)
{
NS_LOCK_INSTANCE();
*result = NULL;
NS_UNLOCK_INSTANCE();
return NS_OK;
}
nsresult nsMsgMailNewsUrl::SetLoadAttribs(nsILoadAttribs* aLoadAttribs)
{
NS_ASSERTION(m_URL_s == nsnull, "URL has already been opened");
return NS_OK;
return m_baseURL->SetPreHost(aPreHost);
}
nsresult nsMsgMailNewsUrl::GetLoadGroup(nsILoadGroup* *result) const
NS_IMETHODIMP nsMsgMailNewsUrl::GetHost(char * *aHost)
{
return NS_OK;
return m_baseURL->GetHost(aHost);
}
nsresult nsMsgMailNewsUrl::SetLoadGroup(nsILoadGroup* group)
NS_IMETHODIMP nsMsgMailNewsUrl::SetHost(char * aHost)
{
NS_ASSERTION(m_URL_s == nsnull, "URL has already been opened");
return NS_OK;
return m_baseURL->SetHost(aHost);
}
nsresult nsMsgMailNewsUrl::GetServerStatus(PRInt32 *status)
NS_IMETHODIMP nsMsgMailNewsUrl::GetPort(PRInt32 *aPort)
{
NS_LOCK_INSTANCE();
*status = m_URL_s->server_status;
NS_UNLOCK_INSTANCE();
return NS_OK;
return m_baseURL->GetPort(aPort);
}
nsresult nsMsgMailNewsUrl::ToString(PRUnichar* *aString) const
{
if (aString)
*aString = nsnull;
return NS_OK;
NS_IMETHODIMP nsMsgMailNewsUrl::SetPort(PRInt32 aPort)
{
return m_baseURL->SetPort(aPort);
}
////////////////////////////////////////////////////////////////////////////////////
// End of functions which should be made obsolete after modifying nsIURI
////////////////////////////////////////////////////////////////////////////////////
NS_IMETHODIMP nsMsgMailNewsUrl::GetPath(char * *aPath)
{
return m_baseURL->GetPath(aPath);
}
NS_IMETHODIMP nsMsgMailNewsUrl::SetPath(char * aPath)
{
return m_baseURL->SetPath(aPath);
}
NS_IMETHODIMP nsMsgMailNewsUrl::Equals(nsIURI *other, PRBool *_retval)
{
return m_baseURL->Equals(other, _retval);
}
NS_IMETHODIMP nsMsgMailNewsUrl::Clone(nsIURI **_retval)
{
return m_baseURL->Clone(_retval);
}
NS_IMETHODIMP nsMsgMailNewsUrl::SetRelativePath(const char *i_RelativePath)
{
return m_baseURL->SetRelativePath(i_RelativePath);
}
NS_IMETHODIMP nsMsgMailNewsUrl::GetDirectory(char * *aDirectory)
{
return m_baseURL->GetDirectory(aDirectory);
}
NS_IMETHODIMP nsMsgMailNewsUrl::SetDirectory(char *aDirectory)
{
return m_baseURL->SetDirectory(aDirectory);
}
NS_IMETHODIMP nsMsgMailNewsUrl::GetFileName(char * *aFileName)
{
return m_baseURL->GetFileName(aFileName);
}
NS_IMETHODIMP nsMsgMailNewsUrl::SetFileName(char * aFileName)
{
return m_baseURL->SetFileName(aFileName);
}
NS_IMETHODIMP nsMsgMailNewsUrl::GetQuery(char * *aQuery)
{
return m_baseURL->GetQuery(aQuery);
}
NS_IMETHODIMP nsMsgMailNewsUrl::SetQuery(char *aQuery)
{
return m_baseURL->SetQuery(aQuery);
}
NS_IMETHODIMP nsMsgMailNewsUrl::GetRef(char * *aRef)
{
return m_baseURL->GetRef(aRef);
}
NS_IMETHODIMP nsMsgMailNewsUrl::SetRef(char *aRef)
{
return m_baseURL->SetRef(aRef);
}
NS_IMETHODIMP nsMsgMailNewsUrl::DirFile(char **o_DirFile)
{
return m_baseURL->DirFile(o_DirFile);
}

View File

@ -21,28 +21,21 @@
#include "nscore.h"
#include "nsISupports.h"
#include "nsIURL.h"
#include "nsINetlibURL.h" /* this should be temporary until Network N2 project lands */
#include "nsIUrlListener.h"
#include "nsIUrlListenerManager.h"
#include "nsCOMPtr.h"
#include "nsIMsgMailNewsUrl.h"
#include "nsIURL.h"
///////////////////////////////////////////////////////////////////////////////////
// Okay, I found that all of the mail and news url interfaces needed to support
// several common interfaces (in addition to those provided through nsIURI).
// So I decided to group them all in this interface.
// This interface may grow or it may get smaller (if these things get pushed up
// into nsIURI). The unfortunate thing is that we'd also like to have all of our
// mail news protocols inherit implementations of this interface. But that is
// implementation inheritance across dlls. We could do it though....something else
// to add to the list =).
// So I decided to group them all in this implementation so we don't have to
// duplicate the code.
//
// mscott - I'm now adding a base url implementation for mailnews to unify
// some common code....
//////////////////////////////////////////////////////////////////////////////////
class NS_MSG_BASE nsMsgMailNewsUrl : public nsIMsgMailNewsUrl, public nsINetlibURL
class NS_MSG_BASE nsMsgMailNewsUrl : public nsIMsgMailNewsUrl
{
public:
nsMsgMailNewsUrl();
@ -73,63 +66,65 @@ public:
NS_IMETHOD SetUrlState(PRBool runningUrl, nsresult aStatusCode);
NS_IMETHOD GetUrlState(PRBool *runningUrl);
//////////////////////////////////////////////////////////////////////////////////
// nsIURI support
// mscott: some of these we won't need to implement..as part of the netlib re-write we'll be removing them
// from nsIURI and then we can remove them from here as well....
NS_IMETHOD_(PRBool) Equals(const nsIURI *aURL) const;
NS_IMETHOD GetSpec(const char* *result) const;
NS_IMETHOD SetSpec(const char* spec);
NS_IMETHOD GetProtocol(const char* *result) const;
NS_IMETHOD SetProtocol(const char* protocol);
NS_IMETHOD GetHost(const char* *result) const;
NS_IMETHOD SetHost(const char* host);
NS_IMETHOD GetHostPort(PRUint32 *result) const;
NS_IMETHOD SetHostPort(PRUint32 port);
NS_IMETHOD GetFile(const char* *result) const;
NS_IMETHOD SetFile(const char* file);
NS_IMETHOD GetRef(const char* *result) const;
NS_IMETHOD SetRef(const char* ref);
NS_IMETHOD GetSearch(const char* *result) const;
NS_IMETHOD SetSearch(const char* search);
NS_IMETHOD GetContainer(nsISupports* *result) const;
NS_IMETHOD SetContainer(nsISupports* container);
NS_IMETHOD GetLoadAttribs(nsILoadAttribs* *result) const; // make obsolete
NS_IMETHOD SetLoadAttribs(nsILoadAttribs* loadAttribs); // make obsolete
NS_IMETHOD GetLoadGroup(nsILoadGroup* *result) const; // make obsolete
NS_IMETHOD SetLoadGroup(nsILoadGroup* group); // make obsolete
NS_IMETHOD SetPostHeader(const char* name, const char* value); // make obsolete
NS_IMETHOD SetPostData(nsIInputStream* input); // make obsolete
NS_IMETHOD GetContentLength(PRInt32 *len);
NS_IMETHOD GetServerStatus(PRInt32 *status); // make obsolete
NS_IMETHOD ToString(PRUnichar* *aString) const;
NS_IMETHOD GetSpec(char * *aSpec);
NS_IMETHOD SetSpec(char * aSpec);
// from nsINetlibURL:
/* attribute string Scheme; */
NS_IMETHOD GetScheme(char * *aScheme);
NS_IMETHOD SetScheme(char * aScheme);
NS_IMETHOD GetURLInfo(URL_Struct_ **aResult) const;
NS_IMETHOD SetURLInfo(URL_Struct_ *URL_s);
/* attribute string PreHost; */
NS_IMETHOD GetPreHost(char * *aPreHost);
NS_IMETHOD SetPreHost(char * aPreHost);
/* attribute string Host; */
NS_IMETHOD GetHost(char * *aHost);
NS_IMETHOD SetHost(char * aHost);
/* attribute long Port; */
NS_IMETHOD GetPort(PRInt32 *aPort);
NS_IMETHOD SetPort(PRInt32 aPort);
/* attribute string Path; */
NS_IMETHOD GetPath(char * *aPath);
NS_IMETHOD SetPath(char * aPath);
/* boolean Equals (in nsIURI other); */
NS_IMETHOD Equals(nsIURI *other, PRBool *_retval);
/* nsIURI Clone (); */
NS_IMETHOD Clone(nsIURI **_retval);
NS_IMETHOD SetRelativePath(const char *i_RelativePath);
//////////////////////////////////////////////////////////////////////////////////
// nsIURL support
NS_IMETHOD GetDirectory(char * *aDirectory);
NS_IMETHOD SetDirectory(char * aDirectory);
/* attribute string FileName; */
NS_IMETHOD GetFileName(char * *aFileName);
NS_IMETHOD SetFileName(char * aFileName);
/* attribute string Query; */
NS_IMETHOD GetQuery(char * *aQuery);
NS_IMETHOD SetQuery(char * aQuery);
/* attribute string Ref; */
NS_IMETHOD GetRef(char * *aRef);
NS_IMETHOD SetRef(char * aRef);
NS_IMETHOD DirFile(char **o_DirFile);
protected:
virtual ~nsMsgMailNewsUrl();
virtual void ReconstructSpec(void) = 0;
// protocol specific code to parse a url...
virtual nsresult ParseUrl(const nsString& aSpec) = 0;
char *m_spec;
char *m_protocol;
char *m_host;
char *m_file;
char *m_ref;
char *m_search;
nsCOMPtr<nsIURL> m_baseURL;
char *m_errorMessage;
/* Here's our link to the netlib world.... */
URL_Struct *m_URL_s;
PRBool m_runningUrl;
PRInt32 m_port;
nsISupports* m_container;
// manager of all of current url listeners....
nsCOMPtr<nsIUrlListenerManager> m_urlListeners;

View File

@ -19,9 +19,12 @@
#include "msgCore.h"
#include "nsMsgProtocol.h"
#include "nsIMsgMailNewsUrl.h"
#include "nsINetService.h"
#include "nsISocketTransportService.h"
#include "nsXPIDLString.h"
#include "nsIIOService.h"
static NS_DEFINE_CID(kNetServiceCID, NS_NETSERVICE_CID);
static NS_DEFINE_CID(kSocketTransportServiceCID, NS_SOCKETTRANSPORTSERVICE_CID);
static NS_DEFINE_CID(kIOServiceCID, NS_IOSERVICE_CID);
NS_IMPL_ISUPPORTS(nsMsgProtocol, nsCOMTypeInfo<nsIStreamListener>::GetIID())
@ -29,43 +32,65 @@ nsMsgProtocol::nsMsgProtocol()
{
NS_INIT_REFCNT();
m_flags = 0;
m_startPosition = 0;
m_readCount = 0;
m_socketIsOpen = PR_FALSE;
}
nsMsgProtocol::~nsMsgProtocol()
{}
nsresult nsMsgProtocol::OpenNetworkSocket(nsIURI * aURL, PRUint32 aPort, const char * aHostName) // open a connection on this url
nsresult nsMsgProtocol::OpenNetworkSocket(nsIURI * aURL) // open a connection on this url
{
nsresult rv = NS_OK;
nsXPIDLCString hostName;
PRInt32 port = 0;
NS_WITH_SERVICE(nsINetService, pNetService, kNetServiceCID, &rv);
if (NS_SUCCEEDED(rv) && pNetService)
m_readCount = -1; // with socket connections we want to read as much data as arrives
m_startPosition = 0;
NS_WITH_SERVICE(nsISocketTransportService, socketService, kSocketTransportServiceCID, &rv);
if (NS_SUCCEEDED(rv) && aURL)
{
rv = pNetService->CreateSocketTransport(getter_AddRefs(m_transport), aPort, aHostName);
if (NS_SUCCEEDED(rv) && m_transport)
aURL->GetPort(&port);
aURL->GetHost(getter_Copies(hostName));
rv = socketService->CreateTransport(hostName, port, getter_AddRefs(m_channel));
if (NS_SUCCEEDED(rv) && m_channel)
{
m_socketIsOpen = PR_FALSE;
rv = SetupTransportState();
m_socketIsOpen = PR_TRUE;
}
}
return rv;
}
nsresult nsMsgProtocol::OpenFileSocket(nsIURI * aURL, const nsFileSpec * aFileSpec)
nsresult nsMsgProtocol::OpenFileSocket(nsIURI * aURL, const nsFileSpec * aFileSpec, PRUint32 aStartPosition, PRInt32 aReadCount)
{
// mscott - file needs to be encoded directly into aURL. I should be able to get
// rid of this method completely.
nsresult rv = NS_OK;
NS_WITH_SERVICE(nsINetService, pNetService, kNetServiceCID, &rv);
if (NS_SUCCEEDED(rv) && pNetService && aURL)
m_startPosition = aStartPosition;
m_readCount = aReadCount;
NS_WITH_SERVICE(nsIIOService, netService, kIOServiceCID, &rv);
if (NS_SUCCEEDED(rv) && aURL)
{
nsFilePath filePath(*aFileSpec);
rv = pNetService->CreateFileSocketTransport(getter_AddRefs(m_transport), filePath);
if (NS_SUCCEEDED(rv) && m_transport)
// extract the file path from the uri...
nsXPIDLCString filePath;
aURL->GetPath(getter_Copies(filePath));
char * urlSpec = PR_smprintf("file://%s", (const char *) filePath);
rv = netService->NewChannel("Load", urlSpec, nsnull, nsnull, getter_AddRefs(m_channel));
PR_FREEIF(urlSpec);
if (NS_SUCCEEDED(rv) && m_channel)
{
rv = SetupTransportState();
m_socketIsOpen = PR_TRUE;
m_socketIsOpen = PR_FALSE;
// rv = SetupTransportState();
}
}
@ -76,17 +101,12 @@ nsresult nsMsgProtocol::SetupTransportState()
{
nsresult rv = NS_OK;
if (m_transport)
if (!m_socketIsOpen && m_channel)
{
rv = m_transport->GetOutputStream(getter_AddRefs(m_outputStream));
rv = m_channel->OpenOutputStream(0 /* start position */, getter_AddRefs(m_outputStream));
NS_ASSERTION(NS_SUCCEEDED(rv), "unable to create an output stream");
rv = m_transport->GetOutputStreamConsumer(getter_AddRefs(m_outputConsumer));
NS_ASSERTION(NS_SUCCEEDED(rv), "unable to create an output consumer");
// register self as the consumer for the socket...
rv = m_transport->SetInputStreamConsumer((nsIStreamListener *) this);
NS_ASSERTION(NS_SUCCEEDED(rv), "unable to register NNTP instance as a consumer on the socket");
// we want to open the stream
} // if m_transport
return rv;
@ -97,8 +117,7 @@ nsresult nsMsgProtocol::CloseSocket()
// release all of our socket state
m_socketIsOpen = PR_FALSE;
m_outputStream = null_nsCOMPtr();
m_outputConsumer = null_nsCOMPtr();
m_transport = null_nsCOMPtr();
m_channel = null_nsCOMPtr();
return NS_OK;
}
@ -115,20 +134,10 @@ PRInt32 nsMsgProtocol::SendData(nsIURI * aURL, const char * dataBuffer)
PRUint32 writeCount = 0;
PRInt32 status = 0;
NS_PRECONDITION(m_outputStream && m_outputConsumer, "no registered consumer for our output");
// NS_PRECONDITION(m_outputStream, "oops....we don't have an output stream...how did that happen?");
if (dataBuffer && m_outputStream)
{
nsresult rv = m_outputStream->Write(dataBuffer, PL_strlen(dataBuffer), &writeCount);
if (NS_SUCCEEDED(rv) && writeCount == PL_strlen(dataBuffer))
{
nsCOMPtr<nsIInputStream> inputStream;
inputStream = do_QueryInterface(m_outputStream);
if (inputStream)
m_outputConsumer->OnDataAvailable(aURL, inputStream, writeCount);
status = 1; // mscott: we need some type of MK_OK? MK_SUCCESS? Arrgghhh
}
else // the write failed for some reason, returning 0 trips an error by the caller
status = 0; // mscott: again, I really want to add an error code here!!
}
return status;
@ -136,41 +145,53 @@ PRInt32 nsMsgProtocol::SendData(nsIURI * aURL, const char * dataBuffer)
// Whenever data arrives from the connection, core netlib notifices the protocol by calling
// OnDataAvailable. We then read and process the incoming data from the input stream.
NS_IMETHODIMP nsMsgProtocol::OnDataAvailable(nsIURI* aURL, nsIInputStream *aIStream, PRUint32 aLength)
NS_IMETHODIMP nsMsgProtocol::OnDataAvailable(nsIChannel * /* aChannel */, nsISupports *ctxt, nsIInputStream *inStr, PRUint32 sourceOffset, PRUint32 count)
{
// right now, this really just means turn around and churn through the state machine
return ProcessProtocolState(aURL, aIStream, aLength);
nsCOMPtr<nsIURI> uri = do_QueryInterface(ctxt);
return ProcessProtocolState(uri, inStr, sourceOffset, count);
}
NS_IMETHODIMP nsMsgProtocol::OnStartRequest(nsIURI* aURL, const char *aContentType)
NS_IMETHODIMP nsMsgProtocol::OnStartRequest(nsIChannel * aChannel, nsISupports *ctxt)
{
nsCOMPtr <nsIMsgMailNewsUrl> aMsgUrl = do_QueryInterface(aURL);
return aMsgUrl->SetUrlState(PR_TRUE, NS_OK);
nsresult rv = NS_OK;
nsCOMPtr <nsIMsgMailNewsUrl> aMsgUrl = do_QueryInterface(ctxt, &rv);
if (NS_SUCCEEDED(rv) && aMsgUrl)
return aMsgUrl->SetUrlState(PR_TRUE, NS_OK);
else
return NS_ERROR_NO_INTERFACE;
}
// stop binding is a "notification" informing us that the stream associated with aURL is going away.
NS_IMETHODIMP nsMsgProtocol::OnStopRequest(nsIURI* aURL, nsresult aStatus, const PRUnichar* aMsg)
NS_IMETHODIMP nsMsgProtocol::OnStopRequest(nsIChannel * aChannel, nsISupports *ctxt, nsresult aStatus, const PRUnichar* aMsg)
{
nsCOMPtr <nsIMsgMailNewsUrl> aMsgUrl = do_QueryInterface(aURL);
return aMsgUrl->SetUrlState(PR_FALSE, aStatus);
nsresult rv = NS_OK;
nsCOMPtr <nsIMsgMailNewsUrl> aMsgUrl = do_QueryInterface(ctxt, &rv);
if (NS_SUCCEEDED(rv) && aMsgUrl)
return aMsgUrl->SetUrlState(PR_FALSE, aStatus);
else
return NS_ERROR_NO_INTERFACE;
}
nsresult nsMsgProtocol::LoadUrl(nsIURI * aURL, nsISupports * /* aConsumer */)
{
// okay now kick us off to the next state...
// our first state is a process state so drive the state machine...
PRBool transportOpen = PR_FALSE;
nsresult rv = NS_OK;
nsCOMPtr <nsIMsgMailNewsUrl> aMsgUrl = do_QueryInterface(aURL);
rv = m_transport->IsTransportOpen(&transportOpen);
if (NS_SUCCEEDED(rv))
{
rv = aMsgUrl->SetUrlState(PR_TRUE, NS_OK); // set the url as a url currently being run...
if (!transportOpen)
rv = m_transport->Open(aURL); // opening the url will cause to get notified when the connection is established
if (!m_socketIsOpen)
{
// put us in a state where we are always notified of incoming data
m_channel->AsyncRead(m_startPosition, m_readCount, aURL,this /* stream observer */);
m_socketIsOpen = PR_TRUE; // mark the channel as open
} // if we got an event queue service
else // the connection is already open so we should begin processing our new url...
rv = ProcessProtocolState(aURL, nsnull, 0);
rv = ProcessProtocolState(aURL, nsnull, 0, 0);
}
return rv;

View File

@ -21,8 +21,10 @@
#include "nsIStreamListener.h"
#include "nsIInputStream.h"
#include "nsIOutputStream.h"
#include "nsIEventQueue.h"
#include "nsCOMPtr.h"
#include "nsITransport.h"
#include "nsIChannel.h"
// This is a helper class used to encapsulate code shared between all of the
// mailnews protocol objects (imap, news, pop, smtp, etc.) In particular,
@ -40,27 +42,10 @@ public:
////////////////////////////////////////////////////////////////////////////////////////
// we suppport the nsIStreamListener interface
////////////////////////////////////////////////////////////////////////////////////////
// Whenever data arrives from the connection, core netlib notifies the protocol by calling
// OnDataAvailable. We then read and process the incoming data from the input stream.
// a typical protocol shouldn't need to override this method
NS_IMETHOD OnDataAvailable(nsIURI* aURL, nsIInputStream *aIStream, PRUint32 aLength);
// I expect most protocols to override this method AND call into the base class
// the base class takes the url and sets the state of the url passed in to be running
NS_IMETHOD OnStartRequest(nsIURI* aURL, const char *aContentType);
// stop binding is a "notification" informing us that the stream associated with aURL is going away.
// the base class implementation takes the url and sets the url state to NOT running.
NS_IMETHOD OnStopRequest(nsIURI* aURL, nsresult aStatus, const PRUnichar* aMsg);
// Ideally, a protocol should only have to support the stream listener methods covered above.
// However, we don't have this nsIStreamListenerLite interface defined yet. Until then, we are using
// nsIStreamListener so we need to add stubs for the heavy weight stuff we don't want to use.
NS_IMETHOD OnProgress(nsIURI* aURL, PRUint32 aProgress, PRUint32 aProgressMax) { return NS_OK;}
NS_IMETHOD OnStatus(nsIURI* aURL, const PRUnichar* aMsg) { return NS_OK;}
NS_IMETHOD GetBindInfo(nsIURI* aURL, nsStreamBindingInfo* aInfo) { return NS_OK;} ;
NS_IMETHOD OnDataAvailable(nsIChannel * aChannel, nsISupports *ctxt, nsIInputStream *inStr, PRUint32 sourceOffset, PRUint32 count);
NS_IMETHOD OnStartRequest(nsIChannel * aChannel, nsISupports *ctxt);
NS_IMETHOD OnStopRequest(nsIChannel * aChannel, nsISupports *ctxt, nsresult status, const PRUnichar *errorMsg);
////////////////////////////////////////////////////////////////////////////////////////
// End of nsIStreamListenerSupport
@ -81,8 +66,8 @@ protected:
// methods for opening and closing a socket with core netlib....
// mscott -okay this is lame. I should break this up into a file protocol and a socket based
// protocool class instead of cheating and putting both methods here...
virtual nsresult OpenNetworkSocket(nsIURI * aURL, PRUint32 aPort, const char * aHostName); // open a connection on this url
virtual nsresult OpenFileSocket(nsIURI * aURL, const nsFileSpec * aFileSpec); // used to open a file socket connection
virtual nsresult OpenNetworkSocket(nsIURI * aURL); // open a connection on this url
virtual nsresult OpenFileSocket(nsIURI * aURL, const nsFileSpec * aFileSpec, PRUint32 aStartPosition, PRInt32 aReadCount); // used to open a file socket connection
// a Protocol typically overrides this method. They free any of their own connection state and then
// they call up into the base class to free the generic connection objects
@ -92,7 +77,9 @@ protected:
// ProcessProtocolState - This is the function that gets churned by calls to OnDataAvailable.
// As data arrives on the socket, OnDataAvailable calls ProcessProtocolState.
virtual nsresult ProcessProtocolState(nsIURI * url, nsIInputStream * inputStream, PRUint32 length) = 0;
virtual nsresult ProcessProtocolState(nsIURI * url, nsIInputStream * inputStream,
PRUint32 sourceOffset, PRUint32 length) = 0;
// SendData -- 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.
@ -101,13 +88,14 @@ protected:
virtual PRInt32 SendData(nsIURI * aURL, const char * dataBuffer);
// Ouput stream for writing commands to the socket
nsCOMPtr<nsITransport> m_transport;
nsCOMPtr<nsIChannel> m_channel;
nsCOMPtr<nsIOutputStream> m_outputStream; // this will be obtained from the transport interface
nsCOMPtr<nsIStreamListener> m_outputConsumer; // this will be obtained from the transport interface
PRBool m_socketIsOpen; // mscott: we should look into keeping this state in the nsSocketTransport...
// I'm using it to make sure I open the socket the first time a URL is loaded into the connection
PRUint32 m_flags; // used to store flag information
PRUint32 m_flags; // used to store flag information
PRUint32 m_startPosition;
PRInt32 m_readCount;
};
#endif /* nsMsgProtocol_h__ */

View File

@ -39,7 +39,6 @@ LLIBS= \
$(DIST)\lib\js32$(VERSION_NUMBER).lib \
$(DIST)\lib\msgcompose_s.lib \
$(DIST)\lib\appcores.lib \
$(DIST)\lib\netlib.lib \
$(DIST)\lib\msgbaseutil.lib \
$(DIST)\lib\raptorhtmlpars.lib \
$(LIBNSPR) \

View File

@ -296,6 +296,13 @@ extern "C" NS_EXPORT nsresult NSRegisterSelf(nsISupports* aServMgr, const char*
path, PR_TRUE, PR_TRUE);
if (NS_FAILED(rv)) finalResult = rv;
rv = compMgr->RegisterComponent(kCSmtpServiceCID,
"SMTP Protocol Handler",
NS_NETWORK_PROTOCOL_PROGID_PREFIX "mailto",
path, PR_TRUE, PR_TRUE);
if (NS_FAILED(rv)) finalResult = rv;
rv = compMgr->RegisterComponent(kCMsgQuoteCID,
"Message Quoting",

View File

@ -16,7 +16,7 @@
* Reserved.
*/
#include "nsISupports.idl"
#include "nsIOutputStream.idl"
#include "nsIStreamListener.idl"
%{ C++
%}
@ -29,6 +29,6 @@ interface nsIMsgQuote : nsISupports {
* This is the primary interface for quoting a particular message specified
* by a URI
*/
void QuoteMessage(in wstring msgURI, in nsIOutputStream outStream);
void QuoteMessage(in wstring msgURI, in nsIStreamListener aStreamListener);
};

View File

@ -786,7 +786,7 @@ nsComposeAppCore::NewMessage(nsAutoString& aUrl,
char *aCString;
message->GetCharSet(aCharset);
message->GetSubject(aString);
message->GetSubject(&aString);
switch (messageType)
{
default:
@ -807,7 +807,7 @@ nsComposeAppCore::NewMessage(nsAutoString& aUrl,
}
}
message->GetAuthor(aString);
message->GetAuthor(&aString);
mMsgCompFields->SetTo(nsAutoCString(aString), NULL);
if (NS_SUCCEEDED(rv = nsMsgI18NDecodeMimePartIIStr(aString, encodedCharset, decodedString))) {
if (NS_SUCCEEDED(rv = ConvertFromUnicode(msgCompHeaderInternalCharset(), decodedString, &aCString))) {
@ -819,8 +819,8 @@ nsComposeAppCore::NewMessage(nsAutoString& aUrl,
if (messageType == 1)
{
nsString cString, dString;
message->GetRecipients(cString);
message->GetCCList(dString);
message->GetRecipients(&cString);
message->GetCCList(&dString);
if (cString.Length() > 0 && dString.Length() > 0)
cString = cString + ", ";
cString = cString + dString;

View File

@ -27,6 +27,8 @@
#include "nsURLFetcher.h"
#include "nsMimeTypes.h"
#include "nsMsgComposeStringBundle.h"
#include "nsXPIDLString.h"
static NS_DEFINE_CID(kPrefCID, NS_PREF_CID);
@ -297,11 +299,11 @@ nsMsgAttachmentHandler::PickEncoding(const char *charset)
else if (!PL_strcasecmp(m_encoding, ENCODING_UUENCODE))
{
char *tailName = NULL;
const char *turl;
nsXPIDLCString turl;
if (mURL)
{
mURL->GetSpec(&turl);
mURL->GetSpec(getter_Copies(turl));
tailName = PL_strrchr(turl, '/');
if (tailName)
@ -322,7 +324,7 @@ nsMsgAttachmentHandler::PickEncoding(const char *charset)
PR_FREEIF(tmp);
}
}
m_encoder_data = MIME_UUEncoderInit((char *)(tailName ? tailName : ""),
mime_encoder_output_fn,
m_mime_delivery_state);
@ -404,8 +406,8 @@ nsresult
nsMsgAttachmentHandler::SnarfAttachment(nsMsgCompFields *compFields)
{
nsresult status = 0;
const char *url_string = nsnull;
char *tempName = nsnull;
nsXPIDLCString url_string;
NS_ASSERTION (! m_done, "Already done");
@ -440,7 +442,7 @@ nsMsgAttachmentHandler::SnarfAttachment(nsMsgCompFields *compFields)
return NS_MSG_UNABLE_TO_OPEN_TMP_FILE;
}
mURL->GetSpec(&url_string);
mURL->GetSpec(getter_Copies(url_string));
#ifdef XP_MAC
// do we need to add IMAP: to this list? nsMsgIsLocalFileURL returns PR_FALSE always for IMAP
@ -477,7 +479,7 @@ nsMsgAttachmentHandler::SnarfAttachment(nsMsgCompFields *compFields)
// the old fe_MakeAppleDoubleEncodeStream() stream in 4.x
//
printf("...and then magic happens...which converts %s to appledouble encoding\n", url_string);
printf("...and then magic happens...which converts %s to appledouble encoding\n", (const char*)url_string);
//
// Now that we have morphed this file, we need to change where mURL is pointing.
@ -495,7 +497,7 @@ nsMsgAttachmentHandler::SnarfAttachment(nsMsgCompFields *compFields)
return NS_ERROR_OUT_OF_MEMORY;
}
if (NS_FAILED(nsMsgNewURL(&mURL, nsString(newURLSpec))))
if (NS_FAILED(nsMsgNewURL(&mURL, newURLSpec)))
{
PR_FREEIF(src_filename);
PR_FREEIF(separator);
@ -569,7 +571,6 @@ nsMsgAttachmentHandler::SnarfAttachment(nsMsgCompFields *compFields)
// Ok, here we are, we need to fire the URL off and get the data
// in the temp file
//
// Create a fetcher for the URL attachment...
mFetcher = new nsURLFetcher();
if (!mFetcher)

View File

@ -21,7 +21,7 @@
#include "nsIPref.h"
#include "prmem.h"
#include "nsMsgSend.h"
#include "nsINetService.h"
#include "nsIIOService.h"
#include "nsMailHeaders.h"
#include "nsMsgI18N.h"
#include "nsMsgCompPrefs.h"
@ -31,12 +31,13 @@
#include "nsMsgNewsCID.h"
#include "nsMimeTypes.h"
#include "nsMsgComposeStringBundle.h"
#include "nsXPIDLString.h"
static NS_DEFINE_CID(kPrefCID, NS_PREF_CID);
static NS_DEFINE_CID(kNetServiceCID, NS_NETSERVICE_CID);
static NS_DEFINE_CID(kPrefCID, NS_PREF_CID);
static NS_DEFINE_CID(kMsgHeaderParserCID, NS_MSGHEADERPARSER_CID);
static NS_DEFINE_CID(kMimeURLUtilsCID, NS_IMIME_URLUTILS_CID);
static NS_DEFINE_CID(kNntpServiceCID, NS_NNTPSERVICE_CID);
static NS_DEFINE_CID(kIOServiceCID, NS_IOSERVICE_CID);
//
// Hopefully, someone will write and XP call like this eventually!
@ -469,27 +470,28 @@ mime_generate_headers (nsMsgCompFields *fields,
}
NS_WITH_SERVICE(nsINetService, pNetService, kNetServiceCID, &rv);
NS_WITH_SERVICE(nsIIOService, pNetService, kIOServiceCID, &rv);
if (NS_SUCCEEDED(rv) && pNetService)
{
nsString aNSStr;
char* sCStr;
PRUnichar * appInfo = nsnull;
pNetService->GetAppCodeName(aNSStr);
sCStr = aNSStr.ToNewCString();
if (sCStr) {
pNetService->GetAppCodeName(&appInfo);
nsAutoString cStr(appInfo, eOneByte);
if (!cStr.IsEmpty())
{
// PUSH_STRING ("X-Mailer: "); // To be more standards compliant
PUSH_STRING ("User-Agent: ");
PUSH_STRING(sCStr);
delete [] sCStr;
PUSH_STRING(cStr.GetBuffer());
nsCRT::free(appInfo);
pNetService->GetAppVersion(aNSStr);
sCStr = aNSStr.ToNewCString();
if (sCStr) {
pNetService->GetAppVersion(&appInfo);
cStr = appInfo;
if (!cStr.IsEmpty())
{
PUSH_STRING (" ");
PUSH_STRING(sCStr);
delete [] sCStr;
PUSH_STRING(cStr.GetBuffer());
}
nsCRT::free(appInfo);
PUSH_NEWLINE ();
}
}
@ -1630,22 +1632,21 @@ nsMsgMIMEGenerateMailtoFormPostHeaders (const char *from,
if (!subject_p)
{
char* sAppName = nsnull;
nsresult rv = NS_OK;
NS_WITH_SERVICE(nsINetService, pNetService, kNetServiceCID, &rv);
PRUnichar * sAppName = nsnull;
NS_WITH_SERVICE(nsIIOService, pNetService, kIOServiceCID, &rv);
if (NS_SUCCEEDED(rv) && pNetService)
{
nsString aNSStr;
pNetService->GetAppCodeName(&sAppName);
pNetService->GetAppCodeName(aNSStr);
sAppName = aNSStr.ToNewCString();
}
/* If the URL didn't provide a subject, we will. */
StrAllocCat (extra_headers, "Subject: Form posted from ");
NS_ASSERTION (sAppName, "null AppCodeName");
StrAllocCat (extra_headers, sAppName);
StrAllocCat (extra_headers, CRLF);
nsCAutoString cstr(sAppName);
/* If the URL didn't provide a subject, we will. */
StrAllocCat (extra_headers, "Subject: Form posted from ");
NS_ASSERTION (!cstr.IsEmpty(), "null AppCodeName");
StrAllocCat (extra_headers, cstr);
StrAllocCat (extra_headers, CRLF);
nsCRT::free(sAppName);
}
/* Note: the `encrypt', `sign', and `body' parameters are currently
@ -1749,12 +1750,12 @@ msg_pick_real_name (nsMsgAttachmentHandler *attachment, const char *charset)
NS_WITH_SERVICE(nsIPref, prefs, kPrefCID, &rv);
const char *s, *s2;
char *s3;
const char *url;
nsXPIDLCString url;
if ( (attachment->m_real_name) && (*attachment->m_real_name))
return;
attachment->mURL->GetSpec(&url);
attachment->mURL->GetSpec(getter_Copies(url));
// Otherwise, extract a name from the URL.
s = url;
@ -1766,9 +1767,7 @@ msg_pick_real_name (nsMsgAttachmentHandler *attachment, const char *charset)
!PL_strncasecmp (url, "snews:", 6) ||
!PL_strncasecmp (url, "IMAP:", 5) ||
!PL_strncasecmp (url, "mailbox:", 8))
{
return;
}
/* Take the part of the file name after the last / or \ */
s2 = PL_strrchr (s, '/');
@ -1877,19 +1876,14 @@ msg_pick_real_name (nsMsgAttachmentHandler *attachment, const char *charset)
// Utility to create a nsIURI object...
nsresult
nsMsgNewURL(nsIURI** aInstancePtrResult, const nsString& aSpec)
nsMsgNewURL(nsIURI** aInstancePtrResult, const char * aSpec)
{
nsresult rv = NS_OK;
if (nsnull == aInstancePtrResult)
return NS_ERROR_NULL_POINTER;
nsINetService *inet = nsnull;
nsresult rv = nsServiceManager::GetService(kNetServiceCID, nsCOMTypeInfo<nsINetService>::GetIID(),
(nsISupports **)&inet);
if (rv != NS_OK)
return rv;
rv = inet->CreateURL(aInstancePtrResult, aSpec, nsnull, nsnull, nsnull);
nsServiceManager::ReleaseService(kNetServiceCID, inet);
NS_WITH_SERVICE(nsIIOService, pNetService, kIOServiceCID, &rv);
if (NS_SUCCEEDED(rv) && pNetService)
rv = pNetService->NewURI(aSpec, nsnull, aInstancePtrResult);
return rv;
}
@ -1957,14 +1951,14 @@ char *
GenerateFileNameFromURI(nsIURI *aURL)
{
nsresult rv;
const char *file;
const char *spec;
nsXPIDLCString file;
nsXPIDLCString spec;;
char *returnString;
char *cp = nsnull;
char *cp1 = nsnull;
rv = aURL->GetFile(&file);
if ( NS_SUCCEEDED(rv) && file && (*file))
rv = aURL->GetPath(getter_Copies(file));
if ( NS_SUCCEEDED(rv) && file)
{
char *newFile = PL_strdup(file);
if (!newFile)
@ -1993,8 +1987,8 @@ GenerateFileNameFromURI(nsIURI *aURL)
cp1 = nsnull;
rv = aURL->GetSpec(&spec);
if ( NS_SUCCEEDED(rv) && spec && (*spec) )
rv = aURL->GetSpec(getter_Copies(spec));
if ( NS_SUCCEEDED(rv) && spec)
{
char *newSpec = PL_strdup(spec);
if (!newSpec)
@ -2013,8 +2007,8 @@ GenerateFileNameFromURI(nsIURI *aURL)
if (!hostStr)
hostStr = cp;
const char *protocol = nsnull;
if (NS_SUCCEEDED(aURL->GetProtocol(&protocol)) && (protocol) && (*protocol) )
nsXPIDLCString protocol;
if (NS_SUCCEEDED(aURL->GetScheme(getter_Copies(protocol))) && (protocol))
{
if (PL_strcasecmp(protocol, "http") == 0)
{

View File

@ -107,7 +107,7 @@ PRBool nsMsgMIMEGetConformToStandard (void);
//
// network service type calls...
//
nsresult nsMsgNewURL(nsIURI** aInstancePtrResult, const nsString& aSpec);
nsresult nsMsgNewURL(nsIURI** aInstancePtrResult, const char * aSpec);
PRBool nsMsgIsLocalFile(const char *url);
char *nsMsgGetLocalFileFromURL(char *url);
char *nsMsgPlatformFileToURL (const char *name);

View File

@ -64,7 +64,7 @@ nsMsgCompose::nsMsgCompose()
m_webShell = nsnull;
m_webShellWin = nsnull;
m_editor = nsnull;
mOutStream=nsnull;
mQuoteStreamListener=nsnull;
m_compFields = new nsMsgCompFields;
NS_IF_ADDREF(m_compFields);
mBodyLoaded = PR_FALSE;
@ -100,7 +100,7 @@ nsMsgCompose::~nsMsgCompose()
{
NS_IF_RELEASE(m_sendListener);
NS_IF_RELEASE(m_compFields);
NS_IF_RELEASE(mOutStream);
NS_IF_RELEASE(mQuoteStreamListener);
// ducarroz: we don't need to own the editor shell as JS does it for us.
// NS_IF_RELEASE(m_editor);
}
@ -603,8 +603,8 @@ nsresult nsMsgCompose::CreateMessage(const PRUnichar * originalMsgURI, MSG_Compo
nsString encodedCharset; // we don't use this
char *aCString;
message->GetCharSet(aCharset);
message->GetSubject(aString);
message->GetCharSet(&aCharset);
message->GetSubject(&aString);
switch (type)
{
default: break;
@ -623,7 +623,7 @@ nsresult nsMsgCompose::CreateMessage(const PRUnichar * originalMsgURI, MSG_Compo
else
m_compFields->SetSubject(bString.GetUnicode());
message->GetAuthor(aString);
message->GetAuthor(&aString);
m_compFields->SetTo(nsAutoCString(aString));
if (NS_SUCCEEDED(rv = nsMsgI18NDecodeMimePartIIStr(aString, encodedCharset, decodedString)))
if (NS_SUCCEEDED(rv = ConvertFromUnicode(msgCompHeaderInternalCharset(), decodedString, &aCString)))
@ -635,9 +635,9 @@ nsresult nsMsgCompose::CreateMessage(const PRUnichar * originalMsgURI, MSG_Compo
if (type == MSGCOMP_TYPE_ReplyAll)
{
nsString cString, dString;
message->GetRecipients(cString);
message->GetRecipients(&cString);
CleanUpRecipients(cString);
message->GetCCList(dString);
message->GetCCList(&dString);
CleanUpRecipients(dString);
if (cString.Length() > 0 && dString.Length() > 0)
cString = cString + ", ";
@ -695,13 +695,13 @@ nsresult nsMsgCompose::CreateMessage(const PRUnichar * originalMsgURI, MSG_Compo
// THIS IS THE CLASS THAT IS THE STREAM CONSUMER OF THE HTML OUPUT
// FROM LIBMIME. THIS IS FOR QUOTING
////////////////////////////////////////////////////////////////////////////////////
QuotingOutputStreamImpl::~QuotingOutputStreamImpl()
QuotingOutputStreamListener::~QuotingOutputStreamListener()
{
if (mComposeObj)
NS_RELEASE(mComposeObj);
}
QuotingOutputStreamImpl::QuotingOutputStreamImpl(void)
QuotingOutputStreamListener::QuotingOutputStreamListener(void)
{
mComposeObj = nsnull;
mMsgBody = "<br><BLOCKQUOTE TYPE=CITE><html><br>--- Original Message ---<br><br>";
@ -709,7 +709,7 @@ QuotingOutputStreamImpl::QuotingOutputStreamImpl(void)
}
nsresult
QuotingOutputStreamImpl::ConvertToPlainText()
QuotingOutputStreamListener::ConvertToPlainText()
{
nsresult rv;
nsString convertedText;
@ -733,7 +733,7 @@ QuotingOutputStreamImpl::ConvertToPlainText()
// Set the charset...
// RICHIE
//nsAutoString utf8("UTF-8");
printf("Warning: UTF-8 output is choking Ender!!!\n");
printf("Warning: UTF-8 output is choking Ender!!!\n");
nsAutoString utf8("US-ASCII");
parser->SetDocumentCharset(utf8, kCharsetFromMetaTag);
@ -759,8 +759,12 @@ printf("Warning: UTF-8 output is choking Ender!!!\n");
return rv;
}
nsresult
QuotingOutputStreamImpl::Close(void)
NS_IMETHODIMP QuotingOutputStreamListener::OnStartRequest(nsIChannel * /* aChannel */, nsISupports * /* ctxt */)
{
return NS_OK;
}
NS_IMETHODIMP QuotingOutputStreamListener::OnStopRequest(nsIChannel * /* aChannel */, nsISupports * /* ctxt */, nsresult status, const PRUnichar * /* errorMsg */)
{
if (mComposeObj)
{
@ -791,40 +795,40 @@ QuotingOutputStreamImpl::Close(void)
return NS_OK;
}
nsresult
QuotingOutputStreamImpl::Write(const char* aBuf, PRUint32 aCount, PRUint32 *aWriteCount)
NS_IMETHODIMP QuotingOutputStreamListener::OnDataAvailable(nsIChannel * /* aChannel */,
nsISupports *ctxt, nsIInputStream *inStr,
PRUint32 sourceOffset, PRUint32 count)
{
char *newBuf = (char *)PR_Malloc(aCount + 1);
*aWriteCount = 0;
if (!newBuf)
return NS_ERROR_FAILURE;
nsresult rv = NS_OK;
if (!inStr)
return NS_ERROR_NULL_POINTER;
*aWriteCount = aCount;
nsCRT::memcpy(newBuf, aBuf, aCount);
newBuf[aCount] = '\0';
mMsgBody += newBuf;
printf("%s", newBuf);
PR_FREEIF(newBuf);
return NS_OK;
char *newBuf = (char *)PR_Malloc(count + 1);
if (!newBuf)
return NS_ERROR_FAILURE;
PRUint32 numWritten = 0;
rv = inStr->Read(newBuf, count, &numWritten);
newBuf[count] = '\0';
if (NS_SUCCEEDED(rv))
{
mMsgBody += newBuf;
}
PR_FREEIF(newBuf);
return rv;
}
nsresult
QuotingOutputStreamImpl::Flush(void)
{
return NS_OK;
}
nsresult
QuotingOutputStreamImpl::SetComposeObj(nsMsgCompose *obj)
QuotingOutputStreamListener::SetComposeObj(nsMsgCompose *obj)
{
mComposeObj = obj;
return NS_OK;
}
NS_IMPL_ISUPPORTS(QuotingOutputStreamImpl, nsCOMTypeInfo<nsIOutputStream>::GetIID());
NS_IMPL_ISUPPORTS(QuotingOutputStreamListener, nsCOMTypeInfo<nsIStreamListener>::GetIID());
////////////////////////////////////////////////////////////////////////////////////
// END OF QUOTING CONSUMER STREAM
// END OF QUOTING LISTENER
////////////////////////////////////////////////////////////////////////////////////
// net service definitions....
@ -875,20 +879,19 @@ nsMsgCompose::QuoteOriginalMessage(const PRUnichar *originalMsgURI, PRInt32 what
return NS_ERROR_FAILURE;
// Create the consumer output stream.. this will receive all the HTML from libmime
mOutStream = new QuotingOutputStreamImpl();
mQuoteStreamListener = new QuotingOutputStreamListener();
if (!mOutStream)
if (!mQuoteStreamListener)
{
printf("Failed to create nsIOutputStream\n");
printf("Failed to create mQuoteStreamListener\n");
return NS_ERROR_FAILURE;
}
NS_ADDREF(mOutStream);
NS_ADDREF(mQuoteStreamListener);
NS_ADDREF(this);
mOutStream->SetComposeObj(this);
mQuoteStreamListener->SetComposeObj(this);
// mBaseStream = do_QueryInterface(mOutStream);
return mQuote->QuoteMessage(originalMsgURI, mOutStream);
return mQuote->QuoteMessage(originalMsgURI, mQuoteStreamListener);
}
void nsMsgCompose::HackToGetBody(PRInt32 what)

View File

@ -27,7 +27,7 @@
#include "nsIMsgCopyServiceListener.h"
#include "nsIMsgSend.h"
class QuotingOutputStreamImpl;
class QuotingOutputStreamListener;
class nsMsgComposeSendListener;
class nsMsgCompose : public nsIMsgCompose
@ -40,7 +40,7 @@ class nsMsgCompose : public nsIMsgCompose
/* this macro defines QueryInterface, AddRef and Release for this class */
NS_DECL_ISUPPORTS
/*** nsIMsgCompose pure virtual functions */
/*** nsIMsgCompose pure virtual functions */
/* void Initialize (in nsIDOMWindow aWindow, in wstring originalMsgURI, in MSG_ComposeType type, in MSG_ComposeFormat format, in nsIMsgCompFields compFields, in nsISupports object); */
NS_IMETHOD Initialize(nsIDOMWindow *aWindow, const PRUnichar *originalMsgURI, MSG_ComposeType type, MSG_ComposeFormat format, nsIMsgCompFields *compFields, nsISupports *object);
@ -104,7 +104,7 @@ class nsMsgCompose : public nsIMsgCompose
nsIWebShellWindow* m_webShellWin;
nsMsgCompFields* m_compFields;
PRBool m_composeHTML;
QuotingOutputStreamImpl * mOutStream;
QuotingOutputStreamListener* mQuoteStreamListener;
nsCOMPtr<nsIOutputStream> mBaseStream;
nsCOMPtr<nsIMsgQuote> mQuote;
@ -117,29 +117,29 @@ class nsMsgCompose : public nsIMsgCompose
};
////////////////////////////////////////////////////////////////////////////////////
// THIS IS THE CLASS THAT IS THE STREAM CONSUMER OF THE HTML OUPUT
// THIS IS THE CLASS THAT IS THE STREAM Listener OF THE HTML OUPUT
// FROM LIBMIME. THIS IS FOR QUOTING
////////////////////////////////////////////////////////////////////////////////////
class QuotingOutputStreamImpl : public nsIOutputStream
class QuotingOutputStreamListener : public nsIStreamListener
{
public:
QuotingOutputStreamImpl(void);
virtual ~QuotingOutputStreamImpl(void);
QuotingOutputStreamListener(void);
virtual ~QuotingOutputStreamListener(void);
// nsISupports interface
NS_DECL_ISUPPORTS
// nsIBaseStream interface
NS_IMETHOD Close(void);
// nsIStreamListener interface
NS_IMETHOD OnDataAvailable(nsIChannel * aChannel,
nsISupports *ctxt,
nsIInputStream *inStr,
PRUint32 sourceOffset,
PRUint32 count);
NS_IMETHOD OnStartRequest(nsIChannel * aChannel, nsISupports *ctxt);
NS_IMETHOD OnStopRequest(nsIChannel * aChannel, nsISupports *ctxt, nsresult status, const PRUnichar *errorMsg);
// nsIOutputStream interface
NS_IMETHOD Write(const char* aBuf, PRUint32 aCount, PRUint32 *aWriteCount);
NS_IMETHOD Flush(void);
NS_IMETHOD SetComposeObj(nsMsgCompose *obj);
NS_IMETHOD ConvertToPlainText();
NS_IMETHOD SetComposeObj(nsMsgCompose *obj);
NS_IMETHOD ConvertToPlainText();
private:
nsMsgCompose *mComposeObj;

View File

@ -22,14 +22,12 @@
#include "nsIServiceManager.h"
#include "nsIAppShellService.h"
#include "nsAppShellCIDs.h"
#include "nsINetService.h"
#include "nsIWebShellWindow.h"
#include "nsIWebShell.h"
#include "nsAppCoresCIDs.h"
#include "nsIDOMToolkitCore.h"
static NS_DEFINE_CID(kAppShellServiceCID, NS_APPSHELL_SERVICE_CID);
static NS_DEFINE_CID(kNetServiceCID, NS_NETSERVICE_CID);
static NS_DEFINE_CID(kToolkitCoreCID, NS_TOOLKITCORE_CID);
static NS_DEFINE_CID(kMsgComposeCID, NS_MSGCOMPOSE_CID);

View File

@ -18,15 +18,16 @@
#include "prprf.h"
#include "prmem.h"
#include "nsCOMPtr.h"
#include "nsINetService.h"
#include "nsIStringBundle.h"
#include "nsMsgComposeStringBundle.h"
#include "nsIServiceManager.h"
#include "nsIPref.h"
#include "nsIIOService.h"
#include "nsIURI.h"
/* This is the next generation string retrieval call */
static NS_DEFINE_CID(kStringBundleServiceCID, NS_STRINGBUNDLESERVICE_CID);
static NS_DEFINE_CID(kNetServiceCID, NS_NETSERVICE_CID);
static NS_DEFINE_CID(kIOServiceCID, NS_IOSERVICE_CID);
static NS_DEFINE_IID(kIPrefIID, NS_IPREF_IID);
static NS_DEFINE_CID(kPrefCID, NS_PREF_CID);
@ -46,7 +47,7 @@ ComposeBEGetStringByIDREAL(PRInt32 stringID)
if (!NS_SUCCEEDED(res) || !prefs)
propertyURL = COMPOSE_BE_URL;
NS_WITH_SERVICE(nsINetService, pNetService, kNetServiceCID, &res);
NS_WITH_SERVICE(nsIIOService, pNetService, kIOServiceCID, &res);
if (!NS_SUCCEEDED(res) || (nsnull == pNetService))
{
return PL_strdup("???"); // Don't I18N this string...failsafe return value
@ -55,14 +56,14 @@ ComposeBEGetStringByIDREAL(PRInt32 stringID)
NS_WITH_SERVICE(nsIStringBundleService, sBundleService, kStringBundleServiceCID, &res);
if (NS_SUCCEEDED(res) && (nsnull != sBundleService))
{
nsIURI *url = nsnull;
nsCOMPtr<nsIURI> url;
nsILocale *locale = nsnull;
#if 1
nsIStringBundle* sBundle = nsnull;
res = sBundleService->CreateBundle(propertyURL, locale, &sBundle);
#else
res = pNetService->CreateURL(&url, nsString(propertyURL), nsnull, nsnull, nsnull);
res = pNetService->NewURI(propertyURL, nsnull, getter_AddRefs(url));
// cleanup...if necessary
if (propertyURL != COMPOSE_BE_URL)
PR_FREEIF(propertyURL);

View File

@ -18,7 +18,6 @@
#include "prprf.h"
#include "prmem.h"
#include "nsCOMPtr.h"
#include "nsINetService.h"
#include "nsIStringBundle.h"
#include "nsMsgComposeStringBundle.h"
#include "nsIServiceManager.h"

View File

@ -98,18 +98,14 @@ nsMsgAskBooleanQuestionByID(PRInt32 msgID, PRBool *answer)
if (!msg)
return NS_ERROR_INVALID_ARG;
#ifdef NECKO
NS_WITH_SERVICE(nsIPrompt, dialog, kNetSupportDialogCID, &rv);
#else
NS_WITH_SERVICE(nsINetSupportDialogService, dialog, kNetSupportDialogCID, &rv);
#endif
if (NS_FAILED(rv))
return NS_ERROR_FACTORY_NOT_LOADED;
nsAutoString confirmText(msg);
if (dialog)
{
rv = dialog->Confirm(confirmText, &result);
rv = dialog->Confirm(confirmText.GetUnicode(), &result);
if (result == 1)
{
*answer = PR_TRUE;
@ -133,18 +129,14 @@ nsMsgAskBooleanQuestionByID(char *msg, PRBool *answer)
if ((!msg) || (!*msg))
return NS_ERROR_INVALID_ARG;
#ifdef NECKO
NS_WITH_SERVICE(nsIPrompt, dialog, kNetSupportDialogCID, &rv);
#else
NS_WITH_SERVICE(nsINetSupportDialogService, dialog, kNetSupportDialogCID, &rv);
#endif
if (NS_FAILED(rv))
return NS_ERROR_FACTORY_NOT_REGISTERED;
nsAutoString confirmText(msg);
if (dialog)
{
rv = dialog->Confirm(confirmText, &result);
rv = dialog->Confirm(confirmText.GetUnicode(), &result);
if (result == 1)
{
*answer = PR_TRUE;

View File

@ -23,7 +23,8 @@
#include "nsIGenericFactory.h"
#include "nsIServiceManager.h"
#include "nsIStreamListener.h"
#include "nsIStreamConverter.h"
#include "nsIStreamConverter2.h"
#include "nsIMimeStreamConverter.h"
#include "nsFileStream.h"
#include "nsFileSpec.h"
#include "nsMimeTypes.h"
@ -31,7 +32,6 @@
#include "nsICharsetConverterManager.h"
#include "prprf.h"
#include "nsMsgQuote.h"
#include "nsINetService.h"
#include "nsMsgCompUtils.h"
#include "nsIMsgMessageService.h"
#include "nsMsgUtils.h"
@ -46,7 +46,6 @@ nsMsgQuote::nsMsgQuote()
mTmpFileSpec = nsnull;
mTmpIFileSpec = nsnull;
mOutStream = nsnull;
mURI = nsnull;
mMessageService = nsnull;
}
@ -83,8 +82,6 @@ NS_NewMsgQuote(const nsIID &aIID, void ** aInstancePtrResult)
return NS_ERROR_NULL_POINTER; /* aInstancePtrResult was NULL....*/
}
// net service definitions....
static NS_DEFINE_CID(kNetServiceCID, NS_NETSERVICE_CID);
// stream converter
static NS_DEFINE_CID(kStreamConverterCID, NS_STREAM_CONVERTER_CID);
@ -192,16 +189,20 @@ SaveQuoteMessageCompleteCallback(nsIURI *aURL, nsresult aExitCode, void *tagData
ptr->mMessageService = nsnull;
}
if (NS_FAILED(aExitCode))
/* mscott - the NS_BINDING_ABORTED is a hack to get around a problem I have
with the necko code...it returns this and treats it as an error when
it really isn't an error! I'm trying to get them to change this.
*/
if (NS_FAILED(aExitCode) && aExitCode != NS_BINDING_ABORTED)
{
NS_RELEASE(ptr);
return aExitCode;
}
// Create a mime parser (nsIStreamConverter)!
nsCOMPtr<nsIStreamConverter> mimeParser;
nsCOMPtr<nsIStreamConverter2> mimeParser;
rv = nsComponentManager::CreateInstance(kStreamConverterCID,
NULL, nsCOMTypeInfo<nsIStreamConverter>::GetIID(),
NULL, nsCOMTypeInfo<nsIStreamConverter2>::GetIID(),
(void **) getter_AddRefs(mimeParser));
if (NS_FAILED(rv) || !mimeParser)
{
@ -235,7 +236,15 @@ SaveQuoteMessageCompleteCallback(nsIURI *aURL, nsresult aExitCode, void *tagData
}
// Set us as the output stream for HTML data from libmime...
if (NS_FAILED(mimeParser->SetOutputStream(ptr->mOutStream, ptr->mURI)))
// SHERRY --> rhp, i need you to verify the arguments for this call...
// i just hacked them up to get it to build.
char * contentType = nsnull;
nsMimeOutputType outType;
nsCOMPtr<nsIMimeStreamConverter> mimeConverter = do_QueryInterface(mimeParser);
if (mimeConverter)
mimeConverter->SetMimeOutputType(nsMimeOutput::nsMimeMessageQuoting);
if (NS_FAILED(mimeParser->Init(aURL, ptr->mStreamListener, nsnull /* the channel */)))
{
NS_RELEASE(ptr);
printf("Unable to set the output stream for the mime parser...\ncould be failure to create internal libmime data\n");
@ -243,17 +252,17 @@ SaveQuoteMessageCompleteCallback(nsIURI *aURL, nsresult aExitCode, void *tagData
}
// Assuming this is an RFC822 message...
mimeParser->OnStartRequest(aURL, MESSAGE_RFC822);
mimeParser->OnStartRequest(nsnull, aURL);
// Just pump all of the data from the file into libmime...
while (NS_SUCCEEDED(fileStream->PumpFileStream()))
{
PRUint32 len;
in->GetLength(&len);
mimeParser->OnDataAvailable(aURL, in, len);
mimeParser->OnDataAvailable(nsnull, aURL, in, 0, len);
}
mimeParser->OnStopRequest(aURL, NS_OK, nsnull);
mimeParser->OnStopRequest(nsnull, aURL, NS_OK, nsnull);
in->Close();
ptr->mTmpFileSpec->Delete(PR_FALSE);
NS_RELEASE(ptr);
@ -261,14 +270,15 @@ SaveQuoteMessageCompleteCallback(nsIURI *aURL, nsresult aExitCode, void *tagData
}
nsresult
nsMsgQuote::QuoteMessage(const PRUnichar *msgURI, nsIOutputStream *outStream)
nsMsgQuote::QuoteMessage(const PRUnichar *msgURI, nsIStreamListener * aQuoteMsgStreamListener)
{
nsresult rv;
if (!msgURI)
return NS_ERROR_INVALID_ARG;
mOutStream = outStream;
mStreamListener = aQuoteMsgStreamListener;
mTmpFileSpec = nsMsgCreateTempFileSpec("nsquot.tmp");
if (!mTmpFileSpec)
return NS_ERROR_FAILURE;

View File

@ -22,6 +22,7 @@
#include "nsFileSpec.h"
#include "nsIFileSpec.h"
#include "nsIMsgMessageService.h"
#include "nsIStreamListener.h"
#define NS_MSGQUOTE_CID \
{0x1C7ABF0C, 0x21E5, 0x11d3, \
@ -29,21 +30,20 @@
class nsMsgQuote: public nsIMsgQuote {
public:
nsMsgQuote();
virtual ~nsMsgQuote();
nsMsgQuote();
virtual ~nsMsgQuote();
/* this macro defines QueryInterface, AddRef and Release for this class */
NS_DECL_ISUPPORTS
NS_DECL_ISUPPORTS
/* long QuoteMessage (in wstring msgURI, in nsIOutputStream outStream); */
NS_IMETHOD QuoteMessage(const PRUnichar *msgURI, nsIOutputStream *outStream);
NS_IMETHOD QuoteMessage(const PRUnichar *msgURI, nsIStreamListener * aStreamListener);
//
// Implementation data...
//
nsFileSpec *mTmpFileSpec;
nsIFileSpec *mTmpIFileSpec;
nsIOutputStream *mOutStream;
nsCOMPtr<nsIStreamListener> mStreamListener;
char *mURI;
nsIMsgMessageService *mMessageService;
};

View File

@ -25,7 +25,6 @@
#include "nsMsgBaseCID.h"
#include "nsMsgNewsCID.h"
#include "nsIMsgHeaderParser.h"
#include "nsINetService.h"
#include "nsISmtpService.h" // for actually sending the message...
#include "nsINntpService.h" // for actually posting the message...
#include "nsMsgCompPrefs.h"
@ -47,6 +46,7 @@
#include "nsIFileSpec.h"
#include "nsMsgCopy.h"
#include "nsMsgTransition.h"
#include "nsXPIDLString.h"
#include "nsMsgPrompts.h"
#include "nsMsgTransition.h"
#include "nsIDOMHTMLImageElement.h"
@ -60,7 +60,6 @@
static NS_DEFINE_IID(kIMsgSend, NS_IMSGSEND_IID);
static NS_DEFINE_CID(kSmtpServiceCID, NS_SMTPSERVICE_CID);
static NS_DEFINE_CID(kNntpServiceCID, NS_NNTPSERVICE_CID);
static NS_DEFINE_CID(kNetServiceCID, NS_NETSERVICE_CID);
static NS_DEFINE_IID(kIPrefIID, NS_IPREF_IID);
static NS_DEFINE_CID(kPrefCID, NS_PREF_CID);
static NS_DEFINE_CID(kMimeURLUtilsCID, NS_IMIME_URLUTILS_CID);
@ -497,7 +496,7 @@ nsMsgComposeAndSend::GatherMimeAttachments()
m_plaintext->m_mime_delivery_state = this;
char *tempURL = nsMsgPlatformFileToURL (mHTMLFileSpec->GetCString());
if (!tempURL || NS_FAILED(nsMsgNewURL(&(m_plaintext->mURL), nsString(tempURL))))
if (!tempURL || NS_FAILED(nsMsgNewURL(&(m_plaintext->mURL), tempURL)))
{
delete m_plaintext;
m_plaintext = nsnull;
@ -877,9 +876,9 @@ nsMsgComposeAndSend::GatherMimeAttachments()
if (status < 0)
goto FAIL;
const char *turl;
ma->mURL->GetSpec(&turl);
hdrs = mime_generate_attachment_headers (ma->m_type, ma->m_encoding,
nsXPIDLCString turl;
ma->mURL->GetSpec(getter_Copies(turl));
hdrs = mime_generate_attachment_headers (ma->m_type, ma->m_encoding,
ma->m_description,
ma->m_x_mac_type,
ma->m_x_mac_creator,
@ -1181,11 +1180,9 @@ PRUint32 i;
nsString tDesc;
// Create the URI
if (NS_FAILED(image->GetSrc(tUrl))) {
//return MK_MIME_MPART_ATTACHMENT_ERROR;
return NS_ERROR_FAILURE;
}
if (NS_FAILED(nsMsgNewURL(&attachment.url, tUrl)))
if (NS_FAILED(image->GetSrc(tUrl)))
return NS_ERROR_FAILURE;
if (NS_FAILED(nsMsgNewURL(&attachment.url, nsCAutoString(tUrl))))
return NS_ERROR_OUT_OF_MEMORY;
NS_ADDREF(attachment.url);
@ -1204,12 +1201,9 @@ PRUint32 i;
nsString tUrl;
// Create the URI
if (NS_FAILED(link->GetHref(tUrl))) {
//return MK_MIME_MPART_ATTACHMENT_ERROR;
return NS_ERROR_FAILURE;
}
if (NS_FAILED(nsMsgNewURL(&attachment.url, tUrl)))
if (NS_FAILED(link->GetHref(tUrl)))
return NS_ERROR_FAILURE;
if (NS_FAILED(nsMsgNewURL(&attachment.url, nsCAutoString(tUrl))))
return NS_ERROR_OUT_OF_MEMORY;
NS_ADDREF(attachment.url);
@ -1220,11 +1214,9 @@ PRUint32 i;
nsString tName;
// Create the URI
if (NS_FAILED(anchor->GetHref(tUrl))) {
//return MK_MIME_MPART_ATTACHMENT_ERROR;
return NS_ERROR_FAILURE;
}
if (NS_FAILED(nsMsgNewURL(&attachment.url, tUrl)))
if (NS_FAILED(anchor->GetHref(tUrl)))
return NS_ERROR_FAILURE;
if (NS_FAILED(nsMsgNewURL(&attachment.url, nsCAutoString(tUrl))))
return NS_ERROR_OUT_OF_MEMORY;
NS_ADDREF(attachment.url);
@ -1290,8 +1282,8 @@ PRUint32 i;
// Start counting the attachments which are going to come from mail folders
// and from NNTP servers.
//
const char *turl;
m_attachments[i].mURL->GetSpec(&turl);
nsXPIDLCString turl;
m_attachments[i].mURL->GetSpec(getter_Copies(turl));
if (PL_strncasecmp(turl, "mailbox:",8) || PL_strncasecmp(turl, "IMAP:",5))
(*aMailboxCount)++;
else if (PL_strncasecmp(turl, "news:",5) || PL_strncasecmp(turl, "snews:",6))
@ -1493,10 +1485,10 @@ nsMsgComposeAndSend::HackAttachments(const nsMsgAttachmentData *attachments,
// real name is set in the case of vcard so don't change it.
// m_attachments[i].m_real_name = 0;
// Count up attachments which are going to come from mail folders
// and from NNTP servers.
const char *turl;
m_attachments[i].mURL->GetSpec(&turl);
/* Count up attachments which are going to come from mail folders
and from NNTP servers. */
nsXPIDLCString turl;
m_attachments[i].mURL->GetSpec(getter_Copies(turl));
if (PL_strncasecmp(turl, "mailbox:",8) ||
PL_strncasecmp(turl, "IMAP:",5))
mailbox_count++;
@ -2504,7 +2496,7 @@ BuildURLAttachmentData(nsIURI *url)
int attachCount = 2; // one entry and one empty entry
nsMsgAttachmentData *attachments = nsnull;
char *theName = nsnull;
const char *spec = nsnull;
nsXPIDLCString spec;
if (!url)
return nsnull;
@ -2514,7 +2506,7 @@ BuildURLAttachmentData(nsIURI *url)
return nsnull;
// Now get a readable name...
url->GetSpec(&spec);
url->GetSpec(getter_Copies(spec));
if (spec)
{
theName = PL_strrchr(spec, '/');
@ -2529,7 +2521,7 @@ BuildURLAttachmentData(nsIURI *url)
attachments[0].url = url; // The URL to attach. This should be 0 to signify "end of list".
attachments[0].real_name = (char *)PL_strdup(theName); // The original name of this document, which will eventually show up in the
NS_ADDREF(url);
NS_IF_ADDREF(url);
return attachments;
}
@ -2557,11 +2549,11 @@ nsMsgComposeAndSend::SendWebPage(nsIMsgIdentity *aUserIndenti
/* string GetBody(); */
PRInt32 bodyLen;
const char *msgBody = ((nsMsgCompFields*)fields)->GetBody();
nsXPIDLCString body;
if (!msgBody)
{
const char *body = nsnull;
url->GetSpec(&body);
msgBody = (char *)body;
url->GetSpec(getter_Copies(body));
msgBody = (const char *)body;
}
bodyLen = PL_strlen(msgBody);

View File

@ -453,10 +453,10 @@ nsCOMPtr<nsIMsgSend> pMsgSend = nsnull;
return NS_ERROR_FAILURE;
// Get the recipients...
if (NS_FAILED(mMessage->GetRecipients(recips)))
if (NS_FAILED(mMessage->GetRecipients(&recips)))
return NS_ERROR_UNEXPECTED;
else
mMessage->GetCCList(ccList);
mMessage->GetCCList(&ccList);
// Get the composition fields interface
nsresult res = nsComponentManager::CreateInstance(kMsgCompFieldsCID, NULL, nsCOMTypeInfo<nsIMsgCompFields>::GetIID(),
@ -592,7 +592,7 @@ nsMsgSendLater::StartNextMailFileSend()
char *tString = nsnull;
nsString subject;
mMessage->GetSubject(subject);
mMessage->GetSubject(&subject);
tString = subject.ToNewCString();
#ifdef NS_DEBUG
printf("Sending message: [%s]\n", tString);

View File

@ -507,7 +507,7 @@ int nsMsgSendPart::Write()
nsCOMPtr<nsIMimeURLUtils> myURLUtil;
char *tmp = NULL;
int res = nsComponentManager::CreateInstance(kCMimeURLUtilsCID,
nsresult res = nsComponentManager::CreateInstance(kCMimeURLUtilsCID,
NULL, nsCOMTypeInfo<nsIMimeURLUtils>::GetIID(),
(void **) getter_AddRefs(myURLUtil));
if (!NS_SUCCEEDED(res))

View File

@ -17,7 +17,6 @@
*/
#include "msgCore.h"
#include "nsMsgTransition.h" // need this to get MK_ defines...
#include "nsSmtpProtocol.h"
#include "nscore.h"
#include "nsIStreamListener.h"
@ -26,7 +25,6 @@
#include "nsIMsgHeaderParser.h"
#include "nsFileStream.h"
#include "nsIMsgMailNewsUrl.h"
#include "nsINetService.h"
#include "nsMsgBaseCID.h"
@ -36,8 +34,6 @@
#include "prprf.h"
#include "nsEscape.h"
static NS_DEFINE_CID(kNetServiceCID, NS_NETSERVICE_CID);
static NS_DEFINE_CID(kHeaderParserCID, NS_MSGHEADERPARSER_CID);
extern "C"
@ -66,8 +62,6 @@ char *XP_AppCodeName = "Mozilla";
const char *XP_AppCodeName = "Mozilla";
#endif
#define NET_IS_SPACE(x) ((((unsigned int) (x)) > 0x7f) ? 0 : isspace(x))
typedef PRUint32 nsMsgKey;
const nsMsgKey nsMsgKey_None = 0xffffffff;
/*
* This function takes an error code and associated error data
@ -217,7 +211,6 @@ nsSmtpProtocol::nsSmtpProtocol(nsIURI * aURL) : m_responseText("", eOneByte)
nsSmtpProtocol::~nsSmtpProtocol()
{
// free our local state
PR_FREEIF(m_hostName);
PR_FREEIF(m_addressCopy);
PR_FREEIF(m_verifyAddress);
PR_FREEIF(m_dataBuf);
@ -234,20 +227,8 @@ void nsSmtpProtocol::Initialize(nsIURI * aURL)
if (aURL)
m_runningURL = do_QueryInterface(aURL);
const char * hostName = NULL;
if (aURL)
{
aURL->GetHost(&hostName);
aURL->GetHostPort(&m_port);
}
if (hostName)
m_hostName = PL_strdup(hostName);
else
m_hostName = NULL;
// call base class to set up the url
rv = OpenNetworkSocket(aURL, m_port, m_hostName);
rv = OpenNetworkSocket(aURL);
m_dataBuf = (char *) PR_Malloc(sizeof(char) * OUTPUT_BUFFER_SIZE);
m_dataBufSize = OUTPUT_BUFFER_SIZE;
@ -293,9 +274,9 @@ const char * nsSmtpProtocol::GetUserDomainName()
////////////////////////////////////////////////////////////////////////////////////////////
// stop binding is a "notification" informing us that the stream associated with aURL is going away.
NS_IMETHODIMP nsSmtpProtocol::OnStopRequest(nsIURI* aURL, nsresult aStatus, const PRUnichar* aMsg)
NS_IMETHODIMP nsSmtpProtocol::OnStopRequest(nsIChannel * /* aChannel */, nsISupports *ctxt, nsresult aStatus, const PRUnichar *aMsg)
{
nsMsgProtocol::OnStopRequest(aURL, aStatus, aMsg);
nsMsgProtocol::OnStopRequest(nsnull, ctxt, aStatus, aMsg);
// okay, we've been told that the send is done and the connection is going away. So
// we need to release all of our state
@ -1294,7 +1275,8 @@ nsresult nsSmtpProtocol::LoadUrl(nsIURI * aURL, nsISupports * /* aConsumer */)
*
* returns zero or more if the transfer needs to be continued.
*/
nsresult nsSmtpProtocol::ProcessProtocolState(nsIURI * url, nsIInputStream * inputStream, PRUint32 length)
nsresult nsSmtpProtocol::ProcessProtocolState(nsIURI * url, nsIInputStream * inputStream,
PRUint32 sourceOffset, PRUint32 length)
{
PRInt32 status = 0;
ClearFlag(SMTP_PAUSE_FOR_READ); /* already paused; reset */

View File

@ -22,11 +22,8 @@
#include "nsMsgProtocol.h"
#include "nsIStreamListener.h"
#include "nsCOMPtr.h"
#include "nsITransport.h"
#include "rosetta.h"
#include HG40855
#include "nsIOutputStream.h"
#include "nsISmtpUrl.h"
/* states of the machine
@ -81,17 +78,13 @@ public:
////////////////////////////////////////////////////////////////////////////////////////
// stop binding is a "notification" informing us that the stream associated with aURL is going away.
NS_IMETHOD OnStopRequest(nsIURI* aURL, nsresult aStatus, const PRUnichar* aMsg);
NS_IMETHOD OnStopRequest(nsIChannel * aChannel, nsISupports *ctxt, nsresult status, const PRUnichar *errorMsg);
private:
// Smtp Event Sinks
// the nsISmtpURL that is currently running
nsCOMPtr<nsISmtpUrl> m_runningURL;
PRUint32 m_LastTime;
HG60917
// Generic state information -- What state are we in? What state do we want to go to
// after the next response? What was the last response code? etc.
SmtpState m_nextState;
@ -100,7 +93,6 @@ private:
PRInt32 m_previousResponseCode;
PRInt32 m_continuationResponse;
nsString m_responseText; /* text returned from Smtp server */
char *m_hostName;
PRUint32 m_port;
char *m_addressCopy;
@ -121,7 +113,8 @@ private:
// initialization function given a new url and transport layer
void Initialize(nsIURI * aURL);
virtual nsresult ProcessProtocolState(nsIURI * url, nsIInputStream * inputStream, PRUint32 length);
virtual nsresult ProcessProtocolState(nsIURI * url, nsIInputStream * inputStream,
PRUint32 sourceOffset, PRUint32 length);
////////////////////////////////////////////////////////////////////////////////////////
// Communication methods --> Reading and writing protocol

View File

@ -19,10 +19,6 @@
#include "msgCore.h" // precompiled header...
#include "nsCOMPtr.h"
#ifdef XP_PC
#include <windows.h> // for InterlockedIncrement
#endif
#include "nsSmtpService.h"
#include "nsIMsgMailSession.h"
#include "nsIMsgIdentity.h"
@ -33,6 +29,7 @@
#include "nsSmtpProtocol.h"
static NS_DEFINE_CID(kCSmtpUrlCID, NS_SMTPURL_CID);
static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID);
// foward declarations...
@ -48,8 +45,27 @@ nsSmtpService::nsSmtpService()
nsSmtpService::~nsSmtpService()
{}
NS_IMPL_THREADSAFE_ISUPPORTS(nsSmtpService, nsCOMTypeInfo<nsISmtpService>::GetIID());
NS_IMPL_THREADSAFE_ADDREF(nsSmtpService);
NS_IMPL_THREADSAFE_RELEASE(nsSmtpService);
nsresult nsSmtpService::QueryInterface(const nsIID &aIID, void** aInstancePtr)
{
if (NULL == aInstancePtr)
return NS_ERROR_NULL_POINTER;
if (aIID.Equals(nsCOMTypeInfo<nsISmtpService>::GetIID()) || aIID.Equals(kISupportsIID))
{
*aInstancePtr = (void*) ((nsISmtpService*)this);
NS_ADDREF_THIS();
return NS_OK;
}
if (aIID.Equals(nsCOMTypeInfo<nsIProtocolHandler>::GetIID()))
{
*aInstancePtr = (void *) ((nsIProtocolHandler*) this);
NS_ADDREF_THIS();
return NS_OK;
}
return NS_NOINTERFACE;
}
static NS_DEFINE_CID(kCMsgMailSessionCID, NS_MSGMAILSESSION_CID);
@ -173,3 +189,45 @@ nsresult NS_MsgLoadMailtoUrl(nsIURI * aUrl, nsISupports * aConsumer)
return rv;
}
NS_IMETHODIMP nsSmtpService::GetScheme(char * *aScheme)
{
nsresult rv = NS_OK;
if (aScheme)
*aScheme = PL_strdup("mailto");
else
rv = NS_ERROR_NULL_POINTER;
return rv;
}
NS_IMETHODIMP nsSmtpService::GetDefaultPort(PRInt32 *aDefaultPort)
{
nsresult rv = NS_OK;
if (aDefaultPort)
*aDefaultPort = SMTP_PORT;
else
rv = NS_ERROR_NULL_POINTER;
return rv;
}
NS_IMETHODIMP nsSmtpService::MakeAbsolute(const char *aRelativeSpec, nsIURI *aBaseURI, char **_retval)
{
// no such thing as relative urls for smtp.....
NS_ASSERTION(0, "unimplemented");
return NS_OK;
}
NS_IMETHODIMP nsSmtpService::NewURI(const char *aSpec, nsIURI *aBaseURI, nsIURI **_retval)
{
// i just haven't implemented this yet...I will be though....
NS_ASSERTION(0, "unimplemented");
return NS_OK;
}
NS_IMETHODIMP nsSmtpService::NewChannel(const char *verb, nsIURI *aURI, nsIEventSinkGetter *eventSinkGetter, nsIEventQueue *eventQueue, nsIChannel **_retval)
{
// mscott - right now, I don't like the idea of returning channels to the caller. They just want us
// to run the url, they don't want a channel back...I'm going to be addressing this issue with
// the necko team in more detail later on.
NS_ASSERTION(0, "unimplemented");
return NS_OK;
}

View File

@ -21,6 +21,7 @@
#include "nscore.h"
#include "nsISmtpService.h"
#include "nsIProtocolHandler.h"
////////////////////////////////////////////////////////////////////////////////////////
// The Smtp Service is an interfaced designed to make building and running mail to urls
@ -29,7 +30,7 @@
// this service away =).
////////////////////////////////////////////////////////////////////////////////////////
class nsSmtpService : public nsISmtpService
class nsSmtpService : public nsISmtpService, public nsIProtocolHandler
{
public:
@ -56,6 +57,19 @@ public:
////////////////////////////////////////////////////////////////////////////////////////
// End support of nsISmtpService interface
////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////
// we suppport the nsIProtocolHandler interface
////////////////////////////////////////////////////////////////////////////////////////
NS_IMETHOD GetScheme(char * *aScheme);
NS_IMETHOD GetDefaultPort(PRInt32 *aDefaultPort);
NS_IMETHOD MakeAbsolute(const char *aRelativeSpec, nsIURI *aBaseURI, char **_retval);
NS_IMETHOD NewURI(const char *aSpec, nsIURI *aBaseURI, nsIURI **_retval);
NS_IMETHOD NewChannel(const char *verb, nsIURI *aURI, nsIEventSinkGetter *eventSinkGetter, nsIEventQueue *eventQueue, nsIChannel **_retval);
////////////////////////////////////////////////////////////////////////////////////////
// End support of nsIProtocolHandler interface
////////////////////////////////////////////////////////////////////////////////////////
};
#endif /* nsSmtpService_h___ */

View File

@ -18,14 +18,8 @@
#include "msgCore.h"
#ifdef XP_PC
#include <windows.h> // for InterlockedIncrement
#endif
#include "nsIURL.h"
#include "nsIURI.h"
#include "nsSmtpUrl.h"
#include "nsINetService.h" /* XXX: NS_FALSE */
#include "nsString.h"
extern "C" {
@ -72,8 +66,6 @@ nsSmtpUrl::nsSmtpUrl() : nsMsgMailNewsUrl(),
m_priorityPart = nsnull;
m_userNameString = nsnull;
m_port = SMTP_PORT;
}
nsSmtpUrl::~nsSmtpUrl()
@ -274,199 +266,37 @@ nsresult nsSmtpUrl::ParseMessageToPost(char * searchPart)
}
// XXX recode to use nsString api's
// XXX don't bother with port numbers
// XXX don't bother with ref's
// XXX null pointer checks are incomplete
nsresult nsSmtpUrl::ParseUrl(const nsString& aSpec)
NS_IMETHODIMP nsSmtpUrl::SetSpec(char * aSpec)
{
// XXX hack!
char* cSpec = aSpec.ToNewCString();
NS_LOCK_INSTANCE();
PR_FREEIF(m_protocol);
PR_FREEIF(m_host);
PR_FREEIF(m_ref);
PR_FREEIF(m_search);
m_port = SMTP_PORT;
// Strip out reference and search info
char* ref = strpbrk(cSpec, "#?");
if (nsnull != ref) {
char* search = nsnull;
if ('#' == *ref) {
search = PL_strchr(ref + 1, '?');
if (nsnull != search) {
*search++ = '\0';
}
PRIntn hashLen = PL_strlen(ref + 1);
if (0 != hashLen) {
m_ref = (char*) PR_Malloc(hashLen + 1);
PL_strcpy(m_ref, ref + 1);
}
}
else {
search = ref + 1;
}
if (search) {
// The rest is the search
PRIntn searchLen = PL_strlen(search);
if (0 != searchLen) {
m_search = (char*) PR_Malloc(searchLen + 1);
PL_strcpy(m_search, search);
}
}
// XXX Terminate string at start of reference or search
*ref = '\0';
}
// The URL is considered absolute if and only if it begins with a
// protocol spec. A protocol spec is an alphanumeric string of 1 or
// more characters that is terminated with a colon.
PRBool isAbsolute = PR_FALSE;
char* cp = nsnull;
char* ap = cSpec;
char ch;
while (0 != (ch = *ap)) {
if (((ch >= 'a') && (ch <= 'z')) ||
((ch >= 'A') && (ch <= 'Z')) ||
((ch >= '0') && (ch <= '9'))) {
ap++;
continue;
}
if ((ch == ':') && (ap - cSpec >= 2)) {
isAbsolute = PR_TRUE;
cp = ap;
break;
}
break;
}
// absolute spec
PR_FREEIF(m_spec);
PRInt32 slen = aSpec.Length();
m_spec = (char *) PR_Malloc(slen + 1);
aSpec.ToCString(m_spec, slen+1);
// get protocol first
PRInt32 plen = cp - cSpec;
m_protocol = (char*) PR_Malloc(plen + 1);
PL_strncpy(m_protocol, cSpec, plen);
m_protocol[plen] = 0;
cp++; // eat : in protocol
// skip over one, two or three slashes
if (*cp == '/')
{
cp++;
if (*cp == '/')
{
cp++;
if (*cp == '/')
cp++;
}
else
{
delete cSpec;
NS_UNLOCK_INSTANCE();
return NS_ERROR_ILLEGAL_VALUE;
}
const char* cp0 = cp;
// To field follows protocol for smtp style urls
cp = PL_strpbrk(cp, "/:");
if (nsnull == cp)
{
// There is only a host name
PRInt32 hlen = PL_strlen(cp0);
m_toPart = (char*) PR_Malloc(hlen + 1);
PL_strcpy(m_toPart, cp0);
}
else
{
// host name came first....the recipients are really just after
// the host name....so cp points to "/recip1,recip2,..."
// grab the host name if it is there....
PRInt32 hlen = cp - cp0;
if (hlen > 0)
{
m_host = (char*) PR_Malloc(hlen + 1);
PL_strncpy(m_host, cp0, hlen);
m_host[hlen] = 0;
}
// what about the port?
if (*cp == ':') // then port follows the ':"
{
// We have a port number
cp0 = cp+1;
cp = PL_strchr(cp, '/');
m_port = strtol(cp0, (char **)nsnull, 10);
}
if (*cp == '/')
cp++;
if (cp)
m_toPart = PL_strdup(cp);
}
}
// now parse out the search field...
ParseMessageToPost(m_search);
delete cSpec;
NS_UNLOCK_INSTANCE();
return NS_OK;
nsresult rv = nsMsgMailNewsUrl::SetSpec(aSpec);
if (NS_SUCCEEDED(rv))
rv = ParseUrl();
return rv;
}
void nsSmtpUrl::ReconstructSpec(void)
// mscott - i think this function can be obsoleted and its functionality
// moved into SetSpec or an init method....
nsresult nsSmtpUrl::ParseUrl()
{
PR_FREEIF(m_spec);
NS_LOCK_INSTANCE();
char portBuffer[10];
if (-1 != m_port) {
PR_snprintf(portBuffer, 10, ":%d", m_port);
}
else {
portBuffer[0] = '\0';
}
nsresult rv = NS_OK;
PRInt32 plen = PL_strlen(m_protocol) + PL_strlen(m_host) +
PL_strlen(portBuffer) + PL_strlen(m_file) + 4;
if (m_ref) {
plen += 1 + PL_strlen(m_ref);
}
if (m_search) {
plen += 1 + PL_strlen(m_search);
}
// the recipients should consist of just the path part up to to the query part
char * uriPath = nsnull;
rv = GetFileName(&m_toPart);
m_spec = (char *) PR_Malloc(plen + 1);
PR_snprintf(m_spec, plen, "%s://%s%s%s",
m_protocol, ((nsnull != m_host) ? m_host : ""), portBuffer,
m_file);
// now parse out the search field...
char * searchPart = nsnull;
rv = GetQuery(&searchPart);
if (NS_SUCCEEDED(rv) && searchPart)
{
ParseMessageToPost(searchPart);
nsCRT::free(searchPart);
}
if (m_ref) {
PL_strcat(m_spec, "#");
PL_strcat(m_spec, m_ref);
}
if (m_search) {
PL_strcat(m_spec, "?");
PL_strcat(m_spec, m_search);
}
// and as a last step, parse the search field as it contains the message (if the messasge
// is in the url....
ParseMessageToPost(m_search);
NS_UNLOCK_INSTANCE();
return rv;
}
nsresult nsSmtpUrl::GetUserEmailAddress(const char ** aUserName)

View File

@ -27,6 +27,9 @@ class nsSmtpUrl : public nsISmtpUrl, public nsMsgMailNewsUrl
public:
NS_DECL_ISUPPORTS_INHERITED
// nsIURI over-ride...
NS_IMETHOD SetSpec(char * aSpec);
// From nsISmtpUrl
// mscott: I used to have individual getters for ALL of these fields but it was
@ -72,12 +75,10 @@ public:
nsSmtpUrl();
// protocol specific code to parse a url...
virtual nsresult ParseUrl(const nsString& aSpec);
protected:
virtual ~nsSmtpUrl();
virtual void ReconstructSpec(void);
// protocol specific code to parse a url...
virtual nsresult ParseUrl();
// data retrieved from parsing the url: (Note the url could be a post from file or it could be inthe url)
char *m_toPart;

View File

@ -15,6 +15,8 @@
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
#include "msgCore.h" // for pre-compiled headers
#include "nsCOMPtr.h"
#include "stdio.h"
#include "nscore.h"
@ -24,14 +26,14 @@
#include "prmem.h"
#include "plstr.h"
#include "nsRepository.h"
#include "nsIURL.h"
#include "nsIURI.h"
#include "nsString.h"
#include "nsINetService.h"
#include "nsIServiceManager.h"
#include "nsURLFetcher.h"
#include "nsIIOService.h"
#include "nsIChannel.h"
#include "nsIHTTPChannel.h"
// netlib definitions....
static NS_DEFINE_CID(kNetServiceCID, NS_NETSERVICE_CID);
static NS_DEFINE_CID(kIOServiceCID, NS_IOSERVICE_CID);
/*
* This function will be used by the factory to generate an
@ -68,23 +70,15 @@ nsURLFetcher::nsURLFetcher()
// Init member variables...
mOutStream = nsnull;
mTotalWritten = 0;
mURL = nsnull;
mStillRunning = PR_TRUE;
mCallback = nsnull;
mNetService = nsnull;
mContentType = nsnull;
}
nsURLFetcher::~nsURLFetcher()
{
mStillRunning = PR_FALSE;
if (mNetService)
{
nsServiceManager::ReleaseService(kNetServiceCID, mNetService);
}
PR_FREEIF(mContentType);
NS_IF_RELEASE(mURL);
}
nsresult
@ -96,36 +90,9 @@ nsURLFetcher::StillRunning(PRBool *running)
// Methods for nsIStreamListener...
//
// Return information regarding the current URL load.<BR>
// The info structure that is passed in is filled out and returned
// to the caller.
//
//This method is currently not called.
//
nsresult
nsURLFetcher::GetBindInfo(nsIURI* aURL, nsStreamBindingInfo* aInfo)
{
#ifdef NS_DEBUG_rhp
printf("nsURLFetcher::GetBindInfo()\n");
#endif
return NS_OK;
}
/**
* Notify the client that data is available in the input stream. This
* method is called whenver data is written into the input stream by the
* networking library...<BR><BR>
*
* @param pIStream The input stream containing the data. This stream can
* be either a blocking or non-blocking stream.
* @param length The amount of data that was just pushed into the stream.
* @return The return value is currently ignored.
*/
nsresult
nsURLFetcher::OnDataAvailable(nsIURI* aURL, nsIInputStream *aIStream,
PRUint32 aLength)
nsURLFetcher::OnDataAvailable(nsIChannel * aChannel, nsISupports * ctxt, nsIInputStream *aIStream,
PRUint32 sourceOffset, PRUint32 aLength)
{
PRUint32 readLen = aLength;
PRUint32 wroteIt;
@ -155,70 +122,26 @@ nsURLFetcher::OnDataAvailable(nsIURI* aURL, nsIInputStream *aIStream,
// Methods for nsIStreamObserver
/**
* Notify the observer that the URL has started to load. This method is
* called only once, at the beginning of a URL load.<BR><BR>
*
* @return The return value is currently ignored. In the future it may be
* used to cancel the URL load..
*/
nsresult
nsURLFetcher::OnStartRequest(nsIURI* aURL, const char *aContentType)
nsURLFetcher::OnStartRequest(nsIChannel *aChannel, nsISupports *ctxt)
{
if (aChannel)
{
char *contentType = nsnull;
if (NS_SUCCEEDED(aChannel->GetContentType(&contentType)) && contentType)
mContentType = PL_strdup(contentType);
}
#ifdef NS_DEBUG_rhp
printf("nsURLFetcher::OnStartRequest() for Content-Type: %s\n", aContentType);
printf("nsURLFetcher::OnStartRequest() for Content-Type: %s\n", mContentType);
#endif
if (aContentType)
mContentType = PL_strdup(aContentType);
return NS_OK;
}
/**
* Notify the observer that progress as occurred for the URL load.<BR>
*/
nsresult
nsURLFetcher::OnProgress(nsIURI* aURL, PRUint32 aProgress, PRUint32 aProgressMax)
nsURLFetcher::OnStopRequest(nsIChannel * /* aChannel */, nsISupports * /* ctxt */, nsresult aStatus, const PRUnichar* aMsg)
{
#ifdef NS_DEBUG_rhp
printf("nsURLFetcher::OnProgress() - %d bytes\n", aProgress);
#endif
return NS_OK;
}
/**
* Notify the observer with a status message for the URL load.<BR>
*/
nsresult
nsURLFetcher::OnStatus(nsIURI* aURL, const PRUnichar* aMsg)
{
#ifdef NS_DEBUG_rhp
nsString tmp(aMsg);
char *msg = tmp.ToNewCString();
printf("nsURLFetcher::OnStatus(): %s\n", msg);
PR_FREEIF(msg);
#endif
return NS_OK;
}
/**
* Notify the observer that the URL has finished loading. This method is
* called once when the networking library has finished processing the
* URL transaction initiatied via the nsINetService::Open(...) call.<BR><BR>
*
* This method is called regardless of whether the URL loaded successfully.<BR><BR>
*
* @param status Status code for the URL load.
* @param msg A text string describing the error.
* @return The return value is currently ignored.
*/
nsresult
nsURLFetcher::OnStopRequest(nsIURI* aURL, nsresult aStatus, const PRUnichar* aMsg)
{
#ifdef NS_DEBUG_rhp
#ifdef NS_DEBUG_richie
printf("nsURLFetcher::OnStopRequest()\n");
#endif
@ -255,24 +178,20 @@ nsURLFetcher::FireURLRequest(nsIURI *aURL, nsOutputFileStream *fOut,
return NS_ERROR_FAILURE;
}
rv = nsServiceManager::GetService(kNetServiceCID, nsCOMTypeInfo<nsINetService>::GetIID(),
(nsISupports **)&mNetService);
if ((rv != NS_OK) || (!mNetService))
{
return NS_ERROR_FACTORY_NOT_LOADED;
}
NS_WITH_SERVICE(nsIIOService, service, kIOServiceCID, &rv);
if (NS_FAILED(rv)) return rv;
if (NS_FAILED(mNetService->OpenStream(aURL, this)))
{
nsServiceManager::ReleaseService(kNetServiceCID, mNetService);
return NS_ERROR_UNEXPECTED;
}
nsCOMPtr<nsIChannel> channel;
rv = service->NewChannelFromURI("load", aURL, nsnull, getter_AddRefs(channel));
if (NS_FAILED(rv)) return rv;
mURL = aURL;
rv = channel->AsyncRead(0, -1, nsnull, this);
if (NS_FAILED(rv)) return rv;
mURL = dont_QueryInterface(aURL);
mOutStream = fOut;
mCallback = cb;
mTagData = tagData;
NS_ADDREF(mURL);
NS_ADDREF(this);
return NS_OK;
}

View File

@ -19,9 +19,9 @@
#define nsURLFetcher_h_
#include "nsCOMPtr.h"
#include "nsIBufferInputStream.h"
#include "nsIStreamListener.h"
#include "nsFileStream.h"
#include "nsINetService.h"
//
// Callback declarations for URL completion
@ -49,70 +49,20 @@ public:
NS_IMETHOD FireURLRequest(nsIURI *aURL, nsOutputFileStream *fOut,
nsAttachSaveCompletionCallback cb, void *tagData);
// Methods for nsIStreamListener...
/**
* Return information regarding the current URL load.<BR>
* The info structure that is passed in is filled out and returned
* to the caller.
*
* This method is currently not called.
*/
NS_IMETHOD GetBindInfo(nsIURI* aURL, nsStreamBindingInfo* aInfo);
/**
* Notify the client that data is available in the input stream. This
* method is called whenver data is written into the input stream by the
* networking library...<BR><BR>
*
* @param pIStream The input stream containing the data. This stream can
* be either a blocking or non-blocking stream.
* @param length The amount of data that was just pushed into the stream.
* @return The return value is currently ignored.
*/
NS_IMETHOD OnDataAvailable(nsIURI* aURL, nsIInputStream *aIStream,
PRUint32 aLength);
NS_IMETHOD OnDataAvailable(nsIChannel * aChannel, nsISupports *ctxt, nsIInputStream *inStr, PRUint32 sourceOffset, PRUint32 count);
// Methods for nsIStreamObserver
/**
* Notify the observer that the URL has started to load. This method is
* called only once, at the beginning of a URL load.<BR><BR>
*
* @return The return value is currently ignored. In the future it may be
* used to cancel the URL load..
*/
NS_IMETHOD OnStartRequest(nsIURI* aURL, const char *aContentType);
/**
* Notify the observer that progress as occurred for the URL load.<BR>
*/
NS_IMETHOD OnProgress(nsIURI* aURL, PRUint32 aProgress, PRUint32 aProgressMax);
/**
* Notify the observer with a status message for the URL load.<BR>
*/
NS_IMETHOD OnStatus(nsIURI* aURL, const PRUnichar* aMsg);
/**
* Notify the observer that the URL has finished loading. This method is
* called once when the networking library has finished processing the
* URL transaction initiatied via the nsINetService::Open(...) call.<BR><BR>
*
* This method is called regardless of whether the URL loaded successfully.<BR><BR>
*
* @param status Status code for the URL load.
* @param msg A text string describing the error.
* @return The return value is currently ignored.
*/
NS_IMETHOD OnStopRequest(nsIURI* aURL, nsresult aStatus, const PRUnichar* aMsg);
NS_IMETHOD OnStartRequest(nsIChannel * aChannel, nsISupports *ctxt);
NS_IMETHOD OnStopRequest(nsIChannel * aChannel, nsISupports *ctxt, nsresult aStatus, const PRUnichar* aMsg);
private:
nsINetService *mNetService; // Net service for the URL operation
nsOutputFileStream *mOutStream; // the output file stream
PRBool mStillRunning; // Are we still running?
PRInt32 mTotalWritten; // Size counter variable
nsIURI *mURL; // URL being processed
nsCOMPtr<nsIURI> mURL; // URL being processed
char *mContentType; // The content type retrieved from the server
void *mTagData; // Tag data for callback...
nsAttachSaveCompletionCallback mCallback; // Callback to call once the file is saved...

View File

@ -26,37 +26,25 @@ PROGRAM = TestMSGCompose
CPPSRCS = test.cpp
LIBS = \
LIBS = \
-lmsgbaseutil \
-labouturl \
-lfileurl \
-lftpurl \
-lgophurl \
-lremoturl \
-lhttpurl \
-lsockstuburl \
-lnetcache \
-lmimetype \
-lnetcnvts \
-lnetwork \
-lnetlib \
-lmozreg \
-lxpcom \
-lpwcac \
-lmozdbm \
-lxp \
-lpref \
-lmozjs \
-ljsdom \
-ljsurl \
-lsecfree \
-lreg \
-lxpcom \
-lmozdbm \
-lxp \
-lpref \
-lmozjs \
-ljsdom \
-ljsurl \
-lsecfree \
$(TIMER_LIBS) \
$(ZLIB_LIBS) \
$(NSPR_LIBS) \
-limg \
-lmozutil \
$(TK_LIBS) \
$(NULL)
$(ZLIB_LIBS) \
$(NSPR_LIBS) \
-limg \
-lmozutil \
$(TK_LIBS) \
-lneckoutil_s \
$(NULL)
include $(topsrcdir)/config/rules.mk

View File

@ -15,10 +15,10 @@
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
#define NS_IMPL_IDS
#include "nsIServiceManager.h"
#include "nsICharsetConverterManager.h"
#include "nsCOMPtr.h"
#include "msgCore.h"
#include "nsMsgBaseCID.h"
@ -26,12 +26,7 @@
#include "nsMsgCompCID.h"
#include <stdio.h>
#ifdef XP_PC
#include <windows.h>
#endif
#include "nsCOMPtr.h"
#include "nsIIOService.h"
#include "nsIComponentManager.h"
#include "nsMsgCompCID.h"
#include "nsIMsgCompose.h"
@ -47,7 +42,6 @@
#include "nsIGenericFactory.h"
#include "nsIWebShellWindow.h"
#include "nsINetService.h"
#include "nsIComponentManager.h"
#include "nsString.h"
@ -66,7 +60,6 @@
#include "nsIMimeURLUtils.h"
#ifdef XP_PC
#define NETLIB_DLL "netlib.dll"
#define XPCOM_DLL "xpcom32.dll"
#define PREF_DLL "xppref32.dll"
#define APPSHELL_DLL "nsappshell.dll"
@ -76,7 +69,6 @@
#ifdef XP_MAC
#include "nsMacRepository.h"
#else
#define NETLIB_DLL "libnetlib"MOZ_DLL_SUFFIX
#define XPCOM_DLL "libxpcom"MOZ_DLL_SUFFIX
#define PREF_DLL "libpref"MOZ_DLL_SUFFIX
#define APPCORES_DLL "libappcores"MOZ_DLL_SUFFIX
@ -89,7 +81,7 @@
/////////////////////////////////////////////////////////////////////////////////
// Define keys for all of the interfaces we are going to require for this test
/////////////////////////////////////////////////////////////////////////////////
static NS_DEFINE_CID(kNetServiceCID, NS_NETSERVICE_CID);
static NS_DEFINE_CID(kEventQueueServiceCID, NS_EVENTQUEUESERVICE_CID);
static NS_DEFINE_CID(kSmtpServiceCID, NS_SMTPSERVICE_CID);
static NS_DEFINE_CID(kFileLocatorCID, NS_FILELOCATOR_CID);
@ -106,6 +98,7 @@ static NS_DEFINE_CID(kGenericFactoryCID, NS_GENERICFACTORY_CID);
static NS_DEFINE_CID(kAllocatorCID, NS_ALLOCATOR_CID);
static NS_DEFINE_CID(kCharsetConverterManagerCID, NS_ICHARSETCONVERTERMANAGER_CID);
static NS_DEFINE_IID(kICharsetConverterManagerCID, NS_ICHARSETCONVERTERMANAGER_IID);
static NS_DEFINE_CID(kIOServiceCID, NS_IOSERVICE_CID);
PRBool keepOnRunning = PR_TRUE;
nsICharsetConverterManager *ccMan = nsnull;
@ -152,21 +145,18 @@ NS_IMPL_ISUPPORTS(SendOperationListener, nsCOMTypeInfo<nsIMsgSendListener>::GetI
////////////////////////////////////////////////////////////////////////////////////
// Utility to create a nsIURL object...
// Utility to create a nsIURI object...
nsresult
nsMsgNewURL(nsIURI** aInstancePtrResult, const nsString& aSpec)
nsMsgNewURL(nsIURI** aInstancePtrResult, const char * aSpec)
{
nsresult rv = NS_OK;
if (nsnull == aInstancePtrResult)
return NS_ERROR_NULL_POINTER;
nsINetService *inet = nsnull;
nsresult rv = nsServiceManager::GetService(kNetServiceCID, nsCOMTypeInfo<nsINetService>::GetIID(),
(nsISupports **)&inet);
if (rv != NS_OK)
return rv;
rv = inet->CreateURL(aInstancePtrResult, aSpec, nsnull, nsnull, nsnull);
nsServiceManager::ReleaseService(kNetServiceCID, inet);
NS_WITH_SERVICE(nsIIOService, pNetService, kIOServiceCID, &rv);
if (NS_SUCCEEDED(rv) && pNetService)
rv = pNetService->NewURI(aSpec, nsnull, aInstancePtrResult);
return rv;
}
@ -182,16 +172,17 @@ GetLocalAttachments(void)
if (!attachments)
return NULL;
nsMsgNewURL(&url, "file://C:/boxster.jpg");
nsCRT::memset(attachments, 0, sizeof(nsMsgAttachedFile) * attachCount);
nsMsgNewURL(&url, nsString("file://C:/boxster.jpg"));
nsMsgNewURL(&url, "file://C:/boxster.jpg");
attachments[0].orig_url = url;
attachments[0].file_spec = new nsFileSpec("C:\\boxster.jpg");
attachments[0].type = PL_strdup("image/jpeg");
attachments[0].encoding = PL_strdup(ENCODING_BINARY);
attachments[0].description = PL_strdup("Boxster Image");
nsMsgNewURL(&url2, nsString("file://C:/boxster.jpg"));
nsMsgNewURL(&url2, "file://C:/boxster.jpg");
attachments[1].orig_url = url2;
attachments[1].file_spec = new nsFileSpec("C:\\boxster.jpg");
attachments[1].type = PL_strdup("image/jpeg");
@ -212,9 +203,9 @@ GetRemoteAttachments()
return NULL;
nsCRT::memset(attachments, 0, sizeof(nsMsgAttachmentData) * attachCount);
url = nsnull;
nsMsgNewURL(&url, nsString("http://people.netscape.com/rhp/sherry.html"));
nsMsgNewURL(&url, "http://people.netscape.com/rhp/sherry.html");
NS_ADDREF(url);
attachments[0].url = url; // The URL to attach. This should be 0 to signify "end of list".
@ -238,10 +229,12 @@ GetRemoteAttachments()
// This can be any explanatory text; it's not a file name.
url = nsnull;
nsMsgNewURL(&url, nsString("http://people.netscape.com/rhp/rhp-home2.gif"));
nsMsgNewURL(&url, "http://people.netscape.com/rhp/rhp-home2.gif");
// This can be any explanatory text; it's not a file name.
NS_ADDREF(url);
attachments[1].url = url; // The URL to attach. This should be 0 to signify "end of list".
return attachments;
}
@ -270,9 +263,6 @@ SetupRegistry(void)
return NS_ERROR_FAILURE;
}
// netlib
nsComponentManager::RegisterComponent(kNetServiceCID, NULL, NULL, NETLIB_DLL, PR_FALSE, PR_FALSE);
// xpcom
nsComponentManager::RegisterComponent(kEventQueueServiceCID, NULL, NULL, XPCOM_DLL, PR_FALSE, PR_FALSE);
nsComponentManager::RegisterComponent(kEventQueueCID, NULL, NULL, XPCOM_DLL, PR_FALSE, PR_FALSE);
@ -328,8 +318,18 @@ int main(int argc, char *argv[])
{
nsIMsgCompFields *pMsgCompFields;
nsIMsgSend *pMsgSend;
nsresult rv = NS_OK;
nsresult rv = NS_OK;
//nsIAppShellService* appShell = nsnull;
nsComponentManager::RegisterComponent(kEventQueueServiceCID, NULL, NULL, XPCOM_DLL, PR_FALSE, PR_FALSE);
nsComponentManager::RegisterComponent(kEventQueueCID, NULL, NULL, XPCOM_DLL, PR_FALSE, PR_FALSE);
nsComponentManager::RegisterComponent(kPrefCID, nsnull, nsnull, PREF_DLL, PR_TRUE, PR_TRUE);
nsComponentManager::RegisterComponent(kFileLocatorCID, NULL, NS_FILELOCATOR_PROGID, APPSHELL_DLL, PR_TRUE, PR_TRUE);
nsComponentManager::RegisterComponent(kMimeURLUtilsCID, NULL, NULL, MIME_DLL, PR_FALSE, PR_FALSE);
nsComponentManager::RegisterComponent(kNetSupportDialogCID, NULL, NULL, APPSHELL_DLL, PR_FALSE, PR_FALSE);
nsComponentManager::RegisterComponent(kAppShellServiceCID, NULL, NULL, APPSHELL_DLL, PR_FALSE, PR_FALSE);
SetupRegistry();
// Create the Event Queue for this thread...

View File

@ -1,3 +1,21 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
#include "msgCore.h"
#include "nsMsgBaseCID.h"
#include "nsMsgLocalCID.h"
@ -16,7 +34,6 @@
#include "nsIServiceManager.h"
#include "nscore.h"
#include "nsIMsgMailSession.h"
#include "nsINetService.h"
#include "nsIComponentManager.h"
#include "nsString.h"
#include "nsISmtpService.h"
@ -32,7 +49,6 @@
#include "nsFileStream.h"
#ifdef XP_PC
#define NETLIB_DLL "netlib.dll"
#define XPCOM_DLL "xpcom32.dll"
#define PREF_DLL "xppref32.dll"
#define APPSHELL_DLL "nsappshell.dll"
@ -41,7 +57,6 @@
#ifdef XP_MAC
#include "nsMacRepository.h"
#else
#define NETLIB_DLL "libnetlib"MOZ_DLL_SUFFIX
#define XPCOM_DLL "libxpcom"MOZ_DLL_SUFFIX
#define PREF_DLL "libpref"MOZ_DLL_SUFFIX
#define APPCORES_DLL "libappcores"MOZ_DLL_SUFFIX
@ -55,7 +70,6 @@
// Define keys for all of the interfaces we are going to require for this test
/////////////////////////////////////////////////////////////////////////////////
static NS_DEFINE_CID(kNetServiceCID, NS_NETSERVICE_CID);
static NS_DEFINE_CID(kEventQueueServiceCID, NS_EVENTQUEUESERVICE_CID);
static NS_DEFINE_CID(kSmtpServiceCID, NS_SMTPSERVICE_CID);
static NS_DEFINE_CID(kFileLocatorCID, NS_FILELOCATOR_CID);
@ -338,12 +352,11 @@ int main(int argc, char *argv[])
nsFileSpec *mailFile = nsnull;
nsIFileSpec *mailIFile = nsnull;
nsComponentManager::RegisterComponent(kNetServiceCID, NULL, NULL, NETLIB_DLL, PR_FALSE, PR_FALSE);
nsComponentManager::RegisterComponent(kEventQueueServiceCID, NULL, NULL, XPCOM_DLL, PR_FALSE, PR_FALSE);
nsComponentManager::RegisterComponent(kEventQueueCID, NULL, NULL, XPCOM_DLL, PR_FALSE, PR_FALSE);
nsComponentManager::RegisterComponent(kPrefCID, nsnull, nsnull, PREF_DLL, PR_TRUE, PR_TRUE);
nsComponentManager::RegisterComponent(kFileLocatorCID, NULL, NS_FILELOCATOR_PROGID, APPSHELL_DLL, PR_FALSE, PR_FALSE);
nsComponentManager::RegisterComponent(kMimeURLUtilsCID, NULL, NULL, MIME_DLL, PR_FALSE, PR_FALSE);
nsComponentManager::RegisterComponent(kEventQueueServiceCID, NULL, NULL, XPCOM_DLL, PR_FALSE, PR_FALSE);
nsComponentManager::RegisterComponent(kEventQueueCID, NULL, NULL, XPCOM_DLL, PR_FALSE, PR_FALSE);
nsComponentManager::RegisterComponent(kPrefCID, nsnull, nsnull, PREF_DLL, PR_TRUE, PR_TRUE);
nsComponentManager::RegisterComponent(kFileLocatorCID, NULL, NS_FILELOCATOR_PROGID, APPSHELL_DLL, PR_FALSE, PR_FALSE);
nsComponentManager::RegisterComponent(kMimeURLUtilsCID, NULL, NULL, MIME_DLL, PR_FALSE, PR_FALSE);
// Create the Event Queue for this thread...
NS_WITH_SERVICE(nsIEventQueueService, pEventQService, kEventQueueServiceCID, &rv);

View File

@ -25,11 +25,10 @@
#define NS_IMPL_IDS
#include "nsIServiceManager.h"
#include "nsICharsetConverterManager.h"
#include "nsIIOService.h"
#include "nsCOMPtr.h"
#include "nsIURL.h"
#include "nsIEventQueueService.h"
#include "nsINetService.h"
#include "nsIInputStream.h"
#include "nsIOutputStream.h"
#include "nsIGenericFactory.h"
@ -42,6 +41,11 @@
#include "nsIAllocator.h" // for the CID
#include "nsURLFetcher.h"
#include "nsIIOService.h"
#include "nsIChannel.h"
static NS_DEFINE_CID(kIOServiceCID, NS_IOSERVICE_CID);
#ifdef WIN32
#include "windows.h"
#endif
@ -77,7 +81,6 @@ static NS_DEFINE_CID(kEventQueueServiceCID, NS_EVENTQUEUESERVICE_CID);
static NS_DEFINE_CID(kGenericFactoryCID, NS_GENERICFACTORY_CID);
// netlib definitions....
static NS_DEFINE_CID(kNetServiceCID, NS_NETSERVICE_CID);
static NS_DEFINE_CID(kCharsetConverterManagerCID, NS_ICHARSETCONVERTERMANAGER_CID);
static NS_DEFINE_IID(kICharsetConverterManagerIID, NS_ICHARSETCONVERTERMANAGER_IID);
@ -97,7 +100,6 @@ SetupRegistry(void)
}
// netlib
nsComponentManager::RegisterComponent(kNetServiceCID, NULL, NULL, NETLIB_DLL, PR_FALSE, PR_FALSE);
// xpcom
static NS_DEFINE_CID(kAllocatorCID, NS_ALLOCATOR_CID);
@ -159,19 +161,15 @@ NS_IMPL_ISUPPORTS(ConsoleOutputStreamImpl, nsCOMTypeInfo<nsIOutputStream>::GetII
// Utility to create a nsIURI object...
nsresult
nsMsgNewURL(nsIURI** aInstancePtrResult, const nsString& aSpec)
nsMsgNewURL(nsIURI** aInstancePtrResult, const char * aSpec)
{
nsresult rv = NS_OK;
if (nsnull == aInstancePtrResult)
return NS_ERROR_NULL_POINTER;
nsINetService *inet = nsnull;
nsresult rv = nsServiceManager::GetService(kNetServiceCID, nsCOMTypeInfo<nsINetService>::GetIID(),
(nsISupports **)&inet);
if (rv != NS_OK)
return rv;
rv = inet->CreateURL(aInstancePtrResult, aSpec, nsnull, nsnull, nsnull);
nsServiceManager::ReleaseService(kNetServiceCID, inet);
NS_WITH_SERVICE(nsIIOService, pNetService, kIOServiceCID, &rv);
if (NS_SUCCEEDED(rv) && pNetService)
rv = pNetService->NewURI(aSpec, nsnull, aInstancePtrResult);
return rv;
}
@ -221,7 +219,7 @@ main(int argc, char** argv)
return rv;
// Create an nsIURI object needed for the URL operation IO...
if (NS_FAILED(nsMsgNewURL(&aURL, nsString(argv[1]))))
if (NS_FAILED(nsMsgNewURL(&aURL, argv[1])))
{
printf("Unable to create URL\n");
return NS_ERROR_FAILURE;

View File

@ -35,7 +35,6 @@ OBJS=\
LLIBS= \
$(DIST)\lib\rdf.lib \
$(DIST)\lib\xpcom.lib \
$(DIST)\lib\netlib.lib \
$(DIST)\lib\uconv.lib \
$(LIBNSPR)

View File

@ -26,12 +26,12 @@
#include "nsRepository.h"
#include "nsIURL.h"
#include "nsString.h"
#include "nsINetService.h"
#include "nsIServiceManager.h"
#include "nsURLFetcher.h"
#include "nsIIOService.h"
#include "nsIChannel.h"
// netlib definitions....
static NS_DEFINE_CID(kNetServiceCID, NS_NETSERVICE_CID);
static NS_DEFINE_CID(kIOServiceCID, NS_IOSERVICE_CID);
/*
* This function will be used by the factory to generate an
@ -68,21 +68,13 @@ nsURLFetcher::nsURLFetcher()
// Init member variables...
mOutStream = nsnull;
mTotalWritten = 0;
mURL = nsnull;
mStillRunning = PR_TRUE;
mCallback = nsnull;
mNetService = nsnull;
}
nsURLFetcher::~nsURLFetcher()
{
mStillRunning = PR_FALSE;
if (mNetService)
{
nsServiceManager::ReleaseService(kNetServiceCID, mNetService);
}
NS_RELEASE(mURL);
}
nsresult
@ -93,24 +85,6 @@ nsURLFetcher::StillRunning(PRBool *running)
}
// Methods for nsIStreamListener...
//
// Return information regarding the current URL load.<BR>
// The info structure that is passed in is filled out and returned
// to the caller.
//
//This method is currently not called.
//
nsresult
nsURLFetcher::GetBindInfo(nsIURI* aURL, nsStreamBindingInfo* aInfo)
{
#ifdef NS_DEBUG_rhp
printf("nsURLFetcher::GetBindInfo()\n");
#endif
return NS_OK;
}
/**
* Notify the client that data is available in the input stream. This
* method is called whenver data is written into the input stream by the
@ -122,10 +96,10 @@ nsURLFetcher::GetBindInfo(nsIURI* aURL, nsStreamBindingInfo* aInfo)
* @return The return value is currently ignored.
*/
nsresult
nsURLFetcher::OnDataAvailable(nsIURI* aURL, nsIInputStream *aIStream,
PRUint32 aLength)
nsURLFetcher::OnDataAvailable(nsIChannel * aChannel, nsISupports * ctxt, nsIInputStream *aIStream,
PRUint32 sourceOffset, PRUint32 aLength)
{
nsresult rc;
nsresult rc = NS_OK;
PRUint32 readLen = aLength;
if (!mOutStream)
@ -155,41 +129,8 @@ nsURLFetcher::OnDataAvailable(nsIURI* aURL, nsIInputStream *aIStream,
* used to cancel the URL load..
*/
nsresult
nsURLFetcher::OnStartRequest(nsIURI* aURL, const char *aContentType)
nsURLFetcher::OnStartRequest(nsIChannel * aChannel, nsISupports * ctxt)
{
#ifdef NS_DEBUG_rhp
printf("nsURLFetcher::OnStartRequest() for Content-Type: %s\n", aContentType);
#endif
return NS_OK;
}
/**
* Notify the observer that progress as occurred for the URL load.<BR>
*/
nsresult
nsURLFetcher::OnProgress(nsIURI* aURL, PRUint32 aProgress, PRUint32 aProgressMax)
{
#ifdef NS_DEBUG_rhp
printf("nsURLFetcher::OnProgress() - %d bytes\n", aProgress);
#endif
return NS_OK;
}
/**
* Notify the observer with a status message for the URL load.<BR>
*/
nsresult
nsURLFetcher::OnStatus(nsIURI* aURL, const PRUnichar* aMsg)
{
#ifdef NS_DEBUG_rhp
nsString tmp(aMsg);
char *msg = tmp.ToNewCString();
printf("nsURLFetcher::OnStatus(): %s\n", msg);
PR_FREEIF(msg);
#endif
return NS_OK;
}
@ -205,7 +146,7 @@ nsURLFetcher::OnStatus(nsIURI* aURL, const PRUnichar* aMsg)
* @return The return value is currently ignored.
*/
nsresult
nsURLFetcher::OnStopRequest(nsIURI* aURL, nsresult aStatus, const PRUnichar* aMsg)
nsURLFetcher::OnStopRequest(nsIChannel * /* aChannel */, nsISupports * /* ctxt */, nsresult aStatus, const PRUnichar* aMsg)
{
#ifdef NS_DEBUG_rhp
printf("nsURLFetcher::OnStopRequest()\n");
@ -236,7 +177,7 @@ nsURLFetcher::FireURLRequest(nsIURI *aURL, nsOutputFileStream *fOut,
if ( (!aURL) || (!fOut) )
{
return NS_ERROR_FAILURE;
return NS_ERROR_INVALID_ARG;
}
if (!fOut->is_open())
@ -244,24 +185,20 @@ nsURLFetcher::FireURLRequest(nsIURI *aURL, nsOutputFileStream *fOut,
return NS_ERROR_FAILURE;
}
rv = nsServiceManager::GetService(kNetServiceCID, nsCOMTypeInfo<nsINetService>::GetIID(),
(nsISupports **)&mNetService);
if ((rv != NS_OK) || (!mNetService))
{
return NS_ERROR_FAILURE;
}
NS_WITH_SERVICE(nsIIOService, service, kIOServiceCID, &rv);
if (NS_FAILED(rv)) return rv;
if (NS_FAILED(mNetService->OpenStream(aURL, this)))
{
nsServiceManager::ReleaseService(kNetServiceCID, mNetService);
return NS_ERROR_FAILURE;
}
nsCOMPtr<nsIChannel> channel;
rv = service->NewChannelFromURI("load", aURL, nsnull, getter_AddRefs(channel));
if (NS_FAILED(rv)) return rv;
mURL = aURL;
rv = channel->AsyncRead(0, -1, nsnull, this);
if (NS_FAILED(rv)) return rv;
mURL = dont_QueryInterface(aURL);
mOutStream = fOut;
mCallback = cb;
mTagData = tagData;
NS_ADDREF(mURL);
NS_ADDREF(this);
return NS_OK;
}

View File

@ -20,6 +20,8 @@
#include "nsCOMPtr.h"
#include "nsFileStream.h"
#include "nsIStreamListener.h"
#include "nsIURI.h"
//
// Callback declarations for URL completion
@ -46,15 +48,6 @@ public:
NS_IMETHOD FireURLRequest(nsIURI *aURL, nsOutputFileStream *fOut,
nsAttachSaveCompletionCallback cb, void *tagData);
// Methods for nsIStreamListener...
/**
* Return information regarding the current URL load.<BR>
* The info structure that is passed in is filled out and returned
* to the caller.
*
* This method is currently not called.
*/
NS_IMETHOD GetBindInfo(nsIURI* aURL, nsStreamBindingInfo* aInfo);
/**
* Notify the client that data is available in the input stream. This
@ -66,8 +59,8 @@ public:
* @param length The amount of data that was just pushed into the stream.
* @return The return value is currently ignored.
*/
NS_IMETHOD OnDataAvailable(nsIURI* aURL, nsIInputStream *aIStream,
PRUint32 aLength);
NS_IMETHOD OnDataAvailable(nsIChannel * aChannel, nsISupports * ctxt, nsIInputStream *aIStream,
PRUint32 sourceOffset, PRUint32 aLength);
// Methods for nsIStreamObserver
@ -78,17 +71,7 @@ public:
* @return The return value is currently ignored. In the future it may be
* used to cancel the URL load..
*/
NS_IMETHOD OnStartRequest(nsIURI* aURL, const char *aContentType);
/**
* Notify the observer that progress as occurred for the URL load.<BR>
*/
NS_IMETHOD OnProgress(nsIURI* aURL, PRUint32 aProgress, PRUint32 aProgressMax);
/**
* Notify the observer with a status message for the URL load.<BR>
*/
NS_IMETHOD OnStatus(nsIURI* aURL, const PRUnichar* aMsg);
NS_IMETHOD OnStartRequest(nsIChannel * aChannel, nsISupports * aCtxt);
/**
* Notify the observer that the URL has finished loading. This method is
@ -101,15 +84,15 @@ public:
* @param msg A text string describing the error.
* @return The return value is currently ignored.
*/
NS_IMETHOD OnStopRequest(nsIURI* aURL, nsresult aStatus, const PRUnichar* aMsg);
NS_IMETHOD OnStopRequest(nsIChannel * /* aChannel */, nsISupports * /* ctxt */, nsresult aStatus, const PRUnichar* aMsg);
;
private:
nsINetService *mNetService; // Net service for the URL operation
nsOutputFileStream *mOutStream; // the output file stream
PRBool mStillRunning; // Are we still running?
PRInt32 mTotalWritten; // Size counter variable
nsIURI *mURL; // URL being processed
nsCOMPtr<nsIURI> mURL; // URL being processed
void *mTagData; // Tag data for callback...
nsAttachSaveCompletionCallback mCallback; // Callback to call once the file is saved...
};

View File

@ -1,3 +1,21 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
#include "msgCore.h"
#include "nsCOMPtr.h"
#include "nsMsgBaseCID.h"
@ -20,8 +38,6 @@
#include "nsIMsgMailSession.h"
#include "nsINetSupportDialogService.h"
#include "nsINetService.h"
#include "nsIComponentManager.h"
#include "nsString.h"
@ -42,7 +58,6 @@
#ifdef XP_PC
#define NETLIB_DLL "netlib.dll"
#define XPCOM_DLL "xpcom32.dll"
#define PREF_DLL "xppref32.dll"
#define APPSHELL_DLL "nsappshell.dll"
@ -51,7 +66,6 @@
#ifdef XP_MAC
#include "nsMacRepository.h"
#else
#define NETLIB_DLL "libnetlib"MOZ_DLL_SUFFIX
#define XPCOM_DLL "libxpcom"MOZ_DLL_SUFFIX
#define PREF_DLL "libpref"MOZ_DLL_SUFFIX
#define APPCORES_DLL "libappcores"MOZ_DLL_SUFFIX
@ -63,8 +77,6 @@
/////////////////////////////////////////////////////////////////////////////////
// Define keys for all of the interfaces we are going to require for this test
/////////////////////////////////////////////////////////////////////////////////
static NS_DEFINE_CID(kNetServiceCID, NS_NETSERVICE_CID);
static NS_DEFINE_CID(kEventQueueServiceCID, NS_EVENTQUEUESERVICE_CID);
static NS_DEFINE_CID(kFileLocatorCID, NS_FILELOCATOR_CID);
static NS_DEFINE_CID(kEventQueueCID, NS_EVENTQUEUE_CID);
@ -115,7 +127,6 @@ nsresult OnIdentityCheck()
int main(int argc, char *argv[])
{
nsresult rv = NS_OK;
nsComponentManager::RegisterComponent(kNetServiceCID, NULL, NULL, NETLIB_DLL, PR_FALSE, PR_FALSE);
nsComponentManager::RegisterComponent(kEventQueueServiceCID, NULL, NULL, XPCOM_DLL, PR_FALSE, PR_FALSE);
nsComponentManager::RegisterComponent(kEventQueueCID, NULL, NULL, XPCOM_DLL, PR_FALSE, PR_FALSE);
nsComponentManager::RegisterComponent(kPrefCID, nsnull, nsnull, PREF_DLL, PR_TRUE, PR_TRUE);

View File

@ -1,9 +1,26 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
#include "nsCOMPtr.h"
#include "nsIMsgCompFields.h"
#include "nsIMsgSend.h"
#include "prmem.h"
#include "nsIComponentManager.h"
#include "nsINetService.h"
#include "nsIPref.h"
#include "nsIAllocator.h"
#include "nsIEventQueueService.h"
@ -15,6 +32,7 @@
#include "nsIFileLocator.h"
#include "nsIMsgSendListener.h"
#include "nsIMsgCopyServiceListener.h"
#include "nsIIOService.h"
#include <stdio.h>
#ifdef XP_PC
@ -22,7 +40,6 @@
#endif
#ifdef XP_PC
#define NETLIB_DLL "netlib.dll"
#define XPCOM_DLL "xpcom32.dll"
#define PREF_DLL "xppref32.dll"
#define APPSHELL_DLL "nsappshell.dll"
@ -30,7 +47,6 @@
#ifdef XP_MAC
#include "nsMacRepository.h"
#else
#define NETLIB_DLL "libnetlib"MOZ_DLL_SUFFIX
#define XPCOM_DLL "libxpcom"MOZ_DLL_SUFFIX
#define PREF_DLL "libpref"MOZ_DLL_SUFFIX
#define APPSHELL_DLL "libnsappshell"MOZ_DLL_SUFFIX
@ -40,7 +56,7 @@
/////////////////////////////////////////////////////////////////////////////////
// Define keys for all of the interfaces we are going to require for this test
/////////////////////////////////////////////////////////////////////////////////
static NS_DEFINE_CID(kNetServiceCID, NS_NETSERVICE_CID);
static NS_DEFINE_CID(kIOServiceCID, NS_IOSERVICE_CID);
static NS_DEFINE_CID(kPrefCID, NS_PREF_CID);
static NS_DEFINE_CID(kAllocatorCID, NS_ALLOCATOR_CID);
static NS_DEFINE_CID(kMsgCompFieldsCID, NS_MSGCOMPFIELDS_CID);
@ -240,28 +256,21 @@ CreateListenerArray(nsIMsgSendListener *listener)
// Utility to create a nsIURI object...
nsresult
nsMsgNewURL(nsIURI** aInstancePtrResult, const nsString& aSpec)
nsMsgNewURL(nsIURI** aInstancePtrResult, const char * aSpec)
{
nsresult rv = NS_OK;
if (nsnull == aInstancePtrResult)
return NS_ERROR_NULL_POINTER;
nsINetService *inet = nsnull;
nsresult rv = nsServiceManager::GetService(kNetServiceCID, nsCOMTypeInfo<nsINetService>::GetIID(),
(nsISupports **)&inet);
if (rv != NS_OK)
return rv;
rv = inet->CreateURL(aInstancePtrResult, aSpec, nsnull, nsnull, nsnull);
nsServiceManager::ReleaseService(kNetServiceCID, inet);
NS_WITH_SERVICE(nsIIOService, pNetService, kIOServiceCID, &rv);
if (NS_SUCCEEDED(rv) && pNetService)
rv = pNetService->NewURI(aSpec, nsnull, aInstancePtrResult);
return rv;
}
static nsresult
SetupRegistry(void)
{
// netlib
nsComponentManager::RegisterComponent(kNetServiceCID, NULL, NULL, NETLIB_DLL, PR_FALSE, PR_FALSE);
// xpcom
nsComponentManager::RegisterComponent(kEventQueueServiceCID, NULL, NULL, XPCOM_DLL, PR_FALSE, PR_FALSE);
nsComponentManager::RegisterComponent(kEventQueueCID, NULL, NULL, XPCOM_DLL, PR_FALSE, PR_FALSE);
@ -270,7 +279,6 @@ SetupRegistry(void)
// prefs
nsComponentManager::RegisterComponent(kPrefCID, NULL, NULL, PREF_DLL, PR_FALSE, PR_FALSE);
nsComponentManager::RegisterComponent(kFileLocatorCID, NULL, NS_FILELOCATOR_PROGID, APPSHELL_DLL, PR_FALSE, PR_FALSE);
return NS_OK;

View File

@ -26,41 +26,29 @@ PROGRAM = smtpTest
CPPSRCS = smtpTest.cpp
LIBS = \
-labouturl \
-lfileurl \
-lftpurl \
-lgophurl \
-lremoturl \
-lhttpurl \
-lsockstuburl \
-lnetcache \
-lmimetype \
-lnetcnvts \
-lnetwork \
-lnetlib \
-lmozreg \
-lxpcom \
-lpwcac \
-lmozdbm \
-lxp \
-lpref \
-lmozjs \
-lraptorhtmlpars \
-lexpat \
-lxmltok \
-ljsdom \
-ljsurl \
-limg \
-lxp \
-lmozutil \
-lsecfree \
$(TIMER_LIBS) \
$(ZLIB_LIBS) \
$(DIST)/lib/librdfbase_s.a \
$(NSPR_LIBS) \
$(TK_LIBS) \
$(NULL)
LIBS = \
-lxpcom \
-lmozdbm \
-lxp \
-lpref \
-lmozjs \
-lraptorhtmlpars \
-lexpat \
-lxmltok \
-ljsdom \
-ljsurl \
-limg \
-lxp \
-lmozutil \
-lsecfree \
-lmozreg \
$(TIMER_LIBS) \
$(ZLIB_LIBS) \
$(DIST)/lib/librdfbase_s.a \
$(NSPR_LIBS) \
$(TK_LIBS) \
-lneckoutil_s \
$(NULL)
include $(topsrcdir)/config/rules.mk

View File

@ -24,14 +24,12 @@ OBJS = \
.\$(OBJDIR)\smtpTest.obj \
$(NULL)
LLIBS= \
$(DIST)\lib\xpcom.lib \
$(LIBNSPR) \
$(DIST)\lib\raptorgfxwin.lib \
$(DIST)\lib\raptorwidget.lib \
$(DIST)\lib\netlib.lib \
$(DIST)\lib\xplib.lib \
$(NULL)
LLIBS= \
$(DIST)\lib\xpcom.lib \
$(LIBNSPR) \
$(DIST)\lib\raptorgfxwin.lib \
$(DIST)\lib\raptorwidget.lib \
$(NULL)
LLFLAGS=-SUBSYSTEM:CONSOLE

View File

@ -32,9 +32,7 @@
#include "nsIStreamListener.h"
#include "nsIInputStream.h"
#include "nsITransport.h"
#include "nsIURL.h"
#include "nsINetService.h"
#include "nsIURI.h"
#include "nsIComponentManager.h"
#include "nsString.h"
@ -43,7 +41,6 @@
#include "nsIMsgMailNewsUrl.h"
#include "nsIUrlListener.h"
#include "nsINetService.h"
#include "nsIServiceManager.h"
#include "nsIEventQueueService.h"
#include "nsIEventQueue.h"
@ -52,15 +49,13 @@
#include "nsFileSpec.h"
#ifdef XP_PC
#define NETLIB_DLL "netlib.dll"
#define XPCOM_DLL "xpcom32.dll"
#define PREF_DLL "xppref32.dll"
#define APPSHELL_DLL "nsappshell.dll"
#define PREF_DLL "d:\\mozilla\\dist\\win32_d.obj\\bin\\xppref32.dll"
#define APPSHELL_DLL "d:\\mozilla\\dist\\win32_d.obj\\bin\\nsappshell.dll"
#else
#ifdef XP_MAC
#include "nsMacRepository.h"
#else
#define NETLIB_DLL "libnetlib"MOZ_DLL_SUFFIX
#define XPCOM_DLL "libxpcom"MOZ_DLL_SUFFIX
#define PREF_DLL "libpref"MOZ_DLL_SUFFIX
#define APPCORES_DLL "libappcores"MOZ_DLL_SUFFIX
@ -72,7 +67,6 @@
// Define keys for all of the interfaces we are going to require for this test
/////////////////////////////////////////////////////////////////////////////////
static NS_DEFINE_CID(kNetServiceCID, NS_NETSERVICE_CID);
static NS_DEFINE_CID(kEventQueueServiceCID, NS_EVENTQUEUESERVICE_CID);
static NS_DEFINE_CID(kSmtpServiceCID, NS_SMTPSERVICE_CID);
static NS_DEFINE_CID(kPrefCID, NS_PREF_CID);
@ -135,7 +129,7 @@ static void strip_nonprintable(char *string) {
class nsSmtpTestDriver : public nsIUrlListener
{
public:
nsSmtpTestDriver(nsINetService * pService, nsIEventQueue *queue);
nsSmtpTestDriver(nsIEventQueue *queue);
virtual ~nsSmtpTestDriver();
NS_DECL_ISUPPORTS
@ -172,7 +166,6 @@ protected:
PRBool m_runningURL;
PRBool m_runTestHarness;
nsCOMPtr<nsINetService> m_netService;
nsISmtpService *m_smtpService;
nsCOMPtr<nsISmtpUrl> m_smtpUrl;
@ -211,8 +204,7 @@ nsresult nsSmtpTestDriver::OnStopRunningUrl(nsIURI * aUrl, nsresult aExitCode)
return NS_OK;
}
nsSmtpTestDriver::nsSmtpTestDriver(nsINetService * pNetService,
nsIEventQueue *queue)
nsSmtpTestDriver::nsSmtpTestDriver(nsIEventQueue *queue)
{
NS_INIT_REFCNT();
m_urlSpec[0] = '\0';
@ -220,9 +212,8 @@ nsSmtpTestDriver::nsSmtpTestDriver(nsINetService * pNetService,
m_protocolInitialized = PR_FALSE;
m_runningURL = PR_FALSE;
m_runTestHarness = PR_TRUE;
m_eventQueue = queue;
m_netService = dont_QueryInterface(pNetService);
NS_IF_ADDREF(m_eventQueue);
m_eventQueue = queue;
NS_IF_ADDREF(m_eventQueue);
InitializeTestDriver(); // prompts user for initialization information...
@ -429,16 +420,16 @@ nsresult nsSmtpTestDriver::OnSendMessageInFile()
int main()
{
nsINetService * pNetService;
nsIEventQueue *queue;
nsresult result;
nsComponentManager::RegisterComponent(kNetServiceCID, NULL, NULL, NETLIB_DLL, PR_FALSE, PR_FALSE);
nsComponentManager::RegisterComponent(kEventQueueServiceCID, NULL, NULL, XPCOM_DLL, PR_FALSE, PR_FALSE);
nsComponentManager::RegisterComponent(kEventQueueCID, NULL, NULL, XPCOM_DLL, PR_FALSE, PR_FALSE);
nsComponentManager::RegisterComponent(kPrefCID, nsnull, nsnull, PREF_DLL, PR_TRUE, PR_TRUE);
result = nsComponentManager::RegisterComponent(kPrefCID, nsnull, nsnull, PREF_DLL, PR_TRUE, PR_TRUE);
nsComponentManager::RegisterComponent(kFileLocatorCID, NULL, NS_FILELOCATOR_PROGID, APPSHELL_DLL, PR_FALSE, PR_FALSE);
result = nsComponentManager::AutoRegister(nsIComponentManager::NS_Startup, NULL /* default */);
// make sure prefs get initialized and loaded..
// mscott - this is just a bad bad bad hack right now until prefs
// has the ability to take nsnull as a parameter. Once that happens,
@ -447,7 +438,7 @@ int main()
if (NS_FAILED(result) || (prefs == nsnull)) {
exit(result);
}
prefs->StartUp();
if (NS_FAILED(prefs->ReadUserPrefs()))
{
printf("Failed on reading user prefs!\n");
@ -462,14 +453,6 @@ int main()
result = pEventQService->CreateThreadEventQueue();
if (NS_FAILED(result)) return result;
// ask the net lib service for a nsINetStream:
result = NS_NewINetService(&pNetService, NULL);
if (NS_FAILED(result) || !pNetService)
{
printf("unable to initialize net serivce. \n");
return 1;
}
result = pEventQService->GetThreadEventQueue(PR_GetCurrentThread(),&queue);
if (NS_FAILED(result) || !queue) {
printf("unable to get event queue.\n");
@ -477,7 +460,7 @@ int main()
}
// okay, everything is set up, now we just need to create a test driver and run it...
nsSmtpTestDriver * driver = new nsSmtpTestDriver(pNetService,queue);
nsSmtpTestDriver * driver = new nsSmtpTestDriver(queue);
if (driver)
{
NS_ADDREF(driver);

View File

@ -29,6 +29,8 @@
#include "nsMsgMessageFlags.h"
#include "nsISupportsArray.h"
#include "nsDBFolderInfo.h"
#include "nsICollation.h"
#include "nsCOMPtr.h"
class ListContext;
class nsMsgKeyArray;
@ -196,6 +198,7 @@ public:
nsIMdbStore *GetStore() {return m_mdbStore;}
virtual PRUint32 GetCurVersion();
nsIMsgHeaderParser *GetHeaderParser();
nsresult GetCollationKeyGenerator();
static nsMsgDatabase* FindInCache(nsFileSpec &dbName);
@ -203,7 +206,7 @@ public:
nsresult RowCellColumnTonsString(nsIMdbRow *row, mdb_token columnToken, nsString &resultStr);
nsresult RowCellColumnToUInt32(nsIMdbRow *row, mdb_token columnToken, PRUint32 *uint32Result, PRUint32 defaultValue = 0);
nsresult RowCellColumnToUInt32(nsIMdbRow *row, mdb_token columnToken, PRUint32 &uint32Result, PRUint32 defaultValue = 0);
nsresult RowCellColumnToMime2EncodedString(nsIMdbRow *row, mdb_token columnToken, nsString &resultStr);
nsresult RowCellColumnToMime2DecodedString(nsIMdbRow *row, mdb_token columnToken, nsString &resultStr);
nsresult RowCellColumnToCollationKey(nsIMdbRow *row, mdb_token columnToken, nsString &resultStr);
// helper functions to put values in cells for the passed-in row
@ -280,6 +283,7 @@ protected:
static nsVoidArray/*<nsMsgDatabase>*/* GetDBCache();
static nsVoidArray/*<nsMsgDatabase>*/* m_dbCache;
nsCOMPtr <nsICollation> m_collationKeyGenerator;
// mdb bookkeeping stuff
nsresult InitExistingDB();
nsresult InitNewDB();

View File

@ -52,20 +52,20 @@ public:
NS_IMETHOD SetSubject(const char *subject);
NS_IMETHOD SetStatusOffset(PRUint32 statusOffset);
NS_IMETHOD GetAuthor(nsString &resultAuthor);
NS_IMETHOD GetSubject(nsString &resultSubject);
NS_IMETHOD GetRecipients(nsString &resultRecipients);
NS_IMETHOD GetMessageId(nsString &resultMessageId);
NS_IMETHOD GetAuthor(nsString *resultAuthor);
NS_IMETHOD GetSubject(nsString *resultSubject);
NS_IMETHOD GetRecipients(nsString *resultRecipients);
NS_IMETHOD GetMessageId(nsString *resultMessageId);
NS_IMETHOD GetMime2EncodedAuthor(nsString &resultAuthor);
NS_IMETHOD GetMime2EncodedSubject(nsString &resultSubject);
NS_IMETHOD GetMime2EncodedRecipients(nsString &resultRecipients);
NS_IMETHOD GetMime2DecodedAuthor(nsString *resultAuthor);
NS_IMETHOD GetMime2DecodedSubject(nsString *resultSubject);
NS_IMETHOD GetMime2DecodedRecipients(nsString *resultRecipients);
NS_IMETHOD GetAuthorCollationKey(nsString &resultAuthor);
NS_IMETHOD GetSubjectCollationKey(nsString &resultSubject);
NS_IMETHOD GetRecipientsCollationKey(nsString &resultRecipients);
NS_IMETHOD GetAuthorCollationKey(nsString *resultAuthor);
NS_IMETHOD GetSubjectCollationKey(nsString *resultSubject);
NS_IMETHOD GetRecipientsCollationKey(nsString *resultRecipients);
NS_IMETHOD GetCCList(nsString &ccList);
NS_IMETHOD GetCCList(nsString *ccList);
// flag handling routines
NS_IMETHOD GetFlags(PRUint32 *result);
NS_IMETHOD SetFlags(PRUint32 flags);
@ -87,7 +87,7 @@ public:
NS_IMETHOD SetPriority(const char *priority);
NS_IMETHOD GetMessageOffset(PRUint32 *result);
NS_IMETHOD GetStatusOffset(PRUint32 *result);
NS_IMETHOD GetCharSet(nsString &result);
NS_IMETHOD GetCharSet(nsString *result);
NS_IMETHOD GetPriority(nsMsgPriority *msgPriority);
NS_IMETHOD GetThreadParent(nsMsgKey *result);
NS_IMETHOD SetThreadParent(nsMsgKey inKey);

View File

@ -2005,7 +2005,7 @@ nsresult nsMsgDatabase::RowCellColumnTonsString(nsIMdbRow *hdrRow, mdb_token col
return err;
}
nsresult nsMsgDatabase::RowCellColumnToMime2EncodedString(nsIMdbRow *row, mdb_token columnToken, nsString &resultStr)
nsresult nsMsgDatabase::RowCellColumnToMime2DecodedString(nsIMdbRow *row, mdb_token columnToken, nsString &resultStr)
{
nsresult err;
nsString nakedString;
@ -2029,52 +2029,56 @@ nsresult nsMsgDatabase::RowCellColumnToMime2EncodedString(nsIMdbRow *row, mdb_to
return err;
}
nsresult nsMsgDatabase::GetCollationKeyGenerator()
{
nsresult err = NS_OK;
if (!m_collationKeyGenerator)
{
nsCOMPtr <nsILocale> locale;
nsString localeName;
// get a locale factory
nsILocaleFactory* localeFactory;
err = nsComponentManager::FindFactory(kLocaleFactoryCID, (nsIFactory**) &localeFactory);
if (NS_SUCCEEDED(err) && localeFactory)
{
// do this for a new db if no UI to be provided for locale selection
err = localeFactory->GetApplicationLocale(getter_AddRefs(locale));
if (locale)
{
// or generate a locale from a stored locale name ("en_US", "fr_FR")
//err = localeFactory->NewLocale(&localeName, &locale);
nsCOMPtr <nsICollationFactory> f;
err = nsComponentManager::CreateInstance(kCollationFactoryCID, NULL,
kICollationFactoryIID, getter_AddRefs(f));
if (NS_SUCCEEDED(err) && f)
{
// get a collation interface instance
err = f->CreateCollation(locale, getter_AddRefs(m_collationKeyGenerator));
}
}
NS_RELEASE(localeFactory);
}
}
return err;
}
nsresult nsMsgDatabase::RowCellColumnToCollationKey(nsIMdbRow *row, mdb_token columnToken, nsString &resultStr)
{
nsString nakedString;
nsresult err;
err = RowCellColumnTonsString(row, columnToken, nakedString);
err = RowCellColumnToMime2DecodedString(row, columnToken, nakedString);
if (NS_SUCCEEDED(err))
{
nsILocaleFactory* localeFactory;
nsILocale* locale;
nsString localeName;
// get a locale factory
err = nsComponentManager::FindFactory(kLocaleFactoryCID, (nsIFactory**)&localeFactory);
if (NS_SUCCEEDED(err) && localeFactory)
err = GetCollationKeyGenerator();
if (NS_SUCCEEDED(err) && m_collationKeyGenerator)
{
// do this for a new db if no UI to be provided for locale selection
err = localeFactory->GetApplicationLocale(&locale);
// or generate a locale from a stored locale name ("en_US", "fr_FR")
//err = localeFactory->NewLocale(&localeName, &locale);
// release locale factory
NS_RELEASE(localeFactory);
nsICollationFactory *f;
err = nsComponentManager::CreateInstance(kCollationFactoryCID, NULL,
kICollationFactoryIID, (void**) &f);
if (NS_SUCCEEDED(err) && f)
{
nsICollation *inst;
// get a collation interface instance
err = f->CreateCollation(locale, &inst);
// release locale, collation factory
NS_RELEASE(locale);
NS_RELEASE(f);
if (NS_SUCCEEDED(err) && inst)
{
err = inst->CreateSortKey( kCollationCaseInSensitive, nakedString, resultStr) ;
NS_RELEASE(inst);
}
}
err = m_collationKeyGenerator->CreateSortKey( kCollationCaseInSensitive, nakedString, resultStr) ;
}
}
return err;
@ -2389,7 +2393,7 @@ nsresult nsMsgDatabase::ThreadNewHdr(nsMsgHdr* newHdr, PRBool &newThread)
// try subject threading if we couldn't find a reference and the subject starts with Re:
nsAutoString subject (eOneByte);
newHdr->GetSubject(subject);
newHdr->GetSubject(&subject);
if ((ThreadBySubjectWithoutRe() || (newHdrFlags & MSG_FLAG_HAS_RE)) && (!thread))
{
thread = getter_AddRefs(GetThreadForSubject(subject));
@ -2558,7 +2562,7 @@ nsresult nsMsgDatabase::AddNewThread(nsMsgHdr *msgHdr)
nsString2 subject(eOneByte);
nsresult err = msgHdr->GetSubject(subject);
nsresult err = msgHdr->GetSubject(&subject);
err = CreateNewThread(msgHdr->m_messageKey, subject.GetBuffer(), &threadHdr);
msgHdr->SetThreadId(msgHdr->m_messageKey);
@ -2686,8 +2690,8 @@ nsresult nsMsgDatabase::DumpContents()
nsAutoString subject;
msgHdr->GetMessageKey(&key);
msgHdr->GetAuthor(author);
msgHdr->GetSubject(subject);
msgHdr->GetAuthor(&author);
msgHdr->GetSubject(&subject);
char *authorStr = author.ToNewCString();
char *subjectStr = subject.ToNewCString();
printf("hdr key = %u, author = %s subject = %s\n", key, (authorStr) ? authorStr : "", (subjectStr) ? subjectStr : "");
@ -2741,7 +2745,7 @@ nsresult nsMsgDatabase::DumpThread(nsMsgKey threadId)
nsMsgKey key;
nsString subject;
(void)pMessage->GetMessageKey(&key);
pMessage->GetSubject(subject);
pMessage->GetSubject(&subject);
printf("message in thread %u %s\n", key, (const char *) nsAutoCString(subject));
}

View File

@ -182,7 +182,10 @@ NS_IMETHODIMP nsMsgHdr::GetProperty(const char *propertyName, nsString &resultPr
nsresult err = NS_OK;
mdb_token property_token;
err = m_mdb->GetStore()->StringToToken(m_mdb->GetEnv(), propertyName, &property_token);
if (m_mdb->GetStore())
err = m_mdb->GetStore()->StringToToken(m_mdb->GetEnv(), propertyName, &property_token);
else
err = NS_ERROR_NULL_POINTER;
if (err == NS_OK)
err = m_mdb->RowCellColumnTonsString(GetMDBRow(), property_token, resultProperty);
@ -451,65 +454,65 @@ NS_IMETHODIMP nsMsgHdr::SetPriority(const char *priority)
return SetPriority(priorityVal);
}
NS_IMETHODIMP nsMsgHdr::GetAuthor(nsString &resultAuthor)
NS_IMETHODIMP nsMsgHdr::GetAuthor(nsString *resultAuthor)
{
return m_mdb->RowCellColumnTonsString(GetMDBRow(), m_mdb->m_senderColumnToken, resultAuthor);
return m_mdb->RowCellColumnTonsString(GetMDBRow(), m_mdb->m_senderColumnToken, *resultAuthor);
}
NS_IMETHODIMP nsMsgHdr::GetSubject(nsString &resultSubject)
NS_IMETHODIMP nsMsgHdr::GetSubject(nsString *resultSubject)
{
return m_mdb->RowCellColumnTonsString(GetMDBRow(), m_mdb->m_subjectColumnToken, resultSubject);
return m_mdb->RowCellColumnTonsString(GetMDBRow(), m_mdb->m_subjectColumnToken, *resultSubject);
}
NS_IMETHODIMP nsMsgHdr::GetRecipients(nsString &resultRecipients)
NS_IMETHODIMP nsMsgHdr::GetRecipients(nsString *resultRecipients)
{
return m_mdb->RowCellColumnTonsString(GetMDBRow(), m_mdb->m_recipientsColumnToken, resultRecipients);
return m_mdb->RowCellColumnTonsString(GetMDBRow(), m_mdb->m_recipientsColumnToken, *resultRecipients);
}
NS_IMETHODIMP nsMsgHdr::GetCCList(nsString &resultCCList)
NS_IMETHODIMP nsMsgHdr::GetCCList(nsString *resultCCList)
{
return m_mdb->RowCellColumnTonsString(GetMDBRow(), m_mdb->m_ccListColumnToken, resultCCList);
return m_mdb->RowCellColumnTonsString(GetMDBRow(), m_mdb->m_ccListColumnToken, *resultCCList);
}
NS_IMETHODIMP nsMsgHdr::GetMessageId(nsString &resultMessageId)
NS_IMETHODIMP nsMsgHdr::GetMessageId(nsString *resultMessageId)
{
return m_mdb->RowCellColumnTonsString(GetMDBRow(), m_mdb->m_messageIdColumnToken, resultMessageId);
return m_mdb->RowCellColumnTonsString(GetMDBRow(), m_mdb->m_messageIdColumnToken, *resultMessageId);
}
NS_IMETHODIMP nsMsgHdr::GetMime2EncodedAuthor(nsString &resultAuthor)
NS_IMETHODIMP nsMsgHdr::GetMime2DecodedAuthor(nsString *resultAuthor)
{
return m_mdb->RowCellColumnToMime2EncodedString(GetMDBRow(), m_mdb->m_senderColumnToken, resultAuthor);
return m_mdb->RowCellColumnToMime2DecodedString(GetMDBRow(), m_mdb->m_senderColumnToken, *resultAuthor);
}
NS_IMETHODIMP nsMsgHdr::GetMime2EncodedSubject(nsString &resultSubject)
NS_IMETHODIMP nsMsgHdr::GetMime2DecodedSubject(nsString *resultSubject)
{
return m_mdb->RowCellColumnToMime2EncodedString(GetMDBRow(), m_mdb->m_subjectColumnToken, resultSubject);
return m_mdb->RowCellColumnToMime2DecodedString(GetMDBRow(), m_mdb->m_subjectColumnToken, *resultSubject);
}
NS_IMETHODIMP nsMsgHdr::GetMime2EncodedRecipients(nsString &resultRecipients)
NS_IMETHODIMP nsMsgHdr::GetMime2DecodedRecipients(nsString *resultRecipients)
{
return m_mdb->RowCellColumnToMime2EncodedString(GetMDBRow(), m_mdb->m_recipientsColumnToken, resultRecipients);
return m_mdb->RowCellColumnToMime2DecodedString(GetMDBRow(), m_mdb->m_recipientsColumnToken, *resultRecipients);
}
NS_IMETHODIMP nsMsgHdr::GetAuthorCollationKey(nsString &resultAuthor)
NS_IMETHODIMP nsMsgHdr::GetAuthorCollationKey(nsString *resultAuthor)
{
return m_mdb->RowCellColumnToCollationKey(GetMDBRow(), m_mdb->m_senderColumnToken, resultAuthor);
return m_mdb->RowCellColumnToCollationKey(GetMDBRow(), m_mdb->m_senderColumnToken, *resultAuthor);
}
NS_IMETHODIMP nsMsgHdr::GetSubjectCollationKey(nsString &resultSubject)
NS_IMETHODIMP nsMsgHdr::GetSubjectCollationKey(nsString *resultSubject)
{
return m_mdb->RowCellColumnToCollationKey(GetMDBRow(), m_mdb->m_subjectColumnToken, resultSubject);
return m_mdb->RowCellColumnToCollationKey(GetMDBRow(), m_mdb->m_subjectColumnToken, *resultSubject);
}
NS_IMETHODIMP nsMsgHdr::GetRecipientsCollationKey(nsString &resultRecipients)
NS_IMETHODIMP nsMsgHdr::GetRecipientsCollationKey(nsString *resultRecipients)
{
return m_mdb->RowCellColumnToCollationKey(GetMDBRow(), m_mdb->m_recipientsColumnToken, resultRecipients);
return m_mdb->RowCellColumnToCollationKey(GetMDBRow(), m_mdb->m_recipientsColumnToken, *resultRecipients);
}
NS_IMETHODIMP nsMsgHdr::GetCharSet(nsString &result)
NS_IMETHODIMP nsMsgHdr::GetCharSet(nsString *result)
{
return m_mdb->RowCellColumnTonsString(GetMDBRow(), m_mdb->m_messageCharSetColumnToken, result);
return m_mdb->RowCellColumnTonsString(GetMDBRow(), m_mdb->m_messageCharSetColumnToken, *result);
}
NS_IMETHODIMP nsMsgHdr::SetThreadParent(nsMsgKey inKey)
@ -599,7 +602,7 @@ PRBool nsMsgHdr::IsParentOf(nsIMsgDBHdr *possibleChild)
nsAutoString2 reference(eOneByte);
nsAutoString2 messageId(eOneByte);
GetMessageId(messageId);
GetMessageId(&messageId);
possibleChild->GetStringReference(numReferences - 1, reference);
return (messageId.Equals(reference));

View File

@ -243,6 +243,13 @@ NSRegisterSelf(nsISupports* aServMgr, const char* path)
path, PR_TRUE, PR_TRUE);
if (NS_FAILED(rv)) finalResult = rv;
rv = compMgr->RegisterComponent(kCImapService,
"Imap Protocol Handler",
NS_NETWORK_PROTOCOL_PROGID_PREFIX "imap",
path, PR_TRUE, PR_TRUE);
if (NS_FAILED(rv)) finalResult = rv;
rv = compMgr->RegisterComponent(kCImapMessageResource,
"Imap Message Resource Factory",
NS_RDF_RESOURCE_FACTORY_PROGID_PREFIX "imap_message",

View File

@ -27,6 +27,7 @@ public:
NS_IMETHOD GetNumberOfMessages(PRInt32 *result) = 0;
NS_IMETHOD GetUidOfMessage(PRInt32 zeroBasedIndex, PRUint32 *result) = 0;
NS_IMETHOD GetMessageFlags(PRInt32 zeroBasedIndex, imapMessageFlagsType *resul) = 0;
NS_IMETHOD GetNumberOfRecentMessages(PRInt32 *result) = 0;
};

View File

@ -154,7 +154,7 @@ struct mailbox_spec {
char *allocatedPathName;
PRUnichar *unicharPathName;
char hierarchySeparator;
const char *hostName;
char *hostName;
nsImapProtocol *connection; // do we need this? It seems evil.
nsImapFlagAndUidState *flagState;

View File

@ -59,6 +59,26 @@ NS_IMETHODIMP nsImapFlagAndUidState::GetMessageFlags(PRInt32 zeroBasedIndex, ima
return NS_OK;
}
NS_IMETHODIMP nsImapFlagAndUidState::GetNumberOfRecentMessages(PRInt32 *result)
{
if (!result)
return NS_ERROR_NULL_POINTER;
PR_CEnterMonitor(this);
PRUint32 counter = 0;
PRInt32 numUnseenMessages = 0;
for (counter = 0; counter < (PRUint32) fNumberOfMessagesAdded; counter++)
{
if (fFlags[counter] & kImapMsgRecentFlag)
numUnseenMessages++;
}
PR_CExitMonitor(this);
*result = numUnseenMessages;
return NS_OK;
}
/* amount to expand for imap entry flags when we need more */

View File

@ -34,6 +34,7 @@ public:
NS_IMETHOD GetNumberOfMessages(PRInt32 *result);
NS_IMETHOD GetUidOfMessage(PRInt32 zeroBasedIndex, PRUint32 *result);
NS_IMETHOD GetMessageFlags(PRInt32 zeroBasedIndex, imapMessageFlagsType *result);
NS_IMETHOD GetNumberOfRecentMessages(PRInt32 *result);
PRInt32 GetNumberOfDeletedMessages();

View File

@ -846,6 +846,33 @@ NS_IMETHODIMP nsImapMailFolder::GetRememberedPassword(char ** password)
}
NS_IMETHODIMP
nsImapMailFolder::MarkMessagesRead(nsISupportsArray *messages, PRBool markRead)
{
nsresult rv;
nsMsgKeyArray keysToMarkRead;
// tell the folder to do it, which will mark them read in the db.
rv = nsMsgFolder::MarkMessagesRead(messages, markRead);
if (NS_SUCCEEDED(rv))
{
nsCString messageIds;
nsMsgKeyArray srcKeyArray;
rv = BuildIdsAndKeyArray(messages, messageIds, keysToMarkRead);
if (NS_FAILED(rv)) return rv;
rv = StoreImapFlags(kImapMsgSeenFlag, markRead, keysToMarkRead);
}
return rv;
}
NS_IMETHODIMP
nsImapMailFolder::MarkAllMessagesRead(void)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP nsImapMailFolder::Adopt(nsIMsgFolder *srcFolder,
PRUint32 *outPos)
{
@ -883,7 +910,7 @@ nsresult nsImapMailFolder::GetDBFolderInfoAndDB(
nsresult
nsImapMailFolder::BuildIdsAndKeyArray(nsISupportsArray* messages,
nsString2& msgIds,
nsCString& msgIds,
nsMsgKeyArray& keyArray)
{
nsresult rv = NS_ERROR_NULL_POINTER;
@ -896,7 +923,8 @@ nsImapMailFolder::BuildIdsAndKeyArray(nsISupportsArray* messages,
rv = messages->Count(&count);
if (NS_FAILED(rv)) return rv;
// build up message keys.
for (i = 0; i < count; i++)
{
msgSupports = getter_AddRefs(messages->ElementAt(i));
@ -906,15 +934,54 @@ nsImapMailFolder::BuildIdsAndKeyArray(nsISupportsArray* messages,
nsMsgKey key;
rv = message->GetMessageKey(&key);
if (NS_SUCCEEDED(rv))
{
if (msgIds.Length() > 0)
msgIds.Append(',');
msgIds.Append((PRInt32)key);
keyArray.Add(key);
}
}
}
return AllocateUidStringFromKeyArray(keyArray, msgIds);
}
nsresult
nsImapMailFolder::AllocateUidStringFromKeyArray(nsMsgKeyArray &keyArray, nsCString &msgIds)
{
nsresult rv = NS_OK;
PRInt32 startSequence = (keyArray.GetSize() > 0) ? keyArray[0] : -1;
PRInt32 curSequenceEnd = startSequence;
PRUint32 total = keyArray.GetSize();
// sort keys and then generate ranges instead of singletons!
keyArray.QuickSort();
for (PRUint32 keyIndex = 0; keyIndex < total; keyIndex++)
{
PRUint32 curKey = keyArray[keyIndex];
PRUint32 nextKey = (keyIndex + 1 < total) ? keyArray[keyIndex + 1] : 0xFFFFFFFF;
PRBool lastKey = (nextKey == 0xFFFFFFFF);
if (lastKey)
curSequenceEnd = curKey;
if (nextKey == (PRUint32) curSequenceEnd + 1 && !lastKey)
{
curSequenceEnd = nextKey;
continue;
}
else if (curSequenceEnd > startSequence)
{
msgIds.Append(startSequence, 10);
msgIds += ':';
msgIds.Append(curSequenceEnd, 10);
if (!lastKey)
msgIds += ',';
startSequence = nextKey;
curSequenceEnd = startSequence;
}
else
{
startSequence = nextKey;
curSequenceEnd = startSequence;
msgIds.Append(keyArray[keyIndex], 10);
if (!lastKey)
msgIds += ',';
}
}
return rv;
}
@ -994,7 +1061,7 @@ NS_IMETHODIMP nsImapMailFolder::DeleteMessages(nsISupportsArray *messages,
if (NS_SUCCEEDED(rv))
srcSupport = do_QueryInterface(srcFolder, &rv);
nsString2 messageIds("", eOneByte);
nsCString messageIds;
nsMsgKeyArray srcKeyArray;
rv = BuildIdsAndKeyArray(messages, messageIds, srcKeyArray);
if (NS_FAILED(rv)) return rv;
@ -1256,9 +1323,17 @@ NS_IMETHODIMP nsImapMailFolder::UpdateImapMailboxInfo(
// if this is the INBOX, tell the stand-alone biff about the new high water mark
if (mFlags & MSG_FOLDER_FLAG_INBOX)
{
PRInt32 numRecentMessages = 0;
if (keysToFetch.GetSize() > 0)
{
SetBiffState(nsMsgBiffState_NewMail);
SetNumNewMessages(keysToFetch.GetSize());
if (aSpec->flagState)
{
aSpec->flagState->GetNumberOfRecentMessages(&numRecentMessages);
SetNumNewMessages(numRecentMessages);
}
}
}
if (keysToFetch.GetSize())
{
@ -1789,6 +1864,21 @@ nsresult nsImapMailFolder::StoreImapFlags(imapMessageFlagsType flags, PRBool add
nsresult rv = NS_OK;
if (PR_TRUE/* !NET_IsOffline() */)
{
NS_WITH_SERVICE(nsIImapService, imapService, kCImapService, &rv);
if (addFlags)
{
nsCString msgIds;
AllocateUidStringFromKeyArray(keysToFlag, msgIds);
imapService->AddMessageFlags(m_eventQueue, this, nsnull, nsnull, msgIds, flags, PR_TRUE);
}
else
{
nsCString msgIds;
AllocateUidStringFromKeyArray(keysToFlag, msgIds);
imapService->SubtractMessageFlags(m_eventQueue, this, nsnull, nsnull, msgIds, flags, PR_TRUE);
}
// If we are not offline, we want to add the flag changes to the server
// use the imap service to add or remove flags.
}
@ -2156,20 +2246,18 @@ nsImapMailFolder::NormalEndMsgWriteStream(nsIImapProtocol* aProtocol)
{
nsCOMPtr<nsISupports> aSupport;
m_tempMessageStream->Close();
res = aProtocol->GetStreamConsumer(getter_AddRefs(aSupport));
if (NS_SUCCEEDED(res))
{
nsCOMPtr<nsIWebShell> webShell;
nsFilePath filePath(MESSAGE_PATH);
webShell = do_QueryInterface(aSupport, &res);
if (NS_SUCCEEDED(res) && webShell)
{
nsFileURL fileURL(filePath);
char * message_path_url = PL_strdup(fileURL.GetAsString());
res = webShell->LoadURL(nsAutoString(message_path_url).GetUnicode(), nsnull, PR_TRUE, nsURLReloadBypassCache, 0);
res = webShell->LoadURL(nsAutoString(message_path_url).GetUnicode(), nsnull, PR_TRUE);
if (NS_SUCCEEDED(res))
{
// now mark the message as read in the db.
@ -2179,8 +2267,9 @@ nsImapMailFolder::NormalEndMsgWriteStream(nsIImapProtocol* aProtocol)
if (NS_SUCCEEDED(res))
msgHdr->MarkRead(PR_TRUE);
}
PR_FREEIF(message_path_url);
}
}
else
{
nsCOMPtr<nsIStreamListener> streamListener;
@ -2189,6 +2278,7 @@ 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;
@ -2198,10 +2288,10 @@ nsImapMailFolder::NormalEndMsgWriteStream(nsIImapProtocol* aProtocol)
do_QueryInterface(inputFileStream->GetIStream(), &res);
PRUint32 fileSize = 0;
res = inputStream->GetLength(&fileSize);
streamListener->OnStartRequest(aUrl, "");
streamListener->OnDataAvailable(aUrl, inputStream,
streamListener->OnStartRequest(nsnull, aCtxt);
streamListener->OnDataAvailable(nsnull /* channel */, aCtxt, inputStream, 0 /* offset */,
fileSize);
streamListener->OnStopRequest(aUrl, 0, nsnull);
streamListener->OnStopRequest(nsnull, aCtxt, 0, nsnull);
inputStream = null_nsCOMPtr();
delete inputFileStream;
}
@ -2920,7 +3010,7 @@ nsImapMailFolder::CopyMessages2(nsIMsgFolder* srcFolder,
m_copyState->m_streamCopy = PR_TRUE;
// ** jt - needs to create server to server move/copy undo msg txn
nsString2 messageIds("", eOneByte);
nsCString messageIds;
nsMsgKeyArray srcKeyArray;
nsCOMPtr<nsIUrlListener> urlListener;
@ -2962,7 +3052,7 @@ nsImapMailFolder::CopyMessages(nsIMsgFolder* srcFolder,
char *hostname1 = nsnull, *hostname2 = nsnull, *username1 = nsnull,
*username2 = nsnull;
nsAutoString protocolType;
nsString2 messageIds("", eOneByte);
nsCString messageIds;
nsMsgKeyArray srcKeyArray;
nsCOMPtr<nsIUrlListener> urlListener;
nsCOMPtr<nsISupports> srcSupport;

View File

@ -32,16 +32,11 @@
#include "nsITransactionManager.h"
#include "nsMsgTxn.h"
#include "nsIMsgMessageService.h"
#ifdef DEBUG_bienvenu
#define DOING_FILTERS
#endif
#ifdef DOING_FILTERS
#include "nsIMsgFilterHitNotify.h"
#include "nsIMsgFilterList.h"
class nsImapMoveCoalescer;
#endif
#define FOUR_K 4096
@ -141,6 +136,9 @@ public:
NS_IMETHOD UserNeedsToAuthenticateForFolder(PRBool displayOnly, PRBool *authenticate);
NS_IMETHOD RememberPassword(const char *password);
NS_IMETHOD GetRememberedPassword(char ** password);
NS_IMETHOD MarkMessagesRead(nsISupportsArray *messages, PRBool markRead);
NS_IMETHOD MarkAllMessagesRead(void);
virtual nsresult GetDBFolderInfoAndDB(nsIDBFolderInfo **folderInfo,
nsIMsgDatabase **db);
@ -305,7 +303,6 @@ public:
nsISupports* copyState);
NS_IMETHOD MatchName(nsString *name, PRBool *matches);
#ifdef DOING_FILTERS
// nsIMsgFilterHitNotification method(s)
NS_IMETHOD ApplyFilterHit(nsIMsgFilter *filter, PRBool *applyMore);
@ -314,7 +311,6 @@ public:
char *destFolder,
nsIMsgFilter *filter);
nsresult StoreImapFlags(imapMessageFlagsType flags, PRBool addFlags, nsMsgKeyArray &msgKeys);
#endif // DOING_FILTERS
protected:
// Helper methods
void FindKeysToAdd(const nsMsgKeyArray &existingKeys, nsMsgKeyArray
@ -357,8 +353,9 @@ protected:
void ClearCopyState(nsresult exitCode);
nsresult SetTransactionManager(nsITransactionManager* txnMgr);
nsresult BuildIdsAndKeyArray(nsISupportsArray* messages,
nsString2& msgIds, nsMsgKeyArray& keyArray);
nsCString& msgIds, nsMsgKeyArray& keyArray);
nsresult AllocateUidStringFromKeyArray(nsMsgKeyArray &keyArray, nsCString &msgIds);
nsresult GetMessageHeader(nsIMsgDBHdr ** aMsgHdr);
nsNativeFileSpec *m_pathName;

View File

@ -20,17 +20,12 @@
#define FORCE_PR_LOG /* Allow logging in the release build */
// as does this
#define NS_IMPL_IDS
#include "msgCore.h" // for pre-compiled headers
#include "nsIServiceManager.h"
#include "nsICharsetConverterManager.h"
#include "msgCore.h" // for pre-compiled headers
#include "nsMsgImapCID.h"
#ifdef XP_PC
#include <windows.h> // for InterlockedIncrement
#endif
#include "nsIEventQueueService.h"
#include "nsImapCore.h"
@ -44,16 +39,13 @@
#include "plbase64.h"
#include "nsIWebShell.h"
#include "nsIImapService.h"
#include "nsISocketTransportService.h"
#include "nsXPIDLString.h"
PRLogModuleInfo *IMAP;
// netlib required files
#include "nsIStreamListener.h"
#include "nsIInputStream.h"
#include "nsIOutputStream.h"
#include "nsINetService.h"
#include "nsIMsgIncomingServer.h"
#include "nsIImapIncomingServer.h"
@ -74,7 +66,7 @@ PRLogModuleInfo *IMAP;
const char *kImapTrashFolderName = "Trash"; // **** needs to be localized ****
static NS_DEFINE_CID(kNetServiceCID, NS_NETSERVICE_CID);
static NS_DEFINE_CID(kSocketTransportServiceCID, NS_SOCKETTRANSPORTSERVICE_CID);
static NS_DEFINE_IID(kIWebShell, NS_IWEB_SHELL_IID);
static NS_DEFINE_CID(kEventQueueServiceCID, NS_EVENTQUEUESERVICE_CID);
static NS_DEFINE_CID(kCImapService, NS_IMAPSERVICE_CID);
@ -284,7 +276,8 @@ nsresult nsImapProtocol::Initialize(nsIImapHostSessionList * aHostSessionList, n
nsImapProtocol::~nsImapProtocol()
{
PR_FREEIF(m_userName);
PR_FREEIF(m_hostName);
nsCRT::free(m_hostName);
PR_FREEIF(m_dataOutputBuf);
if (m_inputStreamBuffer)
@ -346,11 +339,8 @@ nsImapProtocol::GetImapHostName()
{
if (!m_userName && m_runningUrl)
{
const char * temp = nsnull;
nsCOMPtr<nsIURI> url = do_QueryInterface(m_runningUrl);
url->GetHost(&temp);
if (temp) // keep our own copy
m_hostName = PL_strdup(temp);
url->GetHost(&m_hostName);
}
return m_hostName;
@ -458,28 +448,29 @@ nsresult nsImapProtocol::SetupWithUrl(nsIURI * aURL, nsISupports* aConsumer)
if (!m_server)
rv = m_runningUrl->GetServer(getter_AddRefs(m_server));
if ( m_runningUrl && !m_transport /* and we don't have a transport yet */)
if ( m_runningUrl && !m_channel /* and we don't have a transport yet */)
{
// extract the file name and create a file transport...
PRUint32 port = IMAP_PORT;
PRInt32 port = IMAP_PORT;
nsXPIDLCString hostName;
aURL->GetHostPort(&port);
NS_WITH_SERVICE(nsINetService, pNetService, kNetServiceCID, &rv);
NS_WITH_SERVICE(nsISocketTransportService, socketService, kSocketTransportServiceCID, &rv);
if (NS_SUCCEEDED(rv) && pNetService)
rv = pNetService->CreateSocketTransport(getter_AddRefs(m_transport), port, GetImapHostName());
if (NS_SUCCEEDED(rv) && aURL)
{
aURL->GetPort(&port);
aURL->GetHost(getter_Copies(hostName));
rv = m_transport->GetOutputStream(getter_AddRefs(m_outputStream));
NS_ASSERTION(NS_SUCCEEDED(rv), "ooops, transport layer unable to create an output stream");
rv = m_transport->GetOutputStreamConsumer(getter_AddRefs(m_outputConsumer));
NS_ASSERTION(NS_SUCCEEDED(rv), "ooops, transport layer unable to provide us with an output consumer!");
// register self as the consumer for the socket...
rv = m_transport->SetInputStreamConsumer((nsIStreamListener *) this);
NS_ASSERTION(NS_SUCCEEDED(rv), "unable to register Imap instance as a consumer on the socket");
ClearFlag(IMAP_CONNECTION_IS_OPEN);
rv = socketService->CreateTransport(hostName, port, getter_AddRefs(m_channel));
if (NS_SUCCEEDED(rv))
rv = m_channel->OpenOutputStream(0 /* start position */, getter_AddRefs(m_outputStream));
}
} // if m_runningUrl
} // if aUR
return rv;
return rv;
}
@ -549,8 +540,7 @@ void nsImapProtocol::ImapThreadMain(void *aParm)
}
me->m_runningUrl = null_nsCOMPtr();
me->m_transport = null_nsCOMPtr();
me->m_inputStream = null_nsCOMPtr();
me->m_channel = null_nsCOMPtr();
me->m_outputStream = null_nsCOMPtr();
me->m_outputConsumer = null_nsCOMPtr();
me->m_streamConsumer = null_nsCOMPtr();
@ -932,8 +922,7 @@ void nsImapProtocol::ParseIMAPandCheckForNewMail(const char* commandString)
/////////////////////////////////////////////////////////////////////////////////////////////
// we suppport the nsIStreamListener interface
////////////////////////////////////////////////////////////////////////////////////////////
NS_IMETHODIMP nsImapProtocol::OnDataAvailable(nsIURI* aURL, nsIInputStream *aIStream, PRUint32 aLength)
NS_IMETHODIMP nsImapProtocol::OnDataAvailable(nsIChannel * /* aChannel */, nsISupports *ctxt, nsIInputStream *aIStream, PRUint32 aSourceOffset, PRUint32 aLength)
{
PR_CEnterMonitor(this);
@ -943,7 +932,7 @@ NS_IMETHODIMP nsImapProtocol::OnDataAvailable(nsIURI* aURL, nsIInputStream *aISt
if(NS_SUCCEEDED(res) && aLength > 0)
{
// make sure m_inputStream is set to the right input stream...
if (m_inputStream == nsnull)
if (!m_inputStream)
m_inputStream = dont_QueryInterface(aIStream);
// if we received data, we need to signal the data available monitor...
@ -958,7 +947,7 @@ NS_IMETHODIMP nsImapProtocol::OnDataAvailable(nsIURI* aURL, nsIInputStream *aISt
return res;
}
NS_IMETHODIMP nsImapProtocol::OnStartRequest(nsIURI* aURL, const char *aContentType)
NS_IMETHODIMP nsImapProtocol::OnStartRequest(nsIChannel * /* aChannel */, nsISupports *ctxt)
{
PR_CEnterMonitor(this);
nsresult rv = NS_OK;
@ -970,16 +959,16 @@ NS_IMETHODIMP nsImapProtocol::OnStartRequest(nsIURI* aURL, const char *aContentT
}
// stop binding is a "notification" informing us that the stream associated with aURL is going away.
NS_IMETHODIMP nsImapProtocol::OnStopRequest(nsIURI* aURL, nsresult aStatus, const PRUnichar* aMsg)
NS_IMETHODIMP nsImapProtocol::OnStopRequest(nsIChannel * /* aChannel */, nsISupports *ctxt, nsresult aStatus, const PRUnichar* aMsg)
{
PR_CEnterMonitor(this);
nsresult rv = NS_OK;
nsCOMPtr<nsIMsgMailNewsUrl> mailnewsurl = do_QueryInterface(m_runningUrl, &rv);
if (NS_SUCCEEDED(rv) && mailnewsurl)
mailnewsurl->SetUrlState(PR_FALSE, aStatus); // set change in url
m_transport = null_nsCOMPtr();
m_channel = null_nsCOMPtr();
m_outputStream = null_nsCOMPtr();
m_outputConsumer = null_nsCOMPtr();
m_inputStream = null_nsCOMPtr();
PR_CExitMonitor(this);
return NS_OK;
}
@ -1021,25 +1010,14 @@ nsresult nsImapProtocol::SendData(const char * dataBuffer)
PRUint32 writeCount = 0;
nsresult rv = NS_ERROR_NULL_POINTER;
if (!m_transport)
if (!m_channel)
return NS_ERROR_FAILURE;
NS_PRECONDITION(m_outputStream && m_outputConsumer, "no registered consumer for our output");
if (dataBuffer && m_outputStream)
{
m_currentCommand = dataBuffer;
Log("SendData", nsnull, dataBuffer);
rv = m_outputStream->Write(dataBuffer, PL_strlen(dataBuffer),
&writeCount);
if (NS_SUCCEEDED(rv) && writeCount == PL_strlen(dataBuffer))
{
nsCOMPtr<nsIInputStream> inputStream = do_QueryInterface(m_outputStream);
nsCOMPtr<nsIURI> url = do_QueryInterface(m_runningUrl);
if (inputStream)
rv = m_outputConsumer->OnDataAvailable(url,
inputStream,
writeCount);
}
rv = m_outputStream->Write(dataBuffer, PL_strlen(dataBuffer), &writeCount);
if (NS_FAILED(rv))
TellThreadToDie(PR_FALSE);
}
@ -1068,7 +1046,7 @@ nsresult nsImapProtocol::LoadUrl(nsIURI * aURL, nsISupports * aConsumer)
if (NS_FAILED(rv)) return rv;
SetupSinkProxy(); // generate proxies for all of the event sinks in the url
m_lastActiveTime = PR_Now();
if (m_transport && m_runningUrl)
if (m_channel && m_runningUrl)
{
nsIImapUrl::nsImapAction imapAction;
m_runningUrl->GetImapAction(&imapAction);
@ -1079,12 +1057,10 @@ nsresult nsImapProtocol::LoadUrl(nsIURI * aURL, nsISupports * aConsumer)
// can get away with this.
m_needNoop = (imapAction == nsIImapUrl::nsImapSelectFolder || imapAction == nsIImapUrl::nsImapDeleteAllMsgs);
PRBool transportOpen = PR_FALSE;
m_transport->IsTransportOpen(&transportOpen);
if (transportOpen == PR_FALSE)
if (!TestFlag(IMAP_CONNECTION_IS_OPEN))
{
// m_urlInProgress = PR_TRUE;
rv = m_transport->Open(aURL); // opening the url will cause to get notified when the connection is established
m_channel->AsyncRead(0, -1, aURL,this /* stream observer */);
SetFlag(IMAP_CONNECTION_IS_OPEN);
}
// We now have a url to run so signal the monitor for url ready to be processed...
@ -1105,7 +1081,7 @@ NS_IMETHODIMP nsImapProtocol::IsBusy(PRBool &aIsConnectionBusy,
nsresult rv = NS_OK;
aIsConnectionBusy = PR_FALSE;
isInboxConnection = PR_FALSE;
if (!m_transport)
if (!m_channel)
{
// ** jt -- something is really wrong kill the thread
TellThreadToDie(PR_FALSE);
@ -1139,7 +1115,7 @@ NS_IMETHODIMP nsImapProtocol::CanHandleUrl(nsIImapUrl * aImapUrl,
PRBool isBusy = PR_FALSE;
PRBool isInboxConnection = PR_FALSE;
if (!m_transport)
if (!m_channel)
{
// *** jt -- something is really wrong; it could be the dialer gave up
// the connection or ip binding has been release by the operating
@ -4678,7 +4654,7 @@ void nsImapProtocol::DiscoverMailboxList()
if (boxSpec)
{
boxSpec->folderSelected = PR_FALSE;
boxSpec->hostName = GetImapHostName();
boxSpec->hostName = nsCRT::strdup(GetImapHostName());
boxSpec->connection = this;
boxSpec->flagState = nsnull;
boxSpec->discoveredFromLsub = PR_TRUE;

View File

@ -23,8 +23,6 @@
#include "nsIImapUrl.h"
#include "nsIStreamListener.h"
#include "nsITransport.h"
#include "nsIOutputStream.h"
#include "nsImapCore.h"
#include "nsString2.h"
@ -53,6 +51,7 @@ class nsIWebShell;
#define IMAP_RECEIVED_GREETING 0x00000001 /* should we pause for the next read */
#define IMAP_FIRST_PASS_IN_THREAD 0x00000002 /* entering thread for the first time? */
#define IMAP_CONNECTION_IS_OPEN 0x00000004 /* is the connection currently open? */
class nsImapProtocol : public nsIImapProtocol
{
@ -79,18 +78,14 @@ public:
////////////////////////////////////////////////////////////////////////////////////////
// we suppport the nsIStreamListener interface
////////////////////////////////////////////////////////////////////////////////////////
// mscott; I don't think we need to worry about this yet so I'll leave it stubbed out for now
NS_IMETHOD GetBindInfo(nsIURI* aURL, nsStreamBindingInfo* aInfo) { return NS_OK;} ;
// Whenever data arrives from the connection, core netlib notifies the protocol by calling
// OnDataAvailable. We then read and process the incoming data from the input stream.
NS_IMETHOD OnDataAvailable(nsIURI* aURL, nsIInputStream *aIStream, PRUint32 aLength);
NS_IMETHOD OnStartRequest(nsIURI* aURL, const char *aContentType);
NS_IMETHOD OnDataAvailable(nsIChannel * aChannel, nsISupports *ctxt, nsIInputStream *inStr, PRUint32 sourceOffset, PRUint32 count);
NS_IMETHOD OnStartRequest(nsIChannel * aChannel,nsISupports *ctxt);
// stop binding is a "notification" informing us that the stream associated with aURL is going away.
NS_IMETHOD OnStopRequest(nsIURI* aURL, nsresult aStatus, const PRUnichar* aMsg);
NS_IMETHOD OnStopRequest(nsIChannel * aChannel,nsISupports *ctxt, nsresult aStatus, const PRUnichar *aMsg);
// Ideally, a protocol should only have to support the stream listener methods covered above.
// However, we don't have this nsIStreamListenerLite interface defined yet. Until then, we are using
@ -286,14 +281,12 @@ private:
PRUint32 m_curReadIndex; // current read index
// Ouput stream for writing commands to the socket
nsCOMPtr<nsITransport> m_transport;
nsCOMPtr<nsIInputStream> m_inputStream; // this is the stream netlib writes data into for us to read.
nsCOMPtr<nsIOutputStream> m_outputStream; // this will be obtained from the transport interface
nsCOMPtr<nsIStreamListener> m_outputConsumer; // this will be obtained from the transport interface
nsCOMPtr<nsIChannel> m_channel;
nsCOMPtr<nsIOutputStream> m_outputStream; // this will be obtained from the transport interface
nsCOMPtr<nsIInputStream> m_inputStream;
nsCOMPtr<nsIStreamListener> m_outputConsumer;
nsCOMPtr<nsISupports> m_streamConsumer; // if we are displaying an article this is the rfc-822 display sink...
nsCOMPtr<nsISupports> m_streamConsumer; // 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

View File

@ -789,6 +789,7 @@ void nsImapServerResponseParser::mailbox_list(PRBool discoveredFromLsub)
}
}
nsCRT::free(boxSpec->hostName);
PR_FREEIF(boxSpec); // mscott - do we have any fields we need to release?
}
@ -2273,7 +2274,7 @@ struct mailbox_spec *nsImapServerResponseParser::CreateCurrentMailboxSpec(const
const char *host =
fServerConnection.GetImapHostName();
nsIMAPNamespace *ns = nsnull;
if (host != nsnull && fHostSessionList)
if (host && fHostSessionList)
{
const char* userName = fServerConnection.GetImapUserName();
fHostSessionList->GetNamespaceForMailboxForHost(host,

View File

@ -19,10 +19,6 @@
#include "msgCore.h" // precompiled header...
#include "nsMsgImapCID.h"
#ifdef XP_PC
#include <windows.h> // for InterlockedIncrement
#endif
#include "nsIServiceManager.h"
#include "nsIComponentManager.h"
@ -38,6 +34,7 @@
#include "nsIRDFService.h"
#include "nsIEventQueueService.h"
#include "nsRDFCID.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
// that multiply inherits from nsISupports
@ -71,15 +68,21 @@ nsresult nsImapService::QueryInterface(const nsIID &aIID, void** aInstancePtr)
if (aIID.Equals(nsIImapService::GetIID()) || aIID.Equals(kISupportsIID))
{
*aInstancePtr = (void*) ((nsIImapService*)this);
AddRef();
NS_ADDREF_THIS();
return NS_OK;
}
if (aIID.Equals(nsIMsgMessageService::GetIID()))
{
*aInstancePtr = (void*) ((nsIMsgMessageService*)this);
AddRef();
NS_ADDREF_THIS();
return NS_OK;
}
if (aIID.Equals(nsIProtocolHandler::GetIID()))
{
*aInstancePtr = (void*) ((nsIProtocolHandler*)this);
NS_ADDREF_THIS();
return NS_OK;
}
#if defined(NS_DEBUG)
/*
@ -149,7 +152,10 @@ nsImapService::SelectFolder(nsIEventQueue * aClientEventQueue,
urlSpec.Append(folderName.GetBuffer());
nsCOMPtr <nsIURI> url = do_QueryInterface(imapUrl, &rv);
if (NS_SUCCEEDED(rv) && url)
rv = url->SetSpec(urlSpec.GetBuffer());
// mscott - this cast to a char * is okay...there's a bug in the XPIDL
// compiler that is preventing in string parameters from showing up as
// const char *. hopefully they will fix it soon.
rv = url->SetSpec((char *) urlSpec.GetBuffer());
if (NS_SUCCEEDED(rv))
rv = GetImapConnectionAndLoadUrl(aClientEventQueue,
imapUrl,
@ -202,7 +208,10 @@ nsImapService::LiteSelectFolder(nsIEventQueue * aClientEventQueue,
urlSpec.Append(folderName.GetBuffer());
nsCOMPtr <nsIURI> url = do_QueryInterface(imapUrl, &rv);
if (NS_SUCCEEDED(rv) && url)
rv = url->SetSpec(urlSpec.GetBuffer());
// mscott - this cast to a char * is okay...there's a bug in the XPIDL
// compiler that is preventing in string parameters from showing up as
// const char *. hopefully they will fix it soon.
rv = url->SetSpec((char *) urlSpec.GetBuffer());
if (NS_SUCCEEDED(rv))
rv = GetImapConnectionAndLoadUrl(aClientEventQueue, imapUrl,
aUrlListener, nsnull, aURL);
@ -389,7 +398,10 @@ nsImapService::FetchMessage(nsIEventQueue * aClientEventQueue,
urlSpec.Append(messageIdentifierList);
nsCOMPtr <nsIURI> url = do_QueryInterface(imapUrl, &rv);
if (NS_SUCCEEDED(rv) && url)
rv = url->SetSpec(urlSpec.GetBuffer());
// mscott - this cast to a char * is okay...there's a bug in the XPIDL
// compiler that is preventing in string parameters from showing up as
// const char *. hopefully they will fix it soon.
rv = url->SetSpec((char *) urlSpec.GetBuffer());
if (NS_SUCCEEDED(rv))
rv = GetImapConnectionAndLoadUrl(aClientEventQueue, imapUrl,
aUrlListener,
@ -435,11 +447,17 @@ nsImapService::CreateStartOfImapUrl(nsIImapUrl * &imapUrl,
urlSpec.Append('@');
#endif
urlSpec.Append(hostname);
urlSpec.Append(':');
urlSpec.Append("143"); // mscott -- i know this is bogus...i'm i a hurry =)
// *** jefft - force to parse the urlSpec in order to search for
// the correct incoming server
nsCOMPtr <nsIURI> url = do_QueryInterface(imapUrl, &rv);
if (NS_SUCCEEDED(rv) && url)
rv = url->SetSpec(urlSpec.GetBuffer());
// mscott - this cast to a char * is okay...there's a bug in the XPIDL
// compiler that is preventing in string parameters from showing up as
// const char *. hopefully they will fix it soon.
rv = url->SetSpec((char *) urlSpec.GetBuffer());
}
@ -495,7 +513,10 @@ nsImapService::GetHeaders(nsIEventQueue * aClientEventQueue,
urlSpec.Append(messageIdentifierList);
nsCOMPtr <nsIURI> url = do_QueryInterface(imapUrl, &rv);
if (NS_SUCCEEDED(rv) && url)
rv = url->SetSpec(urlSpec.GetBuffer());
// mscott - this cast to a char * is okay...there's a bug in the XPIDL
// compiler that is preventing in string parameters from showing up as
// const char *. hopefully they will fix it soon.
rv = url->SetSpec((char *) urlSpec.GetBuffer());
if (NS_SUCCEEDED(rv))
rv = GetImapConnectionAndLoadUrl(aClientEventQueue, imapUrl,
@ -544,7 +565,10 @@ nsImapService::Noop(nsIEventQueue * aClientEventQueue,
urlSpec.Append(folderName.GetBuffer());
nsCOMPtr <nsIURI> url = do_QueryInterface(imapUrl, &rv);
if (NS_SUCCEEDED(rv) && url)
rv = url->SetSpec(urlSpec.GetBuffer());
// mscott - this cast to a char * is okay...there's a bug in the XPIDL
// compiler that is preventing in string parameters from showing up as
// const char *. hopefully they will fix it soon.
rv = url->SetSpec((char *) urlSpec.GetBuffer());
if (NS_SUCCEEDED(rv))
rv = GetImapConnectionAndLoadUrl(aClientEventQueue, imapUrl,
aUrlListener, nsnull, aURL);
@ -589,7 +613,10 @@ nsImapService::Expunge(nsIEventQueue * aClientEventQueue,
urlSpec.Append(folderName.GetBuffer());
nsCOMPtr <nsIURI> url = do_QueryInterface(imapUrl, &rv);
if (NS_SUCCEEDED(rv) && url)
rv = url->SetSpec(urlSpec.GetBuffer());
// mscott - this cast to a char * is okay...there's a bug in the XPIDL
// compiler that is preventing in string parameters from showing up as
// const char *. hopefully they will fix it soon.
rv = url->SetSpec((char *) urlSpec.GetBuffer());
if (NS_SUCCEEDED(rv))
rv = GetImapConnectionAndLoadUrl(aClientEventQueue, imapUrl,
aUrlListener, nsnull, aURL);
@ -639,7 +666,10 @@ nsImapService::Biff(nsIEventQueue * aClientEventQueue,
urlSpec.Append(uidHighWater, 10);
nsCOMPtr <nsIURI> url = do_QueryInterface(imapUrl, &rv);
if (NS_SUCCEEDED(rv) && url)
rv = url->SetSpec(urlSpec.GetBuffer());
// mscott - this cast to a char * is okay...there's a bug in the XPIDL
// compiler that is preventing in string parameters from showing up as
// const char *. hopefully they will fix it soon.
rv = url->SetSpec((char *) urlSpec.GetBuffer());
if (NS_SUCCEEDED(rv))
rv = GetImapConnectionAndLoadUrl(aClientEventQueue, imapUrl,
aUrlListener, nsnull, aURL);
@ -692,7 +722,10 @@ nsImapService::DeleteMessages(nsIEventQueue * aClientEventQueue,
urlSpec.Append(messageIdentifierList);
nsCOMPtr <nsIURI> url = do_QueryInterface(imapUrl, &rv);
if (NS_SUCCEEDED(rv) && url)
rv = url->SetSpec(urlSpec.GetBuffer());
// mscott - this cast to a char * is okay...there's a bug in the XPIDL
// compiler that is preventing in string parameters from showing up as
// const char *. hopefully they will fix it soon.
rv = url->SetSpec((char *) urlSpec.GetBuffer());
if (NS_SUCCEEDED(rv))
rv = GetImapConnectionAndLoadUrl(aClientEventQueue, imapUrl,
aUrlListener, nsnull, aURL);
@ -738,7 +771,10 @@ nsImapService::DeleteAllMessages(nsIEventQueue * aClientEventQueue,
urlSpec.Append(folderName.GetBuffer());
nsCOMPtr <nsIURI> url = do_QueryInterface(imapUrl, &rv);
if (NS_SUCCEEDED(rv) && url)
rv = url->SetSpec(urlSpec.GetBuffer());
// mscott - this cast to a char * is okay...there's a bug in the XPIDL
// compiler that is preventing in string parameters from showing up as
// const char *. hopefully they will fix it soon.
rv = url->SetSpec((char *) urlSpec.GetBuffer());
if (NS_SUCCEEDED(rv))
rv = GetImapConnectionAndLoadUrl(aClientEventQueue, imapUrl,
aUrlListener, nsnull, aURL);
@ -839,7 +875,10 @@ nsresult nsImapService::DiddleFlags(nsIEventQueue * aClientEventQueue,
urlSpec.Append(flags, 10);
nsCOMPtr <nsIURI> url = do_QueryInterface(imapUrl, &rv);
if (NS_SUCCEEDED(rv) && url)
rv = url->SetSpec(urlSpec.GetBuffer());
// mscott - this cast to a char * is okay...there's a bug in the XPIDL
// compiler that is preventing in string parameters from showing up as
// const char *. hopefully they will fix it soon.
rv = url->SetSpec((char *) urlSpec.GetBuffer());
if (NS_SUCCEEDED(rv))
rv = GetImapConnectionAndLoadUrl(aClientEventQueue, imapUrl,
aUrlListener, nsnull, aURL);
@ -923,7 +962,10 @@ nsImapService::DiscoverAllFolders(nsIEventQueue* aClientEventQueue,
urlSpec.Append("/discoverallboxes");
nsCOMPtr <nsIURI> url = do_QueryInterface(aImapUrl, &rv);
if (NS_SUCCEEDED(rv) && url)
rv = url->SetSpec(urlSpec.GetBuffer());
// mscott - this cast to a char * is okay...there's a bug in the XPIDL
// compiler that is preventing in string parameters from showing up as
// const char *. hopefully they will fix it soon.
rv = url->SetSpec((char *) urlSpec.GetBuffer());
if (NS_SUCCEEDED(rv))
rv = GetImapConnectionAndLoadUrl(aClientEventQueue, aImapUrl,
aUrlListener, nsnull, aURL);
@ -959,7 +1001,10 @@ nsImapService::DiscoverAllAndSubscribedFolders(nsIEventQueue* aClientEventQueue,
urlSpec.Append("/discoverallandsubscribedboxes");
nsCOMPtr <nsIURI> url = do_QueryInterface(aImapUrl, &rv);
if (NS_SUCCEEDED(rv) && url)
rv = url->SetSpec(urlSpec.GetBuffer());
// mscott - this cast to a char * is okay...there's a bug in the XPIDL
// compiler that is preventing in string parameters from showing up as
// const char *. hopefully they will fix it soon.
rv = url->SetSpec((char *) urlSpec.GetBuffer());
if (NS_SUCCEEDED(rv))
rv = GetImapConnectionAndLoadUrl(aClientEventQueue, aImapUrl,
aUrlListener, nsnull, aURL);
@ -1001,7 +1046,10 @@ nsImapService::DiscoverChildren(nsIEventQueue* aClientEventQueue,
urlSpec.Append(folderName.GetBuffer());
nsCOMPtr <nsIURI> url = do_QueryInterface(aImapUrl, &rv);
if (NS_SUCCEEDED(rv) && url)
rv = url->SetSpec(urlSpec.GetBuffer());
// mscott - this cast to a char * is okay...there's a bug in the XPIDL
// compiler that is preventing in string parameters from showing up as
// const char *. hopefully they will fix it soon.
rv = url->SetSpec((char *) urlSpec.GetBuffer());
if (NS_SUCCEEDED(rv))
rv = GetImapConnectionAndLoadUrl(aClientEventQueue,
aImapUrl,
@ -1052,7 +1100,10 @@ nsImapService::DiscoverLevelChildren(nsIEventQueue* aClientEventQueue,
urlSpec.Append(folderName.GetBuffer());
nsCOMPtr <nsIURI> url = do_QueryInterface(aImapUrl, &rv);
if (NS_SUCCEEDED(rv) && url)
rv = url->SetSpec(urlSpec.GetBuffer());
// mscott - this cast to a char * is okay...there's a bug in the XPIDL
// compiler that is preventing in string parameters from showing up as
// const char *. hopefully they will fix it soon.
rv = url->SetSpec((char *) urlSpec.GetBuffer());
if (NS_SUCCEEDED(rv))
rv = GetImapConnectionAndLoadUrl(aClientEventQueue,
aImapUrl,
@ -1159,7 +1210,10 @@ nsImapService::OnlineMessageCopy(nsIEventQueue* aClientEventQueue,
nsCOMPtr <nsIURI> url = do_QueryInterface(imapUrl, &rv);
if (NS_SUCCEEDED(rv) && url)
rv = url->SetSpec(urlSpec.GetBuffer());
// mscott - this cast to a char * is okay...there's a bug in the XPIDL
// compiler that is preventing in string parameters from showing up as
// const char *. hopefully they will fix it soon.
rv = url->SetSpec((char *) urlSpec.GetBuffer());
if (NS_SUCCEEDED(rv))
rv = GetImapConnectionAndLoadUrl(aClientEventQueue, imapUrl,
aUrlListener, nsnull, aURL);
@ -1225,7 +1279,9 @@ nsImapService::AppendMessageFromFile(nsIEventQueue* aClientEventQueue,
}
nsCOMPtr<nsIURI> url = do_QueryInterface(imapUrl, &rv);
if (NS_SUCCEEDED(rv))
rv = url->SetSpec(urlSpec.GetBuffer());
// mscott - this cast is OK....bug in idl compiler is preventing
// the argument in SetSpec from being expressed as a const char *
rv = url->SetSpec((char *) urlSpec.GetBuffer());
if (NS_SUCCEEDED(rv))
rv = GetImapConnectionAndLoadUrl(aClientEventQueue, imapUrl,
aListener, nsnull, aURL);
@ -1846,3 +1902,47 @@ char *CreateIMAPListFolderURL(const char *imapHost, const char *mailboxName, cha
return returnString;
}
#endif
NS_IMETHODIMP nsImapService::GetScheme(char * *aScheme)
{
nsresult rv = NS_OK;
if (aScheme)
*aScheme = PL_strdup("imap");
else
rv = NS_ERROR_NULL_POINTER;
return rv;
}
NS_IMETHODIMP nsImapService::GetDefaultPort(PRInt32 *aDefaultPort)
{
nsresult rv = NS_OK;
if (aDefaultPort)
*aDefaultPort = IMAP_PORT;
else
rv = NS_ERROR_NULL_POINTER;
return rv;
}
NS_IMETHODIMP nsImapService::MakeAbsolute(const char *aRelativeSpec, nsIURI *aBaseURI, char **_retval)
{
// no such thing as relative urls for smtp.....
NS_ASSERTION(0, "unimplemented");
return NS_OK;
}
NS_IMETHODIMP nsImapService::NewURI(const char *aSpec, nsIURI *aBaseURI, nsIURI **_retval)
{
// i just haven't implemented this yet...I will be though....
NS_ASSERTION(0, "unimplemented");
return NS_OK;
}
NS_IMETHODIMP nsImapService::NewChannel(const char *verb, nsIURI *aURI, nsIEventSinkGetter *eventSinkGetter, nsIEventQueue *eventQueue, nsIChannel **_retval)
{
// mscott - right now, I don't like the idea of returning channels to the caller. They just want us
// to run the url, they don't want a channel back...I'm going to be addressing this issue with
// the necko team in more detail later on.
NS_ASSERTION(0, "unimplemented");
return NS_OK;
}

View File

@ -24,13 +24,14 @@
#include "nsISupportsArray.h"
#include "nsCOMPtr.h"
#include "nsIFileSpec.h"
#include "nsIProtocolHandler.h"
class nsIImapHostSessionList;
class nsString2;
class nsIImapUrl;
class nsIMsgFolder;
class nsImapService : public nsIImapService, public nsIMsgMessageService
class nsImapService : public nsIImapService, public nsIMsgMessageService, public nsIProtocolHandler
{
public:
@ -149,6 +150,7 @@ public:
////////////////////////////////////////////////////////////////////////////////////////
// End support of nsIImapService interface
////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////
// we suppport the nsIMsgMessageService Interface
////////////////////////////////////////////////////////////////////////////////////////
@ -161,6 +163,19 @@ public:
NS_IMETHOD SaveMessageToDisk(const char *aMessageURI, nsIFileSpec *aFile, PRBool aAppendToFile,
nsIUrlListener *aUrlListener, nsIURI **aURL);
////////////////////////////////////////////////////////////////////////////////////////
// we suppport the nsIProtocolHandler interface
////////////////////////////////////////////////////////////////////////////////////////
NS_IMETHOD GetScheme(char * *aScheme);
NS_IMETHOD GetDefaultPort(PRInt32 *aDefaultPort);
NS_IMETHOD MakeAbsolute(const char *aRelativeSpec, nsIURI *aBaseURI, char **_retval);
NS_IMETHOD NewURI(const char *aSpec, nsIURI *aBaseURI, nsIURI **_retval);
NS_IMETHOD NewChannel(const char *verb, nsIURI *aURI, nsIEventSinkGetter *eventSinkGetter, nsIEventQueue *eventQueue, nsIChannel **_retval);
////////////////////////////////////////////////////////////////////////////////////////
// End support of nsIProtocolHandler interface
////////////////////////////////////////////////////////////////////////////////////////
protected:
nsresult GetFolderName(nsIMsgFolder* aImapFolder,
nsString2& folderName);

View File

@ -19,16 +19,10 @@
#include "msgCore.h" // precompiled header...
#include "nsMsgImapCID.h"
#ifdef XP_PC
#include <windows.h> // for InterlockedIncrement
#endif
#include "nsIEventQueueService.h"
#include "nsIURL.h"
#include "nsImapUrl.h"
#include "nsINetService.h"
#include "nsIMsgMailSession.h"
#include "nsIIMAPHostSessionList.h"
#include "nsIMAPGenericParser.h"
@ -41,6 +35,7 @@
#include "nsIImapIncomingServer.h"
#include "nsMsgBaseCID.h"
#include "nsImapUtils.h"
#include "nsXPIDLString.h"
static NS_DEFINE_CID(kMsgMailSessionCID, NS_MSGMAILSESSION_CID);
static NS_DEFINE_CID(kCImapHostSessionListCID, NS_IIMAPHOSTSESSIONLIST_CID);
@ -239,140 +234,30 @@ NS_IMETHODIMP nsImapUrl::SetImapMiscellaneousSink(nsIImapMiscellaneousSink *
// End nsIImapUrl specific support
////////////////////////////////////////////////////////////////////////////////////
nsresult nsImapUrl::ParseUrl(const nsString& aSpec)
NS_IMETHODIMP nsImapUrl::SetSpec(char * aSpec)
{
#ifdef DEBUG_mscott
// mscott - i just added a new method for intialization, I'm adding a quick
// check here to verify that initialize was called on this class...this is
// really for debugging purposes so I can find out if I missed a spot where
// I needed to initialize the url before using it.
NS_ASSERTION(m_userName, "oops...looks like we didn't initialize the url.");
#endif
nsresult rv = nsMsgMailNewsUrl::SetSpec(aSpec);
if (NS_SUCCEEDED(rv))
rv = ParseUrl();
return rv;
}
// XXX hack!
char* cSpec = aSpec.ToNewCString();
nsresult nsImapUrl::ParseUrl()
{
nsresult rv = NS_OK;
NS_LOCK_INSTANCE();
NS_LOCK_INSTANCE();
PR_FREEIF(m_protocol);
PR_FREEIF(m_host);
PR_FREEIF(m_search);
PR_FREEIF(m_file);
m_port = IMAP_PORT;
// mscott -> eventually we'll replace all of this duplicate host and port parsing code with a url parser
// class..this should come with N2 Landing...
// The URL is considered absolute if and only if it begins with a
// protocol spec. A protocol spec is an alphanumeric string of 1 or
// more characters that is terminated with a colon.
PRBool isAbsolute = PR_FALSE;
char* cp = nsnull;
char *imapPartOfUrl = nsnull;
char* ap = cSpec;
char ch;
while (0 != (ch = *ap))
char * imapPartOfUrl = nsnull;
rv = GetPath(&imapPartOfUrl);
if (NS_SUCCEEDED(rv) && imapPartOfUrl && imapPartOfUrl+1)
{
if (((ch >= 'a') && (ch <= 'z')) ||
((ch >= 'A') && (ch <= 'Z')) ||
((ch >= '0') && (ch <= '9')))
{
ap++;
continue;
}
if ((ch == ':') && (ap - cSpec >= 2))
{
isAbsolute = PR_TRUE;
cp = ap;
break;
}
break;
}
PRInt32 slen = aSpec.Length();
m_spec = (char *) PR_Malloc(slen + 1);
aSpec.ToCString(m_spec, slen+1);
// get protocol first
PRInt32 plen = cp - cSpec;
m_protocol = (char*) PR_Malloc(plen + 1);
PL_strncpy(m_protocol, cSpec, plen);
m_protocol[plen] = 0;
cp++; // eat : in protocol
// skip over one, two or three slashes
if (*cp == '/')
{
cp++;
if (*cp == '/')
{
cp++;
if (*cp == '/')
cp++;
}
}
else
{
delete [] cSpec;
NS_UNLOCK_INSTANCE();
return NS_ERROR_ILLEGAL_VALUE;
}
// Host name follows protocol for http style urls
const char* cp0 = cp;
cp = PL_strchr(cp0, '@');
if (cp) {
// we have a username between cp0 and cp
PR_FREEIF(m_userName);
m_userName = PL_strndup(cp0, (cp - cp0));
cp0 = cp+1;
}
cp = PL_strpbrk(cp0, "/:");
if (nsnull == cp)
{
// There is only a host name
PRInt32 hlen = PL_strlen(cp0);
m_host = (char*) PR_Malloc(hlen + 1);
PL_strcpy(m_host, cp0);
ParseImapPart(imapPartOfUrl+1); // GetPath leaves leading '/' in the path!!!
nsCRT::free(imapPartOfUrl);
}
else {
PRInt32 hlen = cp - cp0;
m_host = (char*) PR_Malloc(hlen + 1);
PL_strncpy(m_host, cp0, hlen);
m_host[hlen] = 0;
if (':' == *cp)
{
// We have a port number
cp0 = cp+1;
cp = PL_strchr(cp, '/');
m_port = strtol(cp0, (char **)nsnull, 10 /* base 10 */);
}
imapPartOfUrl = cp + 1; // #### probably not quite right - should check for "/"??
cp = PL_strchr(cp, '?');
if (cp)
{
cp++;
PRInt32 cplen = PL_strlen(cp);
m_search = (char*) PR_Malloc(cplen+1);
PL_strcpy(m_search, cp);
}
}
if (imapPartOfUrl)
m_file = PL_strdup(imapPartOfUrl);
ParseImapPart(imapPartOfUrl);
delete [] cSpec;
if (m_host)
nsXPIDLCString host;
rv = GetHost(getter_Copies(host));
if (NS_SUCCEEDED(rv) && host)
{
nsresult rv = NS_OK;
NS_WITH_SERVICE(nsIMsgMailSession, session, kMsgMailSessionCID, &rv);
if (NS_FAILED(rv)) return rv;
@ -382,7 +267,7 @@ nsresult nsImapUrl::ParseUrl(const nsString& aSpec)
nsCOMPtr<nsIMsgIncomingServer> server;
rv = accountManager->FindServer(m_userName,
m_host,
host,
"imap",
getter_AddRefs(server));
if (NS_FAILED(rv)) return rv;
@ -395,43 +280,6 @@ nsresult nsImapUrl::ParseUrl(const nsString& aSpec)
return NS_OK;
}
void nsImapUrl::ReconstructSpec(void)
{
PR_FREEIF(m_spec);
char portBuffer[10];
if (0 != m_port)
PR_snprintf(portBuffer, 10, ":%d", m_port);
else
portBuffer[0] = '\0';
PRInt32 plen = PL_strlen(m_protocol) + PL_strlen(m_host) +
PL_strlen(portBuffer) + 4;
if (m_file)
plen += 1 + PL_strlen(m_file);
if (m_search)
plen += 1 + PL_strlen(m_search);
m_spec = (char *) PR_Malloc(plen + 1);
PR_snprintf(m_spec, plen, "%s://%s%s",
m_protocol, ((nsnull != m_host) ? m_host : ""), portBuffer);
if (m_file)
{
PL_strcat(m_spec, "/");
PL_strcat(m_spec, m_file);
}
if (m_search)
{
PL_strcat(m_spec, "?");
PL_strcat(m_spec, m_search);
}
}
NS_IMETHODIMP nsImapUrl::CreateSearchCriteriaString(nsString2 *aResult)
{
if (nsnull == aResult || !m_searchCriteriaString)
@ -466,7 +314,7 @@ NS_IMETHODIMP nsImapUrl::CreateListOfMessageIdsString(nsString2 *aResult)
// since that can specify an IMAP MIME part
char *wherePart = PL_strstr(m_listOfMessageIds, "/;section=");
if (wherePart)
bytesToCopy = MIN(bytesToCopy, wherePart - m_listOfMessageIds);
bytesToCopy = PR_MIN(bytesToCopy, wherePart - m_listOfMessageIds);
aResult->Assign(m_listOfMessageIds, bytesToCopy);
@ -896,7 +744,7 @@ NS_IMETHODIMP nsImapUrl::AllocateCanonicalPath(const char *serverPath, char onli
nsresult rv = NS_ERROR_NULL_POINTER;
char *canonicalPath = nsnull;
char delimiterToUse = onlineDelimiter;
const char* hostName = nsnull;
nsXPIDLCString hostName;
char* userName = nsnull;
nsString aString;
char *currentPath = (char *) serverPath;
@ -918,7 +766,7 @@ NS_IMETHODIMP nsImapUrl::AllocateCanonicalPath(const char *serverPath, char onli
if (!serverPath || NS_FAILED(rv))
goto done;
GetHost(&hostName);
GetHost(getter_Copies(hostName));
m_server->GetUsername(&userName);
hostSessionList->GetOnlineDirForHost(hostName, userName, aString);
@ -1090,7 +938,11 @@ nsImapUrl::GetURI(char** aURI)
{
*aURI = nsnull;
PRUint32 key = m_listOfMessageIds ? atoi(m_listOfMessageIds) : 0;
return nsBuildImapMessageURI(m_file, key, aURI);
nsXPIDLCString theFile;
// mscott --> this is probably wrong (the part about getting the file part)
// we may need to extract it from a different part of the uri.
GetFileName(getter_Copies(theFile));
return nsBuildImapMessageURI(theFile, key, aURI);
}
return rv;
}

View File

@ -30,6 +30,9 @@ public:
NS_DECL_ISUPPORTS_INHERITED
// nsIURI override
NS_IMETHOD SetSpec(char * aSpec);
///////////////////////////////////////////////////////////////////////////////
// we support the nsIImapUrl interface
///////////////////////////////////////////////////////////////////////////////
@ -93,8 +96,7 @@ public:
protected:
virtual nsresult ParseUrl(const nsString& aSpec);
virtual void ReconstructSpec(void);
virtual nsresult ParseUrl();
char *m_listOfMessageIds;
// handle the imap specific parsing

View File

@ -27,24 +27,11 @@ PROGRAM = testimap
CPPSRCS = imapProtocolTest.cpp
LIBS = \
-L$(DIST)/lib \
-L$(DIST)/bin \
-labouturl \
-lfileurl \
-lftpurl \
-lgophurl \
-lremoturl \
-lhttpurl \
-lsockstuburl \
-lnetcache \
-lmimetype \
-lnetcnvts \
-lnetwork \
-lnetlib \
-lmozreg \
LIBS = \
-L$(DIST)/lib \
-L$(DIST)/bin \
-lmozreg \
-lxpcom \
-lpwcac \
-lmozdbm \
-lxp \
-lpref \
@ -62,6 +49,7 @@ LIBS = \
$(ZLIB_LIBS) \
$(NSPR_LIBS) \
$(TK_LIBS) \
-lneckoutil_s \
$(NULL)
include $(topsrcdir)/config/rules.mk

View File

@ -643,11 +643,11 @@ nsresult nsIMAP4TestDriver::OnTestUrlParsing()
nsCOMPtr<nsIMsgMailNewsUrl> mailnewsurl = do_QueryInterface(imapUrl);
mailnewsurl->SetSpec("imap://nsmail-2.mcom.com:143/test");
const char * urlHost = nsnull;
PRUint32 urlPort = 0;
char * urlHost = nsnull;
PRInt32 urlPort = 0;
mailnewsurl->GetHost(&urlHost);
mailnewsurl->GetHostPort(&urlPort);
mailnewsurl->GetPort(&urlPort);
printf("Host name test: %s\n", PL_strcmp(urlHost, hostName) == 0 ? "PASSED." : "FAILED!");
if (port > 0) // did the user try to test the port?
@ -673,13 +673,24 @@ int main()
nsComponentManager::RegisterComponent(kEventQueueServiceCID, NULL, NULL, XPCOM_DLL, PR_FALSE, PR_FALSE);
nsComponentManager::RegisterComponent(kPrefCID, nsnull, nsnull, PREF_DLL, PR_TRUE, PR_TRUE);
nsComponentManager::RegisterComponent(kEventQueueCID, NULL, NULL, XPCOM_DLL, PR_FALSE, PR_FALSE);
nsComponentManager::RegisterComponent(kFileLocatorCID, NULL, NS_FILELOCATOR_PROGID, APPSHELL_DLL, PR_FALSE, PR_FALSE);
// IMAP Service goes here?
nsComponentManager::RegisterComponent(kImapUrlCID, nsnull, nsnull,
MSGIMAP_DLL, PR_FALSE, PR_FALSE);
nsComponentManager::RegisterComponent(kFileLocatorCID, NULL, NS_FILELOCATOR_PROGID, APPSHELL_DLL, PR_FALSE, PR_FALSE);
result = nsComponentManager::AutoRegister(nsIComponentManager::NS_Startup, NULL /* default */);
nsComponentManager::RegisterComponent(kImapProtocolCID, nsnull, nsnull,
MSGIMAP_DLL, PR_FALSE, PR_FALSE);
// make sure prefs get initialized and loaded..
// mscott - this is just a bad bad bad hack right now until prefs
// has the ability to take nsnull as a parameter. Once that happens,
// prefs will do the work of figuring out which prefs file to load...
NS_WITH_SERVICE(nsIPref, prefs, kPrefCID, &result);
if (NS_FAILED(result) || (prefs == nsnull)) {
exit(result);
}
prefs->StartUp();
if (NS_FAILED(prefs->ReadUserPrefs()))
{
printf("Failed on reading user prefs!\n");
exit(-1);
}
// Create the Event Queue for the test app thread...a standin for the ui thread
NS_WITH_SERVICE(nsIEventQueueService, pEventQService, kEventQueueServiceCID, &result);

View File

@ -266,6 +266,12 @@ NSRegisterSelf(nsISupports* aServMgr, const char* path)
path, PR_TRUE, PR_TRUE);
if (NS_FAILED(rv)) finalResult = rv;
rv = compMgr->RegisterComponent(kMailboxServiceCID,
"Mailbox Protocol Handler",
NS_NETWORK_PROTOCOL_PROGID_PREFIX "mailbox",
path, PR_TRUE, PR_TRUE);
if (NS_FAILED(rv)) finalResult = rv;
rv = compMgr->RegisterComponent(kMailboxParserCID, nsnull, nsnull,
path, PR_TRUE, PR_TRUE);
if (NS_FAILED(rv)) finalResult = rv;
@ -279,6 +285,13 @@ NSRegisterSelf(nsISupports* aServMgr, const char* path)
path, PR_TRUE, PR_TRUE);
if (NS_FAILED(rv)) finalResult = rv;
rv = compMgr->RegisterComponent(kPop3ServiceCID,
"POP Protocol Handler",
NS_NETWORK_PROTOCOL_PROGID_PREFIX "pop3",
path, PR_TRUE, PR_TRUE);
if (NS_FAILED(rv)) finalResult = rv;
// register our RDF resource factories:
rv = compMgr->RegisterComponent(kLocalMailFolderResourceCID,
"Local Mail Folder Resource Factory",

View File

@ -35,6 +35,7 @@ EXPORTS= \
nsPop3IncomingServer.h \
nsLocalMessage.h \
nsLocalMailFolder.h \
nsLocalUtils.h \
$(NULL)
################################################################################

View File

@ -20,7 +20,6 @@
#include "nsMailboxProtocol.h"
#include "nscore.h"
#include "nsIOutputStream.h"
#include "nsINetService.h"
#include "nsIMsgDatabase.h"
#include "nsIMsgHdr.h"
#include "nsMsgLineBuffer.h"
@ -38,7 +37,6 @@
#define ENABLE_SMOKETEST 1
static NS_DEFINE_CID(kNetServiceCID, NS_NETSERVICE_CID);
static NS_DEFINE_IID(kIWebShell, NS_IWEB_SHELL_IID);
static NS_DEFINE_CID(kCMailDB, NS_MAILDB_CID);
@ -68,14 +66,33 @@ nsMailboxProtocol::~nsMailboxProtocol()
void nsMailboxProtocol::Initialize(nsIURI * aURL)
{
NS_PRECONDITION(aURL, "invalid URL passed into MAILBOX Protocol");
nsresult rv = NS_OK;
if (aURL)
{
nsresult rv = aURL->QueryInterface(nsIMailboxUrl::GetIID(), (void **) getter_AddRefs(m_runningUrl));
if (NS_SUCCEEDED(rv) && m_runningUrl)
{
rv = m_runningUrl->GetMailboxAction(&m_mailboxAction);
nsFileSpec * fileSpec = nsnull;
m_runningUrl->GetFilePath(&fileSpec);
rv = OpenFileSocket(aURL, fileSpec);
if (m_mailboxAction == nsIMailboxUrl::ActionParseMailbox)
rv = OpenFileSocket(aURL, fileSpec, 0, -1 /* read in all the bytes in the file */);
else
{
// we need to specify a byte range to read in so we read in JUST the message we want.
SetupMessageExtraction();
nsMsgKey aMsgKey;
PRUint32 aMsgSize = 0;
rv = m_runningUrl->GetMessageKey(&aMsgKey);
NS_ASSERTION(NS_SUCCEEDED(rv), "oops....i messed something up");
rv = m_runningUrl->GetMessageSize(&aMsgSize);
NS_ASSERTION(NS_SUCCEEDED(rv), "oops....i messed something up");
// mscott -- oops...impedence mismatch between aMsgSize and the desired
// argument type!
rv = OpenFileSocket(aURL, fileSpec, (PRUint32) aMsgKey, aMsgSize);
NS_ASSERTION(NS_SUCCEEDED(rv), "oops....i messed something up");
}
}
}
@ -92,7 +109,7 @@ void nsMailboxProtocol::Initialize(nsIURI * aURL)
// we suppport the nsIStreamListener interface
////////////////////////////////////////////////////////////////////////////////////////////
NS_IMETHODIMP nsMailboxProtocol::OnStartRequest(nsIURI* aURL, const char *aContentType)
NS_IMETHODIMP nsMailboxProtocol::OnStartRequest(nsIChannel * aChannel, nsISupports *ctxt)
{
// extract the appropriate event sinks from the url and initialize them in our protocol data
// the URL should be queried for a nsINewsURL. If it doesn't support a news URL interface then
@ -101,26 +118,25 @@ NS_IMETHODIMP nsMailboxProtocol::OnStartRequest(nsIURI* aURL, const char *aConte
if (m_nextState == MAILBOX_READ_FOLDER && m_mailboxParser)
{
// we need to inform our mailbox parser that it's time to start...
m_mailboxParser->OnStartRequest(aURL, aContentType);
m_mailboxParser->OnStartRequest(aChannel, ctxt);
}
else if(m_mailboxCopyHandler)
m_mailboxCopyHandler->OnStartRequest(aURL, aContentType);
m_mailboxCopyHandler->OnStartRequest(aChannel, ctxt);
return NS_OK;
}
// stop binding is a "notification" informing us that the stream associated with aURL is going away.
NS_IMETHODIMP nsMailboxProtocol::OnStopRequest(nsIURI* aURL, nsresult aStatus, const PRUnichar* aMsg)
NS_IMETHODIMP nsMailboxProtocol::OnStopRequest(nsIChannel * aChannel, nsISupports *ctxt, nsresult aStatus, const PRUnichar *aMsg)
{
if (m_nextState == MAILBOX_READ_FOLDER && m_mailboxParser)
{
// we need to inform our mailbox parser that there is no more incoming data...
m_mailboxParser->OnStopRequest(aURL, 0, nsnull);
m_mailboxParser->OnStopRequest(aChannel, ctxt, 0, nsnull);
}
else if (m_mailboxCopyHandler)
m_mailboxCopyHandler->OnStopRequest(aURL, 0, nsnull);
m_mailboxCopyHandler->OnStopRequest(aChannel, ctxt, 0, nsnull);
else if (m_nextState == MAILBOX_READ_MESSAGE)
{
DoneReadingMessage();
@ -148,7 +164,7 @@ NS_IMETHODIMP nsMailboxProtocol::OnStopRequest(nsIURI* aURL, nsresult aStatus, c
// is coming from netlib so they are never going to ping us again with on data available. This means
// we'll never be going through the Process loop...
nsMsgProtocol::OnStopRequest(aURL, aStatus, aMsg);
nsMsgProtocol::OnStopRequest(aChannel, ctxt, aStatus, aMsg);
return CloseSocket();
}
@ -170,7 +186,7 @@ PRInt32 nsMailboxProtocol::DoneReadingMessage()
nsFileURL fileURL(filePath);
char * message_path_url = PL_strdup(fileURL.GetAsString());
rv = m_displayConsumer->LoadURL(nsAutoString(message_path_url).GetUnicode(), nsnull, PR_TRUE, nsURLReloadBypassCache, 0);
rv = m_displayConsumer->LoadURL(nsAutoString(message_path_url).GetUnicode(), nsnull, PR_TRUE);
PR_FREEIF(message_path_url);
@ -210,7 +226,6 @@ PRInt32 nsMailboxProtocol::SetupMessageExtraction()
nsresult nsMailboxProtocol::LoadUrl(nsIURI * aURL, nsISupports * aConsumer)
{
nsresult rv = NS_OK;
HG77067
if (aURL)
{
m_runningUrl = do_QueryInterface(aURL);
@ -244,14 +259,12 @@ nsresult nsMailboxProtocol::LoadUrl(nsIURI * aURL, nsISupports * aConsumer)
// converting the message from RFC-822 to HTML before displaying it...
ClearFlag(MAILBOX_MSG_PARSE_FIRST_LINE);
m_tempMessageFile->openStreamForWriting();
SetupMessageExtraction();
m_nextState = MAILBOX_READ_MESSAGE;
break;
case nsIMailboxUrl::ActionCopyMessage:
case nsIMailboxUrl::ActionMoveMessage:
rv = m_runningUrl->GetMailboxCopyHandler(getter_AddRefs(m_mailboxCopyHandler));
SetupMessageExtraction();
m_nextState = MAILBOX_READ_MESSAGE;
break;
@ -268,7 +281,7 @@ nsresult nsMailboxProtocol::LoadUrl(nsIURI * aURL, nsISupports * aConsumer)
return rv;
}
PRInt32 nsMailboxProtocol::ReadFolderResponse(nsIInputStream * inputStream, PRUint32 length)
PRInt32 nsMailboxProtocol::ReadFolderResponse(nsIInputStream * inputStream, PRUint32 sourceOffset, PRUint32 length)
{
// okay we are doing a folder read in 8K chunks of a mail folder....
// this is almost too easy....we can just forward the data in this stream on to our
@ -279,7 +292,7 @@ PRInt32 nsMailboxProtocol::ReadFolderResponse(nsIInputStream * inputStream, PRUi
if (m_mailboxParser)
{
nsCOMPtr <nsIURI> url = do_QueryInterface(m_runningUrl);
rv = m_mailboxParser->OnDataAvailable(url, inputStream, length); // let the parser deal with it...
rv = m_mailboxParser->OnDataAvailable(nsnull, url, inputStream, sourceOffset, length); // let the parser deal with it...
}
if (NS_FAILED(rv))
@ -299,7 +312,7 @@ PRInt32 nsMailboxProtocol::ReadFolderResponse(nsIInputStream * inputStream, PRUi
return 0;
}
PRInt32 nsMailboxProtocol::ReadMessageResponse(nsIInputStream * inputStream, PRUint32 length)
PRInt32 nsMailboxProtocol::ReadMessageResponse(nsIInputStream * inputStream, PRUint32 sourceOffset, PRUint32 length)
{
char *line = nsnull;
PRUint32 status = 0;
@ -313,7 +326,7 @@ PRInt32 nsMailboxProtocol::ReadMessageResponse(nsIInputStream * inputStream, PRU
if (m_mailboxCopyHandler)
{
nsCOMPtr <nsIURI> url = do_QueryInterface(m_runningUrl);
rv = m_mailboxCopyHandler->OnDataAvailable(url, inputStream, length);
rv = m_mailboxCopyHandler->OnDataAvailable(nsnull, url, inputStream, sourceOffset, length);
}
}
else
@ -369,7 +382,7 @@ PRInt32 nsMailboxProtocol::ReadMessageResponse(nsIInputStream * inputStream, PRU
*
* returns zero or more if the transfer needs to be continued.
*/
nsresult nsMailboxProtocol::ProcessProtocolState(nsIURI * url, nsIInputStream * inputStream, PRUint32 length)
nsresult nsMailboxProtocol::ProcessProtocolState(nsIURI * url, nsIInputStream * inputStream, PRUint32 offset, PRUint32 length)
{
PRInt32 status = 0;
ClearFlag(MAILBOX_PAUSE_FOR_READ); /* already paused; reset */
@ -383,13 +396,13 @@ nsresult nsMailboxProtocol::ProcessProtocolState(nsIURI * url, nsIInputStream *
if (inputStream == nsnull)
SetFlag(MAILBOX_PAUSE_FOR_READ);
else
status = ReadMessageResponse(inputStream, length);
status = ReadMessageResponse(inputStream, offset, length);
break;
case MAILBOX_READ_FOLDER:
if (inputStream == nsnull)
SetFlag(MAILBOX_PAUSE_FOR_READ); // wait for file socket to read in the next chunk...
else
status = ReadFolderResponse(inputStream, length);
status = ReadFolderResponse(inputStream, offset, length);
break;
case MAILBOX_DONE:
case MAILBOX_ERROR_DONE:

View File

@ -86,11 +86,8 @@ public:
// we suppport the nsIStreamListener interface
////////////////////////////////////////////////////////////////////////////////////////
NS_IMETHOD OnStartRequest(nsIURI* aURL, const char *aContentType);
// stop binding is a "notification" informing us that the stream associated with aURL is going away.
NS_IMETHOD OnStopRequest(nsIURI* aURL, nsresult aStatus, const PRUnichar* aMsg);
NS_IMETHOD OnStartRequest(nsIChannel * aChannel, nsISupports *ctxt);
NS_IMETHOD OnStopRequest(nsIChannel * aChannel, nsISupports *ctxt, nsresult aStatus, const PRUnichar *aMsg);
////////////////////////////////////////////////////////////////////////////////////////
// End of nsIStreamListenerSupport
@ -119,7 +116,8 @@ private:
nsCOMPtr<nsIWebShell> m_displayConsumer; // if we are displaying an article this is the rfc-822 display sink...
virtual nsresult ProcessProtocolState(nsIURI * url, nsIInputStream * inputStream, PRUint32 length);
virtual nsresult ProcessProtocolState(nsIURI * url, nsIInputStream * inputStream,
PRUint32 sourceOffset, PRUint32 length);
virtual nsresult CloseSocket();
// initialization function given a new url and transport layer
@ -134,8 +132,8 @@ private:
// When parsing a mailbox folder in chunks, this protocol state reads in the current chunk
// and forwards it to the mailbox parser.
PRInt32 ReadFolderResponse(nsIInputStream * inputStream, PRUint32 length);
PRInt32 ReadMessageResponse(nsIInputStream * inputStream, PRUint32 length);
PRInt32 ReadFolderResponse(nsIInputStream * inputStream, PRUint32 sourceOffset, PRUint32 length);
PRInt32 ReadMessageResponse(nsIInputStream * inputStream, PRUint32 sourceOffset, PRUint32 length);
PRInt32 DoneReadingMessage();
////////////////////////////////////////////////////////////////////////////////////////

View File

@ -23,7 +23,6 @@
#include <windows.h> // for InterlockedIncrement
#endif
#include "nsINetService.h"
#include "nsMailboxService.h"
#include "nsMailboxUrl.h"
@ -61,15 +60,21 @@ nsresult nsMailboxService::QueryInterface(const nsIID &aIID, void** aInstancePtr
if (aIID.Equals(nsIMailboxService::GetIID()) || aIID.Equals(kISupportsIID))
{
*aInstancePtr = (void*) ((nsIMailboxService*)this);
AddRef();
NS_ADDREF_THIS();
return NS_OK;
}
if (aIID.Equals(nsIMsgMessageService::GetIID()))
{
*aInstancePtr = (void*) ((nsIMsgMessageService*)this);
AddRef();
NS_ADDREF_THIS();
return NS_OK;
}
if (aIID.Equals(nsIProtocolHandler::GetIID()))
{
*aInstancePtr = (void*) ((nsIProtocolHandler*)this);
NS_ADDREF_THIS();
return NS_OK;
}
#if defined(NS_DEBUG)
/*
@ -272,3 +277,46 @@ nsresult nsMailboxService::PrepareMessageUrl(const char * aSrcMsgMailboxURI, nsI
return rv;
}
NS_IMETHODIMP nsMailboxService::GetScheme(char * *aScheme)
{
nsresult rv = NS_OK;
if (aScheme)
*aScheme = PL_strdup("mailbox");
else
rv = NS_ERROR_NULL_POINTER;
return rv;
}
NS_IMETHODIMP nsMailboxService::GetDefaultPort(PRInt32 *aDefaultPort)
{
nsresult rv = NS_OK;
if (aDefaultPort)
*aDefaultPort = -1; // mailbox doesn't use a port!!!!!
else
rv = NS_ERROR_NULL_POINTER;
return rv;
}
NS_IMETHODIMP nsMailboxService::MakeAbsolute(const char *aRelativeSpec, nsIURI *aBaseURI, char **_retval)
{
// no such thing as relative urls for smtp.....
NS_ASSERTION(0, "unimplemented");
return NS_OK;
}
NS_IMETHODIMP nsMailboxService::NewURI(const char *aSpec, nsIURI *aBaseURI, nsIURI **_retval)
{
// i just haven't implemented this yet...I will be though....
NS_ASSERTION(0, "unimplemented");
return NS_OK;
}
NS_IMETHODIMP nsMailboxService::NewChannel(const char *verb, nsIURI *aURI, nsIEventSinkGetter *eventSinkGetter, nsIEventQueue *eventQueue, nsIChannel **_retval)
{
// mscott - right now, I don't like the idea of returning channels to the caller. They just want us
// to run the url, they don't want a channel back...I'm going to be addressing this issue with
// the necko team in more detail later on.
NS_ASSERTION(0, "unimplemented");
return NS_OK;
}

View File

@ -30,16 +30,9 @@
#include "nsIStreamListener.h"
#include "nsFileSpec.h"
#include "nsIFileSpec.h"
#include "nsIProtocolHandler.h"
////////////////////////////////////////////////////////////////////////////////////////
// The Mailbox Service is an interface designed to make building and running mailbox urls
// easier. I'm not sure if this service will go away when the new networking model comes
// on line (as part of the N2 project). So I reserve the right to change my mind and take
// this service away =).
////////////////////////////////////////////////////////////////////////////////////////
class nsMailboxService : public nsIMailboxService, public nsIMsgMessageService
class nsMailboxService : public nsIMailboxService, public nsIMsgMessageService, public nsIProtocolHandler
{
public:
@ -78,6 +71,20 @@ public:
NS_IMETHOD SaveMessageToDisk(const char *aMessageURI, nsIFileSpec *aFile, PRBool aAppendToFile,
nsIUrlListener *aUrlListener, nsIURI **aURL);
////////////////////////////////////////////////////////////////////////////////////////
// we suppport the nsIProtocolHandler Interface
////////////////////////////////////////////////////////////////////////////////////////
NS_IMETHOD GetScheme(char * *aScheme);
NS_IMETHOD GetDefaultPort(PRInt32 *aDefaultPort);
NS_IMETHOD MakeAbsolute(const char *aRelativeSpec, nsIURI *aBaseURI, char **_retval);
NS_IMETHOD NewURI(const char *aSpec, nsIURI *aBaseURI, nsIURI **_retval);
NS_IMETHOD NewChannel(const char *verb, nsIURI *aURI, nsIEventSinkGetter *eventSinkGetter, nsIEventQueue *eventQueue, nsIChannel **_retval);
////////////////////////////////////////////////////////////////////////////////////////
// End support of nsIProtocolHandler interface
////////////////////////////////////////////////////////////////////////////////////////
protected:
// helper functions used by the service
nsresult PrepareMessageUrl(const char * aSrcMsgMailboxURI, nsIUrlListener * aUrlListener,

View File

@ -18,16 +18,10 @@
#include "msgCore.h" // precompiled header...
#ifdef XP_PC
#include <windows.h> // for InterlockedIncrement
#endif
#include "nsIURL.h"
#include "nsIURI.h"
#include "nsIMailboxUrl.h"
#include "nsMailboxUrl.h"
#include "nsINetService.h" /* XXX: NS_FALSE */
#include "nsString.h"
#include "nsEscape.h"
#include "nsCRT.h"
@ -55,7 +49,7 @@ static NS_DEFINE_CID(kCMailDB, NS_MAILDB_CID);
static NS_DEFINE_CID(kMsgMailSessionCID, NS_MSGMAILSESSION_CID);
static char *nsMailboxGetURI(char *nativepath)
static char *nsMailboxGetURI(const char *nativepath)
{
nsresult rv;
@ -105,7 +99,7 @@ static char *nsMailboxGetURI(char *nativepath)
if (NS_FAILED(rv)) continue;
// the relpath is just past the serverpath
char *relpath = nativepath + len;
const char *relpath = nativepath + len;
// skip past leading / if any
while (*relpath == '/') relpath++;
uri = PR_smprintf("%s/%s", (const char*)serverURI, relpath);
@ -225,30 +219,21 @@ nsresult nsMailboxUrl::GetFilePath(nsFileSpec ** aFilePath)
return NS_OK;
}
#if 0
nsresult nsMailboxUrl::SetFilePath(const nsFileSpec& aFilePath)
{
NS_LOCK_INSTANCE();
if (m_filePath)
delete m_filePath;
m_filePath = new nsFileSpec(aFilePath);
NS_UNLOCK_INSTANCE();
return NS_OK;
}
#endif
nsresult nsMailboxUrl::GetMessageKey(nsMsgKey* aMessageKey)
{
*aMessageKey = m_messageKey;
return NS_OK;
}
NS_IMETHODIMP
nsMailboxUrl::GetMessageSize(PRUint32 *aMessageSize)
NS_IMETHODIMP nsMailboxUrl::GetMessageSize(PRUint32 * aMessageSize)
{
*aMessageSize = m_messageSize;
return NS_OK;
if (aMessageSize)
{
*aMessageSize = m_messageSize;
return NS_OK;
}
else
return NS_ERROR_NULL_POINTER;
}
nsresult nsMailboxUrl::SetMessageSize(PRUint32 aMessageSize)
@ -257,7 +242,7 @@ nsresult nsMailboxUrl::SetMessageSize(PRUint32 aMessageSize)
return NS_OK;
}
// from nsIMsgUriUrl
NS_IMETHODIMP nsMailboxUrl::GetURI(char ** aURI)
{
// function not implemented yet....
@ -325,6 +310,7 @@ NS_IMETHODIMP nsMailboxUrl::GetMessageFile(nsIFileSpec ** aFileSpec)
return NS_OK;
}
#if 0 // mscott - i can remove this function once I move the funcionality elsewhere...
NS_IMETHODIMP nsMailboxUrl::SetURLInfo(URL_Struct *URL_s)
{
nsresult rv = nsMsgMailNewsUrl::SetURLInfo(URL_s);
@ -339,22 +325,23 @@ NS_IMETHODIMP nsMailboxUrl::SetURLInfo(URL_Struct *URL_s)
return rv;
}
#endif
////////////////////////////////////////////////////////////////////////////////////
// End nsIMailboxUrl specific support
////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
// possible search part phrases include: MessageID=id&number=MessageKey
nsresult nsMailboxUrl::ParseSearchPart()
{
nsXPIDLCString searchPart;
nsresult rv = GetQuery(getter_Copies(searchPart));
// add code to this function to decompose everything past the '?'.....
if (m_search)
if (NS_SUCCEEDED(rv) && searchPart && *searchPart)
{
char * messageKey = extractAttributeValue(m_search, "number=");
m_messageID = extractAttributeValue(m_search,"messageid=");
char * messageKey = extractAttributeValue(searchPart, "number=");
m_messageID = extractAttributeValue(searchPart,"messageid=");
if (messageKey)
m_messageKey = atol(messageKey); // convert to a long...
if (messageKey || m_messageID)
@ -362,152 +349,29 @@ nsresult nsMailboxUrl::ParseSearchPart()
m_mailboxAction = nsIMailboxUrl::ActionDisplayMessage;
PR_FREEIF(messageKey);
}
else
m_mailboxAction = nsIMailboxUrl::ActionParseMailbox;
return NS_OK;
return rv;
}
// warning: don't assume when parsing the url that the protocol part is "news"...
nsresult nsMailboxUrl::ParseUrl(const nsString& aSpec)
{
// XXX hack!
char* cSpec = aSpec.ToNewCString();
NS_LOCK_INSTANCE();
PR_FREEIF(m_protocol);
PR_FREEIF(m_host);
PR_FREEIF(m_file);
PR_FREEIF(m_ref);
PR_FREEIF(m_search);
// The URL is considered absolute if and only if it begins with a
// protocol spec. A protocol spec is an alphanumeric string of 1 or
// more characters that is terminated with a colon.
PRBool isAbsolute = PR_FALSE;
char* cp=NULL;
char* ap = cSpec;
char ch;
while (0 != (ch = *ap))
{
if (((ch >= 'a') && (ch <= 'z')) ||
((ch >= 'A') && (ch <= 'Z')) ||
((ch >= '0') && (ch <= '9')))
{
ap++;
continue;
}
if ((ch == ':') && (ap - cSpec >= 2))
{
isAbsolute = PR_TRUE;
cp = ap;
break;
}
break;
}
PR_FREEIF(m_spec);
PRInt32 slen = aSpec.Length();
m_spec = (char *) PR_Malloc(slen + 1);
aSpec.ToCString(m_spec, slen+1);
// get protocol first
PRInt32 plen = cp - cSpec;
m_protocol = (char*) PR_Malloc(plen + 1);
PL_strncpy(m_protocol, cSpec, plen);
m_protocol[plen] = 0;
cp++; // eat : in protocol
// skip over one, two or three slashes
if (*cp == '/')
{
cp++;
if (*cp == '/')
{
cp++;
if (*cp == '/')
cp++;
}
}
else
{
delete [] cSpec;
NS_UNLOCK_INSTANCE();
return NS_ERROR_ILLEGAL_VALUE;
}
//#if defined(XP_UNIX) || defined (XP_MAC) || defined(XP_BEOS)
// Always leave the top level slash for absolute file paths under Mac and UNIX.
// The code above sometimes results in stripping all of slashes
// off. This only happens when a previously stripped url is asked to be
// parsed again. Under Win32 this is not a problem since file urls begin
// with a drive letter not a slash. This problem show's itself when
// nested documents such as iframes within iframes are parsed.
if ((PL_strcmp(m_protocol, "mailbox") == 0) ||
(PL_strcmp(m_protocol, "mailboxMessage") ==0)) {
if (*cp != '/') {
cp--;
}
}
//#endif /* XP_UNIX */
// The remainder of the string is the file name and the search path....
// Strip out the ? stuff....
char* search = strpbrk(cSpec, "?");
if (nsnull != search)
{
search++; // advance past the question mark
// The rest is the search..copy it so we can parse it later...
if (search)
m_search = PL_strdup(search);
if (search - cp - 1 > 0)
m_file = PL_strndup(cp, search - cp -1);
else
m_file = nsnull;
}
else // the rest of the rl is the file part....
{
m_file = PL_strdup(cp);
}
#ifdef NS_WIN32
// If the filename starts with a "x|" where is an single
// character then we assume it's a drive name and change the
// vertical bar back to a ":"
if ((PL_strlen(m_file) >= 2) && (m_file[1] == '|'))
m_file[1] = ':';
#endif /* NS_WIN32 */
delete [] cSpec;
if (m_filePath)
delete m_filePath;
DirFile(getter_Copies(m_file));
ParseSearchPart();
m_filePath = new nsFileSpec(nsFilePath(m_file));
// we need to set the mailbox action type that this url represented....
// if we had a search field then we parsed it and it set the mailbox state...
// otherwise there was no search part to the urlSpec so we should manually set the
// parse mailbox action (which is the default)
if (m_search == nsnull)
m_mailboxAction = nsIMailboxUrl::ActionParseMailbox;
NS_UNLOCK_INSTANCE();
return NS_OK;
}
void nsMailboxUrl::ReconstructSpec(void)
NS_IMETHODIMP nsMailboxUrl::SetSpec(char * aSpec)
{
PR_FREEIF(m_spec);
if (m_search)
m_spec = PR_smprintf("%s://%s?%s", m_protocol, m_file, m_search);
else
m_spec = PR_smprintf("%s://%s", m_protocol, m_file);
nsresult rv = nsMsgMailNewsUrl::SetSpec(aSpec);
if (NS_SUCCEEDED(rv))
rv = ParseUrl("");
return rv;
}
// takes a string like ?messageID=fooo&number=MsgKey and returns a new string

View File

@ -24,12 +24,13 @@
#include "nsFileSpec.h"
#include "nsIFileSpec.h"
#include "nsCOMPtr.h"
#include "nsXPIDLString.h"
class nsMailboxUrl : public nsIMailboxUrl, public nsMsgMailNewsUrl, public nsIMsgUriUrl
{
public:
// overrides for nsIURI
NS_IMETHOD SetURLInfo(URL_Struct *URL_s);
// nsIURI over-ride...
NS_IMETHOD SetSpec(char * aSpec);
// from nsIMailboxUrl:
NS_IMETHOD GetMessageHeader(nsIMsgDBHdr ** aMsgHdr);
@ -57,10 +58,10 @@ public:
NS_DECL_ISUPPORTS_INHERITED
// protocol specific code to parse a url...
virtual nsresult ParseUrl(const nsString& aSpec);
protected:
// protocol specific code to parse a url...
virtual nsresult ParseUrl(const nsString& aSpec);
// mailboxurl specific state
nsCOMPtr<nsIStreamListener> m_mailboxParser;
@ -71,11 +72,10 @@ protected:
char *m_messageID;
PRUint32 m_messageSize;
nsMsgKey m_messageKey;
nsXPIDLCString m_file;
// used by save message to disk
nsCOMPtr<nsIFileSpec> m_messageFileSpec;
virtual void ReconstructSpec(void);
nsresult ParseSearchPart();
};

View File

@ -17,6 +17,7 @@
*/
#include "msgCore.h"
#include "nsIURI.h"
#include "nsParseMailbox.h"
#include "nsIMsgHdr.h"
#include "nsIMsgDatabase.h"
@ -32,6 +33,8 @@
#include "nsFileStream.h"
#include "nsMsgFolderFlags.h"
#include "nsIMsgFolder.h"
#include "nsXPIDLString.h"
#include "nsIURL.h"
#ifdef DOING_FILTERS
#include "nsIMsgFilterService.h"
@ -52,28 +55,32 @@ NS_IMPL_ISUPPORTS_INHERITED(nsMsgMailboxParser, nsParseMailMessageState, nsIStre
// Whenever data arrives from the connection, core netlib notifices the protocol by calling
// OnDataAvailable. We then read and process the incoming data from the input stream.
NS_IMETHODIMP nsMsgMailboxParser::OnDataAvailable(nsIURI* aURL, nsIInputStream *aIStream, PRUint32 aLength)
NS_IMETHODIMP nsMsgMailboxParser::OnDataAvailable(nsIChannel * /* aChannel */, nsISupports *ctxt, nsIInputStream *aIStream, PRUint32 sourceOffset,
PRUint32 aLength)
{
// right now, this really just means turn around and process the url
ProcessMailboxInputStream(aURL, aIStream, aLength);
return NS_OK;
nsresult rv = NS_OK;
nsCOMPtr<nsIURI> url = do_QueryInterface(ctxt, &rv);
if (NS_SUCCEEDED(rv))
rv = ProcessMailboxInputStream(url, aIStream, aLength);
return rv;
}
NS_IMETHODIMP nsMsgMailboxParser::OnStartRequest(nsIURI* aURL, const char *aContentType)
NS_IMETHODIMP nsMsgMailboxParser::OnStartRequest(nsIChannel * /* aChannel */, nsISupports *ctxt)
{
// extract the appropriate event sinks from the url and initialize them in our protocol data
// the URL should be queried for a nsIMailboxURL. If it doesn't support a mailbox URL interface then
// we have an error.
nsresult rv = NS_OK;
nsCOMPtr<nsIMailboxUrl> runningUrl = do_QueryInterface(aURL, &rv);
printf("\n+++ nsMsgMailboxParser::OnStartRequest: URL: %p, Content type: %s\n", aURL, aContentType);
nsCOMPtr<nsIMailboxUrl> runningUrl = do_QueryInterface(ctxt, &rv);
nsCOMPtr<nsIURL> url = do_QueryInterface(ctxt);
if (NS_SUCCEEDED(rv) && runningUrl)
{
// okay, now fill in our event sinks...Note that each getter ref counts before
// it returns the interface to us...we'll release when we are done
const char *fileName;
aURL->GetFile(&fileName);
nsXPIDLCString fileName;
url->DirFile(getter_Copies(fileName));
if (fileName)
{
nsFilePath dbPath(fileName);
@ -88,7 +95,7 @@ NS_IMETHODIMP nsMsgMailboxParser::OnStartRequest(nsIURI* aURL, const char *aCont
rv = mailDB->Open(dbFileSpec, PR_TRUE, PR_TRUE, (nsIMsgDatabase **) getter_AddRefs(m_mailDB));
}
NS_ASSERTION(m_mailDB, "failed to open mail db parsing folder");
printf("url file = %s\n", fileName);
printf("url file = %s\n", (const char *)fileName);
}
}
@ -99,7 +106,7 @@ NS_IMETHODIMP nsMsgMailboxParser::OnStartRequest(nsIURI* aURL, const char *aCont
}
// stop binding is a "notification" informing us that the stream associated with aURL is going away.
NS_IMETHODIMP nsMsgMailboxParser::OnStopRequest(nsIURI* aURL, nsresult aStatus, const PRUnichar* aMsg)
NS_IMETHODIMP nsMsgMailboxParser::OnStopRequest(nsIChannel * /* aChannel */, nsISupports *ctxt, nsresult aStatus, const PRUnichar *aMsg)
{
DoneParsingFolder();
// what can we do? we can close the stream?
@ -129,9 +136,9 @@ NS_IMETHODIMP nsMsgMailboxParser::OnStopRequest(nsIURI* aURL, nsresult aStatus,
nsMsgKey key;
msgHdr->GetMessageKey(&key);
msgHdr->GetAuthor(author);
msgHdr->GetSubject(subject);
#ifdef DEBUG
msgHdr->GetAuthor(&author);
msgHdr->GetSubject(&subject);
#ifdef DEBUG_bienvenu
// leak nsString return values...
printf("hdr key = %d, author = %s subject = %s\n", key, author.GetBuffer(), subject.GetBuffer());
#endif

View File

@ -19,11 +19,11 @@
#ifndef nsParseMailbox_H
#define nsParseMailbox_H
#include "nsIURI.h"
#include "nsIMsgParseMailMsgState.h"
#include "nsMsgKeyArray.h"
#include "nsVoidArray.h"
#include "nsIStreamListener.h"
#include "nsITransport.h"
#include "nsMsgLineBuffer.h"
#include "nsIMsgHeaderParser.h"
#include "nsIMsgDatabase.h"
@ -168,25 +168,9 @@ public:
////////////////////////////////////////////////////////////////////////////////////////
// we suppport the nsIStreamListener interface
////////////////////////////////////////////////////////////////////////////////////////
// mscott; I don't think we need to worry about this yet so I'll leave it stubbed out for now
NS_IMETHOD GetBindInfo(nsIURI* aURL, nsStreamBindingInfo* aInfo) { return NS_OK;} ;
// Whenever data arrives from the connection, core netlib notifies the protocol by calling
// OnDataAvailable. We then read and process the incoming data from the input stream.
NS_IMETHOD OnDataAvailable(nsIURI* aURL, nsIInputStream *aIStream, PRUint32 aLength);
NS_IMETHOD OnStartRequest(nsIURI* aURL, const char *aContentType);
// stop binding is a "notification" informing us that the stream associated with aURL is going away.
NS_IMETHOD OnStopRequest(nsIURI* aURL, nsresult aStatus, const PRUnichar* aMsg);
// Ideally, a protocol should only have to support the stream listener methods covered above.
// However, we don't have this nsIStreamListenerLite interface defined yet. Until then, we are using
// nsIStreamListener so we need to add stubs for the heavy weight stuff we don't want to use.
NS_IMETHOD OnProgress(nsIURI* aURL, PRUint32 aProgress, PRUint32 aProgressMax) { return NS_OK;}
NS_IMETHOD OnStatus(nsIURI* aURL, const PRUnichar* aMsg) { return NS_OK;}
NS_IMETHOD OnDataAvailable(nsIChannel * aChannel, nsISupports *ctxt, nsIInputStream *inStr, PRUint32 sourceOffset, PRUint32 count);
NS_IMETHOD OnStartRequest(nsIChannel * aChannel, nsISupports *ctxt);
NS_IMETHOD OnStopRequest(nsIChannel * aChannel, nsISupports *ctxt, nsresult status, const PRUnichar *errorMsg);
void SetDB (nsIMsgDatabase *mailDB) {m_mailDB = dont_QueryInterface(mailDB); }
char *GetMailboxName() {return m_mailboxName;}

View File

@ -26,40 +26,10 @@
#include "plstr.h"
#include "MailNewsTypes.h"
#include "nsString.h"
#include "nsXPIDLString.h"
#include "nsINetService.h"
#include "nsIMsgIncomingServer.h"
#if 0
#include "nsINetSupportDialogService.h"
static NS_DEFINE_CID(kCNetSupportDialog, NS_NETSUPPORTDIALOG_CID);
#endif
static NS_DEFINE_CID(kNetServiceCID, NS_NETSERVICE_CID);
char * NET_SACopy (char **destination, const char *source)
{
if(*destination)
{
PR_Free(*destination);
*destination = 0;
}
if (! source)
{
*destination = NULL;
}
else
{
*destination = (char *) PR_Malloc (PL_strlen(source) + 1);
if (*destination == NULL)
return(NULL);
PL_strcpy (*destination, source);
}
return *destination;
}
/* km
*
*
@ -107,15 +77,6 @@ net_pop3_check_for_hash_messages_marked_delete(PLHashEntry* he,
return HT_ENUMERATE_NEXT; /* XP_Maphash will continue traversing the hash */
}
#if 0
static int
uidl_cmp (const void *obj1, const void *obj2)
{
PR_ASSERT (obj1 && obj2);
return PL_strcmp ((char *) obj1, (char *) obj2);
}
#endif
static void
put_hash(Pop3UidlHost* host, PLHashTable* table, const char* key, char value)
{
@ -387,7 +348,7 @@ void KillPopData(char* data)
// nsPop3Protocol class implementation
nsPop3Protocol::nsPop3Protocol(nsIURI* aURL) : nsMsgLineBuffer(NULL, FALSE), m_username(eOneByte), m_password(eOneByte), m_commandResponse(eOneByte)
nsPop3Protocol::nsPop3Protocol(nsIURI* aURL) : nsMsgLineBuffer(NULL, FALSE), m_username(eOneByte), m_password(eOneByte), m_commandResponse(eOneByte), m_senderInfo (eOneByte)
{
Initialize(aURL);
}
@ -413,12 +374,7 @@ void nsPop3Protocol::Initialize(nsIURI * aURL)
m_nsIPop3URL = do_QueryInterface(aURL);
if (m_nsIPop3URL)
{
const char * hostName = nsnull;
PRUint32 port = POP3_PORT;
aURL->GetHost(&hostName);
aURL->GetHostPort(&port);
rv = OpenNetworkSocket(aURL, port, hostName);
rv = OpenNetworkSocket(aURL);
}
} // if we got a url...
@ -442,7 +398,6 @@ nsPop3Protocol::~nsPop3Protocol()
FreeMsgInfo();
PR_FREEIF(m_pop3ConData->only_uidl);
PR_FREEIF(m_pop3ConData->obuffer)
PR_FREEIF(m_pop3ConData->sender_info);
PR_Free(m_pop3ConData);
if (m_lineStreamBuffer)
@ -466,8 +421,6 @@ void nsPop3Protocol::SetPassword(const char* passwd)
nsresult nsPop3Protocol::LoadUrl(nsIURI* aURL, nsISupports * /* aConsumer */)
{
const char* urlSpec = NULL;
const char* host = NULL;
nsresult rv = 0;
if (aURL)
@ -481,16 +434,20 @@ nsresult nsPop3Protocol::LoadUrl(nsIURI* aURL, nsISupports * /* aConsumer */)
// -*-*-*- To Do:
// Call SetUsername(accntName);
// Call SetPassword(aPassword);
rv = aURL->GetSpec(&urlSpec);
nsCOMPtr<nsIURL> url = do_QueryInterface(aURL, &rv);
if (NS_FAILED(rv)) return rv;
nsXPIDLCString queryPart;
rv = url->GetQuery(getter_Copies(queryPart));
NS_ASSERTION(NS_SUCCEEDED(rv), "unable to get the url spect");
if (PL_strcasestr(urlSpec, "?check"))
if (PL_strcasestr(queryPart, "check"))
m_pop3ConData->only_check_for_new_mail = PR_TRUE;
else
m_pop3ConData->only_check_for_new_mail = PR_FALSE;
if (PL_strcasestr(urlSpec, "?gurl"))
if (PL_strcasestr(queryPart, "gurl"))
m_pop3ConData->get_url = PR_TRUE;
else
m_pop3ConData->get_url = PR_FALSE;
@ -510,15 +467,13 @@ nsresult nsPop3Protocol::LoadUrl(nsIURI* aURL, nsISupports * /* aConsumer */)
}
// UIDL stuff
rv = aURL->GetHost(&host);
NS_ASSERTION(NS_SUCCEEDED(rv), "unable to get the host from the url");
m_nsIPop3URL->GetPop3Sink(getter_AddRefs(m_nsIPop3Sink));
nsCOMPtr<nsIPop3IncomingServer> popServer;
char* mailDirectory = 0;
nsXPIDLCString host;
aURL->GetHost(getter_Copies(host));
rv = m_nsIPop3Sink->GetPopServer(getter_AddRefs(popServer));
nsCOMPtr<nsIMsgIncomingServer> server = do_QueryInterface(popServer);
@ -530,7 +485,7 @@ nsresult nsPop3Protocol::LoadUrl(nsIURI* aURL, nsISupports * /* aConsumer */)
m_pop3ConData->biffstate = nsMsgBiffState_NoMail;
const char* uidl = PL_strcasestr(urlSpec, "?uidl=");
const char* uidl = PL_strcasestr(queryPart, "uidl=");
PR_FREEIF(m_pop3ConData->only_uidl);
if (uidl)
@ -657,7 +612,7 @@ PRInt32 nsPop3Protocol::SendData(nsIURI * aURL, const char * dataBuffer)
{
PRInt32 result = nsMsgProtocol::SendData(aURL, dataBuffer);
if (result) // yeah this sucks...i need an error code....
if (result >= 0) // yeah this sucks...i need an error code....
{
m_pop3ConData->pause_for_read = PR_TRUE;
m_pop3ConData->next_state = POP3_WAIT_FOR_RESPONSE;
@ -1766,7 +1721,7 @@ PRInt32 nsPop3Protocol::SendXsender()
PRInt32 nsPop3Protocol::XsenderResponse()
{
m_pop3ConData->seenFromHeader = PR_FALSE;
PR_FREEIF(m_pop3ConData->sender_info);
m_senderInfo = "";
if (POP3_XSENDER_UNDEFINED & m_pop3CapabilityFlags)
m_pop3CapabilityFlags &= ~POP3_XSENDER_UNDEFINED;
@ -1774,7 +1729,7 @@ PRInt32 nsPop3Protocol::XsenderResponse()
if (m_pop3ConData->command_succeeded) {
if (m_commandResponse.Length() > 4)
{
StrAllocCopy(m_pop3ConData->sender_info, m_commandResponse.GetBuffer());
m_senderInfo = m_commandResponse;
}
if (! (POP3_HAS_XSENDER & m_pop3CapabilityFlags))
m_pop3CapabilityFlags |= POP3_HAS_XSENDER;
@ -1905,7 +1860,7 @@ nsPop3Protocol::RetrResponse(nsIInputStream* inputStream,
}
/* RETR complete message */
if (m_pop3ConData->sender_info)
if (!m_senderInfo.IsEmpty())
flags |= MSG_FLAG_SENDER_AUTHED;
if(m_pop3ConData->cur_msg_size < 0)
@ -2108,9 +2063,9 @@ nsPop3Protocol::HandleLine(char *line, PRUint32 line_length)
if (!m_pop3ConData->msg_closure)
return -1;
if (m_pop3ConData->sender_info && !m_pop3ConData->seenFromHeader)
if (!m_senderInfo.IsEmpty() && !m_pop3ConData->seenFromHeader)
{
if (line_length > 6 && !XP_MEMCMP("From: ", line, 6))
if (line_length > 6 && !PL_strncasecmp("From: ", line, 6))
{
/* Zzzzz PL_strstr only works with NULL terminated string. Since,
* the last character of a line is either a carriage return
@ -2121,7 +2076,7 @@ nsPop3Protocol::HandleLine(char *line, PRUint32 line_length)
char ch = line[line_length-1];
line[line_length-1] = 0;
m_pop3ConData->seenFromHeader = PR_TRUE;
if (PL_strstr(line, m_pop3ConData->sender_info) == NULL)
if (PL_strstr(line, m_senderInfo.GetBuffer()) == NULL)
m_nsIPop3Sink->SetSenderAuthedFlag(m_pop3ConData->msg_closure,
PR_FALSE);
line[line_length-1] = ch;
@ -2270,7 +2225,8 @@ nsPop3Protocol::CommitState(PRBool remove_last_entry)
*
* returns zero or more if the transfer needs to be continued.
*/
nsresult nsPop3Protocol::ProcessProtocolState (nsIURI* aURL, nsIInputStream* aInputStream, PRUint32 aLength)
nsresult nsPop3Protocol::ProcessProtocolState(nsIURI * url, nsIInputStream * aInputStream,
PRUint32 sourceOffset, PRUint32 aLength)
{
PRInt32 status = 0;
nsCOMPtr<nsIMsgMailNewsUrl> mailnewsurl = do_QueryInterface(m_nsIPop3URL);
@ -2647,9 +2603,6 @@ nsresult nsPop3Protocol::ProcessProtocolState (nsIURI* aURL, nsIInputStream* aIn
if(m_pop3ConData->msg_del_started)
m_nsIPop3Sink->EndMailDelivery();
if (m_transport)
m_transport->OnStopRequest(mailnewsurl, 0, nsnull);
if (mailnewsurl)
mailnewsurl->SetUrlState(PR_FALSE, NS_OK);
@ -2712,10 +2665,7 @@ nsresult nsPop3Protocol::ProcessProtocolState (nsIURI* aURL, nsIInputStream* aIn
m_pop3ConData->next_state = POP3_READ_PASSWORD;
else
/* Else we got a "real" error, so finish up. */
m_pop3ConData->next_state = POP3_FREE;
if (m_transport)
m_transport->OnStopRequest(mailnewsurl, 0, nsnull);
m_pop3ConData->next_state = POP3_FREE;
if (mailnewsurl)
mailnewsurl->SetUrlState(PR_FALSE, NS_ERROR_FAILURE);

View File

@ -19,20 +19,17 @@
#ifndef nsPop3Protocol_h__
#define nsPop3Protocol_h__
#include "nsCOMPtr.h"
#include "nsIStreamListener.h"
#include "nsITransport.h"
#include "nsIOutputStream.h"
#include "nsIInputStream.h"
#include "nsIPop3URL.h"
#include "nsIPop3Sink.h"
#include "nsMsgLineBuffer.h"
#include "nsCOMPtr.h"
#include "nsMsgProtocol.h"
#include "MailNewsTypes.h"
#include "rosetta.h"
#include HG09893
#include HG47233
#include "prerror.h"
#include "plhash.h"
@ -113,7 +110,6 @@ extern int MK_CONNECTION_TIMED_OUT;
#define MK_CONNECTION_TIMED_OUT -241
#endif
#define POP3_PORT 110 // The IANA port for Pop3
#define OUTPUT_BUFFER_SIZE 8192 // maximum size of command string
/* structure to hold data pertaining to the active state of
@ -281,7 +277,6 @@ typedef struct _Pop3ConData {
PRBool delete_server_message_during_top_traversal;
PRBool get_url;
PRBool seenFromHeader;
char *sender_info;
} Pop3ConData;
class nsPop3Protocol : public nsMsgProtocol, public nsMsgLineBuffer
@ -304,10 +299,11 @@ private:
nsString m_username;
nsString m_password;
Pop3ConData* m_pop3ConData;
nsString m_senderInfo;
nsString m_commandResponse;
virtual nsresult ProcessProtocolState(nsIURI* aURL, nsIInputStream* aInputStream, PRUint32 aLength);
virtual nsresult ProcessProtocolState(nsIURI * url, nsIInputStream * inputStream,
PRUint32 sourceOffset, PRUint32 length);
virtual nsresult CloseSocket();
virtual PRInt32 SendData(nsIURI * aURL, const char * dataBuffer);
void Initialize(nsIURI * aURL);

View File

@ -18,7 +18,6 @@
#include "msgCore.h" // precompiled header...
#include "nsINetService.h"
#include "nsPop3Service.h"
#include "nsIMsgIncomingServer.h"
#include "nsIPop3IncomingServer.h"
@ -26,8 +25,13 @@
#include "nsPop3URL.h"
#include "nsPop3Sink.h"
#include "nsPop3Protocol.h"
#include "nsCOMPtr.h"
#include "nsMsgLocalCID.h"
#define POP3_PORT 110 // The IANA port for Pop3
static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID);
static NS_DEFINE_CID(kPop3UrlCID, NS_POP3URL_CID);
nsPop3Service::nsPop3Service()
{
@ -37,7 +41,27 @@ nsPop3Service::nsPop3Service()
nsPop3Service::~nsPop3Service()
{}
NS_IMPL_THREADSAFE_ISUPPORTS(nsPop3Service, nsIPop3Service::GetIID());
NS_IMPL_THREADSAFE_ADDREF(nsPop3Service);
NS_IMPL_THREADSAFE_RELEASE(nsPop3Service);
nsresult nsPop3Service::QueryInterface(const nsIID &aIID, void** aInstancePtr)
{
if (NULL == aInstancePtr)
return NS_ERROR_NULL_POINTER;
if (aIID.Equals(nsIPop3Service::GetIID()) || aIID.Equals(kISupportsIID))
{
*aInstancePtr = (void*) ((nsIPop3Service*)this);
NS_ADDREF_THIS();
return NS_OK;
}
if (aIID.Equals(nsIProtocolHandler::GetIID()))
{
*aInstancePtr = (void *) ((nsIProtocolHandler*) this);
NS_ADDREF_THIS();
return NS_OK;
}
return NS_NOINTERFACE;
}
NS_IMETHODIMP nsPop3Service::CheckForNewMail(nsIUrlListener * aUrlListener,
nsIMsgFolder *inbox,
@ -58,7 +82,7 @@ NS_IMETHODIMP nsPop3Service::CheckForNewMail(nsIUrlListener * aUrlListener,
if (NS_SUCCEEDED(rv) && popServer && hostname)
{
// now construct a pop3 url...
char * urlSpec = PR_smprintf("pop3://%s?check", hostname);
char * urlSpec = PR_smprintf("pop3://%s:%d?check", hostname, POP3_PORT);
rv = BuildPop3Url(urlSpec, inbox, popServer, aUrlListener, getter_AddRefs(url));
PR_FREEIF(urlSpec);
if (hostname) PL_strfree(hostname);
@ -98,7 +122,7 @@ nsresult nsPop3Service::GetNewMail(nsIUrlListener * aUrlListener,
if (NS_SUCCEEDED(rv) && popServer)
{
// now construct a pop3 url...
char * urlSpec = PR_smprintf("pop3://%s", popHost);
char * urlSpec = PR_smprintf("pop3://%s:%d", popHost, POP3_PORT);
rv = BuildPop3Url(urlSpec, nsnull, popServer, aUrlListener, getter_AddRefs(url));
PR_FREEIF(urlSpec);
}
@ -118,14 +142,12 @@ nsresult nsPop3Service::GetNewMail(nsIUrlListener * aUrlListener,
return rv;
}
nsresult nsPop3Service::BuildPop3Url(const char * urlSpec,
nsresult nsPop3Service::BuildPop3Url(char * urlSpec,
nsIMsgFolder *inbox,
nsIPop3IncomingServer *server,
nsIUrlListener * aUrlListener,
nsIURI ** aUrl)
{
nsresult rv = NS_OK;
// create a sink to run the url with
nsPop3Sink * pop3Sink = new nsPop3Sink();
if (pop3Sink)
{
@ -134,22 +156,37 @@ nsresult nsPop3Service::BuildPop3Url(const char * urlSpec,
}
// now create a pop3 url and a protocol instance to run the url....
nsPop3URL * pop3Url = new nsPop3URL();
nsCOMPtr<nsIPop3URL> pop3Url;
nsresult rv = nsComponentManager::CreateInstance(kPop3UrlCID,
nsnull,
nsCOMTypeInfo<nsIPop3URL>::GetIID(),
getter_AddRefs(pop3Url));
if (pop3Url)
{
pop3Url->SetPop3Sink(pop3Sink);
pop3Url->SetSpec(urlSpec);
if (aUrlListener)
{
nsCOMPtr<nsIMsgMailNewsUrl> mailnewsurl = do_QueryInterface(pop3Url);
if (mailnewsurl)
mailnewsurl->RegisterListener(aUrlListener);
}
if (aUrl)
{
rv = pop3Url->QueryInterface(nsCOMTypeInfo<nsIURI>::GetIID(), (void **) aUrl);
if (*aUrl)
{
(*aUrl)->SetSpec(urlSpec);
// the following is only a temporary work around hack because necko
// is loosing our port when the url is just scheme://host:port.
// when they fix this bug I can remove the following code where we
// manually set the port.
(*aUrl)->SetPort(POP3_PORT);
}
}
}
// does the caller want to listen to the url?
if (aUrlListener)
pop3Url->RegisterListener(aUrlListener);
if (aUrl)
rv = pop3Url->QueryInterface(nsIURI::GetIID(), (void **) aUrl);
else // hmmm delete is protected...what can we do here? no one has a ref cnt on the object...
NS_IF_RELEASE(pop3Url);
return rv;
}
@ -179,3 +216,47 @@ nsresult nsPop3Service::RunPopUrl(nsIMsgIncomingServer * aServer, nsIURI * aUrlT
return rv;
}
NS_IMETHODIMP nsPop3Service::GetScheme(char * *aScheme)
{
nsresult rv = NS_OK;
if (aScheme)
*aScheme = PL_strdup("pop3");
else
rv = NS_ERROR_NULL_POINTER;
return rv;
}
NS_IMETHODIMP nsPop3Service::GetDefaultPort(PRInt32 *aDefaultPort)
{
nsresult rv = NS_OK;
if (aDefaultPort)
*aDefaultPort = POP3_PORT;
else
rv = NS_ERROR_NULL_POINTER;
return rv;
}
NS_IMETHODIMP nsPop3Service::MakeAbsolute(const char *aRelativeSpec, nsIURI *aBaseURI, char **_retval)
{
// no such thing as relative urls for smtp.....
NS_ASSERTION(0, "unimplemented");
return NS_OK;
}
NS_IMETHODIMP nsPop3Service::NewURI(const char *aSpec, nsIURI *aBaseURI, nsIURI **_retval)
{
// i just haven't implemented this yet...I will be though....
NS_ASSERTION(0, "unimplemented");
return NS_OK;
}
NS_IMETHODIMP nsPop3Service::NewChannel(const char *verb, nsIURI *aURI, nsIEventSinkGetter *eventSinkGetter, nsIEventQueue *eventQueue, nsIChannel **_retval)
{
// mscott - right now, I don't like the idea of returning channels to the caller. They just want us
// to run the url, they don't want a channel back...I'm going to be addressing this issue with
// the necko team in more detail later on.
NS_ASSERTION(0, "unimplemented");
return NS_OK;
}

View File

@ -26,9 +26,10 @@
#include "nsIUrlListener.h"
#include "nsIStreamListener.h"
#include "nsFileSpec.h"
#include "nsIProtocolHandler.h"
class nsPop3Service : public nsIPop3Service
class nsPop3Service : public nsIPop3Service, nsIProtocolHandler
{
public:
@ -53,9 +54,22 @@ public:
// End suppport for the nsIPop3Service Interface
////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////
// we suppport the nsIProtocolHandler interface
////////////////////////////////////////////////////////////////////////////////////////
NS_IMETHOD GetScheme(char * *aScheme);
NS_IMETHOD GetDefaultPort(PRInt32 *aDefaultPort);
NS_IMETHOD MakeAbsolute(const char *aRelativeSpec, nsIURI *aBaseURI, char **_retval);
NS_IMETHOD NewURI(const char *aSpec, nsIURI *aBaseURI, nsIURI **_retval);
NS_IMETHOD NewChannel(const char *verb, nsIURI *aURI, nsIEventSinkGetter *eventSinkGetter, nsIEventQueue *eventQueue, nsIChannel **_retval);
////////////////////////////////////////////////////////////////////////////////////////
// End support of nsIProtocolHandler interface
////////////////////////////////////////////////////////////////////////////////////////
protected:
// convience function to make constructing of the pop3 url easier...
nsresult BuildPop3Url(const char * urlSpec, nsIMsgFolder *inbox,
nsresult BuildPop3Url(char * urlSpec, nsIMsgFolder *inbox,
nsIPop3IncomingServer *, nsIUrlListener * aUrlListener,
nsIURI ** aUrl);

View File

@ -168,7 +168,7 @@ nsPop3Sink::EndMailDelivery()
{
if (m_outFileStream)
m_outFileStream->flush(); // try this.
m_newMailParser->OnStopRequest(nsnull, NS_OK, nsnull);
m_newMailParser->OnStopRequest(nsnull, nsnull, NS_OK, nsnull);
delete m_newMailParser;
m_newMailParser = NULL;
}

View File

@ -18,15 +18,9 @@
#include "msgCore.h" // precompiled header...
#ifdef XP_PC
#include <windows.h> // for InterlockedIncrement
#endif
#include "nsIURL.h"
#include "nsPop3URL.h"
#include "nsPop3Protocol.h"
#include "nsINetService.h" /* XXX: NS_FALSE */
#include "nsString.h"
#include "prmem.h"
#include "plstr.h"
@ -49,7 +43,7 @@ nsresult NS_NewPopUrl(const nsIID &aIID, void ** aInstancePtrResult)
return NS_ERROR_NULL_POINTER; /* aInstancePtrResult was NULL....*/
}
nsPop3URL::nsPop3URL()
nsPop3URL::nsPop3URL(): nsMsgMailNewsUrl()
{
}
@ -86,228 +80,11 @@ nsresult nsPop3URL::GetPop3Sink(nsIPop3Sink** aPop3Sink)
}
////////////////////////////////////////////////////////////////////////////////
// XXX recode to use nsString api's
// XXX don't bother with port numbers
// XXX don't bother with ref's
// XXX null pointer checks are incomplete
nsresult nsPop3URL::ParseUrl(const nsString& aSpec)
{
// XXX hack!
char* cSpec = aSpec.ToNewCString();
NS_LOCK_INSTANCE();
PR_FREEIF(m_protocol);
PR_FREEIF(m_host);
PR_FREEIF(m_file);
PR_FREEIF(m_ref);
PR_FREEIF(m_search);
m_port = POP3_PORT;
// Strip out reference and search info
char* ref = strpbrk(cSpec, "#?");
if (nsnull != ref) {
char* search = nsnull;
if ('#' == *ref) {
search = PL_strchr(ref + 1, '?');
if (nsnull != search) {
*search++ = '\0';
}
PRIntn hashLen = PL_strlen(ref + 1);
if (0 != hashLen) {
m_ref = (char*) PR_Malloc(hashLen + 1);
PL_strcpy(m_ref, ref + 1);
}
}
else {
search = ref + 1;
}
if (nsnull != search) {
// The rest is the search
PRIntn searchLen = PL_strlen(search);
if (0 != searchLen) {
m_search = (char*) PR_Malloc(searchLen + 1);
PL_strcpy(m_search, search);
}
}
// XXX Terminate string at start of reference or search
*ref = '\0';
}
// The URL is considered absolute if and only if it begins with a
// protocol spec. A protocol spec is an alphanumeric string of 1 or
// more characters that is terminated with a colon.
PRBool isAbsolute = PR_FALSE;
char* cp = nsnull;
char* ap = cSpec;
char ch;
while (0 != (ch = *ap)) {
if (((ch >= 'a') && (ch <= 'z')) ||
((ch >= 'A') && (ch <= 'Z')) ||
((ch >= '0') && (ch <= '9'))) {
ap++;
continue;
}
if ((ch == ':') && (ap - cSpec >= 2)) {
isAbsolute = PR_TRUE;
cp = ap;
break;
}
break;
}
// absolute spec
PR_FREEIF(m_spec);
PRInt32 slen = aSpec.Length();
m_spec = (char *) PR_Malloc(slen + 1);
aSpec.ToCString(m_spec, slen+1);
// get protocol first
PRInt32 plen = cp - cSpec;
m_protocol = (char*) PR_Malloc(plen + 1);
PL_strncpy(m_protocol, cSpec, plen);
m_protocol[plen] = 0;
cp++; // eat : in protocol
// skip over one, two or three slashes
if (*cp == '/') {
cp++;
if (*cp == '/') {
cp++;
if (*cp == '/') {
cp++;
}
}
}
else
{
delete [] cSpec;
NS_UNLOCK_INSTANCE();
return NS_ERROR_ILLEGAL_VALUE;
}
#if defined(XP_UNIX) || defined (XP_MAC) || defined(XP_BEOS)
// Always leave the top level slash for absolute file paths under Mac and UNIX.
// The code above sometimes results in stripping all of slashes
// off. This only happens when a previously stripped url is asked to be
// parsed again. Under Win32 this is not a problem since file urls begin
// with a drive letter not a slash. This problem show's itself when
// nested documents such as iframes within iframes are parsed.
if (PL_strcmp(m_protocol, "file") == 0) {
if (*cp != '/') {
cp--;
}
}
#endif /* XP_UNIX */
const char* cp0 = cp;
if ((PL_strcmp(m_protocol, "resource") == 0) ||
(PL_strcmp(m_protocol, "file") == 0)) {
// resource/file url's do not have host names.
// The remainder of the string is the file name
PRInt32 flen = PL_strlen(cp);
m_file = (char*) PR_Malloc(flen + 1);
PL_strcpy(m_file, cp);
#ifdef NS_WIN32
if (PL_strcmp(m_protocol, "file") == 0) {
// If the filename starts with a "x|" where is an single
// character then we assume it's a drive name and change the
// vertical bar back to a ":"
if ((flen >= 2) && (m_file[1] == '|')) {
m_file[1] = ':';
}
}
#endif /* NS_WIN32 */
} else {
// Host name follows protocol for http style urls
cp = PL_strpbrk(cp, "/:");
if (nsnull == cp) {
// There is only a host name
PRInt32 hlen = PL_strlen(cp0);
m_host = (char*) PR_Malloc(hlen + 1);
PL_strcpy(m_host, cp0);
}
else {
PRInt32 hlen = cp - cp0;
m_host = (char*) PR_Malloc(hlen + 1);
PL_strncpy(m_host, cp0, hlen);
m_host[hlen] = 0;
if (':' == *cp) {
// We have a port number
cp0 = cp+1;
cp = PL_strchr(cp, '/');
m_port = strtol(cp0, (char **)nsnull, 10);
}
}
if (nsnull == cp) {
// There is no file name
// Set filename to "/"
m_file = (char*) PR_Malloc(2);
m_file[0] = '/';
m_file[1] = 0;
}
else {
// The rest is the file name
PRInt32 flen = PL_strlen(cp);
m_file = (char*) PR_Malloc(flen + 1);
PL_strcpy(m_file, cp);
}
}
//printf("protocol='%s' host='%s' file='%s'\n", m_protocol, m_host, m_file);
delete [] cSpec;
NS_UNLOCK_INSTANCE();
// mscott - i don't believe I'm going to need this
// method anymore..
NS_ASSERTION(0, "we shouldn't need to call this method anymore");
return NS_OK;
}
void nsPop3URL::ReconstructSpec(void)
{
PR_FREEIF(m_spec);
char portBuffer[10];
if (-1 != m_port) {
PR_snprintf(portBuffer, 10, ":%d", m_port);
}
else {
portBuffer[0] = '\0';
}
PRInt32 plen = PL_strlen(m_protocol) + PL_strlen(m_host) +
PL_strlen(portBuffer) + PL_strlen(m_file) + 4;
if (m_ref) {
plen += 1 + PL_strlen(m_ref);
}
if (m_search) {
plen += 1 + PL_strlen(m_search);
}
m_spec = (char *) PR_Malloc(plen + 1);
PR_snprintf(m_spec, plen, "%s://%s%s%s",
m_protocol, ((nsnull != m_host) ? m_host : ""), portBuffer,
m_file);
if (m_ref) {
PL_strcat(m_spec, "#");
PL_strcat(m_spec, m_ref);
}
if (m_search) {
PL_strcat(m_spec, "?");
PL_strcat(m_spec, m_search);
}
}

View File

@ -35,12 +35,10 @@ public:
NS_DECL_ISUPPORTS_INHERITED
// protocol specific code to parse a url...
virtual nsresult ParseUrl(const nsString& aSpec);
protected:
virtual ~nsPop3URL();
virtual void ReconstructSpec(void);
// protocol specific code to parse a url...
virtual nsresult ParseUrl(const nsString& aSpec);
/* Pop3 specific event sinks */
nsCOMPtr<nsIPop3Sink> m_pop3Sink;

View File

@ -45,7 +45,7 @@
#include "msgCore.h"
#include "prprf.h"
#include "nspr.h"
#include <stdio.h>
#include <assert.h>
@ -53,6 +53,7 @@
#include <windows.h>
#endif
#include "nsIFileSpec.h"
#include "nsFileSpec.h"
#include "nsIPref.h"
#include "plstr.h"
@ -61,37 +62,33 @@
#include "nsIMailboxService.h"
#include "nsIStreamListener.h"
#include "nsIInputStream.h"
#include "nsITransport.h"
#include "nsIURL.h"
#include "nsINetService.h"
#include "nsIComponentManager.h"
#include "nsString.h"
#include "nsMsgDBCID.h"
#include "nsIMailboxUrl.h"
#include "nsMailboxUrl.h"
#include "nsMailboxProtocol.h"
#include "nsParseMailbox.h"
#include "nsMailDatabase.h"
#include "nsIMsgDatabase.h"
#include "nsIUrlListener.h"
#include "nsIUrlListenerManager.h"
#include "nsINetService.h"
#include "nsIServiceManager.h"
#include "nsIEventQueueService.h"
#include "nsRDFCID.h"
#include "nsMsgBaseCID.h"
#include "nsMsgLocalCID.h"
#include "nsIFileLocator.h"
#include "nsMsgUtils.h"
#include "nsLocalUtils.h"
#ifdef XP_PC
#define NETLIB_DLL "netlib.dll"
#define XPCOM_DLL "xpcom32.dll"
#define RDF_DLL "rdf.dll"
#define PREF_DLL "xppref32.dll"
#define APPSHELL_DLL "nsappshell.dll"
#else
#ifdef XP_MAC
#include "nsMacRepository.h"
#else
#define NETLIB_DLL "libnetlib"MOZ_DLL_SUFFIX
#define XPCOM_DLL "libxpcom"MOZ_DLL_SUFFIX
#define LOCAL_DLL "libmsglocal"MOZ_DLL_SUFFIX
#define RDF_DLL "librdf"MOZ_DLL_SUFFIX
@ -102,23 +99,16 @@
/////////////////////////////////////////////////////////////////////////////////
// Define keys for all of the interfaces we are going to require for this test
/////////////////////////////////////////////////////////////////////////////////
static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID);
static NS_DEFINE_CID(kCUrlListenerManagerCID, NS_URLLISTENERMANAGER_CID);
static NS_DEFINE_IID(kNetServiceCID, NS_NETSERVICE_CID);
static NS_DEFINE_IID(kEventQueueServiceCID, NS_EVENTQUEUESERVICE_CID);
static NS_DEFINE_IID(kIInputStreamIID, NS_IINPUTSTREAM_IID);
static NS_DEFINE_IID(kIURLIID, NS_IURL_IID);
static NS_DEFINE_CID(kEventQueueServiceCID, NS_EVENTQUEUESERVICE_CID);
static NS_DEFINE_CID(kCMailboxServiceCID, NS_MAILBOXSERVICE_CID);
static NS_DEFINE_IID(kIEventQueueServiceIID, NS_IEVENTQUEUESERVICE_IID);
static NS_DEFINE_CID(kRDFServiceCID, NS_RDFSERVICE_CID);
static NS_DEFINE_CID(kCMailboxParser, NS_MAILBOXPARSER_CID);
static NS_DEFINE_IID(kIPrefIID, NS_IPREF_IID);
static NS_DEFINE_CID(kPrefCID, NS_PREF_CID);
static NS_DEFINE_IID(kFileLocatorCID, NS_FILELOCATOR_CID);
static NS_DEFINE_CID(kCMailDB, NS_MAILDB_CID);
/////////////////////////////////////////////////////////////////////////////////
// Define default values to be used to drive the test
@ -164,7 +154,7 @@ static void strip_nonprintable(char *string) {
// would be asked to process it....right now it is just Mailbox specific....
///////////////////////////////////////////////////////////////////////////////////
class nsMailboxTestDriver : public nsIUrlListener, nsIStreamListener
class nsMailboxTestDriver : public nsIStreamListener, nsIUrlListener
{
public:
NS_DECL_ISUPPORTS
@ -198,13 +188,9 @@ public:
////////////////////////////////////////////////////////////////////////////////////////
// we suppport the nsIStreamListener interface --> primarily to test copy, move and delete
////////////////////////////////////////////////////////////////////////////////////////
NS_IMETHOD OnProgress(nsIURI* aURL, PRUint32 aProgress, PRUint32 aProgressMax) { return NS_OK;}
NS_IMETHOD OnStatus(nsIURI* aURL, const PRUnichar* aMsg) { return NS_OK;}
NS_IMETHOD GetBindInfo(nsIURI* aURL, nsStreamBindingInfo* aInfo) { return NS_OK;}
NS_IMETHOD OnDataAvailable(nsIURI* aURL, nsIInputStream *aIStream, PRUint32 aLength);
NS_IMETHOD OnStartRequest(nsIURI* aURL, const char *aContentType);
NS_IMETHOD OnStopRequest(nsIURI* aURL, nsresult aStatus, const PRUnichar* aMsg);
NS_IMETHOD OnDataAvailable(nsIChannel * aChannel, nsISupports *ctxt, nsIInputStream *inStr, PRUint32 sourceOffset, PRUint32 count);
NS_IMETHOD OnStartRequest(nsIChannel * aChannel, nsISupports *ctxt);
NS_IMETHOD OnStopRequest(nsIChannel * aChannel, nsISupports *ctxt, nsresult status, const PRUnichar *errorMsg);
////////////////////////////////////////////////////////////////////////////////////////
// End of nsIStreamListenerSupport
@ -226,7 +212,7 @@ protected:
void InitializeProtocol(const char * urlSpec);
nsresult SetupUrl(char *group);
nsMailDatabase * OpenDB(nsFileSpec filePath);
nsIMsgDatabase * OpenDB(nsFileSpec filePath);
};
nsresult nsMailboxTestDriver::OnStartRunningUrl(nsIURI * aUrl)
@ -264,16 +250,16 @@ NS_IMETHODIMP nsMailboxTestDriver::QueryInterface(const nsIID &aIID, void** aIns
if (NULL == aInstancePtr)
return NS_ERROR_NULL_POINTER;
if (aIID.Equals(nsIStreamListener::GetIID()) || aIID.Equals(kISupportsIID))
if (aIID.Equals(nsCOMTypeInfo<nsIStreamListener>::GetIID()) || aIID.Equals(nsCOMTypeInfo<nsISupports>::GetIID()))
{
*aInstancePtr = (void*) ((nsIStreamListener*)this);
AddRef();
NS_ADDREF_THIS();
return NS_OK;
}
if (aIID.Equals(nsIUrlListener::GetIID()))
if (aIID.Equals(nsCOMTypeInfo<nsIUrlListener>::GetIID()))
{
*aInstancePtr = (void*) ((nsIUrlListener*)this);
AddRef();
NS_ADDREF_THIS();
return NS_OK;
}
@ -289,7 +275,7 @@ nsMailboxTestDriver::nsMailboxTestDriver(nsIEventQueue *queue, nsIStreamListener
m_runningURL = PR_FALSE;
m_runTestHarness = PR_TRUE;
m_eventQueue = queue;
NS_IF_ADDREF(queue);
NS_IF_ADDREF(queue);
InitializeTestDriver(); // prompts user for initialization information...
@ -344,23 +330,7 @@ void nsMailboxTestDriver::InitializeTestDriver()
{
PL_strcpy(m_urlSpec, DEFAULT_URL_TYPE); // copy "mailbox://" part into url spec...
// read in the default mail folder path...
// propogating bienvenu's preferences hack.....
#define ROOT_PATH_LENGTH 128
char* rootPath;
nsresult rv;
NS_WITH_SERVICE(nsIPref, prefs, kPrefCID, &rv);
if (prefs && NS_SUCCEEDED(rv))
{
rv = prefs->CopyCharPref(kMsgRootFolderPref, &rootPath);
nsServiceManager::ReleaseService(kPrefCID, prefs);
}
if (NS_SUCCEEDED(rv))
{
m_folderSpec = rootPath;
}
PR_FREEIF(rootPath);
m_folderSpec = "c:\\Program Files\\Netscape\\Users\\mscott\\mail";
}
// prints the userPrompt and then reads in the user data. Assumes urlData has already been allocated.
@ -446,12 +416,19 @@ nsresult nsMailboxTestDriver::OnExit()
return NS_OK;
}
nsMailDatabase * nsMailboxTestDriver::OpenDB(nsFileSpec filePath)
nsIMsgDatabase * nsMailboxTestDriver::OpenDB(nsFileSpec filePath)
{
nsMailDatabase * mailDb = nsnull;
nsresult rv = NS_OK;
rv = nsMailDatabase::Open(filePath, PR_FALSE, &mailDb);
return mailDb;
nsIMsgDatabase * db;
nsCOMPtr<nsIMsgDatabase> mailDB;
nsresult rv = nsComponentManager::CreateInstance(kCMailDB, nsnull, nsCOMTypeInfo<nsIMsgDatabase>::GetIID(), (void **) getter_AddRefs(mailDB));
if (NS_SUCCEEDED(rv) && mailDB)
{
nsCOMPtr <nsIFileSpec> dbFileSpec;
NS_NewFileSpecWithSpec(filePath, getter_AddRefs(dbFileSpec));
rv = mailDB->Open(dbFileSpec, PR_TRUE, PR_FALSE, &db);
}
return db;
}
nsresult nsMailboxTestDriver::OnCopyMessage()
@ -483,13 +460,14 @@ nsresult nsMailboxTestDriver::OnDisplayMessage(PRBool copyMessage)
PR_FREEIF(displayString);
// concatenate folder name onto folder path....
char * fullFolderPath = PR_smprintf("%s%c%s", folderPath ? folderPath : "",PR_DIRECTORY_SEPARATOR, m_userData);
char * fullFolderPath = PR_smprintf("%s%c%s", folderPath ? folderPath : "", '\\', m_userData);
char * mailboxName = PL_strdup(m_userData);
PR_FREEIF(folderPath);
// now turn this into a nsFilePath...
nsFileSpec filePath(fullFolderPath);
PR_FREEIF(fullFolderPath);
nsMailDatabase * mailDb = OpenDB(filePath);
nsIMsgDatabase * mailDb = OpenDB(filePath);
if (mailDb)
{
// extract the message key array
@ -508,19 +486,22 @@ nsresult nsMailboxTestDriver::OnDisplayMessage(PRBool copyMessage)
// okay, we have the msgKey so let's get rid of our db state...
mailDb->Close(PR_TRUE);
// now ask the mailbox service to parse this mailbox...
NS_WITH_SERVICE(nsIMailboxService, mailboxService, kCMailboxServiceCID, &rv);
if (NS_SUCCEEDED(rv) && mailboxService)
// mscott - hacky....sprintf up a mailbox URI to represent the message.
char * uri = nsnull;
char * testString = PR_smprintf("%s%s", "mscott@dredd.mcom.com/", mailboxName);
rv = nsBuildLocalMessageURI(/* (const char *) filePath */ testString, msgKey, &uri);
if (NS_SUCCEEDED(rv))
{
nsIURI * url = nsnull;
if (copyMessage)
mailboxService->CopyMessage("", this, PR_FALSE, this, nsnull);
else // display the message
mailboxService->DisplayMessage(filePath, msgKey, nsnull, nsnull, this, nsnull);
if (url)
url->QueryInterface(nsIMailboxUrl::GetIID(), (void **) &m_url);
NS_IF_RELEASE(url);
nsIMsgMessageService * messageService = nsnull;
rv = GetMessageServiceFromURI(uri, &messageService);
if (NS_SUCCEEDED(rv) && messageService)
{
nsISupports * asupport = nsnull;
QueryInterface(nsCOMTypeInfo<nsISupports>::GetIID(), (void **) asupport);
messageService->DisplayMessage(uri, asupport, nsnull, nsnull);
ReleaseMessageServiceFromURI(uri, messageService);
}
}
}
else
@ -554,7 +535,7 @@ nsresult nsMailboxTestDriver::OpenMailbox()
PR_FREEIF(displayString);
// concatenate folder name onto folder path....
char * fullFolderPath = PR_smprintf("%s%c%s", folderPath ? folderPath : "",PR_DIRECTORY_SEPARATOR, m_userData);
char * fullFolderPath = PR_smprintf("%s%c%s", folderPath ? folderPath : "",'\\', m_userData);
PR_FREEIF(folderPath);
// now turn this into a nsFileSpec...
nsFileSpec filePath(fullFolderPath);
@ -580,15 +561,15 @@ nsresult nsMailboxTestDriver::OpenMailbox()
// End on command handlers for mailbox
/////////////////////////////////////////////////////////////////////////////////
NS_IMETHODIMP nsMailboxTestDriver::OnDataAvailable(nsIURI* aURL, nsIInputStream *aStream, PRUint32 aLength)
NS_IMETHODIMP nsMailboxTestDriver::OnDataAvailable(nsIChannel * /* aChannel */, nsISupports *ctxt, nsIInputStream *inStr, PRUint32 sourceOffset, PRUint32 aLength)
{
// read the data out and print it to the screen....
if (aLength > 0)
{
char * buffer = (char *) PR_Malloc(sizeof(char) * aLength + 1);
if (buffer && aStream)
if (buffer && inStr)
{
aStream->Read(buffer, aLength, nsnull);
inStr->Read(buffer, aLength, nsnull);
printf(buffer);
}
@ -597,62 +578,58 @@ NS_IMETHODIMP nsMailboxTestDriver::OnDataAvailable(nsIURI* aURL, nsIInputStream
return NS_OK;
}
NS_IMETHODIMP nsMailboxTestDriver::OnStartRequest(nsIURI* aURL, const char *aContentType)
NS_IMETHODIMP nsMailboxTestDriver::OnStartRequest(nsIChannel * aChannel, nsISupports *ctxt)
{
nsIMailboxUrl * mailboxUrl = nsnull;
if (aURL)
aURL->QueryInterface(nsIMailboxUrl::GetIID(), (void **) &mailboxUrl);
nsCOMPtr<nsIMailboxUrl> mailboxUrl = do_QueryInterface(ctxt);
if (mailboxUrl)
{
nsMsgKey msgKey;
mailboxUrl->GetMessageKey(msgKey);
mailboxUrl->GetMessageKey(&msgKey);
printf ("Begin Copying Message with message key %d.\n", msgKey);
}
NS_IF_RELEASE(mailboxUrl);
return NS_OK;
}
NS_IMETHODIMP nsMailboxTestDriver::OnStopRequest(nsIURI* aURL, nsresult aStatus, const PRUnichar* aMsg)
NS_IMETHODIMP nsMailboxTestDriver::OnStopRequest(nsIChannel * /* aChannel */, nsISupports *ctxt, nsresult aStatus, const PRUnichar* aMsg)
{
nsIMailboxUrl * mailboxUrl = nsnull;
if (aURL)
aURL->QueryInterface(nsIMailboxUrl::GetIID(), (void **) &mailboxUrl);
nsCOMPtr<nsIMailboxUrl> mailboxUrl = do_QueryInterface(ctxt);
if (mailboxUrl)
{
nsMsgKey msgKey;
mailboxUrl->GetMessageKey(msgKey);
mailboxUrl->GetMessageKey(&msgKey);
printf ("\nEnd Copying Message with message key %d.\n", msgKey);
}
NS_IF_RELEASE(mailboxUrl);
return NS_OK;
}
int main()
{
nsINetService * pNetService;
nsCOMPtr<nsIEventQueue> queue;
nsresult result;
nsComponentManager::RegisterComponent(kNetServiceCID, NULL, NULL, NETLIB_DLL, PR_FALSE, PR_FALSE);
nsComponentManager::RegisterComponent(kEventQueueServiceCID, NULL, NULL, XPCOM_DLL, PR_FALSE, PR_FALSE);
nsComponentManager::RegisterComponent(kPrefCID, nsnull, nsnull, PREF_DLL, PR_TRUE, PR_TRUE);
nsComponentManager::RegisterComponent(kCMailboxServiceCID, nsnull, nsnull, LOCAL_DLL, PR_TRUE, PR_TRUE);
result = nsComponentManager::RegisterComponent(kPrefCID, nsnull, nsnull, PREF_DLL, PR_TRUE, PR_TRUE);
nsComponentManager::RegisterComponent(kFileLocatorCID, NULL, NS_FILELOCATOR_PROGID, APPSHELL_DLL, PR_FALSE, PR_FALSE);
// make sure prefs get initialized and loaded..
// mscott - this is just a bad bad bad hack right now until prefs
// has the ability to take nsnull as a parameter. Once that happens,
// prefs will do the work of figuring out which prefs file to load...
NS_WITH_SERVICE(nsIPref, prefs, kPrefCID, &result);
if (NS_FAILED(result) || !prefs) {
result = nsComponentManager::AutoRegister(nsIComponentManager::NS_Startup, NULL /* default */);
// make sure prefs get initialized and loaded..
// mscott - this is just a bad bad bad hack right now until prefs
// has the ability to take nsnull as a parameter. Once that happens,
// prefs will do the work of figuring out which prefs file to load...
NS_WITH_SERVICE(nsIPref, prefs, kPrefCID, &result);
if (NS_FAILED(result) || (prefs == nsnull)) {
exit(result);
}
}
prefs->StartUp();
if (NS_FAILED(prefs->ReadUserPrefs()))
{
printf("Failed on reading user prefs!\n");
exit(-1);
}
// Create the Event Queue for this thread...
nsIEventQueueService* pEventQService;
@ -664,14 +641,6 @@ int main()
result = pEventQService->CreateThreadEventQueue();
if (NS_FAILED(result)) return result;
// ask the net lib service for a nsINetStream:
result = NS_NewINetService(&pNetService, NULL);
if (NS_FAILED(result) || !pNetService)
{
printf("unable to initialize net serivce. \n");
return 1;
}
pEventQService->GetThreadEventQueue(PR_GetCurrentThread(),getter_AddRefs(queue));
if (NS_FAILED(result) || !queue) {
printf("unable to get event queue.\n");
@ -681,8 +650,8 @@ int main()
// bienvenu -- this is where you replace my creation of a stub mailbox parser with one of your own
// that gets passed into the mailbox test driver and it binds your parser to the mailbox url you run
// through the driver.
nsIStreamListener * mailboxParser = nsnull;
nsComponentManager::CreateInstance(kCMailboxParser, nsnull, nsIStreamListener::GetIID(), (void **) &mailboxParser);
nsCOMPtr<nsIStreamListener> mailboxParser = nsnull;
nsComponentManager::CreateInstance(kCMailboxParser, nsnull, nsIStreamListener::GetIID(), getter_AddRefs(mailboxParser));
// okay, everything is set up, now we just need to create a test driver and run it...
nsMailboxTestDriver * driver = new nsMailboxTestDriver(queue, mailboxParser);
@ -694,9 +663,5 @@ int main()
NS_RELEASE(driver);
}
// shut down:
NS_IF_RELEASE(mailboxParser);
NS_IF_RELEASE(pNetService);
return 0;
}

View File

@ -24,28 +24,16 @@ PROGRAM = .\$(OBJDIR)\mailboxTest.exe
OBJS = \
.\$(OBJDIR)\mailboxTest.obj \
# .\$(OBJDIR)\nsMsgMailboxParserStub.obj \
$(NULL)
LINCS= -I$(PUBLIC)\raptor \
-I$(PUBLIC)\xpcom \
-I$(PUBLIC)\netlib \
-I$(PUBLIC)\mailnews \
-I$(PUBLIC)\security \
-I$(PUBLIC)\pref \
-I$(PUBLIC)\rdfutil \
-I$(PUBLIC)\rdf \
-I$(PUBLIC)\js \
LLIBS= \
$(DIST)\lib\xpcom.lib \
$(DIST)\lib\xpcom.lib \
$(LIBNSPR) \
$(DIST)\lib\raptorgfxwin.lib \
$(DIST)\lib\raptorwidget.lib \
$(DIST)\lib\netlib.lib \
$(DIST)\lib\rdfutil_s.lib \
$(DIST)\lib\xplib.lib \
$(DIST)\lib\mork.lib \
$(DIST)\lib\msgdb.lib \
$(DIST)\lib\msgbaseutil.lib \
$(DIST)\lib\msglocal_s.lib \
$(NULL)
LLFLAGS= -SUBSYSTEM:CONSOLE

View File

@ -18,6 +18,6 @@
DEPTH=..\..\..
#commented out because it won't build
DIRS=pop3
DIRS=pop3 mailbox
include <$(DEPTH)\config\rules.mak>

View File

@ -26,25 +26,14 @@ OBJS = \
.\$(OBJDIR)\mboxParserTest.obj \
$(NULL)
LINCS= \
-I$(PUBLIC)\raptor \
-I$(PUBLIC)\xpcom \
-I$(PUBLIC)\netlib \
-I$(PUBLIC)\mailnews \
-I$(PUBLIC)\security \
-I$(PUBLIC)\pref \
-I$(PUBLIC)\rdf
LLIBS= \
$(DIST)\lib\xpcom.lib \
$(LIBNSPR) \
$(DIST)\lib\raptorgfxwin.lib \
$(DIST)\lib\raptorwidget.lib \
$(DIST)\lib\netlib.lib \
$(DIST)\lib\msglocal.lib \
$(DIST)\lib\msgcore.lib \
$(DIST)\lib\rdf.lib \
$(DIST)\lib\xplib.lib \
$(NULL)
LLFLAGS= -SUBSYSTEM:CONSOLE

View File

@ -25,37 +25,26 @@ include $(DEPTH)/config/autoconf.mk
PROGRAM = pop3Test
CPPSRCS = pop3Test.cpp
LIBS = \
-labouturl \
-lfileurl \
-lftpurl \
-lgophurl \
-lremoturl \
-lhttpurl \
-lsockstuburl \
-lnetcache \
-lmimetype \
-lnetcnvts \
-lnetwork \
-lnetlib \
-lmsgbaseutil \
-lmozreg \
-lxpcom \
-lpwcac \
-lmozdbm \
-lxp \
-lpref \
-lmozjs \
-ljsdom \
-ljsurl \
-lsecfree \
$(TIMER_LIBS) \
$(ZLIB_LIBS) \
$(NSPR_LIBS) \
-limg \
-lmozutil \
$(TK_LIBS) \
$(NULL)
LIBS = \
-lmsgbaseutil \
-lmozreg \
-lxpcom \
-lmozdbm \
-lxp \
-lpref \
-lmozjs \
-ljsdom \
-ljsurl \
-lsecfree \
$(TIMER_LIBS) \
$(ZLIB_LIBS) \
$(NSPR_LIBS) \
-limg \
-lmozutil \
-lneckoutil_s \
$(TK_LIBS) \
$(NULL)
include $(topsrcdir)/config/rules.mk

Some files were not shown because too many files have changed in this diff Show More