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.

287 lines
9.0 KiB

  1. /*
  2. * oeconprp . c p p
  3. *
  4. * Purpose:
  5. * Implements connection dialog tab page for OE
  6. *
  7. * Owner:
  8. * shaheedp.
  9. *
  10. * Copyright (C) Microsoft Corp. 1998.
  11. */
  12. #include "pch.hxx"
  13. #include <commctrl.h>
  14. #include <imnxport.h>
  15. #include <Shlwapi.h>
  16. #include "acctman.h"
  17. #include "acctui.h"
  18. #include "connect.h"
  19. #include "dllmain.h"
  20. #include "resource.h"
  21. #include "accthelp.h"
  22. #include "server.h"
  23. #include "strconst.h"
  24. #include "oeconprp.h"
  25. #include "demand.h"
  26. ASSERTDATA
  27. /*
  28. * p r o t o t y p e s
  29. *
  30. */
  31. TCHAR szLanConn[CCHMAX_CONNECTOID];
  32. void UpdateControlStates(HWND hwnd)
  33. {
  34. BOOL fEnable, fLan;
  35. HWND hwndCombo;
  36. TCHAR szEntryName[CCHMAX_CONNECTOID];
  37. int iSel;
  38. hwndCombo = GetDlgItem(hwnd, idcRasConnection);
  39. if (BST_CHECKED == IsDlgButtonChecked(hwnd, idcRasAndLan))
  40. fEnable = TRUE;
  41. else
  42. fEnable = FALSE;
  43. EnableWindow(hwndCombo, fEnable);
  44. EnableWindow(GetDlgItem(hwnd, idcRasAdd), fEnable);
  45. if (fEnable)
  46. fEnable = ((iSel = ComboBox_GetCurSel(hwndCombo)) != CB_ERR);
  47. if (fEnable)
  48. {
  49. ComboBox_GetLBText(hwndCombo, iSel, szEntryName);
  50. //If it is Lan we don't want to enable props
  51. if (lstrcmp(szEntryName, szLanConn) == 0)
  52. fEnable = false;
  53. }
  54. EnableWindow(GetDlgItem(hwnd, idcRasProp), fEnable);
  55. }
  56. void OEConnProp_InitDialog(HWND hwnd, LPSTR szEntryName, DWORD iConnectType, BOOL fFirstInit)
  57. {
  58. HWND hwndCombo;
  59. int iSel;
  60. Assert(szEntryName != NULL);
  61. hwndCombo = GetDlgItem(hwnd, idcRasConnection);
  62. if (fFirstInit)
  63. {
  64. SetIntlFont(hwndCombo);
  65. HrFillRasCombo(hwndCombo, FALSE, NULL);
  66. //Add the the Local Area Network to the combo box
  67. ComboBox_AddString(hwndCombo, szLanConn);
  68. }
  69. if (iConnectType == CONNECTION_TYPE_LAN || iConnectType == CONNECTION_TYPE_RAS)
  70. {
  71. //CheckRadioButton(hwnd, idcInetSettings, idcRasAndLan, idcRasAndLan);
  72. CheckDlgButton(hwnd, idcRasAndLan, BST_CHECKED);
  73. if (iConnectType == CONNECTION_TYPE_LAN)
  74. {
  75. iSel = (*szLanConn != 0) ? ComboBox_FindStringExact(hwndCombo, -1, szLanConn) : 0;
  76. }
  77. else
  78. {
  79. iSel = (*szEntryName != 0) ? ComboBox_FindStringExact(hwndCombo, -1, szEntryName) : 0;
  80. }
  81. ComboBox_SetCurSel(hwndCombo, iSel);
  82. }
  83. else
  84. {
  85. Assert(iConnectType == CONNECTION_TYPE_INETSETTINGS);
  86. ComboBox_SetCurSel(hwndCombo, 0);
  87. }
  88. UpdateControlStates(hwnd);
  89. }
  90. // if pAcct is NULL, we're in the wizard, otherwise we're in the prop sheet
  91. void OEConnProp_WMCommand(HWND hwnd, HWND hwndCmd, int id, WORD wCmd, IImnAccount *pAcct)
  92. {
  93. BOOL fEnable;
  94. if (wCmd == BN_CLICKED)
  95. {
  96. switch (id)
  97. {
  98. case idcRasAdd:
  99. ConnectPage_MakeNewConnection(hwnd);
  100. EnableWindow(GetDlgItem(hwnd, idcRasProp),
  101. ComboBox_GetCurSel(GetDlgItem(hwnd, idcRasConnection)) != CB_ERR);
  102. UpdateControlStates(hwnd);
  103. break;
  104. case idcRasProp:
  105. ConnectPage_EditConnection(hwnd);
  106. break;
  107. default:
  108. UpdateControlStates(hwnd);
  109. if (pAcct != NULL)
  110. {
  111. PropSheet_Changed(GetParent(hwnd), hwnd);
  112. PropSheet_QuerySiblings(GetParent(hwnd), SM_SETDIRTY, PAGE_RAS);
  113. }
  114. break;
  115. }
  116. }
  117. else if (wCmd == CBN_SELENDOK && id == idcRasConnection)
  118. {
  119. UpdateControlStates(hwnd);
  120. if (pAcct != NULL)
  121. {
  122. PropSheet_Changed(GetParent(hwnd), hwnd);
  123. PropSheet_QuerySiblings(GetParent(hwnd), SM_SETDIRTY, PAGE_RAS);
  124. }
  125. }
  126. }
  127. //****
  128. //Need to change these.
  129. const static HELPMAP g_rgCtxMapConnect[] = {
  130. {idcRasAndLan, 601},
  131. {idcRasProp, IDH_NEWS_SERV_CNKT_PROPS},
  132. {idcRasConnection, IDH_NEWS_SERV_CNKT_DIALUP_CONNECT},
  133. {idcRasAdd, IDH_NEWS_SERV_CNKT_ADD},
  134. {IDC_STATIC0, IDH_INETCOMM_GROUPBOX},
  135. {IDC_STATIC1, IDH_INETCOMM_GROUPBOX},
  136. {IDC_STATIC2, IDH_INETCOMM_GROUPBOX},
  137. {IDC_STATIC3, IDH_INETCOMM_GROUPBOX},
  138. {0,0}};
  139. INT_PTR CALLBACK OEConnProp_DlgProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
  140. {
  141. ACCTTYPE type;
  142. NMHDR *pnmh;
  143. CAccount *pAcct;
  144. BOOL fModem;
  145. int iSel;
  146. HWND hwndModem, hwndCombo;
  147. SERVER_TYPE sfType;
  148. char *psz, szEntryName[CCHMAX_CONNECTOID], szBackup[CCHMAX_CONNECTOID];
  149. TCHAR szRes[CCHMAX_STRINGRES];
  150. DWORD dw;
  151. pAcct = (CAccount *)GetWindowLongPtr(hwnd, DWLP_USER);
  152. switch (uMsg)
  153. {
  154. case WM_INITDIALOG:
  155. LoadString(g_hInstRes, idsConnectionLAN, szLanConn, ARRAYSIZE(szLanConn));
  156. // Get the ServerParams and store them in our extra bytes
  157. pAcct = (CAccount *)((PROPSHEETPAGE *)lParam)->lParam;
  158. SetWindowLongPtr(hwnd, DWLP_USER, (LPARAM)pAcct);
  159. Assert(pAcct);
  160. pAcct->GetAccountType(&type);
  161. Assert(type == ACCT_MAIL || type == ACCT_NEWS);
  162. // Get the connection info
  163. if (FAILED(pAcct->GetPropSz(AP_RAS_CONNECTOID, szEntryName, ARRAYSIZE(szEntryName))))
  164. szEntryName[0] = 0;
  165. if (FAILED(pAcct->GetPropDw(AP_RAS_CONNECTION_TYPE, &dw)))
  166. {
  167. dw = CONNECTION_TYPE_INETSETTINGS;
  168. }
  169. OEConnProp_InitDialog(hwnd, szEntryName, dw, TRUE);
  170. if (FAILED(pAcct->GetPropDw(AP_RAS_CONNECTION_FLAGS, &dw)))
  171. dw = 0;
  172. PropSheet_QuerySiblings(GetParent(hwnd), SM_INITIALIZED, PAGE_RAS);
  173. PropSheet_UnChanged(GetParent(hwnd), hwnd);
  174. return (TRUE);
  175. case WM_HELP:
  176. case WM_CONTEXTMENU:
  177. return OnContextHelp(hwnd, uMsg, wParam, lParam, g_rgCtxMapConnect);
  178. case WM_COMMAND:
  179. OEConnProp_WMCommand(hwnd, GET_WM_COMMAND_HWND(wParam, lParam),
  180. GET_WM_COMMAND_ID(wParam, lParam),
  181. GET_WM_COMMAND_CMD(wParam, lParam),
  182. pAcct);
  183. return (TRUE);
  184. case WM_NOTIFY:
  185. pnmh = (NMHDR *)lParam;
  186. switch (pnmh->code)
  187. {
  188. case PSN_APPLY:
  189. hwndCombo = GetDlgItem(hwnd, idcRasConnection);
  190. if (IsDlgButtonChecked(hwnd, idcRasAndLan))
  191. {
  192. iSel = ComboBox_GetCurSel(hwndCombo);
  193. if (iSel != CB_ERR)
  194. {
  195. ComboBox_GetLBText(hwndCombo, iSel, szEntryName);
  196. if (lstrcmp(szLanConn, szEntryName) == 0)
  197. {
  198. dw = CONNECTION_TYPE_LAN;
  199. EnableWindow(GetDlgItem(hwnd, idcRasProp), FALSE);
  200. }
  201. else
  202. {
  203. dw = CONNECTION_TYPE_RAS;
  204. pAcct->SetPropSz(AP_RAS_CONNECTOID, szEntryName);
  205. }
  206. }
  207. else
  208. {
  209. dw = CONNECTION_TYPE_INETSETTINGS;
  210. CheckDlgButton(hwnd, idcRasAndLan, BST_UNCHECKED);
  211. }
  212. }
  213. else
  214. {
  215. dw = CONNECTION_TYPE_INETSETTINGS;
  216. }
  217. if ((dw == CONNECTION_TYPE_LAN) || (dw == CONNECTION_TYPE_INETSETTINGS))
  218. {
  219. pAcct->SetPropSz(AP_RAS_CONNECTOID, NULL);
  220. }
  221. pAcct->SetPropDw(AP_RAS_CONNECTION_TYPE, dw);
  222. PropSheet_UnChanged(GetParent(hwnd), hwnd);
  223. dw = PAGE_RAS;
  224. PropSheet_QuerySiblings(GetParent(hwnd), SM_SAVECHANGES, (LPARAM)&dw);
  225. if (dw == -1)
  226. {
  227. SetWindowLongPtr(hwnd, DWLP_MSGRESULT, PSNRET_INVALID_NOCHANGEPAGE);
  228. return(TRUE);
  229. }
  230. break;
  231. }
  232. return(TRUE);
  233. }
  234. return (FALSE);
  235. }