VirtualBox

source: vbox/trunk/src/VBox/Main/linux/module.cpp@ 977

Last change on this file since 977 was 436, checked in by vboxsync, 18 years ago

Main: Added USBDevice to the DeviceType enum to provide USB device activity (search for USB_DEVICE_ACTIVITY in ConsoleImpl.cpp). Thanks to MS COM C++ bingings polluting the global namespace with enum values, I had to rename the USBDevice class to OUSBDevice (and to add the COM_DECL_READONLY_ENUM_AND_COLLECTION_EX_BEGIN macro for even more flexible collection declarations).

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 4.7 KB
Line 
1/** @file
2 *
3 * XPCOM module implementation functions
4 */
5
6/*
7 * Copyright (C) 2006 InnoTek Systemberatung GmbH
8 *
9 * This file is part of VirtualBox Open Source Edition (OSE), as
10 * available from http://www.virtualbox.org. This file is free software;
11 * you can redistribute it and/or modify it under the terms of the GNU
12 * General Public License as published by the Free Software Foundation,
13 * in version 2 as it comes in the "COPYING" file of the VirtualBox OSE
14 * distribution. VirtualBox OSE is distributed in the hope that it will
15 * be useful, but WITHOUT ANY WARRANTY of any kind.
16 *
17 * If you received this file as part of a commercial VirtualBox
18 * distribution, then only the terms of your commercial VirtualBox
19 * license agreement apply instead of the previous paragraph.
20 */
21
22#include <nsIGenericFactory.h>
23#include <VirtualBox_XPCOM.h>
24
25#include <GuestImpl.h>
26#include <KeyboardImpl.h>
27#include <MouseImpl.h>
28#include <DisplayImpl.h>
29#include <MachineDebuggerImpl.h>
30#include <USBDeviceImpl.h>
31#include <RemoteUSBDeviceImpl.h>
32#include <SharedFolderImpl.h>
33#include <FramebufferImpl.h>
34#include <ProgressImpl.h>
35#include <NetworkAdapterImpl.h>
36
37#include <SessionImpl.h>
38#include <ConsoleImpl.h>
39#include <ConsoleVRDPServer.h>
40
41// XPCOM glue code unfolding
42
43NS_DECL_CLASSINFO(Guest)
44NS_IMPL_THREADSAFE_ISUPPORTS1_CI(Guest, IGuest)
45NS_DECL_CLASSINFO(Keyboard)
46NS_IMPL_THREADSAFE_ISUPPORTS1_CI(Keyboard, IKeyboard)
47NS_DECL_CLASSINFO(Mouse)
48NS_IMPL_THREADSAFE_ISUPPORTS1_CI(Mouse, IMouse)
49NS_DECL_CLASSINFO(Display)
50NS_IMPL_THREADSAFE_ISUPPORTS1_CI(Display, IDisplay)
51NS_DECL_CLASSINFO(MachineDebugger)
52NS_IMPL_THREADSAFE_ISUPPORTS1_CI(MachineDebugger, IMachineDebugger)
53NS_DECL_CLASSINFO(InternalFramebuffer)
54NS_IMPL_THREADSAFE_ISUPPORTS1_CI(InternalFramebuffer, IFramebuffer)
55NS_DECL_CLASSINFO(Progress)
56NS_IMPL_THREADSAFE_ISUPPORTS1_CI(Progress, IProgress)
57NS_DECL_CLASSINFO(CombinedProgress)
58NS_IMPL_THREADSAFE_ISUPPORTS1_CI(CombinedProgress, IProgress)
59NS_DECL_CLASSINFO(OUSBDevice)
60NS_IMPL_THREADSAFE_ISUPPORTS1_CI(OUSBDevice, IUSBDevice)
61NS_DECL_CLASSINFO(RemoteUSBDevice)
62NS_IMPL_THREADSAFE_ISUPPORTS1_CI(RemoteUSBDevice, IHostUSBDevice)
63NS_DECL_CLASSINFO(SharedFolder)
64NS_IMPL_THREADSAFE_ISUPPORTS1_CI(SharedFolder, ISharedFolder)
65NS_DECL_CLASSINFO(RemoteDisplayInfo)
66NS_IMPL_THREADSAFE_ISUPPORTS1_CI(RemoteDisplayInfo, IRemoteDisplayInfo)
67
68NS_DECL_CLASSINFO(Session)
69NS_IMPL_THREADSAFE_ISUPPORTS2_CI(Session, ISession, IInternalSessionControl)
70NS_DECL_CLASSINFO(Console)
71NS_IMPL_THREADSAFE_ISUPPORTS1_CI(Console, IConsole)
72
73COM_IMPL_READONLY_ENUM_AND_COLLECTION_EX(ComObjPtr <OUSBDevice>, IUSBDevice, OUSBDevice)
74COM_IMPL_READONLY_ENUM_AND_COLLECTION_EX(ComObjPtr <RemoteUSBDevice>, IHostUSBDevice, RemoteUSBDevice)
75COM_IMPL_READONLY_ENUM_AND_COLLECTION(SharedFolder)
76
77/**
78 * Singleton class factory that holds the reference to the created instance
79 * (preventing it from being destroyed) until the module is explicitly
80 * unloaded by the XPCOM shutdown code.
81 *
82 * Suitable for IN-PROC components.
83 */
84class SessionClassFactory : public Session
85{
86public:
87 virtual ~SessionClassFactory() {
88 FinalRelease();
89 instance = 0;
90 }
91 static nsresult getInstance (Session **inst) {
92 int rv = NS_OK;
93 if (instance == 0) {
94 instance = new SessionClassFactory();
95 if (instance) {
96 instance->AddRef(); // protect FinalConstruct()
97 rv = instance->FinalConstruct();
98 if (NS_FAILED(rv))
99 instance->Release();
100 else
101 instance->AddRef(); // self-reference
102 } else {
103 rv = NS_ERROR_OUT_OF_MEMORY;
104 }
105 } else {
106 instance->AddRef();
107 }
108 *inst = instance;
109 return rv;
110 }
111 static nsresult releaseInstance () {
112 if (instance)
113 instance->Release();
114 return NS_OK;
115 }
116
117private:
118 static Session *instance;
119};
120
121/** @note this is for singleton; disabled for now */
122//
123//Session *SessionClassFactory::instance = 0;
124//
125//NS_GENERIC_FACTORY_SINGLETON_CONSTRUCTOR_WITH_RC (
126// Session, SessionClassFactory::getInstance
127//)
128
129NS_GENERIC_FACTORY_CONSTRUCTOR_WITH_RC (Session)
130
131static const nsModuleComponentInfo components[] =
132{
133 {
134 "Session component", NS_SESSION_CID, NS_SESSION_CONTRACTID,
135 SessionConstructor,
136 NULL, // registration function
137 NULL, // deregistration function
138/** @note this is for singleton; disabled for now */
139// SessionClassFactory::releaseInstance,
140 NULL, // destructor function
141 NS_CI_INTERFACE_GETTER_NAME(Session),
142 NULL, // language helper
143 &NS_CLASSINFO_NAME(Session)
144 }
145};
146
147NS_IMPL_NSGETMODULE(SessionModule, components)
148
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette