fix for #121639. get forward as attachment to work for news again.

while I'm at it, some code cleanup.  note, this fix also makes it so
we use the news cache when copying messages, which is a perf win.
most of this r=naving, all of it r/sr=bienvenu
This commit is contained in:
sspitzer%netscape.com 2002-02-20 08:23:05 +00:00
Родитель b2412d8006
Коммит d2cb3313a4
9 изменённых файлов: 55 добавлений и 71 удалений

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

@ -63,28 +63,33 @@ NS_INTERFACE_MAP_END_THREADSAFE
static nsresult GetMessage(nsIURI *aURL, nsIMsgDBHdr **message)
{
nsCOMPtr<nsIMsgMessageUrl> uriURL;
nsXPIDLCString uri;
nsresult rv;
NS_ENSURE_ARG_POINTER(message);
if(!message)
return NS_ERROR_NULL_POINTER;
nsCOMPtr<nsIMsgMessageUrl> uriURL;
nsresult rv;
//Need to get message we are about to copy
uriURL = do_QueryInterface(aURL, &rv);
if(NS_FAILED(rv))
return rv;
rv = uriURL->GetUri(getter_Copies(uri));
if(NS_FAILED(rv))
return rv;
// get the uri. first try and use the original message spec
// if that fails, use the spec of nsIURI that we're called with
nsXPIDLCString uri;
rv = uriURL->GetOriginalSpec(getter_Copies(uri));
if (NS_FAILED(rv) || uri.IsEmpty()) {
rv = uriURL->GetUri(getter_Copies(uri));
NS_ENSURE_SUCCESS(rv,rv);
}
nsCOMPtr <nsIMsgMessageService> msgMessageService;
rv = GetMessageServiceFromURI(uri, getter_AddRefs(msgMessageService));
NS_ENSURE_SUCCESS(rv,rv);
if (!msgMessageService) return NS_ERROR_FAILURE;
if (!msgMessageService)
return NS_ERROR_FAILURE;
return msgMessageService->MessageURIToMsgHdr(uri, message);
rv = msgMessageService->MessageURIToMsgHdr(uri.get(), message);
return rv;
}
nsCopyMessageStreamListener::nsCopyMessageStreamListener()

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

@ -560,7 +560,7 @@ nsMsgSendLater::StartNextMailFileSend()
{
nsFileSpec fileSpec;
nsresult rv = NS_OK;
nsXPIDLCString aMessageURI;
nsXPIDLCString messageURI;
PRBool hasMore = PR_FALSE;
@ -590,7 +590,7 @@ nsMsgSendLater::StartNextMailFileSend()
if(NS_FAILED(rv) || (!myRDFNode))
return NS_ERROR_NOT_AVAILABLE;
mMessageFolder->GetUriForMsg(mMessage, getter_Copies(aMessageURI));
mMessageFolder->GetUriForMsg(mMessage, getter_Copies(messageURI));
#ifdef NS_DEBUG
nsXPIDLCString subject;
@ -607,7 +607,7 @@ nsMsgSendLater::StartNextMailFileSend()
return NS_ERROR_FAILURE;
nsCOMPtr <nsIMsgMessageService> messageService;
rv = GetMessageServiceFromURI(aMessageURI, getter_AddRefs(messageService));
rv = GetMessageServiceFromURI(messageURI, getter_AddRefs(messageService));
if (NS_FAILED(rv) && !messageService)
return NS_ERROR_FACTORY_NOT_LOADED;
@ -633,7 +633,7 @@ nsMsgSendLater::StartNextMailFileSend()
if (convertedListener)
{
// Now, just plug the two together and get the hell out of the way!
rv = messageService->DisplayMessage(aMessageURI, convertedListener, nsnull, nsnull, nsnull, nsnull);
rv = messageService->DisplayMessage(messageURI, convertedListener, nsnull, nsnull, nsnull, nsnull);
}
else
rv = NS_ERROR_FAILURE;

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

@ -176,7 +176,7 @@ nsStringEndsWith(nsString& name, const char *ending)
PRInt32 len = name.Length();
if (len == 0) return PR_FALSE;
PRInt32 endingLen = PL_strlen(ending);
PRInt32 endingLen = strlen(ending);
if (len > endingLen && name.RFind(ending, PR_TRUE) == len - endingLen) {
return PR_TRUE;
}
@ -1479,7 +1479,7 @@ NS_IMETHODIMP nsMsgLocalMailFolder::UserNeedsToAuthenticateForFolder(PRBool disp
if (m_master->IsCachePasswordProtected() && !m_master->IsUserAuthenticated() && !m_master->AreLocalFoldersAuthenticated())
{
char *savedPassword = GetRememberedPassword();
if (savedPassword && nsCRT::strlen(savedPassword))
if (savedPassword && strlen(savedPassword))
ret = PR_TRUE;
FREEIF(savedPassword);
}
@ -2326,9 +2326,9 @@ NS_IMETHODIMP nsMsgLocalMailFolder::CopyData(nsIInputStream *aIStream, PRInt32 a
mCopyState->m_leftOver += readCount;
mCopyState->m_dataBuffer[mCopyState->m_leftOver] ='\0';
start = mCopyState->m_dataBuffer;
end = PL_strchr(start, '\r');
end = strchr(start, '\r');
if (!end)
end = PL_strchr(start, '\n');
end = strchr(start, '\n');
else if (*(end+1) == nsCRT::LF && linebreak_len == 0)
linebreak_len = 2;
@ -2342,7 +2342,7 @@ NS_IMETHODIMP nsMsgLocalMailFolder::CopyData(nsIInputStream *aIStream, PRInt32 a
{
if (mCopyState->m_fromLineSeen)
{
if (nsCRT::strncmp(start, "From ", 5) == 0)
if (strncmp(start, "From ", 5) == 0)
{
line = ">";
@ -2362,7 +2362,7 @@ NS_IMETHODIMP nsMsgLocalMailFolder::CopyData(nsIInputStream *aIStream, PRInt32 a
else
{
mCopyState->m_fromLineSeen = PR_TRUE;
NS_ASSERTION(nsCRT::strncmp(start, "From ", 5) == 0,
NS_ASSERTION(strncmp(start, "From ", 5) == 0,
"Fatal ... bad message format\n");
}
@ -2378,7 +2378,7 @@ NS_IMETHODIMP nsMsgLocalMailFolder::CopyData(nsIInputStream *aIStream, PRInt32 a
mCopyState->m_leftOver = 0;
break;
}
end = PL_strchr(start, '\r');
end = strchr(start, '\r');
if (end)
{
if (*(end+1) == nsCRT::LF) //need to set the linebreak_len each time
@ -2388,7 +2388,7 @@ NS_IMETHODIMP nsMsgLocalMailFolder::CopyData(nsIInputStream *aIStream, PRInt32 a
}
if (!end)
{
end = PL_strchr(start, '\n');
end = strchr(start, '\n');
if (end)
linebreak_len = 1; //LF
else
@ -2959,7 +2959,7 @@ nsresult nsMsgLocalMailFolder::DeleteMsgsOnPop3Server(nsISupportsArray *messages
len = 0;
else {
len -= size;
uidl = PL_strstr(header, X_UIDL);
uidl = strstr(header, X_UIDL);
}
} else
len = 0;
@ -3093,7 +3093,7 @@ nsMsgLocalMailFolder::OnStartRunningUrl(nsIURI * aUrl)
{
nsXPIDLCString aSpec;
aUrl->GetSpec(getter_Copies(aSpec));
if (aSpec && PL_strstr((const char *) aSpec, "uidl="))
if (aSpec && strstr(aSpec.get(), "uidl="))
{
nsCOMPtr<nsIPop3Sink> popsink;
rv = popurl->GetPop3Sink(getter_AddRefs(popsink));
@ -3117,7 +3117,7 @@ nsMsgLocalMailFolder::OnStopRunningUrl(nsIURI * aUrl, nsresult aExitCode)
nsXPIDLCString aSpec;
aUrl->GetSpec(getter_Copies(aSpec));
if (PL_strstr(aSpec, "uidl="))
if (strstr(aSpec, "uidl="))
{
nsCOMPtr<nsIPop3URL> popurl = do_QueryInterface(aUrl, &rv);
if (NS_SUCCEEDED(rv))

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

@ -665,7 +665,7 @@ nsParseMailMessageState::IsEnvelopeLine(const char *buf, PRInt32 buf_size)
if (buf_size < 29) return PR_FALSE;
if (*buf != 'F') return PR_FALSE;
if (nsCRT::strncmp(buf, "From ", 5)) return PR_FALSE;
if (strncmp(buf, "From ", 5)) return PR_FALSE;
end = buf + buf_size;
date = buf + 5;
@ -730,7 +730,7 @@ nsParseMailMessageState::IsEnvelopeLine(const char *buf, PRInt32 buf_size)
if (buf_size < 5) return PR_FALSE;
if (*buf != 'F') return PR_FALSE;
if (nsCRT::strncmp(buf, "From ", 5)) return PR_FALSE;
if (strncmp(buf, "From ", 5)) return PR_FALSE;
#endif /* !STRICT_ENVELOPE */
@ -2288,7 +2288,7 @@ PRInt32 ParseOutgoingMessage::ParseFolderLine(const char *line, PRUint32 lineLen
m_lastBodyLineEmpty = (m_state == nsIMsgParseMailMsgState::ParseBodyState && (EMPTY_MESSAGE_LINE(line)));
// make sure we mangle naked From lines
if (line[0] == 'F' && !nsCRT::strncmp(line, "From ", 5))
if (line[0] == 'F' && !strncmp(line, "From ", 5))
{
res = XP_FileWrite (">", 1, m_out_file);
if (res < 1)

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

@ -393,7 +393,7 @@ nsPop3Sink::IncorporateWrite(const char* block,
PRInt32 length)
{
PRInt32 blockOffset = 0;
if (!PL_strncmp(block, "From ", 5))
if (!strncmp(block, "From ", 5))
{
length++;
blockOffset = 1;

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

@ -78,8 +78,6 @@
NS_NETWORK_PROTOCOL_CONTRACTID_PREFIX "snews"
#define NS_NNTPPROTOCOLHANDLER_CONTRACTID \
NS_NETWORK_PROTOCOL_CONTRACTID_PREFIX "nntp"
#define NS_NEWSMESSAGEPROTOCOLHANDLER_CONTRACTID \
NS_NETWORK_PROTOCOL_CONTRACTID_PREFIX "news-message"
#define NS_NEWSMESSAGESERVICE_CONTRACTID \
"@mozilla.org/messenger/messageservice;1?type=news-message"
#define NS_NNTPMESSAGESERVICE_CONTRACTID \

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

@ -102,10 +102,6 @@ static const nsModuleComponentInfo components[] =
NS_NNTPSERVICE_CID,
NS_NEWSPROTOCOLHANDLER_CONTRACTID,
nsNntpServiceConstructor },
{ "News Message Protocol Handler",
NS_NNTPSERVICE_CID,
NS_NEWSMESSAGEPROTOCOLHANDLER_CONTRACTID,
nsNntpServiceConstructor },
{ "Secure News Protocol Handler",
NS_NNTPSERVICE_CID,
NS_SNEWSPROTOCOLHANDLER_CONTRACTID,

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

@ -98,10 +98,9 @@ static NS_DEFINE_CID(kCacheServiceCID, NS_CACHESERVICE_CID);
nsNntpService::nsNntpService()
{
NS_INIT_REFCNT();
mPrintingOperation = PR_FALSE;
NS_INIT_REFCNT();
mPrintingOperation = PR_FALSE;
mOpenAttachmentOperation = PR_FALSE;
mCopyingOperation = PR_FALSE;
}
nsNntpService::~nsNntpService()
@ -232,11 +231,7 @@ nsNntpService::DisplayMessage(const char* aMessageURI, nsISupports * aDisplayCon
rv = DecomposeNewsMessageURI(aMessageURI, getter_AddRefs(folder), &key);
NS_ENSURE_SUCCESS(rv,rv);
nsCAutoString uri;
//
// if we are copying, we need the uri to be a news://host/group#key uri
// so that we can get back to the nsIMsgDBHdr.
//
nsCAutoString urlStr;
// if we are displaying (or printing), we want the news://host/message-id url
// we keep the original uri around, for cancelling and so we can get to the
// articles by doing GROUP and then ARTICLE <n>.
@ -245,31 +240,23 @@ nsNntpService::DisplayMessage(const char* aMessageURI, nsISupports * aDisplayCon
// we'll use that to look up in the cache, so if
// you are reading a message that you've already read, you
// (from a cross post) it would be in your cache.
//
// if we used news://host/group#key, we would not have that behaviour
//
// XXX fix it so copy operations check the memory cache
if (mCopyingOperation) {
uri = aMessageURI;
}
else {
nsXPIDLCString messageIdURL;
rv = CreateMessageIDURL(folder, key, getter_Copies(messageIdURL));
NS_ENSURE_SUCCESS(rv,rv);
uri = messageIdURL.get();
}
nsXPIDLCString messageIdURL;
rv = CreateMessageIDURL(folder, key, getter_Copies(messageIdURL));
NS_ENSURE_SUCCESS(rv,rv);
urlStr = messageIdURL.get();
// rhp: If we are displaying this message for the purposes of printing, append
// the magic operand.
if (mPrintingOperation)
uri.Append("?header=print");
urlStr.Append("?header=print");
nsNewsAction action = nsINntpUrl::ActionFetchArticle;
if (mOpenAttachmentOperation)
action = nsINntpUrl::ActionFetchPart;
nsCOMPtr<nsIURI> url;
rv = ConstructNntpUrl(uri.get(), aUrlListener, aMsgWindow, aMessageURI, action, getter_AddRefs(url));
rv = ConstructNntpUrl(urlStr.get(), aUrlListener, aMsgWindow, aMessageURI, action, getter_AddRefs(url));
NS_ENSURE_SUCCESS(rv,rv);
if (NS_SUCCEEDED(rv))
@ -559,18 +546,17 @@ nsNntpService::GetFolderFromUri(const char *uri, nsIMsgFolder **folder)
}
NS_IMETHODIMP
nsNntpService::CopyMessage(const char * aSrcMailboxURI, nsIStreamListener * aMailboxCopyHandler, PRBool moveMessage,
nsNntpService::CopyMessage(const char * aSrcMessageURI, nsIStreamListener * aMailboxCopyHandler, PRBool moveMessage,
nsIUrlListener * aUrlListener, nsIMsgWindow *aMsgWindow, nsIURI **aURL)
{
nsresult rv = NS_ERROR_NULL_POINTER;
nsCOMPtr<nsISupports> streamSupport;
if (!aSrcMailboxURI || !aMailboxCopyHandler) return rv;
streamSupport = do_QueryInterface(aMailboxCopyHandler, &rv);
if (NS_SUCCEEDED(rv)) {
mCopyingOperation = PR_TRUE;
rv = DisplayMessage(aSrcMailboxURI, streamSupport, aMsgWindow, aUrlListener, nsnull, aURL);
mCopyingOperation = PR_FALSE;
}
NS_ENSURE_ARG_POINTER(aSrcMessageURI);
NS_ENSURE_ARG_POINTER(aMailboxCopyHandler);
nsresult rv;
nsCOMPtr<nsISupports> streamSupport = do_QueryInterface(aMailboxCopyHandler, &rv);
NS_ENSURE_SUCCESS(rv,rv);
rv = DisplayMessage(aSrcMessageURI, streamSupport, aMsgWindow, aUrlListener, nsnull, aURL);
return rv;
}
@ -1118,7 +1104,7 @@ nsNntpService::GetProtocolForUri(nsIURI *aUri, nsIMsgWindow *aMsgWindow, nsINNTP
if (NS_FAILED(rv) || !server) {
PRBool isSecure = PR_FALSE;
if (nsCRT::strcasecmp("snews",(const char *)scheme) == 0) {
if (PL_strcasecmp("snews",scheme.get()) == 0) {
isSecure = PR_TRUE;
if ((port == 0) || (port == -1)) {
port = SECURE_NEWS_PORT;
@ -1604,7 +1590,7 @@ nsNntpService::HandleContent(const char * aContentType, const char * aCommand, n
nsCOMPtr<nsIChannel> aChannel = do_QueryInterface(request, &rv);
NS_ENSURE_SUCCESS(rv, rv);
if (nsCRT::strcasecmp(aContentType, "x-application-newsgroup") == 0)
if (PL_strcasecmp(aContentType, "x-application-newsgroup") == 0)
{
nsCOMPtr<nsIURI> uri;
rv = aChannel->GetURI(getter_AddRefs(uri));

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

@ -102,7 +102,6 @@ protected:
PRBool mPrintingOperation; // Flag for printing operations
PRBool mOpenAttachmentOperation; // Flag for opening attachments
PRBool mCopyingOperation;
nsCOMPtr<nsICacheSession> mCacheSession; // the cache session used by news
};