1 | /*
|
---|
2 | Copyright (C) 1996
|
---|
3 |
|
---|
4 | This program is free software; you can redistribute it and/or modify
|
---|
5 | it under the terms of the GNU General Public License as published by
|
---|
6 | the Free Software Foundation; either version 2 of the License, or
|
---|
7 | (at your option) any later version.
|
---|
8 |
|
---|
9 | This program is distributed in the hope that it will be useful,
|
---|
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
12 | GNU General Public License for more details.
|
---|
13 |
|
---|
14 | You should have received a copy of the GNU General Public License
|
---|
15 | along with this program; if not, write to the Free Software
|
---|
16 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
---|
17 |
|
---|
18 | The author can be contacted via Email at [email protected]
|
---|
19 | */
|
---|
20 | #include <windows.h>
|
---|
21 | #include <stdlib.h>
|
---|
22 | #include <stdio.h>
|
---|
23 | #include <string.h>
|
---|
24 | #include <memory.h>
|
---|
25 | #pragma hdrstop
|
---|
26 | #include "netio.h"
|
---|
27 | #include "settings.h"
|
---|
28 | #include "httpsrv.h"
|
---|
29 | #include "resource.h"
|
---|
30 | #include "locate.h"
|
---|
31 | #include "locateP.h"
|
---|
32 | #include "cgiwrapper.h"
|
---|
33 | #include "startbrowser.h"
|
---|
34 | #include "d_winsock.h"
|
---|
35 |
|
---|
36 | #define MAINWINDOWWIDTH 400
|
---|
37 | #define MAINWINDOWHEIGHT 200
|
---|
38 |
|
---|
39 | #define RESTHEIGHT 45 // Extra window size reqd below logo
|
---|
40 | #define WASTEHEIGHT 44 // Error in ht due to caption and menu bar
|
---|
41 | #define WASTEWIDTH 6
|
---|
42 |
|
---|
43 | // size and position of the collection title
|
---|
44 | #define COLTITLEWIDTH 351
|
---|
45 | #define COLTITLEHEIGHT 35
|
---|
46 | #define COLTITLEX ((MAINWINDOWWIDTH-COLTITLEWIDTH)/2)
|
---|
47 | #define COLTITLEY 10
|
---|
48 |
|
---|
49 | // size and position of the version string
|
---|
50 | #define VERSIONWIDTH MAINWINDOWWIDTH
|
---|
51 | #define VERSIONHEIGHT 20
|
---|
52 | #define VERSIONX 0
|
---|
53 | #define VERSIONY (COLTITLEY+COLTITLEHEIGHT)
|
---|
54 |
|
---|
55 | // size and position of the Greenstone digital library logo
|
---|
56 | #define LOGOWIDTH 135
|
---|
57 | #define LOGOHEIGHT 55
|
---|
58 | #define LOGOX (MAINWINDOWWIDTH-LOGOWIDTH-20)
|
---|
59 | #define LOGOY (MAINWINDOWHEIGHT-LOGOHEIGHT-RESTHEIGHT)
|
---|
60 |
|
---|
61 | // size and position of the status string
|
---|
62 | #define STATUSX 20
|
---|
63 | #define STATUSY ((LOGOY-VERSIONY-VERSIONHEIGHT)/2+VERSIONY+VERSIONHEIGHT)
|
---|
64 | #define STATUSWIDTH MAINWINDOWWIDTH-STATUSX
|
---|
65 | #define STATUSHEIGHT (MAINWINDOWHEIGHT-RESTHEIGHT-STATUSY)
|
---|
66 |
|
---|
67 | // size and position of the info string (same position as the button)
|
---|
68 | #define INFOWIDTH MAINWINDOWWIDTH
|
---|
69 | #define INFOHEIGHT (MAINWINDOWHEIGHT-INFOY)
|
---|
70 | #define INFOX 0
|
---|
71 | #define INFOY ((MAINWINDOWHEIGHT-RESTHEIGHT)+10)
|
---|
72 |
|
---|
73 | // size and position of the button
|
---|
74 | #define ENTERBUTTONWIDTH 150
|
---|
75 | #define ENTERBUTTONHEIGHT 30
|
---|
76 | #define ENTERBUTTONX ((MAINWINDOWWIDTH-ENTERBUTTONWIDTH)/2)
|
---|
77 | #define ENTERBUTTONY ((MAINWINDOWHEIGHT-RESTHEIGHT)+5)
|
---|
78 |
|
---|
79 | #define VERSIONSTRING "version 1.1"
|
---|
80 | const char versionstring[] = VERSIONSTRING;
|
---|
81 |
|
---|
82 | const char strnothing[] = "";
|
---|
83 | const char strinit[] = "Initialising...";
|
---|
84 | const char strsb[] = "Starting browser...";
|
---|
85 | const char strenterlib[] = "Press the 'Enter Library' button to start a browser\n"
|
---|
86 | "and begin using this library";
|
---|
87 | const char strenterstaticlib[] = "Press the 'Enter Library' button to start a browser\n"
|
---|
88 | "and begin using the static version\n"
|
---|
89 | "of this library";
|
---|
90 | const char *statusstring = NULL; // points to the current status string
|
---|
91 | const char *infostring = NULL; // points to the current info string
|
---|
92 |
|
---|
93 |
|
---|
94 | // globals to do with networking and browsers
|
---|
95 | int have_networking = 0;
|
---|
96 | int netscapeneeded = 0;
|
---|
97 | char startbrowserdir[1024] = ""; // HARD LIMIT!!!!!
|
---|
98 |
|
---|
99 |
|
---|
100 | // stats to do with the last time the enter library button was pressed
|
---|
101 | // these stats are needed to make suggestions about the proxy
|
---|
102 | int enterlib_libaccessnum = -1; // -1 = NA
|
---|
103 | DWORD enterlib_time = 0;
|
---|
104 |
|
---|
105 |
|
---|
106 | enum { undefined_window, console_window, plain_window }
|
---|
107 | window_state;
|
---|
108 |
|
---|
109 | HDC coltitledc = NULL;
|
---|
110 | HBITMAP defcoltitlebitmap = NULL, coltitlebitmap=NULL;
|
---|
111 |
|
---|
112 | HDC logodc=NULL;
|
---|
113 | HBITMAP deflogobitmap=NULL, logobitmap=NULL;
|
---|
114 |
|
---|
115 | HWND GoButton = NULL;
|
---|
116 |
|
---|
117 |
|
---|
118 | void finish_up() {
|
---|
119 | // remember the current preferences
|
---|
120 | write_settings();
|
---|
121 |
|
---|
122 | // Shutdown the HTTP server
|
---|
123 | EndHTTPServer();
|
---|
124 |
|
---|
125 | // Shutdown the main server modules
|
---|
126 | CleanUpNetIO();
|
---|
127 | // RemoveFnordFromTray();
|
---|
128 |
|
---|
129 | // Unload the wsock32 dll
|
---|
130 | d_UnloadWinsock();
|
---|
131 |
|
---|
132 | // Clean up graphics stuff from window
|
---|
133 |
|
---|
134 | if (defcoltitlebitmap != NULL)
|
---|
135 | SelectObject (coltitledc, defcoltitlebitmap);
|
---|
136 | if (coltitlebitmap != NULL)
|
---|
137 | DeleteObject (coltitlebitmap);
|
---|
138 | if (coltitledc != NULL)
|
---|
139 | DeleteDC (coltitledc);
|
---|
140 |
|
---|
141 | if (deflogobitmap != NULL)
|
---|
142 | SelectObject (logodc, deflogobitmap);
|
---|
143 | if (logobitmap != NULL)
|
---|
144 | DeleteObject (logobitmap);
|
---|
145 | if (logodc != NULL)
|
---|
146 | DeleteDC (logodc);
|
---|
147 |
|
---|
148 | // Shutdown the main window
|
---|
149 | PostQuitMessage(0);
|
---|
150 | }
|
---|
151 |
|
---|
152 |
|
---|
153 | int overlap(int left, int top, int right, int bottom,
|
---|
154 | RECT &r2)
|
---|
155 | {
|
---|
156 | if (left <= r2.right && r2.left <= right &&
|
---|
157 | top <= r2.bottom && r2.top <= bottom)
|
---|
158 | return 1;
|
---|
159 | else
|
---|
160 | return 0;
|
---|
161 | }
|
---|
162 |
|
---|
163 |
|
---|
164 | void paint_window (HDC pdc, RECT &updateRect) {
|
---|
165 | // make sure the various DCs are set up
|
---|
166 | if (coltitledc == NULL) {
|
---|
167 | coltitledc = CreateCompatibleDC(pdc);
|
---|
168 | defcoltitlebitmap = SelectObject (coltitledc, coltitlebitmap);
|
---|
169 | }
|
---|
170 |
|
---|
171 | if (logodc == NULL) {
|
---|
172 | logodc = CreateCompatibleDC(pdc);
|
---|
173 | deflogobitmap = SelectObject (logodc, logobitmap);
|
---|
174 | }
|
---|
175 |
|
---|
176 | // update the collection title if needed
|
---|
177 | if (overlap(COLTITLEX, COLTITLEY,
|
---|
178 | COLTITLEX+COLTITLEWIDTH, COLTITLEY+COLTITLEHEIGHT,
|
---|
179 | updateRect)) {
|
---|
180 | BitBlt (pdc, COLTITLEX, COLTITLEY,
|
---|
181 | COLTITLEX+COLTITLEWIDTH, COLTITLEY+COLTITLEHEIGHT,
|
---|
182 | coltitledc, 0, 0, SRCCOPY);
|
---|
183 | }
|
---|
184 |
|
---|
185 | // update the version string if needed
|
---|
186 | if (overlap (VERSIONX, VERSIONY,
|
---|
187 | VERSIONX+VERSIONWIDTH, VERSIONY+VERSIONHEIGHT,
|
---|
188 | updateRect)) {
|
---|
189 | RECT versionRect;
|
---|
190 | versionRect.left = VERSIONX;
|
---|
191 | versionRect.top = VERSIONY;
|
---|
192 | versionRect.right = VERSIONX+VERSIONWIDTH;
|
---|
193 | versionRect.bottom = VERSIONY+VERSIONHEIGHT;
|
---|
194 | DrawText(pdc, versionstring, -1, &versionRect, DT_CENTER);
|
---|
195 | }
|
---|
196 |
|
---|
197 | // decide what we want to draw
|
---|
198 | if (gs_show_console) {
|
---|
199 | // we want to draw a "console" window
|
---|
200 | if (window_state != console_window ||
|
---|
201 | overlap (text_rect.left, text_rect.top,
|
---|
202 | text_rect.right, text_rect.bottom,
|
---|
203 | updateRect)) {
|
---|
204 | refresh_console (pdc);
|
---|
205 | }
|
---|
206 |
|
---|
207 | window_state = console_window;
|
---|
208 |
|
---|
209 | } else {
|
---|
210 | // we want to draw a "plain" window
|
---|
211 |
|
---|
212 | // update the status string if needed
|
---|
213 | if ((statusstring != NULL) && (strlen(statusstring) > 0)
|
---|
214 | && overlap (STATUSX, STATUSY,
|
---|
215 | STATUSX+STATUSWIDTH, STATUSY+STATUSHEIGHT,
|
---|
216 | updateRect)) {
|
---|
217 | RECT statusRect;
|
---|
218 | statusRect.left = STATUSX;
|
---|
219 | statusRect.top = STATUSY;
|
---|
220 | statusRect.right = STATUSX+STATUSWIDTH;
|
---|
221 | statusRect.bottom = STATUSY+STATUSHEIGHT;
|
---|
222 | FillRect(pdc, &statusRect, GetStockObject(WHITE_BRUSH));
|
---|
223 |
|
---|
224 | int cury = STATUSY;
|
---|
225 | int startline = 0, here = 0;
|
---|
226 | while (statusstring[here] != '\0') {
|
---|
227 | if (statusstring[here] < ' ') {
|
---|
228 | if (here - startline > 0) {
|
---|
229 | // output the text
|
---|
230 | TextOut (pdc, STATUSX, cury,
|
---|
231 | &statusstring[startline], here-startline);
|
---|
232 | cury += line_spacing;
|
---|
233 | }
|
---|
234 | startline = here+1;
|
---|
235 | }
|
---|
236 | here++;
|
---|
237 | }
|
---|
238 | // output any remaining text
|
---|
239 | if (here - startline > 0) {
|
---|
240 | TextOut (pdc, STATUSX, cury, &statusstring[startline], here-startline);
|
---|
241 | }
|
---|
242 | }
|
---|
243 |
|
---|
244 | // update the logo (always)
|
---|
245 | BitBlt (pdc, LOGOX, LOGOY, LOGOX+LOGOWIDTH, LOGOY+LOGOHEIGHT,
|
---|
246 | logodc, 0, 0, SRCCOPY);
|
---|
247 |
|
---|
248 | window_state = plain_window;
|
---|
249 | }
|
---|
250 |
|
---|
251 |
|
---|
252 | // update the info string if needed
|
---|
253 | if ((GoButton == NULL) && (infostring != NULL) &&
|
---|
254 | overlap (INFOX, INFOY,
|
---|
255 | INFOX+INFOWIDTH, INFOY+INFOHEIGHT,
|
---|
256 | updateRect)) {
|
---|
257 | RECT infoRect;
|
---|
258 | infoRect.left = INFOX;
|
---|
259 | infoRect.top = INFOY;
|
---|
260 | infoRect.right = INFOX+INFOWIDTH;
|
---|
261 | infoRect.bottom = INFOY+INFOHEIGHT;
|
---|
262 | FillRect(pdc, &infoRect, GetStockObject(WHITE_BRUSH));
|
---|
263 | DrawText(pdc, infostring, -1, &infoRect, DT_CENTER);
|
---|
264 | }
|
---|
265 | }
|
---|
266 |
|
---|
267 |
|
---|
268 | void handle_painting (HWND Window) {
|
---|
269 | HDC pdc; PAINTSTRUCT ps;
|
---|
270 | pdc = BeginPaint(Window, &ps);
|
---|
271 |
|
---|
272 | paint_window (pdc, ps.rcPaint);
|
---|
273 |
|
---|
274 | EndPaint(Window, &ps);
|
---|
275 | }
|
---|
276 |
|
---|
277 |
|
---|
278 | // returns 1 on success, 0 otherwise
|
---|
279 | int enter_library (HWND Window) {
|
---|
280 | char url[256], numbuf[20];
|
---|
281 | int res;
|
---|
282 |
|
---|
283 | // get the url and attempt to start a browser
|
---|
284 | if (have_networking) {
|
---|
285 | strcpy(url, "http://");
|
---|
286 | strcat(url, GetLocalName(NULL));
|
---|
287 | if (gs_port_num != 80) {
|
---|
288 | itoa(gs_port_num,numbuf,10);
|
---|
289 | strcat(url,":");
|
---|
290 | strcat(url,numbuf);
|
---|
291 | }
|
---|
292 | strcat(url, gs_enterlib);
|
---|
293 |
|
---|
294 | // add a unique ending so it will always result in a request
|
---|
295 | if (strstr (gs_enterlib, "?") == NULL) strcat (url, "?");
|
---|
296 | else strcat (url, "&");
|
---|
297 |
|
---|
298 | strcat (url, "uq=");
|
---|
299 | itoa ((int)GetTickCount(), numbuf, 10);
|
---|
300 | strcat (url, numbuf);
|
---|
301 |
|
---|
302 | // remember the library access number for later proxy checking
|
---|
303 | enterlib_libaccessnum = libaccessnum;
|
---|
304 |
|
---|
305 | // do a quick check to make sure we're using netscape when
|
---|
306 | // we should be (it might have been just installed)
|
---|
307 | if (netscapeneeded) gs_check_browser_settings (netscapeneeded);
|
---|
308 |
|
---|
309 | if (strlen (startbrowserdir) <= 0) {
|
---|
310 | res = startbrowser (url, gs_browser_exe, NULL);
|
---|
311 |
|
---|
312 | } else res = startbrowser (url, gs_browser_exe, startbrowserdir);
|
---|
313 |
|
---|
314 | } else {
|
---|
315 | char staticpath[256];
|
---|
316 |
|
---|
317 | // try to find the static pages
|
---|
318 | strcpy (url, gs_staticpages);
|
---|
319 |
|
---|
320 | // remove any slashes from the static pathname
|
---|
321 | int len = strlen (url);
|
---|
322 | while ((len > 0) && ((url[len-1] == '\\') || (url[len-1] == '/'))) {
|
---|
323 | len--;
|
---|
324 | }
|
---|
325 | url[len] = '\0';
|
---|
326 |
|
---|
327 | // add one slash to the end
|
---|
328 | strcat (url, "\\");
|
---|
329 |
|
---|
330 | // check to make sure the static directory is available
|
---|
331 | strcpy (staticpath, url);
|
---|
332 | strcat (staticpath, "static\\");
|
---|
333 |
|
---|
334 | // check this directory
|
---|
335 | if (!cstrcheckdir(staticpath)) {
|
---|
336 | PostMessage(Window,WM_CLOSE,0,0);
|
---|
337 | return 0;
|
---|
338 | }
|
---|
339 |
|
---|
340 | // add filename of the first page
|
---|
341 | strcat (url, "niupepa.htm");
|
---|
342 |
|
---|
343 | res = startbrowser (url, gs_browser_exe, NULL);
|
---|
344 | startbrowserdir[0] = '\0'; // doesn't make sense for non-networked case
|
---|
345 | }
|
---|
346 |
|
---|
347 | if (res == SB_NOERROR) {
|
---|
348 | // success !!
|
---|
349 |
|
---|
350 | // remember the time the browser was started for later proxy checking
|
---|
351 | if (have_networking) enterlib_time = GetTickCount();
|
---|
352 |
|
---|
353 | return 1;
|
---|
354 | }
|
---|
355 |
|
---|
356 | // no browser was started
|
---|
357 | enterlib_libaccessnum = -1;
|
---|
358 |
|
---|
359 | if ((res == SB_FAIL_BADFORMAT) || (res == SB_FAIL_NOTFOUND)) {
|
---|
360 | if (!netscapeneeded) { // any browser
|
---|
361 | MessageBox(Window,
|
---|
362 | "Failed to start your chosen browser. It seems that your\n"
|
---|
363 | "chosen browser has been removed or corrupted.\n"
|
---|
364 | "Please check you browser choice by going to the\n"
|
---|
365 | "'Settings...' item under the 'File' menu.",
|
---|
366 | "Greenstone Digital Library Software", MB_OK);
|
---|
367 | } else { // netscape used
|
---|
368 | MessageBox(Window,
|
---|
369 | "Failed to start Netscape. It seems that Netscape has\n"
|
---|
370 | "been removed or corrupted. You need Netscape\n"
|
---|
371 | "installed to use the Greenstone Digital Library\n"
|
---|
372 | "software on non-networked machines.\n\n"
|
---|
373 | "You can install Netscape by choosing\n"
|
---|
374 | "'Install Netscape 4.05' from the 'File' menu.",
|
---|
375 | "Greenstone Digital Library Software", MB_OK);
|
---|
376 | }
|
---|
377 |
|
---|
378 | } else {
|
---|
379 | MessageBox(Window,
|
---|
380 | "Failed to start your browser. This may have been\n"
|
---|
381 | "because there was not enough memory available. Shut\n"
|
---|
382 | "down all other applications you have running, and\n"
|
---|
383 | "try again.",
|
---|
384 | "Greenstone Digital Library Software", MB_OK);
|
---|
385 | }
|
---|
386 |
|
---|
387 | return 0; // failed
|
---|
388 | }
|
---|
389 |
|
---|
390 |
|
---|
391 | void install_netscape (HWND Window) {
|
---|
392 | char installpath[256];
|
---|
393 |
|
---|
394 | // try to find the browser directory
|
---|
395 | strcpy (installpath, gs_gsdlhome); // use gsdlhome to find the CD-ROM drive...
|
---|
396 |
|
---|
397 | // remove any slashes from the pathname
|
---|
398 | int len = strlen (installpath);
|
---|
399 | while ((len > 0) && ((installpath[len-1] == '\\') || (installpath[len-1] == '/'))) {
|
---|
400 | len--;
|
---|
401 | }
|
---|
402 | // remove '\gsdl'
|
---|
403 | len = len - 5;
|
---|
404 | installpath[len] = '\0';
|
---|
405 |
|
---|
406 | strcat (installpath, "\\netscape\\");
|
---|
407 |
|
---|
408 | // check this directory
|
---|
409 | if (!cstrcheckdir(installpath)) {
|
---|
410 | return;
|
---|
411 | }
|
---|
412 |
|
---|
413 | // get the operating system information
|
---|
414 | OSVERSIONINFO osver;
|
---|
415 | memset(&osver, 0, sizeof(OSVERSIONINFO));
|
---|
416 | osver.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
|
---|
417 | GetVersionEx(&osver);
|
---|
418 |
|
---|
419 | // get the install program for this operating system
|
---|
420 | if (osver.dwPlatformId == VER_PLATFORM_WIN32s) {
|
---|
421 | strcat (installpath, "n16e405.exe");
|
---|
422 | } else {
|
---|
423 | strcat (installpath, "n32e405.exe");
|
---|
424 | }
|
---|
425 |
|
---|
426 | // run the install program
|
---|
427 | int res = WinExec (installpath, SW_SHOW);
|
---|
428 | if (res == 0) {
|
---|
429 | // out of resources or memory
|
---|
430 | MessageBox (Window,
|
---|
431 | "Did not have enough resources or memory to run the\n"
|
---|
432 | "install program. Try shutting down all other programs\n"
|
---|
433 | "and trying again.",
|
---|
434 | "Greenstone Digital Library Software",
|
---|
435 | MB_OK|MB_APPLMODAL);
|
---|
436 |
|
---|
437 | } else if (res == ERROR_BAD_FORMAT) {
|
---|
438 | // executable image is corrupt -- ????
|
---|
439 | MessageBox (Window,
|
---|
440 | "The install program seems to be corrupt.",
|
---|
441 | "Greenstone Digital Library Software",
|
---|
442 | MB_OK|MB_APPLMODAL);
|
---|
443 |
|
---|
444 | } else if ((res == ERROR_FILE_NOT_FOUND) || (res == ERROR_PATH_NOT_FOUND)) {
|
---|
445 | // couldn't find the executable -- ????
|
---|
446 | MessageBox (Window,
|
---|
447 | "Could not find the install program. Try installing\n"
|
---|
448 | "Netscape from the Greenstone Digital Library\n"
|
---|
449 | "software's install program.",
|
---|
450 | "Greenstone Digital Library Software",
|
---|
451 | MB_OK|MB_APPLMODAL);
|
---|
452 | }
|
---|
453 | }
|
---|
454 |
|
---|
455 | void open_help () {
|
---|
456 | char topdir[256], cmd[256];
|
---|
457 |
|
---|
458 | // try to find the browser directory
|
---|
459 | strcpy (topdir, gs_gsdlhome); // use gsdlhome to find the CD-ROM drive...
|
---|
460 | strcpy (cmd, "notepad ");
|
---|
461 |
|
---|
462 | // remove any slashes from the pathname
|
---|
463 | int len = strlen (topdir);
|
---|
464 | while ((len > 0) && ((topdir[len-1] == '\\') || (topdir[len-1] == '/'))) {
|
---|
465 | len--;
|
---|
466 | }
|
---|
467 | // remove the '\gsdl'
|
---|
468 | len = len - 5;
|
---|
469 | topdir[len] = '\0';
|
---|
470 |
|
---|
471 | strcat (topdir, "\\README.txt");
|
---|
472 | strcat (cmd, topdir);
|
---|
473 |
|
---|
474 | WinExec (cmd, SW_SHOW);
|
---|
475 | }
|
---|
476 |
|
---|
477 |
|
---|
478 | long __stdcall WndProc(HWND Window, UINT Message, WPARAM WParam, LPARAM LParam) {
|
---|
479 | switch(Message) {
|
---|
480 | // Constant Messages
|
---|
481 | case WM_CREATE:
|
---|
482 | break;
|
---|
483 |
|
---|
484 | case WM_CHAR:
|
---|
485 | // if the user hit the return key and if this is not a
|
---|
486 | // repeat key press then attempt to start a browser
|
---|
487 | if ((WParam == '\r') && !(LParam & 0xe0000000)) {
|
---|
488 | if (enter_library (Window) && !gs_show_console)
|
---|
489 | ShowWindow(Window,SW_MINIMIZE);
|
---|
490 | }
|
---|
491 |
|
---|
492 | case WM_COMMAND:
|
---|
493 | if ((HWND)LParam == GoButton) {
|
---|
494 | // attempt to start a browser
|
---|
495 | if (enter_library (Window) && !gs_show_console)
|
---|
496 | ShowWindow(Window,SW_MINIMIZE);
|
---|
497 |
|
---|
498 | } else {
|
---|
499 | switch (LOWORD(WParam)) {
|
---|
500 | case ID_PROJECT_SETTINGS:
|
---|
501 | Settings_Dialog(Window, netscapeneeded);
|
---|
502 | break;
|
---|
503 | case ID_INSTALL_NETSCAPE:
|
---|
504 | install_netscape(Window);
|
---|
505 | break;
|
---|
506 | case IDHELP:
|
---|
507 | open_help();
|
---|
508 | break;
|
---|
509 | case ID_PROJECT_EXIT:
|
---|
510 | finish_up();
|
---|
511 | break;
|
---|
512 | default:
|
---|
513 | break;
|
---|
514 | }
|
---|
515 | }
|
---|
516 | break;
|
---|
517 |
|
---|
518 | case WM_PAINT:
|
---|
519 | handle_painting(Window);
|
---|
520 | break;
|
---|
521 |
|
---|
522 | case HTTP_SERVER_MSG:
|
---|
523 | ProcessHTTPServerMsg(WParam, LParam);
|
---|
524 | break;
|
---|
525 |
|
---|
526 | case WM_DESTROY:
|
---|
527 | finish_up();
|
---|
528 | break;
|
---|
529 |
|
---|
530 | default:
|
---|
531 | //Unhandled Messages end up here (DefWindowProc)
|
---|
532 | return DefWindowProc(Window, Message, WParam, LParam);
|
---|
533 | }
|
---|
534 |
|
---|
535 | return(0);
|
---|
536 | }
|
---|
537 |
|
---|
538 | // returns 0 if successful,
|
---|
539 | // otherwise a WSA error number
|
---|
540 | int tryinitnetwork (HANDLE Instance, HWND MsgWindow, char *path) {
|
---|
541 | // try to load winsock
|
---|
542 | int err = d_LoadWinsock (path);
|
---|
543 |
|
---|
544 | if (err == D_NOERROR) {
|
---|
545 | // next, try to init netio
|
---|
546 | err = InitNetIO();
|
---|
547 |
|
---|
548 | if (err == 0) {
|
---|
549 | // next, try to start the http server
|
---|
550 | err = StartHTTPServer(MsgWindow);
|
---|
551 |
|
---|
552 | if (err == 0) {
|
---|
553 | // finally, get the host name (no error value
|
---|
554 | // is returned from this function)
|
---|
555 | GetLocalName(Instance);
|
---|
556 |
|
---|
557 | } else {
|
---|
558 | // couldn't start the http server,
|
---|
559 | // deinit netio and unload winsock
|
---|
560 | CleanUpNetIO();
|
---|
561 | d_UnloadWinsock();
|
---|
562 | }
|
---|
563 |
|
---|
564 | } else {
|
---|
565 | // couldn't init netio, unload winsock
|
---|
566 | d_UnloadWinsock();
|
---|
567 | }
|
---|
568 |
|
---|
569 | } else {
|
---|
570 | // couldn't load winsock
|
---|
571 | err = WSASYSNOTREADY;
|
---|
572 | }
|
---|
573 |
|
---|
574 | return err;
|
---|
575 | }
|
---|
576 |
|
---|
577 |
|
---|
578 | // inits all the network functionality
|
---|
579 | // returns 0 if an unrecoverable error occurred,
|
---|
580 | // and 1 if everything successfully initialised.
|
---|
581 | int initnetwork (HANDLE Instance, HWND MsgWindow) {
|
---|
582 | OSVERSIONINFO osver;
|
---|
583 |
|
---|
584 | // get the operating system information
|
---|
585 | memset(&osver, 0, sizeof(OSVERSIONINFO));
|
---|
586 | osver.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
|
---|
587 | GetVersionEx(&osver);
|
---|
588 |
|
---|
589 | // first try to initialise the network with system installed
|
---|
590 | // networking software
|
---|
591 | startbrowserdir[0] = '\0';
|
---|
592 | netscapeneeded = 0;
|
---|
593 | // int err = tryinitnetwork (Instance, MsgWindow, NULL);
|
---|
594 | int err = 1;
|
---|
595 |
|
---|
596 | // if an error occurred, try again with billsock
|
---|
597 | if (err != 0) {
|
---|
598 | // get the path of billsock (current directory + ("net16" | "net32"))
|
---|
599 | char winsockpath[1024]; // HARD LIMIT!!!!
|
---|
600 |
|
---|
601 | find_location();
|
---|
602 | strcpy (winsockpath, data_location);
|
---|
603 |
|
---|
604 | // remove all the slashes at the end of billpath
|
---|
605 | int len = strlen (winsockpath);
|
---|
606 | while ((len > 0) && ((winsockpath[len-1] == '\\') || (winsockpath[len-1] == '/'))) {
|
---|
607 | len--;
|
---|
608 | }
|
---|
609 | winsockpath[len] = '\0';
|
---|
610 |
|
---|
611 | if (osver.dwPlatformId == VER_PLATFORM_WIN32s)
|
---|
612 | strcat (winsockpath, "\\net16\\");
|
---|
613 | else {
|
---|
614 | strcat (winsockpath, "\\net32\\");
|
---|
615 | strcpy (startbrowserdir, winsockpath);
|
---|
616 | }
|
---|
617 |
|
---|
618 | // try again
|
---|
619 | err = tryinitnetwork (Instance, MsgWindow, winsockpath);
|
---|
620 |
|
---|
621 | if (err == 0) {
|
---|
622 | // we will need to use netscape on 95/98/NT machines
|
---|
623 | if (osver.dwPlatformId != VER_PLATFORM_WIN32s) {
|
---|
624 | netscapeneeded = 1;
|
---|
625 | // make sure the browser state is in step with the network condition
|
---|
626 | gs_check_browser_settings (netscapeneeded);
|
---|
627 | }
|
---|
628 |
|
---|
629 | // check to see if a browser is running
|
---|
630 | if (browserrunning(gs_browser_exe) == NO_ERROR) {
|
---|
631 | MessageBox (NULL,
|
---|
632 | "The Greenstone Digital Library software has detected a\n"
|
---|
633 | "running browser. To let our networking software\n"
|
---|
634 | "correctly initialize, please shut down your browser\n"
|
---|
635 | "and restart the Greenstone Digital Library software.",
|
---|
636 | "Greenstone Digital Library Software", MB_OK|MB_APPLMODAL);
|
---|
637 | PostMessage(MsgWindow,WM_CLOSE,0,0);
|
---|
638 | finish_up(); // will unload winsock
|
---|
639 | exit(0); // nothing more to do
|
---|
640 | }
|
---|
641 | }
|
---|
642 | }
|
---|
643 |
|
---|
644 | // if an error occurred display a nice error message
|
---|
645 | if (err != 0) {
|
---|
646 |
|
---|
647 | // WSASYSNOTREADY Couldn't load winsock
|
---|
648 | // WSAVERNOTSUPPORTED The version of Windows Sockets support requested
|
---|
649 | // is not provided by this particular Windows Sockets implementation.
|
---|
650 | // WSAEINVAL The Windows Sockets version specified by the application
|
---|
651 | // is not supported by this DLL.
|
---|
652 | // WSAEPROTONOSUPPORT The specified protocol is not supported.
|
---|
653 | // WSAEPROTOTYPE The specified protocol is the wrong type for this socket.
|
---|
654 | // WSAESOCKTNOSUPPORT The specified socket type is not supported in
|
---|
655 | // this address family.
|
---|
656 | // WSANOTINITIALISED A successful WSAStartup must occur before
|
---|
657 | // using this function.
|
---|
658 | // WSAENETDOWN The Windows Sockets implementation
|
---|
659 | // has detected that the network subsystem has failed.
|
---|
660 | // WSAEADDRINUSE The specified address
|
---|
661 | // is already in use. (See the SO_REUSEADDR socket option under setsockopt.)
|
---|
662 | // WSAEFAULT The namelen argument is too small (less
|
---|
663 | // than the size of a struct sockaddr).
|
---|
664 | // WSAEINPROGRESS A blocking Windows Sockets call is in progress.
|
---|
665 | // WSAEAFNOSUPPORT The specified address family is not supported
|
---|
666 | // by this protocol.
|
---|
667 | // WSAENOBUFS Not enough buffers available, too many connections.
|
---|
668 | // WSAENOTSOCK The descriptor is not a socket.
|
---|
669 | // WSAEISCONN The socket is already connected.
|
---|
670 | // WSAEMFILE No more file descriptors are available.
|
---|
671 | // WSAEOPNOTSUPP The referenced socket is not of a type that
|
---|
672 | // supports the listen operation.
|
---|
673 |
|
---|
674 | // get a text version of the error number
|
---|
675 | char errstr[256];
|
---|
676 |
|
---|
677 | switch (err) {
|
---|
678 | case WSASYSNOTREADY: strcpy(errstr, "WSASYSNOTREADY");
|
---|
679 | break;
|
---|
680 | case WSAVERNOTSUPPORTED: strcpy (errstr, "WSAVERNOTSUPPORTED");
|
---|
681 | break;
|
---|
682 | case WSAEINVAL: strcpy (errstr, "WSAEINVAL");
|
---|
683 | break;
|
---|
684 | case WSAEPROTONOSUPPORT: strcpy (errstr, "WSAEPROTONOSUPPORT");
|
---|
685 | break;
|
---|
686 | case WSAEPROTOTYPE: strcpy (errstr, "WSAEPROTOTYPE");
|
---|
687 | break;
|
---|
688 | case WSAESOCKTNOSUPPORT: strcpy (errstr, "WSAESOCKTNOSUPPORT");
|
---|
689 | break;
|
---|
690 | case WSANOTINITIALISED: strcpy (errstr, "WSANOTINITIALISED");
|
---|
691 | break;
|
---|
692 | case WSAEFAULT: strcpy (errstr, "WSAEFAULT");
|
---|
693 | break;
|
---|
694 | case WSAEAFNOSUPPORT: strcpy (errstr, "WSAEAFNOSUPPORT");
|
---|
695 | break;
|
---|
696 | case WSAENOTSOCK: strcpy (errstr, "WSAENOTSOCK");
|
---|
697 | break;
|
---|
698 | case WSAEISCONN: strcpy (errstr, "WSAEISCONN");
|
---|
699 | break;
|
---|
700 | case WSAEOPNOTSUPP: strcpy (errstr, "WSAEOPNOTSUPP");
|
---|
701 | break;
|
---|
702 | case WSAENETDOWN: strcpy (errstr, "WSAENETDOWN");
|
---|
703 | break;
|
---|
704 | case WSAEADDRINUSE: strcpy (errstr, "WSAEADDRINUSE");
|
---|
705 | break;
|
---|
706 | case WSAEINPROGRESS: strcpy (errstr, "WSAEINPROGRESS");
|
---|
707 | break;
|
---|
708 | case WSAENOBUFS: strcpy (errstr, "WSAENOBUFS");
|
---|
709 | break;
|
---|
710 | case WSAEMFILE: strcpy (errstr, "WSAEMFILE");
|
---|
711 | break;
|
---|
712 | default: sprintf (errstr, "WSA ERROR: %i", err);
|
---|
713 | break;
|
---|
714 | }
|
---|
715 |
|
---|
716 | // create a nice error message
|
---|
717 | char message[2048];
|
---|
718 |
|
---|
719 | switch (err) {
|
---|
720 | case WSAEADDRINUSE:
|
---|
721 | // couldn't bind socket
|
---|
722 | sprintf (message, "Could not find a free socket.", errstr);
|
---|
723 | break;
|
---|
724 |
|
---|
725 | default:
|
---|
726 | // cannot init winsock
|
---|
727 | sprintf (message, "Could not initialize the network\n"
|
---|
728 | " (Reason: %s).", errstr);
|
---|
729 | break;
|
---|
730 | }
|
---|
731 |
|
---|
732 | strcat (message, "\n\n"
|
---|
733 | // no static library for this collection
|
---|
734 | // "You will still be able to use the static version of this\n"
|
---|
735 | // "collection, however, searching will be unavailable.");
|
---|
736 | "Please submit a bug report using the support.htm file\n"
|
---|
737 | "on the CD-ROM.");
|
---|
738 |
|
---|
739 | MessageBox (NULL, message, "Greestone Digital Library Software", MB_OK);
|
---|
740 | }
|
---|
741 |
|
---|
742 | return (err == 0);
|
---|
743 | }
|
---|
744 |
|
---|
745 |
|
---|
746 | void log_computer_info () {
|
---|
747 | char tmpstr[1024];
|
---|
748 |
|
---|
749 | // get various information about this computer
|
---|
750 | if (gs_keep_log || gs_show_console) {
|
---|
751 | // get operating system information
|
---|
752 | OSVERSIONINFO osver;
|
---|
753 | osver.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
|
---|
754 |
|
---|
755 | if (GetVersionEx(&osver)) {
|
---|
756 | if (osver.dwPlatformId == VER_PLATFORM_WIN32s) {
|
---|
757 | log_message ("Platform: win32s\n");
|
---|
758 | } else if (osver.dwPlatformId == VER_PLATFORM_WIN32_WINDOWS) {
|
---|
759 | log_message ("Platform: windows 95\n");
|
---|
760 | } else if (osver.dwPlatformId == VER_PLATFORM_WIN32_NT) {
|
---|
761 | log_message ("Platform: windows NT\n");
|
---|
762 | }
|
---|
763 |
|
---|
764 | sprintf (tmpstr, "MajorVersion: %i\n", (int)osver.dwMajorVersion);
|
---|
765 | log_message(tmpstr);
|
---|
766 | sprintf (tmpstr, "MinorVersion: %i\n", (int)osver.dwMinorVersion);
|
---|
767 | log_message(tmpstr);
|
---|
768 | sprintf (tmpstr, "BuildNumber: %i\n", (int)osver.dwBuildNumber);
|
---|
769 | log_message(tmpstr);
|
---|
770 | sprintf (tmpstr, "CSDVersion: %s\n\n", osver.szCSDVersion);
|
---|
771 | log_message(tmpstr);
|
---|
772 | }
|
---|
773 |
|
---|
774 | // get memory information
|
---|
775 | MEMORYSTATUS memstatus;
|
---|
776 | memstatus.dwLength = sizeof(MEMORYSTATUS);
|
---|
777 | GlobalMemoryStatus(&memstatus);
|
---|
778 |
|
---|
779 | sprintf (tmpstr, "TotalPhys: %i Meg\n", (int)(memstatus.dwTotalPhys/1024/1024));
|
---|
780 | log_message (tmpstr);
|
---|
781 | sprintf (tmpstr, "AvailPhys: %i Meg\n", (int)(memstatus.dwAvailPhys/1024/1024));
|
---|
782 | log_message (tmpstr);
|
---|
783 | sprintf (tmpstr, "TotalPageFile: %i Meg\n", (int)(memstatus.dwTotalPageFile/1024/1024));
|
---|
784 | log_message (tmpstr);
|
---|
785 | sprintf (tmpstr, "AvailPageFile: %i Meg\n", (int)(memstatus.dwAvailPageFile/1024/1024));
|
---|
786 | log_message (tmpstr);
|
---|
787 | sprintf (tmpstr, "TotalVirtual: %i Meg\n", (int)(memstatus.dwTotalVirtual/1024/1024));
|
---|
788 | log_message (tmpstr);
|
---|
789 | sprintf (tmpstr, "AvailVirtual: %i Meg\n\n", (int)(memstatus.dwAvailVirtual/1024/1024));
|
---|
790 | log_message (tmpstr);
|
---|
791 |
|
---|
792 | // log the version number
|
---|
793 | log_message("GSDL version: " VERSIONSTRING "\n");
|
---|
794 | }
|
---|
795 |
|
---|
796 | }
|
---|
797 |
|
---|
798 |
|
---|
799 | int __stdcall WinMain(HANDLE Instance, HANDLE /*PrevInstance*/, LPSTR CmdLineStr, int /*CmdShow*/) {
|
---|
800 | HWND MainWindow; MSG Message; WNDCLASS MainClass;
|
---|
801 |
|
---|
802 | //Create a window class
|
---|
803 | MainClass.style = CS_HREDRAW | CS_VREDRAW;
|
---|
804 | MainClass.lpfnWndProc = WndProc;
|
---|
805 | MainClass.cbClsExtra = 0;
|
---|
806 | MainClass.cbWndExtra = 0;
|
---|
807 | MainClass.hInstance = Instance;
|
---|
808 | MainClass.hIcon = LoadIcon(Instance, MAKEINTRESOURCE(TRAY_ICON));
|
---|
809 | MainClass.hCursor = LoadCursor(NULL, IDC_ARROW);
|
---|
810 | MainClass.hbrBackground = GetStockObject(WHITE_BRUSH);
|
---|
811 | MainClass.lpszMenuName = MAKEINTRESOURCE(Main_Menu);
|
---|
812 | MainClass.lpszClassName = "Greenstone Digital Library Software";
|
---|
813 | if (!RegisterClass(&MainClass))
|
---|
814 | return 0;
|
---|
815 |
|
---|
816 | // Load various bitmaps
|
---|
817 | coltitlebitmap = LoadBitmap (Instance, MAKEINTRESOURCE(GSDL_COL_TITLE));
|
---|
818 | logobitmap= LoadBitmap (Instance, MAKEINTRESOURCE(GSDL_LOGO));
|
---|
819 |
|
---|
820 | // Create the main window
|
---|
821 | MainWindow = CreateWindow("Greenstone Digital Library Software",
|
---|
822 | "Greenstone Digital Library Software",
|
---|
823 | WS_OVERLAPPED | WS_CAPTION | WS_SYSMENU |
|
---|
824 | WS_MINIMIZEBOX,
|
---|
825 | CW_USEDEFAULT, CW_USEDEFAULT,
|
---|
826 | MAINWINDOWWIDTH + WASTEWIDTH,
|
---|
827 | MAINWINDOWHEIGHT + WASTEHEIGHT,
|
---|
828 | NULL, NULL, Instance, NULL);
|
---|
829 |
|
---|
830 | text_rect.left = 0;
|
---|
831 | text_rect.top = VERSIONY+VERSIONHEIGHT + 5;
|
---|
832 | text_rect.right = MAINWINDOWWIDTH;
|
---|
833 | text_rect.bottom = MAINWINDOWHEIGHT-RESTHEIGHT - 1;
|
---|
834 |
|
---|
835 | window_state = undefined_window;
|
---|
836 |
|
---|
837 | ShowWindow(MainWindow, SW_SHOW);
|
---|
838 | set_location(CmdLineStr);
|
---|
839 |
|
---|
840 | // get ready to draw the main window
|
---|
841 | RECT windowRect;
|
---|
842 | GetClientRect (MainWindow, &windowRect);
|
---|
843 | HDC pdc = GetDC (MainWindow);
|
---|
844 |
|
---|
845 | // retrieve and save the text metrics
|
---|
846 | TEXTMETRIC tm;
|
---|
847 | GetTextMetrics(pdc, &tm);
|
---|
848 | line_spacing = tm.tmHeight + tm.tmExternalLeading;
|
---|
849 | GSDL_Window = MainWindow;
|
---|
850 |
|
---|
851 | // draw the main window containing an init message
|
---|
852 | infostring = strinit;
|
---|
853 | paint_window (pdc, windowRect);
|
---|
854 | DWORD lastcheck = GetTickCount();
|
---|
855 |
|
---|
856 | // init various modules
|
---|
857 | read_settings (0); // don't know if netscape is needed at this point
|
---|
858 | if (!gsdl_init()) // quit if can't initialise the library correctly
|
---|
859 | exit (0);
|
---|
860 | initstartbrowser();
|
---|
861 | log_computer_info ();
|
---|
862 |
|
---|
863 | // attempt to initialise the network
|
---|
864 | have_networking = initnetwork (Instance, MainWindow);
|
---|
865 | if (!have_networking) {
|
---|
866 | MessageBox(NULL,
|
---|
867 | "Failed to initialize networking.",
|
---|
868 | "Greenstone Digital Library Software",MB_OK|MB_SYSTEMMODAL);
|
---|
869 | exit (0); // there is no static library for this collection
|
---|
870 | }
|
---|
871 | // show the initialising message for at least 1 second
|
---|
872 | while (DiffTickCounts (lastcheck, GetTickCount()) < 1000) {
|
---|
873 | Sleep (1);
|
---|
874 | }
|
---|
875 |
|
---|
876 | // if autoenter is enabled attempt to start a browser
|
---|
877 | if (have_networking && gs_auto_enter) {
|
---|
878 | infostring = strsb;
|
---|
879 | paint_window (pdc, windowRect);
|
---|
880 | lastcheck = GetTickCount();
|
---|
881 | if (enter_library (MainWindow) && !gs_show_console) {
|
---|
882 | // stay maximised for at least 1 second
|
---|
883 | while (DiffTickCounts (lastcheck, GetTickCount()) < 1000) Sleep (1);
|
---|
884 | ShowWindow(MainWindow,SW_MINIMIZE);
|
---|
885 | }
|
---|
886 | }
|
---|
887 |
|
---|
888 | // remove the last info message
|
---|
889 | infostring = strnothing;
|
---|
890 | paint_window (pdc, windowRect);
|
---|
891 |
|
---|
892 | // add the "enter library" button
|
---|
893 | GoButton = CreateWindow(
|
---|
894 | "BUTTON", // predefined class
|
---|
895 | "Enter Library", // button text
|
---|
896 | WS_VISIBLE | WS_CHILD | BS_DEFPUSHBUTTON, // styles
|
---|
897 | ENTERBUTTONX, // starting x position
|
---|
898 | ENTERBUTTONY, // starting y position
|
---|
899 | ENTERBUTTONWIDTH, // button width
|
---|
900 | ENTERBUTTONHEIGHT, // button height
|
---|
901 | MainWindow, // parent window
|
---|
902 | NULL, // No menu
|
---|
903 | Instance,
|
---|
904 | NULL); // pointer not needed
|
---|
905 |
|
---|
906 | if (have_networking) statusstring = strenterlib;
|
---|
907 | else statusstring = strenterstaticlib;
|
---|
908 | paint_window (pdc, windowRect);
|
---|
909 |
|
---|
910 | // release the DC used to display the init messages
|
---|
911 | ReleaseDC (MainWindow, pdc);
|
---|
912 |
|
---|
913 | //Message loop
|
---|
914 | lastcheck = GetTickCount();
|
---|
915 | int seenbrowser = 0; // if we see a browser then it disappears
|
---|
916 | // we will ask if they want to close the
|
---|
917 | // the library down
|
---|
918 | char last_gs_browser_exe[MAX_FILENAME_SIZE]; // need to notice when the
|
---|
919 | // browser setting changes
|
---|
920 | strcpy (last_gs_browser_exe, gs_browser_exe);
|
---|
921 |
|
---|
922 | for (;;) {
|
---|
923 | if (PeekMessage(&Message, NULL, 0, 0, PM_REMOVE)) {
|
---|
924 | if (Message.message == WM_QUIT) break;
|
---|
925 | TranslateMessage(&Message); /* translate keyboard messages */
|
---|
926 | DispatchMessage(&Message); /* return control to Windows NT */
|
---|
927 |
|
---|
928 | } else {
|
---|
929 | if (DiffTickCounts (lastcheck, GetTickCount()) > 500) {
|
---|
930 | // make sure the browser hasn't changed
|
---|
931 | if (strcmp (last_gs_browser_exe, gs_browser_exe) != 0) {
|
---|
932 | seenbrowser = 0;
|
---|
933 | strcpy (last_gs_browser_exe, gs_browser_exe);
|
---|
934 | }
|
---|
935 |
|
---|
936 | // do check
|
---|
937 | lastcheck = GetTickCount();
|
---|
938 | if (browserrunning(gs_browser_exe) == NO_ERROR) {
|
---|
939 | // we were able to connect to a browser
|
---|
940 | seenbrowser = 1;
|
---|
941 |
|
---|
942 | // see if the enter library button has been pressed
|
---|
943 | // with nothing happening for 20 seconds
|
---|
944 | if ((enterlib_libaccessnum >= 0) &&
|
---|
945 | (enterlib_libaccessnum == libaccessnum) &&
|
---|
946 | (DiffTickCounts (enterlib_time, GetTickCount()) > 20000)) {
|
---|
947 | // something could be wrong!! (most likely cause is a proxy)
|
---|
948 | MessageBox(NULL,
|
---|
949 | "Your browser does not seem to be responding to the 'Enter Library'\n"
|
---|
950 | "request. Try turning off all proxy servers in your browser settings.",
|
---|
951 | "Greenstone Digital Library Software",MB_OK|MB_SYSTEMMODAL);
|
---|
952 | enterlib_libaccessnum = -1;
|
---|
953 | }
|
---|
954 |
|
---|
955 |
|
---|
956 | } else {
|
---|
957 | // no browser was found
|
---|
958 | if (seenbrowser) {
|
---|
959 | // we have seen a browser in the past
|
---|
960 | if (MessageBox(NULL,
|
---|
961 | "The Greenstone Digital Library software has noticed that you\n"
|
---|
962 | "shut down your browser. Would you also like to shut down the\n"
|
---|
963 | "Greenstone Digital Library software?",
|
---|
964 | "Greenstone Digital Library Software",MB_YESNO|MB_SYSTEMMODAL) == IDYES)
|
---|
965 | PostMessage(MainWindow,WM_CLOSE,0,0);
|
---|
966 | }
|
---|
967 | seenbrowser = 0;
|
---|
968 | }
|
---|
969 | }
|
---|
970 |
|
---|
971 | Sleep (1); // millisecond
|
---|
972 | }
|
---|
973 | }
|
---|
974 |
|
---|
975 | return Message.wParam;
|
---|
976 | }
|
---|