2017-09-08 11:59:42 +00:00
|
|
|
/* Copyright (c) Mark Harmstone 2016-17
|
|
|
|
*
|
2016-11-02 19:36:59 +00:00
|
|
|
* This file is part of WinBtrfs.
|
2017-09-08 11:59:42 +00:00
|
|
|
*
|
2016-11-02 19:36:59 +00:00
|
|
|
* WinBtrfs is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU Lesser General Public Licence as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the Licence, or
|
|
|
|
* (at your option) any later version.
|
2017-09-08 11:59:42 +00:00
|
|
|
*
|
2016-11-02 19:36:59 +00:00
|
|
|
* WinBtrfs 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 Licence for more details.
|
2017-09-08 11:59:42 +00:00
|
|
|
*
|
2016-11-02 19:36:59 +00:00
|
|
|
* You should have received a copy of the GNU Lesser General Public Licence
|
|
|
|
* along with WinBtrfs. If not, see <http://www.gnu.org/licenses/>. */
|
|
|
|
|
2017-11-26 13:16:29 +00:00
|
|
|
#pragma once
|
|
|
|
|
2016-11-02 19:36:59 +00:00
|
|
|
#include <shlobj.h>
|
|
|
|
|
|
|
|
extern LONG objs_loaded;
|
|
|
|
|
|
|
|
class BtrfsContextMenu : public IShellExtInit, IContextMenu {
|
|
|
|
public:
|
|
|
|
BtrfsContextMenu() {
|
|
|
|
refcount = 0;
|
2018-12-16 11:04:40 +00:00
|
|
|
ignore = true;
|
|
|
|
stgm_set = false;
|
|
|
|
uacicon = nullptr;
|
|
|
|
allow_snapshot = false;
|
2016-11-02 19:36:59 +00:00
|
|
|
InterlockedIncrement(&objs_loaded);
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual ~BtrfsContextMenu() {
|
|
|
|
if (stgm_set) {
|
|
|
|
GlobalUnlock(stgm.hGlobal);
|
|
|
|
ReleaseStgMedium(&stgm);
|
|
|
|
}
|
2017-09-08 11:59:42 +00:00
|
|
|
|
|
|
|
if (uacicon)
|
|
|
|
DeleteObject(uacicon);
|
|
|
|
|
2016-11-02 19:36:59 +00:00
|
|
|
InterlockedDecrement(&objs_loaded);
|
|
|
|
}
|
|
|
|
|
|
|
|
// IUnknown
|
2017-09-08 11:59:42 +00:00
|
|
|
|
2016-11-02 19:36:59 +00:00
|
|
|
HRESULT __stdcall QueryInterface(REFIID riid, void **ppObj);
|
2017-09-08 11:59:42 +00:00
|
|
|
|
2016-11-02 19:36:59 +00:00
|
|
|
ULONG __stdcall AddRef() {
|
|
|
|
return InterlockedIncrement(&refcount);
|
|
|
|
}
|
|
|
|
|
|
|
|
ULONG __stdcall Release() {
|
|
|
|
LONG rc = InterlockedDecrement(&refcount);
|
2017-09-08 11:59:42 +00:00
|
|
|
|
2016-11-02 19:36:59 +00:00
|
|
|
if (rc == 0)
|
|
|
|
delete this;
|
2017-09-08 11:59:42 +00:00
|
|
|
|
2016-11-02 19:36:59 +00:00
|
|
|
return rc;
|
|
|
|
}
|
2017-09-08 11:59:42 +00:00
|
|
|
|
2016-11-02 19:36:59 +00:00
|
|
|
// IShellExtInit
|
2017-09-08 11:59:42 +00:00
|
|
|
|
2016-11-02 19:36:59 +00:00
|
|
|
virtual HRESULT __stdcall Initialize(PCIDLIST_ABSOLUTE pidlFolder, IDataObject* pdtobj, HKEY hkeyProgID);
|
2017-09-08 11:59:42 +00:00
|
|
|
|
2016-11-02 19:36:59 +00:00
|
|
|
// IContextMenu
|
2017-09-08 11:59:42 +00:00
|
|
|
|
2016-11-02 19:36:59 +00:00
|
|
|
virtual HRESULT __stdcall QueryContextMenu(HMENU hmenu, UINT indexMenu, UINT idCmdFirst, UINT idCmdLast, UINT uFlags);
|
|
|
|
virtual HRESULT __stdcall InvokeCommand(LPCMINVOKECOMMANDINFO pici);
|
|
|
|
virtual HRESULT __stdcall GetCommandString(UINT_PTR idCmd, UINT uFlags, UINT* pwReserved, LPSTR pszName, UINT cchMax);
|
|
|
|
|
|
|
|
private:
|
|
|
|
LONG refcount;
|
2018-12-16 11:04:40 +00:00
|
|
|
bool ignore, allow_snapshot;
|
|
|
|
bool bg;
|
|
|
|
wstring path;
|
2016-11-02 19:36:59 +00:00
|
|
|
STGMEDIUM stgm;
|
2018-12-16 11:04:40 +00:00
|
|
|
bool stgm_set;
|
2017-09-08 11:59:42 +00:00
|
|
|
HBITMAP uacicon;
|
|
|
|
|
2018-12-16 11:04:40 +00:00
|
|
|
void reflink_copy(HWND hwnd, const WCHAR* fn, const WCHAR* dir);
|
2017-09-08 11:59:42 +00:00
|
|
|
void get_uac_icon();
|
2016-11-02 19:36:59 +00:00
|
|
|
};
|