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.

277 lines
6.9 KiB

  1. #include "stdafx.h"
  2. #include "objects.h"
  3. #include "maindoc.h"
  4. #include "resource.h"
  5. #include "grpcrtit.h"
  6. #include "delgrpit.h"
  7. /***********************************************************
  8. Function:
  9. Arguments:
  10. Return:
  11. Purpose:
  12. Author(s):
  13. Revision:
  14. Date:
  15. ***********************************************************/
  16. COleDsFileService::COleDsFileService( )
  17. {
  18. }
  19. /***********************************************************
  20. Function:
  21. Arguments:
  22. Return:
  23. Purpose:
  24. Author(s):
  25. Revision:
  26. Date:
  27. ***********************************************************/
  28. COleDsFileService::COleDsFileService( IUnknown *pIUnk): COleDsService( pIUnk )
  29. {
  30. m_bHasChildren = TRUE;
  31. m_bSupportAdd = TRUE;
  32. m_bSupportDelete = TRUE;
  33. }
  34. /***********************************************************
  35. Function:
  36. Arguments:
  37. Return:
  38. Purpose:
  39. Author(s):
  40. Revision:
  41. Date:
  42. ***********************************************************/
  43. COleDsFileService::~COleDsFileService( )
  44. {
  45. }
  46. /***********************************************************
  47. Function:
  48. Arguments:
  49. Return:
  50. Purpose:
  51. Author(s):
  52. Revision:
  53. Date:
  54. ***********************************************************/
  55. DWORD COleDsFileService::GetChildren( DWORD* pTokens,
  56. DWORD dwMaxChildren,
  57. CDialog* pQueryStatus,
  58. BOOL* pFilters,
  59. DWORD dwFilters )
  60. {
  61. HRESULT hResult;
  62. IADsFileService* pIOleDsFileService = NULL;
  63. IADsFileServiceOperations* pIFServOper = NULL;
  64. IADsCollection* pICollFShares = NULL;
  65. IADsCollection* pICollSessions = NULL;
  66. IADsCollection* pICollRes = NULL;
  67. IADsContainer* pIContainer = NULL;
  68. if( NULL == m_pIUnk )
  69. {
  70. ASSERT( FALSE );
  71. return 0L;
  72. }
  73. COleDsObject::GetChildren( pTokens, dwMaxChildren, pQueryStatus,
  74. pFilters, dwFilters );
  75. hResult = m_pIUnk->QueryInterface( IID_IADsFileService,
  76. (void**) &pIOleDsFileService );
  77. hResult = m_pIUnk->QueryInterface( IID_IADsFileServiceOperations,
  78. (void**) &pIFServOper );
  79. ASSERT( SUCCEEDED( hResult ) );
  80. if( FAILED( hResult ) )
  81. return 0L;
  82. hResult = pIOleDsFileService->QueryInterface( IID_IADsContainer,
  83. (void**) &pIContainer );
  84. ASSERT( SUCCEEDED( hResult ) );
  85. if( FAILED( hResult ) )
  86. {
  87. pIOleDsFileService->Release( );
  88. return 0L;
  89. }
  90. COleDsObject::GetChildren( pIContainer );
  91. pIContainer->Release( );
  92. hResult = pIFServOper->Sessions ( &pICollSessions );
  93. hResult = pIFServOper->Resources( &pICollRes );
  94. if( NULL != pICollFShares )
  95. {
  96. COleDsObject::GetChildren( pICollFShares );
  97. pICollFShares->Release( );
  98. }
  99. if( NULL != pICollSessions )
  100. {
  101. COleDsObject::GetChildren( pICollSessions );
  102. pICollSessions->Release( );
  103. }
  104. if( NULL != pICollRes )
  105. {
  106. COleDsObject::GetChildren( pICollRes );
  107. pICollRes->Release( );
  108. }
  109. pIFServOper->Release( );
  110. pIOleDsFileService->Release( );
  111. return m_dwCount;
  112. }
  113. /***********************************************************
  114. Function:
  115. Arguments:
  116. Return:
  117. Purpose:
  118. Author(s):
  119. Revision:
  120. Date:
  121. ***********************************************************/
  122. HRESULT COleDsFileService::DeleteItem( COleDsObject* pObject )
  123. {
  124. DWORD dwType;
  125. HRESULT hResult;
  126. CString strQualifiedName;
  127. CString strItemType;
  128. CString strDeleteName;
  129. CDeleteGroupItem aDeleteItem;
  130. IADsCollection* pIColl = NULL;
  131. IADsFileService* pIFServ = NULL;
  132. hResult = m_pIUnk->QueryInterface( IID_IADsFileService, (void**)&pIFServ );
  133. ASSERT( SUCCEEDED( hResult ) );
  134. if( FAILED( hResult ) )
  135. {
  136. return E_FAIL;
  137. }
  138. dwType = pObject->GetType( );
  139. switch( dwType )
  140. {
  141. case FILESHARE:
  142. {
  143. return ContainerDeleteItem( pObject );
  144. }
  145. case SESSION:
  146. {
  147. IADsFileServiceOperations* pIOper = NULL;
  148. hResult = pIFServ->QueryInterface( IID_IADsFileServiceOperations, (void**)&pIOper );
  149. ASSERT( SUCCEEDED( hResult ) );
  150. if( FAILED( hResult ) )
  151. {
  152. break;
  153. }
  154. hResult = pIOper->Sessions( &pIColl );
  155. pIOper->Release( );
  156. break;
  157. }
  158. case RESOURCE:
  159. {
  160. IADsFileServiceOperations* pIOper = NULL;
  161. hResult = pIFServ->QueryInterface( IID_IADsFileServiceOperations, (void**)&pIOper );
  162. ASSERT( SUCCEEDED( hResult ) );
  163. if( FAILED( hResult ) )
  164. {
  165. break;
  166. }
  167. hResult = pIOper->Resources( &pIColl );
  168. pIOper->Release( );
  169. break;
  170. }
  171. default:
  172. ASSERT( FALSE );
  173. return E_FAIL;
  174. }
  175. if( NULL != pIColl )
  176. {
  177. strDeleteName = pObject->GetDeleteName( );
  178. MakeQualifiedName( strQualifiedName, m_strOleDsPath, m_dwType );
  179. strItemType = pObject->GetClass( );
  180. aDeleteItem.m_strItemName = strDeleteName;
  181. aDeleteItem.m_strParent = strQualifiedName;
  182. aDeleteItem.m_strItemType = strItemType;
  183. if( aDeleteItem.DoModal( ) == IDOK )
  184. {
  185. VARIANT var;
  186. VariantInit( &var );
  187. V_VT( &var ) = VT_BSTR;
  188. V_BSTR( &var ) = AllocBSTR( aDeleteItem.m_strItemName.GetBuffer( 128 ) );
  189. hResult = pIColl->Remove( V_BSTR( &var ) );
  190. VariantClear( &var );
  191. }
  192. pIColl->Release( );
  193. }
  194. pIFServ->Release( );
  195. return hResult;
  196. }
  197. /***********************************************************
  198. Function:
  199. Arguments:
  200. Return:
  201. Purpose:
  202. Author(s):
  203. Revision:
  204. Date:
  205. ***********************************************************/
  206. HRESULT COleDsFileService::AddItem( )
  207. {
  208. return ContainerAddItem( );
  209. }
  210. /***********************************************************
  211. Function:
  212. Arguments:
  213. Return:
  214. Purpose:
  215. Author(s):
  216. Revision:
  217. Date:
  218. ***********************************************************/
  219. HRESULT COleDsFileService::MoveItem( )
  220. {
  221. return ContainerMoveItem( );
  222. }
  223. /***********************************************************
  224. Function:
  225. Arguments:
  226. Return:
  227. Purpose:
  228. Author(s):
  229. Revision:
  230. Date:
  231. ***********************************************************/
  232. HRESULT COleDsFileService::CopyItem( )
  233. {
  234. return ContainerCopyItem( );
  235. }