server.cpp revision 3fa054c0038fc8f6731129def4437296b773918f
e379fc6d7f79163700290d92ce75deb4f3005301jerenkrantz * XPCOM server process start point
e379fc6d7f79163700290d92ce75deb4f3005301jerenkrantz * Copyright (C) 2006-2007 innotek GmbH
6ca0e6973c8176100f4a426444823ae5e777e28fsascha * This file is part of VirtualBox Open Source Edition (OSE), as
6ca0e6973c8176100f4a426444823ae5e777e28fsascha * available from http://www.virtualbox.org. This file is free software;
6ca0e6973c8176100f4a426444823ae5e777e28fsascha * you can redistribute it and/or modify it under the terms of the GNU
6ca0e6973c8176100f4a426444823ae5e777e28fsascha * General Public License as published by the Free Software Foundation,
6ca0e6973c8176100f4a426444823ae5e777e28fsascha * in version 2 as it comes in the "COPYING" file of the VirtualBox OSE
6ca0e6973c8176100f4a426444823ae5e777e28fsascha * distribution. VirtualBox OSE is distributed in the hope that it will
6ca0e6973c8176100f4a426444823ae5e777e28fsascha * be useful, but WITHOUT ANY WARRANTY of any kind.
6ca0e6973c8176100f4a426444823ae5e777e28fsascha * If you received this file as part of a commercial VirtualBox
6ca0e6973c8176100f4a426444823ae5e777e28fsascha * distribution, then only the terms of your commercial VirtualBox
6ca0e6973c8176100f4a426444823ae5e777e28fsascha * license agreement apply instead of the previous paragraph.
0d9c389e9c63d02edb068917d49af2fa8012af91marc// for nsMyFactory
6ca0e6973c8176100f4a426444823ae5e777e28fsascha// for the signal handler
a7d224ab99ed0a9b2b7fee9db6ac231fb7e02b0bfuankg// for the backtrace signal handler
105475009f541187ba7a14a367547d9404c578befielding/////////////////////////////////////////////////////////////////////////////
105475009f541187ba7a14a367547d9404c578befielding// VirtualBox component instantiation
105475009f541187ba7a14a367547d9404c578befielding/////////////////////////////////////////////////////////////////////////////
6ca0e6973c8176100f4a426444823ae5e777e28fsascha// implement nsISupports parts of our objects with support for nsIClassInfo
6ca0e6973c8176100f4a426444823ae5e777e28fsaschaNS_IMPL_THREADSAFE_ISUPPORTS1_CI(VirtualBox, IVirtualBox)
a736bac16e58d5e96945f35ee3c43a2cd2f5d37ejerenkrantzNS_IMPL_THREADSAFE_ISUPPORTS1_CI(Machine, IMachine)
6ca0e6973c8176100f4a426444823ae5e777e28fsaschaNS_IMPL_THREADSAFE_ISUPPORTS2_CI(SessionMachine, IMachine, IInternalMachineControl)
6ca0e6973c8176100f4a426444823ae5e777e28fsaschaNS_IMPL_THREADSAFE_ISUPPORTS1_CI(SnapshotMachine, IMachine)
96e6cafca226a8a2a64a7bbdc634b5b2679c9e0csaschaNS_IMPL_THREADSAFE_ISUPPORTS2_CI(HVirtualDiskImage, IHardDisk, IVirtualDiskImage)
22ad84685642948ad15cc1e881ecbc4ac8cbf98cmanojNS_IMPL_THREADSAFE_ISUPPORTS2_CI(HISCSIHardDisk, IHardDisk, IISCSIHardDisk)
22ad84685642948ad15cc1e881ecbc4ac8cbf98cmanojNS_IMPL_THREADSAFE_ISUPPORTS2_CI(HVMDKImage, IHardDisk, IVMDKImage)
22ad84685642948ad15cc1e881ecbc4ac8cbf98cmanojNS_IMPL_THREADSAFE_ISUPPORTS1_CI(HardDiskAttachment, IHardDiskAttachment)
aa811cad2eb3fc01d17a5c8eba274b915ab8cd20manojNS_IMPL_THREADSAFE_ISUPPORTS1_CI(CombinedProgress, IProgress)
aa811cad2eb3fc01d17a5c8eba274b915ab8cd20manojNS_IMPL_THREADSAFE_ISUPPORTS1_CI(FloppyDrive, IFloppyDrive)
aa811cad2eb3fc01d17a5c8eba274b915ab8cd20manojNS_IMPL_THREADSAFE_ISUPPORTS1_CI(SharedFolder, ISharedFolder)
e6b0215ca481b00d658a0adfea378c36a67aa088trawickNS_IMPL_THREADSAFE_ISUPPORTS1_CI(VRDPServer, IVRDPServer)
aa811cad2eb3fc01d17a5c8eba274b915ab8cd20manojNS_IMPL_THREADSAFE_ISUPPORTS1_CI(FloppyImage, IFloppyImage)
b9e4a86f22b3e8666186b9fe08e9241cdaf50d26manojNS_IMPL_THREADSAFE_ISUPPORTS1_CI(HostDVDDrive, IHostDVDDrive)
aa811cad2eb3fc01d17a5c8eba274b915ab8cd20manojNS_IMPL_THREADSAFE_ISUPPORTS1_CI(HostFloppyDrive, IHostFloppyDrive)
708fec3f1a67942d7ee00b8c57fb0aa4fb40dde2kbrandNS_IMPL_THREADSAFE_ISUPPORTS1_CI(GuestOSType, IGuestOSType)
708fec3f1a67942d7ee00b8c57fb0aa4fb40dde2kbrandNS_IMPL_THREADSAFE_ISUPPORTS1_CI(NetworkAdapter, INetworkAdapter)
708fec3f1a67942d7ee00b8c57fb0aa4fb40dde2kbrandNS_IMPL_THREADSAFE_ISUPPORTS1_CI(SerialPort, ISerialPort)
6ca0e6973c8176100f4a426444823ae5e777e28fsaschaNS_IMPL_THREADSAFE_ISUPPORTS1_CI(USBController, IUSBController)
6ca0e6973c8176100f4a426444823ae5e777e28fsaschaNS_IMPL_THREADSAFE_ISUPPORTS1_CI(USBDeviceFilter, IUSBDeviceFilter)
6ca0e6973c8176100f4a426444823ae5e777e28fsaschaNS_IMPL_THREADSAFE_ISUPPORTS2_CI(HostUSBDevice, IUSBDevice, IHostUSBDevice)
708fec3f1a67942d7ee00b8c57fb0aa4fb40dde2kbrandNS_IMPL_THREADSAFE_ISUPPORTS1_CI(HostUSBDeviceFilter, IHostUSBDeviceFilter)
0af3a77b888861a190b1701079a96469f323e661rbbNS_IMPL_THREADSAFE_ISUPPORTS1_CI(AudioAdapter, IAudioAdapter)
6ca0e6973c8176100f4a426444823ae5e777e28fsaschaNS_IMPL_THREADSAFE_ISUPPORTS1_CI(SystemProperties, ISystemProperties)
6ca0e6973c8176100f4a426444823ae5e777e28fsaschaNS_IMPL_THREADSAFE_ISUPPORTS1_CI(BIOSSettings, IBIOSSettings)
6ca0e6973c8176100f4a426444823ae5e777e28fsascha// collections and enumerators
708fec3f1a67942d7ee00b8c57fb0aa4fb40dde2kbrandCOM_IMPL_READONLY_ENUM_AND_COLLECTION(HardDiskAttachment)
708fec3f1a67942d7ee00b8c57fb0aa4fb40dde2kbrandCOM_IMPL_READONLY_ENUM_AND_COLLECTION(USBDeviceFilter)
cb5d3f2f217d457dada4883addb1dc9f3f17bb85fieldingCOM_IMPL_READONLY_ENUM_AND_COLLECTION(HostUSBDeviceFilter)
6ca0e6973c8176100f4a426444823ae5e777e28fsaschaCOM_IMPL_READONLY_ENUM_AND_COLLECTION_AS(Progress, IProgress)
6ca0e6973c8176100f4a426444823ae5e777e28fsaschaCOM_IMPL_READONLY_ENUM_AND_COLLECTION_AS(IfaceUSBDevice, IUSBDevice)
6ca0e6973c8176100f4a426444823ae5e777e28fsascha////////////////////////////////////////////////////////////////////////////////
6ca0e6973c8176100f4a426444823ae5e777e28fsascha /* Delay before shutting down the VirtualBox server after the last
6ca0e6973c8176100f4a426444823ae5e777e28fsascha * VirtualBox instance is released, in ms */
6ca0e6973c8176100f4a426444823ae5e777e28fsaschastatic bool gAutoShutdown = false;
6ca0e6973c8176100f4a426444823ae5e777e28fsascha/////////////////////////////////////////////////////////////////////////////
d52ef6a778f70aae633080afeb3b8668005a07c7jerenkrantz * Simple but smart PLEvent wrapper.
6ca0e6973c8176100f4a426444823ae5e777e28fsascha * @note Instances must be always created with <tt>operator new</tt>!
319fab7d7f9b50ff1e6403b44a51c09f9a594cdbsf * Posts this event to the given message queue. This method may only be
319fab7d7f9b50ff1e6403b44a51c09f9a594cdbsf * called once. @note On success, the event will be deleted automatically
319fab7d7f9b50ff1e6403b44a51c09f9a594cdbsf * after it is delivered and handled. On failure, the event will delete
319fab7d7f9b50ff1e6403b44a51c09f9a594cdbsf * itself before this method returns! The caller must not delete it in
319fab7d7f9b50ff1e6403b44a51c09f9a594cdbsf * either case.
319fab7d7f9b50ff1e6403b44a51c09f9a594cdbsf delete this;
0af58edfee6112cc3399e0e693340e525b96ab1ctrawick virtual void *handler() = 0;
0af58edfee6112cc3399e0e693340e525b96ab1ctrawick static void *PR_CALLBACK eventHandler (PLEvent *self)
0af58edfee6112cc3399e0e693340e525b96ab1ctrawick return reinterpret_cast <Ev *> (self)->that->handler();
0af58edfee6112cc3399e0e693340e525b96ab1ctrawick static void PR_CALLBACK eventDestructor (PLEvent *self)
0af58edfee6112cc3399e0e693340e525b96ab1ctrawick////////////////////////////////////////////////////////////////////////////////
0af58edfee6112cc3399e0e693340e525b96ab1ctrawick * VirtualBox class factory that destroys the created instance right after
cbe7e2406bb76d2182ef7065f0a4064a8ad65631trawick * the last reference to it is released by the client, and recreates it again
cbe7e2406bb76d2182ef7065f0a4064a8ad65631trawick * when necessary (so VirtualBox acts like a singleton object).
0af58edfee6112cc3399e0e693340e525b96ab1ctrawick printf ("Informational: VirtualBox object deleted.\n");
0af58edfee6112cc3399e0e693340e525b96ab1ctrawick /* we overload Release() to guarantee the VirtualBox destructor is
047cb8df15a408e0c0c6125c4a351b35aa3c6e82sf * always called on the main thread */
a299403a6661753a93f4e4f476946c0de4e11311trawick /* the last reference held by clients is being released
a299403a6661753a93f4e4f476946c0de4e11311trawick * (see GetInstance()) */
6ca0e6973c8176100f4a426444823ae5e777e28fsascha /* sTimes is null if this call originates from
39a5e6b885a8705613e73c368e063547ec2bf813sf * FactoryDestructor() */
2c294c31addd5c957bafe6e78c4a30d423ad6e80rbb LogFlowFunc (("Last VirtualBox instance was released.\n"));
2c294c31addd5c957bafe6e78c4a30d423ad6e80rbb LogFlowFunc (("Scheduling server shutdown in %d ms...\n",
2c294c31addd5c957bafe6e78c4a30d423ad6e80rbb /* make sure the previous timer (if any) is stopped;
0368b03c62a6bd2af3b5c2077fdb2257032aebf6sf * otherwise RTTimerStart() will definitely fail. */
d0211374a981173d4537e3f919c708b5f64040fcgstein int vrc = RTTimerStart (sTimer, uint64_t (VBoxSVC_ShutdownDelay) * 1000000);
39a5e6b885a8705613e73c368e063547ec2bf813sf "on XPCOM shutdown.\n"));
6ca0e6973c8176100f4a426444823ae5e777e28fsascha /* Failed to start the timer, post the shutdown event
6ca0e6973c8176100f4a426444823ae5e777e28fsascha * manually if not on the main thread alreay. */
739cc2257378b5b9092669d142dbf5d41b6f75b7trawick /* Here we come if:
e68a106d8ca66ed58b44bca438b13838ddd4f2b8sf * a) gEventQ is 0 which means either FactoryDestructor() is called
e68a106d8ca66ed58b44bca438b13838ddd4f2b8sf * or the IPC/DCONNECT shutdown sequence is initiated by the
0a2212da6843659e65c378c5201e6612be625731sf * XPCOM shutdown routine (NS_ShutdownXPCOM()), which always
e68a106d8ca66ed58b44bca438b13838ddd4f2b8sf * happens on the main thread.
739cc2257378b5b9092669d142dbf5d41b6f75b7trawick * b) gEventQ has reported we're on the main thread. This means
739cc2257378b5b9092669d142dbf5d41b6f75b7trawick * that DestructEventHandler() has been called, but another
e68a106d8ca66ed58b44bca438b13838ddd4f2b8sf * client was faster and requested VirtualBox again.
d0bec559bdc255b6bfc91251d24c5ea9a10e1b75rjung * In either case, there is nothing to do.
2c294c31addd5c957bafe6e78c4a30d423ad6e80rbb * Note: case b) is actually no more valid since we don't
2c294c31addd5c957bafe6e78c4a30d423ad6e80rbb * call Release() from DestructEventHandler() in this case
212c401808586d1fecd0e639ec1697229674a151sf * any more. Thus, we assert below.
d0211374a981173d4537e3f919c708b5f64040fcgstein /* called on the main thread */
d0211374a981173d4537e3f919c708b5f64040fcgstein /* stop accepting GetInstance() requests on other threads during
855aa233fcb7b51d738fca5c36585646ae1960c3jerenkrantz * possible destruction */
f0845d140b11c340e910322f5fb4469bf5c98092sf /* sInstance is NULL here if it was deleted immediately after
f0845d140b11c340e910322f5fb4469bf5c98092sf * creation due to initialization error. See GetInstance(). */
f0845d140b11c340e910322f5fb4469bf5c98092sf /* Release the guard reference added in GetInstance() */
f0845d140b11c340e910322f5fb4469bf5c98092sf /* make it leave the event loop */
6ca0e6973c8176100f4a426444823ae5e777e28fsascha /* This condition is quite rare: a new client will have to
d0bec559bdc255b6bfc91251d24c5ea9a10e1b75rjung * connect after this event has been posted to the main queue
6ca0e6973c8176100f4a426444823ae5e777e28fsascha * but before it started to process it. */
df349d5fc2ae7d106b058fe779c7ea4d19ee0588trawick LogFlowFunc (("Destruction is canceled (refcnt=%d).\n", count));
521fc51bdadd21ae8cc2f4a8b354c5fe424a037csf static void ShutdownTimer (PRTTIMER pTimer, void *pvUser)
164141857c02667118df04b14fe536d1756f0ef4jorton /* A "too late" event is theoretically possible if somebody
164141857c02667118df04b14fe536d1756f0ef4jorton * manually ended the server after a destruction has been scheduled
164141857c02667118df04b14fe536d1756f0ef4jorton * and this method was so lucky that it got a chance to run before
164141857c02667118df04b14fe536d1756f0ef4jorton * the timer was killed. */
a91a466a0d812a522d492c3c182163f73591ca20aaron /* post a quit event to the main queue */
d0bec559bdc255b6bfc91251d24c5ea9a10e1b75rjung /* A failure above means we've been already stopped (for example
d0bec559bdc255b6bfc91251d24c5ea9a10e1b75rjung * by Ctrl-C). FactoryDestructor() (NS_ShutdownXPCOM())
d0bec559bdc255b6bfc91251d24c5ea9a10e1b75rjung * will do the job. Nothing to do. */
d0bec559bdc255b6bfc91251d24c5ea9a10e1b75rjung /* create a critsect to protect object construction */
d0211374a981173d4537e3f919c708b5f64040fcgstein int vrc = RTTimerCreateEx (&sTimer, 0, 0, ShutdownTimer, NULL);
c71458c4b81237e414c1c774a80da14fe22c52b4jorton LogFlowFunc (("Failed to create a timer! (vrc=%Vrc)\n", vrc));
212c401808586d1fecd0e639ec1697229674a151sf /* Either posting a destruction event falied for some reason (most
212c401808586d1fecd0e639ec1697229674a151sf * likely, the quit event has been received before the last release),
d0211374a981173d4537e3f919c708b5f64040fcgstein * or the client has terminated abnormally w/o releasing its
d0211374a981173d4537e3f919c708b5f64040fcgstein * VirtualBox instance (so NS_ShutdownXPCOM() is doing a cleanup).
d0211374a981173d4537e3f919c708b5f64040fcgstein * Release the guard reference we added in GetInstance(). */
d0bec559bdc255b6bfc91251d24c5ea9a10e1b75rjung LogFlowFunc (("Creating new VirtualBox object...\n"));
7bfe076b680e6e591add6cdc754ce9a6910682a2sascha /* make an extra AddRef to take the full control
7bfe076b680e6e591add6cdc754ce9a6910682a2sascha * on the VirtualBox destruction (see FinalRelease()) */
7bfe076b680e6e591add6cdc754ce9a6910682a2sascha printf ("Informational: VirtualBox object created (rc=%08X).\n", rv);
4281cf6a722c99ae21394dc2000bd48efcebdb3akbrand /* On failure diring VirtualBox initialization, delete it
11ce1f263fdd8812189b85930874943f9fa81bd5fielding * immediately on the current thread by releasing all
4281cf6a722c99ae21394dc2000bd48efcebdb3akbrand * references in order to properly schedule the server
4281cf6a722c99ae21394dc2000bd48efcebdb3akbrand * shutdown. Since the object is fully deleted here, there
11ce1f263fdd8812189b85930874943f9fa81bd5fielding * is a chance to fix the error and request a new
4281cf6a722c99ae21394dc2000bd48efcebdb3akbrand * instantiation before the server terminates. However,
4281cf6a722c99ae21394dc2000bd48efcebdb3akbrand * the main reason to maintain the shoutdown delay on
8c2ac56b3654234237ca3a943407361c45a3a4d1sf * failure is to let the front-end completely fetch error
292707b9868335763d6f2bb74a263134eeeb8cadkbrand * info from a server-side IVirtualBoxErrorInfo object. */
708fec3f1a67942d7ee00b8c57fb0aa4fb40dde2kbrand /* On success, make sure the previous timer is stopped to
4281cf6a722c99ae21394dc2000bd48efcebdb3akbrand * cancel a scheduled server termination (if any). */
92a2439559cf1161742650ed9c50c6483bd029cemadhum LogFlowFunc (("Using existing VirtualBox object...\n"));
cda405bd389d0b9a161ba98f4a10caeebd24d7dfkbrand LogFlowFunc (("Another client has requested a reference to VirtualBox, "
cda405bd389d0b9a161ba98f4a10caeebd24d7dfkbrand "canceling detruction...\n"));
cda405bd389d0b9a161ba98f4a10caeebd24d7dfkbrand /* make sure the previous timer is stopped */
cda405bd389d0b9a161ba98f4a10caeebd24d7dfkbrand /* Don't be confused that sInstance is of the *ClassFactory type. This is
cda405bd389d0b9a161ba98f4a10caeebd24d7dfkbrand * actually a singleton instance (*ClassFactory inherits the singleton
cda405bd389d0b9a161ba98f4a10caeebd24d7dfkbrand * class; we combined them just for "simplicity" and used "static" for
708fec3f1a67942d7ee00b8c57fb0aa4fb40dde2kbrand * factory methods. *ClassFactory here is necessary for a couple of extra
708fec3f1a67942d7ee00b8c57fb0aa4fb40dde2kbrand * methods. */
cda405bd389d0b9a161ba98f4a10caeebd24d7dfkbrandVirtualBoxClassFactory *VirtualBoxClassFactory::sInstance = 0;
cda405bd389d0b9a161ba98f4a10caeebd24d7dfkbrand////////////////////////////////////////////////////////////////////////////////
cda405bd389d0b9a161ba98f4a10caeebd24d7dfkbrandtypedef NSFactoryDestructorProcPtr NSFactoryConsructorProcPtr;
8c2ac56b3654234237ca3a943407361c45a3a4d1sf * Enhanced module component information structure.
183fa93e80381d4a172fde145fc796b3f6906f4cwrowe * nsModuleComponentInfo lacks the factory construction callback,
4281cf6a722c99ae21394dc2000bd48efcebdb3akbrand * here we add it. This callback is called by NS_NewMyFactory() after
ac0c8366f49659958162b4bfb3d625a77343eda3kbrand * a nsMyFactory instance is successfully created.
4281cf6a722c99ae21394dc2000bd48efcebdb3akbrand /** (optional) Factory Construction Callback */
92a2439559cf1161742650ed9c50c6483bd029cemadhum////////////////////////////////////////////////////////////////////////////////
047cb8df15a408e0c0c6125c4a351b35aa3c6e82sf "VirtualBox component",
047cb8df15a408e0c0c6125c4a351b35aa3c6e82sf VirtualBoxClassFactory::FactoryDestructor, // factory destructor function
047cb8df15a408e0c0c6125c4a351b35aa3c6e82sf 0, // flags
047cb8df15a408e0c0c6125c4a351b35aa3c6e82sf VirtualBoxClassFactory::FactoryConstructor // factory constructor function
047cb8df15a408e0c0c6125c4a351b35aa3c6e82sf/////////////////////////////////////////////////////////////////////////////
047cb8df15a408e0c0c6125c4a351b35aa3c6e82sf * Generic component factory.
047cb8df15a408e0c0c6125c4a351b35aa3c6e82sf * The code below is stolen from nsGenericFactory.h / nsGenericFactory.cpp,
047cb8df15a408e0c0c6125c4a351b35aa3c6e82sf * because we get a segmentation fault for some unknown reason when VBoxSVC
047cb8df15a408e0c0c6125c4a351b35aa3c6e82sf * starts up (somewhere during the initialization of the libipcdc.so module)
047cb8df15a408e0c0c6125c4a351b35aa3c6e82sf * when we just reference XPCOM's NS_NewGenericFactory() from here (i.e. even
047cb8df15a408e0c0c6125c4a351b35aa3c6e82sf * before actually calling it) and run VBoxSVC using the debug XPCOM
047cb8df15a408e0c0c6125c4a351b35aa3c6e82sf * libraries.
047cb8df15a408e0c0c6125c4a351b35aa3c6e82sf * Actually, I know why, but I find it too stupid even to discuss.
047cb8df15a408e0c0c6125c4a351b35aa3c6e82sfclass nsMyFactory : public nsIGenericFactory, public nsIClassInfo {
047cb8df15a408e0c0c6125c4a351b35aa3c6e82sf /* nsIGenericFactory methods */
265e9c84e4ee23f41ac25622f8b8b3f481bbf281jorton NS_IMETHOD SetComponentInfo(const nsModuleComponentInfo *info);
265e9c84e4ee23f41ac25622f8b8b3f481bbf281jorton NS_IMETHOD GetComponentInfo(const nsModuleComponentInfo **infop);
265e9c84e4ee23f41ac25622f8b8b3f481bbf281jorton NS_IMETHOD CreateInstance(nsISupports *aOuter, REFNSIID aIID, void **aResult);
265e9c84e4ee23f41ac25622f8b8b3f481bbf281jorton static NS_METHOD Create(nsISupports* outer, const nsIID& aIID, void* *aInstancePtr);
265e9c84e4ee23f41ac25622f8b8b3f481bbf281jortonnsMyFactory::nsMyFactory(const nsModuleComponentInfo *info)
265e9c84e4ee23f41ac25622f8b8b3f481bbf281jorton *mInfo->mClassInfoGlobal = NS_STATIC_CAST(nsIClassInfo *, this);
9d432e23f6025b78322cbee43e8e89262a108e5eaaronNS_IMETHODIMP nsMyFactory::CreateInstance(nsISupports *aOuter,
9d432e23f6025b78322cbee43e8e89262a108e5eaaron // XXX do we care if (mInfo->mFlags & THREADSAFE)?
9d432e23f6025b78322cbee43e8e89262a108e5eaaronNS_IMETHODIMP nsMyFactory::GetInterfaces(PRUint32 *countp,
cb6310f4ea253e5706c71958b0943f142cbda667jortonNS_IMETHODIMP nsMyFactory::GetHelperForLanguage(PRUint32 language,
cb6310f4ea253e5706c71958b0943f142cbda667jorton return mInfo->mGetLanguageHelperProc(language, helper);
cb6310f4ea253e5706c71958b0943f142cbda667jortonNS_IMETHODIMP nsMyFactory::GetContractID(char **aContractID)
cb6310f4ea253e5706c71958b0943f142cbda667jorton *aContractID = (char *)nsMemory::Alloc(strlen(mInfo->mContractID) + 1);
cb6310f4ea253e5706c71958b0943f142cbda667jortonNS_IMETHODIMP nsMyFactory::GetClassDescription(char * *aClassDescription)
cb6310f4ea253e5706c71958b0943f142cbda667jortonNS_IMETHODIMP nsMyFactory::GetClassID(nsCID * *aClassID)
e36cfe8caf074cce72f1e4136894608665b7fbd8colmNS_IMETHODIMP nsMyFactory::GetClassIDNoAlloc(nsCID *aClassID)
0b083c7f392e96303fc8aee44571631964778b7cjimNS_IMETHODIMP nsMyFactory::GetImplementationLanguage(PRUint32 *langp)
65f6e321663b3fd0f93d8b47b4df05f189de6cf1sf// nsIGenericFactory: component-info accessors
65f6e321663b3fd0f93d8b47b4df05f189de6cf1sfNS_IMETHODIMP nsMyFactory::SetComponentInfo(const nsModuleComponentInfo *info)
65f6e321663b3fd0f93d8b47b4df05f189de6cf1sf *mInfo->mClassInfoGlobal = NS_STATIC_CAST(nsIClassInfo *, this);
65f6e321663b3fd0f93d8b47b4df05f189de6cf1sfNS_IMETHODIMP nsMyFactory::GetComponentInfo(const nsModuleComponentInfo **infop)
b8f1ab8691c3c3aad22102f6926dde31b7e45db9sfNS_METHOD nsMyFactory::Create(nsISupports* outer, const nsIID& aIID, void* *aInstancePtr)
b8f1ab8691c3c3aad22102f6926dde31b7e45db9sf // sorry, aggregation not spoken here.
b8f1ab8691c3c3aad22102f6926dde31b7e45db9sf * Instantiates a new factory and calls
b8f1ab8691c3c3aad22102f6926dde31b7e45db9sf * nsMyModuleComponentInfo::mFactoryConstructor.
return rv;
return rv;
static nsresult
factory);
return rc;
void *handler()
if (pszPidFile)
return NULL;
#if defined(USE_BACKTRACE)
* the code is taken from http://www.linuxjournal.com/article/6391.
int i, trace_size = 0;
exit (0);
bool fDaemonize = false;
gAutoShutdown = true;
fDaemonize = true;
fDaemonize = true;
#ifdef __OS2__
if (fDaemonize)
if (childpid != 0)
bool fSuccess = false;
fSuccess = true;
if (sid < 0)
#if defined(USE_BACKTRACE)
RTR3Init(false);
int iSize;
for (int i=iSize; i>0; i--)
#ifdef DEBUG
for (int i=iSize; i>0; i--)
if (fDaemonize)
#ifndef __OS2__
if (pszPidFile)
while (gKeepRunning)
if (pszPidFile)
if (fDaemonize)
#ifndef __OS2__