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