1 | /** @file
|
---|
2 | *
|
---|
3 | * XPCOM module implementation functions
|
---|
4 | */
|
---|
5 |
|
---|
6 | /*
|
---|
7 | * Copyright (C) 2006 InnoTek Systemberatung 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 as published by the Free Software Foundation,
|
---|
13 | * in version 2 as it comes in the "COPYING" file of the VirtualBox OSE
|
---|
14 | * distribution. VirtualBox OSE is distributed in the hope that it will
|
---|
15 | * be useful, but WITHOUT ANY WARRANTY of any kind.
|
---|
16 | *
|
---|
17 | * If you received this file as part of a commercial VirtualBox
|
---|
18 | * distribution, then only the terms of your commercial VirtualBox
|
---|
19 | * license agreement apply instead of the previous paragraph.
|
---|
20 | */
|
---|
21 |
|
---|
22 | #include <nsIGenericFactory.h>
|
---|
23 | #include <VirtualBox_XPCOM.h>
|
---|
24 |
|
---|
25 | #include <GuestImpl.h>
|
---|
26 | #include <KeyboardImpl.h>
|
---|
27 | #include <MouseImpl.h>
|
---|
28 | #include <DisplayImpl.h>
|
---|
29 | #include <MachineDebuggerImpl.h>
|
---|
30 | #include <USBDeviceImpl.h>
|
---|
31 | #include <RemoteUSBDeviceImpl.h>
|
---|
32 | #include <SharedFolderImpl.h>
|
---|
33 | #include <FramebufferImpl.h>
|
---|
34 | #include <ProgressImpl.h>
|
---|
35 | #include <NetworkAdapterImpl.h>
|
---|
36 |
|
---|
37 | #include <SessionImpl.h>
|
---|
38 | #include <ConsoleImpl.h>
|
---|
39 | #include <ConsoleVRDPServer.h>
|
---|
40 |
|
---|
41 | // XPCOM glue code unfolding
|
---|
42 |
|
---|
43 | NS_DECL_CLASSINFO(Guest)
|
---|
44 | NS_IMPL_THREADSAFE_ISUPPORTS1_CI(Guest, IGuest)
|
---|
45 | NS_DECL_CLASSINFO(Keyboard)
|
---|
46 | NS_IMPL_THREADSAFE_ISUPPORTS1_CI(Keyboard, IKeyboard)
|
---|
47 | NS_DECL_CLASSINFO(Mouse)
|
---|
48 | NS_IMPL_THREADSAFE_ISUPPORTS1_CI(Mouse, IMouse)
|
---|
49 | NS_DECL_CLASSINFO(Display)
|
---|
50 | NS_IMPL_THREADSAFE_ISUPPORTS1_CI(Display, IDisplay)
|
---|
51 | NS_DECL_CLASSINFO(MachineDebugger)
|
---|
52 | NS_IMPL_THREADSAFE_ISUPPORTS1_CI(MachineDebugger, IMachineDebugger)
|
---|
53 | NS_DECL_CLASSINFO(InternalFramebuffer)
|
---|
54 | NS_IMPL_THREADSAFE_ISUPPORTS1_CI(InternalFramebuffer, IFramebuffer)
|
---|
55 | NS_DECL_CLASSINFO(Progress)
|
---|
56 | NS_IMPL_THREADSAFE_ISUPPORTS1_CI(Progress, IProgress)
|
---|
57 | NS_DECL_CLASSINFO(CombinedProgress)
|
---|
58 | NS_IMPL_THREADSAFE_ISUPPORTS1_CI(CombinedProgress, IProgress)
|
---|
59 | NS_DECL_CLASSINFO(OUSBDevice)
|
---|
60 | NS_IMPL_THREADSAFE_ISUPPORTS1_CI(OUSBDevice, IUSBDevice)
|
---|
61 | NS_DECL_CLASSINFO(RemoteUSBDevice)
|
---|
62 | NS_IMPL_THREADSAFE_ISUPPORTS1_CI(RemoteUSBDevice, IHostUSBDevice)
|
---|
63 | NS_DECL_CLASSINFO(SharedFolder)
|
---|
64 | NS_IMPL_THREADSAFE_ISUPPORTS1_CI(SharedFolder, ISharedFolder)
|
---|
65 | NS_DECL_CLASSINFO(RemoteDisplayInfo)
|
---|
66 | NS_IMPL_THREADSAFE_ISUPPORTS1_CI(RemoteDisplayInfo, IRemoteDisplayInfo)
|
---|
67 |
|
---|
68 | NS_DECL_CLASSINFO(Session)
|
---|
69 | NS_IMPL_THREADSAFE_ISUPPORTS2_CI(Session, ISession, IInternalSessionControl)
|
---|
70 | NS_DECL_CLASSINFO(Console)
|
---|
71 | NS_IMPL_THREADSAFE_ISUPPORTS1_CI(Console, IConsole)
|
---|
72 |
|
---|
73 | COM_IMPL_READONLY_ENUM_AND_COLLECTION_EX(ComObjPtr <OUSBDevice>, IUSBDevice, OUSBDevice)
|
---|
74 | COM_IMPL_READONLY_ENUM_AND_COLLECTION_EX(ComObjPtr <RemoteUSBDevice>, IHostUSBDevice, RemoteUSBDevice)
|
---|
75 | COM_IMPL_READONLY_ENUM_AND_COLLECTION(SharedFolder)
|
---|
76 |
|
---|
77 | /**
|
---|
78 | * Singleton class factory that holds the 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 | */
|
---|
84 | class SessionClassFactory : public Session
|
---|
85 | {
|
---|
86 | public:
|
---|
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 |
|
---|
117 | private:
|
---|
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 |
|
---|
129 | NS_GENERIC_FACTORY_CONSTRUCTOR_WITH_RC (Session)
|
---|
130 |
|
---|
131 | static const nsModuleComponentInfo components[] =
|
---|
132 | {
|
---|
133 | {
|
---|
134 | "Session component", NS_SESSION_CID, NS_SESSION_CONTRACTID,
|
---|
135 | SessionConstructor,
|
---|
136 | NULL, // registration function
|
---|
137 | NULL, // deregistration function
|
---|
138 | /** @note this is for singleton; disabled for now */
|
---|
139 | // SessionClassFactory::releaseInstance,
|
---|
140 | NULL, // destructor function
|
---|
141 | NS_CI_INTERFACE_GETTER_NAME(Session),
|
---|
142 | NULL, // language helper
|
---|
143 | &NS_CLASSINFO_NAME(Session)
|
---|
144 | }
|
---|
145 | };
|
---|
146 |
|
---|
147 | NS_IMPL_NSGETMODULE(SessionModule, components)
|
---|
148 |
|
---|