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 <shlobj.h>
19 
20 extern LONG objs_loaded;
21 
22 class BtrfsIconOverlay : public IShellIconOverlayIdentifier {
23 public:
24     BtrfsIconOverlay() {
25         refcount = 0;
26         InterlockedIncrement(&objs_loaded);
27     }
28 
29     virtual ~BtrfsIconOverlay() {
30         InterlockedDecrement(&objs_loaded);
31     }
32 
33     // IUnknown
34 
35     HRESULT __stdcall QueryInterface(REFIID riid, void **ppObj);
36 
37     ULONG __stdcall AddRef() {
38         return InterlockedIncrement(&refcount);
39     }
40 
41     ULONG __stdcall Release() {
42         LONG rc = InterlockedDecrement(&refcount);
43 
44         if (rc == 0)
45             delete this;
46 
47         return rc;
48     }
49 
50     // IShellIconOverlayIdentifier
51 
52     virtual HRESULT __stdcall GetOverlayInfo(PWSTR pwszIconFile, int cchMax, int* pIndex, DWORD* pdwFlags);
53     virtual HRESULT __stdcall GetPriority(int *pPriority);
54     virtual HRESULT __stdcall IsMemberOf(PCWSTR pwszPath, DWORD dwAttrib);
55 
56 private:
57     LONG refcount;
58 };
59