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.

257 lines
6.6 KiB

  1. // P3Service.cpp : Implementation of CP3Service
  2. #include "stdafx.h"
  3. #include "P3Admin.h"
  4. #include "P3Service.h"
  5. #include <POP3Server.h>
  6. #include <smtpinet.h>
  7. #include <inetinfo.h>
  8. //////////////////////////////////////////////////////////////////////
  9. // Construction/Destruction
  10. //////////////////////////////////////////////////////////////////////
  11. CP3Service::CP3Service() :
  12. m_pIUnk(NULL), m_pAdminX(NULL)
  13. {
  14. }
  15. CP3Service::~CP3Service()
  16. {
  17. if ( NULL != m_pIUnk )
  18. m_pIUnk->Release();
  19. }
  20. //////////////////////////////////////////////////////////////////////
  21. // IP3Domains
  22. //////////////////////////////////////////////////////////////////////
  23. STDMETHODIMP CP3Service::get_ThreadCountPerCPU(long *pVal)
  24. {
  25. if ( NULL == m_pAdminX ) return E_POINTER;
  26. return m_pAdminX->GetThreadCountPerCPU( pVal );
  27. }
  28. STDMETHODIMP CP3Service::put_ThreadCountPerCPU(long newVal)
  29. {
  30. if ( NULL == m_pAdminX ) return E_POINTER;
  31. return m_pAdminX->SetThreadCountPerCPU( newVal );
  32. }
  33. STDMETHODIMP CP3Service::get_SocketsMax(long *pVal)
  34. {
  35. if ( NULL == m_pAdminX ) return E_POINTER;
  36. return m_pAdminX->GetSocketMax( pVal );
  37. }
  38. STDMETHODIMP CP3Service::get_SocketsMin(long *pVal)
  39. {
  40. if ( NULL == m_pAdminX ) return E_POINTER;
  41. return m_pAdminX->GetSocketMin( pVal );
  42. }
  43. STDMETHODIMP CP3Service::get_SocketsThreshold(long *pVal)
  44. {
  45. if ( NULL == m_pAdminX ) return E_POINTER;
  46. return m_pAdminX->GetSocketThreshold( pVal );
  47. }
  48. STDMETHODIMP CP3Service::SetSockets(long lMax, long lMin, long lThreshold, long lBacklog)
  49. {
  50. if ( NULL == m_pAdminX ) return E_POINTER;
  51. return m_pAdminX->SetSockets( lMax, lMin, lThreshold, lBacklog );
  52. }
  53. STDMETHODIMP CP3Service::get_SocketsBacklog(long *pVal)
  54. {
  55. if ( NULL == m_pAdminX ) return E_POINTER;
  56. return m_pAdminX->GetSocketBacklog( pVal );
  57. }
  58. STDMETHODIMP CP3Service::get_Port(long *pVal)
  59. {
  60. if ( NULL == m_pAdminX ) return E_POINTER;
  61. return m_pAdminX->GetPort( pVal );
  62. }
  63. STDMETHODIMP CP3Service::put_Port(long newVal)
  64. {
  65. if ( NULL == m_pAdminX ) return E_POINTER;
  66. return m_pAdminX->SetPort( newVal );
  67. }
  68. STDMETHODIMP CP3Service::get_SPARequired(BOOL *pVal)
  69. {
  70. if ( NULL == m_pAdminX ) return E_POINTER;
  71. return m_pAdminX->GetSPARequired( pVal );
  72. }
  73. STDMETHODIMP CP3Service::put_SPARequired(BOOL newVal)
  74. {
  75. if ( NULL == m_pAdminX ) return E_POINTER;
  76. return m_pAdminX->SetSPARequired( newVal );
  77. }
  78. STDMETHODIMP CP3Service::get_POP3ServiceStatus(/*[out, retval]*/ long *pVal)
  79. {
  80. if ( NULL == m_pAdminX ) return E_POINTER;
  81. return m_pAdminX->GetServiceStatus( POP3_SERVICE_NAME, reinterpret_cast<LPDWORD>( pVal ));
  82. }
  83. STDMETHODIMP CP3Service::StartPOP3Service()
  84. {
  85. if ( NULL == m_pAdminX ) return E_POINTER;
  86. return m_pAdminX->StartService( POP3_SERVICE_NAME );
  87. }
  88. STDMETHODIMP CP3Service::StopPOP3Service()
  89. {
  90. if ( NULL == m_pAdminX ) return E_POINTER;
  91. return m_pAdminX->StopService( POP3_SERVICE_NAME );
  92. }
  93. STDMETHODIMP CP3Service::PausePOP3Service()
  94. {
  95. if ( NULL == m_pAdminX ) return E_POINTER;
  96. return m_pAdminX->ControlService( POP3_SERVICE_NAME, SERVICE_CONTROL_PAUSE);
  97. }
  98. STDMETHODIMP CP3Service::ResumePOP3Service()
  99. {
  100. if ( NULL == m_pAdminX ) return E_POINTER;
  101. return m_pAdminX->ControlService( POP3_SERVICE_NAME, SERVICE_CONTROL_CONTINUE );
  102. }
  103. STDMETHODIMP CP3Service::get_SMTPServiceStatus(/*[out, retval]*/ long *pVal)
  104. {
  105. if ( NULL == m_pAdminX ) return E_POINTER;
  106. return m_pAdminX->GetServiceStatus( SMTP_SERVICE_NAME, reinterpret_cast<LPDWORD>( pVal ));
  107. }
  108. STDMETHODIMP CP3Service::StartSMTPService()
  109. {
  110. if ( NULL == m_pAdminX ) return E_POINTER;
  111. return m_pAdminX->StartService( SMTP_SERVICE_NAME );
  112. }
  113. STDMETHODIMP CP3Service::StopSMTPService()
  114. {
  115. if ( NULL == m_pAdminX ) return E_POINTER;
  116. return m_pAdminX->StopService( SMTP_SERVICE_NAME );
  117. }
  118. STDMETHODIMP CP3Service::PauseSMTPService()
  119. {
  120. if ( NULL == m_pAdminX ) return E_POINTER;
  121. return m_pAdminX->ControlService( SMTP_SERVICE_NAME, SERVICE_CONTROL_PAUSE);
  122. }
  123. STDMETHODIMP CP3Service::ResumeSMTPService()
  124. {
  125. if ( NULL == m_pAdminX ) return E_POINTER;
  126. return m_pAdminX->ControlService( SMTP_SERVICE_NAME, SERVICE_CONTROL_CONTINUE );
  127. }
  128. STDMETHODIMP CP3Service::get_IISAdminServiceStatus(/*[out, retval]*/ long *pVal)
  129. {
  130. if ( NULL == m_pAdminX ) return E_POINTER;
  131. return m_pAdminX->GetServiceStatus( IISADMIN_SERVICE_NAME, reinterpret_cast<LPDWORD>( pVal ));
  132. }
  133. STDMETHODIMP CP3Service::StartIISAdminService()
  134. {
  135. if ( NULL == m_pAdminX ) return E_POINTER;
  136. return m_pAdminX->StartService( IISADMIN_SERVICE_NAME );
  137. }
  138. STDMETHODIMP CP3Service::StopIISAdminService()
  139. {
  140. if ( NULL == m_pAdminX ) return E_POINTER;
  141. return m_pAdminX->StopService( IISADMIN_SERVICE_NAME );
  142. }
  143. STDMETHODIMP CP3Service::PauseIISAdminService()
  144. {
  145. if ( NULL == m_pAdminX ) return E_POINTER;
  146. return m_pAdminX->ControlService( IISADMIN_SERVICE_NAME, SERVICE_CONTROL_PAUSE);
  147. }
  148. STDMETHODIMP CP3Service::ResumeIISAdminService()
  149. {
  150. if ( NULL == m_pAdminX ) return E_POINTER;
  151. return m_pAdminX->ControlService( IISADMIN_SERVICE_NAME, SERVICE_CONTROL_CONTINUE );
  152. }
  153. STDMETHODIMP CP3Service::get_W3ServiceStatus(/*[out, retval]*/ long *pVal)
  154. {
  155. if ( NULL == m_pAdminX ) return E_POINTER;
  156. return m_pAdminX->GetServiceStatus( W3_SERVICE_NAME, reinterpret_cast<LPDWORD>( pVal ));
  157. }
  158. STDMETHODIMP CP3Service::StartW3Service()
  159. {
  160. if ( NULL == m_pAdminX ) return E_POINTER;
  161. return m_pAdminX->StartService( W3_SERVICE_NAME );
  162. }
  163. STDMETHODIMP CP3Service::StopW3Service()
  164. {
  165. if ( NULL == m_pAdminX ) return E_POINTER;
  166. return m_pAdminX->StopService( W3_SERVICE_NAME );
  167. }
  168. STDMETHODIMP CP3Service::PauseW3Service()
  169. {
  170. if ( NULL == m_pAdminX ) return E_POINTER;
  171. return m_pAdminX->ControlService( W3_SERVICE_NAME, SERVICE_CONTROL_PAUSE);
  172. }
  173. STDMETHODIMP CP3Service::ResumeW3Service()
  174. {
  175. if ( NULL == m_pAdminX ) return E_POINTER;
  176. return m_pAdminX->ControlService( W3_SERVICE_NAME, SERVICE_CONTROL_CONTINUE );
  177. }
  178. //////////////////////////////////////////////////////////////////////
  179. // Implementation: public
  180. //////////////////////////////////////////////////////////////////////
  181. HRESULT CP3Service::Init(IUnknown *pIUnk, CP3AdminWorker *p)
  182. {
  183. if ( NULL == pIUnk )
  184. return E_INVALIDARG;
  185. if ( NULL == p )
  186. return E_INVALIDARG;
  187. m_pIUnk = pIUnk;
  188. m_pAdminX = p;
  189. return S_OK;
  190. }