]> cygwin.com Git - cygwin-apps/setup.git/blob - choose.cc
2002-04-23 Robert Collins <rbtcollins@hotmail.com>
[cygwin-apps/setup.git] / choose.cc
1 /*
2 * Copyright (c) 2000, 2001 Red Hat, Inc.
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 * A copy of the GNU General Public License can be found at
10 * http://www.gnu.org/
11 *
12 * Written by DJ Delorie <dj@cygnus.com>
13 *
14 */
15
16 /* The purpose of this file is to let the user choose which packages
17 to install, and which versions of the package when more than one
18 version is provided. The "trust" level serves as an indication as
19 to which version should be the default choice. At the moment, all
20 we do is compare with previously installed packages to skip any
21 that are already installed (by setting the action to ACTION_SAME).
22 While the "trust" stuff is supported, it's not really implemented
23 yet. We always prefer the "current" option. In the future, this
24 file might have a user dialog added to let the user choose to not
25 install packages, or to install packages that aren't installed by
26 default. */
27
28 #if 0
29 static const char *cvsid =
30 "\n%%% $Id$\n";
31 #endif
32
33 #include "win32.h"
34 #include <commctrl.h>
35 #include <stdio.h>
36 #include <stdlib.h>
37 #include <io.h>
38 #include <ctype.h>
39 #include <process.h>
40
41 #include "dialog.h"
42 #include "resource.h"
43 #include "state.h"
44 #include "ini.h"
45 #include "msg.h"
46 #include "log.h"
47 #include "find.h"
48 #include "filemanip.h"
49 #include "io_stream.h"
50 #include "propsheet.h"
51 #include "choose.h"
52 #include "category.h"
53
54 #include "package_db.h"
55 #include "package_meta.h"
56 #include "package_version.h"
57 #include "cygpackage.h"
58
59 #include "PickView.h"
60
61 #include "port.h"
62 #include "threebar.h"
63 extern ThreeBarProgressPage Progress;
64
65 static int initialized = 0;
66
67 static HWND lv, nextbutton, choose_inst_text;
68 static PickView *chooser = NULL;
69
70 static void set_view_mode (HWND h, PickView::views mode);
71
72 static void
73 paint (HWND hwnd)
74 {
75 HDC hdc;
76 PAINTSTRUCT ps;
77 int x, y;
78
79 hdc = BeginPaint (hwnd, &ps);
80
81 SelectObject (hdc, chooser->sysfont);
82 SetBkColor (hdc, GetSysColor (COLOR_WINDOW));
83 SetTextColor (hdc, GetSysColor (COLOR_WINDOWTEXT));
84
85 RECT cr;
86 GetClientRect (hwnd, &cr);
87
88 x = cr.left - chooser->scroll_ulc_x;
89 y = cr.top - chooser->scroll_ulc_y + chooser->header_height;
90
91 IntersectClipRect (hdc, cr.left, cr.top + chooser->header_height, cr.right,
92 cr.bottom);
93
94 chooser->contents.paint (hdc, x, y, 0, (chooser->get_view_mode () ==
95 PickView::views::Category) ? 0 : 1);
96
97 if (chooser->contents.itemcount () == 0)
98 {
99 static const char *msg = "Nothing to Install/Update";
100 if (source == IDC_SOURCE_DOWNLOAD)
101 msg = "Nothing to Download";
102 TextOut (hdc, HMARGIN, chooser->header_height, msg, strlen (msg));
103 }
104
105 EndPaint (hwnd, &ps);
106 }
107
108 static LRESULT CALLBACK
109 list_vscroll (HWND hwnd, HWND hctl, UINT code, int pos)
110 {
111 chooser->scroll (hwnd, SB_VERT, &chooser->scroll_ulc_y, code);
112 return 0;
113 }
114
115 static LRESULT CALLBACK
116 list_hscroll (HWND hwnd, HWND hctl, UINT code, int pos)
117 {
118 chooser->scroll (hwnd, SB_HORZ, &chooser->scroll_ulc_x, code);
119 return 0;
120 }
121
122 static LRESULT CALLBACK
123 list_click (HWND hwnd, BOOL dblclk, int x, int y, UINT hitCode)
124 {
125 int row, refresh;
126
127 if (chooser->contents.itemcount () == 0)
128 return 0;
129
130 if (y < chooser->header_height)
131 return 0;
132 x += chooser->scroll_ulc_x;
133 y += chooser->scroll_ulc_y - chooser->header_height;
134
135 row = (y + ROW_MARGIN / 2) / chooser->row_height;
136
137 if (row < 0 || row >= chooser->contents.itemcount ())
138 return 0;
139
140 refresh = chooser->click (row, x);
141
142 // XXX we need a method to queryt he database to see if more
143 // than just one package has changed! Until then...
144 #if 0
145 if (refresh)
146 {
147 #endif
148 RECT r;
149 GetClientRect (lv, &r);
150 SCROLLINFO si;
151 memset (&si, 0, sizeof (si));
152 si.cbSize = sizeof (si);
153 si.fMask = SIF_ALL; /* SIF_RANGE was giving strange behaviour */
154 si.nMin = 0;
155
156 si.nMax = chooser->contents.itemcount () * chooser->row_height;
157 si.nPage = r.bottom - chooser->header_height;
158
159 /* if we are under the minimum display count ,
160 * set the offset to 0
161 */
162 if ((unsigned int) si.nMax <= si.nPage)
163 chooser->scroll_ulc_y = 0;
164 si.nPos = chooser->scroll_ulc_y;
165
166 SetScrollInfo (lv, SB_VERT, &si, TRUE);
167
168 InvalidateRect (lv, &r, TRUE);
169 #if 0
170 }
171 else
172 {
173 RECT rect;
174 rect.left =
175 chooser->headers[chooser->new_col].x - chooser->scroll_ulc_x;
176 rect.right =
177 chooser->headers[chooser->src_col + 1].x - chooser->scroll_ulc_x;
178 rect.top =
179 chooser->header_height + row * chooser->row_height -
180 chooser->scroll_ulc_y;
181 rect.bottom = rect.top + chooser->row_height;
182 InvalidateRect (hwnd, &rect, TRUE);
183 }
184 #endif
185 return 0;
186 }
187
188 static LRESULT CALLBACK
189 listview_proc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
190 {
191 switch (message)
192 {
193 case WM_HSCROLL:
194 return HANDLE_WM_HSCROLL (hwnd, wParam, lParam, list_hscroll);
195 case WM_VSCROLL:
196 return HANDLE_WM_VSCROLL (hwnd, wParam, lParam, list_vscroll);
197 case WM_LBUTTONDOWN:
198 return HANDLE_WM_LBUTTONDOWN (hwnd, wParam, lParam, list_click);
199 case WM_PAINT:
200 paint (hwnd);
201 return 0;
202 case WM_NOTIFY:
203 {
204 // pnmh = (LPNMHDR) lParam
205 LPNMHEADER phdr = (LPNMHEADER) lParam;
206 switch (phdr->hdr.code)
207 {
208 case HDN_ITEMCHANGED:
209 if (phdr->hdr.hwndFrom == chooser->ListHeader ())
210 {
211 if (phdr->pitem && phdr->pitem->mask & HDI_WIDTH)
212 chooser->headers[phdr->iItem].width = phdr->pitem->cxy;
213 for (int i = 1; i <= chooser->last_col; i++)
214 chooser->headers[i].x =
215 chooser->headers[i - 1].x + chooser->headers[i - 1].width;
216 RECT r;
217 GetClientRect (hwnd, &r);
218 SCROLLINFO si;
219 si.cbSize = sizeof (si);
220 si.fMask = SIF_ALL;
221 GetScrollInfo (hwnd, SB_HORZ, &si);
222 int oldMax = si.nMax;
223 si.nMax =
224 chooser->headers[chooser->last_col].x +
225 chooser->headers[chooser->last_col].width;
226 if (si.nTrackPos && oldMax > si.nMax)
227 si.nTrackPos += si.nMax - oldMax;
228 si.nPage = r.right;
229 SetScrollInfo (hwnd, SB_HORZ, &si, TRUE);
230 InvalidateRect (hwnd, &r, TRUE);
231 if (si.nTrackPos && oldMax > si.nMax)
232 chooser->scroll (hwnd, SB_HORZ, &chooser->scroll_ulc_x,
233 SB_THUMBTRACK);
234 }
235 break;
236 default:
237 break;
238 }
239 }
240 default:
241 return DefWindowProc (hwnd, message, wParam, lParam);
242 }
243 }
244
245 static void
246 register_windows (HINSTANCE hinst)
247 {
248 WNDCLASSEX wcex;
249 static int done = 0;
250
251 if (done)
252 return;
253 done = 1;
254
255 memset (&wcex, 0, sizeof (wcex));
256 wcex.cbSize = sizeof (WNDCLASSEX);
257 wcex.style = CS_HREDRAW | CS_VREDRAW;
258 wcex.lpfnWndProc = listview_proc;
259 wcex.hInstance = hinst;
260 wcex.hIcon = LoadIcon (0, IDI_APPLICATION);
261 wcex.hCursor = LoadCursor (0, IDC_ARROW);
262 wcex.hbrBackground = (HBRUSH) (COLOR_WINDOW + 1);
263 wcex.lpszClassName = "listview";
264
265 RegisterClassEx (&wcex);
266 }
267
268 static void
269 set_existence ()
270 {
271 packagedb db;
272 /* Remove packages that are in the db, not installed, and have no
273 mirror info. */
274 size_t n = 1;
275 while (n <= db.packages.number ())
276 {
277 packagemeta & pkg = *db.packages[n];
278 bool mirrors = false;
279 size_t o = 1;
280 while (o <= pkg.versions.number () && !mirrors)
281 {
282 packageversion & ver = *pkg.versions[o];
283 if (((source != IDC_SOURCE_CWD) && (ver.bin.sites.number ()
284 || ver.src.sites.number ()))
285 || ver.bin.Cached () || ver.src.Cached ())
286 mirrors = true;
287 ++o;
288 }
289 if (!pkg.installed && !mirrors)
290 {
291 packagemeta *pkgm = db.packages.removebyindex (n);
292 delete pkgm;
293 }
294 else
295 ++n;
296 }
297 }
298
299 static void
300 fill_missing_category ()
301 {
302 packagedb db;
303 for (size_t n = 1; n <= db.packages.number (); n++)
304 {
305 packagemeta & pkg = *db.packages[n];
306 if (!pkg.Categories.number ())
307 pkg.add_category (db.categories.registerbykey ("Misc"));
308 pkg.add_category (db.categories.registerbykey ("All"));
309 }
310 }
311
312 static void
313 default_trust (HWND h, trusts trust)
314 {
315 chooser->deftrust = trust;
316 packagedb db;
317 for (size_t n = 1; n <= db.packages.number (); n++)
318 {
319 packagemeta & pkg = *db.packages[n];
320 if (pkg.installed
321 || pkg.Categories.getbykey (db.categories.registerbykey ("Base"))
322 || pkg.Categories.getbykey (db.categories.registerbykey ("Misc")))
323 {
324 pkg.desired = pkg.trustp (trust);
325 if (pkg.desired)
326 {
327 pkg.desired->binpicked = pkg.desired == pkg.installed ? 0 : 1;
328 pkg.desired->srcpicked = 0;
329 }
330 }
331 else
332 pkg.desired = 0;
333 }
334 RECT r;
335 GetClientRect (h, &r);
336 InvalidateRect (h, &r, TRUE);
337 if (nextbutton)
338 SetFocus (nextbutton);
339 // and then do the same for categories with no packages.
340 size_t n = 1;
341 while (n <= db.categories.number ())
342 {
343 if (!db.categories[n]->packages)
344 {
345 Category *cat = db.categories.removebyindex (n);
346 delete cat;
347 }
348 else
349 ++n;
350 }
351 }
352
353 static void
354 set_view_mode (HWND h, PickView::views mode)
355 {
356 chooser->set_view_mode (mode);
357
358 chooser->clear_view ();
359 packagedb db;
360 if (chooser->get_view_mode () == PickView::views::Package)
361 {
362 for (size_t n = 1; n <= db.packages.number (); n++)
363 {
364 packagemeta & pkg = *db.packages[n];
365 if ((!pkg.desired && pkg.installed)
366 || (pkg.desired
367 && (pkg.desired->srcpicked || pkg.desired->binpicked)))
368 chooser->insert_pkg (pkg);
369 }
370 }
371 else if (chooser->get_view_mode () == PickView::views::PackageFull)
372 {
373 for (size_t n = 1; n <= db.packages.number (); n++)
374 {
375 packagemeta & pkg = *db.packages[n];
376 chooser->insert_pkg (pkg);
377 }
378 }
379 else if (chooser->get_view_mode () == PickView::views::Category)
380 {
381 /* start collapsed. TODO: make this a chooser flag */
382 for (size_t n = 1; n <= db.categories.number (); n++)
383 chooser->insert_category (db.categories[n], CATEGORY_COLLAPSED);
384 }
385
386 RECT r;
387 GetClientRect (h, &r);
388 SCROLLINFO si;
389 memset (&si, 0, sizeof (si));
390 si.cbSize = sizeof (si);
391 si.fMask = SIF_ALL;
392 si.nMin = 0;
393 si.nMax = chooser->headers[chooser->last_col].x + chooser->headers[chooser->last_col].width; // + HMARGIN;
394 si.nPage = r.right;
395 SetScrollInfo (h, SB_HORZ, &si, TRUE);
396
397 si.nMax = chooser->contents.itemcount () * chooser->row_height;
398 si.nPage = r.bottom - chooser->header_height;
399 SetScrollInfo (h, SB_VERT, &si, TRUE);
400
401 chooser->scroll_ulc_x = chooser->scroll_ulc_y = 0;
402
403 InvalidateRect (h, &r, TRUE);
404
405 if (nextbutton)
406 SetFocus (nextbutton);
407 }
408
409 static void
410 create_listview (HWND dlg, RECT * r)
411 {
412 lv = CreateWindowEx (WS_EX_CLIENTEDGE,
413 "listview",
414 "listviewwindow",
415 WS_CHILD | WS_HSCROLL | WS_VSCROLL | WS_VISIBLE,
416 r->left, r->top,
417 r->right - r->left + 1, r->bottom - r->top + 1,
418 dlg,
419 (HMENU) MAKEINTRESOURCE (IDC_CHOOSE_LIST),
420 hinstance, 0);
421 ShowWindow (lv, SW_SHOW);
422 packagedb db;
423 chooser =
424 new PickView (PickView::views::Category, lv,
425 db.categories.registerbykey ("All"));
426
427 default_trust (lv, TRUST_CURR);
428 set_view_mode (lv, PickView::views::Category);
429 if (!SetDlgItemText (dlg, IDC_CHOOSE_VIEWCAPTION, chooser->mode_caption ()))
430 log (LOG_BABBLE, "Failed to set View button caption %ld",
431 GetLastError ());
432 for (size_t n = 1; n <= db.packages.number (); n++)
433 {
434 packagemeta & pkg = *db.packages[n];
435 pkg.set_requirements (chooser->deftrust);
436 }
437 /* FIXME: do we need to init the desired fields ? */
438 static int ta[] = { IDC_CHOOSE_CURR, 0 };
439 rbset (dlg, ta, IDC_CHOOSE_CURR);
440
441 }
442
443 static BOOL
444 dialog_cmd (HWND h, int id, HWND hwndctl, UINT code)
445 {
446 packagedb db;
447 switch (id)
448 {
449 case IDC_CHOOSE_PREV:
450 default_trust (lv, TRUST_PREV);
451 for (size_t n = 1; n <= db.packages.number (); n++)
452 {
453 packagemeta & pkg = *db.packages[n];
454 pkg.set_requirements (TRUST_PREV);
455 }
456 set_view_mode (lv, chooser->get_view_mode ());
457 break;
458 case IDC_CHOOSE_CURR:
459 default_trust (lv, TRUST_CURR);
460 for (size_t n = 1; n <= db.packages.number (); n++)
461 {
462 packagemeta & pkg = *db.packages[n];
463 pkg.set_requirements (TRUST_CURR);
464 }
465 set_view_mode (lv, chooser->get_view_mode ());
466 break;
467 case IDC_CHOOSE_EXP:
468 default_trust (lv, TRUST_TEST);
469 for (size_t n = 1; n <= db.packages.number (); n++)
470 {
471 packagemeta & pkg = *db.packages[n];
472 pkg.set_requirements (TRUST_TEST);
473 }
474 set_view_mode (lv, chooser->get_view_mode ());
475 break;
476 case IDC_CHOOSE_VIEW:
477 set_view_mode (lv, ++chooser->get_view_mode ());
478 if (!SetDlgItemText
479 (h, IDC_CHOOSE_VIEWCAPTION, chooser->mode_caption ()))
480 log (LOG_BABBLE, "Failed to set View button caption %ld",
481 GetLastError ());
482 break;
483
484 case IDOK:
485 if (source == IDC_SOURCE_CWD)
486 NEXT (IDD_S_INSTALL);
487 else
488 NEXT (IDD_S_DOWNLOAD);
489 break;
490
491 case IDC_BACK:
492 initialized = 0;
493 if (source == IDC_SOURCE_CWD)
494 NEXT (IDD_LOCAL_DIR);
495 else
496 NEXT (IDD_SITE);
497 break;
498
499 case IDCANCEL:
500 NEXT (0);
501 break;
502 }
503 return 0;
504 }
505
506 static void
507 GetParentRect (HWND parent, HWND child, RECT * r)
508 {
509 POINT p;
510 GetWindowRect (child, r);
511 p.x = r->left;
512 p.y = r->top;
513 ScreenToClient (parent, &p);
514 r->left = p.x;
515 r->top = p.y;
516 p.x = r->right;
517 p.y = r->bottom;
518 ScreenToClient (parent, &p);
519 r->right = p.x;
520 r->bottom = p.y;
521 }
522
523 static BOOL CALLBACK
524 dialog_proc (HWND h, UINT message, WPARAM wParam, LPARAM lParam)
525 {
526 HWND frame;
527 RECT r;
528 switch (message)
529 {
530 case WM_INITDIALOG:
531 nextbutton = GetDlgItem (h, IDOK);
532 frame = GetDlgItem (h, IDC_LISTVIEW_POS);
533 choose_inst_text = GetDlgItem (h, IDC_CHOOSE_INST_TEXT);
534 if (source == IDC_SOURCE_DOWNLOAD)
535 SetWindowText (choose_inst_text, "Select packages to download ");
536 else
537 SetWindowText (choose_inst_text, "Select packages to install ");
538 GetParentRect (h, frame, &r);
539 r.top += 2;
540 r.bottom -= 2;
541 create_listview (h, &r);
542
543 #if 0
544 load_dialog (h);
545 #endif
546 return TRUE;
547 case WM_COMMAND:
548 return HANDLE_WM_COMMAND (h, wParam, lParam, dialog_cmd);
549 }
550 return FALSE;
551 }
552
553 /* Find out where to put existing tar file in local directory in
554 known package array. */
555 static void
556 scan2 (char *path, unsigned int size)
557 {
558 packagemeta *pkg;
559 fileparse f;
560
561 if (!parse_filename (path, f))
562 return;
563
564 #if 0
565 // only process source package files?
566 if (f.what.size () != 0 && f.what.cstr_oneuse ()[0] != 's')
567 return;
568 #endif
569
570 packagedb db;
571 pkg = db.packages.getbykey (f.pkg);
572 if (pkg == NULL)
573 return;
574
575 /* Scan existing package list looking for a match between a known
576 package and a tar archive on disk.
577 While scanning, keep track of appropriate "holes" in the trust
578 table where a tar file could be put if no known entry
579 exists.
580
581 We have 4 specific insertion points and one generic point.
582 The generic point is in versioned order in the package version array.
583 The specific points are
584 *installed
585 *prev
586 *curr
587 *exp.
588
589 if the version number matches a version in the db,
590 we simply add this as a mirror source to that version.
591 If it matches no version, we add a new version to the db.
592
593 Lastly if the version number does not matche one of installed/prev/current/exp
594 AND we had to create a new version entry
595 we apply the following heuristic:
596 if there is no exp, we link this in exp.
597 If there is an exp and this is higher, we link this in exp, and
598 if there is no curr, bump what was in exp to curr. If there was a curr, we leave it be.
599 if this is lower than exp, and there is no curr, link as curr. If there is a curr, leave it be.
600 If this is lower than curr, and there is no prev, link as prev, if there is a prev, leave it be.
601
602 Whilst this logic is potentially wrong from time to time, it guarantees that
603 setup.ini defined stability won't be altered unintentially. An alternative is to
604 mark setup.ini defined prev/curr/exp packages as such, when this algorithm, can
605 get smarter.
606
607 So, if setup.ini knows that ash-20010425-1.tar.gz is the current
608 version and there is an ash-20010426-1.tar.gz in the current directory,
609 the 20010426 version will be placed in the "test" slot, assuming that
610 there is no test version listed in setup.ini. */
611
612 int added = 0;
613 for (size_t n = 1; n <= pkg->versions.number (); n++)
614 {
615 if (!f.ver.casecompare (pkg->versions[n]->Canonical_version ()))
616 {
617 if (f.what == String ())
618 {
619 //bin package
620 pkg->versions[n]->bin.set_cached (String ("file://") + path);
621 }
622 else if (f.what == "src")
623 {
624 //src package
625 pkg->versions[n]->src.set_cached (String ("file://") + path);
626 }
627 added = 1;
628 }
629 }
630 if (!added)
631 {
632 #if 0
633 // Do we want old versions to show up
634 packageversion *pv = new cygpackage (f.pkg);
635 ((cygpackage *) pv)->set_canonical_version (f.ver);
636 if (!f.what.size ())
637 pv->bin.set_cached (String ("file://") + path);
638 else
639 // patch or src, assume src until someone complains
640 pv->src.set_cached (String ("file://") + path);
641 pkg->add_version (*pv);
642
643 #endif
644
645 /* And now the hole finder */
646 #if 0
647 if (!pkg->exp)
648 pkg->exp = thenewver;
649 else if (strcasecmp (f.ver, pkg->versions[n]->Canonicalversion ()) < 0)
650 /* try curr */
651 if (!pkg->curr)
652 pkg->curr = thenewver;
653 else if (strcasecmp (f.ver, pkg->versions[n]->Canonicalversion ()) <
654 0)
655 /* try prev */
656 if (!pkg->prev)
657 pkg->prev = thenewver;
658 #endif
659 }
660
661 }
662
663 static void
664 scan_downloaded_files ()
665 {
666 find (".", scan2);
667 }
668
669 void
670 do_choose (HINSTANCE h, HWND owner)
671 {
672 int rv;
673
674 nextbutton = 0;
675
676 register_windows (h);
677
678 if (source == IDC_SOURCE_DOWNLOAD || source == IDC_SOURCE_CWD)
679 scan_downloaded_files ();
680
681 set_existence ();
682 fill_missing_category ();
683
684 rv = DialogBox (h, MAKEINTRESOURCE (IDD_CHOOSE), owner, dialog_proc);
685 if (rv == -1)
686 fatal (owner, IDS_DIALOG_FAILED);
687
688 log (LOG_BABBLE, "Chooser results...");
689 packagedb db;
690 for (size_t n = 1; n <= db.packages.number (); n++)
691 {
692 packagemeta & pkg = *db.packages[n];
693 // static const char *infos[] = { "nada", "prev", "curr", "test" };
694 const char *trust = ((pkg.desired == pkg.prev) ? "prev"
695 : (pkg.desired == pkg.curr) ? "curr"
696 : (pkg.desired == pkg.exp) ? "test" : "unknown");
697 String action = pkg.action_caption ();
698 String const installed =
699 pkg.installed ? pkg.installed->Canonical_version () : "none";
700
701 log (LOG_BABBLE, "[%s] action=%s trust=%s installed=%s"
702 " src?=%s",
703 pkg.name.cstr_oneuse (), action.cstr_oneuse (), trust,
704 installed.cstr_oneuse (), pkg.desired
705 && pkg.desired->srcpicked ? "yes" : "no");
706 if (pkg.Categories.number ())
707 {
708 /* List categories the package belongs to */
709 String all_categories = pkg.Categories[1]->key.name;
710 for (size_t n = 2; n <= pkg.Categories.number (); n++)
711 all_categories += String (", ") + pkg.Categories[n]->key.name;
712
713 log (LOG_BABBLE, String (" categories=") + all_categories);
714 }
715 if (pkg.desired && pkg.desired->required)
716 {
717 /* List other packages this package depends on */
718 Dependency *dp = pkg.desired->required;
719 String requires = dp->package;
720 for (dp = dp->next; dp; dp = dp->next)
721 if (dp->package.size ())
722 requires += String (", ") + dp->package;
723
724 log (LOG_BABBLE, String (" requires=") + requires);
725 }
726 #if 0
727
728 /* FIXME: Reinstate this code, but spit out all mirror sites */
729
730 for (int t = 1; t < NTRUST; t++)
731 {
732 if (pkg->info[t].install)
733 log (LOG_BABBLE, " [%s] ver=%s\n"
734 " inst=%s %d exists=%s\n"
735 " src=%s %d exists=%s",
736 infos[t],
737 pkg->info[t].version ? : "(none)",
738 pkg->info[t].install ? : "(none)",
739 pkg->info[t].install_size,
740 (pkg->info[t].install_exists) ? "yes" : "no",
741 pkg->info[t].source ? : "(none)",
742 pkg->info[t].source_size,
743 (pkg->info[t].source_exists) ? "yes" : "no");
744 }
745 #endif
746 }
747 }
748
749 #define WM_APP_START_CHOOSE WM_APP+0
750 #define WM_APP_CHOOSE_IS_FINISHED WM_APP+1
751
752 extern void do_choose (HINSTANCE h, HWND owner);
753
754 void
755 do_choose_thread (void *p)
756 {
757 ChooserPage *cp;
758
759 cp = static_cast < ChooserPage * >(p);
760
761 do_choose (cp->GetInstance (), cp->GetHWND ());
762
763 cp->PostMessage (WM_APP_CHOOSE_IS_FINISHED);
764
765 _endthread ();
766 }
767
768 bool ChooserPage::Create ()
769 {
770 return PropertyPage::Create (IDD_CHOOSER);
771 }
772
773 void
774 ChooserPage::OnActivate ()
775 {
776 GetOwner ()->SetButtons (0);
777 PostMessage (WM_APP_START_CHOOSE);
778 }
779
780 bool ChooserPage::OnMessageApp (UINT uMsg, WPARAM wParam, LPARAM lParam)
781 {
782 switch (uMsg)
783 {
784 case WM_APP_START_CHOOSE:
785 {
786 // Start the chooser thread.
787 _beginthread (do_choose_thread, 0, this);
788 break;
789 }
790 case WM_APP_CHOOSE_IS_FINISHED:
791 {
792 switch (next_dialog)
793 {
794 case 0:
795 {
796 // Cancel
797 GetOwner ()->PressButton (PSBTN_CANCEL);
798 break;
799 }
800 case IDD_LOCAL_DIR:
801 case IDD_SITE:
802 {
803 // Back
804 GetOwner ()->SetActivePageByID (next_dialog);
805 break;
806 }
807 case IDD_S_DOWNLOAD:
808 {
809 // Next, start download from internet
810 Progress.SetActivateTask (WM_APP_START_DOWNLOAD);
811 GetOwner ()->SetActivePageByID (IDD_INSTATUS);
812 break;
813 }
814 case IDD_S_INSTALL:
815 {
816 // Next, install
817 Progress.SetActivateTask (WM_APP_START_INSTALL);
818 GetOwner ()->SetActivePageByID (IDD_INSTATUS);
819 break;
820 }
821 }
822 }
823 default:
824 return false;
825 break;
826 }
827 return true;
828 }
This page took 0.072059 seconds and 5 git commands to generate.