summaryrefslogtreecommitdiff
path: root/network/wlan/ihvsampleui/IHVClassFactory.cpp
diff options
context:
space:
mode:
authorDave Wilson <[email protected]>2015-03-17 19:50:07 -0700
committerDave Wilson <[email protected]>2015-03-17 19:50:07 -0700
commit97cf5197cf5b882b2c689d8dc2b555f2edf8f418 (patch)
tree46f3701832d70b420eb0fc0eb93261f9da45db3f /network/wlan/ihvsampleui/IHVClassFactory.cpp
parentef1905bf1e8825bb31120dfb27e0daf3154d859a (diff)
Initial publish
Diffstat (limited to 'network/wlan/ihvsampleui/IHVClassFactory.cpp')
-rw-r--r--network/wlan/ihvsampleui/IHVClassFactory.cpp166
1 files changed, 166 insertions, 0 deletions
diff --git a/network/wlan/ihvsampleui/IHVClassFactory.cpp b/network/wlan/ihvsampleui/IHVClassFactory.cpp
new file mode 100644
index 00000000..7da337d5
--- /dev/null
+++ b/network/wlan/ihvsampleui/IHVClassFactory.cpp
@@ -0,0 +1,166 @@
+//
+// Copyright (C) Microsoft Corporation 2005
+// IHV UI Extension sample
+//
+
+#include "precomp.h"
+#include "ihvuiinc_i.c"
+
+extern long g_serverLock; //lock count on server
+
+//
+// IUnknown Implementation
+//
+CIHVClassFactory::CIHVClassFactory() : m_refCount(1)
+{
+}
+
+CIHVClassFactory::~CIHVClassFactory()
+{
+}
+
+STDMETHODIMP_(ULONG)
+CIHVClassFactory::AddRef()
+{
+ return InterlockedIncrement(&m_refCount);
+}
+
+STDMETHODIMP_(ULONG)
+CIHVClassFactory::Release()
+{
+ ULONG refCount = InterlockedDecrement(&m_refCount);
+ if (refCount == 0)
+ {
+ delete this;
+ }
+ return refCount;
+}
+
+STDMETHODIMP
+CIHVClassFactory::QueryInterface(
+ REFIID riid,
+ void **ppvObject
+ )
+{
+ HRESULT hr = E_INVALIDARG;
+ if (NULL != ppvObject)
+ {
+ hr = S_OK;
+ if (riid == IID_IUnknown)
+ {
+ *ppvObject = static_cast<IUnknown *>(this);
+ }
+ else if (riid == IID_IClassFactory)
+ {
+ *ppvObject = static_cast<IClassFactory *>(this);
+ }
+ else
+ {
+ *ppvObject = NULL;
+ return E_NOINTERFACE;
+ }
+ reinterpret_cast<IUnknown *>(*ppvObject)->AddRef();
+ }
+
+ return hr;
+}
+
+
+//
+// IClassFactory Implementaion
+//
+STDMETHODIMP
+CIHVClassFactory::CreateInstance(
+ IUnknown *pUnkOuter,
+ REFIID riid,
+ void **ppvObject
+ )
+{
+ HRESULT hr = E_NOINTERFACE;
+
+ // aggregation not supported
+ if (pUnkOuter != NULL)
+ {
+ return CLASS_E_NOAGGREGATION;
+ }
+
+ if (NULL == ppvObject)
+ {
+ return E_INVALIDARG;
+ }
+
+ // Figure out which interface is wanted
+ // the ui will call us only as IID_IDot11ExtUI
+ if (IID_IDot11SampleExtUI == riid ||
+ IID_IDot11ExtUI == riid ||
+ IID_IWizardExtension == riid)
+ {
+ CDot11SampleExtUI *pExtUI = new(std::nothrow) CDot11SampleExtUI();
+ if (NULL == pExtUI)
+ {
+ return E_OUTOFMEMORY;
+ }
+
+ pExtUI->AddRef();
+ hr = pExtUI->QueryInterface(riid, ppvObject);
+
+ pExtUI->Release();
+ }
+ else if (IID_IDot11SampleExtUIConProperty == riid)
+ {
+ CDot11SampleExtUIConProperty *pCDot11SampleExtUIConProperty = new(std::nothrow) CDot11SampleExtUIConProperty();
+ if (NULL == pCDot11SampleExtUIConProperty)
+ {
+ return E_OUTOFMEMORY;
+ }
+
+ pCDot11SampleExtUIConProperty->AddRef();
+ hr = pCDot11SampleExtUIConProperty->QueryInterface(riid, ppvObject);
+
+ pCDot11SampleExtUIConProperty->Release();
+ }
+ else if (IID_IDot11SampleExtUISecProperty == riid)
+ {
+ CDot11SampleExtUISecProperty *pCDot11SampleExtUISecProperty = new(std::nothrow) CDot11SampleExtUISecProperty();
+ if (NULL == pCDot11SampleExtUISecProperty)
+ {
+ return E_OUTOFMEMORY;
+ }
+
+ pCDot11SampleExtUISecProperty->AddRef();
+ hr = pCDot11SampleExtUISecProperty->QueryInterface(riid, ppvObject);
+
+ pCDot11SampleExtUISecProperty->Release();
+ }
+ else if (IID_IDot11SampleExtUIKeyProperty == riid)
+ {
+ CDot11SampleExtUIKeyProperty *pCDot11SampleExtUIKeyProperty = new(std::nothrow) CDot11SampleExtUIKeyProperty();
+ if (NULL == pCDot11SampleExtUIKeyProperty)
+ {
+ return E_OUTOFMEMORY;
+ }
+
+ pCDot11SampleExtUIKeyProperty->AddRef();
+ hr = pCDot11SampleExtUIKeyProperty->QueryInterface(riid, ppvObject);
+
+ pCDot11SampleExtUIKeyProperty->Release();
+ }
+
+ return hr;
+}
+
+
+STDMETHODIMP
+CIHVClassFactory::LockServer(BOOL fLock)
+{
+ if (fLock)
+ {
+ InterlockedIncrement(&g_serverLock);
+ }
+ else
+ {
+ InterlockedDecrement(&g_serverLock);
+ }
+
+ return S_OK;
+}