VirtualBox

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

Last change on this file since 25414 was 22357, checked in by vboxsync, 15 years ago

COM, Python: wrappers cleanup, some generic improvments

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 5.5 KB
Line 
1/** @file
2 *
3 * XPCOM module implementation functions
4 */
5
6/*
7 * Copyright (C) 2006-2009 Sun Microsystems, Inc.
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 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
18 * Clara, CA 95054 USA or visit http://www.sun.com if you need
19 * additional information or have any questions.
20 */
21
22/* Make sure all the stdint.h macros are included - must come first! */
23#ifndef __STDC_LIMIT_MACROS
24# define __STDC_LIMIT_MACROS
25#endif
26#ifndef __STDC_CONSTANT_MACROS
27# define __STDC_CONSTANT_MACROS
28#endif
29
30#include <nsIGenericFactory.h>
31
32// generated file
33#include "VirtualBox_XPCOM.h"
34
35#include "GuestImpl.h"
36#include "KeyboardImpl.h"
37#include "MouseImpl.h"
38#include "DisplayImpl.h"
39#include "MachineDebuggerImpl.h"
40#include "USBDeviceImpl.h"
41#include "RemoteUSBDeviceImpl.h"
42#include "SharedFolderImpl.h"
43#include "ProgressImpl.h"
44#include "NetworkAdapterImpl.h"
45
46#include "SessionImpl.h"
47#include "ConsoleImpl.h"
48#include "ConsoleVRDPServer.h"
49#include "VirtualBoxCallbackImpl.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_ISUPPORTS1_CI(Display, IDisplay)
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(RemoteDisplayInfo)
76NS_IMPL_THREADSAFE_ISUPPORTS1_CI(RemoteDisplayInfo, IRemoteDisplayInfo)
77
78NS_DECL_CLASSINFO(Session)
79NS_IMPL_THREADSAFE_ISUPPORTS2_CI(Session, ISession, IInternalSessionControl)
80NS_DECL_CLASSINFO(Console)
81NS_IMPL_THREADSAFE_ISUPPORTS1_CI(Console, IConsole)
82NS_DECL_CLASSINFO(CallbackWrapper)
83NS_IMPL_THREADSAFE_ISUPPORTS3_CI(CallbackWrapper, IVirtualBoxCallback, IConsoleCallback, ILocalOwner)
84/**
85 * Singleton class factory that holds a reference to the created instance
86 * (preventing it from being destroyed) until the module is explicitly
87 * unloaded by the XPCOM shutdown code.
88 *
89 * Suitable for IN-PROC components.
90 */
91class SessionClassFactory : public Session
92{
93public:
94 virtual ~SessionClassFactory() {
95 FinalRelease();
96 instance = 0;
97 }
98 static nsresult getInstance (Session **inst) {
99 int rv = NS_OK;
100 if (instance == 0) {
101 instance = new SessionClassFactory();
102 if (instance) {
103 instance->AddRef(); // protect FinalConstruct()
104 rv = instance->FinalConstruct();
105 if (NS_FAILED(rv))
106 instance->Release();
107 else
108 instance->AddRef(); // self-reference
109 } else {
110 rv = NS_ERROR_OUT_OF_MEMORY;
111 }
112 } else {
113 instance->AddRef();
114 }
115 *inst = instance;
116 return rv;
117 }
118 static nsresult releaseInstance () {
119 if (instance)
120 instance->Release();
121 return NS_OK;
122 }
123
124private:
125 static Session *instance;
126};
127
128/** @note this is for singleton; disabled for now */
129//
130//Session *SessionClassFactory::instance = 0;
131//
132//NS_GENERIC_FACTORY_SINGLETON_CONSTRUCTOR_WITH_RC (
133// Session, SessionClassFactory::getInstance
134//)
135
136NS_GENERIC_FACTORY_CONSTRUCTOR_WITH_RC (Session)
137
138NS_GENERIC_FACTORY_CONSTRUCTOR_WITH_RC (CallbackWrapper)
139
140
141/**
142 * Component definition table.
143 * Lists all components defined in this module.
144 */
145static const nsModuleComponentInfo components[] =
146{
147 {
148 "Session component", // description
149 NS_SESSION_CID, NS_SESSION_CONTRACTID, // CID/ContractID
150 SessionConstructor, // constructor function
151 NULL, // registration function
152 NULL, // deregistration function
153/** @note this is for singleton; disabled for now */
154// SessionClassFactory::releaseInstance,
155 NULL, // destructor function
156 NS_CI_INTERFACE_GETTER_NAME(Session), // interfaces function
157 NULL, // language helper
158 &NS_CLASSINFO_NAME(Session) // global class info & flags
159 },
160 {
161 "CallbackWrapper component", // description
162 NS_CALLBACKWRAPPER_CID, NS_CALLBACKWRAPPER_CONTRACTID, // CID/ContractID
163 CallbackWrapperConstructor, // constructor function
164 NULL, // registration function
165 NULL, // deregistration function
166 NULL, // destructor function
167 NS_CI_INTERFACE_GETTER_NAME(CallbackWrapper), // interfaces function
168 NULL, // language helper
169 &NS_CLASSINFO_NAME(CallbackWrapper) // global class info & flags
170 }
171
172};
173
174NS_IMPL_NSGETMODULE (VirtualBox_Client_Module, components)
175/* vi: set tabstop=4 shiftwidth=4 expandtab: */
Note: See TracBrowser for help on using the repository browser.

© 2023 Oracle
ContactPrivacy policyTerms of Use