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.

326 lines
8.8 KiB

  1. /**********************************************************************/
  2. /** Microsoft Windows/NT **/
  3. /** Copyright(c) Microsoft Corporation, 1997 - 1999 **/
  4. /**********************************************************************/
  5. /*
  6. actreg.h
  7. WINS active registrations node information.
  8. FILE HISTORY:
  9. */
  10. #include "loadrecs.h"
  11. #ifndef _ACTREG_H
  12. #define _ACTREG_H
  13. #ifndef _WINSHAND_H
  14. #include "winshand.h"
  15. #endif
  16. #ifndef _WINSDB_H
  17. #include "winsdb.h"
  18. #endif
  19. #ifndef _MULTIP_H
  20. #include "multip.h"
  21. #endif
  22. #ifndef _BUSYDLG_H
  23. #include "..\common\busydlg.h"
  24. #endif
  25. #ifndef _VERIFY_H
  26. #include "verify.h"
  27. #endif
  28. #ifndef _CONFIG_H
  29. #include "config.h"
  30. #endif
  31. typedef struct WinsStrRecord_t
  32. {
  33. int nIndex;
  34. CString strName;
  35. CString strExpiration;
  36. CString strActive;
  37. CString strStatic;
  38. CString strIPAdd;
  39. CString strOwner;
  40. CString strType;
  41. CString strVersion;
  42. } WinsStrRecord;
  43. typedef enum _ACTREG_COL
  44. {
  45. ACTREG_COL_NAME,
  46. ACTREG_COL_TYPE,
  47. ACTREG_COL_IPADDRESS,
  48. ACTREG_COL_STATE,
  49. ACTREG_COL_STATIC,
  50. ACTREG_COL_OWNER,
  51. ACTREG_COL_VERSION,
  52. ACTREG_COL_EXPIRATION,
  53. ACTREG_COL_MAX
  54. };
  55. class CDlgWorkerThread;
  56. typedef CList<WinsStrRecord*,WinsStrRecord*> RecordListBase;
  57. typedef CArray<WINSERVERS, WINSERVERS> WinsServersArray;
  58. class RecordList : public RecordListBase
  59. {
  60. public:
  61. ~RecordList()
  62. {
  63. RemoveAllEntries();
  64. }
  65. WinsStrRecord * FindItem(int nIndex)
  66. {
  67. WinsStrRecord * pRec = NULL;
  68. POSITION pos = GetHeadPosition();
  69. while (pos)
  70. {
  71. WinsStrRecord * pCurRec = GetNext(pos);
  72. if (pCurRec->nIndex == nIndex)
  73. {
  74. pRec = pCurRec;
  75. break;
  76. }
  77. }
  78. return pRec;
  79. }
  80. void RemoveAllEntries()
  81. {
  82. // cleanup the list
  83. while (!IsEmpty())
  84. delete RemoveHead();
  85. }
  86. POSITION AddTail(WinsStrRecord * pwsr)
  87. {
  88. // Sets a maximum size. If we hit this we remove the oldest element.
  89. // this works because we always add to the tail of the list.
  90. if ( GetCount() > 500 )
  91. {
  92. delete RemoveHead();
  93. }
  94. return RecordListBase::AddTail(pwsr);
  95. }
  96. };
  97. class CSortWorker : public CDlgWorkerThread
  98. {
  99. public:
  100. CSortWorker(IWinsDatabase * pCurrentDatabase, int nColumn, DWORD dwSortOptions);
  101. ~CSortWorker();
  102. void OnDoAction();
  103. private:
  104. IWinsDatabase * m_pCurrentDatabase;
  105. int m_nColumn;
  106. DWORD m_dwSortOptions;
  107. };
  108. /*---------------------------------------------------------------------------
  109. Class: CActiveRegistrationsHandler
  110. ---------------------------------------------------------------------------*/
  111. class CActiveRegistrationsHandler : public CMTWinsHandler
  112. {
  113. // Interface
  114. public:
  115. CActiveRegistrationsHandler(ITFSComponentData *pCompData);
  116. ~CActiveRegistrationsHandler();
  117. // base handler functionality we override
  118. OVERRIDE_NodeHandler_HasPropertyPages();
  119. OVERRIDE_NodeHandler_CreatePropertyPages();
  120. OVERRIDE_NodeHandler_DestroyHandler();
  121. OVERRIDE_NodeHandler_OnAddMenuItems();
  122. OVERRIDE_NodeHandler_OnCommand();
  123. OVERRIDE_NodeHandler_GetString();
  124. OVERRIDE_BaseHandlerNotify_OnCreateNodeId2();
  125. OVERRIDE_BaseHandlerNotify_OnExpand();
  126. OVERRIDE_BaseResultHandlerNotify_OnResultSelect();
  127. OVERRIDE_BaseResultHandlerNotify_OnResultDelete();
  128. OVERRIDE_BaseResultHandlerNotify_OnResultRefresh();
  129. OVERRIDE_ResultHandler_AddMenuItems();
  130. OVERRIDE_ResultHandler_Command();
  131. OVERRIDE_ResultHandler_OnGetResultViewType();
  132. OVERRIDE_ResultHandler_GetVirtualString();
  133. OVERRIDE_ResultHandler_GetVirtualImage();
  134. OVERRIDE_ResultHandler_CreatePropertyPages();
  135. OVERRIDE_ResultHandler_HasPropertyPages();
  136. // base result handler overridees
  137. STDMETHODIMP CacheHint(int nStartIndex, int nEndIndex);
  138. STDMETHODIMP SortItems(int nColumn,
  139. DWORD dwSortOptions,
  140. LPARAM lUserParam);
  141. HRESULT SetVirtualLbSize(ITFSComponent * pComponent, LONG_PTR data);
  142. // needed for background threading with a QueryObject
  143. virtual void OnHaveData(ITFSNode * pParentNode, LPARAM Data, LPARAM Type);
  144. ITFSQueryObject* OnCreateQuery(ITFSNode * pNode);
  145. // multi select support
  146. virtual const GUID * GetVirtualGuid(int nIndex)
  147. {
  148. return &GUID_WinsActiveRegistrationLeafNodeType;
  149. }
  150. public:
  151. // CWinsHandler overrides
  152. virtual HRESULT InitializeNode(ITFSNode * pNode);
  153. // base result handler overrides
  154. OVERRIDE_BaseHandlerNotify_OnPropertyChange();
  155. OVERRIDE_BaseResultHandlerNotify_OnResultPropertyChange();
  156. virtual int GetImageIndex(BOOL bOpenImage);
  157. void GetServerName(ITFSNode * pNode, CString &strServerName);
  158. HRESULT OnImportLMHOSTS(ITFSNode* pNode);
  159. HRESULT OnExportEntries();
  160. BOOL IsLocalConnection(ITFSNode *pNode);
  161. HRESULT ImportStaticMappingsFile(ITFSNode *pNode, CString strTmpFile,BOOL fDelete);
  162. DWORD RemoteTmp(CString & strDir, CString & strPrefix, CString & strRemoteFile);
  163. HRESULT EditMapping(ITFSNode *pNode, ITFSComponent *pComponent, int nIndex);
  164. HRESULT OnCheckRegNames(ITFSNode* pNode);
  165. HRESULT OnDeleteOwner(ITFSNode* pNode);
  166. void CheckNameConsistency(ITFSNode* pNode, BOOL fVerifyWithPartners);
  167. HRESULT RefreshResults(ITFSNode *pNode);
  168. // helpers
  169. public:
  170. HRESULT OnCreateMapping(ITFSNode *pNode);
  171. HRESULT OnDatabaseLoadStart(ITFSNode *pNode);
  172. HRESULT OnDatabaseLoadStop(ITFSNode *pNode);
  173. HRESULT AddMapping(ITFSNode* pNode);
  174. void GetStateString(DWORD dwState, CString& strType);
  175. void FilterCleanup(ITFSNode *pNode);
  176. void GetVersionInfo(LONG lLowWord, LONG lHighWord, CString& strVers);
  177. void CleanNetBIOSName(LPCSTR lpszSrc,
  178. CString & strDest,
  179. BOOL fExpandChars,
  180. BOOL fTruncate,
  181. BOOL fLanmanCompatible,
  182. BOOL fOemName,
  183. BOOL fWackwack,
  184. int nLength);
  185. PWINSINTF_RECORD_ACTION_T QueryForName(ITFSNode *pNode, PWINSINTF_RECORD_ACTION_T pRecAction, BOOL fStatic = TRUE);
  186. void GetStaticTypeString(DWORD dwState, CString& strStaticType);
  187. DWORD TombstoneRecords(ITFSComponent *pComponent, WinsRecord* pws);
  188. DWORD TombstoneAllRecords(DWORD dwServerIpAddress, ITFSNode * pNode);
  189. HRESULT UpdateRecord(ITFSComponent *pComponenet, WinsRecord *pws, int nDelIndex);
  190. BOOL GetRecordOwner(ITFSNode * pNode, WinsRecord * pWinsRecord);
  191. void GetOwnerInfo(CServerInfoArray & serverInfoArray);
  192. HRESULT BuildOwnerArray(handle_t hBinding);
  193. void SetServer(ITFSNode * pServer) { m_spServerNode.Set(pServer); }
  194. BOOL IsLanManCompatible();
  195. public:
  196. CLoadRecords m_dlgLoadRecords;
  197. SPIWinsDatabase m_spWinsDatabase;
  198. SPITFSNode m_spServerNode;
  199. IWinsDatabase * m_pCurrentDatabase;
  200. CString m_strFindName;
  201. BOOL m_fMatchCase;
  202. BOOL m_fFindNameOrIP; // TRUE for Name
  203. // for the static mapping dialog
  204. CString m_strStaticMappingName;
  205. CString m_strStaticMappingScope;
  206. CStringArray m_strArrayStaticMappingIPAddress;
  207. CString m_strStaticMappingType;
  208. int m_nStaticMappingType;
  209. CDWordArray m_lArrayIPAddress;
  210. CMultipleIpNamePair m_Multiples;
  211. ULONG m_nSelectedIndex;
  212. // for the combobox of Find record
  213. CStringArray m_strFindNamesArray;
  214. NameTypeMapping m_NameTypeMap;
  215. CServerInfoArray * m_pServerInfoArray;
  216. BOOL m_fLoadedOnce;
  217. BOOL m_fFindLoaded;
  218. BOOL m_fDbLoaded;
  219. BOOL m_fForceReload;
  220. // Implementation
  221. private:
  222. void GetServerIP(ITFSNode * pNode, DWORD &dwIP,CString &strIP);
  223. WinsStrRecord * BuildWinsStrRecord(int nIndex);
  224. void DatabaseLoadingCleanup();
  225. HRESULT UpdateListboxCount(ITFSNode * pNode, BOOL bClear = FALSE);
  226. HRESULT UpdateCurrentView(ITFSNode * pNode);
  227. HRESULT UpdateVerbs(ITFSNode * pNode);
  228. BOOL CompareRecName(LPSTR szNewName);
  229. DWORD AddMappingToServer(ITFSNode* pNode,
  230. int nType,
  231. int nCount,
  232. CMultipleIpNamePair& mipnp,
  233. BOOL fEdit = FALSE); // Editing existing mapping?
  234. void AppendScopeName(char* lpName, char* lpAppend);
  235. HRESULT AddToLocalStorage(PWINSINTF_RECORD_ACTION_T pRecAction,ITFSNode* pNode);
  236. HRESULT DeleteRegistration(ITFSComponent * pComponent, int nIndex);
  237. DWORD DeleteMappingFromServer(ITFSComponent * pComponent,WinsRecord *pws,int nIndex);
  238. HRESULT EditMappingToServer(ITFSNode* pNode,
  239. int nType,
  240. int nCount,
  241. CMultipleIpNamePair& mipnp,
  242. BOOL fEdit,
  243. WinsRecord *pRecord); // Editing existing mapping?
  244. void ToString(DWORD dwParam, CString& strParam);
  245. void SetLoadedOnce(ITFSNode * pNode);
  246. private:
  247. CString m_strActiveReg;
  248. CString m_strDesp;
  249. RecordList m_RecList;
  250. WINSDB_STATE m_winsdbState;
  251. WSAData m_WsaData;
  252. SOCKET m_sd;
  253. u_long m_NonBlocking;
  254. struct sockaddr_in myad;
  255. u_short m_uTranID;
  256. char m_pScope[20];
  257. WinsRecord m_CurrentRecord;
  258. CConfiguration m_Config;
  259. };
  260. #endif _ACTREG_H