Making it build with new RDF registration mechanism.

This commit is contained in:
warren%netscape.com 1999-02-26 12:24:22 +00:00
parent a80cfd24db
commit f8b67aa56a
23 changed files with 225 additions and 421 deletions

View File

@ -87,6 +87,7 @@ MSGLIBS= \
LLIBS= \
$(MSGLIBS) \
$(DIST)\lib\xpcom32.lib \
$(DIST)\lib\raptorbase.lib \
$(DIST)\lib\xplib.lib \
# $(DIST)\lib\netlib.lib \
$(DIST)\lib\libplc21.lib \
@ -102,7 +103,7 @@ LINCS=$(LINCS) -I, \
-I$(PUBLIC)\mailnews \
-I$(PUBLIC)\pref \
-I$(PUBLIC)\raptor \
-I$(XPDIST)\msg \
-I$(PUBLIC)\rdf \
$(NULL)
#//------------------------------------------------------------------------

View File

@ -22,6 +22,8 @@
#include "nsMsgBaseCID.h"
#include "pratom.h"
#include "nsRepository.h"
#include "rdf.h"
#include "nsCRT.h"
/* Include all of the interfaces our factory can generate components for */
#include "nsIMsgRFC822Parser.h"
@ -42,28 +44,31 @@ public:
// nsISupports methods
NS_DECL_ISUPPORTS
nsMsgFactory(const nsCID &aClass);
nsMsgFactory(const nsCID &aClass, const char* aClassName, const char* aProgID);
// nsIFactory methods
NS_IMETHOD CreateInstance(nsISupports *aOuter, const nsIID &aIID, void **aResult);
NS_IMETHOD LockFactory(PRBool aLock);
// nsIFactory methods
NS_IMETHOD CreateInstance(nsISupports *aOuter, const nsIID &aIID, void **aResult);
NS_IMETHOD LockFactory(PRBool aLock);
protected:
virtual ~nsMsgFactory();
protected:
virtual ~nsMsgFactory();
private:
nsCID mClassID;
nsCID mClassID;
char* mClassName;
char* mProgID;
};
nsMsgFactory::nsMsgFactory(const nsCID &aClass)
nsMsgFactory::nsMsgFactory(const nsCID &aClass, const char* aClassName, const char* aProgID)
: mClassID(aClass), mClassName(nsCRT::strdup(aClassName)), mProgID(nsCRT::strdup(aProgID))
{
NS_INIT_REFCNT();
mClassID = aClass;
}
nsMsgFactory::~nsMsgFactory()
{
NS_ASSERTION(mRefCnt == 0, "non-zero refcnt at destruction");
delete[] mClassName;
delete[] mProgID;
}
nsresult nsMsgFactory::QueryInterface(const nsIID &aIID, void **aResult)
@ -105,20 +110,18 @@ nsresult nsMsgFactory::CreateInstance(nsISupports *aOuter, const nsIID &aIID, vo
// Whenever you add a new class that supports an interface, plug it in here!!!
// do they want an RFC822 Parser interface ?
if (mClassID.Equals(kCMsgRFC822ParserCID))
{
if (mClassID.Equals(kCMsgRFC822ParserCID)) {
res = NS_NewRFC822Parser((nsIMsgRFC822Parser **) &inst);
if (NS_FAILED(res)) // was there a problem creating the object ?
return res;
}
else if(mClassID.Equals(kCMsgFolderEventCID))
{
else if (mClassID.Equals(kCMsgFolderEventCID)) {
NS_NOTREACHED("hello? what happens here?");
return NS_OK;
}
// End of checking the interface ID code....
if (inst)
{
if (inst) {
// so we now have the class that supports the desired interface...we need to turn around and
// query for our desired interface.....
res = inst->QueryInterface(aIID, aResult);
@ -143,53 +146,56 @@ nsresult nsMsgFactory::LockFactory(PRBool aLock)
return NS_OK;
}
////////////////////////////////////////////////////////////////////////////////
// return the proper factory to the caller.
extern "C" NS_EXPORT nsresult NSGetFactory(const nsCID &aClass,
nsISupports *serviceMgr,
extern "C" NS_EXPORT nsresult NSGetFactory(nsISupports* serviceMgr,
const nsCID &aClass,
const char *aClassName,
const char *aProgID,
nsIFactory **aFactory)
{
if (nsnull == aFactory)
return NS_ERROR_NULL_POINTER;
// If we decide to implement multiple factories in the msg.dll, then we need to check the class
// type here and create the appropriate factory instead of always creating a nsMsgFactory...
*aFactory = new nsMsgFactory(aClass);
if (aFactory)
return (*aFactory)->QueryInterface(nsIFactory::IID(), (void**)aFactory); // they want a Factory Interface so give it to them
else
return NS_ERROR_OUT_OF_MEMORY;
*aFactory = new nsMsgFactory(aClass, aClassName, aProgID);
if (aFactory)
return (*aFactory)->QueryInterface(nsIFactory::IID(), (void**)aFactory);
else
return NS_ERROR_OUT_OF_MEMORY;
}
extern "C" NS_EXPORT PRBool NSCanUnload()
extern "C" NS_EXPORT PRBool NSCanUnload(nsISupports* serviceMgr)
{
return PRBool(g_InstanceCount == 0 && g_LockCount == 0);
return PRBool(g_InstanceCount == 0 && g_LockCount == 0);
}
////////////////////////////////////////////////////////////////////////////////
extern "C" NS_EXPORT nsresult
NSRegisterSelf(nsISupports* serviceMgr, const char* path)
{
nsresult rv;
// register the message folder factory
rv = nsRepository::RegisterComponent(kCMsgFolderEventCID,
nsnull, nsnull,
path, PR_TRUE, PR_TRUE);
if (NS_FAILED(rv)) return rv;
return rv;
}
extern "C" NS_EXPORT nsresult
NSRegisterSelf(const char* path)
NSUnregisterSelf(nsISupports* serviceMgr, const char* path)
{
nsresult ret;
nsresult rv;
ret = nsRepository::RegisterFactory(kCMsgFolderEventCID, path, PR_TRUE,
PR_TRUE);
if (NS_FAILED(ret)) {
return ret;
}
rv = nsRepository::UnregisterComponent(kCMsgFolderEventCID, path);
if (NS_FAILED(rv)) return rv;
return ret;
return rv;
}
extern "C" NS_EXPORT nsresult
NSUnregisterSelf(const char* path)
{
nsresult ret;
ret = nsRepository::UnregisterFactory(kCMsgFolderEventCID, path);
if (NS_FAILED(ret)) {
return ret;
}
return ret;
}
////////////////////////////////////////////////////////////////////////////////

View File

@ -32,8 +32,8 @@
// that multiply inherits from nsISupports
static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID);
nsMsgFolder::nsMsgFolder(const char* uri)
: nsRDFResource(uri), mFlags(0),
nsMsgFolder::nsMsgFolder(void)
: nsRDFResource(), mFlags(0),
mNumUnreadMessages(-1), mNumTotalMessages(0),
mCsid(0),
mDepth(0),
@ -59,7 +59,7 @@ nsMsgFolder::nsMsgFolder(const char* uri)
mIsCachable = TRUE;
}
nsMsgFolder::~nsMsgFolder()
nsMsgFolder::~nsMsgFolder(void)
{
if(mSubFolders)
{

View File

@ -39,8 +39,8 @@
class nsMsgFolder: public nsRDFResource, public nsIMsgFolder
{
public:
nsMsgFolder(const char* uri);
virtual ~nsMsgFolder();
nsMsgFolder(void);
virtual ~nsMsgFolder(void);
NS_DECL_ISUPPORTS
@ -306,6 +306,4 @@ protected:
};
PR_EXTERN(nsresult) NS_NewRDFMsgFolderResourceFactory(nsIRDFResourceFactory** aResult);
#endif

View File

@ -28,14 +28,14 @@
// that multiply inherits from nsISupports
static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID);
nsMsgImapMailFolder::nsMsgImapMailFolder(const char* uri, nsString& name)
: nsMsgFolder(uri /*, name */)
nsMsgImapMailFolder::nsMsgImapMailFolder(nsString& name)
: nsMsgFolder(/*name*/)
{
mHaveReadNameFromDB = PR_FALSE;
mPathName = nsnull;
}
nsMsgImapMailFolder::~nsMsgImapMailFolder()
nsMsgImapMailFolder::~nsMsgImapMailFolder(void)
{
}

View File

@ -30,8 +30,8 @@
class nsMsgImapMailFolder : public nsMsgFolder, public nsIMsgImapMailFolder
{
public:
nsMsgImapMailFolder(const char* uri, nsString& name);
~nsMsgImapMailFolder();
nsMsgImapMailFolder(nsString& name);
~nsMsgImapMailFolder(void);
NS_DECL_ISUPPORTS

View File

@ -1,132 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1999 Netscape Communications Corporation. All Rights
* Reserved.
*/
#include "msgCore.h" // precompiled header...
#include "nsMsgRDFFolder.h"
#include "nsIRDFResourceFactory.h"
#include "prmem.h"
#include "plstr.h"
nsMsgRDFFolder::nsMsgRDFFolder(const char* uri)
: nsRDFResource(uri), mFolder(nsnull)
{
}
nsMsgRDFFolder::~nsMsgRDFFolder()
{
NS_IF_RELEASE(mFolder);
}
NS_IMPL_ADDREF(nsMsgRDFFolder)
NS_IMPL_RELEASE(nsMsgRDFFolder)
NS_IMETHODIMP
nsMsgRDFFolder::QueryInterface(REFNSIID iid, void** result)
{
if (! result)
return NS_ERROR_NULL_POINTER;
*result = nsnull;
if (iid.Equals(nsIMsgRDFFolder::IID())) {
*result = NS_STATIC_CAST(nsIMsgRDFFolder*, this);
AddRef();
return NS_OK;
}
return nsRDFResource::QueryInterface(iid, result);
}
NS_IMETHODIMP nsMsgRDFFolder::GetFolder(nsIMsgFolder * *aFolder)
{
if(!aFolder)
return NS_ERROR_NULL_POINTER;
NS_ADDREF(mFolder);
*aFolder = mFolder;
return NS_OK;
}
NS_IMETHODIMP nsMsgRDFFolder::SetFolder(nsIMsgFolder * aFolder)
{
if(aFolder)
{
NS_ADDREF(aFolder);
if(mFolder)
NS_RELEASE(mFolder);
mFolder = aFolder;
}
return NS_OK;
}
/**
* This class creates resources for message folder URIs. It should be
* registered for the "mailnewsfolder:" prefix.
*/
class nsMsgFolderResourceFactoryImpl : public nsIRDFResourceFactory
{
public:
nsMsgFolderResourceFactoryImpl(void);
virtual ~nsMsgFolderResourceFactoryImpl(void);
NS_DECL_ISUPPORTS
NS_IMETHOD CreateResource(const char* aURI, nsIRDFResource** aResult);
};
nsMsgFolderResourceFactoryImpl::nsMsgFolderResourceFactoryImpl(void)
{
NS_INIT_REFCNT();
}
nsMsgFolderResourceFactoryImpl::~nsMsgFolderResourceFactoryImpl(void)
{
}
NS_IMPL_ISUPPORTS(nsMsgFolderResourceFactoryImpl, nsIRDFResourceFactory::IID());
NS_IMETHODIMP
nsMsgFolderResourceFactoryImpl::CreateResource(const char* aURI, nsIRDFResource** aResult)
{
if (! aResult)
return NS_ERROR_NULL_POINTER;
nsMsgRDFFolder *folder = new nsMsgRDFFolder(aURI);
if (! folder)
return NS_ERROR_OUT_OF_MEMORY;
folder->QueryInterface(nsIRDFResource::IID(), (void**)aResult);
return NS_OK;
}
nsresult
NS_NewRDFMsgFolderResourceFactory(nsIRDFResourceFactory** aResult)
{
if (! aResult)
return NS_ERROR_NULL_POINTER;
nsMsgFolderResourceFactoryImpl* factory =
new nsMsgFolderResourceFactoryImpl();
if (! factory)
return NS_ERROR_OUT_OF_MEMORY;
NS_ADDREF(factory);
*aResult = factory;
return NS_OK;
}

View File

@ -1,36 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1999 Netscape Communications Corporation. All Rights
* Reserved.
*/
#include "nsIMsgRDFFolder.h"
class nsMsgRDFFolder : public nsRDFResource, public nsIMsgRDFFolder
{
public:
NS_DECL_ISUPPORTS
// nsIMsgRDFFolder methods:
NS_IMETHOD GetFolder(nsIMsgFolder * *aFolder);
NS_IMETHOD SetFolder(nsIMsgFolder * aFolder);
// nsMsgRDFFolder methods:
nsMsgRDFFolder(const char* uri);
virtual ~nsMsgRDFFolder();
protected:
nsIMsgFolder *mFolder;
};

View File

@ -175,8 +175,10 @@ nsresult nsMsgComposeFactory::LockFactory(PRBool aLock)
}
// return the proper factory to the caller.
extern "C" NS_EXPORT nsresult NSGetFactory(const nsCID &aClass,
nsISupports *serviceMgr,
extern "C" NS_EXPORT nsresult NSGetFactory(nsISupports* serviceMgr,
const nsCID &aClass,
const char *aClassName,
const char *aProgID,
nsIFactory **aFactory)
{
if (nsnull == aFactory)
@ -192,12 +194,12 @@ extern "C" NS_EXPORT nsresult NSGetFactory(const nsCID &aClass,
return NS_ERROR_OUT_OF_MEMORY;
}
extern "C" NS_EXPORT PRBool NSCanUnload()
extern "C" NS_EXPORT PRBool NSCanUnload(nsISupports* serviceMgr)
{
return PRBool(g_InstanceCount == 0 && g_LockCount == 0);
}
extern "C" NS_EXPORT nsresult NSRegisterSelf(const char* path)
extern "C" NS_EXPORT nsresult NSRegisterSelf(nsISupports* serviceMgr, const char* path)
{
nsresult ret;
@ -210,7 +212,7 @@ extern "C" NS_EXPORT nsresult NSRegisterSelf(const char* path)
}
extern "C" NS_EXPORT nsresult
NSUnregisterSelf(const char* path)
NSUnregisterSelf(nsISupports* serviceMgr, const char* path)
{
nsresult ret;
@ -220,4 +222,4 @@ NSUnregisterSelf(const char* path)
ret = nsRepository::UnregisterFactory(kCMsgSendCID, path);
return ret;
}
}

View File

@ -45,7 +45,7 @@ nsMsgHdr::QueryInterface(REFNSIID iid, void** result)
}
nsMsgHdr::nsMsgHdr(nsMsgDatabase *db, nsIMdbRow *dbRow)
: nsRDFResource(nsnull)
: nsRDFResource()
{
NS_INIT_REFCNT();
m_mdb = db;

View File

@ -39,6 +39,8 @@ CPP_OBJS=\
LLIBS=\
$(DIST)\lib\xpcom32.lib \
$(DIST)\lib\msgcore.lib \
$(DIST)\lib\msgdb.lib \
$(DIST)\lib\msglocal.lib \
$(LIBNSPR) \
$(DIST)\lib\libplc21.lib \
@ -55,6 +57,7 @@ LINCS= -I$(DEPTH)\mailnews\local\src \
-I$(PUBLIC)\mailnews \
-I$(PUBLIC)\raptor \
-I$(PUBLIC)\rdf \
-I$(PUBLIC)\rdfutil \
-I$(PUBLIC)\netlib \
$(NULL)

View File

@ -23,9 +23,20 @@
#include "nsIFactory.h"
#include "nsRepository.h"
#define NS_MSGLOCALDATASOURCE_CID \
{ /* 992732A0-CABC-11d2-94BE-006097222B83 */ \
0x992732a0, 0xcabc, 0x11d2, \
{0x94, 0xbe, 0x0, 0x60, 0x97, 0x22, 0x2b, 0x83}}
#define NS_MAILNEWSDATASOURCE_CID \
{ /* ddd9d2b2-cd67-11d2-8cca-0060b0fc14a3 */ \
0xddd9d2b2, \
0xcd67, \
0x11d2, \
{0x8c, 0xca, 0x00, 0x60, 0xb0, 0xfc, 0x14, 0xa3} \
}
#define NS_MAILNEWSRESOURCE_CID \
{ /* e490d22c-cd67-11d2-8cca-0060b0fc14a3 */ \
0xe490d22c, \
0xcd67, \
0x11d2, \
{0x8c, 0xca, 0x00, 0x60, 0xb0, 0xfc, 0x14, 0xa3} \
}
#endif // nsMsgLocal_h__

View File

@ -22,19 +22,17 @@
#include "nsISupports.h"
#include "nsMsgLocalCID.h"
#include "pratom.h"
#include "nsIRDFMSGFolderDataSource.h"
// include files for components this factory creates...
#include "nsIMailboxUrl.h"
#include "nsMailboxUrl.h"
#include "nsIMailboxService.h"
#include "nsMSGFolderDataSource.h"
#include "nsMailboxService.h"
#include "nsLocalMailFolder.h"
static NS_DEFINE_CID(kCMsgLocalFactory, NS_MSGLOCALDATASOURCE_CID);
static NS_DEFINE_CID(kCMailboxUrl, NS_MAILBOXURL_CID);
static NS_DEFINE_CID(kCMailboxService, NS_MAILBOXSERVICE_CID);
static NS_DEFINE_CID(kMailNewsDatasourceCID, NS_MAILNEWSDATASOURCE_CID);
static NS_DEFINE_CID(kMailNewsResourceCID, NS_MAILNEWSRESOURCE_CID);
////////////////////////////////////////////////////////////
//
@ -48,28 +46,31 @@ public:
// nsISupports methods
NS_DECL_ISUPPORTS
nsMsgLocalFactory(const nsCID &aClass);
nsMsgLocalFactory(const nsCID &aClass, const char* aClassName, const char* aProgID);
// nsIFactory methods
NS_IMETHOD CreateInstance(nsISupports *aOuter, const nsIID &aIID, void **aResult);
NS_IMETHOD LockFactory(PRBool aLock);
// nsIFactory methods
NS_IMETHOD CreateInstance(nsISupports *aOuter, const nsIID &aIID, void **aResult);
NS_IMETHOD LockFactory(PRBool aLock);
protected:
virtual ~nsMsgLocalFactory();
protected:
virtual ~nsMsgLocalFactory();
private:
nsCID mClassID;
nsCID mClassID;
char* mClassName;
char* mProgID;
};
nsMsgLocalFactory::nsMsgLocalFactory(const nsCID &aClass)
nsMsgLocalFactory::nsMsgLocalFactory(const nsCID &aClass, const char* aClassName, const char* aProgID)
: mClassID(aClass), mClassName(nsCRT::strdup(aClassName)), mProgID(nsCRT::strdup(aProgID))
{
NS_INIT_REFCNT();
mClassID = aClass;
}
nsMsgLocalFactory::~nsMsgLocalFactory()
{
NS_ASSERTION(mRefCnt == 0, "non-zero refcnt at destruction");
delete[] mClassName;
delete[] mProgID;
}
nsresult nsMsgLocalFactory::QueryInterface(const nsIID &aIID, void **aResult)
@ -98,7 +99,7 @@ NS_IMPL_RELEASE(nsMsgLocalFactory)
nsresult nsMsgLocalFactory::CreateInstance(nsISupports *aOuter, const nsIID &aIID, void **aResult)
{
nsresult res = NS_OK;
nsresult rv = NS_OK;
if (aResult == NULL)
return NS_ERROR_NULL_POINTER;
@ -111,37 +112,26 @@ nsresult nsMsgLocalFactory::CreateInstance(nsISupports *aOuter, const nsIID &aII
// Whenever you add a new class that supports an interface, plug it in here!!!
// do they want a local datasource ?
if (mClassID.Equals(kCMsgLocalFactory))
{
res = NS_NewRDFMSGFolderDataSource((nsIRDFDataSource **) &inst);
if (mClassID.Equals(kCMailboxUrl)) {
inst = NS_STATIC_CAST(nsIMailboxUrl*, new nsMailboxUrl(nsnull, nsnull));
}
if (mClassID.Equals(kCMailboxUrl))
{
nsMailboxUrl * mailboxUrl = new nsMailboxUrl(nsnull, nsnull);
if (mailboxUrl) // turn it into any ol' interface so we pick up a ref count on inst...
res = mailboxUrl->QueryInterface(nsIMailboxUrl::IID(), (void **) &inst);
else if (mClassID.Equals(kCMailboxService)) {
inst = new nsMailboxService();
}
else if (mClassID.Equals(kMailNewsDatasourceCID)) {
inst = new nsMSGFolderDataSource();
}
else if (mClassID.Equals(kMailNewsResourceCID)) {
inst = NS_STATIC_CAST(nsIMsgLocalMailFolder*, new nsMsgLocalMailFolder());
}
if (mClassID.Equals(kCMailboxService))
{
nsMailboxService * mailboxService = new nsMailboxService();
if (mailboxService)
res = mailboxService->QueryInterface(nsIMailboxService::IID(), (void **) &inst);
}
if (inst == nsnull)
return NS_ERROR_OUT_OF_MEMORY;
// End of checking the interface ID code....
if (NS_SUCCEEDED(res) && inst)
{
// so we now have the class that supports the desired interface...we need to turn around and
// query for our desired interface.....
res = inst->QueryInterface(aIID, aResult);
NS_RELEASE(inst); // release our extra ref count....
if (NS_FAILED(res)) // if the query interface failed for some reason, then the object did not get ref counted...delete it.
delete inst;
}
return res;
rv = inst->QueryInterface(aIID, aResult);
if (NS_FAILED(rv))
delete inst;
return rv;
}
nsresult nsMsgLocalFactory::LockFactory(PRBool aLock)
@ -156,8 +146,10 @@ nsresult nsMsgLocalFactory::LockFactory(PRBool aLock)
}
// return the proper factory to the caller.
extern "C" NS_EXPORT nsresult NSGetFactory(const nsCID &aClass,
nsISupports *serviceMgr,
extern "C" NS_EXPORT nsresult NSGetFactory(nsISupports* serviceMgr,
const nsCID &aClass,
const char *aClassName,
const char *aProgID,
nsIFactory **aFactory)
{
if (nsnull == aFactory)
@ -165,7 +157,7 @@ extern "C" NS_EXPORT nsresult NSGetFactory(const nsCID &aClass,
// If we decide to implement multiple factories in the msg.dll, then we need to check the class
// type here and create the appropriate factory instead of always creating a nsMsgFactory...
*aFactory = new nsMsgLocalFactory(aClass);
*aFactory = new nsMsgLocalFactory(aClass, aClassName, aProgID);
if (aFactory)
return (*aFactory)->QueryInterface(nsIFactory::IID(), (void**)aFactory); // they want a Factory Interface so give it to them
@ -173,32 +165,58 @@ extern "C" NS_EXPORT nsresult NSGetFactory(const nsCID &aClass,
return NS_ERROR_OUT_OF_MEMORY;
}
extern "C" NS_EXPORT PRBool NSCanUnload()
extern "C" NS_EXPORT PRBool NSCanUnload(nsISupports* serviceMgr)
{
return PRBool(g_InstanceCount == 0 && g_LockCount == 0);
}
extern "C" NS_EXPORT nsresult
NSRegisterSelf(const char* path)
NSRegisterSelf(nsISupports* serviceMgr, const char* path)
{
nsresult ret;
nsresult rv;
ret = nsRepository::RegisterFactory(kCMsgLocalFactory, path, PR_TRUE, PR_TRUE);
ret = nsRepository::RegisterFactory(kCMailboxUrl, path, PR_TRUE, PR_TRUE);
ret = nsRepository::RegisterFactory(kCMailboxService, path, PR_TRUE, PR_TRUE);
rv = nsRepository::RegisterComponent(kCMailboxUrl, nsnull, nsnull,
path, PR_TRUE, PR_TRUE);
if (NS_FAILED(rv)) return rv;
return ret;
rv = nsRepository::RegisterComponent(kCMailboxService, nsnull, nsnull,
path, PR_TRUE, PR_TRUE);
if (NS_FAILED(rv)) return rv;
// register our RDF datasources:
rv = nsRepository::RegisterComponent(kMailNewsDatasourceCID,
"Mail/News Data Source",
NS_RDF_DATASOURCE_PROGID_PREFIX "mailnews",
path, PR_TRUE, PR_TRUE);
if (NS_FAILED(rv)) return rv;
// register our RDF resource factories:
rv = nsRepository::RegisterComponent(kMailNewsResourceCID,
"Mail/News Resource Factory",
NS_RDF_RESOURCE_FACTORY_PROGID_PREFIX "mailbox",
path, PR_TRUE, PR_TRUE);
if (NS_FAILED(rv)) return rv;
return rv;
}
extern "C" NS_EXPORT nsresult
NSUnregisterSelf(const char* path)
NSUnregisterSelf(nsISupports* serviceMgr, const char* path)
{
nsresult ret;
nsresult rv;
ret = nsRepository::UnregisterFactory(kCMsgLocalFactory, path);
ret = nsRepository::UnregisterFactory(kCMailboxUrl, path);
ret = nsRepository::UnregisterFactory(kCMailboxService, path);
rv = nsRepository::UnregisterFactory(kCMailboxUrl, path);
if (NS_FAILED(rv)) return rv;
return ret;
rv = nsRepository::UnregisterFactory(kCMailboxService, path);
if (NS_FAILED(rv)) return rv;
rv = nsRepository::UnregisterComponent(kMailNewsDatasourceCID, path);
if (NS_FAILED(rv)) return rv;
rv = nsRepository::UnregisterComponent(kMailNewsResourceCID, path);
if (NS_FAILED(rv)) return rv;
return rv;
}

View File

@ -21,7 +21,6 @@
#include "nsLocalMailFolder.h"
#include "nsMsgFolderFlags.h"
#include "prprf.h"
#include "nsIRDFResourceFactory.h"
#include "nsISupportsArray.h"
#include "nsIPref.h"
#include "nsIServiceManager.h"
@ -138,15 +137,15 @@ nsURI2Name(char* uriStr, nsString& name)
////////////////////////////////////////////////////////////////////////////////
nsMsgLocalMailFolder::nsMsgLocalMailFolder(const char* uri)
: nsMsgFolder(uri), mPath(nsnull), mExpungedBytes(0),
nsMsgLocalMailFolder::nsMsgLocalMailFolder(void)
: nsMsgFolder(), mPath(nsnull), mExpungedBytes(0),
mHaveReadNameFromDB(PR_FALSE), mGettingMail(PR_FALSE),
mInitialized(PR_FALSE)
{
NS_INIT_REFCNT();
}
nsMsgLocalMailFolder::~nsMsgLocalMailFolder()
nsMsgLocalMailFolder::~nsMsgLocalMailFolder(void)
{
}
@ -227,15 +226,19 @@ nsMsgLocalMailFolder::CreateSubFolders(void)
uri.Append('/');
}
*/
#if 0
uri.Append(currentFolderName);
char* uriStr = uri.ToNewCString();
if (uriStr == nsnull) {
rv = NS_ERROR_OUT_OF_MEMORY;
goto done;
}
#endif
// XXX trim off .sbd from uriStr
nsMsgLocalMailFolder* folder = new nsMsgLocalMailFolder(uriStr);
nsMsgLocalMailFolder* folder = new nsMsgLocalMailFolder(/*uriStr*/);
#if 0
delete[] uriStr;
#endif
if (folder == nsnull) {
rv = NS_ERROR_OUT_OF_MEMORY;
goto done;
@ -937,61 +940,3 @@ NS_IMETHODIMP nsMsgLocalMailFolder::GetPath(nsFileSpec& aPathName)
return NS_OK;
}
////////////////////////////////////////////////////////////////////////////////
/**
* This class creates resources for message folder URIs. It should be
* registered for the "mailnewsfolder:" prefix.
*/
class nsMsgFolderResourceFactoryImpl : public nsIRDFResourceFactory
{
public:
nsMsgFolderResourceFactoryImpl(void);
virtual ~nsMsgFolderResourceFactoryImpl(void);
NS_DECL_ISUPPORTS
NS_IMETHOD CreateResource(const char* aURI, nsIRDFResource** aResult);
};
nsMsgFolderResourceFactoryImpl::nsMsgFolderResourceFactoryImpl(void)
{
NS_INIT_REFCNT();
}
nsMsgFolderResourceFactoryImpl::~nsMsgFolderResourceFactoryImpl(void)
{
}
NS_IMPL_ISUPPORTS(nsMsgFolderResourceFactoryImpl, nsIRDFResourceFactory::IID());
NS_IMETHODIMP
nsMsgFolderResourceFactoryImpl::CreateResource(const char* aURI, nsIRDFResource** aResult)
{
if (! aResult)
return NS_ERROR_NULL_POINTER;
nsMsgLocalMailFolder *folder = new nsMsgLocalMailFolder(aURI);
if (! folder)
return NS_ERROR_OUT_OF_MEMORY;
folder->QueryInterface(nsIRDFResource::IID(), (void**)aResult);
return NS_OK;
}
nsresult
NS_NewRDFMsgFolderResourceFactory(nsIRDFResourceFactory** aResult)
{
if (! aResult)
return NS_ERROR_NULL_POINTER;
nsMsgFolderResourceFactoryImpl* factory =
new nsMsgFolderResourceFactoryImpl();
if (! factory)
return NS_ERROR_OUT_OF_MEMORY;
NS_ADDREF(factory);
*aResult = factory;
return NS_OK;
}

View File

@ -32,8 +32,8 @@
class nsMsgLocalMailFolder : public nsMsgFolder, public nsIMsgLocalMailFolder
{
public:
nsMsgLocalMailFolder(const char* uri);
virtual ~nsMsgLocalMailFolder();
nsMsgLocalMailFolder(void);
virtual ~nsMsgLocalMailFolder(void);
NS_DECL_ISUPPORTS
#if 0

View File

@ -67,18 +67,12 @@ DEFINE_RDF_VOCAB(NC_NAMESPACE_URI, NC, Folder);
DEFINE_RDF_VOCAB(NC_NAMESPACE_URI, NC, Subject);
extern nsresult NS_NewRDFMsgFolderResourceFactory(nsIRDFResourceFactory** aInstancePtrResult);
////////////////////////////////////////////////////////////////////////
// The RDF service manager. Cached in the address book data source's
// constructor
static nsIRDFService* gRDFService = nsnull;
////////////////////////////////////////////////////////////////////////
// THE address book source.
static nsMSGFolderDataSource* gMsgFolderDataSource = nsnull;
////////////////////////////////////////////////////////////////////////
// Utilities
@ -148,8 +142,6 @@ nsMSGFolderDataSource::nsMSGFolderDataSource()
(nsISupports**) &gRDFService);
PR_ASSERT(NS_SUCCEEDED(rv));
gMsgFolderDataSource = this;
}
nsMSGFolderDataSource::~nsMSGFolderDataSource (void)
@ -173,8 +165,6 @@ nsMSGFolderDataSource::~nsMSGFolderDataSource (void)
NS_RELEASE2(kNC_Subject, refcnt);
gMsgFolderDataSource = nsnull;
nsServiceManager::ReleaseService(kRDFServiceCID, gRDFService);
gRDFService = nsnull;
}
@ -323,8 +313,7 @@ NS_IMETHODIMP nsMSGFolderDataSource::GetTargets(nsIRDFResource* source,
folder->GetSubFolders(&subFolders);
nsRDFEnumeratorAssertionCursor* cursor =
new nsRDFEnumeratorAssertionCursor(gMsgFolderDataSource,
source, kNC_Child, subFolders);
new nsRDFEnumeratorAssertionCursor(this, source, kNC_Child, subFolders);
NS_IF_RELEASE(subFolders);
if (cursor == nsnull)
return NS_ERROR_OUT_OF_MEMORY;
@ -338,8 +327,7 @@ NS_IMETHODIMP nsMSGFolderDataSource::GetTargets(nsIRDFResource* source,
folder->GetMessages(&messages);
nsRDFEnumeratorAssertionCursor* cursor =
new nsRDFEnumeratorAssertionCursor(gMsgFolderDataSource,
source, kNC_MessageChild, messages);
new nsRDFEnumeratorAssertionCursor(this, source, kNC_MessageChild, messages);
NS_IF_RELEASE(messages);
if (cursor == nsnull)
return NS_ERROR_OUT_OF_MEMORY;
@ -350,8 +338,7 @@ NS_IMETHODIMP nsMSGFolderDataSource::GetTargets(nsIRDFResource* source,
else if(peq(kNC_Name, property))
{
nsRDFSingletonAssertionCursor* cursor =
new nsRDFSingletonAssertionCursor(gMsgFolderDataSource,
source, property);
new nsRDFSingletonAssertionCursor(this, source, property);
if (cursor == nsnull)
return NS_ERROR_OUT_OF_MEMORY;
NS_ADDREF(cursor);
@ -364,8 +351,7 @@ NS_IMETHODIMP nsMSGFolderDataSource::GetTargets(nsIRDFResource* source,
if(peq(kNC_Name, property))
{
nsRDFSingletonAssertionCursor* cursor =
new nsRDFSingletonAssertionCursor(gMsgFolderDataSource,
source, property, PR_FALSE);
new nsRDFSingletonAssertionCursor(this, source, property, PR_FALSE);
if (cursor == nsnull)
return NS_ERROR_OUT_OF_MEMORY;
NS_ADDREF(cursor);
@ -441,7 +427,7 @@ NS_IMETHODIMP nsMSGFolderDataSource::ArcLabelsOut(nsIRDFResource* source,
arcs->AppendElement(kNC_MessageChild);
arcs->AppendElement(kNC_Name);
nsRDFArrayArcsOutCursor* cursor =
new nsRDFArrayArcsOutCursor(gMsgFolderDataSource, source, arcs);
new nsRDFArrayArcsOutCursor(this, source, arcs);
NS_RELEASE(arcs);
if (cursor == nsnull)
return NS_ERROR_OUT_OF_MEMORY;
@ -477,21 +463,3 @@ NS_IMETHODIMP nsMSGFolderDataSource::DoCommand(const char* aCommand,
PR_ASSERT(0);
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_EXPORT nsresult
NS_NewRDFMSGFolderDataSource(nsIRDFDataSource** result)
{
if (! result)
return NS_ERROR_NULL_POINTER;
// Only one mail data source
if (! gMsgFolderDataSource) {
if ((gMsgFolderDataSource = new nsMSGFolderDataSource()) == nsnull)
return NS_ERROR_OUT_OF_MEMORY;
}
NS_ADDREF(gMsgFolderDataSource);
*result = gMsgFolderDataSource;
return NS_OK;
}

View File

@ -115,4 +115,4 @@ protected:
nsresult ParseSearchPart();
};
#endif // nsMailboxUrl_h__
#endif // nsMailboxUrl_h__

View File

@ -148,8 +148,10 @@ nsresult nsMimeFactory::LockFactory(PRBool aLock)
}
// return the proper factory to the caller.
extern "C" NS_EXPORT nsresult NSGetFactory(const nsCID &aClass,
nsISupports *serviceMgr,
extern "C" NS_EXPORT nsresult NSGetFactory(nsISupports* serviceMgr,
const nsCID &aClass,
const char *aClassName,
const char *aProgID,
nsIFactory **aFactory)
{
if (nsnull == aFactory)
@ -166,7 +168,7 @@ extern "C" NS_EXPORT nsresult NSGetFactory(const nsCID &aClass,
}
extern "C" NS_EXPORT PRBool NSCanUnload()
extern "C" NS_EXPORT PRBool NSCanUnload(nsISupports* serviceMgr)
{
return PRBool(g_InstanceCount == 0 && g_LockCount == 0);
}
@ -179,7 +181,7 @@ extern "C" NS_EXPORT PRBool NSCanUnload()
extern NET_StreamClass *MIME_MessageConverter(int format_out, void *closure,
URL_Struct *url, MWContext *context);
extern "C" NS_EXPORT nsresult NSRegisterSelf(const char *path)
extern "C" NS_EXPORT nsresult NSRegisterSelf(nsISupports* serviceMgr, const char *path)
{
printf("*** Mime being registered\n");
nsRepository::RegisterFactory(kCMimeMimeObjectClassAccessCID, path,
@ -197,7 +199,7 @@ extern "C" NS_EXPORT nsresult NSRegisterSelf(const char *path)
return NS_OK;
}
extern "C" NS_EXPORT nsresult NSUnregisterSelf(const char *path)
extern "C" NS_EXPORT nsresult NSUnregisterSelf(nsISupports* serviceMgr, const char *path)
{
printf("*** Mime being unregistered\n");
nsRepository::UnregisterFactory(kCMimeMimeObjectClassAccessCID, path);

View File

@ -273,7 +273,14 @@ nsComposeAppCore::NewMessage()
}
controllerCID = "6B75BB61-BD41-11d2-9D31-00805F8ADDDE";
appShell->CreateTopLevelWindow(url, controllerCID, newWindow, nsnull, 100, 100);
appShell->CreateTopLevelWindow(nsnull, // parent
url,
controllerCID,
newWindow, // result widget
nsnull, // observer
nsnull, // callbacks
100, // width
100); // height
done:
NS_RELEASE(url);
if (nsnull != appShell) {

View File

@ -126,8 +126,10 @@ nsresult nsComposeFactory::LockFactory(PRBool aLock)
// begin DLL exports
//
nsresult
NSGetFactory(const nsCID &aClass,
nsISupports *serviceMgr,
NSGetFactory(nsISupports* serviceMgr,
const nsCID &aClass,
const char *aClassName,
const char *aProgID,
nsIFactory **aFactory)
{
#ifdef DEBUG
@ -147,7 +149,7 @@ NSGetFactory(const nsCID &aClass,
PRBool
NSCanUnload()
NSCanUnload(nsISupports* serviceMgr)
{
#ifdef DEBUG
printf("compose: NSCanUnload()\n");
@ -156,7 +158,7 @@ NSCanUnload()
}
nsresult
NSRegisterSelf(const char *fullpath)
NSRegisterSelf(nsISupports* serviceMgr, const char *fullpath)
{
#ifdef DEBUG
printf("compose: NSRegisterSelf()\n");
@ -166,7 +168,7 @@ NSRegisterSelf(const char *fullpath)
}
nsresult
NSUnregisterSelf(const char *fullpath)
NSUnregisterSelf(nsISupports* serviceMgr, const char *fullpath)
{
#ifdef DEBUG
printf("compose: NSUnregisterSelf()\n");

View File

@ -8,7 +8,7 @@
xmlns:rdf="http://www.w3.org/TR/WD-rdf-syntax#"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<tree datasources="rdf:mailnewsfolder">
<tree datasources="rdf:mailnews">
<treecol rdf:resource="http://home.netscape.com/NC-rdf#Name"/>
<treehead>
<treeitem>

View File

@ -126,8 +126,10 @@ nsresult nsMessengerFactory::LockFactory(PRBool aLock)
// begin DLL exports
//
nsresult
NSGetFactory(const nsCID &aClass,
nsISupports *serviceMgr,
NSGetFactory(nsISupports* serviceMgr,
const nsCID &aClass,
const char *aClassName,
const char *aProgID,
nsIFactory **aFactory)
{
#ifdef DEBUG
@ -147,7 +149,7 @@ NSGetFactory(const nsCID &aClass,
PRBool
NSCanUnload()
NSCanUnload(nsISupports* serviceMgr)
{
#ifdef DEBUG
printf("messenger: NSCanUnload()\n");
@ -156,7 +158,7 @@ NSCanUnload()
}
nsresult
NSRegisterSelf(const char *fullpath)
NSRegisterSelf(nsISupports* serviceMgr, const char *fullpath)
{
#ifdef DEBUG
printf("messenger: NSRegisterSelf()\n");
@ -166,7 +168,7 @@ NSRegisterSelf(const char *fullpath)
}
nsresult
NSUnregisterSelf(const char *fullpath)
NSUnregisterSelf(nsISupports* serviceMgr, const char *fullpath)
{
#ifdef DEBUG
printf("messenger: NSUnregisterSelf()\n");

View File

@ -207,7 +207,14 @@ nsMsgAppCore::Open3PaneWindow()
}
controllerCID = "6B75BB61-BD41-11d2-9D31-00805F8ADDDE";
appShell->CreateTopLevelWindow(url, controllerCID, newWindow, nsnull, 200, 200);
appShell->CreateTopLevelWindow(nsnull, // parent
url,
controllerCID,
newWindow, // result widget
nsnull, // observer
nsnull, // callbacks
200, // width
200); // height
done:
NS_RELEASE(url);
if (nsnull != appShell) {