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.

262 lines
5.6 KiB

  1. //+---------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1995 - 1995.
  5. //
  6. // File: sdetails.cxx
  7. //
  8. // Contents: Implementation of IShellDetails
  9. //
  10. // History: 13-Dec-95 BruceFo Created
  11. //
  12. //----------------------------------------------------------------------------
  13. #include "headers.hxx"
  14. #pragma hdrstop
  15. #include "sdetails.hxx"
  16. #include "shares.h"
  17. #include "shares.hxx"
  18. #include "resource.h"
  19. #include "util.hxx"
  20. //////////////////////////////////////////////////////////////////////////////
  21. //
  22. // Define the columns that we know about...
  23. //
  24. struct COL_INFO
  25. {
  26. UINT idString;
  27. int fmt;
  28. UINT cxChar;
  29. };
  30. const COL_INFO c_ColumnHeaders1[] =
  31. {
  32. {IDS_NAME, LVCFMT_LEFT, 25},
  33. {IDS_COMMENT, LVCFMT_LEFT, 30},
  34. };
  35. const COL_INFO c_ColumnHeaders2[] =
  36. {
  37. {IDS_NAME, LVCFMT_LEFT, 25},
  38. {IDS_COMMENT, LVCFMT_LEFT, 30},
  39. {IDS_PATH, LVCFMT_LEFT, 30},
  40. {IDS_MAXUSES, LVCFMT_LEFT, 15},
  41. };
  42. //////////////////////////////////////////////////////////////////////////////
  43. STDMETHODIMP
  44. CSharesSD::GetDetailsOf(
  45. LPCITEMIDLIST pidl,
  46. UINT iColumn,
  47. LPSHELLDETAILS lpDetails
  48. )
  49. {
  50. switch (m_level)
  51. {
  52. case 1: return GetDetailsOf1(pidl, iColumn, lpDetails);
  53. case 2: return GetDetailsOf2(pidl, iColumn, lpDetails);
  54. default: appAssert(FALSE); return E_FAIL;
  55. }
  56. }
  57. STDMETHODIMP
  58. CSharesSD::GetDetailsOf1(
  59. LPCITEMIDLIST pidl,
  60. UINT iColumn,
  61. LPSHELLDETAILS lpDetails
  62. )
  63. {
  64. if (iColumn >= ICOL1_MAX)
  65. {
  66. return E_NOTIMPL;
  67. }
  68. HRESULT hr;
  69. LPIDSHARE pids = (LPIDSHARE)pidl;
  70. if (NULL == pids)
  71. {
  72. hr = STRRETLoadString(c_ColumnHeaders1[iColumn].idString, &lpDetails->str);
  73. if (FAILED(hr))
  74. {
  75. return hr;
  76. }
  77. lpDetails->fmt = c_ColumnHeaders1[iColumn].fmt;
  78. lpDetails->cxChar = c_ColumnHeaders1[iColumn].cxChar;
  79. return NOERROR;
  80. }
  81. #ifdef WIZARDS
  82. if ( Share_IsNewShareWizard(pids)
  83. || Share_IsNetWareWizard(pids)
  84. || Share_IsMacWizard(pids)
  85. )
  86. {
  87. switch (iColumn)
  88. {
  89. case ICOL1_NAME:
  90. hr = STRRETCopy(Share_GetName(pids), &lpDetails->str);
  91. if (FAILED(hr))
  92. {
  93. return hr;
  94. }
  95. break;
  96. case ICOL1_COMMENT:
  97. lpDetails->str.uType = STRRET_CSTR;
  98. lpDetails->str.cStr[0] = '\0';
  99. break;
  100. }
  101. }
  102. else
  103. #endif // WIZARDS
  104. {
  105. appAssert(Share_GetLevel(pids) == 1);
  106. switch (iColumn)
  107. {
  108. case ICOL1_NAME:
  109. hr = STRRETCopy(Share_GetName(pids), &lpDetails->str);
  110. if (FAILED(hr))
  111. {
  112. return hr;
  113. }
  114. break;
  115. case ICOL1_COMMENT:
  116. hr = STRRETCopy(Share_GetComment(pids), &lpDetails->str);
  117. if (FAILED(hr))
  118. {
  119. return hr;
  120. }
  121. break;
  122. }
  123. }
  124. return NOERROR;
  125. }
  126. STDMETHODIMP
  127. CSharesSD::GetDetailsOf2(
  128. LPCITEMIDLIST pidl,
  129. UINT iColumn,
  130. LPSHELLDETAILS lpDetails
  131. )
  132. {
  133. if (iColumn >= ICOL2_MAX)
  134. {
  135. return E_NOTIMPL;
  136. }
  137. HRESULT hr;
  138. LPIDSHARE pids = (LPIDSHARE)pidl;
  139. if (NULL == pids)
  140. {
  141. hr = STRRETLoadString(c_ColumnHeaders2[iColumn].idString, &lpDetails->str);
  142. if (FAILED(hr))
  143. {
  144. return hr;
  145. }
  146. lpDetails->fmt = c_ColumnHeaders2[iColumn].fmt;
  147. lpDetails->cxChar = c_ColumnHeaders2[iColumn].cxChar;
  148. return NOERROR;
  149. }
  150. #ifdef WIZARDS
  151. if ( Share_IsNewShareWizard(pids)
  152. || Share_IsNetWareWizard(pids)
  153. || Share_IsMacWizard(pids)
  154. )
  155. {
  156. switch (iColumn)
  157. {
  158. case ICOL2_NAME:
  159. hr = STRRETCopy(Share_GetName(pids), &lpDetails->str);
  160. if (FAILED(hr))
  161. {
  162. return hr;
  163. }
  164. break;
  165. case ICOL2_COMMENT:
  166. lpDetails->str.uType = STRRET_CSTR;
  167. lpDetails->str.cStr[0] = '\0';
  168. break;
  169. }
  170. }
  171. else
  172. #endif // WIZARDS
  173. {
  174. appAssert(Share_GetLevel(pids) == 2);
  175. switch (iColumn)
  176. {
  177. case ICOL2_NAME:
  178. hr = STRRETCopy(Share_GetName(pids), &lpDetails->str);
  179. if (FAILED(hr))
  180. {
  181. return hr;
  182. }
  183. break;
  184. case ICOL2_COMMENT:
  185. hr = STRRETCopy(Share_GetComment(pids), &lpDetails->str);
  186. if (FAILED(hr))
  187. {
  188. return hr;
  189. }
  190. break;
  191. case ICOL2_PATH:
  192. hr = STRRETCopy(Share_GetPath(pids), &lpDetails->str);
  193. if (FAILED(hr))
  194. {
  195. return hr;
  196. }
  197. break;
  198. case ICOL2_MAXUSES:
  199. {
  200. DWORD maxuses = Share_GetMaxUses(pids);
  201. if (maxuses == SHI_USES_UNLIMITED)
  202. {
  203. hr = STRRETLoadString(IDS_UNLIMITED, &lpDetails->str);
  204. if (FAILED(hr))
  205. {
  206. return hr;
  207. }
  208. }
  209. else
  210. {
  211. TCHAR szTemp[MAX_PATH];
  212. wsprintf(szTemp, TEXT("%d"), maxuses);
  213. hr = STRRETCopy(szTemp, &lpDetails->str);
  214. if (FAILED(hr))
  215. {
  216. return hr;
  217. }
  218. }
  219. break;
  220. }
  221. }
  222. }
  223. return NOERROR;
  224. }
  225. STDMETHODIMP
  226. CSharesSD::ColumnClick(
  227. UINT iColumn
  228. )
  229. {
  230. ShellFolderView_ReArrange(m_hwnd, iColumn);
  231. return NOERROR;
  232. }