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.

362 lines
8.7 KiB

  1. #ifdef _DEBUG
  2. #define new DEBUG_NEW
  3. #endif
  4. /////////////////////////////////////////////////////////////////////////////
  5. // Clipboard Operations
  6. /////////////////////////////////////////////////////////////////////////////
  7. inline bool CSystemGroup::Cut()
  8. {
  9. TRACEX(_T("CSystemGroup::Cut\n"));
  10. return false;
  11. }
  12. inline bool CSystemGroup::Copy()
  13. {
  14. TRACEX(_T("CSystemGroup::Copy\n"));
  15. return false;
  16. }
  17. inline bool CSystemGroup::Paste()
  18. {
  19. TRACEX(_T("CSystemGroup::Paste\n"));
  20. return false;
  21. }
  22. /////////////////////////////////////////////////////////////////////////////
  23. // Operations
  24. /////////////////////////////////////////////////////////////////////////////
  25. inline bool CSystemGroup::Refresh()
  26. {
  27. TRACEX(_T("CSystemGroup::Refresh\n"));
  28. return false;
  29. }
  30. inline bool CSystemGroup::ResetStatus()
  31. {
  32. TRACEX(_T("CSystemGroup::ResetStatus\n"));
  33. return false;
  34. }
  35. inline CString CSystemGroup::GetUITypeName()
  36. {
  37. TRACEX(_T("CSystemGroup::GetUITypeName\n"));
  38. CString sTypeName;
  39. sTypeName.LoadString(IDS_STRING_SYSTEM_GROUP);
  40. return sTypeName;
  41. }
  42. inline void CSystemGroup::Serialize(CArchive& ar)
  43. {
  44. TRACEX(_T("CSystemGroup::Serialize\n"));
  45. CHMObject::Serialize(ar);
  46. if( ar.IsStoring() )
  47. {
  48. // write out the list of child groups
  49. ar << GetChildCount();
  50. for( int i = 0; i < GetChildCount(); i++ )
  51. {
  52. GetChild(i)->Serialize(ar);
  53. }
  54. // write out the list of shortcuts
  55. ar << (int)m_Shortcuts.GetSize();
  56. for( i = 0; i < m_Shortcuts.GetSize(); i++ )
  57. {
  58. m_Shortcuts[i]->Serialize(ar);
  59. }
  60. }
  61. else
  62. {
  63. // update the scope items to reflect their correct name
  64. for(int i = 0; i < m_ScopeItems.GetSize(); i++)
  65. {
  66. m_ScopeItems[i]->SetDisplayName(0,m_sName);
  67. m_ScopeItems[i]->SetItem();
  68. }
  69. int iChildCount = 0;
  70. ar >> iChildCount;
  71. for( i = 0; i < iChildCount; i++ )
  72. {
  73. CSystemGroup* pNewGroup = new CSystemGroup;
  74. pNewGroup->SetScopePane(GetScopePane());
  75. pNewGroup->SetName(GetUniqueChildName());
  76. AddChild(pNewGroup);
  77. pNewGroup->Serialize(ar);
  78. }
  79. int iShortcutCount = 0;
  80. ar >> iShortcutCount;
  81. CHealthmonScopePane* pPane = (CHealthmonScopePane*)GetScopePane();
  82. CSystemGroup* pASG = pPane->GetAllSystemsGroup();
  83. for( i = 0; i < iShortcutCount; i++ )
  84. {
  85. CString sName;
  86. CString sSystemName;
  87. ar >> sName;
  88. ar >> sSystemName;
  89. AddShortcut(pASG->GetChild(sName));
  90. }
  91. }
  92. }
  93. inline void CAllSystemsGroup::Serialize(CArchive& ar)
  94. {
  95. TRACEX(_T("CAllSystemsGroup::Serialize\n"));
  96. CHMObject::Serialize(ar);
  97. if( ar.IsStoring() )
  98. {
  99. // write out the list of child groups
  100. ar << GetChildCount();
  101. for( int i = 0; i < GetChildCount(); i++ )
  102. {
  103. GetChild(i)->Serialize(ar);
  104. }
  105. }
  106. else
  107. {
  108. int iChildCount = 0;
  109. ar >> iChildCount;
  110. for( int i = 0; i < iChildCount; i++ )
  111. {
  112. CSystem* pNewSystem = new CSystem;
  113. pNewSystem->Serialize(ar);
  114. //----------------------------------------------
  115. // v-marfin 62501 - check to see if successful
  116. /*CString sFailed = pNewSystem->GetSystemName();
  117. if (sFailed.Right(FAILED_STRING.GetLength()) == FAILED_STRING)
  118. {
  119. sFailed = sFailed.Left(sFailed.GetLength() - FAILED_STRING.GetLength());
  120. pNewSystem->SetSystemName(sFailed);
  121. delete pNewSystem;
  122. continue;
  123. }*/
  124. BOOL bFailed=FALSE;
  125. // v-marfin 62501 - check to see if successful
  126. CString sFailed = pNewSystem->GetSystemName();
  127. if (sFailed.Right(FAILED_STRING.GetLength()) == FAILED_STRING)
  128. {
  129. sFailed = sFailed.Left(sFailed.GetLength() - FAILED_STRING.GetLength());
  130. pNewSystem->SetSystemName(sFailed);
  131. bFailed=TRUE;
  132. CString sMsg;
  133. sMsg.Format(IDS_STRING_TRANSPORT_ERROR,sFailed);
  134. AfxMessageBox(sMsg);
  135. }
  136. //----------------------------------------------
  137. //----------------------------------------------
  138. // v-marfin 62501 - check to see if successful.
  139. // When unable to connect to a system, do not even show
  140. // its icon in the tree. We have to do this hack in the BETA
  141. // time frame since there are too many other implications of
  142. // having the icon appear
  143. // in the list (i.e. if the user tries to add groups to it, it
  144. // causes crashes etc.) We should deal with this in the RTM
  145. // time frame however. So for now, place the code here and
  146. // at final fix time, see the code which is commented out below
  147. // and use that instead of this.
  148. if (bFailed)
  149. {
  150. delete pNewSystem;
  151. continue;
  152. }
  153. //----------------------------------------------
  154. pNewSystem->SetScopePane(GetScopePane());
  155. AddChild(pNewSystem);
  156. //----------------------------------------------
  157. // v-marfin 62501 - check to see if successful.
  158. // When unable to connect to a system, at least show its
  159. // icon so the user sees that it is inaccessible. We
  160. // comment out this code for BETA time frame since there
  161. // are too many other implications of having the icon appear
  162. // in the list (i.e. if the user tries to add groups to it, it
  163. // causes crashes etc.) We should deal with this in the RTM
  164. // time frame however. So for now, the code to check the
  165. // success of connecting will be placed just above here.
  166. /*if (bFailed)
  167. {
  168. delete pNewSystem;
  169. continue;
  170. }*/
  171. //----------------------------------------------
  172. pNewSystem->Connect();
  173. CActionPolicy* pPolicy = new CActionPolicy;
  174. pPolicy->SetSystemName(pNewSystem->GetName());
  175. pNewSystem->AddChild(pPolicy);
  176. }
  177. }
  178. }
  179. /////////////////////////////////////////////////////////////////////////////
  180. // State Members
  181. /////////////////////////////////////////////////////////////////////////////
  182. inline void CSystemGroup::TallyChildStates()
  183. {
  184. TRACEX(_T("CSystemGroup::TallyChildStates\n"));
  185. m_lNormalCount = 0L;
  186. m_lWarningCount = 0L;
  187. m_lCriticalCount = 0L;
  188. m_lUnknownCount = 0L;
  189. for( int i = 0; i < m_Children.GetSize(); i++ )
  190. {
  191. switch( m_Children[i]->GetState() )
  192. {
  193. case HMS_NORMAL:
  194. {
  195. m_lNormalCount++;
  196. }
  197. break;
  198. case HMS_WARNING:
  199. {
  200. m_lWarningCount++;
  201. }
  202. break;
  203. case HMS_CRITICAL:
  204. {
  205. m_lCriticalCount++;
  206. }
  207. break;
  208. case HMS_UNKNOWN:
  209. {
  210. m_lUnknownCount++;
  211. }
  212. break;
  213. }
  214. }
  215. for( i = 0; i < m_Shortcuts.GetSize(); i++ )
  216. {
  217. switch( m_Shortcuts[i]->GetState() )
  218. {
  219. case HMS_NORMAL:
  220. {
  221. m_lNormalCount++;
  222. }
  223. break;
  224. case HMS_WARNING:
  225. {
  226. m_lWarningCount++;
  227. }
  228. break;
  229. case HMS_CRITICAL:
  230. {
  231. m_lCriticalCount++;
  232. }
  233. break;
  234. case HMS_UNKNOWN:
  235. {
  236. m_lUnknownCount++;
  237. }
  238. break;
  239. }
  240. }
  241. }
  242. /////////////////////////////////////////////////////////////////////////////
  243. // Scope Item Members
  244. /////////////////////////////////////////////////////////////////////////////
  245. inline CScopePaneItem* CSystemGroup::CreateScopeItem()
  246. {
  247. TRACEX(_T("CSystemGroup::CreateScopeItem\n"));
  248. CSystemGroupScopeItem * pNewItem = new CSystemGroupScopeItem;
  249. pNewItem->SetObjectPtr(this);
  250. return pNewItem;
  251. }
  252. /////////////////////////////////////////////////////////////////////////////
  253. // Scope Item Members
  254. /////////////////////////////////////////////////////////////////////////////
  255. inline CScopePaneItem* CAllSystemsGroup::CreateScopeItem()
  256. {
  257. TRACEX(_T("CAllSystemsGroup::CreateScopeItem\n"));
  258. CAllSystemsScopeItem * pNewItem = new CAllSystemsScopeItem;
  259. pNewItem->SetObjectPtr(this);
  260. return pNewItem;
  261. }
  262. /////////////////////////////////////////////////////////////////////////////
  263. // New Child Creation Members
  264. /////////////////////////////////////////////////////////////////////////////
  265. inline void CSystemGroup::CreateNewChildSystemGroup()
  266. {
  267. TRACEX(_T("CSystemGroup::CreateNewChildSystemGroup\n"));
  268. CString sName = GetUniqueChildName(IDS_STRING_SYSTEMGROUP_FMT);
  269. CSystemGroup* pNewGroup = new CSystemGroup;
  270. pNewGroup->SetName(sName);
  271. CHMObject::AddChild(pNewGroup);
  272. if( pNewGroup->GetScopeItemCount() )
  273. {
  274. CScopePaneItem* pItem = pNewGroup->GetScopeItem(0);
  275. if( pItem )
  276. {
  277. pItem->SelectItem();
  278. pItem->InvokePropertySheet();
  279. }
  280. }
  281. }
  282. /////////////////////////////////////////////////////////////////////////////
  283. // System Child Members
  284. /////////////////////////////////////////////////////////////////////////////
  285. inline CHMObject* CSystemGroup::GetShortcut(const CString& sName)
  286. {
  287. TRACEX(_T("CSystemGroup::GetShortcut\n"));
  288. for( int i = 0; i < m_Shortcuts.GetSize(); i++ )
  289. {
  290. if( m_Shortcuts[i]->GetName().CompareNoCase(sName) == 0 )
  291. {
  292. return m_Shortcuts[i];
  293. }
  294. }
  295. return NULL;
  296. }