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 "ProgressImpl.h"
|
---|
52 | #include "RemoteUSBDeviceImpl.h"
|
---|
53 | #include "SessionImpl.h"
|
---|
54 | #include "SharedFolderImpl.h"
|
---|
55 | #include "USBDeviceImpl.h"
|
---|
56 | #include "VirtualBoxClientImpl.h"
|
---|
57 |
|
---|
58 | #include "Logging.h"
|
---|
59 |
|
---|
60 | // XPCOM glue code unfolding
|
---|
61 |
|
---|
62 | NS_DECL_CLASSINFO(Guest)
|
---|
63 | NS_IMPL_THREADSAFE_ISUPPORTS1_CI(Guest, IGuest)
|
---|
64 | #ifdef VBOX_WITH_GUEST_CONTROL
|
---|
65 | NS_DECL_CLASSINFO(GuestDirectory)
|
---|
66 | NS_IMPL_THREADSAFE_ISUPPORTS2_CI(GuestDirectory, IGuestDirectory, IDirectory)
|
---|
67 | NS_DECL_CLASSINFO(GuestFile)
|
---|
68 | NS_IMPL_THREADSAFE_ISUPPORTS2_CI(GuestFile, IGuestFile, IFile)
|
---|
69 | NS_DECL_CLASSINFO(GuestFsObjInfo)
|
---|
70 | NS_IMPL_THREADSAFE_ISUPPORTS2_CI(GuestFsObjInfo, IGuestFsObjInfo, IFsObjInfo)
|
---|
71 | NS_DECL_CLASSINFO(GuestProcess)
|
---|
72 | NS_IMPL_THREADSAFE_ISUPPORTS2_CI(GuestProcess, IGuestProcess, IProcess)
|
---|
73 | NS_DECL_CLASSINFO(GuestSession)
|
---|
74 | NS_IMPL_THREADSAFE_ISUPPORTS1_CI(GuestSession, IGuestSession)
|
---|
75 | #endif
|
---|
76 | NS_DECL_CLASSINFO(Keyboard)
|
---|
77 | NS_IMPL_THREADSAFE_ISUPPORTS1_CI(Keyboard, IKeyboard)
|
---|
78 | NS_DECL_CLASSINFO(Mouse)
|
---|
79 | NS_IMPL_THREADSAFE_ISUPPORTS1_CI(Mouse, IMouse)
|
---|
80 | NS_DECL_CLASSINFO(Display)
|
---|
81 | NS_IMPL_THREADSAFE_ISUPPORTS2_CI(Display, IDisplay, IEventListener)
|
---|
82 | NS_DECL_CLASSINFO(MachineDebugger)
|
---|
83 | NS_IMPL_THREADSAFE_ISUPPORTS1_CI(MachineDebugger, IMachineDebugger)
|
---|
84 | NS_DECL_CLASSINFO(Progress)
|
---|
85 | NS_IMPL_THREADSAFE_ISUPPORTS1_CI(Progress, IProgress)
|
---|
86 | NS_DECL_CLASSINFO(OUSBDevice)
|
---|
87 | NS_IMPL_THREADSAFE_ISUPPORTS1_CI(OUSBDevice, IUSBDevice)
|
---|
88 | NS_DECL_CLASSINFO(RemoteUSBDevice)
|
---|
89 | NS_IMPL_THREADSAFE_ISUPPORTS2_CI(RemoteUSBDevice, IHostUSBDevice, IUSBDevice)
|
---|
90 | NS_DECL_CLASSINFO(SharedFolder)
|
---|
91 | NS_IMPL_THREADSAFE_ISUPPORTS1_CI(SharedFolder, ISharedFolder)
|
---|
92 | NS_DECL_CLASSINFO(VRDEServerInfo)
|
---|
93 | NS_IMPL_THREADSAFE_ISUPPORTS1_CI(VRDEServerInfo, IVRDEServerInfo)
|
---|
94 | #ifdef VBOX_WITH_EXTPACK
|
---|
95 | NS_DECL_CLASSINFO(ExtPackFile)
|
---|
96 | NS_IMPL_THREADSAFE_ISUPPORTS2_CI(ExtPackFile, IExtPackFile, IExtPackBase)
|
---|
97 | NS_DECL_CLASSINFO(ExtPack)
|
---|
98 | NS_IMPL_THREADSAFE_ISUPPORTS2_CI(ExtPack, IExtPack, IExtPackBase)
|
---|
99 | NS_DECL_CLASSINFO(ExtPackManager)
|
---|
100 | NS_IMPL_THREADSAFE_ISUPPORTS1_CI(ExtPackManager, IExtPackManager)
|
---|
101 | #endif
|
---|
102 | NS_DECL_CLASSINFO(AdditionsFacility)
|
---|
103 | NS_IMPL_THREADSAFE_ISUPPORTS1_CI(AdditionsFacility, IAdditionsFacility)
|
---|
104 |
|
---|
105 | NS_DECL_CLASSINFO(Session)
|
---|
106 | NS_IMPL_THREADSAFE_ISUPPORTS2_CI(Session, ISession, IInternalSessionControl)
|
---|
107 | NS_DECL_CLASSINFO(Console)
|
---|
108 | NS_IMPL_THREADSAFE_ISUPPORTS1_CI(Console, IConsole)
|
---|
109 |
|
---|
110 | NS_DECL_CLASSINFO(VirtualBoxClient)
|
---|
111 | NS_IMPL_THREADSAFE_ISUPPORTS1_CI(VirtualBoxClient, IVirtualBoxClient)
|
---|
112 |
|
---|
113 | /**
|
---|
114 | * Singleton class factory that holds a reference to the created instance
|
---|
115 | * (preventing it from being destroyed) until the module is explicitly
|
---|
116 | * unloaded by the XPCOM shutdown code.
|
---|
117 | *
|
---|
118 | * Suitable for IN-PROC components.
|
---|
119 | */
|
---|
120 | class SessionClassFactory : public Session
|
---|
121 | {
|
---|
122 | public:
|
---|
123 | virtual ~SessionClassFactory() {
|
---|
124 | FinalRelease();
|
---|
125 | instance = 0;
|
---|
126 | }
|
---|
127 | static nsresult getInstance (Session **inst) {
|
---|
128 | int rv = NS_OK;
|
---|
129 | if (instance == 0) {
|
---|
130 | instance = new SessionClassFactory();
|
---|
131 | if (instance) {
|
---|
132 | instance->AddRef(); // protect FinalConstruct()
|
---|
133 | rv = instance->FinalConstruct();
|
---|
134 | if (NS_FAILED(rv))
|
---|
135 | instance->Release();
|
---|
136 | else
|
---|
137 | instance->AddRef(); // self-reference
|
---|
138 | } else {
|
---|
139 | rv = NS_ERROR_OUT_OF_MEMORY;
|
---|
140 | }
|
---|
141 | } else {
|
---|
142 | instance->AddRef();
|
---|
143 | }
|
---|
144 | *inst = instance;
|
---|
145 | return rv;
|
---|
146 | }
|
---|
147 | static nsresult releaseInstance () {
|
---|
148 | if (instance)
|
---|
149 | instance->Release();
|
---|
150 | return NS_OK;
|
---|
151 | }
|
---|
152 |
|
---|
153 | private:
|
---|
154 | static Session *instance;
|
---|
155 | };
|
---|
156 |
|
---|
157 | /** @note this is for singleton; disabled for now */
|
---|
158 | //
|
---|
159 | //Session *SessionClassFactory::instance = 0;
|
---|
160 | //
|
---|
161 | //NS_GENERIC_FACTORY_SINGLETON_CONSTRUCTOR_WITH_RC (
|
---|
162 | // Session, SessionClassFactory::getInstance
|
---|
163 | //)
|
---|
164 |
|
---|
165 | NS_GENERIC_FACTORY_CONSTRUCTOR_WITH_RC(Session)
|
---|
166 |
|
---|
167 | NS_GENERIC_FACTORY_CONSTRUCTOR_WITH_RC(VirtualBoxClient)
|
---|
168 |
|
---|
169 | /**
|
---|
170 | * Component definition table.
|
---|
171 | * Lists all components defined in this module.
|
---|
172 | */
|
---|
173 | static const nsModuleComponentInfo components[] =
|
---|
174 | {
|
---|
175 | {
|
---|
176 | "Session component", // description
|
---|
177 | NS_SESSION_CID, NS_SESSION_CONTRACTID, // CID/ContractID
|
---|
178 | SessionConstructor, // constructor function
|
---|
179 | NULL, // registration function
|
---|
180 | NULL, // deregistration function
|
---|
181 | /** @note this is for singleton; disabled for now */
|
---|
182 | // SessionClassFactory::releaseInstance,
|
---|
183 | NULL, // destructor function
|
---|
184 | NS_CI_INTERFACE_GETTER_NAME(Session), // interfaces function
|
---|
185 | NULL, // language helper
|
---|
186 | &NS_CLASSINFO_NAME(Session) // global class info & flags
|
---|
187 | },
|
---|
188 | {
|
---|
189 | "VirtualBoxClient component", // description
|
---|
190 | NS_VIRTUALBOXCLIENT_CID, NS_VIRTUALBOXCLIENT_CONTRACTID, // CID/ContractID
|
---|
191 | VirtualBoxClientConstructor, // constructor function
|
---|
192 | NULL, // registration function
|
---|
193 | NULL, // deregistration function
|
---|
194 | NULL, // destructor function
|
---|
195 | NS_CI_INTERFACE_GETTER_NAME(VirtualBoxClient), // interfaces function
|
---|
196 | NULL, // language helper
|
---|
197 | &NS_CLASSINFO_NAME(VirtualBoxClient) // global class info & flags
|
---|
198 | },
|
---|
199 | };
|
---|
200 |
|
---|
201 | NS_IMPL_NSGETMODULE (VirtualBox_Client_Module, components)
|
---|
202 | /* vi: set tabstop=4 shiftwidth=4 expandtab: */
|
---|