1 | /* $Id: module.cpp 93115 2022-01-01 11:31:46Z vboxsync $ */
|
---|
2 | /** @file
|
---|
3 | * XPCOM module implementation functions
|
---|
4 | */
|
---|
5 |
|
---|
6 | /*
|
---|
7 | * Copyright (C) 2006-2022 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 | #define LOG_GROUP LOG_GROUP_MAIN
|
---|
19 |
|
---|
20 | /* Make sure all the stdint.h macros are included - must come first! */
|
---|
21 | #ifndef __STDC_LIMIT_MACROS
|
---|
22 | # define __STDC_LIMIT_MACROS
|
---|
23 | #endif
|
---|
24 | #ifndef __STDC_CONSTANT_MACROS
|
---|
25 | # define __STDC_CONSTANT_MACROS
|
---|
26 | #endif
|
---|
27 |
|
---|
28 | #include <nsIGenericFactory.h>
|
---|
29 |
|
---|
30 | // generated file
|
---|
31 | #include <VBox/com/VirtualBox.h>
|
---|
32 |
|
---|
33 | #include "SessionImpl.h"
|
---|
34 | #include "VirtualBoxClientImpl.h"
|
---|
35 | #include "RemoteUSBDeviceImpl.h"
|
---|
36 | #include "USBDeviceImpl.h"
|
---|
37 |
|
---|
38 | // XPCOM glue code unfolding
|
---|
39 |
|
---|
40 | /*
|
---|
41 | * Declare extern variables here to tell the compiler that
|
---|
42 | * NS_DECL_CLASSINFO(SessionWrap)
|
---|
43 | * already exists in the VBoxAPIWrap library.
|
---|
44 | */
|
---|
45 | NS_DECL_CI_INTERFACE_GETTER(SessionWrap)
|
---|
46 | extern nsIClassInfo *NS_CLASSINFO_NAME(SessionWrap);
|
---|
47 |
|
---|
48 | /*
|
---|
49 | * Declare extern variables here to tell the compiler that
|
---|
50 | * NS_DECL_CLASSINFO(VirtualBoxClientWrap)
|
---|
51 | * already exists in the VBoxAPIWrap library.
|
---|
52 | */
|
---|
53 | NS_DECL_CI_INTERFACE_GETTER(VirtualBoxClientWrap)
|
---|
54 | extern nsIClassInfo *NS_CLASSINFO_NAME(VirtualBoxClientWrap);
|
---|
55 |
|
---|
56 | /**
|
---|
57 | * Singleton class factory that holds a reference to the created instance
|
---|
58 | * (preventing it from being destroyed) until the module is explicitly
|
---|
59 | * unloaded by the XPCOM shutdown code.
|
---|
60 | *
|
---|
61 | * Suitable for IN-PROC components.
|
---|
62 | */
|
---|
63 | class VirtualBoxClientClassFactory : public VirtualBoxClient
|
---|
64 | {
|
---|
65 | public:
|
---|
66 | virtual ~VirtualBoxClientClassFactory()
|
---|
67 | {
|
---|
68 | FinalRelease();
|
---|
69 | instance = 0;
|
---|
70 | }
|
---|
71 |
|
---|
72 | static nsresult GetInstance(VirtualBoxClient **inst)
|
---|
73 | {
|
---|
74 | int rv = NS_OK;
|
---|
75 | if (instance == 0)
|
---|
76 | {
|
---|
77 | instance = new VirtualBoxClientClassFactory();
|
---|
78 | if (instance)
|
---|
79 | {
|
---|
80 | instance->AddRef(); // protect FinalConstruct()
|
---|
81 | rv = instance->FinalConstruct();
|
---|
82 | if (NS_FAILED(rv))
|
---|
83 | instance->Release();
|
---|
84 | else
|
---|
85 | instance->AddRef(); // self-reference
|
---|
86 | }
|
---|
87 | else
|
---|
88 | {
|
---|
89 | rv = NS_ERROR_OUT_OF_MEMORY;
|
---|
90 | }
|
---|
91 | }
|
---|
92 | else
|
---|
93 | {
|
---|
94 | instance->AddRef();
|
---|
95 | }
|
---|
96 | *inst = instance;
|
---|
97 | return rv;
|
---|
98 | }
|
---|
99 |
|
---|
100 | static nsresult FactoryDestructor()
|
---|
101 | {
|
---|
102 | if (instance)
|
---|
103 | instance->Release();
|
---|
104 | return NS_OK;
|
---|
105 | }
|
---|
106 |
|
---|
107 | private:
|
---|
108 | static VirtualBoxClient *instance;
|
---|
109 | };
|
---|
110 |
|
---|
111 | VirtualBoxClient *VirtualBoxClientClassFactory::instance = nsnull;
|
---|
112 |
|
---|
113 |
|
---|
114 | NS_GENERIC_FACTORY_CONSTRUCTOR_WITH_RC(Session)
|
---|
115 |
|
---|
116 | NS_GENERIC_FACTORY_SINGLETON_CONSTRUCTOR_WITH_RC(VirtualBoxClient, VirtualBoxClientClassFactory::GetInstance)
|
---|
117 |
|
---|
118 | /**
|
---|
119 | * Component definition table.
|
---|
120 | * Lists all components defined in this module.
|
---|
121 | */
|
---|
122 | static const nsModuleComponentInfo components[] =
|
---|
123 | {
|
---|
124 | {
|
---|
125 | "Session component", // description
|
---|
126 | NS_SESSION_CID, NS_SESSION_CONTRACTID, // CID/ContractID
|
---|
127 | SessionConstructor, // constructor function
|
---|
128 | NULL, // registration function
|
---|
129 | NULL, // deregistration function
|
---|
130 | NULL, // destructor function
|
---|
131 | NS_CI_INTERFACE_GETTER_NAME(SessionWrap), // interfaces function
|
---|
132 | NULL, // language helper
|
---|
133 | &NS_CLASSINFO_NAME(SessionWrap) // global class info & flags
|
---|
134 | },
|
---|
135 | {
|
---|
136 | "VirtualBoxClient component", // description
|
---|
137 | NS_VIRTUALBOXCLIENT_CID, NS_VIRTUALBOXCLIENT_CONTRACTID, // CID/ContractID
|
---|
138 | VirtualBoxClientConstructor, // constructor function
|
---|
139 | NULL, // registration function
|
---|
140 | NULL, // deregistration function
|
---|
141 | VirtualBoxClientClassFactory::FactoryDestructor, // destructor function
|
---|
142 | NS_CI_INTERFACE_GETTER_NAME(VirtualBoxClientWrap), // interfaces function
|
---|
143 | NULL, // language helper
|
---|
144 | &NS_CLASSINFO_NAME(VirtualBoxClientWrap) // global class info & flags
|
---|
145 | },
|
---|
146 | };
|
---|
147 |
|
---|
148 | NS_IMPL_NSGETMODULE (VirtualBox_Client_Module, components)
|
---|
149 | /* vi: set tabstop=4 shiftwidth=4 expandtab: */
|
---|