ReactOS  0.4.14-dev-614-gbfd8a84
factory.cpp
Go to the documentation of this file.
1 /* Copyright (c) Mark Harmstone 2016-17
2  *
3  * This file is part of WinBtrfs.
4  *
5  * WinBtrfs is free software: you can redistribute it and/or modify
6  * it under the terms of the GNU Lesser General Public Licence as published by
7  * the Free Software Foundation, either version 3 of the Licence, or
8  * (at your option) any later version.
9  *
10  * WinBtrfs is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU Lesser General Public Licence for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public Licence
16  * along with WinBtrfs. If not, see <http://www.gnu.org/licenses/>. */
17 
18 #include "shellext.h"
19 #include <windows.h>
20 #include "factory.h"
21 #include "iconoverlay.h"
22 #include "contextmenu.h"
23 #include "propsheet.h"
24 #include "volpropsheet.h"
25 
27  if (iid == IID_IUnknown || iid == IID_IClassFactory) {
28  *ppv = static_cast<IClassFactory*>(this);
29  } else {
30  *ppv = nullptr;
31  return E_NOINTERFACE;
32  }
33 
34  reinterpret_cast<IUnknown*>(*ppv)->AddRef();
35 
36  return S_OK;
37 }
38 
40  return E_NOTIMPL;
41 }
42 
43 HRESULT __stdcall Factory::CreateInstance(IUnknown* pUnknownOuter, const IID& iid, void** ppv) {
44  if (pUnknownOuter)
45  return CLASS_E_NOAGGREGATION;
46 
47  switch (type) {
48  case FactoryIconHandler:
49  if (iid == IID_IUnknown || iid == IID_IShellIconOverlayIdentifier) {
51  if (!bio)
52  return E_OUTOFMEMORY;
53 
54  return bio->QueryInterface(iid, ppv);
55  }
56  break;
57 
58  case FactoryContextMenu:
59  if (iid == IID_IUnknown || iid == IID_IContextMenu || iid == IID_IShellExtInit) {
61  if (!bcm)
62  return E_OUTOFMEMORY;
63 
64  return bcm->QueryInterface(iid, ppv);
65  }
66  break;
67 
68  case FactoryPropSheet:
69  if (iid == IID_IUnknown || iid == IID_IShellPropSheetExt || iid == IID_IShellExtInit) {
70  BtrfsPropSheet* bps = new BtrfsPropSheet;
71  if (!bps)
72  return E_OUTOFMEMORY;
73 
74  return bps->QueryInterface(iid, ppv);
75  }
76  break;
77 
79  if (iid == IID_IUnknown || iid == IID_IShellPropSheetExt || iid == IID_IShellExtInit) {
81  if (!bps)
82  return E_OUTOFMEMORY;
83 
84  return bps->QueryInterface(iid, ppv);
85  }
86  break;
87 
88  default:
89  break;
90  }
91 
92  *ppv = nullptr;
93  return E_NOINTERFACE;
94 }
HRESULT __stdcall QueryInterface(REFIID riid, void **ppObj)
Definition: factory.cpp:26
#define E_NOINTERFACE
Definition: winerror.h:2364
virtual HRESULT __stdcall CreateInstance(IUnknown *pUnknownOuter, const IID &iid, void **ppv)
Definition: factory.cpp:43
HRESULT __stdcall QueryInterface(REFIID riid, void **ppObj)
Definition: propsheet.cpp:73
REFIID LPVOID * ppv
Definition: atlbase.h:39
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
unsigned int BOOL
Definition: ntddk_ex.h:94
LONG HRESULT
Definition: typedefs.h:77
const GUID IID_IUnknown
#define __stdcall
Definition: typedefs.h:25
virtual HRESULT __stdcall LockServer(BOOL bLock)
Definition: factory.cpp:39
#define CLASS_E_NOAGGREGATION
Definition: winerror.h:2662
HRESULT __stdcall QueryInterface(REFIID riid, void **ppObj)
#define S_OK
Definition: intsafe.h:59
#define E_NOTIMPL
Definition: ddrawi.h:99
HRESULT __stdcall QueryInterface(REFIID riid, void **ppObj)
Definition: contextmenu.cpp:70
const GUID IID_IClassFactory
HRESULT __stdcall QueryInterface(REFIID riid, void **ppObj)
Definition: iconoverlay.cpp:35