528b697cbbea8d8555eac7ee10fbfdb44ac58972
[reactos.git] / reactos / subsys / system / explorer / shell / shellfs.h
1 /*
2 * Copyright 2003, 2004, 2005 Martin Fuchs
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
8 *
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 */
18
19
20 //
21 // Explorer clone
22 //
23 // shellfs.h
24 //
25 // Martin Fuchs, 23.07.2003
26 //
27
28
29 /// shell file/directory entry
30 struct ShellEntry : public Entry
31 {
32 ShellEntry(Entry* parent, LPITEMIDLIST shell_path) : Entry(parent, ET_SHELL), _pidl(shell_path) {}
33 ShellEntry(Entry* parent, const ShellPath& shell_path) : Entry(parent, ET_SHELL), _pidl(shell_path) {}
34
35 virtual bool get_path(PTSTR path, size_t path_count) const;
36 virtual ShellPath create_absolute_pidl() const;
37 virtual HRESULT GetUIObjectOf(HWND hWnd, REFIID riid, LPVOID* ppvOut);
38 virtual BOOL launch_entry(HWND hwnd, UINT nCmdShow=SW_SHOWNORMAL);
39 virtual HRESULT do_context_menu(HWND hwnd, LPPOINT pptScreen, CtxMenuInterfaces& cm_ifs);
40
41 IShellFolder* get_parent_folder() const;
42
43 ShellPath _pidl; // parent relative PIDL
44
45 protected:
46 ShellEntry(LPITEMIDLIST shell_path) : Entry(ET_SHELL), _pidl(shell_path) {}
47 ShellEntry(const ShellPath& shell_path) : Entry(ET_SHELL), _pidl(shell_path) {}
48 };
49
50
51 /// shell folder entry
52 struct ShellDirectory : public ShellEntry, public Directory
53 {
54 ShellDirectory(ShellFolder& root_folder, const ShellPath& shell_path, HWND hwnd)
55 : ShellEntry(shell_path),
56 _folder(root_folder, shell_path),
57 _hwnd(hwnd)
58 {
59 CONTEXT("ShellDirectory::ShellDirectory()");
60
61 lstrcpy(_data.cFileName, root_folder.get_name(shell_path, SHGDN_FORADDRESSBAR));
62 _data.dwFileAttributes = FILE_ATTRIBUTE_DIRECTORY;
63 _shell_attribs = SFGAO_FOLDER;
64
65 ShellFolder subfolder(root_folder, shell_path);
66 IShellFolder* pFolder = subfolder;
67 pFolder->AddRef();
68 _path = pFolder;
69 }
70
71 explicit ShellDirectory(ShellDirectory* parent, LPITEMIDLIST shell_path, HWND hwnd)
72 : ShellEntry(parent, shell_path),
73 _folder(parent->_folder, shell_path),
74 _hwnd(hwnd)
75 {
76 /* not neccessary - the caller will fill the info
77 lstrcpy(_data.cFileName, _folder.get_name(shell_path));
78 _data.dwFileAttributes = FILE_ATTRIBUTE_DIRECTORY;
79 _shell_attribs = SFGAO_FOLDER; */
80
81 _folder->AddRef();
82 _path = _folder;
83 }
84
85 ShellDirectory(const ShellDirectory& other)
86 : ShellEntry(other),
87 Directory(other),
88 _folder(other._folder),
89 _hwnd(other._hwnd)
90 {
91 IShellFolder* pFolder = (IShellFolder*)_path;
92 pFolder->AddRef();
93 }
94
95 ~ShellDirectory()
96 {
97 IShellFolder* pFolder = (IShellFolder*)_path;
98 _path = NULL;
99 pFolder->Release();
100 }
101
102 virtual void read_directory(int scan_flags=SCAN_ALL);
103 virtual const void* get_next_path_component(const void*) const;
104 virtual Entry* find_entry(const void*);
105
106 virtual bool get_path(PTSTR path, size_t path_count) const;
107
108 int extract_icons(bool big_icons);
109
110 ShellFolder _folder;
111 HWND _hwnd;
112
113 protected:
114 bool fill_w32fdata_shell(LPCITEMIDLIST pidl, SFGAOF attribs, WIN32_FIND_DATA*, BY_HANDLE_FILE_INFORMATION*, bool do_access=true);
115 };
116
117
118 inline IShellFolder* ShellEntry::get_parent_folder() const
119 {
120 if (_up)
121 return static_cast<ShellDirectory*>(_up)->_folder;
122 else
123 return GetDesktopFolder();
124 }