VirtualBox

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

Last change on this file since 29615 was 28979, checked in by vboxsync, 15 years ago

Main: Display implements both IDisplay and IConsoleCallback

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