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.

145 lines
4.4 KiB

  1. //
  2. // SECZONES.CPP
  3. //
  4. #include "pch.h"
  5. INT_PTR CALLBACK SecurityZonesDlgProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
  6. {
  7. switch (uMsg)
  8. {
  9. case WM_INITDIALOG:
  10. CheckRadioButton(hDlg, IDC_NOZONES, IDC_IMPORTZONES, IDC_NOZONES);
  11. DisableDlgItem(hDlg, IDC_MODIFYZONES);
  12. CheckRadioButton(hDlg, IDC_NORAT, IDC_IMPORTRAT, IDC_NORAT);
  13. DisableDlgItem(hDlg, IDC_MODIFYRAT);
  14. return TRUE;
  15. case UM_SAVE:
  16. {
  17. TCHAR szSecWorkDir[MAX_PATH];
  18. TCHAR szSecZonesInf[MAX_PATH];
  19. TCHAR szRatingsInf[MAX_PATH];
  20. HCURSOR hOldCur;
  21. BOOL fCheckDirtyOnly = (BOOL) lParam;
  22. hOldCur = SetCursor(LoadCursor(NULL, IDC_WAIT));
  23. // prepare the work dir where the SECZONES.INF would temporarily get copied to
  24. PathCombine(szSecWorkDir, g_szWorkDir, TEXT("seczones.wrk"));
  25. PathCombine(szSecZonesInf, szSecWorkDir, TEXT("seczones.inf"));
  26. if (IsDlgButtonChecked(hDlg, IDC_IMPORTZONES) == BST_CHECKED)
  27. {
  28. if (!fCheckDirtyOnly)
  29. {
  30. ImportZones(g_szInsFile, NULL, szSecZonesInf, TRUE);
  31. CheckRadioButton(hDlg, IDC_NOZONES, IDC_IMPORTZONES, IDC_NOZONES);
  32. DisableDlgItem(hDlg, IDC_MODIFYZONES);
  33. }
  34. g_fInsDirty = TRUE;
  35. }
  36. // prepare the work dir where the RATINGS.INF would temporarily get copied to
  37. PathCombine(szSecWorkDir, g_szWorkDir, TEXT("ratings.wrk"));
  38. PathCombine(szRatingsInf, szSecWorkDir, TEXT("ratings.inf"));
  39. if (IsDlgButtonChecked(hDlg, IDC_IMPORTRAT) == BST_CHECKED)
  40. {
  41. if (!fCheckDirtyOnly)
  42. {
  43. ImportRatings(g_szInsFile, NULL, szRatingsInf, TRUE);
  44. CheckRadioButton(hDlg, IDC_NORAT, IDC_IMPORTRAT, IDC_NORAT);
  45. DisableDlgItem(hDlg, IDC_MODIFYRAT);
  46. }
  47. g_fInsDirty = TRUE;
  48. }
  49. SetCursor(hOldCur);
  50. }
  51. *((LPBOOL)wParam) = TRUE;
  52. break;
  53. case WM_CLOSE:
  54. DestroyWindow(hDlg);
  55. break;
  56. case WM_COMMAND:
  57. switch (wParam)
  58. {
  59. case IDC_NOZONES:
  60. DisableDlgItem(hDlg, IDC_MODIFYZONES);
  61. return TRUE;
  62. case IDC_IMPORTZONES:
  63. EnableDlgItem(hDlg, IDC_MODIFYZONES);
  64. return TRUE;
  65. case IDC_MODIFYZONES:
  66. ModifyZones(hDlg);
  67. SetFocus(GetDlgItem(hDlg, IDC_MODIFYZONES));
  68. return TRUE;
  69. case IDC_NORAT:
  70. DisableDlgItem(hDlg, IDC_MODIFYRAT);
  71. return TRUE;
  72. case IDC_IMPORTRAT:
  73. EnableDlgItem(hDlg, IDC_MODIFYRAT);
  74. return TRUE;
  75. case IDC_MODIFYRAT:
  76. ModifyRatings(hDlg);
  77. SetFocus(GetDlgItem(hDlg, IDC_MODIFYRAT));
  78. return TRUE;
  79. }
  80. break;
  81. }
  82. return FALSE;
  83. }
  84. HRESULT ZonesFinalCopy(LPCTSTR pcszDestDir, DWORD dwFlags, LPDWORD pdwCabState)
  85. {
  86. TCHAR szFrom[MAX_PATH];
  87. if ((HasFlag(dwFlags, PM_CHECK) && pdwCabState != NULL) || HasFlag(dwFlags, PM_COPY))
  88. {
  89. TCHAR szFile[MAX_PATH];
  90. // move seczones.inf to pcszDestDir
  91. PathCombine(szFrom, g_szWorkDir, TEXT("seczones.wrk"));
  92. PathCombine(szFile, szFrom, TEXT("seczones.inf"));
  93. if (HasFlag(dwFlags, PM_CHECK) && pdwCabState != NULL && PathFileExists(szFile))
  94. SetFlag(pdwCabState, CAB_TYPE_CONFIG);
  95. if (HasFlag(dwFlags, PM_COPY))
  96. CopyFileToDir(szFile, pcszDestDir);
  97. // move ratings.inf to pcszDestDir
  98. PathCombine(szFrom, g_szWorkDir, TEXT("ratings.wrk"));
  99. PathCombine(szFile, szFrom, TEXT("ratings.inf"));
  100. if (HasFlag(dwFlags, PM_CHECK) && pdwCabState != NULL && PathFileExists(szFile))
  101. SetFlag(pdwCabState, CAB_TYPE_CONFIG);
  102. if (HasFlag(dwFlags, PM_COPY))
  103. CopyFileToDir(szFile, pcszDestDir);
  104. }
  105. // blow away the work dirs
  106. if (HasFlag(dwFlags, PM_CLEAR))
  107. {
  108. PathCombine(szFrom, g_szWorkDir, TEXT("seczones.wrk"));
  109. PathRemovePath(szFrom);
  110. PathCombine(szFrom, g_szWorkDir, TEXT("ratings.wrk"));
  111. PathRemovePath(szFrom);
  112. }
  113. return S_OK;
  114. }