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.

278 lines
7.1 KiB

  1. //+------------------------------------------------------------------
  2. //
  3. // Copyright (C) 1991-1997 Microsoft Corporation.
  4. //
  5. // File: notprop.cxx
  6. //
  7. // Contents: Notification stat property enumeration interfaces
  8. //
  9. // Classes: CINStatPropertyEnum, CINStatPropertyStorage
  10. //
  11. // History: 24-Feb-97 SitaramR Created
  12. //
  13. //-------------------------------------------------------------------
  14. #include <pch.cxx>
  15. #pragma hdrstop
  16. #include "notprop.hxx"
  17. //+-------------------------------------------------------------------------
  18. //
  19. // Method: CINStatPropertyEnum::AddRef
  20. //
  21. // Synopsis: Increments refcount
  22. //
  23. // History: 24-Feb-1997 SitaramR Created
  24. //
  25. //--------------------------------------------------------------------------
  26. ULONG STDMETHODCALLTYPE CINStatPropertyEnum::AddRef()
  27. {
  28. return InterlockedIncrement( (long *) &_cRefs );
  29. }
  30. //+-------------------------------------------------------------------------
  31. //
  32. // Method: CINStatPropertyEnum::Release
  33. //
  34. // Synopsis: Decrement refcount. Delete if necessary.
  35. //
  36. // History: 24-Feb-1997 SitaramR Created
  37. //
  38. //--------------------------------------------------------------------------
  39. ULONG STDMETHODCALLTYPE CINStatPropertyEnum::Release()
  40. {
  41. Win4Assert( _cRefs > 0 );
  42. ULONG uTmp = InterlockedDecrement( (long *) &_cRefs );
  43. if ( 0 == uTmp )
  44. delete this;
  45. return(uTmp);
  46. }
  47. //+-------------------------------------------------------------------------
  48. //
  49. // Method: CINStatPropertyEnum::QueryInterface
  50. //
  51. // Synopsis: Rebind to other interface
  52. //
  53. // Arguments: [riid] -- IID of new interface
  54. // [ppvObject] -- New interface * returned here
  55. //
  56. // Returns: S_OK if bind succeeded, E_NOINTERFACE if bind failed
  57. //
  58. // History: 24-Feb-1997 SitaramR Created
  59. //
  60. //--------------------------------------------------------------------------
  61. SCODE STDMETHODCALLTYPE CINStatPropertyEnum::QueryInterface( REFIID riid,
  62. void ** ppvObject)
  63. {
  64. Win4Assert( 0 != ppvObject );
  65. if ( riid == IID_IEnumSTATPROPSTG )
  66. *ppvObject = (void *)(IEnumSTATPROPSTG *) this;
  67. else if ( riid == IID_IUnknown )
  68. *ppvObject = (void *)(IUnknown *) this;
  69. else
  70. {
  71. *ppvObject = 0;
  72. return E_NOINTERFACE;
  73. }
  74. AddRef();
  75. return S_OK;
  76. }
  77. //+-------------------------------------------------------------------------
  78. //
  79. // Method: CINStatPropertyStorage::AddRef
  80. //
  81. // Synopsis: Increments refcount
  82. //
  83. // History: 24-Feb-1997 SitaramR Created
  84. //
  85. //--------------------------------------------------------------------------
  86. CINStatPropertyStorage::CINStatPropertyStorage()
  87. : _cRefs(1)
  88. {
  89. }
  90. //+-------------------------------------------------------------------------
  91. //
  92. // Method: CINStatPropertyStorage::AddRef
  93. //
  94. // Synopsis: Increments refcount
  95. //
  96. // History: 24-Feb-1997 SitaramR Created
  97. //
  98. //--------------------------------------------------------------------------
  99. ULONG STDMETHODCALLTYPE CINStatPropertyStorage::AddRef()
  100. {
  101. return InterlockedIncrement( (long *) &_cRefs );
  102. }
  103. //+-------------------------------------------------------------------------
  104. //
  105. // Method: CINStatPropertyStorage::Release
  106. //
  107. // Synopsis: Decrement refcount. Delete if necessary.
  108. //
  109. // History: 24-Feb-1997 SitaramR Created
  110. //
  111. //--------------------------------------------------------------------------
  112. ULONG STDMETHODCALLTYPE CINStatPropertyStorage::Release()
  113. {
  114. Win4Assert( _cRefs > 0 );
  115. ULONG uTmp = InterlockedDecrement( (long *) &_cRefs );
  116. if ( 0 == uTmp )
  117. delete this;
  118. return(uTmp);
  119. }
  120. //+-------------------------------------------------------------------------
  121. //
  122. // Method: CINStatPropertyStorage::QueryInterface
  123. //
  124. // Synopsis: Rebind to other interface
  125. //
  126. // Arguments: [riid] -- IID of new interface
  127. // [ppvObject] -- New interface * returned here
  128. //
  129. // Returns: S_OK if bind succeeded, E_NOINTERFACE if bind failed
  130. //
  131. // History: 24-Feb-1997 SitaramR Created
  132. //
  133. //--------------------------------------------------------------------------
  134. SCODE STDMETHODCALLTYPE CINStatPropertyStorage::QueryInterface( REFIID riid,
  135. void ** ppvObject)
  136. {
  137. Win4Assert( 0 != ppvObject );
  138. if ( riid == IID_IUnknown )
  139. {
  140. AddRef();
  141. *ppvObject = (void *)(IUnknown *) this;
  142. return S_OK;
  143. }
  144. else if ( riid == IID_IPropertyStorage )
  145. {
  146. AddRef();
  147. *ppvObject = (void *)(IPropertyStorage *) this;
  148. return S_OK;
  149. }
  150. else
  151. {
  152. *ppvObject = 0;
  153. return E_NOINTERFACE;
  154. }
  155. }
  156. //+-------------------------------------------------------------------------
  157. //
  158. // Method: CINStatPropertyStorage::ReadMultiple
  159. //
  160. // Synopsis: Generates a file size property
  161. //
  162. // History: 24-Feb-1997 SitaramR Created
  163. //
  164. //--------------------------------------------------------------------------
  165. SCODE STDMETHODCALLTYPE CINStatPropertyStorage::ReadMultiple(
  166. ULONG cpspec,
  167. const PROPSPEC rgpspec[],
  168. PROPVARIANT rgpropvar[] )
  169. {
  170. for (ULONG i = 0; i < cpspec; i++)
  171. {
  172. //
  173. // String named properties are not found, and we only return
  174. // the size property. The size is chosen to be a large number
  175. // because the size is used to enforce space limits on
  176. // filtering.
  177. //
  178. PROPID PropertyId;
  179. if (rgpspec[i].ulKind == PRSPEC_LPWSTR)
  180. PropertyId = 0xFFFFFFFF;
  181. else
  182. PropertyId = rgpspec[i].propid;
  183. if ( PropertyId == PID_STG_SIZE )
  184. {
  185. rgpropvar[i].vt = VT_I8;
  186. LARGE_INTEGER largeInt;
  187. largeInt.QuadPart = 0xFFFFFFF;
  188. rgpropvar[i].hVal = largeInt;
  189. }
  190. else
  191. {
  192. //
  193. // No other properties exist, they are not found
  194. //
  195. rgpropvar[i].vt = VT_EMPTY;
  196. return E_FAIL;
  197. }
  198. }
  199. return S_OK;
  200. }
  201. //+-------------------------------------------------------------------------
  202. //
  203. // Method: CINStatPropertyStorage::Enum
  204. //
  205. // Synopsis: Returns an IEnumSTATPROPSTG interface
  206. //
  207. // History: 24-Feb-1997 SitaramR Created
  208. //
  209. //--------------------------------------------------------------------------
  210. SCODE STDMETHODCALLTYPE CINStatPropertyStorage::Enum( IEnumSTATPROPSTG **ppenum )
  211. {
  212. SCODE sc = S_OK;
  213. TRY
  214. {
  215. *ppenum = new CINStatPropertyEnum;
  216. }
  217. CATCH( CException, e )
  218. {
  219. sc = e.GetErrorCode();
  220. ciDebugOut(( DEB_ERROR,
  221. "CINStatPropertyEnum::Enum - Exception caught 0x%x\n",
  222. sc ));
  223. }
  224. END_CATCH;
  225. return sc;
  226. }