VirtualBox

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

Last change on this file since 17571 was 17553, checked in by vboxsync, 16 years ago

#3551: “Main: Replace remaining collections with safe arrays”
Replaced IUSBDeviceCollection. Reviewed by Christian.

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

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette