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.

107 lines
2.1 KiB

  1. /**********************************************************************/
  2. /** Microsoft Windows/NT **/
  3. /** Copyright(c) Microsoft Corporation, 1997 - 1999 **/
  4. /**********************************************************************/
  5. /*
  6. ipxconn.cpp
  7. Commone server handle bookkeeping class.
  8. FILE HISTORY:
  9. */
  10. #include "stdafx.h"
  11. #include "util.h"
  12. #include "rtrutil.h"
  13. #include "ipxconn.h"
  14. DEBUG_DECLARE_INSTANCE_COUNTER(IPXConnection)
  15. IPXConnection::IPXConnection()
  16. : m_cRefCount(1)
  17. {
  18. DEBUG_INCREMENT_INSTANCE_COUNTER(IPXConnection);
  19. }
  20. IPXConnection::~IPXConnection()
  21. {
  22. DEBUG_DECREMENT_INSTANCE_COUNTER(IPXConnection);
  23. }
  24. ULONG IPXConnection::AddRef()
  25. {
  26. return InterlockedIncrement(&m_cRefCount);
  27. }
  28. ULONG IPXConnection::Release()
  29. {
  30. if (0 == InterlockedDecrement(&m_cRefCount))
  31. {
  32. delete this;
  33. return 0;
  34. }
  35. return m_cRefCount;
  36. }
  37. void IPXConnection::SetMachineName(LPCTSTR pszMachineName)
  38. {
  39. m_stServerName = pszMachineName;
  40. }
  41. LPCTSTR IPXConnection::GetMachineName()
  42. {
  43. return (LPCTSTR) m_stServerName;
  44. }
  45. HRESULT IPXConnection::ConnectToMprServer()
  46. {
  47. Assert(!m_sphMpr);
  48. DWORD dwErr;
  49. dwErr = ::MprAdminServerConnect((LPWSTR) (LPCTSTR)m_stServerName,
  50. &m_sphMpr);
  51. return HRESULT_FROM_WIN32(dwErr);
  52. }
  53. HRESULT IPXConnection::ConnectToMibServer()
  54. {
  55. Assert(!m_sphMib);
  56. DWORD dwErr;
  57. dwErr = ::MprAdminMIBServerConnect((LPWSTR) (LPCTSTR) m_stServerName,
  58. &m_sphMib);
  59. return HRESULT_FROM_WIN32(dwErr);
  60. }
  61. HRESULT IPXConnection::ConnectToConfigServer()
  62. {
  63. Assert(!m_sphConfig);
  64. DWORD dwErr;
  65. dwErr = ::MprConfigServerConnect((LPWSTR)(LPCTSTR)m_stServerName,
  66. &m_sphConfig);
  67. return HRESULT_FROM_WIN32(dwErr);
  68. }
  69. void IPXConnection::DisconnectAll()
  70. {
  71. DisconnectFromMibServer();
  72. DisconnectFromMprServer();
  73. DisconnectFromConfigServer();
  74. }
  75. BOOL IPXConnection::IsComputerAddedAsLocal()
  76. {
  77. return m_fComputerAddedAsLocal;
  78. }
  79. void IPXConnection::SetComputerAddedAsLocal(BOOL fAddedAsLocal)
  80. {
  81. m_fComputerAddedAsLocal = fAddedAsLocal;
  82. }