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.

130 lines
5.0 KiB

  1. #include "resource.h"
  2. #include "xpsp1res.h"
  3. #include "wzcdata.h"
  4. #pragma once
  5. // utility macro to convert a hexa digit into its value
  6. #define HEX(c) ((c)<='9'?(c)-'0':(c)<='F'?(c)-'A'+0xA:(c)-'a'+0xA)
  7. // flags indicating various operational actions.
  8. // flags are used in:
  9. // AddUniqueConfig()
  10. #define WZCADD_HIGROUP 0x00000001 // add in front of its group
  11. #define WZCADD_OVERWRITE 0x00000002 // overwrite data
  12. #define WZCOP_VLIST 0x00000004 // operate on the visible list
  13. #define WZCOP_PLIST 0x00000008 // operate on the preferred list
  14. // defines legal lengths for the WEP Key material
  15. #define WZC_WEPKMAT_40_ASC 5
  16. #define WZC_WEPKMAT_40_HEX 10
  17. #define WZC_WEPKMAT_104_ASC 13
  18. #define WZC_WEPKMAT_104_HEX 26
  19. #define WZC_WEPKMAT_128_ASC 16
  20. #define WZC_WEPKMAT_128_HEX 32
  21. class CWZCQuickCfg:
  22. public CDialogImpl<CWZCQuickCfg>
  23. {
  24. protected:
  25. // handles to the controls
  26. HWND m_hLblInfo;
  27. HWND m_hLblNetworks;
  28. HWND m_hLstNetworks;
  29. HWND m_hWarnIcon;
  30. HWND m_hLblNoWepKInfo;
  31. HWND m_hChkNoWepK;
  32. HWND m_hLblWepKInfo;
  33. HWND m_hLblWepK;
  34. HWND m_hEdtWepK;
  35. HWND m_hLblWepK2;
  36. HWND m_hEdtWepK2;
  37. HWND m_hChkOneX;
  38. HWND m_hBtnAdvanced;
  39. HWND m_hBtnConnect;
  40. // Handle to the images
  41. HIMAGELIST m_hImgs; // list items images
  42. BEGIN_MSG_MAP(CWZCQuickCfg)
  43. MESSAGE_HANDLER(WM_INITDIALOG, OnInitDialog)
  44. MESSAGE_HANDLER(WM_CONTEXTMENU, OnContextMenu)
  45. MESSAGE_HANDLER(WM_HELP, OnHelp)
  46. MESSAGE_HANDLER(WM_TIMER, OnTimer)
  47. NOTIFY_CODE_HANDLER(LVN_ITEMCHANGED, OnItemChanged)
  48. NOTIFY_CODE_HANDLER(NM_DBLCLK, OnDbClick);
  49. COMMAND_ID_HANDLER(IDC_WZCQCFG_CONNECT, OnConnect)
  50. COMMAND_ID_HANDLER(IDCANCEL, OnCancel)
  51. COMMAND_ID_HANDLER(IDCLOSE, OnCancel)
  52. COMMAND_ID_HANDLER(IDC_WZCQCFG_ADVANCED, OnAdvanced)
  53. COMMAND_ID_HANDLER(IDC_WZCQCFG_WEPK, OnWepKMatCmd)
  54. COMMAND_ID_HANDLER(IDC_WZCQCFG_CHK_NOWK, OnCheckConfirmNoWep)
  55. END_MSG_MAP()
  56. enum {IDD = IDD_WZCQCFG };
  57. // GUID on which we're operating
  58. GUID m_Guid;
  59. // zero conf data on the interface
  60. BOOL m_bHaveWZCData;
  61. INTF_ENTRY m_IntfEntry;
  62. DWORD m_dwOIDFlags;
  63. UINT m_nTimer;
  64. HCURSOR m_hCursor;
  65. BOOL m_bKMatTouched; // tells whether the user changed the wep key
  66. // internal lists
  67. CWZCConfig *m_pHdVList; // list of visible configs
  68. CWZCConfig *m_pHdPList; // list of preferred configs
  69. DWORD GetWepKMaterial(UINT *pnKeyLen, LPBYTE *ppszKMat, DWORD *pdwCtlFlags);
  70. BOOL IsConfigInList(CWZCConfig *pHdList, PWZC_WLAN_CONFIG pwzcConfig, CWZCConfig **ppMatchingConfig = NULL);
  71. DWORD InitListView();
  72. DWORD GetOIDs(DWORD dwInFlags, LPDWORD pdwOutFlags);
  73. DWORD SavePreferredConfigs(PINTF_ENTRY pIntf, CWZCConfig *pStartCfg = NULL);
  74. DWORD FillVisibleList(PWZC_802_11_CONFIG_LIST pwzcVList);
  75. DWORD FillPreferredList(PWZC_802_11_CONFIG_LIST pwzcPList);
  76. DWORD RefreshListView();
  77. DWORD RefreshControls();
  78. // calls operating only on the internal lists (m_pHdVList or m_pHdPList)
  79. DWORD AddUniqueConfig(
  80. DWORD dwOpFlags, // operation specific flags (see WZCADD_* flags)
  81. DWORD dwEntryFlags, // flags for the config to be inserted
  82. PWZC_WLAN_CONFIG pwzcConfig, // WZC Configuration
  83. CWZCConfig **ppNewNode = NULL); // [out] gives the pointer of the newly created config object
  84. public:
  85. LPWSTR m_wszTitle;
  86. // class constructor
  87. CWZCQuickCfg(const GUID * pGuid);
  88. // class destructor
  89. ~CWZCQuickCfg();
  90. // Dialog related members
  91. LRESULT OnInitDialog (UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
  92. LRESULT OnContextMenu(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
  93. LRESULT OnHelp(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
  94. LRESULT OnTimer(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
  95. LRESULT OnItemChanged(int idCtrl, LPNMHDR pnmh, BOOL& bHandled);
  96. LRESULT OnDbClick(int idCtrl, LPNMHDR pnmh, BOOL& bHandled);
  97. LRESULT OnConnect(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled);
  98. LRESULT OnCancel(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled);
  99. LRESULT OnAdvanced(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled);
  100. LRESULT OnWepKMatCmd(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled);
  101. LRESULT OnCheckConfirmNoWep(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled);
  102. public:
  103. INT_PTR SpDoModal(HWND hWndParent = ::GetActiveWindow(), LPARAM dwInitParam = NULL)
  104. {
  105. _Module.AddCreateWndData(&m_thunk.cd, (CDialogImplBaseT<CWindow>*)this);
  106. #ifdef _DEBUG
  107. m_bModal = true;
  108. #endif //_DEBUG
  109. return ::DialogBoxParam(
  110. WZCGetSPResModule(),
  111. MAKEINTRESOURCE(CWZCQuickCfg::IDD),
  112. ::GetActiveWindow(),
  113. (DLGPROC)CWZCQuickCfg::StartDialogProc,
  114. NULL);
  115. }
  116. BOOL SpEndDialog(INT_PTR nRetCode)
  117. {
  118. return ::EndDialog(m_hWnd, nRetCode);
  119. }
  120. };