Home | Info | Community | Development | myReactOS | Contact Us
ReactOS Development > Doxygenshellitem.cpp
Go to the documentation of this file.
00001 /* 00002 * IShellItem implementation 00003 * 00004 * Copyright 2008 Vincent Povirk for CodeWeavers 00005 * Copyright 2009 Andrew Hill 00006 * 00007 * This library is free software; you can redistribute it and/or 00008 * modify it under the terms of the GNU Lesser General Public 00009 * License as published by the Free Software Foundation; either 00010 * version 2.1 of the License, or (at your option) any later version. 00011 * 00012 * This library is distributed in the hope that it will be useful, 00013 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00014 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00015 * Lesser General Public License for more details. 00016 * 00017 * You should have received a copy of the GNU Lesser General Public 00018 * License along with this library; if not, write to the Free Software 00019 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA 00020 */ 00021 00022 #include "precomp.h" 00023 00024 WINE_DEFAULT_DEBUG_CHANNEL(shell); 00025 00026 EXTERN_C HRESULT WINAPI SHCreateShellItem(LPCITEMIDLIST pidlParent, 00027 IShellFolder *psfParent, LPCITEMIDLIST pidl, IShellItem **ppsi); 00028 00029 CShellItem::CShellItem() 00030 { 00031 pidl = NULL; 00032 } 00033 00034 CShellItem::~CShellItem() 00035 { 00036 ILFree(pidl); 00037 } 00038 00039 HRESULT CShellItem::get_parent_pidl(LPITEMIDLIST *parent_pidl) 00040 { 00041 *parent_pidl = ILClone(pidl); 00042 if (*parent_pidl) 00043 { 00044 if (ILRemoveLastID(*parent_pidl)) 00045 return S_OK; 00046 else 00047 { 00048 ILFree(*parent_pidl); 00049 *parent_pidl = NULL; 00050 return E_INVALIDARG; 00051 } 00052 } 00053 else 00054 { 00055 *parent_pidl = NULL; 00056 return E_OUTOFMEMORY; 00057 } 00058 } 00059 00060 HRESULT CShellItem::get_parent_shellfolder(IShellFolder **ppsf) 00061 { 00062 LPITEMIDLIST parent_pidl; 00063 CComPtr<IShellFolder> desktop; 00064 HRESULT ret; 00065 00066 ret = get_parent_pidl(&parent_pidl); 00067 if (SUCCEEDED(ret)) 00068 { 00069 ret = SHGetDesktopFolder(&desktop); 00070 if (SUCCEEDED(ret)) 00071 ret = desktop->BindToObject(parent_pidl, NULL, IID_IShellFolder, (void**)ppsf); 00072 ILFree(parent_pidl); 00073 } 00074 00075 return ret; 00076 } 00077 00078 HRESULT WINAPI CShellItem::BindToHandler(IBindCtx *pbc, REFGUID rbhid, REFIID riid, void **ppvOut) 00079 { 00080 FIXME("(%p,%p,%s,%p,%p)\n", this, pbc, shdebugstr_guid(&rbhid), riid, ppvOut); 00081 00082 *ppvOut = NULL; 00083 00084 return E_NOTIMPL; 00085 } 00086 00087 HRESULT WINAPI CShellItem::GetParent(IShellItem **ppsi) 00088 { 00089 LPITEMIDLIST parent_pidl; 00090 HRESULT ret; 00091 00092 TRACE("(%p,%p)\n", this, ppsi); 00093 00094 ret = get_parent_pidl(&parent_pidl); 00095 if (SUCCEEDED(ret)) 00096 { 00097 ret = SHCreateShellItem(NULL, NULL, parent_pidl, ppsi); 00098 ILFree(parent_pidl); 00099 } 00100 00101 return ret; 00102 } 00103 00104 HRESULT WINAPI CShellItem::GetDisplayName(SIGDN sigdnName, LPWSTR *ppszName) 00105 { 00106 FIXME("(%p,%x,%p)\n", this, sigdnName, ppszName); 00107 00108 *ppszName = NULL; 00109 00110 return E_NOTIMPL; 00111 } 00112 00113 HRESULT WINAPI CShellItem::GetAttributes(SFGAOF sfgaoMask, SFGAOF *psfgaoAttribs) 00114 { 00115 CComPtr<IShellFolder> parent_folder; 00116 LPITEMIDLIST child_pidl; 00117 HRESULT ret; 00118 00119 TRACE("(%p,%x,%p)\n", this, sfgaoMask, psfgaoAttribs); 00120 00121 ret = get_parent_shellfolder(&parent_folder); 00122 if (SUCCEEDED(ret)) 00123 { 00124 child_pidl = ILFindLastID(pidl); 00125 *psfgaoAttribs = sfgaoMask; 00126 ret = parent_folder->GetAttributesOf(1, (LPCITEMIDLIST*)&child_pidl, psfgaoAttribs); 00127 } 00128 00129 return ret; 00130 } 00131 00132 HRESULT WINAPI CShellItem::Compare(IShellItem *oth, SICHINTF hint, int *piOrder) 00133 { 00134 FIXME("(%p,%p,%x,%p)\n", this, oth, hint, piOrder); 00135 00136 return E_NOTIMPL; 00137 } 00138 00139 HRESULT WINAPI CShellItem::GetClassID(CLSID *pClassID) 00140 { 00141 TRACE("(%p,%p)\n", this, pClassID); 00142 00143 *pClassID = CLSID_ShellItem; 00144 return S_OK; 00145 } 00146 00147 00148 HRESULT WINAPI CShellItem::SetIDList(LPCITEMIDLIST pidlx) 00149 { 00150 LPITEMIDLIST new_pidl; 00151 00152 TRACE("(%p,%p)\n", this, pidlx); 00153 00154 new_pidl = ILClone(pidlx); 00155 00156 if (new_pidl) 00157 { 00158 ILFree(pidl); 00159 pidl = new_pidl; 00160 return S_OK; 00161 } 00162 else 00163 return E_OUTOFMEMORY; 00164 } 00165 00166 HRESULT WINAPI CShellItem::GetIDList(LPITEMIDLIST *ppidl) 00167 { 00168 TRACE("(%p,%p)\n", this, ppidl); 00169 00170 *ppidl = ILClone(pidl); 00171 if (*ppidl) 00172 return S_OK; 00173 else 00174 return E_OUTOFMEMORY; 00175 } 00176 00177 HRESULT WINAPI SHCreateShellItem(LPCITEMIDLIST pidlParent, 00178 IShellFolder *psfParent, LPCITEMIDLIST pidl, IShellItem **ppsi) 00179 { 00180 IShellItem *newShellItem; 00181 LPITEMIDLIST new_pidl; 00182 CComPtr<IPersistIDList> newPersistIDList; 00183 HRESULT ret; 00184 00185 TRACE("(%p,%p,%p,%p)\n", pidlParent, psfParent, pidl, ppsi); 00186 00187 if (!pidl) 00188 { 00189 return E_INVALIDARG; 00190 } 00191 else if (pidlParent || psfParent) 00192 { 00193 LPITEMIDLIST temp_parent=NULL; 00194 if (!pidlParent) 00195 { 00196 CComPtr<IPersistFolder2> ppf2Parent; 00197 00198 if (FAILED(psfParent->QueryInterface(IID_IPersistFolder2, (void**)&ppf2Parent))) 00199 { 00200 FIXME("couldn't get IPersistFolder2 interface of parent\n"); 00201 return E_NOINTERFACE; 00202 } 00203 00204 if (FAILED(ppf2Parent->GetCurFolder(&temp_parent))) 00205 { 00206 FIXME("couldn't get parent PIDL\n"); 00207 return E_NOINTERFACE; 00208 } 00209 00210 pidlParent = temp_parent; 00211 } 00212 00213 new_pidl = ILCombine(pidlParent, pidl); 00214 ILFree(temp_parent); 00215 00216 if (!new_pidl) 00217 return E_OUTOFMEMORY; 00218 } 00219 else 00220 { 00221 new_pidl = ILClone(pidl); 00222 if (!new_pidl) 00223 return E_OUTOFMEMORY; 00224 } 00225 00226 ret = CShellItem::_CreatorClass::CreateInstance(NULL, IID_IShellItem, (void**)&newShellItem); 00227 if (FAILED(ret)) 00228 { 00229 *ppsi = NULL; 00230 ILFree(new_pidl); 00231 return ret; 00232 } 00233 ret = newShellItem->QueryInterface(IID_IPersistIDList, (void **)&newPersistIDList); 00234 if (FAILED(ret)) 00235 { 00236 ILFree(new_pidl); 00237 return ret; 00238 } 00239 ret = newPersistIDList->SetIDList(new_pidl); 00240 if (FAILED(ret)) 00241 { 00242 ILFree(new_pidl); 00243 return ret; 00244 } 00245 ILFree(new_pidl); 00246 *ppsi = newShellItem; 00247 return ret; 00248 } Generated on Sun May 27 2012 04:26:25 for ReactOS by
1.7.6.1
|