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.

211 lines
8.5 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. // these completion statuses are arranged in an order by which you
  25. // want to present them in the migration log
  26. #define Completion_Status_Completed 0
  27. #define Completion_Status_CompletedWithWarnings 1
  28. #define Completion_Status_CompletedWithErrors 2
  29. #define Completion_Status_Running 3
  30. #define Completion_Status_StatusUnknown 4
  31. #define Completion_Status_DidNotStart 5
  32. #define Completion_Status_Installed 6
  33. #define Completion_Status_InstallFailed 7
  34. #define Completion_Status_Installing 8
  35. class TServerNode : public TNode
  36. {
  37. BOOL bInclude;
  38. WCHAR guid[100];
  39. WCHAR serverName[MAX_PATH];
  40. WCHAR remoteResultPath[MAX_PATH];
  41. BOOL bResultPullingTried;
  42. BOOL bHasResult;
  43. BOOL bResultProcessed;
  44. BOOL bAccountReferenceResultExpected;
  45. BOOL bJoinDomainWithRename;
  46. BOOL bHasQueriedStatusFromFile;
  47. WCHAR resultpath[MAX_PATH];
  48. WCHAR jobpath[MAX_PATH];
  49. WCHAR logpath[MAX_PATH];
  50. BOOL isLogPathValid;
  51. WCHAR timestamp[30];
  52. IDCTAgent * pAgent;
  53. int errSeverity;
  54. DWORD status;
  55. WCHAR errMsg[500];
  56. int listNdx;
  57. BOOL bOutOfResourceToMonitor;
  58. BOOL bMonitoringTried;
  59. BOOL bDoneMonitoring;
  60. // several member variables related to the logging of the agent completion status
  61. _bstr_t bstrStatusForLogging;
  62. _bstr_t bstrErrorMessageForLogging;
  63. DWORD dwStatusForLogging;
  64. public:
  65. TServerNode(WCHAR const * server)
  66. {
  67. safecopy(serverName,server);
  68. guid[0] = 0;
  69. pAgent = NULL;
  70. errSeverity = 0;
  71. errMsg[0] = 0;
  72. timestamp[0] = 0;
  73. resultpath[0] = 0;
  74. remoteResultPath[0] = 0;
  75. bResultPullingTried = FALSE;
  76. bHasResult = FALSE;
  77. bResultProcessed = FALSE;
  78. bHasQueriedStatusFromFile = FALSE;
  79. jobpath[0] = 0;
  80. logpath[0] = 0;
  81. isLogPathValid = TRUE;
  82. bInclude = FALSE;
  83. status = 0;
  84. listNdx = -1;
  85. bOutOfResourceToMonitor = FALSE;
  86. bMonitoringTried = FALSE;
  87. bDoneMonitoring = FALSE;
  88. dwStatusForLogging = Completion_Status_Installing;
  89. }
  90. ~TServerNode()
  91. {
  92. if ( pAgent )
  93. pAgent->Release();
  94. }
  95. WCHAR * GetServer() { return serverName; }
  96. WCHAR * GetJobID() { return guid; }
  97. WCHAR * GetMessageText() { return errMsg; }
  98. int GetSeverity() { return errSeverity; }
  99. IDCTAgent * GetInterface() { return pAgent; }
  100. WCHAR * GetTimeStamp() { return timestamp; }
  101. WCHAR * GetJobFile() { return resultpath; }
  102. WCHAR * GetJobPath() { return jobpath; }
  103. WCHAR * GetLogPath() { return logpath; }
  104. BOOL GetLogPathValid() { return isLogPathValid; }
  105. WCHAR * GetRemoteResultPath() { return remoteResultPath; }
  106. BOOL Include() { return bInclude; }
  107. DWORD GetStatus() { return status; }
  108. BOOL IsInstalled() { return status & Agent_Status_Installed; }
  109. BOOL IsStarted() { return status & Agent_Status_Started; }
  110. BOOL IsFinished() { return status & Agent_Status_Finished; }
  111. BOOL IsRunning() { return ( (status & Agent_Status_Started) && !(status & (Agent_Status_Finished|Agent_Status_Failed))); }
  112. BOOL HasFailed() { return status & Agent_Status_Failed; }
  113. BOOL QueryFailed() { return status & Agent_Status_QueryFailed; }
  114. void SetJobID(WCHAR const * id) { safecopy(guid,id); }
  115. void SetSeverity(int s) { if ( s > errSeverity ) errSeverity = s; }
  116. void SetInterface(IDCTAgent* p) { if ( p ) p->AddRef(); pAgent = p; }
  117. void SetMessageText(WCHAR const * txt) { safecopy(errMsg,txt); }
  118. void SetTimeStamp(WCHAR const * t) { safecopy(timestamp,t); }
  119. void SetJobFile(WCHAR const * filename) { safecopy(resultpath,filename); }
  120. void SetJobPath(WCHAR const * filename) { safecopy(jobpath,filename); safecopy(resultpath,filename); }
  121. void SetLogPath(WCHAR const * filename) { safecopy(logpath,filename); }
  122. void SetLogPathValid(BOOL bValid) { isLogPathValid = bValid; }
  123. void SetRemoteResultPath(WCHAR const * filename) { safecopy(remoteResultPath, filename); }
  124. void SetIncluded(BOOL v) { bInclude = v; }
  125. void SetStatus(DWORD val) { status = val; }
  126. void SetInstalled() { status |= Agent_Status_Installed; }
  127. void SetStarted() { status |= Agent_Status_Started; }
  128. void SetFinished() { status |= Agent_Status_Finished; }
  129. void SetFailed() { status |= Agent_Status_Failed; }
  130. void SetQueryFailed(BOOL bVal) { (bVal) ? status |= Agent_Status_QueryFailed : status &= ~Agent_Status_QueryFailed; }
  131. void SetResultPullingTried(BOOL bTried) { bResultPullingTried = bTried; }
  132. BOOL IsResultPullingTried() { return bResultPullingTried; }
  133. void SetHasResult(BOOL bResult) { bHasResult = bResult; }
  134. BOOL HasResult() { return bHasResult; }
  135. void SetResultProcessed(BOOL bIsProcessed) { bResultProcessed = bIsProcessed; }
  136. BOOL IsResultProcessed() { return bResultProcessed; }
  137. void SetAccountReferenceResultExpected(BOOL isExpected) { bAccountReferenceResultExpected = isExpected; }
  138. BOOL IsAccountReferenceResultExpected() { return bAccountReferenceResultExpected; }
  139. void SetJoinDomainWithRename(BOOL bValue) { bJoinDomainWithRename = bValue; }
  140. BOOL IsJoinDomainWithRename() { return bJoinDomainWithRename; }
  141. void SetOutOfResourceToMonitor(BOOL bOutOfResource) { bOutOfResourceToMonitor = bOutOfResource; }
  142. BOOL IsOutOfResourceToMonitor() { return bOutOfResourceToMonitor; }
  143. void SetMonitoringTried(BOOL bValue) { bMonitoringTried = bValue; }
  144. BOOL IsMonitoringTried() { return bMonitoringTried; }
  145. void SetDoneMonitoring(BOOL bValue) { bDoneMonitoring = bValue; }
  146. BOOL IsDoneMonitoring() { return bDoneMonitoring; }
  147. void QueryStatusFromFile(WCHAR* statusFilename);
  148. void QueryStatusFromFile();
  149. void PrepareForLogging();
  150. WCHAR* GetStatusForLogging() { return ((!bstrStatusForLogging) ? L"" : bstrStatusForLogging); }
  151. DWORD GetStatusNumberForLogging() { return dwStatusForLogging; }
  152. WCHAR* GetErrorMessageForLogging() { return ((!bstrErrorMessageForLogging) ? L"" : bstrErrorMessageForLogging); }
  153. };
  154. int static CompareNames(TNode const * t1, TNode const * t2)
  155. {
  156. TServerNode * server1 = (TServerNode*)t1;
  157. TServerNode * server2 = (TServerNode*)t2;
  158. WCHAR * name1 = server1->GetServer();
  159. WCHAR * name2 = server2->GetServer();
  160. return UStrICmp(name1,name2);
  161. }
  162. int static CompareVal(TNode const * t, void const * v)
  163. {
  164. TServerNode * server = (TServerNode*)t;
  165. WCHAR * name1 = server->GetServer();
  166. WCHAR * name2 = (WCHAR*)v;
  167. return UStrICmp(name1,name2);
  168. }
  169. class TServerList : public TNodeListSortable
  170. {
  171. public:
  172. TServerList()
  173. {
  174. TypeSetSorted();
  175. CompareSet(&CompareNames);
  176. }
  177. ~TServerList()
  178. {
  179. DeleteAllListItems(TServerNode);
  180. }
  181. void Clear() { DeleteAllListItems(TServerNode); }
  182. TServerNode * FindServer(WCHAR const * serverName) { return (TServerNode*)Find(&CompareVal,(void*)serverName); }
  183. TServerNode * AddServer(WCHAR const * serverName) { TServerNode * p = new TServerNode(serverName); Insert(p); return p; }
  184. };
  185. #endif //__SERVERLIST_HPP__