changes to get news cancel working. more to be done, but the basics of

news cancel works for now.
This commit is contained in:
sspitzer%netscape.com 1999-06-13 17:14:05 +00:00
Родитель f270a0605f
Коммит 197b332044
7 изменённых файлов: 203 добавлений и 108 удалений

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

@ -44,6 +44,6 @@ interface nsINntpService : nsISupports {
nsIURL GetNewNews (in nsINntpIncomingServer nntpServer, in string uri, in nsIUrlListener aUrlListener);
void CancelMessages (in nsISupportsArray messages, in nsIUrlListener aUrlListener);
nsIURL CancelMessages (in string hostname, in nsISupportsArray messages, in nsISupports aConsumer, in nsIUrlListener aUrlListener);
};

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

@ -64,6 +64,9 @@
#include "nsNewsUtils.h"
#include "nsIPref.h"
#include "nsIMsgMailSession.h"
#include "nsIMsgIdentity.h"
#define PREF_NEWS_MAX_ARTICLES "news.max_articles"
#define PREF_NEWS_MARK_OLD_READ "news.mark_old_read"
@ -89,6 +92,7 @@ static NS_DEFINE_CID(kPrefServiceCID, NS_PREF_CID);
static NS_DEFINE_CID(kCHeaderParserCID, NS_MSGHEADERPARSER_CID);
static NS_DEFINE_CID(kNNTPArticleListCID, NS_NNTPARTICLELIST_CID);
static NS_DEFINE_CID(kNNTPHostCID, NS_NNTPHOST_CID);
static NS_DEFINE_CID(kCMsgMailSessionCID, NS_MSGMAILSESSION_CID);
// quiet compiler warnings by defining these function prototypes
char *NET_ExplainErrorDetails (int code, ...);
@ -450,10 +454,10 @@ nsresult nsNNTPProtocol::Initialize(nsIURL * aURL)
m_messageID = NULL;
m_articleNumber = 0;
m_originalContentLength = 0;
m_cancelID = NULL;
m_cancelFromHdr = NULL;
m_cancelNewsgroups = NULL;
m_cancelDistribution = NULL;
m_cancelID = nsnull;
m_cancelFromHdr = nsnull;
m_cancelNewsgroups = nsnull;
m_cancelDistribution = nsnull;
return NS_OK;
}
@ -1986,7 +1990,7 @@ PRInt32 nsNNTPProtocol::BeginArticle()
// mscott: short term mime hack.....until libmime plays "nice" with a new stream converter
// interface, we have to interact with it like we did in the old networking world...however this
// would be hard to do now...in addition the code and effort would be wasted as we'd have to through
// it away once libmime did use a new stream converter interface. So we are going to cheet and write
// it away once libmime did use a new stream converter interface. So we are going to cheat and write
// the article to file. We'll then call a load file url on our "temp" file. Then mkfile does all the work
// with talking to the RFC-822->HTML stream converter....clever huh =).....
@ -2099,6 +2103,12 @@ PRInt32 nsNNTPProtocol::ReadArticle(nsIInputStream * inputStream, PRUint32 lengt
// for test purposes...we'd want to write this line out to an rfc-822 stream converter...
// we don't have one now so print the data out so we can verify that we got it....
printf("%s", outputBuffer);
// if we are attempting to cancel, we want to snarf the headers and save the aside, which is what
// ParseHeaderForCancel() does.
if (m_typeWanted == CANCEL_WANTED) {
ParseHeaderForCancel(outputBuffer);
}
if (m_tempArticleStream)
{
PRUint32 count = 0;
@ -2112,6 +2122,47 @@ PRInt32 nsNNTPProtocol::ReadArticle(nsIInputStream * inputStream, PRUint32 lengt
return 0;
}
void nsNNTPProtocol::ParseHeaderForCancel(char *buf)
{
nsString header(buf, eOneByte);
PRInt32 colon = header.Find(':');
if (!colon)
return;
nsString value("", eOneByte);
header.Right(value, header.Length() - colon -1);
value.StripWhitespace();
switch (header[0]) {
case 'F': case 'f':
if (header.Find("From") == 0) {
if (m_cancelFromHdr) PR_FREEIF(m_cancelFromHdr);
m_cancelFromHdr = PL_strdup(value.GetBuffer());
}
break;
case 'M': case 'm':
if (header.Find("Message-ID") == 0) {
if (m_cancelID) PR_FREEIF(m_cancelID);
m_cancelID = PL_strdup(value.GetBuffer());
}
break;
case 'N': case 'n':
if (header.Find("Newsgroups") == 0) {
if (m_cancelNewsgroups) PR_FREEIF(m_cancelNewsgroups);
m_cancelNewsgroups = PL_strdup(value.GetBuffer());
}
break;
case 'D': case 'd':
if (header.Find("Distributions") == 0) {
if (m_cancelDistribution) PR_FREEIF(m_cancelDistribution);
m_cancelDistribution = PL_strdup(value.GetBuffer());
}
break;
}
return;
}
PRInt32 nsNNTPProtocol::BeginAuthorization()
{
char * command = 0;
@ -3546,6 +3597,7 @@ PRInt32 nsNNTPProtocol::StartCancel()
PRInt32 nsNNTPProtocol::Cancel()
{
int status = 0;
nsresult rv = NS_OK;
char *id, *subject, *newsgroups, *distribution, *other_random_headers, *body;
char *from, *old_from;
int L;
@ -3560,12 +3612,13 @@ PRInt32 nsNNTPProtocol::Cancel()
*/
PR_ASSERT (m_responseCode == MK_NNTP_RESPONSE_POST_SEND_NOW);
#if ParseHeadersForCancelHack
/* These shouldn't be set yet, since the headers haven't been "flushed" */
PR_ASSERT (!m_cancelID &&
!m_cancelFromHdr &&
!m_cancelNewsgroups &&
!m_cancelDistribution);
#endif
/* Write out a blank line. This will tell mimehtml.c that the headers
are done, and it will call news_generate_html_header_fn which will
notice the fields we're interested in.
@ -3581,27 +3634,40 @@ PRInt32 nsNNTPProtocol::Cancel()
and not platform dependent -km */
status = SendData(m_runningURL, outputBuffer);
if (status < 0) return status;
/* Now news_generate_html_header_fn should have been called, and these
should have values. */
id = m_cancelID;
old_from = m_cancelFromHdr;
newsgroups = m_cancelNewsgroups;
distribution = m_cancelDistribution;
old_from = m_cancelFromHdr;
id = m_cancelID;
PR_ASSERT (id && newsgroups);
if (!id || !newsgroups) return -1; /* "unknown error"... */
m_cancelNewsgroups = 0;
m_cancelDistribution = 0;
m_cancelFromHdr = 0;
m_cancelID = 0;
m_cancelNewsgroups = nsnull;
m_cancelDistribution = nsnull;
m_cancelFromHdr = nsnull;
m_cancelID = nsnull;
L = PL_strlen (id);
#ifdef UNREADY_CODE
from = MIME_MakeFromField ();
#else
from = "testSender@nowhere.com";
// get the current identity from the news session....
NS_WITH_SERVICE(nsIMsgMailSession,newsSession,kCMsgMailSessionCID,&rv);
if (NS_SUCCEEDED(rv) && newsSession) {
nsCOMPtr<nsIMsgIdentity> identity;
rv = newsSession->GetCurrentIdentity(getter_AddRefs(identity));
if (NS_SUCCEEDED(rv) && identity) {
identity->GetEmail(&from);
}
}
#ifdef DEBUG_NEWS
printf("post the cancel message as %s\n",from);
#endif
#endif
subject = (char *) PR_Malloc (L + 20);
other_random_headers = (char *) PR_Malloc (L + 20);
body = (char *) PR_Malloc (PL_strlen (XP_AppCodeName) + 100);
@ -3612,7 +3678,6 @@ PRInt32 nsNNTPProtocol::Cancel()
which to cancel postings (like telnet.)
Don't do this if server tells us it will validate user. DMB 3/19/97
*/
nsresult rv = NS_OK;
PRBool cancelchk=PR_FALSE;
rv = m_newsHost->QueryExtension("CANCELCHK",&cancelchk);
if (NS_SUCCEEDED(rv) && cancelchk)
@ -3725,7 +3790,7 @@ PRInt32 nsNNTPProtocol::Cancel()
}
FAIL:
FAIL:
PR_FREEIF (id);
PR_FREEIF (from);
PR_FREEIF (old_from);
@ -4735,4 +4800,3 @@ nsresult nsNNTPProtocol::CloseSocket()
return nsMsgProtocol::CloseSocket();
}

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

@ -175,6 +175,8 @@ private:
// and then calls the base class to transmit the data
PRInt32 SendData(nsIURL * aURL, const char * dataBuffer);
void ParseHeaderForCancel(char *buf);
// part of temporary libmime converstion trick......these should go away once MIME uses a new stream
// converter interface...
nsCOMPtr<nsIOutputStream> m_tempArticleStream;

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

@ -68,11 +68,10 @@ static NS_DEFINE_CID(kPrefServiceCID, NS_PREF_CID);
////////////////////////////////////////////////////////////////////////////////
nsMsgNewsFolder::nsMsgNewsFolder(void)
: mExpungedBytes(0),
: mPath(nsnull), mExpungedBytes(0),
mHaveReadNameFromDB(PR_FALSE), mGettingNews(PR_FALSE),
mInitialized(PR_FALSE), m_optionLines(nsnull)
mInitialized(PR_FALSE), mOptionLines(nsnull), mHostname(nsnull)
{
mPath = nsnull;
// NS_INIT_REFCNT(); done by superclass
}
@ -81,7 +80,11 @@ nsMsgNewsFolder::~nsMsgNewsFolder(void)
if (mPath)
delete mPath;
PR_FREEIF(m_optionLines);
// mHostname allocated in nsGetNewsHostName() with new char[]
if (mHostname)
delete [] mHostname;
PR_FREEIF(mOptionLines);
}
NS_IMPL_ADDREF_INHERITED(nsMsgNewsFolder, nsMsgDBFolder)
@ -326,39 +329,31 @@ nsMsgNewsFolder::CreateSubFolders(nsFileSpec &path)
{
nsresult rv = NS_OK;
char *hostname;
rv = GetHostName(&hostname);
if (NS_FAILED(rv)) return rv;
if (isNewsHost()) {
char *newshostname = nsnull;
// since we know it is a host, mURI is of the form
// news://foobar
// all we want is foobar
// so skip over news:// (a.k.a. kNewsRootURI)
newshostname = PR_smprintf("%s", mURI + kNewsRootURILen + 1);
if (newshostname == nsnull) {
return NS_ERROR_OUT_OF_MEMORY;
}
#ifdef DEBUG_NEWS
printf("CreateSubFolders: %s = %s\n", mURI, (const char *)path);
#endif
nsFileSpec newsrcFile("");
rv = GetNewsrcFile(newshostname, path, newsrcFile);
rv = GetNewsrcFile(hostname, path, newsrcFile);
if (rv == NS_OK) {
#ifdef DEBUG_NEWS
printf("uri = %s newsrc file = %s\n", mURI, (const char *)newsrcFile);
#endif
rv = LoadNewsrcFileAndCreateNewsgroups(newsrcFile);
}
PR_FREEIF(newshostname);
newshostname = nsnull;
}
else {
#ifdef DEBUG_NEWS
printf("%s is not a host, so it has no newsgroups.\n", mURI);
printf("%s is not a host, so it has no newsgroups. (what about categories??)\n", mURI);
#endif
rv = NS_OK;
}
PR_FREEIF(hostname);
return rv;
}
@ -401,7 +396,8 @@ nsresult nsMsgNewsFolder::AddSubfolder(nsAutoString name, nsIMsgFolder **child)
nsresult nsMsgNewsFolder::ParseFolder(nsFileSpec& path)
{
return NS_OK;
PR_ASSERT(0);
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP
@ -682,7 +678,8 @@ nsresult nsMsgNewsFolder::CreateDirectoryForFolder(nsFileSpec &path)
return rv;
#else
return NS_OK;
PR_ASSERT(0);
return NS_ERROR_NOT_IMPLEMENTED;
#endif
}
@ -752,7 +749,8 @@ NS_IMETHODIMP nsMsgNewsFolder::CreateSubfolder(const char *folderName)
}
return rv;
#endif
return NS_OK;
PR_ASSERT(0);
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP nsMsgNewsFolder::RemoveSubFolder(nsIMsgFolder *which)
@ -761,23 +759,26 @@ NS_IMETHODIMP nsMsgNewsFolder::RemoveSubFolder(nsIMsgFolder *which)
// Let the base class do list management
nsMsgFolder::RemoveSubFolder(which);
#endif
return NS_OK;
PR_ASSERT(0);
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP nsMsgNewsFolder::Delete()
{
return NS_OK;
PR_ASSERT(0);
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP nsMsgNewsFolder::Rename(const char *newName)
{
return NS_OK;
PR_ASSERT(0);
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP nsMsgNewsFolder::Adopt(nsIMsgFolder *srcFolder, PRUint32 *outPos)
{
return NS_OK;
PR_ASSERT(0);
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP
@ -993,33 +994,41 @@ NS_IMETHODIMP nsMsgNewsFolder::GetCanBeRenamed(PRBool *canBeRenamed)
NS_IMETHODIMP nsMsgNewsFolder::GetRequiresCleanup(PRBool *requiresCleanup)
{
return NS_OK;
PR_ASSERT(0);
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP nsMsgNewsFolder::GetSizeOnDisk(PRUint32 *size)
{
return NS_OK;
PR_ASSERT(0);
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP nsMsgNewsFolder::GetUsersName(char** userName)
{
return NS_OK;
PR_ASSERT(0);
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP nsMsgNewsFolder::GetHostName(char** hostName)
{
nsresult rv;
char *host = nsnull;
rv = nsGetNewsHostName(kNewsRootURI, mURI, &host);
//I'm recopying it because otherwise we'll have a free mismatched memory.
//We should really be using allocators to do all of this.
if(NS_SUCCEEDED(rv) && host)
{
*hostName = PL_strdup(host);
delete[] host;
nsresult rv = NS_OK;
if (!mHostname) {
// mHostname gets freed in the destructor
rv = nsGetNewsHostName(kNewsRootURI, mURI, &mHostname);
if (NS_FAILED(rv)) return rv;
}
if (mHostname) {
*hostName = PL_strdup(mHostname);
if(!*hostName)
return NS_ERROR_OUT_OF_MEMORY;
}
else {
return NS_ERROR_FAILURE;
}
return rv;
}
@ -1073,8 +1082,13 @@ NS_IMETHODIMP nsMsgNewsFolder::DeleteMessages(nsISupportsArray *messages,
}
NS_WITH_SERVICE(nsINntpService, nntpService, kNntpServiceCID, &rv);
if (NS_SUCCEEDED(rv) && nntpService) {
rv = nntpService->CancelMessages(messages, nsnull);
char *hostname;
rv = GetHostName(&hostname);
if (NS_FAILED(rv)) return rv;
rv = nntpService->CancelMessages(hostname, messages, nsnull, nsnull, nsnull);
PR_FREEIF(hostname);
}
// if we were able to CANCEL those messages, remove the from the database
@ -1372,7 +1386,7 @@ nsMsgNewsFolder::LoadNewsrcFileAndCreateNewsgroups(nsFileSpec &newsrcFile)
int status = 0;
PRInt32 numread = 0;
PR_FREEIF(m_optionLines);
PR_FREEIF(mOptionLines);
if (!buffer) return NS_ERROR_OUT_OF_MEMORY;
@ -1560,10 +1574,10 @@ PRInt32
nsMsgNewsFolder::RememberLine(char* line)
{
char* new_data;
if (m_optionLines) {
if (mOptionLines) {
new_data =
(char *) PR_Realloc(m_optionLines,
PL_strlen(m_optionLines)
(char *) PR_Realloc(mOptionLines,
PL_strlen(mOptionLines)
+ PL_strlen(line) + 4);
} else {
new_data = (char *) PR_Malloc(PL_strlen(line) + 3);
@ -1572,7 +1586,7 @@ nsMsgNewsFolder::RememberLine(char* line)
PL_strcpy(new_data, line);
PL_strcat(new_data, LINEBREAK);
m_optionLines = new_data;
mOptionLines = new_data;
return 0;

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

@ -98,7 +98,7 @@ protected:
nsresult CreateSubFolders(nsFileSpec &path);
nsresult AddDirectorySeparator(nsFileSpec &path);
nsresult GetDatabase();
/* Finds the directory associated with this folder. That is if the path is
c:\Inbox, it will return c:\Inbox.sbd if it succeeds. If that path doesn't
currently exist then it will create it
@ -119,7 +119,7 @@ protected:
nsresult MapHostToNewsrcFile(char *newshostname, nsFileSpec &fatFile, nsFileSpec &newsrcFile);
#endif
virtual const nsIID& GetIncomingServerType() {return nsINntpIncomingServer::GetIID();}
protected:
nsNativeFileSpec *mPath;
PRUint32 mExpungedBytes;
@ -127,7 +127,8 @@ protected:
PRBool mGettingNews;
PRBool mInitialized;
nsISupportsArray *mMessages;
char *m_optionLines;
char *mOptionLines;
char *mHostname;
};
#endif // nsMsgNewsFolder_h__

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

@ -34,6 +34,7 @@
#include "nsINetService.h"
#include "nsIMsgMailSession.h"
#include "nsIMsgIdentity.h"
#include "nsString.h"
@ -305,7 +306,7 @@ nsresult nsNntpService::DetermineHostForPosting(nsString &host, const char *news
if (!newsgroupNames) return NS_ERROR_NULL_POINTER;
if (PL_strlen(newsgroupNames) == 0) return NS_ERROR_FAILURE;
#ifdef DEBUG_sspitzer
#ifdef DEBUG_NEWS
printf("newsgroupNames == %s\n",newsgroupNames);
#endif
@ -335,7 +336,7 @@ nsresult nsNntpService::DetermineHostForPosting(nsString &host, const char *news
str.StripWhitespace();
if (str != "") {
#ifdef DEBUG_sspitzer
#ifdef DEBUG_NEWS
printf("value = %s\n", str.GetBuffer());
#endif
nsString theRest("",eOneByte);
@ -350,7 +351,7 @@ nsresult nsNntpService::DetermineHostForPosting(nsString &host, const char *news
theRest = str;
}
#ifdef DEBUG_sspitzer
#ifdef DEBUG_NEWS
printf("theRest == %s\n",theRest.GetBuffer());
#endif
@ -359,7 +360,7 @@ nsresult nsNntpService::DetermineHostForPosting(nsString &host, const char *news
if (slashpos > 0 ) {
// theRest is "host/group"
theRest.Left(host, slashpos);
#ifdef DEBUG_sspitzer
#ifdef DEBUG_NEWS
printf("host == %s\n", host.GetBuffer());
#endif
}
@ -370,7 +371,7 @@ nsresult nsNntpService::DetermineHostForPosting(nsString &host, const char *news
}
str = "";
}
#ifdef DEBUG_sspitzer
#ifdef DEBUG_NEWS
else {
printf("nothing between two commas. ignore and keep going...\n");
}
@ -392,7 +393,7 @@ nsresult nsNntpService::DetermineHostForPosting(nsString &host, const char *news
////////////////////////////////////////////////////////////////////////////////////////
nsresult nsNntpService::PostMessage(nsFilePath &pathToFile, const char *newsgroupNames, nsIUrlListener * aUrlListener, nsIURL **_retval)
{
#ifdef DEBUG_sspitzer
#ifdef DEBUG_NEWS
printf("nsNntpService::PostMessage(%s,%s,??,??)\n",(const char *)pathToFile,newsgroupNames);
#endif
if (!newsgroupNames) return NS_ERROR_NULL_POINTER;
@ -411,7 +412,7 @@ nsresult nsNntpService::PostMessage(nsFilePath &pathToFile, const char *newsgrou
rv = DetermineHostForPosting(host, newsgroupNames);
if (NS_FAILED(rv) || (host == "")) return rv;
#ifdef DEBUG_sspitzer
#ifdef DEBUG_NEWS
printf("post to this host: %s\n",host.GetBuffer());
#endif
@ -435,7 +436,7 @@ nsresult nsNntpService::PostMessage(nsFilePath &pathToFile, const char *newsgrou
rv = nsComponentManager::CreateInstance(kCNNTPNewsgroupPostCID, nsnull, nsINNTPNewsgroupPost::GetIID(), getter_AddRefs(post));
if (NS_FAILED(rv) || !post) return rv;
#ifdef DEBUG_sspitzer
#ifdef DEBUG_NEWS
printf("set file to post to %s\n",(const char *)pathToFile);
#endif
@ -469,23 +470,26 @@ nsNntpService::RunNewsUrl(nsString& urlString, nsString &newsgroupName, nsMsgKey
if (NS_FAILED(rv) || !nntpUrl) return rv;
nntpUrl->SetSpec(nsAutoCString(urlString));
nsCOMPtr <nsINNTPNewsgroup> newsgroup;
rv = nsComponentManager::CreateInstance(kCNNTPNewsgroupCID, nsnull, nsINNTPNewsgroup::GetIID(), getter_AddRefs(newsgroup));
if (NS_FAILED(rv) || !newsgroup) return rv;
rv = newsgroup->Initialize(nsnull /* line */, nsnull /* set */, PR_FALSE /* subscribed */);
nsString newsgroupNameStr(newsgroupName,eOneByte);
newsgroup->SetName((char *)(newsgroupNameStr.GetBuffer()));
nntpUrl->SetNewsgroup(newsgroup);
// if we are running a news url to display a message, these
// will be used later, to mark the message as read after we finish loading
nntpUrl->SetMessageKey(key);
nntpUrl->SetNewsgroupName((char *)(newsgroupNameStr.GetBuffer()));
// I should only be creating this if I have a newsgroup, ie, if my url looks like this:
// news://host/group
if (newsgroupName != "") {
nsCOMPtr <nsINNTPNewsgroup> newsgroup;
rv = nsComponentManager::CreateInstance(kCNNTPNewsgroupCID, nsnull, nsINNTPNewsgroup::GetIID(), getter_AddRefs(newsgroup));
if (NS_FAILED(rv) || !newsgroup) return rv;
rv = newsgroup->Initialize(nsnull /* line */, nsnull /* set */, PR_FALSE /* subscribed */);
newsgroup->SetName((char *)(newsgroupName.GetBuffer()));
nntpUrl->SetNewsgroup(newsgroup);
// if we are running a news url to display a message, these
// will be used later, to mark the message as read after we finish loading
nntpUrl->SetMessageKey(key);
nntpUrl->SetNewsgroupName((char *)(newsgroupName.GetBuffer()));
}
if (aUrlListener) // register listener if there is one...
nntpUrl->RegisterListener(aUrlListener);
@ -566,11 +570,14 @@ NS_IMETHODIMP nsNntpService::GetNewNews(nsINntpIncomingServer *nntpServer, const
return rv;
}
NS_IMETHODIMP nsNntpService::CancelMessages(nsISupportsArray *messages, nsIUrlListener * aUrlListener)
NS_IMETHODIMP nsNntpService::CancelMessages(const char *hostname, nsISupportsArray *messages, nsISupports * aConsumer, nsIUrlListener * aUrlListener, nsIURL ** aURL)
{
nsresult rv = NS_OK;
PRUint32 count = 0;
if (!hostname) return NS_ERROR_NULL_POINTER;
if (PL_strlen(hostname) == 0) return NS_ERROR_FAILURE;
NS_WITH_SERVICE(nsINetSupportDialogService,dialog,kCNetSupportDialogCID,&rv);
if (NS_FAILED(rv)) return rv;
@ -613,29 +620,36 @@ NS_IMETHODIMP nsNntpService::CancelMessages(nsISupportsArray *messages, nsIUrlLi
// they canceled the cancel
return NS_ERROR_FAILURE;
}
nsMsgKey key;
nsString messageId("", eOneByte);
nsString messageIds("", eOneByte);
PRUint32 i;
for (i = 0; i < count; i++) {
nsCOMPtr<nsISupports> msgSupports = getter_AddRefs(messages->ElementAt(i));
nsCOMPtr<nsIMessage> message(do_QueryInterface(msgSupports));
if (message) {
nsMsgKey key;
rv = message->GetMessageKey(&key);
if (NS_SUCCEEDED(rv)) {
if (messageIds.Length() > 0) {
messageIds.Append(',');
}
messageIds.Append((PRInt32)key);
}
}
nsCOMPtr<nsISupports> msgSupports = getter_AddRefs(messages->ElementAt(0));
nsCOMPtr<nsIMessage> message(do_QueryInterface(msgSupports));
if (message) {
rv = message->GetMessageKey(&key);
if (NS_FAILED(rv)) return rv;
rv = message->GetMessageId(messageId);
if (NS_FAILED(rv)) return rv;
}
else {
return NS_ERROR_FAILURE;
}
nsString urlStr("", eOneByte);
urlStr += kNewsRootURI;
urlStr += "/";
urlStr += hostname;
urlStr += "/";
urlStr += messageId;
urlStr += "?cancel";
#ifdef DEBUG_NEWS
printf("attempt to cancel the following IDs: %s\n", messageIds.GetBuffer());
printf("attempt to cancel the message (key,ID,cancel url): (%d,%s,%s)\n", key, messageId.GetBuffer(),urlStr.GetBuffer());
#endif
rv = NS_OK;
nsString blankNewsgroupName("",eOneByte);
rv = RunNewsUrl(urlStr, blankNewsgroupName, nsMsgKey_None, aConsumer, aUrlListener, aURL);
if (NS_SUCCEEDED(rv)) {
// the CANCEL succeeded.

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

@ -40,7 +40,7 @@ public:
NS_IMETHOD GetNewNews(nsINntpIncomingServer *nntpServer, const char *uri, nsIUrlListener * aUrlListener, nsIURL **_retval);
NS_IMETHOD CancelMessages(nsISupportsArray *messages, nsIUrlListener * aUrlListener);
NS_IMETHOD CancelMessages(const char *hostname, nsISupportsArray *messages, nsISupports * aDisplayConsumer, nsIUrlListener * aUrlListener, nsIURL ** aURL);
////////////////////////////////////////////////////////////////////////////////////////
// we suppport the nsIMsgMessageService Interface