Part of making news a stand alone dll. Updates to nntp url to inherit from nsIMsgMailNewsUrl.Add url listener code as well.

This commit is contained in:
mscott%netscape.com 1999-03-26 01:01:15 +00:00
Родитель 5f87931f1e
Коммит 1321dd9d85
2 изменённых файлов: 70 добавлений и 9 удалений

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

@ -37,6 +37,7 @@
// that doesn't allow you to call ::nsISupports::GetIID() inside of a class
// that multiply inherits from nsISupports
static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID);
static NS_DEFINE_CID(kUrlListenerManagerCID, NS_URLLISTENERMANAGER_CID);
nsNntpUrl::nsNntpUrl(nsISupports* aContainer, nsIURLGroup* aGroup)
{
@ -65,11 +66,16 @@ nsNntpUrl::nsNntpUrl(nsISupports* aContainer, nsIURLGroup* aGroup)
m_container = aContainer;
NS_IF_ADDREF(m_container);
// ParseURL(aSpec, aURL); // XXX whh
m_runningUrl = PR_FALSE;
m_urlListeners = nsnull;
nsComponentManager::CreateInstance(kUrlListenerManagerCID, nsnull, nsIUrlListenerManager::GetIID(),
(void **) &m_urlListeners);
}
nsNntpUrl::~nsNntpUrl()
{
NS_IF_RELEASE(m_urlListeners);
NS_IF_RELEASE(m_container);
NS_IF_RELEASE(m_newsHost);
NS_IF_RELEASE(m_articleList);
@ -258,6 +264,53 @@ nsresult nsNntpUrl::GetNewsgroupList (nsINNTPNewsgroupList ** newsgroupList) con
return NS_OK;
}
// url listener registration details...
NS_IMETHODIMP nsNntpUrl::RegisterListener (nsIUrlListener * aUrlListener)
{
NS_LOCK_INSTANCE();
nsresult rv = NS_OK;
if (m_urlListeners)
rv = m_urlListeners->RegisterListener(aUrlListener);
NS_UNLOCK_INSTANCE();
return rv;
}
NS_IMETHODIMP nsNntpUrl::UnRegisterListener (nsIUrlListener * aUrlListener)
{
NS_LOCK_INSTANCE();
nsresult rv = NS_OK;
if (m_urlListeners)
rv = m_urlListeners->UnRegisterListener(aUrlListener);
NS_UNLOCK_INSTANCE();
return rv;
}
NS_IMETHODIMP nsNntpUrl::GetUrlState(PRBool * aRunningUrl)
{
NS_LOCK_INSTANCE();
if (aRunningUrl)
*aRunningUrl = m_runningUrl;
NS_UNLOCK_INSTANCE();
return NS_OK;
}
NS_IMETHODIMP nsNntpUrl::SetUrlState(PRBool aRunningUrl, nsresult aExitCode)
{
NS_LOCK_INSTANCE();
m_runningUrl = aRunningUrl;
if (m_urlListeners)
{
if (m_runningUrl)
m_urlListeners->OnStartRunningUrl(this);
else
m_urlListeners->OnStopRunningUrl(this, aExitCode);
}
NS_UNLOCK_INSTANCE();
return NS_OK;
}
nsresult nsNntpUrl::SetErrorMessage (char * errorMessage)
{
NS_LOCK_INSTANCE();

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

@ -20,16 +20,23 @@
#define nsNntpUrl_h__
#include "nsINntpUrl.h"
#include "nsIUrlListenerManager.h"
#include "nsINetlibURL.h" /* this should be temporary until Network N2 project lands */
#include "nsINNTPNewsgroupPost.h"
class nsNntpUrl : public nsINntpUrl, public nsINetlibURL
{
public:
// from nsIURL:
// nsIMsgMailNewsUrl interface
NS_IMETHOD SetUrlState(PRBool aRunningUrl, nsresult aExitCode);
NS_IMETHOD GetUrlState(PRBool * aRunningUrl);
// mscott: some of these we won't need to implement..as part of the netlib re-write we'll be removing them
// from nsIURL and then we can remove them from here as well....
NS_IMETHOD SetErrorMessage (char * errorMessage);
NS_IMETHOD GetErrorMessage (char ** errorMessage) const; // caller must free using PR_Free
NS_IMETHOD RegisterListener (nsIUrlListener * aUrlListener);
NS_IMETHOD UnRegisterListener (nsIUrlListener * aUrlListener);
// nsIURL
NS_IMETHOD_(PRBool) Equals(const nsIURL *aURL) const;
NS_IMETHOD GetSpec(const char* *result) const;
NS_IMETHOD SetSpec(const char* spec);
@ -78,14 +85,10 @@ public:
NS_IMETHOD SetNewsgroupList (nsINNTPNewsgroupList * newsgroupList);
NS_IMETHOD GetNewsgroupList (nsINNTPNewsgroupList ** newsgroupList) const;
NS_IMETHOD SetErrorMessage (char * errorMessage);
// caller must free using PR_FREE
NS_IMETHOD GetErrorMessage (char ** errorMessage) const;
NS_IMETHOD SetMessageToPost(nsINNTPNewsgroupPost *post);
NS_IMETHOD GetMessageToPost(nsINNTPNewsgroupPost **post);
// nsNntpUrl
// nsNntpUrl
nsNntpUrl(nsISupports* aContainer, nsIURLGroup* aGroup);
NS_DECL_ISUPPORTS
@ -107,8 +110,13 @@ protected:
char *m_search;
char *m_errorMessage;
PRBool m_runningUrl;
nsINNTPNewsgroupPost *m_newsgroupPost;
// manager of all of current url listeners....
nsIUrlListenerManager * m_urlListeners;
PRInt32 m_port;
nsISupports* m_container;