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.

167 lines
4.3 KiB

  1. // P3Config.cpp : Implementation of CP3Config
  2. #include "stdafx.h"
  3. #include "P3Admin.h"
  4. #include "P3Config.h"
  5. #include <POP3Server.h>
  6. #include "P3Domains.h"
  7. #include "P3Service.h"
  8. /////////////////////////////////////////////////////////////////////////////
  9. // CP3Config
  10. STDMETHODIMP CP3Config::IISConfig( BOOL bRegister )
  11. {
  12. return m_AdminX.SetIISConfig( bRegister ? true:false );
  13. }
  14. STDMETHODIMP CP3Config::get_Authentication(IAuthMethods* *ppIAuthMethods)
  15. { // ppIAuthMethods - validated by GetAuthenticationMethods
  16. return m_AdminX.GetAuthenticationMethods( ppIAuthMethods );
  17. }
  18. STDMETHODIMP CP3Config::get_ConfirmAddUser(BOOL *pVal)
  19. { // ppIAuthMethods - validated by GetAuthenticationMethods
  20. return m_AdminX.GetConfirmAddUser( pVal );
  21. }
  22. STDMETHODIMP CP3Config::put_ConfirmAddUser(BOOL newVal)
  23. { // ppIAuthMethods - validated by GetAuthenticationMethods
  24. return m_AdminX.SetConfirmAddUser( newVal );
  25. }
  26. STDMETHODIMP CP3Config::GetFormattedMessage(/*[in]*/ long lError, /*[out]*/ VARIANT *pVal)
  27. {
  28. if ( NULL == pVal )
  29. return E_INVALIDARG;
  30. HRESULT hr = S_OK;
  31. LPVOID lpMsgBuf;
  32. if ( FormatMessage( FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, NULL, lError, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), reinterpret_cast<LPWSTR>( &lpMsgBuf ), 0, NULL ))
  33. {
  34. VariantInit( pVal );
  35. V_VT( pVal ) = VT_BSTR;
  36. V_BSTR( pVal ) = SysAllocString( reinterpret_cast<LPWSTR>( lpMsgBuf ));
  37. LocalFree( lpMsgBuf );
  38. }
  39. else
  40. {
  41. hr = S_FALSE;
  42. }
  43. return hr;
  44. }
  45. STDMETHODIMP CP3Config::get_Service(IP3Service **ppIService)
  46. {
  47. if ( NULL == ppIService )
  48. return E_POINTER;
  49. HRESULT hr;
  50. LPUNKNOWN pIUnk;
  51. CComObject<CP3Service> *p;
  52. *ppIService = NULL;
  53. hr = CComObject<CP3Service>::CreateInstance( &p ); // Reference count still 0
  54. if ( S_OK == hr )
  55. {
  56. hr = _InternalQueryInterface(IID_IUnknown, reinterpret_cast<LPVOID*>( &pIUnk ));
  57. if ( S_OK == hr )
  58. {
  59. if ( S_OK == hr )
  60. hr = p->Init( pIUnk, &m_AdminX );
  61. if ( S_OK == hr )
  62. hr = p->QueryInterface(IID_IP3Service, reinterpret_cast<void**>( ppIService ));
  63. }
  64. if ( S_OK != hr )
  65. delete p; // Release
  66. }
  67. assert( S_OK == hr );
  68. return hr;
  69. }
  70. STDMETHODIMP CP3Config::get_Domains(IP3Domains **ppIDomains)
  71. {
  72. if ( NULL == ppIDomains )
  73. return E_POINTER;
  74. HRESULT hr;
  75. LPUNKNOWN pIUnk;
  76. CComObject<CP3Domains> *p;
  77. *ppIDomains = NULL;
  78. hr = CComObject<CP3Domains>::CreateInstance( &p ); // Reference count still 0
  79. if SUCCEEDED( hr )
  80. {
  81. hr = _InternalQueryInterface(IID_IUnknown, reinterpret_cast<LPVOID*>( &pIUnk ));
  82. if SUCCEEDED( hr )
  83. {
  84. hr = p->Init( pIUnk, &m_AdminX );
  85. if SUCCEEDED( hr )
  86. hr = p->QueryInterface(IID_IP3Domains, reinterpret_cast<void**>( ppIDomains ));
  87. }
  88. if FAILED( hr )
  89. delete p; // Release
  90. }
  91. assert( S_OK == hr );
  92. return hr;
  93. }
  94. STDMETHODIMP CP3Config::get_LoggingLevel(long *pVal)
  95. {
  96. return m_AdminX.GetLoggingLevel( pVal );
  97. }
  98. STDMETHODIMP CP3Config::put_LoggingLevel(long newVal)
  99. {
  100. return m_AdminX.SetLoggingLevel( newVal );
  101. }
  102. STDMETHODIMP CP3Config::get_MachineName(BSTR *pVal)
  103. {
  104. if ( NULL == pVal )
  105. return E_INVALIDARG;
  106. HRESULT hr;
  107. WCHAR sMachineName[MAX_PATH];
  108. hr = m_AdminX.GetMachineName( sMachineName, sizeof( sMachineName )/sizeof(WCHAR));
  109. if SUCCEEDED( hr )
  110. {
  111. *pVal = SysAllocString( sMachineName );
  112. }
  113. return hr;
  114. }
  115. STDMETHODIMP CP3Config::put_MachineName(BSTR newVal)
  116. {
  117. return m_AdminX.SetMachineName( newVal );
  118. }
  119. STDMETHODIMP CP3Config::get_MailRoot(BSTR *pVal)
  120. {
  121. if ( NULL == pVal )
  122. return E_INVALIDARG;
  123. HRESULT hr;
  124. WCHAR sMailRoot[POP3_MAX_MAILROOT_LENGTH];
  125. hr = m_AdminX.GetMailroot( sMailRoot, sizeof( sMailRoot )/sizeof(WCHAR), false );
  126. if SUCCEEDED( hr )
  127. {
  128. *pVal = SysAllocString( sMailRoot );
  129. }
  130. return hr;
  131. }
  132. STDMETHODIMP CP3Config::put_MailRoot(BSTR newVal)
  133. {
  134. return m_AdminX.SetMailroot( newVal );
  135. }