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.

220 lines
5.6 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. COleDsPrintQueue::COleDsPrintQueue( )
  17. {
  18. }
  19. /***********************************************************
  20. Function:
  21. Arguments:
  22. Return:
  23. Purpose:
  24. Author(s):
  25. Revision:
  26. Date:
  27. ***********************************************************/
  28. COleDsPrintQueue::COleDsPrintQueue( IUnknown *pIUnk): COleDsObject( pIUnk )
  29. {
  30. m_bHasChildren = TRUE;
  31. }
  32. /***********************************************************
  33. Function:
  34. Arguments:
  35. Return:
  36. Purpose:
  37. Author(s):
  38. Revision:
  39. Date:
  40. ***********************************************************/
  41. COleDsPrintQueue::~COleDsPrintQueue( )
  42. {
  43. }
  44. /***********************************************************
  45. Function:
  46. Arguments:
  47. Return:
  48. Purpose:
  49. Author(s):
  50. Revision:
  51. Date:
  52. ***********************************************************/
  53. DWORD COleDsPrintQueue::GetChildren( DWORD* pTokens,
  54. DWORD dwMaxChildren,
  55. CDialog* pQueryStatus,
  56. BOOL* pFilters,
  57. DWORD dwFilters )
  58. {
  59. HRESULT hResult;
  60. IADsPrintQueue* pIOleDsPrintQueue = NULL;
  61. IADsCollection* pIJobs = NULL;
  62. IADsPrintQueueOperations* pIPQueueOper = NULL;
  63. if( m_strOleDsPath[ 4 ] == _T(':') )
  64. {
  65. // the wort way to find if this is "LDAP:"
  66. // SWilson (NT) needs this
  67. return 0L;
  68. }
  69. if( NULL == m_pIUnk )
  70. {
  71. ASSERT( FALSE );
  72. return 0L;
  73. }
  74. COleDsObject::GetChildren( pTokens, dwMaxChildren, pQueryStatus,
  75. pFilters, dwFilters );
  76. hResult = m_pIUnk->QueryInterface( IID_IADsPrintQueue,
  77. (void**) &pIOleDsPrintQueue );
  78. if( FAILED( hResult ) )
  79. {
  80. TRACE( _T("ERROR: QueryInterface for IID_IADsPrintQueue failed\n") );
  81. }
  82. else
  83. {
  84. hResult = m_pIUnk->QueryInterface( IID_IADsPrintQueueOperations,
  85. (void**) &pIPQueueOper );
  86. if( FAILED( hResult ) )
  87. {
  88. TRACE( _T("ERROR: QueryInterface for IID_IADsPrintQueueOperations failed\n") );
  89. }
  90. else
  91. {
  92. hResult = pIPQueueOper->PrintJobs( &pIJobs );
  93. if( NULL != pIJobs )
  94. {
  95. COleDsObject::GetChildren( pIJobs );
  96. pIJobs->Release( );
  97. }
  98. pIPQueueOper->Release( );
  99. }
  100. pIOleDsPrintQueue->Release( );
  101. }
  102. return m_dwCount;
  103. }
  104. /***********************************************************
  105. Function:
  106. Arguments:
  107. Return:
  108. Purpose:
  109. Author(s):
  110. Revision:
  111. Date:
  112. ***********************************************************/
  113. HRESULT COleDsPrintQueue::DeleteItem ( COleDsObject* pObject )
  114. {
  115. DWORD dwType;
  116. HRESULT hResult;
  117. CString strQualifiedName;
  118. CString strItemType;
  119. CString strDeleteName;
  120. CDeleteGroupItem aDeleteItem;
  121. IADsCollection* pIColl = NULL;
  122. IADsPrintQueue* pIPQueue = NULL;
  123. BOOL bSuccess = FALSE;
  124. hResult = m_pIUnk->QueryInterface( IID_IADsPrintQueue, (void**)&pIPQueue );
  125. ASSERT( SUCCEEDED( hResult ) );
  126. if( FAILED( hResult ) )
  127. {
  128. return E_FAIL;
  129. }
  130. dwType = pObject->GetType( );
  131. switch( dwType )
  132. {
  133. case PRINTJOB:
  134. {
  135. IADsPrintQueueOperations* pIOper = NULL;
  136. hResult = pIPQueue->QueryInterface( IID_IADsPrintQueueOperations, (void**)&pIOper );
  137. ASSERT( SUCCEEDED( hResult ) );
  138. if( FAILED( hResult ) )
  139. {
  140. break;
  141. }
  142. hResult = pIOper->PrintJobs( &pIColl );
  143. pIOper->Release( );
  144. bSuccess = TRUE;
  145. break;
  146. }
  147. default:
  148. ASSERT( FALSE );
  149. return E_FAIL;
  150. }
  151. if( bSuccess )
  152. {
  153. strDeleteName = pObject->GetDeleteName( );
  154. MakeQualifiedName( strQualifiedName, m_strOleDsPath, m_dwType );
  155. strItemType = pObject->GetClass( );
  156. aDeleteItem.m_strItemName = strDeleteName;
  157. aDeleteItem.m_strParent = strQualifiedName;
  158. aDeleteItem.m_strItemType = strItemType;
  159. if( aDeleteItem.DoModal( ) == IDOK )
  160. {
  161. VARIANT var;
  162. VariantInit( &var );
  163. V_VT( &var ) = VT_BSTR;
  164. V_BSTR( &var ) = AllocBSTR( aDeleteItem.m_strItemName.GetBuffer( 128 ) );
  165. if( NULL != pIColl )
  166. {
  167. hResult = pIColl->Remove( V_BSTR(&var) );
  168. }
  169. VariantClear( &var );
  170. }
  171. if( NULL != pIColl )
  172. {
  173. ULONG ulRef;
  174. ulRef = pIColl->Release( );
  175. if( ulRef )
  176. {
  177. TRACE( _T("ERROR: Release on PrintJob collection did not returned 0\n") );
  178. }
  179. }
  180. }
  181. pIPQueue->Release( );
  182. return hResult;
  183. }