xref: /reactos/dll/win32/shell32/CFolderItems.h (revision 1734f297)
1 /*
2  * PROJECT:     shell32
3  * LICENSE:     LGPL-2.1+ (https://spdx.org/licenses/LGPL-2.1+)
4  * PURPOSE:     FolderItem(s) implementation
5  * COPYRIGHT:   Copyright 2015-2018 Mark Jansen (mark.jansen@reactos.org)
6  */
7 
8 #ifndef _FOLDERITEM_H_
9 #define _FOLDERITEM_H_
10 
11 
12 class CFolderItem:
13     public CComCoClass<CFolderItem>,
14     public CComObjectRootEx<CComMultiThreadModelNoCS>,
15     public IDispatchImpl<FolderItem, &IID_FolderItem>
16 {
17 private:
18     CComHeapPtr<ITEMIDLIST> m_idlist;
19     CComPtr<Folder> m_Folder;
20 
21 public:
22     CFolderItem();
23     ~CFolderItem();
24 
25     HRESULT Initialize(Folder* folder, LPITEMIDLIST idlist);
26 
27 
28     // *** FolderItem methods ***
29     virtual HRESULT STDMETHODCALLTYPE get_Application(IDispatch **ppid);
30     virtual HRESULT STDMETHODCALLTYPE get_Parent(IDispatch **ppid);
31     virtual HRESULT STDMETHODCALLTYPE get_Name(BSTR *pbs);
32     virtual HRESULT STDMETHODCALLTYPE put_Name(BSTR bs);
33     virtual HRESULT STDMETHODCALLTYPE get_Path(BSTR *pbs);
34     virtual HRESULT STDMETHODCALLTYPE get_GetLink(IDispatch **ppid);
35     virtual HRESULT STDMETHODCALLTYPE get_GetFolder(IDispatch **ppid);
36     virtual HRESULT STDMETHODCALLTYPE get_IsLink(VARIANT_BOOL *pb);
37     virtual HRESULT STDMETHODCALLTYPE get_IsFolder(VARIANT_BOOL *pb);
38     virtual HRESULT STDMETHODCALLTYPE get_IsFileSystem(VARIANT_BOOL *pb);
39     virtual HRESULT STDMETHODCALLTYPE get_IsBrowsable(VARIANT_BOOL *pb);
40     virtual HRESULT STDMETHODCALLTYPE get_ModifyDate(DATE *pdt);
41     virtual HRESULT STDMETHODCALLTYPE put_ModifyDate(DATE dt);
42     virtual HRESULT STDMETHODCALLTYPE get_Size(LONG *pul);
43     virtual HRESULT STDMETHODCALLTYPE get_Type(BSTR *pbs);
44     virtual HRESULT STDMETHODCALLTYPE Verbs(FolderItemVerbs **ppfic);
45     virtual HRESULT STDMETHODCALLTYPE InvokeVerb(VARIANT vVerb);
46 
47 
48 DECLARE_NOT_AGGREGATABLE(CFolderItem)
49 DECLARE_PROTECT_FINAL_CONSTRUCT()
50 
51 BEGIN_COM_MAP(CFolderItem)
52     COM_INTERFACE_ENTRY_IID(IID_FolderItem, FolderItem)
53     COM_INTERFACE_ENTRY_IID(IID_IDispatch, IDispatch)
54 END_COM_MAP()
55 };
56 
57 class CFolderItems:
58     public CComCoClass<CFolderItems>,
59     public CComObjectRootEx<CComMultiThreadModelNoCS>,
60     public IDispatchImpl<FolderItems, &IID_FolderItems>
61 {
62 private:
63     CComHeapPtr<ITEMIDLIST> m_idlist;
64     CComPtr<IEnumIDList> m_EnumIDList;
65     CComPtr<Folder> m_Folder;
66     long m_Count;
67 
68 public:
69     CFolderItems();
70     ~CFolderItems();
71 
72     // Please note: CFolderItems takes ownership of idlist.
73     HRESULT Initialize(LPITEMIDLIST idlist, Folder* parent);
74 
75     // *** FolderItems methods ***
76     virtual HRESULT STDMETHODCALLTYPE get_Count(long *plCount);
77     virtual HRESULT STDMETHODCALLTYPE get_Application(IDispatch **ppid);
78     virtual HRESULT STDMETHODCALLTYPE get_Parent(IDispatch **ppid);
79     virtual HRESULT STDMETHODCALLTYPE Item(VARIANT index, FolderItem **ppid);
80     virtual HRESULT STDMETHODCALLTYPE _NewEnum(IUnknown **ppunk);
81 
82 DECLARE_NOT_AGGREGATABLE(CFolderItems)
83 DECLARE_PROTECT_FINAL_CONSTRUCT()
84 
85 BEGIN_COM_MAP(CFolderItems)
86     COM_INTERFACE_ENTRY_IID(IID_FolderItems, FolderItems)
87     COM_INTERFACE_ENTRY_IID(IID_IDispatch, IDispatch)
88 END_COM_MAP()
89 };
90 
91 #endif
92