Rev 179 | Rev 186 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 179 | Rev 185 | ||
---|---|---|---|
Line 6... | Line 6... | ||
6 | // dialog template |
6 | // dialog template |
7 | #define THIS_DIALOG DIALOG_REGISTER |
7 | #define THIS_DIALOG DIALOG_REGISTER |
8 | 8 | ||
9 | 9 | ||
10 | // global variables used in this module only |
10 | // global variables used in this module only |
11 | static wchar_t |
11 | static wchar_t transaction_uuid[128] = L""; |
12 | static unsigned __int32 candidate_code = 0; // 32 bits |
- | |
13 | static bool was_donatebutton_clicked = false; |
12 | static bool was_donatebutton_clicked = false; |
- | 13 | static HWND hThisDialogWnd = NULL; |
|
14 | 14 | ||
15 | 15 | ||
16 | // prototypes of local functions |
16 | // prototypes of local functions |
- | 17 | static void RegistrationCheckThread (void *thread_parms); |
|
17 | static int CALLBACK DialogProc_ThisDialog (HWND hWnd, unsigned int message, WPARAM wParam, LPARAM lParam); |
18 | static int CALLBACK DialogProc_ThisDialog (HWND hWnd, unsigned int message, WPARAM wParam, LPARAM lParam); |
18 | static |
19 | static bool RetrieveActivationCode (wchar_t *candidate_email_or_uuid, unsigned int *returned_code, wchar_t **returned_email, wchar_t **failure_reason); |
19 | 20 | ||
20 | 21 | ||
21 | void DialogBox_Registration (void) |
22 | void DialogBox_Registration (void) |
22 | { |
23 | { |
23 | // helper function to fire up the modal dialog box |
24 | // helper function to fire up the modal dialog box |
- | 25 | ||
- | 26 | // first, test if our server is reachable. We DO NOT want the user to donate if our server isn't here to receive the donation! |
|
- | 27 | if (!RetrieveActivationCode (NULL, NULL, NULL, NULL)) |
|
- | 28 | return; // if it's not, don't display anything |
|
- | 29 | ||
- | 30 | // generate a random transaction UUID for this session |
|
- | 31 | srand ((unsigned int) time (NULL)); |
|
- | 32 | swprintf_s (transaction_uuid, sizeof (transaction_uuid), L"%04x%04x-%04x-%04x-%04x-%04x%04x%04x", rand (), rand (), rand (), (rand () & 0x0fff) | 0x4000, (rand () & 0x3fff) | 0x8000, rand (), rand (), rand ()); |
|
- | 33 | ||
- | 34 | // start a new thread that will ask every 10 seconds if our transaction ID has donated |
|
- | 35 | _beginthread (RegistrationCheckThread, 0, NULL); // fire up the thread |
|
24 | 36 | ||
25 | // display the dialog box (set the parent to be the desktop) |
37 | // display the dialog box (set the parent to be the desktop) |
26 | DialogBox (hAppInstance, MAKEINTRESOURCE (THIS_DIALOG), NULL, DialogProc_ThisDialog); |
38 | DialogBox (hAppInstance, MAKEINTRESOURCE (THIS_DIALOG), NULL, DialogProc_ThisDialog); |
27 | 39 | ||
28 | return; // finished processing this dialog |
40 | return; // finished processing this dialog |
- | 41 | } |
|
- | 42 | ||
- | 43 | ||
- | 44 | static void RegistrationCheckThread (void *thread_parms) |
|
- | 45 | { |
|
- | 46 | // thread entrypoint for the thread that periodically checks whether transaction_uuid has just donated |
|
- | 47 | ||
- | 48 | unsigned int returned_code; // 32 bits minimum |
|
- | 49 | wchar_t *returned_email; |
|
- | 50 | ||
- | 51 | // loop endlessly |
|
- | 52 | for (;;) |
|
- | 53 | { |
|
- | 54 | // query the remote server for the code associated with this transaction UUID |
|
- | 55 | if (RetrieveActivationCode (transaction_uuid, &returned_code, &returned_email, NULL) && IsRegistrationCorrect (returned_email, returned_code)) |
|
- | 56 | break; // stop looping as soon as we get correct values |
|
- | 57 | ||
- | 58 | Sleep (10 * 1000); // next check in 10 seconds |
|
- | 59 | } |
|
- | 60 | ||
- | 61 | // the user just registered, save activation email and activation code |
|
- | 62 | wcscpy_s (options.registration.user_email, WCHAR_SIZEOF (options.registration.user_email), returned_email); |
|
- | 63 | options.registration.activation_code = returned_code; |
|
- | 64 | ||
- | 65 | if (IsWindow (hThisDialogWnd)) |
|
- | 66 | ShowWindow (hThisDialogWnd, SW_HIDE); // make the dialog box disappear |
|
- | 67 | MessageBox (NULL, LOCALIZE (L"Registration_ThankYou"), PROGRAM_NAME, MB_ICONINFORMATION | MB_OK); // display a "thank you" message |
|
- | 68 | was_donatebutton_clicked = false; // prevent the reminder dialog box to open |
|
- | 69 | if (IsWindow (hThisDialogWnd)) |
|
- | 70 | PostMessage (hThisDialogWnd, WM_CLOSE, 0, 0); // then close the dialog box |
|
- | 71 | ||
- | 72 | return; // _endthread() implied |
|
29 | } |
73 | } |
30 | 74 | ||
31 | 75 | ||
32 | static int CALLBACK DialogProc_ThisDialog (HWND hWnd, unsigned int message, WPARAM wParam, LPARAM lParam) |
76 | static int CALLBACK DialogProc_ThisDialog (HWND hWnd, unsigned int message, WPARAM wParam, LPARAM lParam) |
33 | { |
77 | { |
Line 35... | Line 79... | ||
35 | 79 | ||
36 | static wchar_t temp_string[1024]; |
80 | static wchar_t temp_string[1024]; |
37 | 81 | ||
38 | unsigned short wParam_hiword; |
82 | unsigned short wParam_hiword; |
39 | unsigned short wParam_loword; |
83 | unsigned short wParam_loword; |
- | 84 | unsigned int returned_code; // 32 bits minimum |
|
40 | wchar_t *failure_reason; |
85 | wchar_t *failure_reason; |
41 | int write_index; |
86 | int write_index; |
42 | int read_index; |
87 | int read_index; |
43 | int length; |
88 | int length; |
44 | 89 | ||
Line 47... | Line 92... | ||
47 | wParam_loword = LOWORD (wParam); |
92 | wParam_loword = LOWORD (wParam); |
48 | 93 | ||
49 | // have we just fired up this window ? |
94 | // have we just fired up this window ? |
50 | if (message == WM_INITDIALOG) |
95 | if (message == WM_INITDIALOG) |
51 | { |
96 | { |
- | 97 | hThisDialogWnd = hWnd; // save the dialog handle |
|
- | 98 | ||
52 | // center the window |
99 | // center the window |
53 | CenterWindow (hWnd, hMainWnd); |
100 | CenterWindow (hWnd, hMainWnd); |
54 | 101 | ||
55 | // set dialog icons (small one for title bar & big one for task manager) |
102 | // set dialog icons (small one for title bar & big one for task manager) |
56 | SendMessage (hWnd, WM_SETICON, ICON_SMALL, (LPARAM) LoadIcon (hAppInstance, MAKEINTRESOURCE (ICON_MAIN))); |
103 | SendMessage (hWnd, WM_SETICON, ICON_SMALL, (LPARAM) LoadIcon (hAppInstance, MAKEINTRESOURCE (ICON_MAIN))); |
Line 91... | Line 138... | ||
91 | was_donatebutton_clicked = false; // once is enough |
138 | was_donatebutton_clicked = false; // once is enough |
92 | return (true); // prevent window close this time |
139 | return (true); // prevent window close this time |
93 | } |
140 | } |
94 | else |
141 | else |
95 | EndDialog (hWnd, 0); // close the dialog box |
142 | EndDialog (hWnd, 0); // close the dialog box |
- | 143 | ||
- | 144 | hThisDialogWnd = NULL; // this window is about to no longer have a handle, so remember it |
|
96 | } |
145 | } |
97 | 146 | ||
98 | // else did we take action on one of the controls ? |
147 | // else did we take action on one of the controls ? |
99 | else if (message == WM_COMMAND) |
148 | else if (message == WM_COMMAND) |
100 | { |
149 | { |
Line 104... | Line 153... | ||
104 | 153 | ||
105 | // else did the user enter something in the edit boxes ? |
154 | // else did the user enter something in the edit boxes ? |
106 | else if (wParam_hiword == EN_CHANGE) |
155 | else if (wParam_hiword == EN_CHANGE) |
107 | { |
156 | { |
108 | // enable the validation button only if the PayPal email field has data |
157 | // enable the validation button only if the PayPal email field has data |
109 | GetDlgItemText (hWnd, EDITBOX_REGISTRATION_EMAILADDRESS, |
158 | GetDlgItemText (hWnd, EDITBOX_REGISTRATION_EMAILADDRESS, temp_string, WCHAR_SIZEOF (temp_string)); |
110 | 159 | ||
111 | // strip spaces and unprintable characters from candidate email, and bring it lowercase |
160 | // strip spaces and unprintable characters from candidate email, and bring it lowercase |
112 | length = wcslen ( |
161 | length = wcslen (temp_string); |
113 | write_index = 0; |
162 | write_index = 0; |
114 | for (read_index = 0; read_index < length; read_index++) |
163 | for (read_index = 0; read_index < length; read_index++) |
115 | if (!iswspace ( |
164 | if (!iswspace (temp_string[read_index])) |
116 | { |
165 | { |
117 |
|
166 | temp_string[write_index] = tolower (temp_string[read_index]); // force lowercase |
118 | write_index++; // keep only valid signs and discard spaces |
167 | write_index++; // keep only valid signs and discard spaces |
119 | } |
168 | } |
120 |
|
169 | temp_string[write_index] = 0; // ensure string is correctly terminated |
121 | 170 | ||
122 | EnableWindow (GetDlgItem (hWnd, BUTTON_VALIDATECODE), (( |
171 | EnableWindow (GetDlgItem (hWnd, BUTTON_VALIDATECODE), ((temp_string[0] != 0) && (wcslen (temp_string) > 5) && (wcscmp (temp_string, LOCALIZE (L"Registration_YourEmailHere")) != 0) |
123 | && (wcschr ( |
172 | && (wcschr (temp_string, L'@') != NULL) && (wcschr (temp_string, L'.') != NULL))); |
124 | } |
173 | } |
125 | 174 | ||
126 | // else was it the validation button ? |
175 | // else was it the validation button ? |
127 | else if (wParam_loword == BUTTON_VALIDATECODE) |
176 | else if (wParam_loword == BUTTON_VALIDATECODE) |
128 | { |
177 | { |
129 | // |
178 | // enable the validation button only if the PayPal email field has data |
130 |
|
179 | GetDlgItemText (hWnd, EDITBOX_REGISTRATION_EMAILADDRESS, temp_string, WCHAR_SIZEOF (temp_string)); |
131 | 180 | ||
- | 181 | // query the remote server for the code associated with this email. If it fails, ask why. |
|
132 |
|
182 | if (!RetrieveActivationCode (temp_string, &returned_code, NULL, &failure_reason) |
133 |
|
183 | || ((failure_reason != NULL) && (failure_reason[0] != 0))) |
134 | MessageBox (hWnd, failure_reason, PROGRAM_NAME, MB_ICONERROR | MB_OK); // registration failed. Display an error and DON'T make the dialog box disappear |
184 | MessageBox (hWnd, failure_reason, PROGRAM_NAME, MB_ICONERROR | MB_OK); // registration failed. Display an error and DON'T make the dialog box disappear |
135 | 185 | ||
136 | // else is the retrieved data correct ? |
186 | // else is the retrieved data correct ? |
137 | else if (IsRegistrationCorrect ( |
187 | else if (IsRegistrationCorrect (temp_string, returned_code)) |
138 | { |
188 | { |
139 | // if so, save activation email and activation code |
189 | // if so, save activation email and activation code |
140 | wcscpy_s (options.registration.user_email, WCHAR_SIZEOF (options.registration.user_email), |
190 | wcscpy_s (options.registration.user_email, WCHAR_SIZEOF (options.registration.user_email), temp_string); |
141 | options.registration.activation_code = |
191 | options.registration.activation_code = returned_code; |
142 | MessageBox (hWnd, LOCALIZE (L"Registration_ThankYou"), PROGRAM_NAME, MB_ICONINFORMATION | MB_OK); |
192 | MessageBox (hWnd, LOCALIZE (L"Registration_ThankYou"), PROGRAM_NAME, MB_ICONINFORMATION | MB_OK); |
143 | EndDialog (hWnd, 0); // then display a thank you dialog box and make the dialog box disappear |
193 | EndDialog (hWnd, 0); // then display a thank you dialog box and make the dialog box disappear |
144 | } |
194 | } |
145 | 195 | ||
146 | // else the supplied data is wrong |
196 | // else the supplied data is wrong |
Line 155... | Line 205... | ||
155 | else if (wParam_loword == BUTTON_DONATE) |
205 | else if (wParam_loword == BUTTON_DONATE) |
156 | { |
206 | { |
157 | MessageBox (hWnd, LOCALIZE (L"Registration_DontForget"), PROGRAM_NAME, MB_ICONWARNING | MB_OK); // users need to be reminded that they MUST write their email in the activation form |
207 | MessageBox (hWnd, LOCALIZE (L"Registration_DontForget"), PROGRAM_NAME, MB_ICONWARNING | MB_OK); // users need to be reminded that they MUST write their email in the activation form |
158 | 208 | ||
159 | if (wcscmp (languages[language_id].name, L"French") == 0) |
209 | if (wcscmp (languages[language_id].name, L"French") == 0) |
160 |
|
210 | wcscpy_s (temp_string, sizeof (temp_string), PAYPAL_URL_FR); // select the French PayPal page |
161 | else |
211 | else |
162 |
|
212 | wcscpy_s (temp_string, sizeof (temp_string), PAYPAL_URL_XX); // select the international (English) PayPal page |
- | 213 | wcscat_s (temp_string, sizeof (temp_string), transaction_uuid); // in all cases, append the transaction UUID that our server generated for us |
|
163 | 214 | ||
- | 215 | ShellExecute (NULL, L"open", temp_string, NULL, NULL, SW_MAXIMIZE); // open PayPal in the default browser, maximized |
|
164 | was_donatebutton_clicked = true; // remember the user clicked the Donate button |
216 | was_donatebutton_clicked = true; // remember the user clicked the Donate button |
165 | } |
217 | } |
166 | 218 | ||
167 | // else was it the status bar hyperlink ? |
219 | // else was it the status bar hyperlink ? |
168 | else if (wParam_loword == STATICTEXT_REGISTRATION_STATUSBAR) |
220 | else if (wParam_loword == STATICTEXT_REGISTRATION_STATUSBAR) |
Line 172... | Line 224... | ||
172 | // call the default dialog message processing function to keep things going |
224 | // call the default dialog message processing function to keep things going |
173 | return (false); |
225 | return (false); |
174 | } |
226 | } |
175 | 227 | ||
176 | 228 | ||
177 | static |
229 | static bool RetrieveActivationCode (wchar_t *candidate_email_or_uuid, unsigned int *returned_code, wchar_t **returned_email, wchar_t **failure_reason) |
178 | { |
230 | { |
179 | // this function queries the remote server for registration status. If OK, the |
231 | // this function queries the remote server for registration status. If OK, the function returns TRUE and |
- | 232 | // the code and email are returned in the returned_code and returned_email pointers, and failure_reason |
|
180 | // |
233 | // is set to point to a NULL string. On error, FALSE is returned and failure_reason points to the cause |
- | 234 | // of the error (localized). If candidate_email_or_uuid is a NULL string, only a server reachability test |
|
- | 235 | // is performed. |
|
- | 236 | ||
- | 237 | #define REGISTRATION_HOST "pmbaty.com" |
|
181 |
|
238 | #define REGISTRATION_SCRIPT "/chess/whatsmycode.php" |
182 | 239 | ||
183 | static char http_buffer[1024]; // used both for request and reply |
240 | static char http_buffer[1024]; // used both for request and reply |
- | 241 | static char ascii_email_or_uuid[128]; |
|
184 | static |
242 | static wchar_t wide_email[128]; |
185 | 243 | ||
186 | struct sockaddr_in service; |
244 | struct sockaddr_in service; |
187 | struct hostent *hostinfo; |
245 | struct hostent *hostinfo; |
188 | char *data_start; |
246 | char *data_start; |
189 | int write_index; |
247 | int write_index; |
190 | int read_index; |
248 | int read_index; |
191 | int length; |
249 | int length; |
192 | SOCKET s; |
250 | SOCKET s; |
193 | 251 | ||
194 | // get our distribution server's IP address from the host name |
252 | // get our distribution server's IP address from the host name |
195 | hostinfo = gethostbyname ( |
253 | hostinfo = gethostbyname (REGISTRATION_HOST); |
196 | if (hostinfo == NULL) |
254 | if (hostinfo == NULL) |
197 | { |
255 | { |
- | 256 | if (failure_reason != NULL) |
|
198 | *failure_reason = LOCALIZE (L"Registration_NetworkFailure"); |
257 | *failure_reason = LOCALIZE (L"Registration_NetworkFailure"); |
199 | return ( |
258 | return (false); // couldn't resolve hostname, return an error condition |
200 | } |
259 | } |
201 | 260 | ||
202 | // fill in the sockaddr server structure with the server hostinfo data |
261 | // fill in the sockaddr server structure with the server hostinfo data |
203 | service.sin_family = AF_INET; |
262 | service.sin_family = AF_INET; |
204 | service.sin_addr.s_addr = inet_addr (inet_ntoa (*(struct in_addr *) hostinfo->h_addr_list[0])); |
263 | service.sin_addr.s_addr = inet_addr (inet_ntoa (*(struct in_addr *) hostinfo->h_addr_list[0])); |
205 | service.sin_port = htons (80); // connect to webserver there (port 80) |
264 | service.sin_port = htons (80); // connect to webserver there (port 80) |
206 | 265 | ||
207 | // create our socket |
266 | // create our socket |
208 | if ((s = socket (AF_INET, SOCK_STREAM, IPPROTO_TCP)) == INVALID_SOCKET) |
267 | if ((s = socket (AF_INET, SOCK_STREAM, IPPROTO_TCP)) == INVALID_SOCKET) |
209 | { |
268 | { |
- | 269 | if (failure_reason != NULL) |
|
210 | *failure_reason = LOCALIZE (L"Registration_NetworkFailure"); |
270 | *failure_reason = LOCALIZE (L"Registration_NetworkFailure"); |
211 | return (0); // couldn't create socket, return an error condition |
271 | return (0); // couldn't create socket, return an error condition |
212 | } |
272 | } |
213 | 273 | ||
214 | // connect to the distributor's webserver using that socket |
274 | // connect to the distributor's webserver using that socket |
215 | if (connect (s, (struct sockaddr *) &service, sizeof (service)) == -1) |
275 | if (connect (s, (struct sockaddr *) &service, sizeof (service)) == -1) |
216 | { |
276 | { |
- | 277 | closesocket (s); |
|
- | 278 | if (failure_reason != NULL) |
|
217 | *failure_reason = LOCALIZE (L"Registration_NetworkFailure"); |
279 | *failure_reason = LOCALIZE (L"Registration_NetworkFailure"); |
218 | return (0); // unable to connect to webserver, return an error condition |
280 | return (0); // unable to connect to webserver, return an error condition |
219 | } |
281 | } |
220 | 282 | ||
221 | // build the HTTP query and send it |
283 | // build the HTTP query and send it |
- | 284 | if (candidate_email_or_uuid != NULL) |
|
222 | ConvertTo7BitASCII ( |
285 | ConvertTo7BitASCII (ascii_email_or_uuid, sizeof (ascii_email_or_uuid), candidate_email_or_uuid); |
223 | sprintf_s (http_buffer, sizeof (http_buffer), |
286 | sprintf_s (http_buffer, sizeof (http_buffer), |
224 | "GET |
287 | "GET " REGISTRATION_SCRIPT "?%s=%s HTTP/1.1\r\n" |
225 | "Host: |
288 | "Host: " REGISTRATION_HOST "\r\n" |
226 | "Connection: close\r\n" |
289 | "Connection: close\r\n" |
227 | "\r\n", |
290 | "\r\n", |
- | 291 | (candidate_email_or_uuid != NULL ? (wcschr (candidate_email_or_uuid, '@') != NULL ? "email" : "uuid") : "test"), |
|
- | 292 | (candidate_email_or_uuid != NULL ? ascii_email_or_uuid : "1")); |
|
228 | length = strlen (http_buffer); |
293 | length = strlen (http_buffer); |
229 | write_index = send (s, http_buffer, length, 0); // send the HTTP query |
294 | write_index = send (s, http_buffer, length, 0); // send the HTTP query |
230 | if (write_index != length) |
295 | if (write_index != length) |
231 | { |
296 | { |
- | 297 | closesocket (s); |
|
- | 298 | if (failure_reason != NULL) |
|
232 | *failure_reason = LOCALIZE (L"Registration_NetworkFailure"); |
299 | *failure_reason = LOCALIZE (L"Registration_NetworkFailure"); |
233 | return (0); // unable to send HTTP query, return an error condition |
300 | return (0); // unable to send HTTP query, return an error condition |
234 | } |
301 | } |
235 | 302 | ||
236 | // read the reply (10 seconds timeout) |
303 | // read the reply (10 seconds timeout) |
237 | http_buffer[0] = 0; |
304 | http_buffer[0] = 0; |
238 | read_index = RecvWithTimeout (s, 10.0f, http_buffer, sizeof (http_buffer), 0); |
305 | read_index = RecvWithTimeout (s, 10.0f, http_buffer, sizeof (http_buffer), 0); |
239 | if (read_index < 1) |
306 | if (read_index < 1) |
240 | { |
307 | { |
- | 308 | closesocket (s); |
|
- | 309 | if (failure_reason != NULL) |
|
241 | *failure_reason = LOCALIZE (L"Registration_NetworkFailure"); |
310 | *failure_reason = LOCALIZE (L"Registration_NetworkFailure"); |
242 | return (0); // empty or erroneous HTTP reply, return an error condition |
311 | return (0); // empty or erroneous HTTP reply, return an error condition |
243 | } |
312 | } |
244 | 313 | ||
245 | closesocket (s); // finished communicating, close TCP socket |
314 | closesocket (s); // finished communicating, close TCP socket |
246 | 315 | ||
247 | // terminate recv buffer and see where the useful data starts |
316 | // terminate recv buffer and see where the useful data starts |
248 | http_buffer[read_index] = 0; |
317 | http_buffer[read_index] = 0; |
249 | //MessageBoxA (NULL, http_buffer, "HTTP response", MB_OK); |
318 | //MessageBoxA (NULL, http_buffer, "HTTP response", MB_OK); |
250 | if ( |
319 | if (candidate_email_or_uuid == NULL) |
251 | { |
320 | { |
- | 321 | if (failure_reason != NULL) |
|
252 | *failure_reason = L""; // no error, set an empty string as the failure reason |
322 | *failure_reason = L""; // no error, set an empty string as the failure reason |
- | 323 | if ((data_start = strchr (http_buffer, '\n')) != NULL) |
|
- | 324 | *data_start = 0; // see where the first reply line ends and break the string there |
|
- | 325 | return ((strncmp (http_buffer, "HTTP/", 5) == 0) && (strstr (http_buffer, " 200 ") != NULL)); // reachability test only |
|
- | 326 | } |
|
- | 327 | else if ((data_start = strstr (http_buffer, "Success=")) != NULL) |
|
- | 328 | { |
|
- | 329 | if (failure_reason != NULL) |
|
- | 330 | *failure_reason = L""; // no error, set an empty string as the failure reason |
|
- | 331 | if (returned_code != NULL) |
|
253 |
|
332 | *returned_code = (unsigned int) _atoi64 (&data_start[strlen ("Success=")]); |
- | 333 | if (returned_email != NULL) |
|
- | 334 | { |
|
- | 335 | data_start = strchr (data_start, ','); |
|
- | 336 | if (data_start != NULL) |
|
- | 337 | { |
|
- | 338 | if (strchr (data_start, '\r') != 0) |
|
- | 339 | *strchr (data_start, '\r') = 0; // don't report the newline |
|
- | 340 | ConvertToWideChar (wide_email, WCHAR_SIZEOF (wide_email), data_start + 1); |
|
- | 341 | *returned_email = wide_email; |
|
- | 342 | } |
|
- | 343 | else |
|
- | 344 | *returned_email = L""; |
|
- | 345 | } |
|
- | 346 | return (true); // and return the candidate code we got |
|
254 | } |
347 | } |
255 | else if ((data_start = strstr (http_buffer, "Error=")) != NULL) |
348 | else if ((data_start = strstr (http_buffer, "Error=")) != NULL) |
256 | { |
349 | { |
- | 350 | if (failure_reason != NULL) |
|
- | 351 | { |
|
257 | data_start += strlen ("Error="); |
352 | data_start += strlen ("Error="); |
258 | if (strchr (data_start, '\r') != NULL) *strchr (data_start, '\r') = 0; |
353 | if (strchr (data_start, '\r') != NULL) *strchr (data_start, '\r') = 0; |
259 | if (strchr (data_start, '\n') != NULL) *strchr (data_start, '\n') = 0; |
354 | if (strchr (data_start, '\n') != NULL) *strchr (data_start, '\n') = 0; |
260 | if (_stricmp (data_start, "WrongEmail") == 0) *failure_reason = LOCALIZE (L"Registration_WrongEmail"); |
355 | if (_stricmp (data_start, "WrongEmail") == 0) *failure_reason = LOCALIZE (L"Registration_WrongEmail"); |
261 | else if (_stricmp (data_start, "UnknownEmail") == 0) *failure_reason = LOCALIZE (L"Registration_UnknownEmail"); |
356 | else if (_stricmp (data_start, "UnknownEmail") == 0) *failure_reason = LOCALIZE (L"Registration_UnknownEmail"); |
262 | else if (_stricmp (data_start, "TooManyActivations") == 0) *failure_reason = LOCALIZE (L"Registration_TooManyActivations");; |
357 | else if (_stricmp (data_start, "TooManyActivations") == 0) *failure_reason = LOCALIZE (L"Registration_TooManyActivations");; |
- | 358 | } |
|
263 | return ( |
359 | return (false); // server returned an error, return an error condition |
264 | } |
360 | } |
265 | 361 | ||
- | 362 | if (failure_reason != NULL) |
|
266 | *failure_reason = LOCALIZE (L"Registration_NetworkFailure"); // this should never happen |
363 | *failure_reason = LOCALIZE (L"Registration_NetworkFailure"); // this should never happen |
267 | return ( |
364 | return (false); // server returned an error, return an error condition |
- | 365 | ||
- | 366 | #undef REGISTRATION_SCRIPT |
|
- | 367 | #undef REGISTRATION_HOST |
|
268 | } |
368 | } |