CMyDocsFolder.cpp (c2b476bd) | CMyDocsFolder.cpp (d2b91deb) |
---|---|
1/* 2 * Virtual MyDocuments Folder 3 * 4 * Copyright 2007 Johannes Anderwald 5 * Copyright 2009 Andrew Hill 6 * 7 * This library is free software; you can redistribute it and/or 8 * modify it under the terms of the GNU Lesser General Public --- 20 unchanged lines hidden (view full) --- 29} 30 31CMyDocsFolder::~CMyDocsFolder() 32{ 33 if(m_pidlInner) 34 SHFree(m_pidlInner); 35} 36 | 1/* 2 * Virtual MyDocuments Folder 3 * 4 * Copyright 2007 Johannes Anderwald 5 * Copyright 2009 Andrew Hill 6 * 7 * This library is free software; you can redistribute it and/or 8 * modify it under the terms of the GNU Lesser General Public --- 20 unchanged lines hidden (view full) --- 29} 30 31CMyDocsFolder::~CMyDocsFolder() 32{ 33 if(m_pidlInner) 34 SHFree(m_pidlInner); 35} 36 |
37HRESULT WINAPI CMyDocsFolder::FinalConstruct() 38{ 39 m_pidlInner = _ILCreateMyDocuments(); 40 41 if (!m_pidlInner) 42 return E_OUTOFMEMORY; 43 44 return S_OK; 45} 46 47HRESULT CMyDocsFolder::EnsureFolder() 48{ 49 ATLASSERT(m_pidlInner); 50 51 if (m_pisfInner) 52 return S_OK; 53 54 55 HRESULT hr = SHELL32_CoCreateInitSF(m_pidlInner, 56 &CLSID_ShellFSFolder, 57 CSIDL_PERSONAL, 58 IID_PPV_ARG(IShellFolder2, &m_pisfInner)); 59 60 if (FAILED_UNEXPECTEDLY(hr)) 61 return hr; 62 63 return S_OK; 64} 65 |
|
37HRESULT WINAPI CMyDocsFolder::ParseDisplayName(HWND hwndOwner, LPBC pbc, LPOLESTR lpszDisplayName, 38 ULONG *pchEaten, PIDLIST_RELATIVE *ppidl, ULONG *pdwAttributes) 39{ | 66HRESULT WINAPI CMyDocsFolder::ParseDisplayName(HWND hwndOwner, LPBC pbc, LPOLESTR lpszDisplayName, 67 ULONG *pchEaten, PIDLIST_RELATIVE *ppidl, ULONG *pdwAttributes) 68{ |
69 HRESULT hr = EnsureFolder(); 70 if (FAILED(hr)) 71 return hr; 72 |
|
40 return m_pisfInner->ParseDisplayName(hwndOwner, pbc, lpszDisplayName, pchEaten, ppidl, pdwAttributes); 41} 42 43HRESULT WINAPI CMyDocsFolder::EnumObjects(HWND hwndOwner, DWORD dwFlags, LPENUMIDLIST *ppEnumIDList) 44{ | 73 return m_pisfInner->ParseDisplayName(hwndOwner, pbc, lpszDisplayName, pchEaten, ppidl, pdwAttributes); 74} 75 76HRESULT WINAPI CMyDocsFolder::EnumObjects(HWND hwndOwner, DWORD dwFlags, LPENUMIDLIST *ppEnumIDList) 77{ |
78 HRESULT hr = EnsureFolder(); 79 if (FAILED(hr)) 80 return hr; 81 |
|
45 return m_pisfInner->EnumObjects(hwndOwner, dwFlags, ppEnumIDList); 46} 47 48HRESULT WINAPI CMyDocsFolder::BindToObject(PCUIDLIST_RELATIVE pidl, LPBC pbcReserved, REFIID riid, LPVOID *ppvOut) 49{ | 82 return m_pisfInner->EnumObjects(hwndOwner, dwFlags, ppEnumIDList); 83} 84 85HRESULT WINAPI CMyDocsFolder::BindToObject(PCUIDLIST_RELATIVE pidl, LPBC pbcReserved, REFIID riid, LPVOID *ppvOut) 86{ |
87 HRESULT hr = EnsureFolder(); 88 if (FAILED(hr)) 89 return hr; 90 |
|
50 return m_pisfInner->BindToObject(pidl, pbcReserved, riid, ppvOut); 51} 52 53HRESULT WINAPI CMyDocsFolder::BindToStorage(PCUIDLIST_RELATIVE pidl, LPBC pbcReserved, REFIID riid, LPVOID *ppvOut) 54{ | 91 return m_pisfInner->BindToObject(pidl, pbcReserved, riid, ppvOut); 92} 93 94HRESULT WINAPI CMyDocsFolder::BindToStorage(PCUIDLIST_RELATIVE pidl, LPBC pbcReserved, REFIID riid, LPVOID *ppvOut) 95{ |
96 HRESULT hr = EnsureFolder(); 97 if (FAILED(hr)) 98 return hr; 99 |
|
55 return m_pisfInner->BindToStorage(pidl, pbcReserved, riid, ppvOut); 56} 57 58HRESULT WINAPI CMyDocsFolder::CompareIDs(LPARAM lParam, PCUIDLIST_RELATIVE pidl1, PCUIDLIST_RELATIVE pidl2) 59{ | 100 return m_pisfInner->BindToStorage(pidl, pbcReserved, riid, ppvOut); 101} 102 103HRESULT WINAPI CMyDocsFolder::CompareIDs(LPARAM lParam, PCUIDLIST_RELATIVE pidl1, PCUIDLIST_RELATIVE pidl2) 104{ |
105 HRESULT hr = EnsureFolder(); 106 if (FAILED(hr)) 107 return hr; 108 |
|
60 return m_pisfInner->CompareIDs(lParam, pidl1, pidl2); 61} 62 63HRESULT WINAPI CMyDocsFolder::CreateViewObject(HWND hwndOwner, REFIID riid, LPVOID *ppvOut) 64{ | 109 return m_pisfInner->CompareIDs(lParam, pidl1, pidl2); 110} 111 112HRESULT WINAPI CMyDocsFolder::CreateViewObject(HWND hwndOwner, REFIID riid, LPVOID *ppvOut) 113{ |
114 HRESULT hr = EnsureFolder(); 115 if (FAILED(hr)) 116 return hr; 117 |
|
65 return m_pisfInner->CreateViewObject(hwndOwner, riid, ppvOut); 66} 67 68HRESULT WINAPI CMyDocsFolder::GetAttributesOf(UINT cidl, PCUITEMID_CHILD_ARRAY apidl, DWORD *rgfInOut) 69{ 70 static const DWORD dwMyDocumentsAttributes = 71 SFGAO_STORAGE | SFGAO_HASPROPSHEET | SFGAO_STORAGEANCESTOR | SFGAO_CANCOPY | 72 SFGAO_FILESYSANCESTOR | SFGAO_FOLDER | SFGAO_FILESYSTEM | SFGAO_HASSUBFOLDER | SFGAO_CANRENAME | SFGAO_CANDELETE; 73 | 118 return m_pisfInner->CreateViewObject(hwndOwner, riid, ppvOut); 119} 120 121HRESULT WINAPI CMyDocsFolder::GetAttributesOf(UINT cidl, PCUITEMID_CHILD_ARRAY apidl, DWORD *rgfInOut) 122{ 123 static const DWORD dwMyDocumentsAttributes = 124 SFGAO_STORAGE | SFGAO_HASPROPSHEET | SFGAO_STORAGEANCESTOR | SFGAO_CANCOPY | 125 SFGAO_FILESYSANCESTOR | SFGAO_FOLDER | SFGAO_FILESYSTEM | SFGAO_HASSUBFOLDER | SFGAO_CANRENAME | SFGAO_CANDELETE; 126 |
127 HRESULT hr = EnsureFolder(); 128 if (FAILED(hr)) 129 return hr; 130 |
|
74 if(cidl) 75 return m_pisfInner->GetAttributesOf(cidl, apidl, rgfInOut); 76 77 if (!rgfInOut) 78 return E_INVALIDARG; 79 80 if (*rgfInOut == 0) 81 *rgfInOut = ~0; --- 4 unchanged lines hidden (view full) --- 86 *rgfInOut &= ~SFGAO_VALIDATE; 87 88 return S_OK; 89} 90 91HRESULT WINAPI CMyDocsFolder::GetUIObjectOf(HWND hwndOwner, UINT cidl, PCUITEMID_CHILD_ARRAY apidl, 92 REFIID riid, UINT * prgfInOut, LPVOID * ppvOut) 93{ | 131 if(cidl) 132 return m_pisfInner->GetAttributesOf(cidl, apidl, rgfInOut); 133 134 if (!rgfInOut) 135 return E_INVALIDARG; 136 137 if (*rgfInOut == 0) 138 *rgfInOut = ~0; --- 4 unchanged lines hidden (view full) --- 143 *rgfInOut &= ~SFGAO_VALIDATE; 144 145 return S_OK; 146} 147 148HRESULT WINAPI CMyDocsFolder::GetUIObjectOf(HWND hwndOwner, UINT cidl, PCUITEMID_CHILD_ARRAY apidl, 149 REFIID riid, UINT * prgfInOut, LPVOID * ppvOut) 150{ |
151 HRESULT hr = EnsureFolder(); 152 if (FAILED(hr)) 153 return hr; 154 |
|
94 return m_pisfInner->GetUIObjectOf(hwndOwner, cidl, apidl, riid, prgfInOut, ppvOut); 95} 96 97HRESULT WINAPI CMyDocsFolder::GetDisplayNameOf(PCUITEMID_CHILD pidl, DWORD dwFlags, LPSTRRET strRet) 98{ 99 if (!strRet || !pidl) 100 return E_INVALIDARG; 101 | 155 return m_pisfInner->GetUIObjectOf(hwndOwner, cidl, apidl, riid, prgfInOut, ppvOut); 156} 157 158HRESULT WINAPI CMyDocsFolder::GetDisplayNameOf(PCUITEMID_CHILD pidl, DWORD dwFlags, LPSTRRET strRet) 159{ 160 if (!strRet || !pidl) 161 return E_INVALIDARG; 162 |
163 HRESULT hr = EnsureFolder(); 164 if (FAILED(hr)) 165 return hr; 166 |
|
102 /* If we got an fs item just forward to the fs folder */ 103 if (!_ILIsSpecialFolder(pidl)) 104 return m_pisfInner->GetDisplayNameOf(pidl, dwFlags, strRet); 105 106 /* The caller wants our path. Let fs folder handle it */ 107 if ((GET_SHGDN_RELATION (dwFlags) == SHGDN_NORMAL) && 108 (GET_SHGDN_FOR (dwFlags) & SHGDN_FORPARSING)) 109 { --- 5 unchanged lines hidden (view full) --- 115 116 ERR("Got empty pidl without SHGDN_FORPARSING\n"); 117 return E_INVALIDARG; 118} 119 120HRESULT WINAPI CMyDocsFolder::SetNameOf(HWND hwndOwner, PCUITEMID_CHILD pidl, /* simple pidl */ 121 LPCOLESTR lpName, DWORD dwFlags, PITEMID_CHILD *pPidlOut) 122{ | 167 /* If we got an fs item just forward to the fs folder */ 168 if (!_ILIsSpecialFolder(pidl)) 169 return m_pisfInner->GetDisplayNameOf(pidl, dwFlags, strRet); 170 171 /* The caller wants our path. Let fs folder handle it */ 172 if ((GET_SHGDN_RELATION (dwFlags) == SHGDN_NORMAL) && 173 (GET_SHGDN_FOR (dwFlags) & SHGDN_FORPARSING)) 174 { --- 5 unchanged lines hidden (view full) --- 180 181 ERR("Got empty pidl without SHGDN_FORPARSING\n"); 182 return E_INVALIDARG; 183} 184 185HRESULT WINAPI CMyDocsFolder::SetNameOf(HWND hwndOwner, PCUITEMID_CHILD pidl, /* simple pidl */ 186 LPCOLESTR lpName, DWORD dwFlags, PITEMID_CHILD *pPidlOut) 187{ |
188 HRESULT hr = EnsureFolder(); 189 if (FAILED(hr)) 190 return hr; 191 |
|
123 return m_pisfInner->SetNameOf(hwndOwner, pidl, lpName, dwFlags, pPidlOut); 124} 125 126HRESULT WINAPI CMyDocsFolder::GetDefaultSearchGUID(GUID *pguid) 127{ | 192 return m_pisfInner->SetNameOf(hwndOwner, pidl, lpName, dwFlags, pPidlOut); 193} 194 195HRESULT WINAPI CMyDocsFolder::GetDefaultSearchGUID(GUID *pguid) 196{ |
197 HRESULT hr = EnsureFolder(); 198 if (FAILED(hr)) 199 return hr; 200 |
|
128 return m_pisfInner->GetDefaultSearchGUID(pguid); 129} 130 131HRESULT WINAPI CMyDocsFolder::EnumSearches(IEnumExtraSearch ** ppenum) 132{ | 201 return m_pisfInner->GetDefaultSearchGUID(pguid); 202} 203 204HRESULT WINAPI CMyDocsFolder::EnumSearches(IEnumExtraSearch ** ppenum) 205{ |
206 HRESULT hr = EnsureFolder(); 207 if (FAILED(hr)) 208 return hr; 209 |
|
133 return m_pisfInner->EnumSearches(ppenum); 134} 135 136HRESULT WINAPI CMyDocsFolder::GetDefaultColumn(DWORD dwRes, ULONG *pSort, ULONG *pDisplay) 137{ | 210 return m_pisfInner->EnumSearches(ppenum); 211} 212 213HRESULT WINAPI CMyDocsFolder::GetDefaultColumn(DWORD dwRes, ULONG *pSort, ULONG *pDisplay) 214{ |
215 HRESULT hr = EnsureFolder(); 216 if (FAILED(hr)) 217 return hr; 218 |
|
138 return m_pisfInner->GetDefaultColumn(dwRes, pSort, pDisplay); 139} 140 141HRESULT WINAPI CMyDocsFolder::GetDefaultColumnState(UINT iColumn, DWORD *pcsFlags) 142{ | 219 return m_pisfInner->GetDefaultColumn(dwRes, pSort, pDisplay); 220} 221 222HRESULT WINAPI CMyDocsFolder::GetDefaultColumnState(UINT iColumn, DWORD *pcsFlags) 223{ |
224 HRESULT hr = EnsureFolder(); 225 if (FAILED(hr)) 226 return hr; 227 |
|
143 return m_pisfInner->GetDefaultColumnState(iColumn, pcsFlags); 144} 145 146HRESULT WINAPI CMyDocsFolder::GetDetailsEx(PCUITEMID_CHILD pidl, const SHCOLUMNID *pscid, VARIANT *pv) 147{ | 228 return m_pisfInner->GetDefaultColumnState(iColumn, pcsFlags); 229} 230 231HRESULT WINAPI CMyDocsFolder::GetDetailsEx(PCUITEMID_CHILD pidl, const SHCOLUMNID *pscid, VARIANT *pv) 232{ |
233 HRESULT hr = EnsureFolder(); 234 if (FAILED(hr)) 235 return hr; 236 |
|
148 return m_pisfInner->GetDetailsEx(pidl, pscid, pv); 149} 150 151HRESULT WINAPI CMyDocsFolder::GetDetailsOf(PCUITEMID_CHILD pidl, UINT iColumn, SHELLDETAILS *psd) 152{ | 237 return m_pisfInner->GetDetailsEx(pidl, pscid, pv); 238} 239 240HRESULT WINAPI CMyDocsFolder::GetDetailsOf(PCUITEMID_CHILD pidl, UINT iColumn, SHELLDETAILS *psd) 241{ |
242 HRESULT hr = EnsureFolder(); 243 if (FAILED(hr)) 244 return hr; 245 |
|
153 return m_pisfInner->GetDetailsOf(pidl, iColumn, psd); 154} 155 156HRESULT WINAPI CMyDocsFolder::MapColumnToSCID(UINT column, SHCOLUMNID *pscid) 157{ | 246 return m_pisfInner->GetDetailsOf(pidl, iColumn, psd); 247} 248 249HRESULT WINAPI CMyDocsFolder::MapColumnToSCID(UINT column, SHCOLUMNID *pscid) 250{ |
251 HRESULT hr = EnsureFolder(); 252 if (FAILED(hr)) 253 return hr; 254 |
|
158 return m_pisfInner->MapColumnToSCID(column, pscid); 159} 160 161HRESULT WINAPI CMyDocsFolder::GetClassID(CLSID *lpClassId) 162{ 163 if (!lpClassId) 164 return E_POINTER; 165 166 memcpy(lpClassId, &CLSID_MyDocuments, sizeof(GUID)); 167 168 return S_OK; 169} 170 171HRESULT WINAPI CMyDocsFolder::Initialize(PCIDLIST_ABSOLUTE pidl) 172{ | 255 return m_pisfInner->MapColumnToSCID(column, pscid); 256} 257 258HRESULT WINAPI CMyDocsFolder::GetClassID(CLSID *lpClassId) 259{ 260 if (!lpClassId) 261 return E_POINTER; 262 263 memcpy(lpClassId, &CLSID_MyDocuments, sizeof(GUID)); 264 265 return S_OK; 266} 267 268HRESULT WINAPI CMyDocsFolder::Initialize(PCIDLIST_ABSOLUTE pidl) 269{ |
270 if (m_pisfInner) 271 return E_INVALIDARG; 272 273 if (m_pidlInner) 274 SHFree(m_pidlInner); 275 |
|
173 m_pidlInner = ILClone(pidl); | 276 m_pidlInner = ILClone(pidl); |
277 |
|
174 if (!m_pidlInner) 175 return E_OUTOFMEMORY; 176 | 278 if (!m_pidlInner) 279 return E_OUTOFMEMORY; 280 |
177 return SHELL32_CoCreateInitSF(m_pidlInner, 178 &CLSID_ShellFSFolder, 179 CSIDL_PERSONAL, 180 IID_PPV_ARG(IShellFolder2, &m_pisfInner)); | 281 return EnsureFolder(); |
181} 182 183HRESULT WINAPI CMyDocsFolder::GetCurFolder(PIDLIST_ABSOLUTE *pidl) 184{ 185 if (!pidl) 186 return E_POINTER; 187 *pidl = ILClone(m_pidlInner); 188 return S_OK; 189} | 282} 283 284HRESULT WINAPI CMyDocsFolder::GetCurFolder(PIDLIST_ABSOLUTE *pidl) 285{ 286 if (!pidl) 287 return E_POINTER; 288 *pidl = ILClone(m_pidlInner); 289 return S_OK; 290} |