ReactOS  0.4.14-dev-384-g5b37caa
CExplorerCommand.cpp
Go to the documentation of this file.
1 /*
2  * PROJECT: ReactOS Zip Shell Extension
3  * LICENSE: GPL-2.0+ (https://spdx.org/licenses/GPL-2.0+)
4  * PURPOSE: IExplorerCommand implementation
5  * COPYRIGHT: Copyright 2017 Mark Jansen (mark.jansen@reactos.org)
6  */
7 
8 #include "precomp.h"
9 
11  public CComObjectRootEx<CComMultiThreadModelNoCS>,
12  public IExplorerCommand
13 {
14 private:
16 
17 public:
18 
20  {
21  m_pZipObject = zipObject;
22  return S_OK;
23  }
24 
25  // *** IExplorerCommand methods ***
26  STDMETHODIMP GetTitle(IShellItemArray *psiItemArray, LPWSTR *ppszName)
27  {
29  return SHStrDup(Title, ppszName);
30  }
31  STDMETHODIMP GetIcon(IShellItemArray *psiItemArray, LPWSTR *ppszIcon)
32  {
33  CStringW IconName = L"zipfldr.dll,-1";
34  return SHStrDup(IconName, ppszIcon);
35  }
36  STDMETHODIMP GetToolTip(IShellItemArray *psiItemArray, LPWSTR *ppszInfotip)
37  {
39  return SHStrDup(HelpText, ppszInfotip);
40  }
41  STDMETHODIMP GetCanonicalName(GUID *pguidCommandName)
42  {
43  *pguidCommandName = CLSID_ZipFolderExtractAllCommand;
44  return S_OK;
45  }
46  STDMETHODIMP GetState(IShellItemArray *psiItemArray, BOOL fOkToBeSlow, EXPCMDSTATE *pCmdState)
47  {
48  *pCmdState = ECS_ENABLED;
49  return S_OK;
50  }
51  STDMETHODIMP Invoke(IShellItemArray *psiItemArray, IBindCtx *pbc)
52  {
53  CMINVOKECOMMANDINFO cm = { sizeof(cm), 0 };
54  cm.lpVerb = EXTRACT_VERBA;
55  cm.nShow = SW_SHOW;
56  return m_pZipObject->InvokeCommand(&cm);
57  }
58  STDMETHODIMP GetFlags(EXPCMDFLAGS *pFlags)
59  {
60  *pFlags = ECF_DEFAULT;
61  return S_OK;
62  }
63  STDMETHODIMP EnumSubCommands(IEnumExplorerCommand **ppEnum)
64  {
65  DbgPrint("%s\n", __FUNCTION__);
66  return E_NOTIMPL;
67  }
68 
69 public:
72 
74  COM_INTERFACE_ENTRY_IID(IID_IExplorerCommand, IExplorerCommand)
75  END_COM_MAP()
76 };
77 
78 
81  public IEnumExplorerCommand
82 {
83 private:
84  bool m_bFirst;
86 
87 public:
88 
90  :m_bFirst(true)
91  {
92  }
93 
95  {
96  m_pZipObject = zipObject;
97  return S_OK;
98  }
99 
100  // *** IEnumExplorerCommand methods ***
101  STDMETHODIMP Next(ULONG celt, IExplorerCommand **pUICommand, ULONG *pceltFetched)
102  {
103  if (!pUICommand)
104  return E_POINTER;
105 
106  if (pceltFetched)
107  *pceltFetched = 0;
108  if (m_bFirst && celt)
109  {
110  m_bFirst = false;
111  celt--;
112  HRESULT hr = ShellObjectCreatorInit<CExplorerCommand>(m_pZipObject, IID_PPV_ARG(IExplorerCommand, pUICommand));
113  if (SUCCEEDED(hr))
114  {
115  if (pceltFetched)
116  *pceltFetched = 1;
117  }
118  return hr;
119  }
120  return S_FALSE;
121  }
123  {
124  if (m_bFirst)
125  {
126  m_bFirst = false;
127  return S_OK;
128  }
129  return S_FALSE;
130  }
132  {
133  m_bFirst = true;
134  return S_OK;
135  }
136  STDMETHODIMP Clone(IEnumExplorerCommand **ppenum)
137  {
138  return E_NOTIMPL;
139  }
140 
141 public:
144 
146  COM_INTERFACE_ENTRY_IID(IID_IEnumExplorerCommand, IEnumExplorerCommand)
147  END_COM_MAP()
148 };
149 
152  public IExplorerCommandProvider
153 {
154 private:
156 
157 public:
159  {
160  m_pZipObject = zipObject;
161  return S_OK;
162  }
163 
164  // *** IExplorerCommandProvider methods ***
166  {
167  return ShellObjectCreatorInit<CEnumExplorerCommand>(m_pZipObject, riid, ppv);
168  }
169  STDMETHODIMP GetCommand(REFGUID rguidCommandId, REFIID riid, void **ppv)
170  {
172  *ppv = NULL;
173  return E_NOTIMPL;
174  }
175 
176 public:
179 
181  COM_INTERFACE_ENTRY_IID(IID_IExplorerCommandProvider, IExplorerCommandProvider)
182  END_COM_MAP()
183 };
184 
185 
187 {
188  return ShellObjectCreatorInit<CExplorerCommandProvider>(zipObject, riid, ppvOut);
189 }
#define REFIID
Definition: guiddef.h:118
#define true
Definition: stdbool.h:37
CComPtr< IContextMenu > m_pZipObject
EXTERN_C const GUID CLSID_ZipFolderExtractAllCommand
Definition: precomp.h:35
HRESULT hr
Definition: shlfolder.c:183
Definition: scsiwmi.h:51
#define DbgPrint
Definition: loader.c:25
REFIID riid
Definition: precomp.h:44
STDMETHODIMP Clone(IEnumExplorerCommand **ppenum)
REFIID LPVOID * ppv
Definition: atlbase.h:39
#define DECLARE_NOT_AGGREGATABLE(x)
Definition: atlcom.h:611
#define IID_PPV_ARG(Itype, ppType)
STDMETHODIMP GetTitle(IShellItemArray *psiItemArray, LPWSTR *ppszName)
CComPtr< IContextMenu > m_pZipObject
#define IDS_MENUITEM
Definition: resource.h:56
STDMETHODIMP EnumSubCommands(IEnumExplorerCommand **ppEnum)
STDMETHODIMP Initialize(IContextMenu *zipObject)
unsigned int BOOL
Definition: ntddk_ex.h:94
STDMETHODIMP GetFlags(EXPCMDFLAGS *pFlags)
STDMETHODIMP Initialize(IContextMenu *zipObject)
STDMETHODIMP GetIcon(IShellItemArray *psiItemArray, LPWSTR *ppszIcon)
#define STDMETHODIMP
Definition: basetyps.h:43
STDMETHODIMP GetCommand(REFGUID rguidCommandId, REFIID riid, void **ppv)
HRESULT _CExplorerCommandProvider_CreateInstance(IContextMenu *zipObject, REFIID riid, LPVOID *ppvOut)
#define S_FALSE
Definition: winerror.h:2357
smooth NULL
Definition: ftsmooth.c:416
#define IDS_HELPTEXT
Definition: resource.h:57
#define SW_SHOW
Definition: winuser.h:769
STDMETHODIMP GetState(IShellItemArray *psiItemArray, BOOL fOkToBeSlow, EXPCMDSTATE *pCmdState)
#define BEGIN_COM_MAP(x)
Definition: atlcom.h:541
STDMETHODIMP Invoke(IShellItemArray *psiItemArray, IBindCtx *pbc)
SIGDN PWSTR * ppszName
Definition: shobjidl.idl:588
static const WCHAR Title[]
Definition: oid.c:1259
STDMETHODIMP Next(ULONG celt, IExplorerCommand **pUICommand, ULONG *pceltFetched)
LONG HRESULT
Definition: typedefs.h:77
STDMETHODIMP GetCommands(IUnknown *punkSite, REFIID riid, void **ppv)
CComPtr< IContextMenu > m_pZipObject
STDMETHODIMP Initialize(IContextMenu *zipObject)
#define SHStrDup
Definition: shlwapi.h:1537
static const WCHAR L[]
Definition: oid.c:1250
STDMETHODIMP GetToolTip(IShellItemArray *psiItemArray, LPWSTR *ppszInfotip)
#define S_OK
Definition: intsafe.h:59
#define COM_INTERFACE_ENTRY_IID(iid, x)
Definition: atlcom.h:561
#define E_NOTIMPL
Definition: ddrawi.h:99
#define DECLARE_PROTECT_FINAL_CONSTRUCT()
Definition: atlcom.h:639
STDMETHODIMP GetCanonicalName(GUID *pguidCommandName)
const WCHAR * class
Definition: main.c:68
unsigned int ULONG
Definition: retypes.h:1
#define UNIMPLEMENTED
Definition: debug.h:114
#define MAKEINTRESOURCEW(i)
Definition: winuser.h:582
#define END_COM_MAP()
Definition: atlcom.h:552
WCHAR * LPWSTR
Definition: xmlstorage.h:184
#define E_POINTER
Definition: winerror.h:2365
#define __FUNCTION__
Definition: types.h:112
#define EXTRACT_VERBA
Definition: precomp.h:26
STDMETHODIMP Skip(ULONG celt)
#define SUCCEEDED(hr)
Definition: intsafe.h:57