LicenseDialog.cpp 9.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218
  1. /*
  2. ** Command & Conquer Renegade(tm)
  3. ** Copyright 2025 Electronic Arts Inc.
  4. **
  5. ** This program is free software: you can redistribute it and/or modify
  6. ** it under the terms of the GNU General Public License as published by
  7. ** the Free Software Foundation, either version 3 of the License, or
  8. ** (at your option) any later version.
  9. **
  10. ** This program is distributed in the hope that it will be useful,
  11. ** but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. ** GNU General Public License for more details.
  14. **
  15. ** You should have received a copy of the GNU General Public License
  16. ** along with this program. If not, see <http://www.gnu.org/licenses/>.
  17. */
  18. /***********************************************************************************************
  19. *** Confidential - Westwood Studios ***
  20. ***********************************************************************************************
  21. * *
  22. * Project Name : Installer *
  23. * *
  24. * $Archive:: /Commando/Code/Installer/LicenseDialog.cp $*
  25. * *
  26. * $Author:: Ian_l $*
  27. * *
  28. * $Modtime:: 12/04/01 5:17p $*
  29. * *
  30. * $Revision:: 7 $*
  31. * *
  32. *---------------------------------------------------------------------------------------------*
  33. * Functions: *
  34. * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
  35. // Includes.
  36. #include "LicenseDialog.h"
  37. #include "CheckBoxCtrl.h"
  38. #include "ErrorHandler.h"
  39. #include "MessageBox.h"
  40. #include "Resource.h"
  41. #include "Translator.h"
  42. /***********************************************************************************************
  43. * LicenseDialogClass::On_Init_Dialog -- *
  44. * *
  45. * INPUT: *
  46. * *
  47. * OUTPUT: *
  48. * *
  49. * WARNINGS: *
  50. * *
  51. * HISTORY: *
  52. * 08/22/01 IML : Created. *
  53. *=============================================================================================*/
  54. void LicenseDialogClass::On_Init_Dialog (void)
  55. {
  56. Load_License ("License.txt");
  57. // Set initial check text to 'agree' but uncheck it so that the user must consiously check it.
  58. #if NDEBUG
  59. Check_Dlg_Button (IDC_LICENSE_CHECK, false);
  60. #else
  61. Check_Dlg_Button (IDC_LICENSE_CHECK, true);
  62. #endif
  63. Set_Dlg_Item_Text (IDC_LICENSE_CHECK, TxWideStringClass (IDS_AGREE_TO_TERMS));
  64. InstallMenuDialogClass::On_Init_Dialog();
  65. }
  66. /***********************************************************************************************
  67. * LicenseDialogClass::Load_License -- *
  68. * *
  69. * INPUT: *
  70. * *
  71. * OUTPUT: *
  72. * *
  73. * WARNINGS: *
  74. * *
  75. * HISTORY: *
  76. * 08/22/01 IML : Created. *
  77. *=============================================================================================*/
  78. void LicenseDialogClass::Load_License (const char *licensefilename)
  79. {
  80. HANDLE file;
  81. BY_HANDLE_FILE_INFORMATION fileinformation;
  82. // Load up the license agreement text.
  83. // NOTE: This agreement should be in Unicode.
  84. file = CreateFile (licensefilename, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0L, NULL);
  85. // If the file exists...
  86. if (file != INVALID_HANDLE_VALUE) {
  87. if (!GetFileInformationByHandle (file, &fileinformation)) FATAL_SYSTEM_ERROR;
  88. // Does header exist?
  89. if ((fileinformation.nFileSizeHigh == 0) && (fileinformation.nFileSizeLow >= sizeof (WCHAR))) {
  90. int length;
  91. unsigned long bytesreadcount;
  92. WCHAR *buffer;
  93. length = fileinformation.nFileSizeLow / sizeof (WCHAR);
  94. buffer = new WCHAR [length + 1];
  95. if (ReadFile (file, buffer, length * sizeof (WCHAR), &bytesreadcount, NULL)) {
  96. unsigned s, d;
  97. buffer [length] = L'\0';
  98. // Advance past header.
  99. s = 1;
  100. // Strip 0x000D characters from the license text - they're not parsed as carriage return by the multi-line edit control.
  101. d = 0;
  102. while (true) {
  103. if (buffer [s] != 0x000D) {
  104. buffer [d] = buffer [s];
  105. d++;
  106. }
  107. if (buffer [s] == 0x000) break;
  108. s++;
  109. }
  110. Set_Dlg_Item_Text (IDC_LICENSE_EDIT, buffer);
  111. }
  112. delete [] buffer;
  113. }
  114. if (!CloseHandle (file)) FATAL_SYSTEM_ERROR;
  115. }
  116. }
  117. /***********************************************************************************************
  118. * LicenseDialogClass::On_Command -- *
  119. * *
  120. * INPUT: *
  121. * *
  122. * OUTPUT: *
  123. * *
  124. * WARNINGS: *
  125. * *
  126. * HISTORY: *
  127. * 08/22/01 IML : Created. *
  128. *=============================================================================================*/
  129. void LicenseDialogClass::On_Command (int ctrl_id, int message_id, DWORD param)
  130. {
  131. switch (ctrl_id)
  132. {
  133. case IDC_LICENSE_CHECK:
  134. {
  135. CheckBoxCtrlClass *check = Get_Dlg_Item (IDC_LICENSE_CHECK)->As_CheckBoxCtrlClass();
  136. if (check->Get_Check()) {
  137. check->Set_Text (TxWideStringClass (IDS_AGREE_TO_TERMS));
  138. } else {
  139. check->Set_Text (TxWideStringClass (IDS_NOT_AGREE_TO_TERMS));
  140. }
  141. break;
  142. }
  143. case IDOK:
  144. {
  145. CheckBoxCtrlClass *check = Get_Dlg_Item (IDC_LICENSE_CHECK)->As_CheckBoxCtrlClass();
  146. if (!check->Get_Check()) {
  147. MessageBoxClass::Do_Dialog (TxWideStringClass (IDS_WARNING), TxWideStringClass (IDS_MUST_ACCEPT), MessageBoxClass::MESSAGE_BOX_TYPE_OK);
  148. return;
  149. } else {
  150. break;
  151. }
  152. }
  153. default:
  154. break;
  155. }
  156. InstallMenuDialogClass::On_Command (ctrl_id, message_id, param);
  157. }
  158. /***********************************************************************************************
  159. * NDADialogClass::On_Init_Dialog -- *
  160. * *
  161. * INPUT: *
  162. * *
  163. * OUTPUT: *
  164. * *
  165. * WARNINGS: *
  166. * *
  167. * HISTORY: *
  168. * 08/22/01 IML : Created. *
  169. *=============================================================================================*/
  170. void NDADialogClass::On_Init_Dialog (void)
  171. {
  172. Load_License ("NDA.txt");
  173. Set_Dlg_Item_Text (IDC_LICENSE_HEADING, RxWideStringClass (IDS_NON_DISCLOSURE_AGREEMENT));
  174. Set_Dlg_Item_Text (IDC_LICENSE_QUERY, RxWideStringClass (IDS_AGREE_TO_NDA));
  175. // Set initial check text to 'agree' but uncheck it so that the user must consiously check it.
  176. #if NDEBUG
  177. Check_Dlg_Button (IDC_LICENSE_CHECK, false);
  178. #else
  179. Check_Dlg_Button (IDC_LICENSE_CHECK, true);
  180. #endif
  181. Set_Dlg_Item_Text (IDC_LICENSE_CHECK, TxWideStringClass (IDS_AGREE_TO_TERMS));
  182. InstallMenuDialogClass::On_Init_Dialog();
  183. }