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.

141 lines
4.9 KiB

  1. #ifndef __SERVERLIST_HPP__
  2. #define __SERVERLIST_HPP__
  3. /*---------------------------------------------------------------------------
  4. File: ...
  5. Comments: ...
  6. (c) Copyright 1999, Mission Critical Software, Inc., All Rights Reserved
  7. Proprietary and confidential to Mission Critical Software, Inc.
  8. REVISION LOG ENTRY
  9. Revision By: Christy Boles
  10. Revised on 03/04/99 17:10:38
  11. ---------------------------------------------------------------------------
  12. */
  13. //#import "\bin\MCSEADCTAgent.tlb" no_namespace, named_guids
  14. #import "Engine.tlb" no_namespace, named_guids
  15. #include "Common.hpp"
  16. #include "UString.hpp"
  17. #include "TNode.hpp"
  18. #define Agent_Status_Unknown (0x00000000)
  19. #define Agent_Status_Installed (0x00000001)
  20. #define Agent_Status_Started (0x00000002)
  21. #define Agent_Status_Finished (0x00000004)
  22. #define Agent_Status_Failed (0x80000000)
  23. #define Agent_Status_QueryFailed (0x40000000)
  24. class TServerNode : public TNode
  25. {
  26. BOOL bInclude;
  27. WCHAR guid[100];
  28. WCHAR serverName[100];
  29. WCHAR resultpath[MAX_PATH];
  30. WCHAR jobpath[MAX_PATH];
  31. WCHAR logpath[MAX_PATH];
  32. WCHAR timestamp[30];
  33. IDCTAgent * pAgent;
  34. int errSeverity;
  35. DWORD status;
  36. WCHAR errMsg[500];
  37. int listNdx;
  38. public:
  39. TServerNode(WCHAR const * server)
  40. {
  41. safecopy(serverName,server);
  42. guid[0] = 0;
  43. pAgent = NULL;
  44. errSeverity = 0;
  45. errMsg[0] = 0;
  46. timestamp[0] = 0;
  47. resultpath[0] = 0;
  48. jobpath[0] = 0;
  49. logpath[0] = 0;
  50. bInclude = FALSE;
  51. status = 0;
  52. listNdx = -1;
  53. }
  54. ~TServerNode()
  55. {
  56. if ( pAgent )
  57. pAgent->Release();
  58. }
  59. WCHAR * GetServer() { return serverName; }
  60. WCHAR * GetJobID() { return guid; }
  61. WCHAR * GetMessageText() { return errMsg; }
  62. int GetSeverity() { return errSeverity; }
  63. IDCTAgent * GetInterface() { return pAgent; }
  64. WCHAR * GetTimeStamp() { return timestamp; }
  65. WCHAR * GetJobFile() { return resultpath; }
  66. WCHAR * GetJobPath() { return jobpath; }
  67. WCHAR * GetLogPath() { return logpath; }
  68. BOOL Include() { return bInclude; }
  69. DWORD GetStatus() { return status; }
  70. BOOL IsInstalled() { return status & Agent_Status_Installed; }
  71. BOOL IsStarted() { return status & Agent_Status_Started; }
  72. BOOL IsFinished() { return status & Agent_Status_Finished; }
  73. BOOL IsRunning() { return ( (status & Agent_Status_Started) && !(status & (Agent_Status_Finished|Agent_Status_Failed))); }
  74. BOOL HasFailed() { return status & Agent_Status_Failed; }
  75. BOOL QueryFailed() { return status & Agent_Status_QueryFailed; }
  76. void SetJobID(WCHAR const * id) { safecopy(guid,id); }
  77. void SetSeverity(int s) { if ( s > errSeverity ) errSeverity = s; }
  78. void SetInterface(IDCTAgent* p) { if ( p ) p->AddRef(); pAgent = p; }
  79. void SetMessageText(WCHAR const * txt) { safecopy(errMsg,txt); }
  80. void SetTimeStamp(WCHAR const * t) { safecopy(timestamp,t); }
  81. void SetJobFile(WCHAR const * filename) { safecopy(resultpath,filename); }
  82. void SetJobPath(WCHAR const * filename) { safecopy(jobpath,filename); safecopy(resultpath,filename); }
  83. void SetLogPath(WCHAR const * filename) { safecopy(logpath,filename); }
  84. void SetIncluded(BOOL v) { bInclude = v; }
  85. void SetStatus(DWORD val) { status = val; }
  86. void SetInstalled() { status |= Agent_Status_Installed; }
  87. void SetStarted() { status |= Agent_Status_Started; }
  88. void SetFinished() { status |= Agent_Status_Finished; }
  89. void SetFailed() { status |= Agent_Status_Failed; }
  90. void SetQueryFailed() { status |= Agent_Status_QueryFailed; }
  91. };
  92. int static CompareNames(TNode const * t1, TNode const * t2)
  93. {
  94. TServerNode * server1 = (TServerNode*)t1;
  95. TServerNode * server2 = (TServerNode*)t2;
  96. WCHAR * name1 = server1->GetServer();
  97. WCHAR * name2 = server2->GetServer();
  98. return UStrICmp(name1,name2);
  99. }
  100. int static CompareVal(TNode const * t, void const * v)
  101. {
  102. TServerNode * server = (TServerNode*)t;
  103. WCHAR * name1 = server->GetServer();
  104. WCHAR * name2 = (WCHAR*)v;
  105. return UStrICmp(name1,name2);
  106. }
  107. class TServerList : public TNodeListSortable
  108. {
  109. public:
  110. TServerList()
  111. {
  112. TypeSetSorted();
  113. CompareSet(&CompareNames);
  114. }
  115. ~TServerList()
  116. {
  117. DeleteAllListItems(TServerNode);
  118. }
  119. void Clear() { DeleteAllListItems(TServerNode); }
  120. TServerNode * FindServer(WCHAR const * serverName) { return (TServerNode*)Find(&CompareVal,(void*)serverName); }
  121. TServerNode * AddServer(WCHAR const * serverName) { TServerNode * p = new TServerNode(serverName); Insert(p); return p; }
  122. };
  123. #endif //__SERVERLIST_HPP__