VirtualBox

source: vbox/trunk/src/VBox/Main/xpcom/module.cpp@ 34575

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