зеркало из https://github.com/mozilla/pjs.git
Converting to module. r=kipp
This commit is contained in:
Родитель
427ac7cca8
Коммит
11efe4dae0
|
@ -16,151 +16,27 @@
|
|||
* Reserved.
|
||||
*/
|
||||
|
||||
|
||||
#include "nsTimerGtk.h"
|
||||
|
||||
#include "nsUnixTimerCIID.h"
|
||||
|
||||
#include "nsIFactory.h"
|
||||
#include "nsIComponentManager.h"
|
||||
#include "nsIServiceManager.h"
|
||||
#include "nsIGenericFactory.h"
|
||||
#include "nsIModule.h"
|
||||
#include "nsCOMPtr.h"
|
||||
|
||||
static NS_DEFINE_CID(kCTimerGtk, NS_TIMER_GTK_CID);
|
||||
static NS_DEFINE_CID(kComponentManagerCID, NS_COMPONENTMANAGER_CID);
|
||||
#include "nsUnixTimerCIID.h"
|
||||
#include "nsTimerGtk.h"
|
||||
|
||||
class nsTimerGtkFactory : public nsIFactory
|
||||
{
|
||||
public:
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
NS_IMETHOD CreateInstance(nsISupports *aOuter,
|
||||
const nsIID &aIID,
|
||||
void **aResult);
|
||||
|
||||
NS_IMETHOD LockFactory(PRBool aLock);
|
||||
|
||||
nsTimerGtkFactory(const nsCID &aClass);
|
||||
virtual ~nsTimerGtkFactory();
|
||||
|
||||
private:
|
||||
nsCID mClassID;
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(nsTimerGtk)
|
||||
|
||||
struct components_t {
|
||||
nsCID cid;
|
||||
nsIGenericFactory::ConstructorProcPtr constructor;
|
||||
const char *progid;
|
||||
const char *description;
|
||||
};
|
||||
|
||||
nsTimerGtkFactory::nsTimerGtkFactory(const nsCID &aClass) :
|
||||
mRefCnt(0),
|
||||
mClassID(aClass)
|
||||
{
|
||||
}
|
||||
|
||||
nsTimerGtkFactory::~nsTimerGtkFactory()
|
||||
{
|
||||
}
|
||||
|
||||
NS_IMPL_ISUPPORTS(nsTimerGtkFactory, nsIFactory::GetIID())
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsTimerGtkFactory::CreateInstance(nsISupports *aOuter,
|
||||
const nsIID &aIID,
|
||||
void **aResult)
|
||||
{
|
||||
if (aResult == nsnull)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
*aResult = nsnull;
|
||||
|
||||
nsISupports *inst = nsnull;
|
||||
|
||||
if (mClassID.Equals(kCTimerGtk))
|
||||
{
|
||||
inst = (nsISupports *)(nsTimerGtk *) new nsTimerGtk();
|
||||
}
|
||||
|
||||
if (inst == nsnull)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
nsresult rv = inst->QueryInterface(aIID, aResult);
|
||||
|
||||
if (rv != NS_OK)
|
||||
delete inst;
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
nsresult nsTimerGtkFactory::LockFactory(PRBool aLock)
|
||||
static components_t components[] =
|
||||
{
|
||||
// Not implemented in simplest case.
|
||||
return NS_OK;
|
||||
}
|
||||
{ NS_TIMER_GTK_CID, &nsTimerGtkConstructor, "component://netscape/timer/unix/gtk", "GTK timer", },
|
||||
};
|
||||
|
||||
nsresult
|
||||
NSGetFactory(nsISupports* servMgr,
|
||||
const nsCID &aClass,
|
||||
const char *aClassName,
|
||||
const char *aProgID,
|
||||
nsIFactory **aFactory)
|
||||
{
|
||||
if (nsnull == aFactory) {
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
}
|
||||
NS_IMPL_MODULE(components)
|
||||
NS_IMPL_NSGETMODULE(nsModule)
|
||||
|
||||
*aFactory = new nsTimerGtkFactory(aClass);
|
||||
|
||||
if (nsnull == aFactory) {
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
return (*aFactory)->QueryInterface(nsIFactory::GetIID(), (void**)aFactory);
|
||||
|
||||
}
|
||||
|
||||
PRBool
|
||||
NSCanUnload(nsISupports* aServMgr)
|
||||
{
|
||||
return PR_FALSE;
|
||||
}
|
||||
|
||||
nsresult
|
||||
NSRegisterSelf(nsISupports* aServMgr, const char *fullpath)
|
||||
{
|
||||
nsresult rv;
|
||||
|
||||
#ifdef NS_DEBUG
|
||||
printf("*** Registering GTK timer\n");
|
||||
#endif
|
||||
|
||||
nsCOMPtr<nsIServiceManager>
|
||||
serviceManager(do_QueryInterface(aServMgr, &rv));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
NS_WITH_SERVICE(nsIComponentManager, compMgr, kComponentManagerCID, &rv);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
rv = compMgr->RegisterComponent(kCTimerGtk,
|
||||
"GTK timer",
|
||||
"component://netscape/timer/unix/gtk",
|
||||
fullpath,
|
||||
PR_TRUE,
|
||||
PR_TRUE);
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
nsresult
|
||||
NSUnregisterSelf(nsISupports* aServMgr, const char *fullpath)
|
||||
{
|
||||
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsIServiceManager>
|
||||
serviceManager(do_QueryInterface(aServMgr, &rv));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
NS_WITH_SERVICE(nsIComponentManager, compMgr, kComponentManagerCID, &rv);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
compMgr->UnregisterComponent(kCTimerGtk, fullpath);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче