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.

255 lines
6.5 KiB

  1. /*
  2. **------------------------------------------------------------------------------
  3. ** Module: Disk Cleanup Applet
  4. ** File: callback.cpp
  5. **
  6. ** Purpose: Defines the IEmptyVoluemCacheCallback interface for
  7. ** the cleanup manager.
  8. ** Notes:
  9. ** Mod Log: Created by Jason Cobb (2/97)
  10. **
  11. ** Copyright (c)1997 Microsoft Corporation, All Rights Reserved
  12. **------------------------------------------------------------------------------
  13. */
  14. /*
  15. **------------------------------------------------------------------------------
  16. ** Project include files
  17. **------------------------------------------------------------------------------
  18. */
  19. #include "common.h"
  20. #include "callback.h"
  21. #include "dmgrinfo.h"
  22. #include "dmgrdlg.h"
  23. /*
  24. **------------------------------------------------------------------------------
  25. ** Local variables
  26. **------------------------------------------------------------------------------
  27. */
  28. static PCLIENTINFO g_pClientInfo; // Set to the current CLIENTINFO struct
  29. static CleanupMgrInfo *g_pcmi;
  30. CVolumeCacheCallBack::CVolumeCacheCallBack(
  31. void
  32. )
  33. {
  34. g_pClientInfo = NULL;
  35. g_pcmi = NULL;
  36. }
  37. CVolumeCacheCallBack::~CVolumeCacheCallBack(
  38. void
  39. )
  40. {
  41. ;
  42. }
  43. /*
  44. **------------------------------------------------------------------------------
  45. ** CVolumeCacheCallBack::QueryInterface
  46. **
  47. ** Purpose: Part of the IUnknown interface
  48. ** Parameters:
  49. ** riid - interface ID to query on
  50. ** ppv - pointer to interface if we support it
  51. ** Return: NOERROR on success, E_NOINTERFACE otherwise
  52. ** Notes;
  53. ** Mod Log: Created by Jason Cobb (2/97)
  54. **------------------------------------------------------------------------------
  55. */
  56. STDMETHODIMP CVolumeCacheCallBack::QueryInterface(
  57. REFIID riid,
  58. LPVOID FAR *ppv
  59. )
  60. {
  61. *ppv = NULL;
  62. //
  63. //Check for IUnknown interface request
  64. //
  65. if (IsEqualIID (riid, IID_IUnknown))
  66. {
  67. //
  68. //Typecast to the requested interface so C++ sets up
  69. //the virtual tables correctly
  70. //
  71. *ppv = (LPUNKNOWN)(LPEMPTYVOLUMECACHECALLBACK) this;
  72. AddRef();
  73. return NOERROR;
  74. }
  75. //
  76. //Check for IEmptyVolumeCacheCallBack interface request
  77. //
  78. if (IsEqualIID (riid, IID_IEmptyVolumeCacheCallBack))
  79. {
  80. //
  81. //Typecast to the requested interface so C++ sets up
  82. //the virtual tables correctly
  83. //
  84. *ppv = (LPEMPTYVOLUMECACHECALLBACK) this;
  85. AddRef();
  86. return NOERROR;
  87. }
  88. //
  89. //Error - unsupported interface requested
  90. //
  91. return E_NOINTERFACE;
  92. }
  93. /*
  94. **------------------------------------------------------------------------------
  95. ** CVolumeCacheCallBack::AddRef
  96. **
  97. ** Purpose: ups the reference count to this object
  98. ** Notes;
  99. ** Return: current refernce count
  100. ** Mod Log: Created by Jason Cobb (2/97)
  101. **------------------------------------------------------------------------------
  102. */
  103. STDMETHODIMP_(ULONG) CVolumeCacheCallBack::AddRef()
  104. {
  105. return ++m_cRef;
  106. }
  107. /*
  108. **------------------------------------------------------------------------------
  109. ** CVolumeCacheCallBack::Release
  110. **
  111. ** Purpose: downs the reference count to this object
  112. ** and deletes the object if no one is using it
  113. ** Notes;
  114. ** Mod Log: Created by Jason Cobb (2/97)
  115. **------------------------------------------------------------------------------
  116. */
  117. STDMETHODIMP_(ULONG) CVolumeCacheCallBack::Release()
  118. {
  119. //
  120. //Decrement and check
  121. //
  122. if (--m_cRef)
  123. return m_cRef;
  124. //
  125. //No references left to this object
  126. //
  127. delete this;
  128. return 0L;
  129. }
  130. /*
  131. **------------------------------------------------------------------------------
  132. ** CVolumeCacheCallBack::ScanProgress
  133. **
  134. ** Purpose: Part of the IUnknown interface
  135. ** Parameters:
  136. ** dwSpaceUsed - Amount of space that the client can free so far
  137. ** dwFlags - IEmptyVolumeCache flags
  138. ** pszStatus - Display string to tell the user what is happening
  139. ** Return: If E_ABORT then this indicates that no more notifications
  140. ** are required and the client should abort the scan. S_OK
  141. ** if the client should continue scanning.
  142. ** Notes;
  143. ** Mod Log: Created by Jason Cobb (2/97)
  144. **------------------------------------------------------------------------------
  145. */
  146. STDMETHODIMP
  147. CVolumeCacheCallBack::ScanProgress(
  148. DWORDLONG dwSpaceUsed,
  149. DWORD dwFlags,
  150. LPCWSTR pszStatus
  151. )
  152. {
  153. //
  154. //Update the amount of used disk space for this client
  155. //
  156. if (g_pClientInfo)
  157. g_pClientInfo->dwUsedSpace.QuadPart = dwSpaceUsed;
  158. //
  159. //Check the Flags. If this is the last notification from this client
  160. //then set g_pClientInfo to NULL
  161. //
  162. if (dwFlags & EVCCBF_LASTNOTIFICATION)
  163. g_pClientInfo = NULL;
  164. //
  165. //Has the user aborted the scan? If so let the cleanup object know
  166. //so that it can stop scanning
  167. //
  168. if (g_pcmi->bAbortScan)
  169. return E_ABORT;
  170. else
  171. return S_OK;
  172. }
  173. /*
  174. **------------------------------------------------------------------------------
  175. ** CVolumeCacheCallBack::PurgeProgress
  176. **
  177. ** Purpose: Part of the IUnknown interface
  178. ** Parameters:
  179. ** dwSpaceFreed - Amount of disk space freed so far.
  180. ** dwSpaceToFree - Amount the client was expected to free.
  181. ** dwFlags - IEmptyVolumeCache flags
  182. ** pszStatus - Display string to tell the user what is happening
  183. ** Return: If E_ABORT then this indicates that no more notifications
  184. ** are required and the client should abort the scan. S_OK
  185. ** if the client should continue scanning.
  186. ** Notes;
  187. ** Mod Log: Created by Jason Cobb (2/97)
  188. **------------------------------------------------------------------------------
  189. */
  190. STDMETHODIMP
  191. CVolumeCacheCallBack::PurgeProgress(
  192. DWORDLONG dwSpaceFreed,
  193. DWORDLONG dwSpaceToFree,
  194. DWORD dwFlags,
  195. LPCWSTR pszStatus
  196. )
  197. {
  198. g_pcmi->cbCurrentClientPurgedSoFar.QuadPart = dwSpaceFreed;
  199. //
  200. //Update the progress bar
  201. //
  202. PostMessage(g_pcmi->hAbortPurgeWnd, WMAPP_UPDATEPROGRESS, 0, 0);
  203. //
  204. //Has the user aborted the purge? If so let the cleanup object know
  205. //so that it can stop purging
  206. //
  207. if (g_pcmi->bAbortPurge)
  208. return E_ABORT;
  209. else
  210. return S_OK;
  211. }
  212. void
  213. CVolumeCacheCallBack::SetCleanupMgrInfo(
  214. PVOID pVoid
  215. )
  216. {
  217. if (pVoid)
  218. g_pcmi = (CleanupMgrInfo*)pVoid;
  219. }
  220. void
  221. CVolumeCacheCallBack::SetCurrentClient(
  222. PVOID pVoid
  223. )
  224. {
  225. if (pVoid)
  226. g_pClientInfo = (PCLIENTINFO)pVoid;
  227. }