VirtualBox

source: vbox/trunk/src/VBox/Additions/WINNT/VBoxCredProv/VBoxCredProvFactory.cpp@ 103914

Last change on this file since 103914 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: 3.6 KB
Line 
1/* $Id: VBoxCredProvFactory.cpp 98103 2023-01-17 14:15:46Z vboxsync $ */
2/** @file
3 * VBoxCredentialProvFactory - The VirtualBox Credential Provider Factory.
4 */
5
6/*
7 * Copyright (C) 2012-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
29/*********************************************************************************************************************************
30* Header Files *
31*********************************************************************************************************************************/
32#include "VBoxCredentialProvider.h"
33#include "VBoxCredProvFactory.h"
34#include "VBoxCredProvProvider.h"
35
36
37/*********************************************************************************************************************************
38* Internal Functions *
39*********************************************************************************************************************************/
40extern HRESULT VBoxCredProvProviderCreate(REFIID interfaceID, void **ppvInterface);
41
42
43VBoxCredProvFactory::VBoxCredProvFactory(void) :
44 m_cRefs(1) /* Start with one instance. */
45{
46}
47
48VBoxCredProvFactory::~VBoxCredProvFactory(void)
49{
50}
51
52ULONG
53VBoxCredProvFactory::AddRef(void)
54{
55 LONG cRefs = InterlockedIncrement(&m_cRefs);
56 VBoxCredProvVerbose(0, "VBoxCredProvFactory: AddRef: Returning refcount=%ld\n",
57 cRefs);
58 return cRefs;
59}
60
61ULONG
62VBoxCredProvFactory::Release(void)
63{
64 LONG cRefs = InterlockedDecrement(&m_cRefs);
65 VBoxCredProvVerbose(0, "VBoxCredProvFactory: Release: Returning refcount=%ld\n",
66 cRefs);
67 if (!cRefs)
68 {
69 VBoxCredProvVerbose(0, "VBoxCredProvFactory: Calling destructor\n");
70 delete this;
71 }
72 return cRefs;
73}
74
75HRESULT
76VBoxCredProvFactory::QueryInterface(REFIID interfaceID, void **ppvInterface)
77{
78 VBoxCredProvVerbose(0, "VBoxCredProvFactory: QueryInterface\n");
79
80 HRESULT hr = S_OK;
81 if (ppvInterface)
82 {
83 if ( IID_IClassFactory == interfaceID
84 || IID_IUnknown == interfaceID)
85 {
86 *ppvInterface = static_cast<IUnknown*>(this);
87 reinterpret_cast<IUnknown*>(*ppvInterface)->AddRef();
88 }
89 else
90 {
91 *ppvInterface = NULL;
92 hr = E_NOINTERFACE;
93 }
94 }
95 else
96 hr = E_INVALIDARG;
97 return hr;
98}
99
100HRESULT
101VBoxCredProvFactory::CreateInstance(IUnknown *pUnkOuter, REFIID interfaceID, void **ppvInterface)
102{
103 if (pUnkOuter)
104 return CLASS_E_NOAGGREGATION;
105 return VBoxCredProvProviderCreate(interfaceID, ppvInterface);
106}
107
108HRESULT
109VBoxCredProvFactory::LockServer(BOOL fLock)
110{
111 if (fLock)
112 VBoxCredentialProviderAcquire();
113 else
114 VBoxCredentialProviderRelease();
115 return S_OK;
116}
117
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