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.

189 lines
3.8 KiB

  1. ///////////////////////////////////////////////////////////////////////////////
  2. //
  3. // Copyright (c) Microsoft Corporation
  4. //
  5. // SYNOPSIS
  6. //
  7. // Defines the class DatabaseNode.
  8. //
  9. ///////////////////////////////////////////////////////////////////////////////
  10. #include "Precompiled.h"
  11. #include "dbnode.h"
  12. #include "dbpage.h"
  13. #include "dbconfig.h"
  14. #include "logcomp.h"
  15. #include "logcompd.h"
  16. #include "snapinnode.cpp"
  17. DatabaseNode::DatabaseNode(CSnapInItem* parent)
  18. : LoggingMethod(IAS_PROVIDER_MICROSOFT_DB_ACCT, parent)
  19. {
  20. wchar_t buffer[IAS_MAX_STRING];
  21. if (LoadString(
  22. _Module.GetResourceInstance(),
  23. IDS_DB_NODE_NAME,
  24. buffer,
  25. IAS_MAX_STRING
  26. ) > 0)
  27. {
  28. nodeName = buffer;
  29. }
  30. if (LoadString(
  31. _Module.GetResourceInstance(),
  32. IDS_DB_NOT_CONFIGURED,
  33. buffer,
  34. IAS_MAX_STRING
  35. ) > 0)
  36. {
  37. notConfigured = buffer;
  38. }
  39. m_resultDataItem.nImage = IDBI_NODE_LOCAL_FILE_LOGGING;
  40. }
  41. DatabaseNode::~DatabaseNode() throw ()
  42. {
  43. }
  44. HRESULT DatabaseNode::LoadCachedInfoFromSdo() throw ()
  45. {
  46. // Clear the old info.
  47. initString.Empty();
  48. dataSourceName.Empty();
  49. // Load the new info.
  50. HRESULT hr = IASLoadDatabaseConfig(
  51. GetServerName(),
  52. &initString,
  53. &dataSourceName
  54. );
  55. if (FAILED(hr))
  56. {
  57. ShowErrorDialog(
  58. 0,
  59. IDS_DB_E_CANT_READ_DB_CONFIG,
  60. 0,
  61. hr,
  62. IDS_DB_E_TITLE,
  63. GetComponentData()->m_spConsole
  64. );
  65. }
  66. return hr;
  67. }
  68. const wchar_t* DatabaseNode::GetServerName() const throw ()
  69. {
  70. return Parent()->GetServerRoot()->m_bstrServerAddress;
  71. }
  72. LPOLESTR DatabaseNode::GetResultPaneColInfo(int nCol)
  73. {
  74. LPOLESTR info = L"";
  75. switch (nCol)
  76. {
  77. case 0:
  78. {
  79. if (nodeName)
  80. {
  81. info = nodeName;
  82. }
  83. break;
  84. }
  85. case 1:
  86. {
  87. if (dataSourceName)
  88. {
  89. info = dataSourceName;
  90. }
  91. else if (notConfigured)
  92. {
  93. info = notConfigured;
  94. }
  95. break;
  96. }
  97. default:
  98. {
  99. break;
  100. }
  101. }
  102. return info;
  103. }
  104. HRESULT DatabaseNode::OnPropertyChange(
  105. LPARAM arg,
  106. LPARAM param,
  107. IComponentData* pComponentData,
  108. IComponent* pComponent,
  109. DATA_OBJECT_TYPES type
  110. )
  111. {
  112. return LoadCachedInfoFromSdo();
  113. }
  114. HRESULT DatabaseNode::SetVerbs(IConsoleVerb* pConsoleVerb)
  115. {
  116. HRESULT hr = pConsoleVerb->SetVerbState(MMC_VERB_PROPERTIES, ENABLED, TRUE);
  117. if (SUCCEEDED(hr))
  118. {
  119. hr = pConsoleVerb->SetDefaultVerb(MMC_VERB_PROPERTIES);
  120. }
  121. return hr;
  122. }
  123. STDMETHODIMP DatabaseNode::CreatePropertyPages(
  124. LPPROPERTYSHEETCALLBACK lpProvider,
  125. LONG_PTR handle,
  126. IUnknown* pUnk,
  127. DATA_OBJECT_TYPES type
  128. )
  129. {
  130. DatabasePage* page = new (std::nothrow) DatabasePage(handle, 0, this);
  131. if (page == 0)
  132. {
  133. return E_OUTOFMEMORY;
  134. }
  135. HRESULT hr = page->Initialize(configSdo, controlSdo);
  136. if (SUCCEEDED(hr))
  137. {
  138. hr = lpProvider->AddPage(page->Create());
  139. }
  140. if (FAILED(hr))
  141. {
  142. ShowErrorDialog(
  143. 0,
  144. IDS_DB_E_CANT_INIT_DIALOG,
  145. 0,
  146. hr,
  147. IDS_DB_E_TITLE,
  148. GetComponentData()->m_spConsole
  149. );
  150. delete page;
  151. }
  152. return hr;
  153. }
  154. STDMETHODIMP DatabaseNode::QueryPagesFor(DATA_OBJECT_TYPES type)
  155. {
  156. return S_OK;
  157. }