VirtualBox

source: vbox/trunk/src/VBox/Main/src-client/xpcom/module.cpp@ 103415

Last change on this file since 103415 was 98103, checked in by vboxsync, 2 years ago

Copyright year updates by scm.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 4.6 KB
Line 
1/* $Id: module.cpp 98103 2023-01-17 14:15:46Z vboxsync $ */
2/** @file
3 * XPCOM module implementation functions
4 */
5
6/*
7 * Copyright (C) 2006-2023 Oracle and/or its affiliates.
8 *
9 * This file is part of VirtualBox base platform packages, as
10 * available from https://www.virtualbox.org.
11 *
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation, in version 3 of the
15 * License.
16 *
17 * This program is distributed in the hope that it will be useful, but
18 * WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20 * General Public License for more details.
21 *
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, see <https://www.gnu.org/licenses>.
24 *
25 * SPDX-License-Identifier: GPL-3.0-only
26 */
27
28#define LOG_GROUP LOG_GROUP_MAIN
29
30/* Make sure all the stdint.h macros are included - must come first! */
31#ifndef __STDC_LIMIT_MACROS
32# define __STDC_LIMIT_MACROS
33#endif
34#ifndef __STDC_CONSTANT_MACROS
35# define __STDC_CONSTANT_MACROS
36#endif
37
38#include <nsIGenericFactory.h>
39
40// generated file
41#include <VBox/com/VirtualBox.h>
42
43#include "SessionImpl.h"
44#include "VirtualBoxClientImpl.h"
45#include "RemoteUSBDeviceImpl.h"
46#include "USBDeviceImpl.h"
47
48// XPCOM glue code unfolding
49
50/*
51 * Declare extern variables here to tell the compiler that
52 * NS_DECL_CLASSINFO(SessionWrap)
53 * already exists in the VBoxAPIWrap library.
54 */
55NS_DECL_CI_INTERFACE_GETTER(SessionWrap)
56extern nsIClassInfo *NS_CLASSINFO_NAME(SessionWrap);
57
58/*
59 * Declare extern variables here to tell the compiler that
60 * NS_DECL_CLASSINFO(VirtualBoxClientWrap)
61 * already exists in the VBoxAPIWrap library.
62 */
63NS_DECL_CI_INTERFACE_GETTER(VirtualBoxClientWrap)
64extern nsIClassInfo *NS_CLASSINFO_NAME(VirtualBoxClientWrap);
65
66/**
67 * Singleton class factory that holds a reference to the created instance
68 * (preventing it from being destroyed) until the module is explicitly
69 * unloaded by the XPCOM shutdown code.
70 *
71 * Suitable for IN-PROC components.
72 */
73class VirtualBoxClientClassFactory : public VirtualBoxClient
74{
75public:
76 virtual ~VirtualBoxClientClassFactory()
77 {
78 FinalRelease();
79 instance = 0;
80 }
81
82 static nsresult GetInstance(VirtualBoxClient **inst)
83 {
84 int rv = NS_OK;
85 if (instance == 0)
86 {
87 instance = new VirtualBoxClientClassFactory();
88 if (instance)
89 {
90 instance->AddRef(); // protect FinalConstruct()
91 rv = instance->FinalConstruct();
92 if (NS_FAILED(rv))
93 instance->Release();
94 else
95 instance->AddRef(); // self-reference
96 }
97 else
98 {
99 rv = NS_ERROR_OUT_OF_MEMORY;
100 }
101 }
102 else
103 {
104 instance->AddRef();
105 }
106 *inst = instance;
107 return rv;
108 }
109
110 static nsresult FactoryDestructor()
111 {
112 if (instance)
113 instance->Release();
114 return NS_OK;
115 }
116
117private:
118 static VirtualBoxClient *instance;
119};
120
121VirtualBoxClient *VirtualBoxClientClassFactory::instance = nsnull;
122
123
124NS_GENERIC_FACTORY_CONSTRUCTOR_WITH_RC(Session)
125
126NS_GENERIC_FACTORY_SINGLETON_CONSTRUCTOR_WITH_RC(VirtualBoxClient, VirtualBoxClientClassFactory::GetInstance)
127
128/**
129 * Component definition table.
130 * Lists all components defined in this module.
131 */
132static const nsModuleComponentInfo components[] =
133{
134 {
135 "Session component", // description
136 NS_SESSION_CID, NS_SESSION_CONTRACTID, // CID/ContractID
137 SessionConstructor, // constructor function
138 NULL, // registration function
139 NULL, // deregistration function
140 NULL, // destructor function
141 NS_CI_INTERFACE_GETTER_NAME(SessionWrap), // interfaces function
142 NULL, // language helper
143 &NS_CLASSINFO_NAME(SessionWrap) // global class info & flags
144 },
145 {
146 "VirtualBoxClient component", // description
147 NS_VIRTUALBOXCLIENT_CID, NS_VIRTUALBOXCLIENT_CONTRACTID, // CID/ContractID
148 VirtualBoxClientConstructor, // constructor function
149 NULL, // registration function
150 NULL, // deregistration function
151 VirtualBoxClientClassFactory::FactoryDestructor, // destructor function
152 NS_CI_INTERFACE_GETTER_NAME(VirtualBoxClientWrap), // interfaces function
153 NULL, // language helper
154 &NS_CLASSINFO_NAME(VirtualBoxClientWrap) // global class info & flags
155 },
156};
157
158NS_IMPL_NSGETMODULE (VirtualBox_Client_Module, components)
159/* vi: set tabstop=4 shiftwidth=4 expandtab: */
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