VirtualBox

source: vbox/trunk/src/VBox/Main/src-client/xpcom/module.cpp@ 37952

Last change on this file since 37952 was 35975, checked in by vboxsync, 14 years ago

build fix

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