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.
9 * A copy of the GNU General Public License can be found at
18 #include "ControlAdjuster.h"
19 #include "package_db.h"
20 #include "package_meta.h"
24 extern ThreeBarProgressPage Progress
;
26 // Sizing information.
27 static ControlAdjuster::ControlInfo ConfirmControlsInfo
[] = {
28 {IDC_CONFIRM_EDIT
, CP_STRETCH
, CP_STRETCH
},
32 // ---------------------------------------------------------------------------
33 // implements class ConfirmPage
34 // ---------------------------------------------------------------------------
36 ConfirmPage::ConfirmPage ()
38 sizeProcessor
.AddControlInfo (ConfirmControlsInfo
);
42 ConfirmPage::Create ()
44 return PropertyPage::Create (IDD_CONFIRM
);
48 ConfirmPage::OnInit ()
50 // set the edit-area to a larger font
51 SetDlgItemFont(IDC_CONFIRM_EDIT
, "MS Shell Dlg", 10);
55 ConfirmPage::OnActivate()
57 // generate a report on actions we're going to take
61 const SolverTransactionList
& trans
= db
.solution
.transactions ();
63 // first list things we will erase
64 if (source
!= IDC_SOURCE_DOWNLOAD
)
66 std::vector
<std::wstring
> erase
;
67 for (SolverTransactionList::const_iterator i
= trans
.begin ();
68 i
!= trans
.end (); i
++)
70 if (i
->type
== SolverTransaction::transErase
)
72 packageversion pv
= i
->version
;
73 packagemeta
*pkg
= db
.findBinary (PackageSpecification (pv
.Name ()));
75 std::wstring action
= LoadStringW(IDS_CONFIRM_UNINSTALL
);
76 std::wstring line
= format(L
"%ls %s %s", action
.c_str(),
77 i
->version
.Name().c_str(),
78 i
->version
.Canonical_version().c_str());
79 if (pkg
&& pkg
->desired
)
82 line
+= LoadStringW(IDS_CONFIRM_AUTO_ADD
);
85 erase
.push_back (line
);
88 sort (erase
.begin(), erase
.end());
89 for (std::vector
<std::wstring
>::const_iterator i
= erase
.begin ();
90 i
!= erase
.end(); i
++)
94 // then list things downloaded or installed
95 std::vector
<std::wstring
> install
;
96 for (SolverTransactionList::const_iterator i
= trans
.begin ();
97 i
!= trans
.end (); i
++)
99 packageversion pv
= i
->version
;
100 packagemeta
*pkg
= db
.findBinary (PackageSpecification (pv
.Name ()));
102 if (i
->type
== SolverTransaction::transInstall
)
105 if (source
!= IDC_SOURCE_DOWNLOAD
)
106 action
= LoadStringW(IDS_CONFIRM_INSTALL
);
108 action
= LoadStringW(IDS_CONFIRM_DOWNLOAD
);
110 std::wstring line
= format(L
"%ls %s %s", action
.c_str(),
111 i
->version
.Name().c_str(),
112 i
->version
.Canonical_version().c_str());
114 if (i
->version
.Type() == package_source
)
117 line
+= LoadStringW(IDS_CONFIRM_SOURCE
);
119 else if (pkg
&& pkg
->desired
!= pv
)
122 line
+= LoadStringW(IDS_CONFIRM_AUTO_ADD
);
125 install
.push_back (line
);
128 sort (install
.begin(), install
.end());
129 for (std::vector
<std::wstring
>::const_iterator i
= install
.begin ();
130 i
!= install
.end(); i
++)
133 // be explicit about doing nothing
135 s
+= LoadStringW(IDS_CONFIRM_NOTHING
);
137 SetDlgItemTextW (GetHWND (), IDC_CONFIRM_EDIT
, s
.c_str ());
139 // move focus to 'next' button, so enter doesn't get eaten by edit control
140 HWND nextButton
= ::GetDlgItem(::GetParent(GetHWND()), 0x3024 /* ID_WIZNEXT */);
141 PostMessage (GetHWND (), WM_NEXTDLGCTL
, (WPARAM
)nextButton
, TRUE
);
145 ConfirmPage::OnNext ()
151 ConfirmPage::whatNext ()
153 if (source
== IDC_SOURCE_LOCALDIR
)
156 Progress
.SetActivateTask (WM_APP_START_INSTALL
);
160 // Next, start download from internet
161 Progress
.SetActivateTask (WM_APP_START_DOWNLOAD
);
167 ConfirmPage::OnBack ()
173 ConfirmPage::OnUnattended ()