Source code of Windows XP (NT5)
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.

235 lines
5.7 KiB

  1. /////////////////////////////////////////////////////////////////////////////
  2. //
  3. // Copyright (c) 1996-1999 Microsoft Corporation
  4. //
  5. // Module Name:
  6. // Notify.cpp
  7. //
  8. // Abstract:
  9. // Implementation of the notification classes.
  10. //
  11. // Author:
  12. // David Potter (davidp) Septemper 26, 1996
  13. //
  14. // Revision History:
  15. //
  16. // Notes:
  17. //
  18. /////////////////////////////////////////////////////////////////////////////
  19. #include "stdafx.h"
  20. #include "Notify.h"
  21. #include "ClusDoc.h"
  22. #include "ClusItem.h"
  23. #ifdef _DEBUG
  24. #define new DEBUG_NEW
  25. #undef THIS_FILE
  26. static char THIS_FILE[] = __FILE__;
  27. #endif
  28. /////////////////////////////////////////////////////////////////////////////
  29. // CNotifyKey
  30. /////////////////////////////////////////////////////////////////////////////
  31. /////////////////////////////////////////////////////////////////////////////
  32. //++
  33. //
  34. // CClusterNotifyKey::CClusterNotifyKey
  35. //
  36. // Routine Description:
  37. // Cluster notification key constructor for documents.
  38. //
  39. // Arguments:
  40. // pdoc Pointer to the document.
  41. //
  42. // Return Value:
  43. // None.
  44. //
  45. //--
  46. /////////////////////////////////////////////////////////////////////////////
  47. CClusterNotifyKey::CClusterNotifyKey(
  48. IN CClusterDoc * pdoc
  49. )
  50. {
  51. ASSERT_VALID(pdoc);
  52. m_cnkt = cnktDoc;
  53. m_pdoc = pdoc;
  54. } //*** CClusterNotifyKey::CClusterNotifyKey(CClusterDoc*)
  55. /////////////////////////////////////////////////////////////////////////////
  56. //++
  57. //
  58. // CClusterNotifyKey::CClusterNotifyKey
  59. //
  60. // Routine Description:
  61. // Cluster notification key constructor.
  62. //
  63. // Arguments:
  64. // pci Pointer to the cluster item.
  65. // lpszName Name of the object.
  66. //
  67. // Return Value:
  68. // None.
  69. //
  70. //--
  71. /////////////////////////////////////////////////////////////////////////////
  72. CClusterNotifyKey::CClusterNotifyKey(
  73. IN CClusterItem * pci,
  74. IN LPCTSTR lpszName
  75. )
  76. {
  77. ASSERT_VALID(pci);
  78. ASSERT(lpszName != NULL);
  79. ASSERT(*lpszName != _T('\0'));
  80. m_cnkt = cnktClusterItem;
  81. m_pci = pci;
  82. try
  83. {
  84. m_strName = lpszName;
  85. }
  86. catch (...)
  87. {
  88. } // catch: anything
  89. } //*** CClusterNotifyKey::CClusterNotifyKey(CClusterItem*)
  90. //*************************************************************************//
  91. /////////////////////////////////////////////////////////////////////////////
  92. // Global Functions
  93. /////////////////////////////////////////////////////////////////////////////
  94. #ifdef _DEBUG
  95. /////////////////////////////////////////////////////////////////////////////
  96. //++
  97. //
  98. // PszNotificationName
  99. //
  100. // Routine Description:
  101. // Get the name of a notification.
  102. //
  103. // Arguments:
  104. // dwNotification [IN] Notification whose name is to be returned.
  105. //
  106. // Return Value:
  107. // Name of the notificaiton.
  108. //
  109. //--
  110. /////////////////////////////////////////////////////////////////////////////
  111. LPCTSTR PszNotificationName(IN DWORD dwNotification)
  112. {
  113. switch (dwNotification)
  114. {
  115. case CLUSTER_CHANGE_NODE_STATE:
  116. return _T("NODE_STATE");
  117. case CLUSTER_CHANGE_NODE_DELETED:
  118. return _T("NODE_DELETED");
  119. case CLUSTER_CHANGE_NODE_ADDED:
  120. return _T("NODE_ADDED");
  121. case CLUSTER_CHANGE_NODE_PROPERTY:
  122. return _T("NODE_PROPERTY");
  123. case CLUSTER_CHANGE_REGISTRY_NAME:
  124. return _T("REGISTRY_NAME");
  125. case CLUSTER_CHANGE_REGISTRY_ATTRIBUTES:
  126. return _T("REGISTRY_ATTRIBUTES");
  127. case CLUSTER_CHANGE_REGISTRY_VALUE:
  128. return _T("REGISTRY_VALUE");
  129. case CLUSTER_CHANGE_REGISTRY_SUBTREE:
  130. return _T("REGISTRY_SUBTREE");
  131. case CLUSTER_CHANGE_RESOURCE_STATE:
  132. return _T("RESOURCE_STATE");
  133. case CLUSTER_CHANGE_RESOURCE_DELETED:
  134. return _T("RESOURCE_DELETED");
  135. case CLUSTER_CHANGE_RESOURCE_ADDED:
  136. return _T("RESOURCE_ADDED");
  137. case CLUSTER_CHANGE_RESOURCE_PROPERTY:
  138. return _T("RESOURCE_PROPERTY");
  139. case CLUSTER_CHANGE_GROUP_STATE:
  140. return _T("GROUP_STATE");
  141. case CLUSTER_CHANGE_GROUP_DELETED:
  142. return _T("GROUP_DELETED");
  143. case CLUSTER_CHANGE_GROUP_ADDED:
  144. return _T("GROUP_ADDED");
  145. case CLUSTER_CHANGE_GROUP_PROPERTY:
  146. return _T("GROUP_PROPERTY");
  147. case CLUSTER_CHANGE_RESOURCE_TYPE_DELETED:
  148. return _T("RESOURCE_TYPE_DELETED");
  149. case CLUSTER_CHANGE_RESOURCE_TYPE_ADDED:
  150. return _T("RESOURCE_TYPE_ADDED");
  151. case CLUSTER_CHANGE_RESOURCE_TYPE_PROPERTY:
  152. return _T("RESOURCE_TYPE_PROPERTY");
  153. case CLUSTER_CHANGE_NETWORK_STATE:
  154. return _T("NETWORK_STATE");
  155. case CLUSTER_CHANGE_NETWORK_DELETED:
  156. return _T("NETWORK_DELETED");
  157. case CLUSTER_CHANGE_NETWORK_ADDED:
  158. return _T("NETWORK_ADDED");
  159. case CLUSTER_CHANGE_NETWORK_PROPERTY:
  160. return _T("NETWORK_PROPERTY");
  161. case CLUSTER_CHANGE_NETINTERFACE_STATE:
  162. return _T("NETINTERFACE_STATE");
  163. case CLUSTER_CHANGE_NETINTERFACE_DELETED:
  164. return _T("NETINTERFACE_DELETED");
  165. case CLUSTER_CHANGE_NETINTERFACE_ADDED:
  166. return _T("NETINTERFACE_ADDED");
  167. case CLUSTER_CHANGE_NETINTERFACE_PROPERTY:
  168. return _T("NETINTERFACE_PROPERTY");
  169. case CLUSTER_CHANGE_QUORUM_STATE:
  170. return _T("QUORUM_STATE");
  171. case CLUSTER_CHANGE_CLUSTER_STATE:
  172. return _T("CLUSTER_STATE");
  173. case CLUSTER_CHANGE_CLUSTER_PROPERTY:
  174. return _T("CLUSTER_PROPERTY");
  175. default:
  176. return _T("<UNKNOWN>");
  177. } // switch: dwNotification
  178. } //*** PszNotificationName()
  179. #endif // _DEBUG
  180. /////////////////////////////////////////////////////////////////////////////
  181. //++
  182. //
  183. // DeleteAllItemData
  184. //
  185. // Routine Description:
  186. // Deletes all item data in a CList.
  187. //
  188. // Arguments:
  189. // rlp [IN OUT] List whose data is to be deleted.
  190. //
  191. // Return Value:
  192. // None.
  193. //
  194. //--
  195. /////////////////////////////////////////////////////////////////////////////
  196. void DeleteAllItemData(IN OUT CClusterNotifyList & rlp)
  197. {
  198. POSITION pos;
  199. CClusterNotify * pcn;
  200. // Delete all the items in the Contained list.
  201. pos = rlp.GetHeadPosition();
  202. while (pos != NULL)
  203. {
  204. pcn = rlp.GetNext(pos);
  205. ASSERT(pcn != NULL);
  206. delete pcn;
  207. } // while: more items in the list
  208. } //*** DeleteAllItemData()