clean up the interfaces I'll need to remove the message from the db after

the user hits cancel.  add newlines to ends of files.  remove old bogus code.
This commit is contained in:
sspitzer%netscape.com 1999-06-16 07:00:47 +00:00
Родитель 92d566bc69
Коммит 8292b9a734
9 изменённых файлов: 81 добавлений и 68 удалений

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

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

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

@ -84,6 +84,7 @@ public:
NS_IMETHOD GetMessageKey(nsMsgKey * aKey) = 0;
NS_IMETHOD SetNewsgroupName(char *aNewsgroupName) = 0;
NS_IMETHOD GetNewsgroupName(char ** aNewsgroupName) = 0;
};
#endif /* nsIHttpURL_h___ */

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

@ -1869,8 +1869,8 @@ PRInt32 nsNNTPProtocol::SendFirstNNTPCommandResponse()
PR_snprintf(outputBuffer,OUTPUT_BUFFER_SIZE, UNTIL_STRING_BUNDLES_XP_HTML_ARTICLE_EXPIRED);
m_tempErrorStream->Write(outputBuffer, PL_strlen(outputBuffer), &count);
nsMsgKey key = nsMsgKey_None;
rv = m_runningURL->GetMessageKey(&key);
nsMsgKey key = nsMsgKey_None;
rv = m_runningURL->GetMessageKey(&key);
PR_ASSERT(m_messageID && (key != nsMsgKey_None));
if (m_messageID && (key != nsMsgKey_None)) {
PR_snprintf(outputBuffer,OUTPUT_BUFFER_SIZE,"<P>&lt;%.512s&gt; (%lu)", m_messageID, key);
@ -2093,6 +2093,7 @@ PRInt32 nsNNTPProtocol::ReadArticle(nsIInputStream * inputStream, PRUint32 lengt
}
// now mark the message as read
printf("should we be marking later, after the message has finished loading?\n");
nsCOMPtr<nsIMsgDBHdr> msgHdr;
nsresult rv = NS_OK;
@ -3832,6 +3833,18 @@ PRInt32 nsNNTPProtocol::Cancel()
printf("%s\n", alertText.GetBuffer());
#endif /* BUG_7770_FIXED */
}
// just me for now...
#ifdef DEBUG_sspitzer
// delete the message from the db here.
nsMsgKey key = nsMsgKey_None;
rv = m_runningURL->GetMessageKey(&key);
PR_ASSERT(NS_SUCCEEDED(rv));
char *newsgroupname = nsnull;
rv = m_runningURL->GetNewsgroupName(&newsgroupname);
PR_ASSERT(NS_SUCCEEDED(rv) && newsgroupname);
printf("delete %lu from %s\n",key,newsgroupname);
#endif
}
FAIL:

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

@ -68,8 +68,7 @@ static NS_DEFINE_CID(kPrefServiceCID, NS_PREF_CID);
////////////////////////////////////////////////////////////////////////////////
nsMsgNewsFolder::nsMsgNewsFolder(void)
: mPath(nsnull), mExpungedBytes(0),
mHaveReadNameFromDB(PR_FALSE), mGettingNews(PR_FALSE),
: mPath(nsnull), mExpungedBytes(0), mGettingNews(PR_FALSE),
mInitialized(PR_FALSE), mOptionLines(nsnull), mHostname(nsnull)
{
// NS_INIT_REFCNT(); done by superclass
@ -825,20 +824,6 @@ NS_IMETHODIMP nsMsgNewsFolder::GetName(char **name)
if(!name)
return NS_ERROR_NULL_POINTER;
if (!mHaveReadNameFromDB)
{
if (mDepth == 1)
{
SetName("News.Foo.Bar");
mHaveReadNameFromDB = TRUE;
*name = mName.ToNewCString();
return NS_OK;
}
else
{
//Need to read the name from the database
}
}
nsAutoString folderName;
nsNewsURI2Name(kNewsRootURI, mURI, folderName);
*name = folderName.ToNewCString();
@ -848,21 +833,19 @@ NS_IMETHODIMP nsMsgNewsFolder::GetName(char **name)
NS_IMETHODIMP nsMsgNewsFolder::GetPrettyName(char ** prettyName)
{
if (mDepth == 1) {
// Depth == 1 means we are on the news server level
// override the name here to say "News.Foo.Bar"
*prettyName = PL_strdup("News.Foo.Bar");
if (!prettyName)
return NS_ERROR_NULL_POINTER;
nsresult rv = NS_OK;;
char *pName = PL_strdup(*prettyName);
if (pName) {
rv = nsMsgFolder::GetPrettyName(&pName);
delete[] pName;
}
else {
nsresult rv = NS_ERROR_NULL_POINTER;
char *pName = PL_strdup(*prettyName);
if (pName)
rv = nsMsgFolder::GetPrettyName(&pName);
delete[] pName;
return rv;
return NS_ERROR_OUT_OF_MEMORY;
}
return NS_OK;
return rv;
}
nsresult nsMsgNewsFolder::GetDBFolderInfoAndDB(nsIDBFolderInfo **folderInfo, nsIMsgDatabase **db)
@ -935,6 +918,7 @@ NS_IMETHODIMP nsMsgNewsFolder::GetExpungedBytesCount(PRUint32 *count)
NS_IMETHODIMP nsMsgNewsFolder::GetDeletable(PRBool *deletable)
{
#if 0
if(!deletable)
return NS_ERROR_NULL_POINTER;
@ -957,6 +941,10 @@ NS_IMETHODIMP nsMsgNewsFolder::GetDeletable(PRBool *deletable)
else *deletable = PR_TRUE;
return NS_OK;
#else
NS_ASSERTION(0,"GetDeletable() not implemented");
return NS_ERROR_NOT_IMPLEMENTED;
#endif
}
NS_IMETHODIMP nsMsgNewsFolder::GetCanCreateChildren(PRBool *canCreateChildren)
@ -970,6 +958,7 @@ NS_IMETHODIMP nsMsgNewsFolder::GetCanCreateChildren(PRBool *canCreateChildren)
NS_IMETHODIMP nsMsgNewsFolder::GetCanBeRenamed(PRBool *canBeRenamed)
{
#if 0
if(!canBeRenamed)
return NS_ERROR_NULL_POINTER;
@ -990,6 +979,10 @@ NS_IMETHODIMP nsMsgNewsFolder::GetCanBeRenamed(PRBool *canBeRenamed)
*canBeRenamed = PR_TRUE;
return NS_OK;
#else
NS_ASSERTION(0,"GetCanBeRenamed() not implemented");
return NS_ERROR_NOT_IMPLEMENTED;
#endif
}
NS_IMETHODIMP nsMsgNewsFolder::GetRequiresCleanup(PRBool *requiresCleanup)
@ -1087,31 +1080,17 @@ NS_IMETHODIMP nsMsgNewsFolder::DeleteMessages(nsISupportsArray *messages,
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
if (NS_SUCCEEDED(rv)) {
if (mDatabase) {
PRUint32 count = 0;
PRUint32 i;
for (i = 0; i < count; i++) {
nsCOMPtr<nsISupports> msgSupports = getter_AddRefs(messages->ElementAt(i));
nsCOMPtr<nsIMessage> message(do_QueryInterface(msgSupports));
if (message) {
nsCOMPtr<nsIMsgDBHdr> msgDBHdr;
nsCOMPtr<nsIDBMessage> dbMessage(do_QueryInterface(message, &rv));
if(NS_SUCCEEDED(rv)) {
rv = dbMessage->GetMsgDBHdr(getter_AddRefs(msgDBHdr));
if(NS_SUCCEEDED(rv)) {
rv = mDatabase->DeleteHeader(msgDBHdr, nsnull, PR_TRUE, PR_TRUE);
}
}
}
}
char *newsgroupname;
rv = GetName(&newsgroupname);
if (NS_FAILED(rv)) {
PR_FREEIF(hostname);
return rv;
}
rv = nntpService->CancelMessages(hostname, newsgroupname, messages, nsnull, nsnull, nsnull);
PR_FREEIF(hostname);
PR_FREEIF(newsgroupname);
}
return rv;

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

@ -123,7 +123,6 @@ protected:
protected:
nsNativeFileSpec *mPath;
PRUint32 mExpungedBytes;
PRBool mHaveReadNameFromDB;
PRBool mGettingNews;
PRBool mInitialized;
nsISupportsArray *mMessages;

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

@ -459,8 +459,8 @@ nsresult nsNntpService::PostMessage(nsFilePath &pathToFile, const char *newsgrou
nsresult
nsNntpService::RunNewsUrl(nsString& urlString, nsString &newsgroupName, nsMsgKey key, nsISupports * aConsumer, nsIUrlListener *aUrlListener, nsIURL **_retval)
{
#ifdef DEBUG_NEWS
printf("nsNntpService::RunNewsUrl(%s,...)\n", (const char *)nsAutoCString(urlString));
#ifdef DEBUG_sspitzer
printf("nsNntpService::RunNewsUrl(%s,%s,%lu,...)\n", (const char *)nsAutoCString(urlString), (const char *)nsAutoCString(newsgroupName), key);
#endif
nsCOMPtr <nsINntpUrl> nntpUrl;
@ -471,9 +471,6 @@ nsNntpService::RunNewsUrl(nsString& urlString, nsString &newsgroupName, nsMsgKey
nntpUrl->SetSpec(nsAutoCString(urlString));
// 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));
@ -570,7 +567,7 @@ NS_IMETHODIMP nsNntpService::GetNewNews(nsINntpIncomingServer *nntpServer, const
return rv;
}
NS_IMETHODIMP nsNntpService::CancelMessages(const char *hostname, nsISupportsArray *messages, nsISupports * aConsumer, nsIUrlListener * aUrlListener, nsIURL ** aURL)
NS_IMETHODIMP nsNntpService::CancelMessages(const char *hostname, const char *newsgroupname, nsISupportsArray *messages, nsISupports * aConsumer, nsIUrlListener * aUrlListener, nsIURL ** aURL)
{
nsresult rv = NS_OK;
PRUint32 count = 0;
@ -631,8 +628,8 @@ NS_IMETHODIMP nsNntpService::CancelMessages(const char *hostname, nsISupportsArr
printf("attempt to cancel the message (key,ID,cancel url): (%d,%s,%s)\n", key, messageId.GetBuffer(),urlStr.GetBuffer());
#endif
nsString blankNewsgroupName("",eOneByte);
rv = RunNewsUrl(urlStr, blankNewsgroupName, nsMsgKey_None, aConsumer, aUrlListener, aURL);
nsString newsgroupNameStr(newsgroupname,eOneByte);
rv = RunNewsUrl(urlStr, newsgroupNameStr, key, aConsumer, aUrlListener, aURL);
return rv;
}

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

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

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

@ -1092,6 +1092,22 @@ NS_IMETHODIMP nsNntpUrl::SetNewsgroupName(char * aNewsgroupName)
}
}
NS_IMETHODIMP nsNntpUrl::GetNewsgroupName(char ** aNewsgroupName)
{
if (!*aNewsgroupName) return NS_ERROR_NULL_POINTER;
PR_ASSERT(m_newsgroupName);
if (!m_newsgroupName) return NS_ERROR_FAILURE;
*aNewsgroupName = PL_strdup(m_newsgroupName);
if (!aNewsgroupName) {
return NS_ERROR_OUT_OF_MEMORY;
}
else {
return NS_OK;
}
}
NS_IMETHODIMP nsNntpUrl::SetMessageKey(nsMsgKey aKey)
{
m_messageKey = aKey;
@ -1102,4 +1118,8 @@ NS_IMETHODIMP nsNntpUrl::GetMessageKey(nsMsgKey * aKey)
{
*aKey = m_messageKey;
return NS_OK;
}
}

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

@ -84,9 +84,13 @@ public:
NS_IMETHOD GetMessageHeader(nsIMsgDBHdr ** aMsgHdr);
// this should be an IDL attribute
NS_IMETHOD SetMessageKey(nsMsgKey aKey);
NS_IMETHOD GetMessageKey(nsMsgKey * aKey);
NS_IMETHOD SetNewsgroupName(char *aNewsgroupName);
NS_IMETHOD GetMessageKey(nsMsgKey * aKey);
// this should be an IDL attribute
NS_IMETHOD SetNewsgroupName(char * aNewsgroupName);
NS_IMETHOD GetNewsgroupName(char ** aNewsgroupName);
// from nsIMsgMailNewsUrl:
NS_IMETHOD SetUrlState(PRBool aRunningUrl, nsresult aExitCode);