set a default progress event sink == the status feedback version.

necko may over-ride us with another one.
implement Get/SetNotification callbacks in order to extract the progress
event sink if there is one.
This commit is contained in:
mscott%netscape.com 2000-05-03 21:16:22 +00:00
Родитель 823add747f
Коммит 064d2d4d95
2 изменённых файлов: 29 добавлений и 5 удалений

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

@ -31,6 +31,7 @@
#include "nsFileStream.h"
#include "nsINetSupportDialogService.h"
#include "nsIDNSService.h"
#include "nsIMsgStatusFeedback.h"
static NS_DEFINE_CID(kNetSupportDialogCID, NS_NETSUPPORTDIALOG_CID);
static NS_DEFINE_CID(kSocketTransportServiceCID, NS_SOCKETTRANSPORTSERVICE_CID);
@ -57,7 +58,12 @@ nsresult nsMsgProtocol::InitFromURI(nsIURI *aUrl)
nsCOMPtr <nsIMsgMailNewsUrl> mailUrl = do_QueryInterface(aUrl);
if (mailUrl)
{
mailUrl->GetLoadGroup(getter_AddRefs(m_loadGroup));
nsCOMPtr<nsIMsgStatusFeedback> statusFeedback;
mailUrl->GetStatusFeedback(getter_AddRefs(statusFeedback));
mProgressEventSink = do_QueryInterface(statusFeedback);
}
return NS_OK;
}
@ -542,14 +548,28 @@ NS_IMETHODIMP nsMsgProtocol::GetLoadGroup(nsILoadGroup * *aLoadGroup)
NS_IMETHODIMP
nsMsgProtocol::GetNotificationCallbacks(nsIInterfaceRequestor* *aNotificationCallbacks)
{
NS_NOTREACHED("GetNotificationCallbacks");
return NS_ERROR_NOT_IMPLEMENTED;
*aNotificationCallbacks = mCallbacks.get();
NS_IF_ADDREF(*aNotificationCallbacks);
return NS_OK;
}
NS_IMETHODIMP
nsMsgProtocol::SetNotificationCallbacks(nsIInterfaceRequestor* aNotificationCallbacks)
{
return NS_OK; // don't fail when trying to set this
nsresult rv = NS_OK;
mCallbacks = aNotificationCallbacks;
// Verify that the event sink is http
if (mCallbacks)
{
nsCOMPtr<nsIProgressEventSink> progressSink;
(void)mCallbacks->GetInterface(NS_GET_IID(nsIProgressEventSink),
getter_AddRefs(progressSink));
// only replace our current progress event sink if we were given a new one..
if (progressSink) mProgressEventSink = progressSink;
}
return NS_OK;
}

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

@ -31,6 +31,8 @@
#include "nsILoadGroup.h"
#include "nsCOMPtr.h"
#include "nsIFileSpec.h"
#include "nsIInterfaceRequestor.h"
#include "nsIProgressEventSink.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,
@ -69,7 +71,7 @@ protected:
// 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, const char *connectionType); // open a connection on this url
virtual nsresult OpenNetworkSocketWithInfo(const char * aHostName, PRInt32 aGetPort, const char *connectionType); // open a connection with a specific host and port
virtual nsresult OpenNetworkSocketWithInfo(const char * aHostName, PRInt32 aGetPort, const char *connectionType); // open a connection with a specific host and port
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
@ -90,7 +92,7 @@ protected:
// stream, etc).
virtual PRInt32 SendData(nsIURI * aURL, const char * dataBuffer);
virtual nsresult PostMessage(nsIURI* url, nsIFileSpec * fileSpec);
virtual nsresult PostMessage(nsIURI* url, nsIFileSpec * fileSpec);
virtual nsresult InitFromURI(nsIURI *aUrl);
@ -113,6 +115,8 @@ protected:
nsCOMPtr<nsISupports> m_channelContext;
nsCOMPtr<nsILoadGroup> m_loadGroup;
nsLoadFlags mLoadAttributes;
nsCOMPtr<nsIProgressEventSink> mProgressEventSink;
nsCOMPtr<nsIInterfaceRequestor> mCallbacks;
};
#endif /* nsMsgProtocol_h__ */