1 | /** @file
|
---|
2 | *
|
---|
3 | * XPCOM module implementation functions
|
---|
4 | */
|
---|
5 |
|
---|
6 | /*
|
---|
7 | * Copyright (C) 2006-2012 Oracle Corporation
|
---|
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 (GPL) as published by the Free Software
|
---|
13 | * Foundation, in version 2 as it comes in the "COPYING" file of the
|
---|
14 | * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
|
---|
15 | * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
|
---|
16 | */
|
---|
17 |
|
---|
18 | /* Make sure all the stdint.h macros are included - must come first! */
|
---|
19 | #ifndef __STDC_LIMIT_MACROS
|
---|
20 | # define __STDC_LIMIT_MACROS
|
---|
21 | #endif
|
---|
22 | #ifndef __STDC_CONSTANT_MACROS
|
---|
23 | # define __STDC_CONSTANT_MACROS
|
---|
24 | #endif
|
---|
25 |
|
---|
26 | #include <nsIGenericFactory.h>
|
---|
27 |
|
---|
28 | // generated file
|
---|
29 | #include "VirtualBox_XPCOM.h"
|
---|
30 |
|
---|
31 | #include "AdditionsFacilityImpl.h"
|
---|
32 | #include "ConsoleImpl.h"
|
---|
33 | #include "ConsoleVRDPServer.h"
|
---|
34 | #include "DisplayImpl.h"
|
---|
35 | #ifdef VBOX_WITH_EXTPACK
|
---|
36 | # include "ExtPackManagerImpl.h"
|
---|
37 | #endif
|
---|
38 | #include "GuestImpl.h"
|
---|
39 | #ifdef VBOX_WITH_GUEST_CONTROL
|
---|
40 | # include "GuestDirectoryImpl.h"
|
---|
41 | # include "GuestFileImpl.h"
|
---|
42 | # include "GuestFsObjInfoImpl.h"
|
---|
43 | # include "GuestProcessImpl.h"
|
---|
44 | # include "GuestSessionImpl.h"
|
---|
45 | #endif
|
---|
46 | #include "KeyboardImpl.h"
|
---|
47 | #include "MachineDebuggerImpl.h"
|
---|
48 | #include "MouseImpl.h"
|
---|
49 | #include "NATEngineImpl.h"
|
---|
50 | #include "NetworkAdapterImpl.h"
|
---|
51 | #include "ProgressCombinedImpl.h"
|
---|
52 | #include "ProgressImpl.h"
|
---|
53 | #include "RemoteUSBDeviceImpl.h"
|
---|
54 | #include "SessionImpl.h"
|
---|
55 | #include "SharedFolderImpl.h"
|
---|
56 | #include "USBDeviceImpl.h"
|
---|
57 | #include "VirtualBoxClientImpl.h"
|
---|
58 |
|
---|
59 | #include "Logging.h"
|
---|
60 |
|
---|
61 | // XPCOM glue code unfolding
|
---|
62 |
|
---|
63 | NS_DECL_CLASSINFO(Guest)
|
---|
64 | NS_IMPL_THREADSAFE_ISUPPORTS1_CI(Guest, IGuest)
|
---|
65 | #ifdef VBOX_WITH_GUEST_CONTROL
|
---|
66 | NS_DECL_CLASSINFO(GuestDirectory)
|
---|
67 | NS_IMPL_THREADSAFE_ISUPPORTS2_CI(GuestDirectory, IGuestDirectory, IDirectory)
|
---|
68 | NS_DECL_CLASSINFO(GuestFile)
|
---|
69 | NS_IMPL_THREADSAFE_ISUPPORTS2_CI(GuestFile, IGuestFile, IFile)
|
---|
70 | NS_DECL_CLASSINFO(GuestFsObjInfo)
|
---|
71 | NS_IMPL_THREADSAFE_ISUPPORTS2_CI(GuestFsObjInfo, IGuestFsObjInfo, IFsObjInfo)
|
---|
72 | NS_DECL_CLASSINFO(GuestProcess)
|
---|
73 | NS_IMPL_THREADSAFE_ISUPPORTS2_CI(GuestProcess, IGuestProcess, IProcess)
|
---|
74 | NS_DECL_CLASSINFO(GuestSession)
|
---|
75 | NS_IMPL_THREADSAFE_ISUPPORTS1_CI(GuestSession, IGuestSession)
|
---|
76 | #endif
|
---|
77 | NS_DECL_CLASSINFO(Keyboard)
|
---|
78 | NS_IMPL_THREADSAFE_ISUPPORTS1_CI(Keyboard, IKeyboard)
|
---|
79 | NS_DECL_CLASSINFO(Mouse)
|
---|
80 | NS_IMPL_THREADSAFE_ISUPPORTS1_CI(Mouse, IMouse)
|
---|
81 | NS_DECL_CLASSINFO(Display)
|
---|
82 | NS_IMPL_THREADSAFE_ISUPPORTS2_CI(Display, IDisplay, IEventListener)
|
---|
83 | NS_DECL_CLASSINFO(MachineDebugger)
|
---|
84 | NS_IMPL_THREADSAFE_ISUPPORTS1_CI(MachineDebugger, IMachineDebugger)
|
---|
85 | NS_DECL_CLASSINFO(Progress)
|
---|
86 | NS_IMPL_THREADSAFE_ISUPPORTS1_CI(Progress, IProgress)
|
---|
87 | NS_DECL_CLASSINFO(CombinedProgress)
|
---|
88 | NS_IMPL_THREADSAFE_ISUPPORTS1_CI(CombinedProgress, IProgress)
|
---|
89 | NS_DECL_CLASSINFO(OUSBDevice)
|
---|
90 | NS_IMPL_THREADSAFE_ISUPPORTS1_CI(OUSBDevice, IUSBDevice)
|
---|
91 | NS_DECL_CLASSINFO(RemoteUSBDevice)
|
---|
92 | NS_IMPL_THREADSAFE_ISUPPORTS2_CI(RemoteUSBDevice, IHostUSBDevice, IUSBDevice)
|
---|
93 | NS_DECL_CLASSINFO(SharedFolder)
|
---|
94 | NS_IMPL_THREADSAFE_ISUPPORTS1_CI(SharedFolder, ISharedFolder)
|
---|
95 | NS_DECL_CLASSINFO(VRDEServerInfo)
|
---|
96 | NS_IMPL_THREADSAFE_ISUPPORTS1_CI(VRDEServerInfo, IVRDEServerInfo)
|
---|
97 | #ifdef VBOX_WITH_EXTPACK
|
---|
98 | NS_DECL_CLASSINFO(ExtPackFile)
|
---|
99 | NS_IMPL_THREADSAFE_ISUPPORTS2_CI(ExtPackFile, IExtPackFile, IExtPackBase)
|
---|
100 | NS_DECL_CLASSINFO(ExtPack)
|
---|
101 | NS_IMPL_THREADSAFE_ISUPPORTS2_CI(ExtPack, IExtPack, IExtPackBase)
|
---|
102 | NS_DECL_CLASSINFO(ExtPackManager)
|
---|
103 | NS_IMPL_THREADSAFE_ISUPPORTS1_CI(ExtPackManager, IExtPackManager)
|
---|
104 | #endif
|
---|
105 | NS_DECL_CLASSINFO(AdditionsFacility)
|
---|
106 | NS_IMPL_THREADSAFE_ISUPPORTS1_CI(AdditionsFacility, IAdditionsFacility)
|
---|
107 |
|
---|
108 | NS_DECL_CLASSINFO(Session)
|
---|
109 | NS_IMPL_THREADSAFE_ISUPPORTS2_CI(Session, ISession, IInternalSessionControl)
|
---|
110 | NS_DECL_CLASSINFO(Console)
|
---|
111 | NS_IMPL_THREADSAFE_ISUPPORTS1_CI(Console, IConsole)
|
---|
112 |
|
---|
113 | NS_DECL_CLASSINFO(VirtualBoxClient)
|
---|
114 | NS_IMPL_THREADSAFE_ISUPPORTS1_CI(VirtualBoxClient, IVirtualBoxClient)
|
---|
115 |
|
---|
116 | /**
|
---|
117 | * Singleton class factory that holds a reference to the created instance
|
---|
118 | * (preventing it from being destroyed) until the module is explicitly
|
---|
119 | * unloaded by the XPCOM shutdown code.
|
---|
120 | *
|
---|
121 | * Suitable for IN-PROC components.
|
---|
122 | */
|
---|
123 | class SessionClassFactory : public Session
|
---|
124 | {
|
---|
125 | public:
|
---|
126 | virtual ~SessionClassFactory() {
|
---|
127 | FinalRelease();
|
---|
128 | instance = 0;
|
---|
129 | }
|
---|
130 | static nsresult getInstance (Session **inst) {
|
---|
131 | int rv = NS_OK;
|
---|
132 | if (instance == 0) {
|
---|
133 | instance = new SessionClassFactory();
|
---|
134 | if (instance) {
|
---|
135 | instance->AddRef(); // protect FinalConstruct()
|
---|
136 | rv = instance->FinalConstruct();
|
---|
137 | if (NS_FAILED(rv))
|
---|
138 | instance->Release();
|
---|
139 | else
|
---|
140 | instance->AddRef(); // self-reference
|
---|
141 | } else {
|
---|
142 | rv = NS_ERROR_OUT_OF_MEMORY;
|
---|
143 | }
|
---|
144 | } else {
|
---|
145 | instance->AddRef();
|
---|
146 | }
|
---|
147 | *inst = instance;
|
---|
148 | return rv;
|
---|
149 | }
|
---|
150 | static nsresult releaseInstance () {
|
---|
151 | if (instance)
|
---|
152 | instance->Release();
|
---|
153 | return NS_OK;
|
---|
154 | }
|
---|
155 |
|
---|
156 | private:
|
---|
157 | static Session *instance;
|
---|
158 | };
|
---|
159 |
|
---|
160 | /** @note this is for singleton; disabled for now */
|
---|
161 | //
|
---|
162 | //Session *SessionClassFactory::instance = 0;
|
---|
163 | //
|
---|
164 | //NS_GENERIC_FACTORY_SINGLETON_CONSTRUCTOR_WITH_RC (
|
---|
165 | // Session, SessionClassFactory::getInstance
|
---|
166 | //)
|
---|
167 |
|
---|
168 | NS_GENERIC_FACTORY_CONSTRUCTOR_WITH_RC(Session)
|
---|
169 |
|
---|
170 | NS_GENERIC_FACTORY_CONSTRUCTOR_WITH_RC(VirtualBoxClient)
|
---|
171 |
|
---|
172 | /**
|
---|
173 | * Component definition table.
|
---|
174 | * Lists all components defined in this module.
|
---|
175 | */
|
---|
176 | static const nsModuleComponentInfo components[] =
|
---|
177 | {
|
---|
178 | {
|
---|
179 | "Session component", // description
|
---|
180 | NS_SESSION_CID, NS_SESSION_CONTRACTID, // CID/ContractID
|
---|
181 | SessionConstructor, // constructor function
|
---|
182 | NULL, // registration function
|
---|
183 | NULL, // deregistration function
|
---|
184 | /** @note this is for singleton; disabled for now */
|
---|
185 | // SessionClassFactory::releaseInstance,
|
---|
186 | NULL, // destructor function
|
---|
187 | NS_CI_INTERFACE_GETTER_NAME(Session), // interfaces function
|
---|
188 | NULL, // language helper
|
---|
189 | &NS_CLASSINFO_NAME(Session) // global class info & flags
|
---|
190 | },
|
---|
191 | {
|
---|
192 | "VirtualBoxClient component", // description
|
---|
193 | NS_VIRTUALBOXCLIENT_CID, NS_VIRTUALBOXCLIENT_CONTRACTID, // CID/ContractID
|
---|
194 | VirtualBoxClientConstructor, // constructor function
|
---|
195 | NULL, // registration function
|
---|
196 | NULL, // deregistration function
|
---|
197 | NULL, // destructor function
|
---|
198 | NS_CI_INTERFACE_GETTER_NAME(VirtualBoxClient), // interfaces function
|
---|
199 | NULL, // language helper
|
---|
200 | &NS_CLASSINFO_NAME(VirtualBoxClient) // global class info & flags
|
---|
201 | },
|
---|
202 | };
|
---|
203 |
|
---|
204 | NS_IMPL_NSGETMODULE (VirtualBox_Client_Module, components)
|
---|
205 | /* vi: set tabstop=4 shiftwidth=4 expandtab: */
|
---|