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.
|
|
|
|
*/
|
|
|
|
|
2015-02-04 21:54:34 +03:00
|
|
|
#include "stdafx.h"
|
|
|
|
|
2014-07-30 19:20:55 +04:00
|
|
|
#include "OCOverlayFactory.h"
|
|
|
|
#include "OCOverlay.h"
|
|
|
|
|
|
|
|
extern long dllReferenceCount;
|
|
|
|
|
2014-08-04 17:40:08 +04:00
|
|
|
OCOverlayFactory::OCOverlayFactory(int state)
|
2017-01-05 19:28:28 +03:00
|
|
|
: _referenceCount(1), _state(state)
|
2014-07-30 19:20:55 +04:00
|
|
|
{
|
|
|
|
InterlockedIncrement(&dllReferenceCount);
|
|
|
|
}
|
|
|
|
|
|
|
|
OCOverlayFactory::~OCOverlayFactory()
|
|
|
|
{
|
|
|
|
InterlockedDecrement(&dllReferenceCount);
|
|
|
|
}
|
|
|
|
|
|
|
|
IFACEMETHODIMP OCOverlayFactory::QueryInterface(REFIID riid, void **ppv)
|
|
|
|
{
|
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;
|
|
|
|
}
|
|
|
|
|
|
|
|
IFACEMETHODIMP_(ULONG) OCOverlayFactory::AddRef()
|
|
|
|
{
|
|
|
|
return InterlockedIncrement(&_referenceCount);
|
|
|
|
}
|
|
|
|
|
|
|
|
IFACEMETHODIMP_(ULONG) OCOverlayFactory::Release()
|
|
|
|
{
|
|
|
|
ULONG cRef = InterlockedDecrement(&_referenceCount);
|
|
|
|
|
|
|
|
if (0 == cRef)
|
|
|
|
{
|
|
|
|
delete this;
|
|
|
|
}
|
|
|
|
return cRef;
|
|
|
|
}
|
|
|
|
|
|
|
|
IFACEMETHODIMP OCOverlayFactory::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-05 01:51:32 +03:00
|
|
|
if (pUnkOuter != nullptr) { return hResult; }
|
2014-07-30 19:20:55 +04:00
|
|
|
|
2017-01-05 19:28:28 +03:00
|
|
|
hResult = E_OUTOFMEMORY;
|
2014-08-04 17:40:08 +04:00
|
|
|
OCOverlay *lrOverlay = new (std::nothrow) OCOverlay(_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
|
|
|
}
|
|
|
|
|
|
|
|
IFACEMETHODIMP OCOverlayFactory::LockServer(BOOL fLock)
|
|
|
|
{
|
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
|
|
|
}
|