fix for regression #108256 cancelling the auto-sub confirm dialog then running the same url again fails silently

fix for regression bug #108251 don't get the "remove group" dialog when there's msg window.
r=hwaara, sr=bienvenu
This commit is contained in:
sspitzer%netscape.com 2001-11-03 01:56:19 +00:00
Родитель d3f3ac70a4
Коммит a7dc777649
3 изменённых файлов: 46 добавлений и 30 удалений

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

@ -939,6 +939,7 @@ NS_IMETHODIMP nsNNTPProtocol::AsyncOpen(nsIStreamListener *listener, nsISupports
// the memory cache or the local msg cache.
if (mailnewsUrl && (m_newsAction == nsINntpUrl::ActionFetchArticle || m_newsAction == nsINntpUrl::ActionFetchPart))
{
SetupPartExtractorListener(m_channelListener);
if (ReadFromLocalCache())
return NS_OK;
@ -1108,8 +1109,23 @@ nsresult nsNNTPProtocol::LoadUrl(nsIURI * aURL, nsISupports * aConsumer)
rv = m_nntpServer->SubscribeToNewsgroup(group.get());
containsGroup = PR_TRUE;
}
else
return rv;
else {
// XXX FIX ME
// the way news is current written, we've already opened the socket
// and initialized the connection.
//
// until that is fixed, when the user cancels an autosubscribe, we've got to close it and clean up after ourselves
//
// see bug http://bugzilla.mozilla.org/show_bug.cgi?id=108293
// another problem, autosubscribe urls are ending up as cache entries
// because the default action on nntp urls is ActionFetchArticle
//
// see bug http://bugzilla.mozilla.org/show_bug.cgi?id=108294
if (m_runningURL)
DoomCacheEntryForRunningUrl();
return CloseConnection();
}
}
// If we have a group (since before, or just subscribed), set the m_newsFolder.
@ -1167,22 +1183,24 @@ nsresult nsNNTPProtocol::LoadUrl(nsIURI * aURL, nsISupports * aConsumer)
}
nsresult nsNNTPProtocol::DoomCacheEntryForRunningUrl()
{
nsCOMPtr <nsICacheEntryDescriptor> memCacheEntry;
nsCOMPtr<nsIMsgMailNewsUrl> mailnewsurl = do_QueryInterface(m_runningURL);
if (mailnewsurl)
mailnewsurl->GetMemCacheEntry(getter_AddRefs(memCacheEntry));
if (memCacheEntry)
memCacheEntry->Doom();
return NS_OK;
}
// stop binding is a "notification" informing us that the stream associated with aURL is going away.
NS_IMETHODIMP nsNNTPProtocol::OnStopRequest(nsIRequest *request, nsISupports * aContext, nsresult aStatus)
{
// If failed, remove incomplete cache entry (and it'll be reloaded next time).
if (NS_FAILED(aStatus) && m_runningURL)
{
#ifdef DEBUG_CAVIN
printf("*** Status failed in nsNNTPProtocol::OnStopRequest(), so clean up cache entry for the running url.");
#endif
nsCOMPtr <nsICacheEntryDescriptor> memCacheEntry;
nsCOMPtr<nsIMsgMailNewsUrl> mailnewsurl = do_QueryInterface(m_runningURL);
if (mailnewsurl)
mailnewsurl->GetMemCacheEntry(getter_AddRefs(memCacheEntry));
if (memCacheEntry)
memCacheEntry->Doom();
}
DoomCacheEntryForRunningUrl();
nsMsgProtocol::OnStopRequest(request, aContext, aStatus);
@ -2212,16 +2230,8 @@ PRInt32 nsNNTPProtocol::SendFirstNNTPCommandResponse()
// the message for offline use (or at least not displaying it)
PRBool savingArticleOffline = (m_channelListener == nsnull);
nsCOMPtr <nsICacheEntryDescriptor> memCacheEntry;
if (m_runningURL)
{
nsCOMPtr<nsIMsgMailNewsUrl> mailnewsurl = do_QueryInterface(m_runningURL);
if (mailnewsurl)
mailnewsurl->GetMemCacheEntry(getter_AddRefs(memCacheEntry));
// invalidate mem cache entry.
if (memCacheEntry)
memCacheEntry->Doom();
}
DoomCacheEntryForRunningUrl();
if (NS_SUCCEEDED(rv) && group_name && !savingArticleOffline) {
MarkCurrentMsgRead();

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

@ -424,6 +424,7 @@ private:
nsresult CleanupNewsgroupList(); /* cleans up m_newsgroupList, and set it to null */
// cache related helper methods
nsresult DoomCacheEntryForRunningUrl();
nsresult OpenCacheEntry(); // makes a request to the cache service for a cache entry for a url
PRBool ReadFromLocalCache(); // attempts to read the url out of our local (offline) cache....
nsresult ReadFromNewsConnection(); // creates a new news connection to read the url

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

@ -57,6 +57,7 @@
#include "nsIPrompt.h"
#include "nsIStringBundle.h"
#include "nntpCore.h"
#include "nsIWindowWatcher.h"
#define INVALID_VERSION 0
#define VALID_VERSION 1
@ -392,11 +393,8 @@ nsNntpIncomingServer::WriteNewsrcFile()
nsXPIDLCString newsrcLine;
rv = newsFolder->GetNewsrcLine(getter_Copies(newsrcLine));
if (NS_SUCCEEDED(rv) && ((const char *)newsrcLine)) {
// write the line to the newsrc file
newsrcStream << (const char *)newsrcLine;
#ifdef DEBUG_NEWS
printf("writing to newsrc file:\n");
printf("%s",(const char *)newsrcLine);
#endif /* DEBUG_NEWS */
}
}
}
@ -1566,13 +1564,20 @@ NS_IMETHODIMP
nsNntpIncomingServer::GroupNotFound(nsIMsgWindow *aMsgWindow, const char *aName, PRBool aOpening)
{
NS_ENSURE_ARG_POINTER(aName);
NS_ENSURE_ARG_POINTER(aMsgWindow);
nsresult rv;
nsCOMPtr <nsIPrompt> prompt;
rv = aMsgWindow->GetPromptDialog(getter_AddRefs(prompt));
NS_ENSURE_SUCCESS(rv,rv);
if (aMsgWindow) {
rv = aMsgWindow->GetPromptDialog(getter_AddRefs(prompt));
NS_ASSERTION(NS_SUCCEEDED(rv), "no prompt from the msg window");
}
if (!prompt) {
nsCOMPtr<nsIWindowWatcher> wwatch(do_GetService("@mozilla.org/embedcomp/window-watcher;1"));
rv = wwatch->GetNewPrompter(nsnull, getter_AddRefs(prompt));
NS_ENSURE_SUCCESS(rv,rv);
}
nsCOMPtr <nsIStringBundleService> bundleService = do_GetService(NS_STRINGBUNDLE_CONTRACTID,&rv);
NS_ENSURE_SUCCESS(rv,rv);