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