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.

313 lines
11 KiB

  1. //*********************************************************************
  2. //* Microsoft Windows **
  3. //* Copyright(c) Microsoft Corp., 1994 **
  4. //*********************************************************************
  5. //
  6. // ENDUI.C - Functions for Wizard closing pages and internet tour
  7. //
  8. //
  9. // HISTORY:
  10. //
  11. // 1/12/95 jeremys Created.
  12. // 96/03/09 markdu Added LPRASENTRY parameter to CreateConnectoid()
  13. // 96/03/09 markdu Moved all references to 'need terminal window after
  14. // dial' into RASENTRY.dwfOptions.
  15. // 96/03/10 markdu Moved all references to modem name into RASENTRY.
  16. // 96/03/10 markdu Moved all references to phone number into RASENTRY.
  17. // 96/03/10 markdu Made all TCP/IP stuff be per-connectoid.
  18. // 96/03/23 markdu Removed unused TCP/IP code.
  19. // 96/03/24 markdu Replaced memset with ZeroMemory for consistency.
  20. // 96/04/04 markdu Added phonebook name param to CreateConnectoid.
  21. // 96/04/06 markdu NASH BUG 15369 Enable finish AND back button on last page,
  22. // and create the connectoid only after finish has been pressed.
  23. // 96/04/06 markdu NASH BUG 15653 Use exported autodial API.
  24. // 96/05/02 markdu NASH BUG 17333 Write out IE news settings.
  25. // 96/05/06 markdu NASH BUG 21139 Turn off proxy server if connecting
  26. // over modem.
  27. // 96/05/14 markdu NASH BUG 22681 Took out mail and news pages.
  28. //
  29. #include "wizard.h"
  30. #include "icwextsn.h"
  31. #include "imnext.h"
  32. typedef HRESULT (APIENTRY *PFNSETDEFAULTMAILHANDLER)(VOID);
  33. typedef HRESULT (APIENTRY *PFNSETDEFAULTNEWSHANDLER)(VOID);
  34. #define REGKEY_NDC TEXT("Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Advanced")
  35. #define REGKEY_NDC_ENTRY TEXT("CascadeNetworkConnections")
  36. #define REGKEY_NDC_VALUE TEXT("YES")
  37. BOOL CommitConfigurationChanges(HWND hDlg);
  38. /*******************************************************************
  39. NAME: ConnectedOKInitProc
  40. SYNOPSIS: Called when "Your are connected" page is displayed
  41. ENTRY: hDlg - dialog window
  42. fFirstInit - TRUE if this is the first time the dialog
  43. is initialized, FALSE if this InitProc has been called
  44. before (e.g. went past this page and backed up)
  45. ********************************************************************/
  46. BOOL CALLBACK ConnectedOKInitProc(HWND hDlg,BOOL fFirstInit)
  47. {
  48. // enable "finish" button instead of "next"
  49. PropSheet_SetWizButtons(GetParent(hDlg),PSWIZB_FINISH | PSWIZB_BACK);
  50. // if we've travelled through external apprentice pages,
  51. // it's easy for our current page pointer to get munged,
  52. // so reset it here for sanity's sake.
  53. gpWizardState->uCurrentPage = ORD_PAGE_CONNECTEDOK;
  54. return TRUE;
  55. }
  56. /*******************************************************************
  57. NAME: ConnectedOKOKProc
  58. SYNOPSIS: Called when Next or Back btns pressed from page
  59. ENTRY: hDlg - dialog window
  60. fForward - TRUE if 'Next' was pressed, FALSE if 'Back'
  61. puNextPage - if 'Next' was pressed,
  62. proc can fill this in with next page to go to. This
  63. parameter is ingored if 'Back' was pressed.
  64. pfKeepHistory - page will not be kept in history if
  65. proc fills this in with FALSE.
  66. EXIT: returns TRUE to allow page to be turned, FALSE
  67. to keep the same page.
  68. ********************************************************************/
  69. BOOL CALLBACK ConnectedOKOKProc(HWND hDlg,BOOL fForward,UINT * puNextPage,
  70. BOOL * pfKeepHistory)
  71. {
  72. if (fForward)
  73. {
  74. if (CONNECT_RAS == gpUserInfo->uiConnectionType)
  75. {
  76. HKEY hKey = NULL;
  77. RegOpenKeyEx(HKEY_CURRENT_USER, REGKEY_NDC, 0, KEY_WRITE, &hKey);
  78. if (hKey)
  79. {
  80. RegSetValueEx(hKey, REGKEY_NDC_ENTRY, 0, REG_SZ, (LPBYTE)REGKEY_NDC_VALUE, sizeof(REGKEY_NDC_VALUE));
  81. CloseHandle(hKey);
  82. }
  83. }
  84. // set flag to indicate that the user completed the wizard
  85. gfUserFinished = TRUE;
  86. // go configure mail, RNA
  87. if (!CommitConfigurationChanges(hDlg))
  88. {
  89. // set flag to indicate that wizard should exit now
  90. gfQuitWizard = TRUE;
  91. return FALSE;
  92. }
  93. }
  94. return TRUE;
  95. }
  96. /*******************************************************************
  97. NAME: CommitConfigurationChanges
  98. SYNOPSIS: Performs the following as appropriate:
  99. Mail configuration, RNA connectoid creation
  100. ENTRY: hDlg - handle of parent window
  101. EXIT: returns TRUE if successful or partially successful,
  102. FALSE if unsuccessful
  103. NOTES: Displays its own error messages. This function will
  104. continue as far as it can, if one item fails it will
  105. try to commit the rest.
  106. ********************************************************************/
  107. BOOL CommitConfigurationChanges(HWND hDlg)
  108. {
  109. HRESULT hr;
  110. FARPROC fpSetDefault;
  111. HKEY hKey;
  112. TCHAR szBuf[MAX_PATH+1];
  113. DWORD size;
  114. // if connecting over modem, create a connectoid with
  115. // ISP name and phone number
  116. if ( CONNECT_RAS == gpUserInfo->uiConnectionType )
  117. {
  118. DWORD dwRet;
  119. // Only create the connectoid if it is new or has been modified
  120. if (gpUserInfo->fNewConnection || gpUserInfo->fModifyConnection)
  121. {
  122. DEBUGMSG("Creating/modifying connectoid %s", gpUserInfo->szISPName);
  123. dwRet = CreateConnectoid(NULL, gpUserInfo->szISPName, gpRasEntry,
  124. gpUserInfo->szAccountName,gpUserInfo->szPassword);
  125. if (dwRet != ERROR_SUCCESS)
  126. {
  127. DisplayErrorMessage(hDlg,IDS_ERRCreateConnectoid,
  128. dwRet,ERRCLS_RNA,MB_ICONEXCLAMATION);
  129. return FALSE;
  130. }
  131. }
  132. // Only change the defaults if we are not just setting
  133. // up a new mail or news account.
  134. if ( !(gpWizardState->dwRunFlags & RSW_APPRENTICE) )
  135. {
  136. // 96/05/06 markdu NASH BUG 21139 Turn off proxy server if connecting
  137. // over modem.
  138. gpUserInfo->fProxyEnable = FALSE;
  139. // set the name of this connectoid in registry as the connectoid
  140. // to use for autodialing
  141. // 96/04/06 markdu NASH BUG 15653 Use exported autodial API.
  142. InetSetAutodial(TRUE, gpUserInfo->szISPName);
  143. // clear any old backup number
  144. SetBackupInternetConnectoid(NULL);
  145. }
  146. }
  147. else if ( !(gpWizardState->dwRunFlags & RSW_APPRENTICE) )
  148. {
  149. // disable autodialing in registry because user is using LAN
  150. // 96/04/06 markdu NASH BUG 15653 Use exported autodial API.
  151. InetSetAutodial(FALSE, NULL);
  152. }
  153. if ( !(gpWizardState->dwRunFlags & RSW_APPRENTICE) )
  154. {
  155. if (CONNECT_LAN == gpUserInfo->uiConnectionType)
  156. {
  157. // write out proxy server config information
  158. hr = InetSetProxyEx(gpUserInfo->fProxyEnable,
  159. NULL,
  160. gpUserInfo->szProxyServer,
  161. gpUserInfo->szProxyOverride);
  162. if (ERROR_SUCCESS != hr)
  163. {
  164. DisplayErrorMessage(hDlg,IDS_ERRConfigureProxy,
  165. (DWORD) hr,ERRCLS_STANDARD,MB_ICONEXCLAMATION);
  166. return FALSE;
  167. }
  168. }
  169. // make sure "The Internet" icon on desktop points to web browser
  170. // (it may initially be pointing at internet wizard)
  171. // //10/24/96 jmazner Normandy 6968
  172. // //No longer neccessary thanks to Valdon's hooks for invoking ICW.
  173. // 11/21/96 jmazner Normandy 11812
  174. // oops, it _is_ neccessary, since if user downgrades from IE 4 to IE 3,
  175. // ICW 1.1 needs to morph the IE 3 icon.
  176. SetDesktopInternetIconToBrowser();
  177. // set notation in registry whether user selected modem or LAN access,
  178. // for future reference...
  179. RegEntry re(szRegPathInternetSettings,HKEY_LOCAL_MACHINE);
  180. if (re.GetError() == ERROR_SUCCESS)
  181. {
  182. re.SetValue(szRegValAccessMedium,(DWORD)
  183. (CONNECT_LAN == gpUserInfo->uiConnectionType) ? USERPREF_LAN : USERPREF_MODEM);
  184. ASSERT(re.GetError() == ERROR_SUCCESS);
  185. re.SetValue(szRegValAccessType, (DWORD) ACCESSTYPE_OTHER_ISP);
  186. ASSERT(re.GetError() == ERROR_SUCCESS);
  187. }
  188. // set the username as the DNS host name, if there is no host name already
  189. // This is because some ISPs use the DNS host name for security for
  190. // access to mail, etc. (Go figure!)
  191. RegEntry reTcp(szTCPGlobalKeyName,HKEY_LOCAL_MACHINE);
  192. ASSERT(reTcp.GetError() == ERROR_SUCCESS);
  193. if (reTcp.GetError() == ERROR_SUCCESS)
  194. {
  195. TCHAR szHostName[SMALL_BUF_LEN+1]=TEXT("");
  196. // set DNS host name, but only if there's not a host name already set
  197. if (!reTcp.GetString(szRegValHostName,szHostName,sizeof(szHostName))
  198. || !lstrlen(szHostName))
  199. reTcp.SetValue(szRegValHostName,gpUserInfo->szAccountName);
  200. }
  201. // If DNS is set globally, clear it out so the per-connectoid settings
  202. // will be saved.
  203. BOOL fTemp;
  204. DoDNSCheck(hDlg,&fTemp);
  205. if (TRUE == fTemp)
  206. {
  207. gpWizardState->fNeedReboot = TRUE;
  208. }
  209. }
  210. DWORD dwSaveErr = 0;
  211. if ( g_fAcctMgrUILoaded && gpImnApprentice )
  212. {
  213. CONNECTINFO myConnectInfo;
  214. myConnectInfo.cbSize = sizeof( CONNECTINFO );
  215. #ifdef UNICODE
  216. wcstombs(myConnectInfo.szConnectoid, TEXT("Uninitialized\0"), MAX_PATH);
  217. #else
  218. lstrcpy( myConnectInfo.szConnectoid, TEXT("Uninitialized\0"));
  219. #endif
  220. myConnectInfo.type = gpUserInfo->uiConnectionType;
  221. if( CONNECT_RAS == myConnectInfo.type )
  222. {
  223. #ifdef UNICODE
  224. wcstombs(myConnectInfo.szConnectoid, gpUserInfo->szISPName, MAX_PATH);
  225. #else
  226. lstrcpy( myConnectInfo.szConnectoid, gpUserInfo->szISPName);
  227. #endif
  228. }
  229. gpImnApprentice->SetConnectionInformation( &myConnectInfo );
  230. gpImnApprentice->Save( g_pCICWExtension->m_hWizardHWND, &dwSaveErr );
  231. if( ERR_MAIL_ACCT & dwSaveErr )
  232. {
  233. DEBUGMSG(TEXT("gpImnApprentice->Save returned with ERR_MAIL_ACCT!"));
  234. }
  235. if( ERR_NEWS_ACCT & dwSaveErr )
  236. {
  237. DEBUGMSG(TEXT("gpImnApprentice->Save returned with ERR_NEWS_ACCT!"));
  238. }
  239. if( ERR_DIRSERV_ACCT & dwSaveErr )
  240. {
  241. DEBUGMSG("gpImnApprentice->Save returned with ERR_DIR_SERV_ACCT!");
  242. }
  243. }
  244. // If we just completed the manual path (not just mail or news) then
  245. // set the registry key saying that we completed ICW.
  246. if ( !(gpWizardState->dwRunFlags & RSW_APPRENTICE) )
  247. {
  248. RegEntry re(szRegPathICWSettings,HKEY_CURRENT_USER);
  249. if (ERROR_SUCCESS == re.GetError())
  250. re.SetValue(szRegValICWCompleted, (DWORD)1);
  251. }
  252. return TRUE;
  253. }