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.

385 lines
9.9 KiB

  1. //----------------------------------------------------------------------------
  2. //
  3. // Copyright (c) 1997-1999 Microsoft Corporation
  4. // All rights reserved.
  5. //
  6. // File Name:
  7. // appletlk.c
  8. //
  9. // Description:
  10. // This file contains the property sheet and page procedures for the
  11. // Appletalk protocol property sheet.
  12. //
  13. //----------------------------------------------------------------------------
  14. #include "pch.h"
  15. #include "resource.h"
  16. #define MAX_NETWORKNUMBER_LENGTH 8
  17. PROPSHEETHEADER AppleTalk_pshead;
  18. PROPSHEETPAGE AppleTalk_pspage;
  19. UINT CALLBACK
  20. Appletalk_PropertiesPageProc( HWND hwnd, UINT uMsg, LPPROPSHEETPAGE ppsp );
  21. int CALLBACK Appletalk_PropertySheetProc( IN HWND hwndDlg,
  22. IN UINT uMsg,
  23. IN LPARAM lParam );
  24. INT_PTR CALLBACK Appletalk_PropertiesDlgProc(
  25. IN HWND hwnd,
  26. IN UINT uMsg,
  27. IN WPARAM wParam,
  28. IN LPARAM lParam);
  29. //----------------------------------------------------------------------------
  30. //
  31. // Function: Appletalk_PropertySheetProc
  32. //
  33. // Purpose:
  34. //
  35. // Arguments:
  36. //
  37. // Returns:
  38. //
  39. //----------------------------------------------------------------------------
  40. int CALLBACK Appletalk_PropertySheetProc( IN HWND hwndDlg,
  41. IN UINT uMsg,
  42. IN LPARAM lParam )
  43. {
  44. switch( uMsg )
  45. {
  46. case PSCB_INITIALIZED:
  47. // Process PSCB_INITIALIZED
  48. break;
  49. case PSCB_PRECREATE:
  50. // Process PSCB_PRECREATE
  51. break;
  52. default:
  53. // Unknown message
  54. break;
  55. }
  56. return( 0 );
  57. }
  58. //----------------------------------------------------------------------------
  59. //
  60. // Function: Create_Appletalk_PropertySheet
  61. //
  62. // Purpose:
  63. //
  64. // Arguments:
  65. //
  66. // Returns:
  67. //
  68. //----------------------------------------------------------------------------
  69. BOOL
  70. Create_Appletalk_PropertySheet( IN HWND hwndParent )
  71. {
  72. // Initialize property sheet HEADER data
  73. ZeroMemory( &AppleTalk_pshead, sizeof( PROPSHEETHEADER ) );
  74. AppleTalk_pshead.dwSize = sizeof( PROPSHEETHEADER );
  75. AppleTalk_pshead.dwFlags = PSH_PROPSHEETPAGE |
  76. PSH_USECALLBACK |
  77. PSH_USEHICON |
  78. PSH_NOAPPLYNOW;
  79. AppleTalk_pshead.hwndParent = hwndParent;
  80. AppleTalk_pshead.hInstance = FixedGlobals.hInstance;
  81. AppleTalk_pshead.pszCaption = g_StrAppletalkProtocolTitle;
  82. AppleTalk_pshead.nPages = 1;
  83. AppleTalk_pshead.nStartPage = 0;
  84. AppleTalk_pshead.ppsp = &AppleTalk_pspage;
  85. AppleTalk_pshead.pfnCallback = Appletalk_PropertySheetProc;
  86. // Zero out property PAGE data
  87. ZeroMemory (&AppleTalk_pspage, 1 * sizeof( PROPSHEETPAGE) );
  88. AppleTalk_pspage.dwSize = sizeof( PROPSHEETPAGE );
  89. AppleTalk_pspage.dwFlags = PSP_USECALLBACK;
  90. AppleTalk_pspage.hInstance = FixedGlobals.hInstance;
  91. AppleTalk_pspage.pszTemplate = MAKEINTRESOURCE(IDD_APPLETALK_GENERAL);
  92. AppleTalk_pspage.pfnDlgProc = Appletalk_PropertiesDlgProc;
  93. AppleTalk_pspage.pfnCallback = Appletalk_PropertiesPageProc;
  94. // --------- Create & display property sheet ---------
  95. return PropertySheet( &AppleTalk_pshead ) ? TRUE : FALSE;
  96. }
  97. //----------------------------------------------------------------------------
  98. //
  99. // Function: Appletalk_PropertiesPageProc
  100. //
  101. // Purpose:
  102. //
  103. // Arguments:
  104. //
  105. // Returns:
  106. //
  107. //----------------------------------------------------------------------------
  108. UINT CALLBACK
  109. Appletalk_PropertiesPageProc( HWND hwnd, UINT uMsg, LPPROPSHEETPAGE ppsp )
  110. {
  111. switch( uMsg )
  112. {
  113. case PSPCB_CREATE:
  114. return( 1 );
  115. case PSPCB_RELEASE:
  116. return( 0 );
  117. }
  118. return( 0 );
  119. }
  120. //----------------------------------------------------------------------------
  121. //
  122. // Function: OnAppleTalkInitDialog
  123. //
  124. // Purpose:
  125. //
  126. // Arguments: IN HWND hwnd - handle to the dialog box
  127. //
  128. // Returns: VOID
  129. //
  130. //----------------------------------------------------------------------------
  131. static VOID
  132. OnAppleTalkInitDialog( IN HWND hwnd )
  133. {
  134. INT i;
  135. INT iZoneCount;
  136. INT_PTR iDefaultZoneIndex;
  137. TCHAR *pszZone;
  138. //
  139. // Set the text limit on the edit boxes
  140. //
  141. SendDlgItemMessage( hwnd,
  142. IDC_EB_NETWORKRANGE_FROM,
  143. EM_LIMITTEXT,
  144. (WPARAM) MAX_NETRANGE_LEN,
  145. (LPARAM) 0 );
  146. SendDlgItemMessage( hwnd,
  147. IDC_EB_NETWORKRANGE_TO,
  148. EM_LIMITTEXT,
  149. (WPARAM) MAX_NETRANGE_LEN,
  150. (LPARAM) 0 );
  151. if( NetSettings.pCurrentAdapter->bEnableSeedRouting )
  152. {
  153. CheckDlgButton( hwnd, IDC_CB_ENABLESEEDING, BST_CHECKED );
  154. }
  155. else
  156. {
  157. CheckDlgButton( hwnd, IDC_CB_ENABLESEEDING, BST_UNCHECKED );
  158. }
  159. SetWindowText( GetDlgItem( hwnd, IDC_EB_NETWORKRANGE_FROM ),
  160. NetSettings.pCurrentAdapter->szNetworkRangeFrom );
  161. SetWindowText( GetDlgItem( hwnd, IDC_EB_NETWORKRANGE_TO ),
  162. NetSettings.pCurrentAdapter->szNetworkRangeTo );
  163. iZoneCount = GetNameListSize( &(NetSettings.pCurrentAdapter->ZoneList) );
  164. for( i = 0; i < iZoneCount; i++ )
  165. {
  166. pszZone = GetNameListName( &(NetSettings.pCurrentAdapter->ZoneList), i );
  167. SendDlgItemMessage( hwnd,
  168. IDC_CB_DEFAULTZONE,
  169. CB_INSERTSTRING,
  170. (WPARAM) -1,
  171. (LPARAM) pszZone );
  172. SendDlgItemMessage( hwnd,
  173. IDC_LB_ZONELIST,
  174. LB_INSERTSTRING,
  175. (WPARAM) -1,
  176. (LPARAM) pszZone );
  177. }
  178. iDefaultZoneIndex = SendDlgItemMessage( hwnd,
  179. IDC_CB_DEFAULTZONE,
  180. CB_FINDSTRING,
  181. (WPARAM) -1,
  182. (LPARAM) NetSettings.szDefaultZone );
  183. if( iDefaultZoneIndex != CB_ERR )
  184. {
  185. SendDlgItemMessage( hwnd,
  186. IDC_CB_DEFAULTZONE,
  187. CB_SETCURSEL,
  188. iDefaultZoneIndex,
  189. 0 );
  190. }
  191. }
  192. //----------------------------------------------------------------------------
  193. //
  194. // Function: OnAppleTalkApply
  195. //
  196. // Purpose:
  197. //
  198. // Arguments: IN HWND hwnd - handle to the dialog box
  199. //
  200. // Returns: VOID
  201. //
  202. //----------------------------------------------------------------------------
  203. static VOID
  204. OnAppleTalkApply( IN HWND hwnd )
  205. {
  206. INT i;
  207. INT_PTR iEntries;
  208. INT_PTR iDefaultZoneIndex;
  209. TCHAR szZone[MAX_ZONE_LEN + 1];
  210. if( IsDlgButtonChecked( hwnd, IDC_CB_ENABLESEEDING ) )
  211. {
  212. NetSettings.pCurrentAdapter->bEnableSeedRouting = TRUE;
  213. }
  214. else
  215. {
  216. NetSettings.pCurrentAdapter->bEnableSeedRouting = FALSE;
  217. }
  218. GetWindowText( GetDlgItem( hwnd, IDC_EB_NETWORKRANGE_FROM ),
  219. NetSettings.pCurrentAdapter->szNetworkRangeFrom,
  220. MAX_NETRANGE_LEN + 1 );
  221. GetWindowText( GetDlgItem( hwnd, IDC_EB_NETWORKRANGE_TO ),
  222. NetSettings.pCurrentAdapter->szNetworkRangeTo,
  223. MAX_NETRANGE_LEN + 1 );
  224. iDefaultZoneIndex = SendDlgItemMessage( hwnd,
  225. IDC_CB_DEFAULTZONE,
  226. CB_GETCURSEL,
  227. 0,
  228. 0 );
  229. if( iDefaultZoneIndex != LB_ERR )
  230. {
  231. SendDlgItemMessage( hwnd,
  232. IDC_CB_DEFAULTZONE,
  233. CB_GETLBTEXT,
  234. (WPARAM) iDefaultZoneIndex,
  235. (LPARAM) NetSettings.szDefaultZone );
  236. }
  237. iEntries = SendDlgItemMessage( hwnd,
  238. IDC_LB_ZONELIST,
  239. LB_GETCOUNT,
  240. 0,
  241. 0 );
  242. if( iEntries == LB_ERR )
  243. {
  244. return;
  245. }
  246. for( i = 0; i < iEntries; i++ )
  247. {
  248. SendDlgItemMessage( hwnd,
  249. IDC_LB_ZONELIST,
  250. LB_GETTEXT,
  251. (WPARAM) i,
  252. (LPARAM) szZone );
  253. AddNameToNameList( &(NetSettings.pCurrentAdapter->ZoneList), szZone );
  254. }
  255. }
  256. //----------------------------------------------------------------------------
  257. //
  258. // Function: Appletalk_PropertiesDlgProc
  259. //
  260. // Purpose:
  261. //
  262. // Arguments:
  263. //
  264. // Returns:
  265. //
  266. //----------------------------------------------------------------------------
  267. INT_PTR CALLBACK Appletalk_PropertiesDlgProc(
  268. IN HWND hwnd,
  269. IN UINT uMsg,
  270. IN WPARAM wParam,
  271. IN LPARAM lParam)
  272. {
  273. BOOL bStatus = TRUE;
  274. switch( uMsg ) {
  275. case WM_INITDIALOG: {
  276. OnAppleTalkInitDialog( hwnd );
  277. break;
  278. }
  279. case WM_NOTIFY: {
  280. LPNMHDR pnmh = (LPNMHDR) lParam;
  281. switch( pnmh->code ) {
  282. case PSN_APPLY: {
  283. OnAppleTalkApply( hwnd );
  284. }
  285. }
  286. break;
  287. } // end case WM_NOTIFY
  288. case WM_COMMAND: {
  289. WORD wNotifyCode = HIWORD( wParam ) ;
  290. WORD wButtonId = LOWORD( wParam ) ;
  291. break;
  292. }
  293. default:
  294. bStatus = FALSE;
  295. break;
  296. }
  297. return( bStatus );
  298. }