author | Dan |
Sat, 11 Jul 2009 10:07:32 -0400 | |
changeset 3 | 0cce88c7cf7c |
parent 2 | 0c0d5dadfca3 |
child 10 | 014d58335b6d |
permissions | -rw-r--r-- |
0 | 1 |
!macro ShowRange hwnd low high value |
2 |
!define tmp_id ${__LINE__} |
|
3 |
StrCpy $R0 ${low} |
|
4 |
loop.${tmp_id}: |
|
5 |
GetDlgItem $R1 ${hwnd} $R0 |
|
6 |
ShowWindow $R1 ${value} |
|
7 |
IntOp $R0 $R0 + 1 |
|
8 |
IntCmp $R0 ${high} loop.${tmp_id} loop.${tmp_id} |
|
9 |
||
10 |
!undef tmp_id |
|
11 |
!macroend |
|
12 |
!define ShowRange "!insertmacro ShowRange" |
|
13 |
||
14 |
Page custom DatabaseConfigCreate DatabaseConfigLeave " - Database configuration" |
|
15 |
||
16 |
Function DatabaseConfigCreate |
|
17 |
StrCmp $XPUI_ABORTED 1 0 +2 |
|
18 |
Return |
|
19 |
!insertmacro XPUI_INSTALLOPTIONS_EXTRACT_AS "pages\DatabaseConfig.ini" "DatabaseConfig.ini" |
|
20 |
!insertmacro XPUI_HEADER_TEXT "Database configuration" "Configure how $(^Name) will access your database." |
|
21 |
WriteINIStr "$PLUGINSDIR\DatabaseConfig.ini" "Field 9" "Text" \ |
|
22 |
"$(^Name) needs database access to work properly. Setup can create a database for you if you provide \ |
|
23 |
$db_dbmsname's administration password, or you can choose to enter credentials for a database that already exists." |
|
3 | 24 |
|
25 |
StrCpy $R2 0 ; Hide manual credential items |
|
26 |
StrCpy $R3 0 ; Hide root password/set manual to disabled |
|
27 |
||
28 |
; if the back button was clicked we might have use manual checked |
|
29 |
ReadINIStr $0 "$PLUGINSDIR\DatabaseConfig.ini" "Field 3" "State" |
|
30 |
IntCmp $0 1 UseManualIsOn |
|
31 |
||
32 |
StrCpy $R2 1 |
|
33 |
||
34 |
UseManualIsOn: |
|
35 |
||
36 |
; do we need to disable the checkbox? |
|
37 |
ReadINIStr $0 "$PLUGINSDIR\DatabaseConfig.ini" "Field 2" "State" |
|
38 |
IntCmp $0 1 0 ShowDialog ShowDialog |
|
39 |
||
40 |
StrCpy $R3 1 |
|
41 |
||
42 |
ShowDialog: |
|
43 |
||
0 | 44 |
!insertmacro XPUI_INSTALLOPTIONS_INITDIALOG "DatabaseConfig.ini" |
45 |
Pop $XPUI_HWND |
|
3 | 46 |
|
47 |
IntCmp $R2 1 "" SkipHideManual |
|
48 |
||
49 |
${ShowRange} $XPUI_HWND 1204 1207 ${SW_HIDE} |
|
50 |
${ShowRange} $XPUI_HWND 1210 1213 ${SW_HIDE} |
|
51 |
||
52 |
SkipHideManual: |
|
53 |
||
54 |
IntCmp $R3 1 "" SkipForceManual |
|
0 | 55 |
|
3 | 56 |
; check the box and disable |
57 |
GetDlgItem $0 $XPUI_HWND 1202 |
|
58 |
SendMessage $0 ${BM_SETCHECK} ${BST_CHECKED} 0 |
|
59 |
EnableWindow $0 0 |
|
60 |
||
61 |
; hide the root password, enter manually is selected |
|
62 |
GetDlgItem $0 $XPUI_HWND 1203 |
|
63 |
ShowWindow $0 ${SW_HIDE} |
|
64 |
GetDlgItem $0 $XPUI_HWND 1209 |
|
65 |
ShowWindow $0 ${SW_HIDE} |
|
0 | 66 |
|
3 | 67 |
SkipForceManual: |
68 |
||
0 | 69 |
!insertmacro XPUI_INSTALLOPTIONS_SHOW |
70 |
FunctionEnd |
|
71 |
||
72 |
Function DatabaseConfigLeave |
|
73 |
StrCmp $XPUI_ABORTED 1 0 +2 |
|
74 |
Return |
|
75 |
||
76 |
ReadINIStr $0 "$PLUGINSDIR\DatabaseConfig.ini" "Settings" "State" |
|
77 |
StrCmp $0 1 RadioButtonClicked |
|
78 |
StrCmp $0 2 RadioButtonClicked |
|
79 |
StrCmp $0 3 UseManualClicked |
|
80 |
Goto NextClicked |
|
81 |
||
82 |
RadioButtonClicked: |
|
83 |
LockWindow on |
|
84 |
ReadINIStr $0 "$PLUGINSDIR\DatabaseConfig.ini" "Field 1" "State" |
|
85 |
IntCmp $0 0 SetUseExisting |
|
86 |
||
87 |
; Show root password |
|
88 |
GetDlgItem $0 $XPUI_HWND 1203 |
|
89 |
ShowWindow $0 ${SW_SHOW} |
|
90 |
GetDlgItem $0 $XPUI_HWND 1209 |
|
91 |
ShowWindow $0 ${SW_SHOW} |
|
92 |
||
93 |
GetDlgItem $0 $XPUI_HWND 1202 ; Checkbox |
|
94 |
SendMessage $0 ${BM_SETCHECK} ${BST_UNCHECKED} 0 |
|
95 |
EnableWindow $0 1 |
|
96 |
${ShowRange} $XPUI_HWND 1204 1207 ${SW_HIDE} |
|
97 |
${ShowRange} $XPUI_HWND 1210 1213 ${SW_HIDE} |
|
98 |
LockWindow off |
|
99 |
Abort |
|
100 |
||
101 |
SetUseExisting: |
|
102 |
||
103 |
; Hide root password |
|
104 |
GetDlgItem $0 $XPUI_HWND 1203 |
|
105 |
ShowWindow $0 ${SW_HIDE} |
|
106 |
GetDlgItem $0 $XPUI_HWND 1209 |
|
107 |
ShowWindow $0 ${SW_HIDE} |
|
108 |
||
109 |
GetDlgItem $0 $XPUI_HWND 1202 ; Checkbox |
|
110 |
SendMessage $0 ${BM_SETCHECK} ${BST_CHECKED} 0 |
|
111 |
EnableWindow $0 0 |
|
112 |
${ShowRange} $XPUI_HWND 1204 1207 ${SW_SHOW} |
|
113 |
${ShowRange} $XPUI_HWND 1210 1213 ${SW_SHOW} |
|
114 |
LockWindow off |
|
115 |
Abort |
|
116 |
||
117 |
UseManualClicked: |
|
118 |
ReadINIStr $0 "$PLUGINSDIR\DatabaseConfig.ini" "Field 3" "State" |
|
119 |
IntOp $0 $0 * ${SW_SHOW} |
|
120 |
${ShowRange} $XPUI_HWND 1204 1207 $0 |
|
121 |
${ShowRange} $XPUI_HWND 1210 1213 $0 |
|
122 |
Abort |
|
123 |
||
124 |
NextClicked: |
|
125 |
||
126 |
; Figure out how we want to go about this. |
|
127 |
StrCpy $db_needroot 0 |
|
128 |
ReadINIStr $0 "$PLUGINSDIR\DatabaseConfig.ini" "Field 1" "State" |
|
129 |
IntCmp $0 0 UseCustomLogin |
|
130 |
||
131 |
; Validate based on root password. |
|
132 |
StrCpy $db_needroot 1 |
|
133 |
ReadINIStr $db_rootpass "$PLUGINSDIR\DatabaseConfig.ini" "Field 4" "State" |
|
134 |
${db_connect} $1 "$db_rootuser" "$db_rootpass" |
|
135 |
IntCmp $1 0 +3 |
|
136 |
MessageBox MB_OK|MB_ICONEXCLAMATION "The $db_dbmsname root password you entered is incorrect. Please re-enter it." |
|
137 |
Abort |
|
138 |
||
139 |
; Does the user have their own credentials? |
|
140 |
ReadINIStr $0 "$PLUGINSDIR\DatabaseConfig.ini" "Field 3" "State" |
|
141 |
IntCmp $0 0 GenerateRandomLogin |
|
142 |
||
143 |
UseCustomLogin: |
|
144 |
||
145 |
; Pull database settings from dialog |
|
146 |
ReadINIStr $db_name "$PLUGINSDIR\DatabaseConfig.ini" "Field 5" "State" |
|
147 |
ReadINIStr $db_user "$PLUGINSDIR\DatabaseConfig.ini" "Field 6" "State" |
|
148 |
ReadINIStr $db_password "$PLUGINSDIR\DatabaseConfig.ini" "Field 7" "State" |
|
149 |
ReadINIStr $R0 "$PLUGINSDIR\DatabaseConfig.ini" "Field 8" "State" |
|
150 |
||
151 |
; Check password length |
|
152 |
; but don't if the user entered credentials that already exist |
|
153 |
IntCmp $db_needroot 0 SkipLengthCheck |
|
154 |
StrLen $R1 $R0 |
|
155 |
IntCmp $R1 6 +3 0 +3 |
|
156 |
MessageBox MB_OK|MB_ICONEXCLAMATION "Please choose a database password that is at least 6 characters in length." |
|
157 |
Abort |
|
158 |
||
159 |
SkipLengthCheck: |
|
160 |
; Check password/confirm fields |
|
161 |
StrCmp $db_password $R0 +3 |
|
162 |
MessageBox MB_OK|MB_ICONEXCLAMATION "The passwords you entered do not match. Please enter them again." |
|
163 |
Abort |
|
164 |
||
165 |
; If we're root, we can assume the login doesn't exist yet, so skip the validation |
|
2
0c0d5dadfca3
Added LockWindow calls to all custom page exit paths to smooth transitions
Dan
parents:
0
diff
changeset
|
166 |
IntCmp $db_needroot 0 +3 |
0c0d5dadfca3
Added LockWindow calls to all custom page exit paths to smooth transitions
Dan
parents:
0
diff
changeset
|
167 |
LockWindow on |
0 | 168 |
Return |
169 |
||
170 |
${db_connect} $R0 $db_user $db_password |
|
171 |
IntCmp $R0 0 +3 |
|
172 |
; Database auth failed |
|
173 |
MessageBox MB_OK|MB_ICONEXCLAMATION "The username and password you entered are invalid. Please enter them again." |
|
174 |
Abort |
|
175 |
||
176 |
; This can be an error-prone process because entering credentials manually will keep |
|
177 |
; the installer from touching the database. If tables already exist, Enano's installer |
|
178 |
; will throw an error. Confirm this with the user. |
|
179 |
MessageBox MB_YESNO|MB_ICONQUESTION "Do you really want to use manual database settings?$\r$\n\ |
|
180 |
$\r$\n\ |
|
181 |
Setup will not attempt to modify your existing database. If there is \ |
|
182 |
already an installation of $(^Name) in the database, the installer will \ |
|
183 |
fail. This option is recommended only for advanced users." IDYES +2 |
|
184 |
Abort ; on No |
|
185 |
||
2
0c0d5dadfca3
Added LockWindow calls to all custom page exit paths to smooth transitions
Dan
parents:
0
diff
changeset
|
186 |
LockWindow on |
0 | 187 |
Return |
188 |
||
189 |
GenerateRandomLogin: |
|
190 |
StrCpy $db_name "bn_enanocms" |
|
191 |
StrCpy $db_user "bn_enanocms" |
|
192 |
Call GenerateRandomPassword |
|
193 |
Pop $db_password |
|
2
0c0d5dadfca3
Added LockWindow calls to all custom page exit paths to smooth transitions
Dan
parents:
0
diff
changeset
|
194 |
LockWindow on |
0 | 195 |
Return |
196 |
||
197 |
FunctionEnd |
|
198 |
||
199 |
Function GenerateRandomPassword |
|
200 |
SetOutPath $PLUGINSDIR |
|
201 |
File "inst-resources\randompass.php" |
|
202 |
nsExec::ExecToStack '"$stack_instdir\php\php.exe" "$PLUGINSDIR\randompass.php"' |
|
203 |
Pop $R0 |
|
204 |
FunctionEnd |