VirtualBox

source: vbox/trunk/src/VBox/Main/linux/module.cpp@ 5999

Last change on this file since 5999 was 5999, checked in by vboxsync, 17 years ago

The Giant CDDL Dual-License Header Change.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 4.7 KB
Line 
1/** @file
2 *
3 * XPCOM module implementation functions
4 */
5
6/*
7 * Copyright (C) 2006-2007 innotek GmbH
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#include <nsIGenericFactory.h>
19
20// generated file
21#include "VirtualBox_XPCOM.h"
22
23#include "GuestImpl.h"
24#include "KeyboardImpl.h"
25#include "MouseImpl.h"
26#include "DisplayImpl.h"
27#include "MachineDebuggerImpl.h"
28#include "USBDeviceImpl.h"
29#include "RemoteUSBDeviceImpl.h"
30#include "SharedFolderImpl.h"
31#include "FramebufferImpl.h"
32#include "ProgressImpl.h"
33#include "NetworkAdapterImpl.h"
34
35#include "SessionImpl.h"
36#include "ConsoleImpl.h"
37#include "ConsoleVRDPServer.h"
38
39#include "Logging.h"
40
41// XPCOM glue code unfolding
42
43NS_DECL_CLASSINFO(Guest)
44NS_IMPL_THREADSAFE_ISUPPORTS1_CI(Guest, IGuest)
45NS_DECL_CLASSINFO(Keyboard)
46NS_IMPL_THREADSAFE_ISUPPORTS1_CI(Keyboard, IKeyboard)
47NS_DECL_CLASSINFO(Mouse)
48NS_IMPL_THREADSAFE_ISUPPORTS1_CI(Mouse, IMouse)
49NS_DECL_CLASSINFO(Display)
50NS_IMPL_THREADSAFE_ISUPPORTS1_CI(Display, IDisplay)
51NS_DECL_CLASSINFO(MachineDebugger)
52NS_IMPL_THREADSAFE_ISUPPORTS1_CI(MachineDebugger, IMachineDebugger)
53NS_DECL_CLASSINFO(InternalFramebuffer)
54NS_IMPL_THREADSAFE_ISUPPORTS1_CI(InternalFramebuffer, IFramebuffer)
55NS_DECL_CLASSINFO(Progress)
56NS_IMPL_THREADSAFE_ISUPPORTS1_CI(Progress, IProgress)
57NS_DECL_CLASSINFO(CombinedProgress)
58NS_IMPL_THREADSAFE_ISUPPORTS1_CI(CombinedProgress, IProgress)
59NS_DECL_CLASSINFO(OUSBDevice)
60NS_IMPL_THREADSAFE_ISUPPORTS1_CI(OUSBDevice, IUSBDevice)
61NS_DECL_CLASSINFO(RemoteUSBDevice)
62NS_IMPL_THREADSAFE_ISUPPORTS1_CI(RemoteUSBDevice, IHostUSBDevice)
63NS_DECL_CLASSINFO(SharedFolder)
64NS_IMPL_THREADSAFE_ISUPPORTS1_CI(SharedFolder, ISharedFolder)
65NS_DECL_CLASSINFO(RemoteDisplayInfo)
66NS_IMPL_THREADSAFE_ISUPPORTS1_CI(RemoteDisplayInfo, IRemoteDisplayInfo)
67
68NS_DECL_CLASSINFO(Session)
69NS_IMPL_THREADSAFE_ISUPPORTS2_CI(Session, ISession, IInternalSessionControl)
70NS_DECL_CLASSINFO(Console)
71NS_IMPL_THREADSAFE_ISUPPORTS1_CI(Console, IConsole)
72
73COM_IMPL_READONLY_ENUM_AND_COLLECTION_EX(ComObjPtr <OUSBDevice>, IUSBDevice, OUSBDevice)
74COM_IMPL_READONLY_ENUM_AND_COLLECTION_EX(ComObjPtr <RemoteUSBDevice>, IHostUSBDevice, RemoteUSBDevice)
75COM_IMPL_READONLY_ENUM_AND_COLLECTION(SharedFolder)
76
77/**
78 * Singleton class factory that holds a reference to the created instance
79 * (preventing it from being destroyed) until the module is explicitly
80 * unloaded by the XPCOM shutdown code.
81 *
82 * Suitable for IN-PROC components.
83 */
84class SessionClassFactory : public Session
85{
86public:
87 virtual ~SessionClassFactory() {
88 FinalRelease();
89 instance = 0;
90 }
91 static nsresult getInstance (Session **inst) {
92 int rv = NS_OK;
93 if (instance == 0) {
94 instance = new SessionClassFactory();
95 if (instance) {
96 instance->AddRef(); // protect FinalConstruct()
97 rv = instance->FinalConstruct();
98 if (NS_FAILED(rv))
99 instance->Release();
100 else
101 instance->AddRef(); // self-reference
102 } else {
103 rv = NS_ERROR_OUT_OF_MEMORY;
104 }
105 } else {
106 instance->AddRef();
107 }
108 *inst = instance;
109 return rv;
110 }
111 static nsresult releaseInstance () {
112 if (instance)
113 instance->Release();
114 return NS_OK;
115 }
116
117private:
118 static Session *instance;
119};
120
121/** @note this is for singleton; disabled for now */
122//
123//Session *SessionClassFactory::instance = 0;
124//
125//NS_GENERIC_FACTORY_SINGLETON_CONSTRUCTOR_WITH_RC (
126// Session, SessionClassFactory::getInstance
127//)
128
129NS_GENERIC_FACTORY_CONSTRUCTOR_WITH_RC (Session)
130
131
132/**
133 * Component definition table.
134 * Lists all components defined in this module.
135 */
136static const nsModuleComponentInfo components[] =
137{
138 {
139 "Session component", // description
140 NS_SESSION_CID, NS_SESSION_CONTRACTID, // CID/ContractID
141 SessionConstructor, // constructor function
142 NULL, // registration function
143 NULL, // deregistration function
144/** @note this is for singleton; disabled for now */
145// SessionClassFactory::releaseInstance,
146 NULL, // destructor function
147 NS_CI_INTERFACE_GETTER_NAME(Session), // interfaces function
148 NULL, // language helper
149 &NS_CLASSINFO_NAME(Session) // global class info & flags
150 }
151};
152
153NS_IMPL_NSGETMODULE (VirtualBox_Client_Module, components)
154
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