2014-07-30 19:20:55 +04:00
|
|
|
/**
|
|
|
|
* Copyright (c) 2000-2013 Liferay, Inc. All rights reserved.
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or modify it under
|
|
|
|
* the terms of the GNU Lesser General Public License as published by the Free
|
|
|
|
* Software Foundation; either version 2.1 of the License, or (at your option)
|
|
|
|
* any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful, but WITHOUT
|
|
|
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
|
|
|
* FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
|
|
|
|
* details.
|
|
|
|
*/
|
|
|
|
|
2020-08-17 21:35:39 +03:00
|
|
|
#include <windows.h>
|
|
|
|
#include <new>
|
2015-02-04 21:54:34 +03:00
|
|
|
|
2020-08-18 20:11:08 +03:00
|
|
|
#include "NCOverlayFactory.h"
|
|
|
|
#include "NCOverlay.h"
|
2014-07-30 19:20:55 +04:00
|
|
|
|
|
|
|
extern long dllReferenceCount;
|
|
|
|
|
2020-08-18 20:11:08 +03:00
|
|
|
NCOverlayFactory::NCOverlayFactory(int state)
|
2017-01-05 19:28:28 +03:00
|
|
|
: _referenceCount(1), _state(state)
|
2014-07-30 19:20:55 +04:00
|
|
|
{
|
|
|
|
InterlockedIncrement(&dllReferenceCount);
|
|
|
|
}
|
|
|
|
|
2020-08-18 20:11:08 +03:00
|
|
|
NCOverlayFactory::~NCOverlayFactory()
|
2014-07-30 19:20:55 +04:00
|
|
|
{
|
|
|
|
InterlockedDecrement(&dllReferenceCount);
|
|
|
|
}
|
|
|
|
|
2020-08-18 20:11:08 +03:00
|
|
|
IFACEMETHODIMP NCOverlayFactory::QueryInterface(REFIID riid, void **ppv)
|
2014-07-30 19:20:55 +04:00
|
|
|
{
|
2017-01-05 19:28:28 +03:00
|
|
|
HRESULT hResult = S_OK;
|
2014-07-30 19:20:55 +04:00
|
|
|
|
|
|
|
if (IsEqualIID(IID_IUnknown, riid) ||
|
|
|
|
IsEqualIID(IID_IClassFactory, riid))
|
|
|
|
{
|
|
|
|
*ppv = static_cast<IUnknown *>(this);
|
|
|
|
AddRef();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
hResult = E_NOINTERFACE;
|
2020-06-05 01:51:32 +03:00
|
|
|
*ppv = nullptr;
|
2014-07-30 19:20:55 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
return hResult;
|
|
|
|
}
|
|
|
|
|
2020-08-18 20:11:08 +03:00
|
|
|
IFACEMETHODIMP_(ULONG) NCOverlayFactory::AddRef()
|
2014-07-30 19:20:55 +04:00
|
|
|
{
|
|
|
|
return InterlockedIncrement(&_referenceCount);
|
|
|
|
}
|
|
|
|
|
2020-08-18 20:11:08 +03:00
|
|
|
IFACEMETHODIMP_(ULONG) NCOverlayFactory::Release()
|
2014-07-30 19:20:55 +04:00
|
|
|
{
|
|
|
|
ULONG cRef = InterlockedDecrement(&_referenceCount);
|
|
|
|
|
|
|
|
if (0 == cRef)
|
|
|
|
{
|
|
|
|
delete this;
|
|
|
|
}
|
|
|
|
return cRef;
|
|
|
|
}
|
|
|
|
|
2020-08-18 20:11:08 +03:00
|
|
|
IFACEMETHODIMP NCOverlayFactory::CreateInstance(
|
2017-01-05 19:28:28 +03:00
|
|
|
IUnknown *pUnkOuter, REFIID riid, void **ppv)
|
2014-07-30 19:20:55 +04:00
|
|
|
{
|
2017-01-05 19:28:28 +03:00
|
|
|
HRESULT hResult = CLASS_E_NOAGGREGATION;
|
2014-07-30 19:20:55 +04:00
|
|
|
|
2020-06-10 04:47:49 +03:00
|
|
|
if (pUnkOuter) { return hResult; }
|
2014-07-30 19:20:55 +04:00
|
|
|
|
2017-01-05 19:28:28 +03:00
|
|
|
hResult = E_OUTOFMEMORY;
|
2023-02-22 00:14:22 +03:00
|
|
|
auto lrOverlay = new (std::nothrow) NCOverlay(_state);
|
2017-01-05 19:28:28 +03:00
|
|
|
if (!lrOverlay) { return hResult; }
|
2014-07-30 19:20:55 +04:00
|
|
|
|
|
|
|
hResult = lrOverlay->QueryInterface(riid, ppv);
|
2017-01-05 19:28:28 +03:00
|
|
|
lrOverlay->Release();
|
2014-07-30 19:20:55 +04:00
|
|
|
|
2017-01-05 19:28:28 +03:00
|
|
|
return hResult;
|
2014-07-30 19:20:55 +04:00
|
|
|
}
|
|
|
|
|
2020-08-18 20:11:08 +03:00
|
|
|
IFACEMETHODIMP NCOverlayFactory::LockServer(BOOL fLock)
|
2014-07-30 19:20:55 +04:00
|
|
|
{
|
2014-08-04 17:40:08 +04:00
|
|
|
if (fLock) {
|
2014-07-30 19:20:55 +04:00
|
|
|
InterlockedIncrement(&dllReferenceCount);
|
2014-08-04 17:40:08 +04:00
|
|
|
} else {
|
2014-07-30 19:20:55 +04:00
|
|
|
InterlockedDecrement(&dllReferenceCount);
|
|
|
|
}
|
|
|
|
return S_OK;
|
2020-06-05 01:51:32 +03:00
|
|
|
}
|