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.

250 lines
6.4 KiB

  1. // Copyright (c) 1997-1999 Microsoft Corporation
  2. #ifndef __DATASOURCE__
  3. #define __DATASOURCE__
  4. #include <CHString1.h>
  5. #include "..\common\sshWbemHelpers.h"
  6. #include "ServiceThread.h"
  7. #include <aclui.h>
  8. #include <list>
  9. #define OSTYPE_WIN95 16
  10. #define OSTYPE_WIN98 17
  11. #define OSTYPE_WINNT 18
  12. #define ROOT_ONLY 0
  13. #define HIDE_SOME 1
  14. #define SHOW_ALL 2
  15. #define ARRAYSIZE(a) (sizeof(a)/sizeof(a[0]))
  16. // this structure is saved.
  17. enum NODE_TYPE
  18. {
  19. TYPE_NAMESPACE,
  20. TYPE_STATIC_CLASS,
  21. TYPE_DYNAMIC_CLASS,
  22. TYPE_SCOPE_CLASS,
  23. TYPE_STATIC_INSTANCE,
  24. TYPE_SCOPE_INSTANCE,
  25. };
  26. //struct NSNODE;
  27. struct NSNODE
  28. {
  29. NSNODE()
  30. {
  31. sType = TYPE_NAMESPACE; //For backward Compatibility
  32. nsLoaded = false;
  33. pclsObj = NULL;
  34. objSinkNS = NULL;
  35. objSink = NULL;
  36. ns = NULL;
  37. display = NULL;
  38. fullPath = NULL;
  39. relPath = NULL;
  40. }
  41. LPTSTR display; // single word
  42. LPTSTR fullPath; // whole objpath
  43. LPTSTR relPath;
  44. CWbemServices *ns;
  45. CWbemClassObject *pclsObj;
  46. // IWbemServicesEx *pServicesEx;
  47. IWbemObjectSink *objSinkNS;
  48. IWbemObjectSink *objSink;
  49. bool hideMe;
  50. bool nsLoaded;
  51. NODE_TYPE sType;
  52. CSimpleArray<NSNODE *> children;
  53. };
  54. // for the namespace tree nodes.
  55. typedef struct ITEMEXTRA
  56. {
  57. struct NSNODE *nsNode;
  58. bool loaded;
  59. } ITEMEXTRA;
  60. // INTERFACE NOTES:
  61. // WBEM_S_ACCESS_DENIED = no access to data.
  62. // WBEM_S_FALSE = readonly access.
  63. class DataSource
  64. {
  65. public:
  66. DataSource();
  67. virtual long AddRef(){ return InterlockedIncrement(&m_cRef); };
  68. virtual long Release()
  69. {
  70. long lTemp = InterlockedDecrement(&m_cRef);
  71. if (0 == lTemp) delete this;
  72. return lTemp;
  73. }
  74. private:
  75. virtual ~DataSource();
  76. // property sheet - non-null while page is displayed.
  77. // set during property page initialization in General tab
  78. // cleared when ClosePropSheet is called.
  79. HWND m_hwndPropSheet;
  80. public:
  81. short m_OSType;
  82. // property sheet access
  83. void SetPropSheetHandle(HWND hPropSheet)
  84. { m_hwndPropSheet = hPropSheet; }
  85. void ClosePropSheet();
  86. // connecting.
  87. // NOTE: WBEM_S_DIFFERENT means it changed 'machine'. Refresh your UI.
  88. void SetMachineName(CHString1 &machine);
  89. HRESULT Connect(LOGIN_CREDENTIALS *credentials, HWND notify = 0);
  90. HRESULT Initialize(IWbemServices *pServices);
  91. HRESULT Disconnect(bool clearCredentials = true);
  92. HRESULT Reconnect(void);
  93. bool IsNewConnection(long *sessionID);
  94. bool IsConnected(void) const;
  95. bool IsLocal(void) const;
  96. bool IsAncient(void) const;
  97. LOGIN_CREDENTIALS *GetCredentials(void);
  98. bstr_t GetRootNS(void);
  99. CWbemServices RootSecNS(void) const
  100. {
  101. return m_rootSecNS;
  102. };
  103. ISecurityInformation *GetSI(struct NSNODE *nsNode);
  104. void LoadImageList(HWND hTree);
  105. // load a tree control from NSCache.
  106. HRESULT LoadNode(HWND hTree, HTREEITEM hItem = TVI_ROOT,
  107. int flags = SHOW_ALL);
  108. void DeleteAllNodes(void);
  109. // general tab.
  110. HRESULT GetCPU(CHString1 &cpu);
  111. HRESULT GetOS(CHString1 &os);
  112. HRESULT GetOSVersion(CHString1 &ver);
  113. HRESULT GetServicePackNumber(CHString1 &ServPack);
  114. HRESULT GetBldNbr(CHString1 &bldNbr);
  115. HRESULT GetInstallDir(CHString1 &dir);
  116. HRESULT GetDBDir(CHString1 &dir);
  117. HRESULT GetBackupInterval(UINT &interval);
  118. HRESULT SetBackupInterval(UINT interval);
  119. HRESULT GetLastBackup(CHString1 &time);
  120. // logging tab.
  121. enum LOGSTATUS
  122. {
  123. Disabled = 0,
  124. ErrorsOnly,
  125. Verbose
  126. };
  127. HRESULT GetLoggingStatus(LOGSTATUS &status);
  128. HRESULT SetLoggingStatus(LOGSTATUS status);
  129. HRESULT GetLoggingSize(ULONG &size);
  130. HRESULT SetLoggingSize(ULONG size);
  131. HRESULT GetDBLocation(CHString1 &dir);
  132. HRESULT GetLoggingLocation(CHString1 &dir);
  133. HRESULT SetLoggingLocation(CHString1 dir);
  134. bool CanBrowseFS(void) const;
  135. // advanced tab.
  136. HRESULT GetScriptASPEnabled(bool &enabled);
  137. HRESULT SetScriptASPEnabled(bool &enabled);
  138. HRESULT GetAnonConnections(bool &enabled);
  139. HRESULT SetAnonConnections(bool &enabled);
  140. HRESULT GetScriptDefNS(CHString1 &ns);
  141. HRESULT SetScriptDefNS(LPCTSTR ns);
  142. enum RESTART
  143. {
  144. Dont = 0,
  145. AsNeededByESS,
  146. Always
  147. };
  148. HRESULT GetRestart(RESTART &restart);
  149. HRESULT SetRestart(RESTART restart);
  150. HRESULT PutWMISetting(BOOL refresh);
  151. bool IsValidDir(CHString1 &dir);
  152. bool IsValidFile(LPCTSTR szDir);
  153. WbemServiceThread m_rootThread; // this will be \root.
  154. CHString1 m_whackedMachineName;
  155. CWbemServices m_rootSecNS, m_cimv2NS;
  156. HRESULT m_settingHr, m_securityHr, m_osHr, m_cpuHr;
  157. void InsertNamespaceNode(HWND hTreeWnd,HTREEITEM hItem,struct NSNODE *parent, IWbemClassObject *pclsObj);
  158. void InsertClassNode(HWND hTreeWnd,HTREEITEM hItem,struct NSNODE *parent, IWbemClassObject *pclsObj);
  159. void InsertInstanceNode(HWND hTreeWnd,HTREEITEM hItem,struct NSNODE *parent, IWbemClassObject *pclsObj);
  160. void InsertScopeInstanceNode(HWND hTreeWnd,HTREEITEM hItem,struct NSNODE *parent, IWbemClassObject *pclsObj);
  161. void RemovePlus(HWND hTreeWnd,HTREEITEM hItem);
  162. void CancelAllAsyncCalls();
  163. void ProcessEndEnumAsync(IWbemObjectSink *pSink);
  164. void SetControlHandles(HWND hwndStatic, HWND hwndButton);
  165. void ShowControls(bool bShow = true);
  166. private:
  167. long m_sessionID;
  168. LOGIN_CREDENTIALS m_user;
  169. HWND m_hWndStatic;
  170. HWND m_hWndButton;
  171. typedef std::list<struct ITEMEXTRA*> ASYNCLIST;
  172. ASYNCLIST asyncList;
  173. IUnsecuredApartment* m_pUnsecApp;
  174. HRESULT UpdateOldBuild(void);
  175. bool m_NSSecurity;
  176. CWbemClassObject m_OS, m_cpu, m_winMgmt;
  177. struct NSNODE m_NSCache;
  178. HIMAGELIST m_hImageList;
  179. UINT m_folderIcon, m_earthIcon, m_classIcon, m_instanceIcon,m_scopeInstanceIcon,m_scopeClassIcon;
  180. UINT FolderIcon(void) const { return m_folderIcon;};
  181. UINT EarthIcon(void) const { return m_earthIcon;};
  182. UINT ClassIcon(void) const { return m_classIcon;};
  183. UINT InstanceIcon(void) const { return m_instanceIcon;};
  184. UINT ScopeInstanceIcon(void) const { return m_scopeInstanceIcon;};
  185. UINT ScopeClassIcon(void) const { return m_scopeClassIcon;};
  186. LPTSTR CopyString( LPTSTR pszSrc );
  187. bool MFLNamepace(LPTSTR name);
  188. // load the NSCache from WMI.
  189. HRESULT PopulateCacheNode(HWND hTreeWnd,HTREEITEM hItem,struct ITEMEXTRA *extra);
  190. HRESULT PopulateTreeNode(HWND hTree, HTREEITEM hParentItem,
  191. struct NSNODE *parent,
  192. int flags);
  193. void DeleteNode(NSNODE *node);
  194. HRESULT GetAsyncSinkStub(IWbemObjectSink *pSink, IWbemObjectSink **pStubSink);
  195. private:
  196. long m_cRef;
  197. };
  198. #endif __DATASOURCE__