Leaked source code of windows server 2003
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.

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