Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

397 lines
12 KiB

  1. //+---------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1997.
  5. //
  6. // File: I S H E L L F 2 . C P P
  7. //
  8. // Contents: IShellFolder2 implementation for CUPnPDeviceFolder
  9. //
  10. // Notes: The IShellFolder2 interface extends the capabilities of
  11. // IShellFolder. It provides the shell information that
  12. // can be used to populate the column ("details") view.
  13. //
  14. // The methods of IShellFolder2 superset those of IShellFolder.
  15. // This file only implements the methods specific to
  16. // IShellFolder2.
  17. //
  18. //----------------------------------------------------------------------------
  19. #include "pch.h"
  20. #pragma hdrstop
  21. //+---------------------------------------------------------------------------
  22. //
  23. // Member: CUPnPDeviceFolder::GetDefaultSearchGUID
  24. //
  25. // Purpose: Returns the globally unique identifier (GUID) of the default
  26. // search object for the folder.
  27. //
  28. // Arguments:
  29. // lpGUID [out] GUID of the default search object.
  30. //
  31. // Returns: Returns NOERROR if successful or an OLE-defined error
  32. // value otherwise
  33. //
  34. // Notes:
  35. //
  36. STDMETHODIMP
  37. CUPnPDeviceFolder::GetDefaultSearchGUID(GUID * pguid)
  38. {
  39. return E_NOTIMPL;
  40. }
  41. //+---------------------------------------------------------------------------
  42. //
  43. // Member: CUPnPDeviceFolder::EnumSearches
  44. //
  45. // Purpose: Requests a pointer to an interface that allows a client
  46. // to enumerate the available search objects.
  47. //
  48. // Arguments:
  49. // ppEnum [out] Address of a pointer to an enumerator
  50. // object's IEnumExtraSearch interface.
  51. //
  52. // Returns: Returns NOERROR if successful or an OLE-defined error
  53. // value otherwise
  54. //
  55. // Notes:
  56. //
  57. STDMETHODIMP
  58. CUPnPDeviceFolder::EnumSearches(IEnumExtraSearch ** ppenum)
  59. {
  60. return E_NOTIMPL;
  61. }
  62. //+---------------------------------------------------------------------------
  63. //
  64. // Member: CUPnPDeviceFolder::GetDefaultColumn
  65. //
  66. // Purpose: Gets the default sorting and display columns.
  67. //
  68. // Arguments:
  69. // dwReserved [in] Reserved. Set to zero.
  70. // pSort [out] Pointer to a value that receives the
  71. // index of the default sorted column.
  72. // pDisplay [out] Pointer to a value that receives the
  73. // index of the default display column.
  74. //
  75. // Returns: Returns NOERROR if successful or an OLE-defined error
  76. // value otherwise
  77. //
  78. // Notes:
  79. //
  80. STDMETHODIMP
  81. CUPnPDeviceFolder::GetDefaultColumn(DWORD dwRes,
  82. ULONG * pSort,
  83. ULONG * pDisplay)
  84. {
  85. return E_NOTIMPL;
  86. }
  87. //+---------------------------------------------------------------------------
  88. //
  89. // Member: CUPnPDeviceFolder::GetDefaultColumnState
  90. //
  91. // Purpose: Retrieves the default state for a specified column.
  92. //
  93. // Arguments:
  94. // iColumn [in] Integer that specifies the column
  95. // number.
  96. // pcsFlags [out] Pointer to a value that contains flags
  97. // that indicate the default column state.
  98. // This parameter can include a combination
  99. // of the SHCOLSTATE_* flags.
  100. //
  101. // Returns: Returns NOERROR if successful or an OLE-defined error
  102. // value otherwise
  103. //
  104. // Notes:
  105. //
  106. STDMETHODIMP
  107. CUPnPDeviceFolder::GetDefaultColumnState(UINT iColumn, DWORD * pcsFlags)
  108. {
  109. return E_NOTIMPL;
  110. }
  111. //+---------------------------------------------------------------------------
  112. //
  113. // Function: HrVariantFromSz
  114. //
  115. // Purpose: Converts the given string into a variant to pass back from
  116. // GetDetailsEx().
  117. //
  118. // Arguments:
  119. // sz [in] String to convert
  120. // pvar [out] Returns new allocated BSTR in variant
  121. //
  122. // Returns: S_OK if success, E_FAIL if string was empty, OLE error otherwise
  123. //
  124. // Author: danielwe 2001/05/3
  125. //
  126. // Notes: Nothing needs to be freed after this
  127. //
  128. HRESULT HrVariantFromSz(LPCWSTR sz, VARIANT *pvar)
  129. {
  130. HRESULT hr = S_OK;
  131. if (*sz)
  132. {
  133. BSTR bstr;
  134. bstr = ::SysAllocString(sz);
  135. if (bstr)
  136. {
  137. V_VT(pvar) = VT_BSTR;
  138. V_BSTR(pvar) = bstr;
  139. }
  140. else
  141. {
  142. hr = E_OUTOFMEMORY;
  143. TraceError("HrVariantFromSz: SysAllocString", hr);
  144. }
  145. }
  146. else
  147. {
  148. hr = E_FAIL;
  149. }
  150. TraceError("HrVariantFromSz", hr);
  151. return hr;
  152. }
  153. //+---------------------------------------------------------------------------
  154. //
  155. // Member: CUPnPDeviceFolder::GetDetailsEx
  156. //
  157. // Purpose: Retrieves detailed information, identified by a property
  158. // set ID (FMTID) and property ID (PID), on an item in a shell
  159. // folder.
  160. //
  161. // Arguments:
  162. // pidl [in] PIDL of the item, relative to the
  163. // parent folder. This method accepts
  164. // only single-level PIDLs. The structure
  165. // must contain exactly one SHITEMID
  166. // structure followed by a terminating
  167. // zero.
  168. // pscid [in] Pointer to an SHCOLUMNID structure that
  169. // identifies the column.
  170. // pv [out] Pointer to a VARIANT with the requested
  171. // information. The value will be fully
  172. // typed.
  173. //
  174. // Returns: Returns NOERROR if successful or an OLE-defined error
  175. // value otherwise
  176. //
  177. // Notes: In the "My Network Places" folder, there are two columns:
  178. // "Name" and "Comment". The "Name" column should contain
  179. // the display name (a.k.a. FriendlyName) of the device, which
  180. // is returned by GetDisplayNameOf(). This supplies the value
  181. // of the "Comment" column, which is:
  182. // - the device's get_Description() property, if supplied
  183. // - an empty string otherwise (returning an error yields this)
  184. //
  185. STDMETHODIMP
  186. CUPnPDeviceFolder::GetDetailsEx(LPCITEMIDLIST pidl,
  187. const SHCOLUMNID * pscid,
  188. VARIANT * pv)
  189. {
  190. TraceTag(ttidShellFolderIface, "OBJ: CUPnPDeviceFolder::GetDetailsEx");
  191. HRESULT hr;
  192. PUPNPDEVICEFOLDPIDL pupdfp;
  193. hr = S_OK;
  194. pupdfp = NULL;
  195. if (!pidl)
  196. {
  197. hr = E_INVALIDARG;
  198. goto Cleanup;
  199. }
  200. if (!pscid)
  201. {
  202. hr = E_INVALIDARG;
  203. goto Cleanup;
  204. }
  205. if (!pv)
  206. {
  207. hr = E_INVALIDARG;
  208. goto Cleanup;
  209. }
  210. // Make sure that the pidls passed in are our pidls.
  211. //
  212. {
  213. BOOL fResult;
  214. fResult = FIsUPnPDeviceFoldPidl(pidl);
  215. if (!fResult)
  216. {
  217. // not one of our PIDLs, can't do anything
  218. hr = E_INVALIDARG;
  219. goto Cleanup;
  220. }
  221. }
  222. pupdfp = ConvertToUPnPDevicePIDL(pidl);
  223. if (IsEqualGUID(pscid->fmtid, FMTID_SummaryInformation))
  224. {
  225. switch (pscid->pid)
  226. {
  227. case PIDSI_COMMENTS: // "Comment" column
  228. {
  229. CUPnPDeviceFoldPidl udfp;
  230. hr = udfp.HrInit(pupdfp);
  231. if (SUCCEEDED(hr))
  232. {
  233. hr = HrVariantFromSz(udfp.PszGetDescriptionPointer(), pv);
  234. if (FAILED(hr))
  235. {
  236. goto Cleanup;
  237. }
  238. }
  239. break;
  240. }
  241. default:
  242. TraceTag(ttidShellFolderIface, "CUPnPDeviceFolder::GetDetailsEx: "
  243. "Unknown column: %x", pscid->pid);
  244. hr = E_FAIL;
  245. goto Cleanup;
  246. break;
  247. }
  248. }
  249. else if (IsEqualGUID(pscid->fmtid, FMTID_ShellDetails))
  250. {
  251. switch (pscid->pid)
  252. {
  253. case PID_NETWORKLOCATION:
  254. BSTR bstrLocation;
  255. bstrLocation= ::SysAllocString(WszLoadIds(IDS_LOCAL_NETWORK));
  256. if (bstrLocation)
  257. {
  258. V_VT(pv) = VT_BSTR;
  259. V_BSTR(pv) = bstrLocation;
  260. }
  261. else
  262. {
  263. hr = E_OUTOFMEMORY;
  264. TraceError("CUPnPDeviceFolder::GetDetailsEx: "
  265. "SysAllocString", hr);
  266. }
  267. break;
  268. case PID_COMPUTERNAME:
  269. {
  270. CUPnPDeviceFoldPidl udfp;
  271. hr = udfp.HrInit(pupdfp);
  272. if (SUCCEEDED(hr))
  273. {
  274. hr = HrVariantFromSz(udfp.PszGetNamePointer(), pv);
  275. if (FAILED(hr))
  276. {
  277. goto Cleanup;
  278. }
  279. }
  280. }
  281. break;
  282. default:
  283. TraceTag(ttidShellFolderIface, "CUPnPDeviceFolder::GetDetailsEx: "
  284. "Unknown column: %x", pscid->pid);
  285. hr = E_FAIL;
  286. goto Cleanup;
  287. break;
  288. }
  289. }
  290. else
  291. {
  292. // We have a guid we don't know about
  293. //
  294. TraceTag(ttidShellFolderIface, "CUPnPDeviceFolder::GetDetailsEx: "
  295. "Unknown FMTID");
  296. hr = E_FAIL;
  297. goto Cleanup;
  298. }
  299. Assert(SUCCEEDED(hr));
  300. Cleanup:
  301. TraceError("CUPnPDeviceFolder::GetDetailsEx", hr);
  302. return hr;
  303. }
  304. //+---------------------------------------------------------------------------
  305. //
  306. // Member: CUPnPDeviceFolder::GetDetailsOf
  307. //
  308. // Purpose: Retrieves detailed information, identified by a column index,
  309. // on an item in a shell folder.
  310. //
  311. // Arguments:
  312. // pidl [in] PIDL of the item for which you are
  313. // requesting information. This method
  314. // accepts only single-level PIDLs. The
  315. // structure must contain exactly one
  316. // SHITEMID structure followed by a
  317. // terminating zero. If this parameter is
  318. // set to NULL, the title of the
  319. // information field specified by iColumn
  320. // is returned.
  321. // iColumn [in] Zero-based index of the desired
  322. // information field. It is identical to
  323. // the column number of the information as
  324. // it is displayed in a Details view.
  325. // pDetails [out] Pointer to a SHELLDETAILS structure that
  326. // contains the information.
  327. //
  328. // Returns: Returns NOERROR if successful or an OLE-defined error
  329. // value otherwise
  330. //
  331. // Notes:
  332. //
  333. STDMETHODIMP
  334. CUPnPDeviceFolder::GetDetailsOf(LPCITEMIDLIST pidl,
  335. UINT iColumn,
  336. SHELLDETAILS * psd)
  337. {
  338. return E_NOTIMPL;
  339. }
  340. //+---------------------------------------------------------------------------
  341. //
  342. // Member: CUPnPDeviceFolder::MapColumnToSCID
  343. //
  344. // Purpose: Converts a column to the appropriate property set ID (FMTID)
  345. // and property ID (PID).
  346. //
  347. // Arguments:
  348. // iColumn [in] Integer that specifies the column
  349. // number.
  350. // pscid [out] Pointer to an SHCOLUMNID structure
  351. // containing the FMTID and PID.
  352. //
  353. // Returns: Returns NOERROR if successful or an OLE-defined error
  354. // value otherwise
  355. //
  356. // Notes:
  357. //
  358. STDMETHODIMP
  359. CUPnPDeviceFolder::MapColumnToSCID(UINT iColumn,
  360. SHCOLUMNID * pscid)
  361. {
  362. return E_NOTIMPL;
  363. }