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.

231 lines
8.2 KiB

  1. #include "pmcfg.h"
  2. #include <shlobj.h>
  3. #include <shlwapi.h>
  4. DWORD g_dwEnvNameBufLen;
  5. LPTSTR g_szEnvNameBuf;
  6. LPTSTR g_szCurrEnv;
  7. LPTSTR g_szCurrDesc;
  8. TCHAR g_szDescProduction[MAX_MESSAGE];
  9. TCHAR g_szDescPreProduction[MAX_MESSAGE];
  10. TCHAR g_szDescBetaPreProduction[MAX_MESSAGE];
  11. TCHAR g_szDescOther[MAX_MESSAGE];
  12. TCHAR g_szProduction[MAX_RESOURCE];
  13. TCHAR g_szPreProduction[MAX_RESOURCE];
  14. TCHAR g_szBetaPreProduction[MAX_RESOURCE];
  15. TCHAR g_szOther[MAX_RESOURCE];
  16. // unfortunately the registry stores the environment as a string in the registry and
  17. // this string is not localized. So in the registry we use english strings and in
  18. // UI we use localized versions of these strings.
  19. WCHAR g_szEnglishProduction[] = L"Production";
  20. WCHAR g_szEnglishPreProduction[] = L"PreProduction";
  21. WCHAR g_szEnglishBetaPreProduction[] = L"BetaPreProduction";
  22. WCHAR g_szEnglishOther[] = L"Other";
  23. TCHAR g_szCurrChoice[MAX_RESOURCE];
  24. int g_iOrigChoice;
  25. int g_iCurrChoice;
  26. TCHAR g_szTempRemoteFile[INTERNET_MAX_URL_LENGTH];
  27. INT_PTR CALLBACK EnvChangeDlgProc(HWND hWndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam);
  28. BOOL EnvChange
  29. (
  30. HWND hWndDlg,
  31. LPTSTR szEnvNameBuf,
  32. DWORD dwEnvNameBufLen
  33. )
  34. {
  35. g_dwEnvNameBufLen = dwEnvNameBufLen;
  36. g_szEnvNameBuf = szEnvNameBuf;
  37. LoadString(g_hInst, IDS_PRODUCTION, g_szProduction, DIMENSION(g_szProduction));
  38. LoadString(g_hInst, IDS_PREPRODUCTION, g_szPreProduction, DIMENSION(g_szPreProduction));
  39. LoadString(g_hInst, IDS_BETAPREPRODUCTION, g_szBetaPreProduction, DIMENSION(g_szBetaPreProduction));
  40. LoadString(g_hInst, IDS_OTHER, g_szOther, DIMENSION(g_szOther));
  41. LoadString(g_hInst, IDS_PROD_DESC, g_szDescProduction, DIMENSION(g_szDescProduction));
  42. LoadString(g_hInst, IDS_PREP_DESC, g_szDescPreProduction, DIMENSION(g_szDescPreProduction));
  43. LoadString(g_hInst, IDS_BETA_DESC, g_szDescBetaPreProduction, DIMENSION(g_szDescBetaPreProduction));
  44. LoadString(g_hInst, IDS_OTHER_DESC, g_szDescOther, DIMENSION(g_szDescOther));
  45. if(lstrcmp(g_szEnvNameBuf, g_szEnglishPreProduction) == 0)
  46. g_iOrigChoice = IDC_PREPRODUCTION;
  47. else if(lstrcmp(g_szEnvNameBuf, g_szEnglishBetaPreProduction) == 0)
  48. g_iOrigChoice = IDC_BETA_PREPRODUCTION;
  49. else if(lstrcmp(g_szEnvNameBuf, g_szEnglishOther) == 0)
  50. g_iOrigChoice = IDC_OTHER;
  51. else // must be Production
  52. g_iOrigChoice = IDC_PRODUCTION;
  53. if (IDOK == DialogBox( g_hInst,
  54. MAKEINTRESOURCE (IDD_ENV_CHANGE),
  55. hWndDlg,
  56. EnvChangeDlgProc ))
  57. return TRUE;
  58. else
  59. return FALSE;
  60. }
  61. INT_PTR CALLBACK EnvChangeDlgProc(HWND hWndDlg, UINT message, WPARAM wParam,
  62. LPARAM lParam)
  63. {
  64. switch (message)
  65. {
  66. case WM_INITDIALOG:
  67. CheckRadioButton(
  68. hWndDlg, // handle to dialog box
  69. IDC_PRODUCTION, // identifier of first button in group
  70. IDC_OTHER, // identifier of last button in group
  71. g_iOrigChoice // identifier of button to select
  72. );
  73. g_iCurrChoice = g_iOrigChoice;
  74. if (g_iCurrChoice == IDC_PREPRODUCTION)
  75. g_szCurrDesc = g_szDescPreProduction;
  76. else if(g_iCurrChoice == IDC_BETA_PREPRODUCTION)
  77. g_szCurrDesc = g_szDescBetaPreProduction;
  78. else if(g_iCurrChoice == IDC_OTHER)
  79. g_szCurrDesc = g_szDescOther;
  80. else
  81. g_szCurrDesc = g_szDescProduction;
  82. SetDlgItemText(hWndDlg, IDC_DESC, g_szCurrDesc);
  83. // Remote File
  84. if (g_iCurrChoice == IDC_OTHER)
  85. {
  86. EnableWindow(GetDlgItem(hWndDlg, IDC_REMOTEFILE), TRUE);
  87. SetDlgItemText(hWndDlg, IDC_REMOTEFILE, g_CurrentSettings.szRemoteFile);
  88. SendDlgItemMessage(hWndDlg, IDC_REMOTEFILE, EM_SETLIMITTEXT, INTERNET_MAX_URL_LENGTH -1, 0l);
  89. lstrcpy(g_szTempRemoteFile, g_CurrentSettings.szRemoteFile);
  90. }
  91. else
  92. {
  93. EnableWindow(GetDlgItem(hWndDlg, IDC_REMOTEFILE), FALSE);
  94. }
  95. break;
  96. case WM_COMMAND:
  97. switch (LOWORD(wParam))
  98. {
  99. case IDC_MOREINFO:
  100. {
  101. TCHAR szURL[MAX_PATH];
  102. lstrcpy(szURL, _T("http://www.passport.com/devinfo/Setup_Environments.asp"));
  103. ShellExecute(hWndDlg, _T("open"), szURL, NULL, NULL, 0);
  104. return TRUE;
  105. }
  106. case IDOK:
  107. {
  108. // Same choice. Do nothing
  109. if (g_iCurrChoice == g_iOrigChoice &&
  110. !(g_iCurrChoice == IDC_OTHER && lstrcmpi(g_CurrentSettings.szRemoteFile, g_szTempRemoteFile) != 0) )
  111. {
  112. EndDialog( hWndDlg, TRUE );
  113. return TRUE;
  114. }
  115. else // different choice
  116. {
  117. if (g_iCurrChoice == IDC_PREPRODUCTION)
  118. g_szCurrEnv = g_szEnglishPreProduction;
  119. else if(g_iCurrChoice == IDC_BETA_PREPRODUCTION)
  120. g_szCurrEnv = g_szEnglishBetaPreProduction;
  121. else if(g_iCurrChoice == IDC_OTHER)
  122. g_szCurrEnv = g_szEnglishOther;
  123. else // default
  124. g_szCurrEnv = g_szEnglishProduction;
  125. // update curr RemoteFile and EnvName
  126. if (ReadRegRemoteFile(hWndDlg, g_CurrentSettings.szRemoteFile, g_szRemoteComputer, g_szCurrEnv))
  127. lstrcpy(g_CurrentSettings.szEnvName, g_szCurrEnv);
  128. // get RemoteFile for Other
  129. if (g_iCurrChoice == IDC_OTHER && lstrcmpi(g_CurrentSettings.szRemoteFile, g_szTempRemoteFile) != 0 )
  130. {
  131. lstrcpy(g_CurrentSettings.szRemoteFile, g_szTempRemoteFile);
  132. lstrcpy(g_CurrentSettings.szEnvName, g_szCurrEnv);
  133. }
  134. else if (g_iCurrChoice == IDC_OTHER)
  135. {
  136. EndDialog( hWndDlg, TRUE );
  137. return TRUE;
  138. }
  139. EndDialog( hWndDlg, TRUE );
  140. return TRUE;
  141. }
  142. }
  143. case IDCANCEL:
  144. {
  145. EndDialog( hWndDlg, FALSE );
  146. return TRUE;
  147. }
  148. case IDC_REMOTEFILE:
  149. switch (HIWORD(wParam))
  150. {
  151. case EN_CHANGE:
  152. // Get the updated Value
  153. GetDlgItemText(hWndDlg,
  154. IDC_REMOTEFILE,
  155. g_szTempRemoteFile,
  156. g_CurrentSettings.cbRemoteFile);
  157. break;
  158. case EN_MAXTEXT:
  159. {
  160. ReportControlMessage(hWndDlg, LOWORD(wParam), VALIDATION_ERROR);
  161. break;
  162. }
  163. }
  164. break;
  165. }
  166. if (HIWORD(wParam) == BN_CLICKED)
  167. {
  168. switch (LOWORD(wParam))
  169. {
  170. case IDC_PRODUCTION:
  171. case IDC_PREPRODUCTION:
  172. case IDC_BETA_PREPRODUCTION:
  173. EnableWindow(GetDlgItem(hWndDlg, IDC_REMOTEFILE), FALSE);
  174. g_szTempRemoteFile[0] = '\0';
  175. SetDlgItemText(hWndDlg, IDC_REMOTEFILE, g_szTempRemoteFile);
  176. g_iCurrChoice = LOWORD(wParam);
  177. break;
  178. case IDC_OTHER:
  179. EnableWindow(GetDlgItem(hWndDlg, IDC_REMOTEFILE), TRUE);
  180. SendDlgItemMessage(hWndDlg, IDC_REMOTEFILE, EM_SETLIMITTEXT, INTERNET_MAX_URL_LENGTH -1, 0l);
  181. if (ReadRegRemoteFile(hWndDlg, g_szTempRemoteFile, g_szRemoteComputer, g_szEnglishOther))
  182. SetDlgItemText(hWndDlg, IDC_REMOTEFILE, g_szTempRemoteFile);
  183. g_iCurrChoice = LOWORD(wParam);
  184. break;
  185. }
  186. if (g_iCurrChoice == IDC_PREPRODUCTION)
  187. g_szCurrDesc = g_szDescPreProduction;
  188. else if(g_iCurrChoice == IDC_BETA_PREPRODUCTION)
  189. g_szCurrDesc = g_szDescBetaPreProduction;
  190. else if(g_iCurrChoice == IDC_OTHER)
  191. g_szCurrDesc = g_szDescOther;
  192. else
  193. g_szCurrDesc = g_szDescProduction;
  194. SetDlgItemText(hWndDlg, IDC_DESC, g_szCurrDesc);
  195. }
  196. }
  197. return FALSE; // did not process a message
  198. UNREFERENCED_PARAMETER(lParam);
  199. }