xref: /haiku/src/apps/bootmanager/BootManagerController.cpp (revision aed35104852941f0f6f3d1dcc5338b5f337d0a3c)
1b76ca311SAxel Dörfler /*
2197f59b0SAxel Dörfler  * Copyright 2008-2011, Haiku, Inc. All rights reserved.
3b76ca311SAxel Dörfler  * Distributed under the terms of the MIT License.
4b76ca311SAxel Dörfler  *
5b76ca311SAxel Dörfler  * Authors:
649c044abSAxel Dörfler  *		Axel Dörfler, axeld@pinc-software.de
7b76ca311SAxel Dörfler  *		Michael Pfeiffer <laplace@users.sourceforge.net>
8b76ca311SAxel Dörfler  */
9b76ca311SAxel Dörfler 
10b76ca311SAxel Dörfler 
11b76ca311SAxel Dörfler #include "BootManagerController.h"
12b76ca311SAxel Dörfler 
13b76ca311SAxel Dörfler #include <Alert.h>
14b76ca311SAxel Dörfler #include <Application.h>
15b76ca311SAxel Dörfler #include <Catalog.h>
16b76ca311SAxel Dörfler #include <File.h>
17b76ca311SAxel Dörfler #include <FindDirectory.h>
18b76ca311SAxel Dörfler #include <Locale.h>
19b76ca311SAxel Dörfler #include <Path.h>
20b76ca311SAxel Dörfler #include <String.h>
21b76ca311SAxel Dörfler 
2249c044abSAxel Dörfler #include "BootDrive.h"
23b76ca311SAxel Dörfler #include "DefaultPartitionPage.h"
24b76ca311SAxel Dörfler #include "DescriptionPage.h"
255675f44eSAxel Dörfler #include "DrivesPage.h"
26b76ca311SAxel Dörfler #include "FileSelectionPage.h"
275675f44eSAxel Dörfler #include "LegacyBootMenu.h"
28b76ca311SAxel Dörfler #include "PartitionsPage.h"
29b76ca311SAxel Dörfler #include "WizardView.h"
30b76ca311SAxel Dörfler 
31b76ca311SAxel Dörfler 
32546208a5SOliver Tappe #undef B_TRANSLATION_CONTEXT
33546208a5SOliver Tappe #define B_TRANSLATION_CONTEXT "BootManagerController"
34b76ca311SAxel Dörfler 
35b76ca311SAxel Dörfler 
36b76ca311SAxel Dörfler BootManagerController::BootManagerController()
3749c044abSAxel Dörfler 	:
3849c044abSAxel Dörfler 	fBootDrive(NULL),
3949c044abSAxel Dörfler 	fBootMenu(NULL)
40b76ca311SAxel Dörfler {
41b76ca311SAxel Dörfler 	// set defaults
42b76ca311SAxel Dörfler 	fSettings.AddBool("install", true);
43b76ca311SAxel Dörfler 	fSettings.AddInt32("defaultPartition", 0);
44b76ca311SAxel Dörfler 	fSettings.AddInt32("timeout", -1);
45b76ca311SAxel Dörfler 
46b76ca311SAxel Dörfler 	BPath path;
47b76ca311SAxel Dörfler 	if (find_directory(B_USER_SETTINGS_DIRECTORY, &path, true) == B_OK) {
48b76ca311SAxel Dörfler 		path.Append("bootman/MBR");
49b76ca311SAxel Dörfler 		fSettings.AddString("file", path.Path());
50b76ca311SAxel Dörfler 		// create directory
51b76ca311SAxel Dörfler 		BPath parent;
52b76ca311SAxel Dörfler 		if (path.GetParent(&parent) == B_OK) {
53b76ca311SAxel Dörfler 			BDirectory directory;
54b76ca311SAxel Dörfler 			directory.CreateDirectory(parent.Path(), NULL);
55b76ca311SAxel Dörfler 		}
56b76ca311SAxel Dörfler 	} else {
57b76ca311SAxel Dörfler 		fSettings.AddString("file", "");
58b76ca311SAxel Dörfler 	}
59b76ca311SAxel Dörfler 
6049c044abSAxel Dörfler 	// That's the only boot menu we support at the moment.
6149c044abSAxel Dörfler 	fBootMenus.AddItem(new LegacyBootMenu());
62b76ca311SAxel Dörfler }
63b76ca311SAxel Dörfler 
64b76ca311SAxel Dörfler 
65b76ca311SAxel Dörfler BootManagerController::~BootManagerController()
66b76ca311SAxel Dörfler {
67b76ca311SAxel Dörfler }
68b76ca311SAxel Dörfler 
69b76ca311SAxel Dörfler 
705675f44eSAxel Dörfler void
715675f44eSAxel Dörfler BootManagerController::Previous(WizardView* wizard)
725675f44eSAxel Dörfler {
735675f44eSAxel Dörfler 	if (CurrentState() != kStateEntry)
745675f44eSAxel Dörfler 		WizardController::Previous(wizard);
755675f44eSAxel Dörfler 	else {
765675f44eSAxel Dörfler 		fSettings.ReplaceBool("install", false);
7749c044abSAxel Dörfler 		WizardController::Next(wizard);
785675f44eSAxel Dörfler 	}
795675f44eSAxel Dörfler }
805675f44eSAxel Dörfler 
815675f44eSAxel Dörfler 
82b76ca311SAxel Dörfler int32
83b76ca311SAxel Dörfler BootManagerController::InitialState()
84b76ca311SAxel Dörfler {
85b76ca311SAxel Dörfler 	return kStateEntry;
86b76ca311SAxel Dörfler }
87b76ca311SAxel Dörfler 
88b76ca311SAxel Dörfler 
89b76ca311SAxel Dörfler int32
90b76ca311SAxel Dörfler BootManagerController::NextState(int32 state)
91b76ca311SAxel Dörfler {
92b76ca311SAxel Dörfler 	switch (state) {
93b76ca311SAxel Dörfler 		case kStateEntry:
94b76ca311SAxel Dörfler 		{
9549c044abSAxel Dörfler 			const char* path;
9649c044abSAxel Dörfler 			if (fSettings.FindString("disk", &path) != B_OK)
9749c044abSAxel Dörfler 				return kStateErrorEntry;
98b76ca311SAxel Dörfler 
9949c044abSAxel Dörfler 			delete fBootDrive;
10049c044abSAxel Dörfler 
10149c044abSAxel Dörfler 			fBootDrive = new BootDrive(path);
10249c044abSAxel Dörfler 			fBootMenu = fBootDrive->InstalledMenu(fBootMenus);
10349c044abSAxel Dörfler 
10449c044abSAxel Dörfler 			if (fSettings.FindBool("install")) {
10549c044abSAxel Dörfler 				int32 nextState = fBootMenu != NULL
10649c044abSAxel Dörfler 					? kStatePartitions : kStateSaveMBR;
10749c044abSAxel Dörfler 
10849c044abSAxel Dörfler 				// TODO: call BootDrive::AddSupportedMenus() once we support
10949c044abSAxel Dörfler 				// more than one type of boot menu - we'll probably need a
11049c044abSAxel Dörfler 				// requester to choose from them then as well.
11149c044abSAxel Dörfler 				if (fBootMenu == NULL)
11249c044abSAxel Dörfler 					fBootMenu = fBootMenus.ItemAt(0);
11349c044abSAxel Dörfler 
11449c044abSAxel Dörfler 				fCollectPartitionsStatus = fBootMenu->CollectPartitions(
11549c044abSAxel Dörfler 					*fBootDrive, fSettings);
11649c044abSAxel Dörfler 
11749c044abSAxel Dörfler 				return nextState;
118b76ca311SAxel Dörfler 			}
119b76ca311SAxel Dörfler 
120b76ca311SAxel Dörfler 			return kStateUninstall;
121b76ca311SAxel Dörfler 		}
122b76ca311SAxel Dörfler 
123b76ca311SAxel Dörfler 		case kStateErrorEntry:
124b76ca311SAxel Dörfler 			be_app->PostMessage(B_QUIT_REQUESTED);
125b76ca311SAxel Dörfler 			break;
126b76ca311SAxel Dörfler 
127b76ca311SAxel Dörfler 		case kStateSaveMBR:
128b76ca311SAxel Dörfler 			if (_SaveMBR())
129b76ca311SAxel Dörfler 				return kStateMBRSaved;
130b76ca311SAxel Dörfler 			break;
131b76ca311SAxel Dörfler 
132b76ca311SAxel Dörfler 		case kStateMBRSaved:
133b76ca311SAxel Dörfler 			return kStatePartitions;
134b76ca311SAxel Dörfler 
135b76ca311SAxel Dörfler 		case kStatePartitions:
136b76ca311SAxel Dörfler 			if (_HasSelectedPartitions())
137b76ca311SAxel Dörfler 				return kStateDefaultPartitions;
138b76ca311SAxel Dörfler 			break;
139b76ca311SAxel Dörfler 
140b76ca311SAxel Dörfler 		case kStateDefaultPartitions:
141b76ca311SAxel Dörfler 			return kStateInstallSummary;
142b76ca311SAxel Dörfler 
143b76ca311SAxel Dörfler 		case kStateInstallSummary:
144b76ca311SAxel Dörfler 			if (_WriteBootMenu())
145b76ca311SAxel Dörfler 				return kStateInstalled;
146b76ca311SAxel Dörfler 			break;
147b76ca311SAxel Dörfler 
148b76ca311SAxel Dörfler 		case kStateInstalled:
149b76ca311SAxel Dörfler 			be_app->PostMessage(B_QUIT_REQUESTED);
150b76ca311SAxel Dörfler 			break;
151b76ca311SAxel Dörfler 
152b76ca311SAxel Dörfler 		case kStateUninstall:
153b76ca311SAxel Dörfler 			if (_RestoreMBR())
154b76ca311SAxel Dörfler 				return kStateUninstalled;
155b76ca311SAxel Dörfler 			break;
156b76ca311SAxel Dörfler 
157b76ca311SAxel Dörfler 		case kStateUninstalled:
158b76ca311SAxel Dörfler 			be_app->PostMessage(B_QUIT_REQUESTED);
159b76ca311SAxel Dörfler 			break;
160b76ca311SAxel Dörfler 	}
161b76ca311SAxel Dörfler 	// cannot leave the current state/page
162b76ca311SAxel Dörfler 	return -1;
163b76ca311SAxel Dörfler }
164b76ca311SAxel Dörfler 
165b76ca311SAxel Dörfler 
166b76ca311SAxel Dörfler bool
167b76ca311SAxel Dörfler BootManagerController::_HasSelectedPartitions()
168b76ca311SAxel Dörfler {
169b76ca311SAxel Dörfler 	BMessage message;
170b76ca311SAxel Dörfler 	for (int32 i = 0; fSettings.FindMessage("partition", i, &message) == B_OK;
171b76ca311SAxel Dörfler 			i++) {
172b76ca311SAxel Dörfler 		bool show;
173b76ca311SAxel Dörfler 		if (message.FindBool("show", &show) == B_OK && show)
174b76ca311SAxel Dörfler 			return true;
175b76ca311SAxel Dörfler 	}
176b76ca311SAxel Dörfler 
177b76ca311SAxel Dörfler 	BAlert* alert = new BAlert("info",
178b76ca311SAxel Dörfler 		B_TRANSLATE("At least one partition must be selected!"),
179b76ca311SAxel Dörfler 		B_TRANSLATE_COMMENT("OK", "Button"));
180*aed35104SHumdinger 	alert->SetFlags(alert->Flags() | B_CLOSE_ON_ESCAPE);
181b76ca311SAxel Dörfler 	alert->Go();
182b76ca311SAxel Dörfler 
183b76ca311SAxel Dörfler 	return false;
184b76ca311SAxel Dörfler }
185b76ca311SAxel Dörfler 
186b76ca311SAxel Dörfler 
187b76ca311SAxel Dörfler bool
188b76ca311SAxel Dörfler BootManagerController::_WriteBootMenu()
189b76ca311SAxel Dörfler {
190b76ca311SAxel Dörfler 	BAlert* alert = new BAlert("confirm", B_TRANSLATE("About to write the "
191b76ca311SAxel Dörfler 			"boot menu to disk. Are you sure you want to continue?"),
192b76ca311SAxel Dörfler 		B_TRANSLATE_COMMENT("Write boot menu", "Button"),
193b76ca311SAxel Dörfler 		B_TRANSLATE_COMMENT("Back", "Button"), NULL, B_WIDTH_AS_USUAL,
194b76ca311SAxel Dörfler 		B_WARNING_ALERT);
195b76ca311SAxel Dörfler 
196b76ca311SAxel Dörfler 	if (alert->Go() == 1)
197b76ca311SAxel Dörfler 		return false;
198b76ca311SAxel Dörfler 
19949c044abSAxel Dörfler 	fWriteBootMenuStatus = fBootMenu->Install(*fBootDrive, fSettings);
200b76ca311SAxel Dörfler 	return true;
201b76ca311SAxel Dörfler }
202b76ca311SAxel Dörfler 
203b76ca311SAxel Dörfler 
204b76ca311SAxel Dörfler bool
205b76ca311SAxel Dörfler BootManagerController::_SaveMBR()
206b76ca311SAxel Dörfler {
207b76ca311SAxel Dörfler 	BString path;
208b76ca311SAxel Dörfler 	fSettings.FindString("file", &path);
209b76ca311SAxel Dörfler 	BFile file(path.String(), B_READ_WRITE | B_CREATE_FILE | B_ERASE_FILE);
2105675f44eSAxel Dörfler 	fSaveMBRStatus = fBootMenu->SaveMasterBootRecord(&fSettings, &file);
211b76ca311SAxel Dörfler 	return true;
212b76ca311SAxel Dörfler }
213b76ca311SAxel Dörfler 
214b76ca311SAxel Dörfler 
215b76ca311SAxel Dörfler bool
216b76ca311SAxel Dörfler BootManagerController::_RestoreMBR()
217b76ca311SAxel Dörfler {
218b76ca311SAxel Dörfler 	BString disk;
219b76ca311SAxel Dörfler 	BString path;
220b76ca311SAxel Dörfler 	fSettings.FindString("disk", &disk);
221b76ca311SAxel Dörfler 	fSettings.FindString("file", &path);
222b76ca311SAxel Dörfler 
223b76ca311SAxel Dörfler 	BString message;
224b76ca311SAxel Dörfler 	message << B_TRANSLATE_COMMENT("About to restore the Master Boot Record "
225b76ca311SAxel Dörfler 		"(MBR) of %disk from %file. Do you wish to continue?",
226b76ca311SAxel Dörfler 		"Don't translate the place holders: %disk and %file");
227b76ca311SAxel Dörfler 	message.ReplaceFirst("%disk", disk);
228b76ca311SAxel Dörfler 	message.ReplaceFirst("%file", path);
229b76ca311SAxel Dörfler 
230b76ca311SAxel Dörfler 	BAlert* alert = new BAlert("confirm", message.String(),
231b76ca311SAxel Dörfler 		B_TRANSLATE_COMMENT("Restore MBR", "Button"),
232b76ca311SAxel Dörfler 		B_TRANSLATE_COMMENT("Back", "Button"),
233b76ca311SAxel Dörfler 		NULL, B_WIDTH_AS_USUAL, B_WARNING_ALERT);
234b76ca311SAxel Dörfler 	if (alert->Go() == 1)
235b76ca311SAxel Dörfler 		return false;
236b76ca311SAxel Dörfler 
237b76ca311SAxel Dörfler 	BFile file(path.String(), B_READ_ONLY);
2385675f44eSAxel Dörfler 	fRestoreMBRStatus = fBootMenu->RestoreMasterBootRecord(&fSettings, &file);
239b76ca311SAxel Dörfler 	return true;
240b76ca311SAxel Dörfler }
241b76ca311SAxel Dörfler 
242b76ca311SAxel Dörfler 
243b76ca311SAxel Dörfler WizardPageView*
244b76ca311SAxel Dörfler BootManagerController::CreatePage(int32 state, WizardView* wizard)
245b76ca311SAxel Dörfler {
246b76ca311SAxel Dörfler 	WizardPageView* page = NULL;
247197f59b0SAxel Dörfler 	BRect frame(0, 0, 300, 250);
248b76ca311SAxel Dörfler 
249b76ca311SAxel Dörfler 	switch (state) {
250b76ca311SAxel Dörfler 		case kStateEntry:
25149c044abSAxel Dörfler 			fSettings.ReplaceBool("install", true);
25249c044abSAxel Dörfler 			page = new DrivesPage(wizard, fBootMenus, &fSettings, "drives");
253b76ca311SAxel Dörfler 			break;
254b76ca311SAxel Dörfler 		case kStateErrorEntry:
255197f59b0SAxel Dörfler 			page = _CreateErrorEntryPage();
256b76ca311SAxel Dörfler 			wizard->SetPreviousButtonHidden(true);
257b76ca311SAxel Dörfler 			wizard->SetNextButtonLabel(B_TRANSLATE_COMMENT("Done", "Button"));
258b76ca311SAxel Dörfler 			break;
259b76ca311SAxel Dörfler 		case kStateSaveMBR:
260b76ca311SAxel Dörfler 			page = _CreateSaveMBRPage(frame);
261b76ca311SAxel Dörfler 			wizard->SetPreviousButtonHidden(false);
262b76ca311SAxel Dörfler 			break;
263b76ca311SAxel Dörfler 		case kStateMBRSaved:
264197f59b0SAxel Dörfler 			page = _CreateMBRSavedPage();
265b76ca311SAxel Dörfler 			break;
266b76ca311SAxel Dörfler 		case kStatePartitions:
267197f59b0SAxel Dörfler 			page = new PartitionsPage(&fSettings, "partitions");
268b76ca311SAxel Dörfler 			wizard->SetPreviousButtonHidden(false);
269b76ca311SAxel Dörfler 			break;
270b76ca311SAxel Dörfler 		case kStateDefaultPartitions:
271b76ca311SAxel Dörfler 			page = new DefaultPartitionPage(&fSettings, frame, "default");
272b76ca311SAxel Dörfler 			break;
273b76ca311SAxel Dörfler 		case kStateInstallSummary:
274197f59b0SAxel Dörfler 			page = _CreateInstallSummaryPage();
275b76ca311SAxel Dörfler 			break;
276b76ca311SAxel Dörfler 		case kStateInstalled:
277197f59b0SAxel Dörfler 			page = _CreateInstalledPage();
278b76ca311SAxel Dörfler 			wizard->SetNextButtonLabel(B_TRANSLATE_COMMENT("Done", "Button"));
279b76ca311SAxel Dörfler 			break;
280b76ca311SAxel Dörfler 		case kStateUninstall:
281b76ca311SAxel Dörfler 			page = _CreateUninstallPage(frame);
282b76ca311SAxel Dörfler 			wizard->SetPreviousButtonHidden(false);
283b76ca311SAxel Dörfler 			break;
284b76ca311SAxel Dörfler 		case kStateUninstalled:
285b76ca311SAxel Dörfler 			// TODO prevent overwriting MBR after clicking "Previous"
286197f59b0SAxel Dörfler 			page = _CreateUninstalledPage();
287b76ca311SAxel Dörfler 			wizard->SetNextButtonLabel(B_TRANSLATE_COMMENT("Done", "Button"));
288b76ca311SAxel Dörfler 			break;
289b76ca311SAxel Dörfler 	}
290b76ca311SAxel Dörfler 
291b76ca311SAxel Dörfler 	return page;
292b76ca311SAxel Dörfler }
293b76ca311SAxel Dörfler 
294b76ca311SAxel Dörfler 
295b76ca311SAxel Dörfler WizardPageView*
296197f59b0SAxel Dörfler BootManagerController::_CreateErrorEntryPage()
297b76ca311SAxel Dörfler {
298b76ca311SAxel Dörfler 	BString description;
299b76ca311SAxel Dörfler 
30049c044abSAxel Dörfler 	if (fCollectPartitionsStatus == B_PARTITION_TOO_SMALL) {
301b76ca311SAxel Dörfler 		description << B_TRANSLATE_COMMENT("Partition table not compatible",
302b76ca311SAxel Dörfler 				"Title") << "\n\n"
303b76ca311SAxel Dörfler 			<< B_TRANSLATE("The partition table of the first hard disk is not "
304b76ca311SAxel Dörfler 				"compatible with Boot Manager.\n"
305b76ca311SAxel Dörfler 				"Boot Manager needs 2 KB available space before the first "
306b76ca311SAxel Dörfler 				"partition.");
307b76ca311SAxel Dörfler 	} else {
308b76ca311SAxel Dörfler 		description << B_TRANSLATE_COMMENT("Error reading partition table",
309b76ca311SAxel Dörfler 				"Title") << "\n\n"
310b76ca311SAxel Dörfler 			<< B_TRANSLATE("Boot Manager is unable to read the partition "
311b76ca311SAxel Dörfler 				"table!");
312b76ca311SAxel Dörfler 	}
313b76ca311SAxel Dörfler 
314197f59b0SAxel Dörfler 	return new DescriptionPage("errorEntry", description.String(), true);
315b76ca311SAxel Dörfler }
316b76ca311SAxel Dörfler 
317b76ca311SAxel Dörfler 
318b76ca311SAxel Dörfler WizardPageView*
319b76ca311SAxel Dörfler BootManagerController::_CreateSaveMBRPage(BRect frame)
320b76ca311SAxel Dörfler {
321b76ca311SAxel Dörfler 	BString description;
322b76ca311SAxel Dörfler 	BString disk;
323b76ca311SAxel Dörfler 	fSettings.FindString("disk", &disk);
324b76ca311SAxel Dörfler 
325b76ca311SAxel Dörfler 	description << B_TRANSLATE_COMMENT("Backup Master Boot Record", "Title")
326197f59b0SAxel Dörfler 		<< "\n" << B_TRANSLATE("The Master Boot Record (MBR) of the boot "
327b76ca311SAxel Dörfler 			"device:\n"
328b76ca311SAxel Dörfler 			"\t%s\n"
329b76ca311SAxel Dörfler 			"will now be saved to disk. Please select a file to "
330b76ca311SAxel Dörfler 			"save the MBR into.\n\n"
331b76ca311SAxel Dörfler 			"If something goes wrong with the installation or if "
332b76ca311SAxel Dörfler 			"you later wish to remove the boot menu, simply run the "
333b76ca311SAxel Dörfler 			"bootman program and choose the 'Uninstall' option.");
334b76ca311SAxel Dörfler 	description.ReplaceFirst("%s", disk);
335b76ca311SAxel Dörfler 
336b76ca311SAxel Dörfler 	return new FileSelectionPage(&fSettings, frame, "saveMBR",
337b76ca311SAxel Dörfler 		description.String(),
338b76ca311SAxel Dörfler 		B_SAVE_PANEL);
339b76ca311SAxel Dörfler }
340b76ca311SAxel Dörfler 
341b76ca311SAxel Dörfler 
342b76ca311SAxel Dörfler WizardPageView*
343197f59b0SAxel Dörfler BootManagerController::_CreateMBRSavedPage()
344b76ca311SAxel Dörfler {
345b76ca311SAxel Dörfler 	BString description;
346b76ca311SAxel Dörfler 	BString file;
347b76ca311SAxel Dörfler 	fSettings.FindString("file", &file);
348b76ca311SAxel Dörfler 
349b76ca311SAxel Dörfler 	if (fSaveMBRStatus == B_OK) {
350b76ca311SAxel Dörfler 		description << B_TRANSLATE_COMMENT("Old Master Boot Record saved",
351197f59b0SAxel Dörfler 				"Title") << "\n"
352b76ca311SAxel Dörfler 			<< B_TRANSLATE("The old Master Boot Record was successfully "
353b76ca311SAxel Dörfler 				"saved to %s.") << "\n";
354b76ca311SAxel Dörfler 	} else {
355b76ca311SAxel Dörfler 		description << B_TRANSLATE_COMMENT("Old Master Boot Record Saved "
356197f59b0SAxel Dörfler 				"failure", "Title") << "\n"
357b76ca311SAxel Dörfler 			<< B_TRANSLATE("The old Master Boot Record could not be saved "
358b76ca311SAxel Dörfler 				"to %s") << "\n";
359b76ca311SAxel Dörfler 	}
360b76ca311SAxel Dörfler 	description.ReplaceFirst("%s", file);
361b76ca311SAxel Dörfler 
362197f59b0SAxel Dörfler 	return new DescriptionPage("summary", description.String(), true);
363b76ca311SAxel Dörfler }
364b76ca311SAxel Dörfler 
365b76ca311SAxel Dörfler 
366b76ca311SAxel Dörfler WizardPageView*
367197f59b0SAxel Dörfler BootManagerController::_CreateInstallSummaryPage()
368b76ca311SAxel Dörfler {
369b76ca311SAxel Dörfler 	BString description;
370b76ca311SAxel Dörfler 	BString disk;
371b76ca311SAxel Dörfler 	fSettings.FindString("disk", &disk);
372b76ca311SAxel Dörfler 
373197f59b0SAxel Dörfler 	description << B_TRANSLATE_COMMENT("Summary", "Title") << "\n"
374b76ca311SAxel Dörfler 		<< B_TRANSLATE("About to write the following boot menu to the boot "
375b76ca311SAxel Dörfler 			"disk (%s). Please verify the information below before continuing.")
376b76ca311SAxel Dörfler 		<< "\n\n";
377b76ca311SAxel Dörfler 	description.ReplaceFirst("%s", disk);
378b76ca311SAxel Dörfler 
379b76ca311SAxel Dörfler 	BMessage message;
380b76ca311SAxel Dörfler 	for (int32 i = 0; fSettings.FindMessage("partition", i, &message) == B_OK;
381b76ca311SAxel Dörfler 			i++) {
382b76ca311SAxel Dörfler 		bool show;
383b76ca311SAxel Dörfler 		if (message.FindBool("show", &show) != B_OK || !show)
384b76ca311SAxel Dörfler 			continue;
385b76ca311SAxel Dörfler 
386b76ca311SAxel Dörfler 		BString name;
387b76ca311SAxel Dörfler 		BString path;
388b76ca311SAxel Dörfler 		message.FindString("name", &name);
389b76ca311SAxel Dörfler 		message.FindString("path", &path);
390b76ca311SAxel Dörfler 
391b76ca311SAxel Dörfler 		BString displayName;
3925675f44eSAxel Dörfler 		if (fBootMenu->GetDisplayText(name.String(), displayName) == B_OK)
393b76ca311SAxel Dörfler 			description << displayName << "\t(" << path << ")\n";
394b76ca311SAxel Dörfler 		else
395b76ca311SAxel Dörfler 			description << name << "\t(" << path << ")\n";
396b76ca311SAxel Dörfler 	}
397b76ca311SAxel Dörfler 
398197f59b0SAxel Dörfler 	return new DescriptionPage("summary", description.String(), true);
399b76ca311SAxel Dörfler }
400b76ca311SAxel Dörfler 
401b76ca311SAxel Dörfler 
402b76ca311SAxel Dörfler WizardPageView*
403197f59b0SAxel Dörfler BootManagerController::_CreateInstalledPage()
404b76ca311SAxel Dörfler {
405b76ca311SAxel Dörfler 	BString description;
406b76ca311SAxel Dörfler 
407b76ca311SAxel Dörfler 	if (fWriteBootMenuStatus == B_OK) {
408b76ca311SAxel Dörfler 		description << B_TRANSLATE_COMMENT("Installation of boot menu "
409197f59b0SAxel Dörfler 				"completed", "Title") << "\n"
410b76ca311SAxel Dörfler 			<< B_TRANSLATE("The boot manager has been successfully installed "
411b76ca311SAxel Dörfler 				"on your system.");
412b76ca311SAxel Dörfler 	} else {
413b76ca311SAxel Dörfler 		description << B_TRANSLATE_COMMENT("Installation of boot menu failed",
414197f59b0SAxel Dörfler 				"Title") << "\n"
415b76ca311SAxel Dörfler 			<< B_TRANSLATE("An error occurred writing the boot menu. "
416b76ca311SAxel Dörfler 				"The Master Boot Record might be destroyed, "
417b76ca311SAxel Dörfler 				"you should restore the MBR now!");
418b76ca311SAxel Dörfler 	}
419b76ca311SAxel Dörfler 
420197f59b0SAxel Dörfler 	return new DescriptionPage("done", description, true);
421b76ca311SAxel Dörfler }
422b76ca311SAxel Dörfler 
423b76ca311SAxel Dörfler 
424b76ca311SAxel Dörfler WizardPageView*
425b76ca311SAxel Dörfler BootManagerController::_CreateUninstallPage(BRect frame)
426b76ca311SAxel Dörfler {
427b76ca311SAxel Dörfler 	BString description;
428b76ca311SAxel Dörfler 	description << B_TRANSLATE_COMMENT("Uninstall boot manager", "Title")
429b76ca311SAxel Dörfler 		<< "\n\n"
430b76ca311SAxel Dörfler 		<< B_TRANSLATE("Please locate the Master Boot Record (MBR) save file "
431b76ca311SAxel Dörfler 			"to restore from. This is the file that was created when the "
432b76ca311SAxel Dörfler 			"boot manager was first installed.");
433b76ca311SAxel Dörfler 
434b76ca311SAxel Dörfler 	return new FileSelectionPage(&fSettings, frame, "restoreMBR",
435b76ca311SAxel Dörfler 		description.String(), B_OPEN_PANEL);
436b76ca311SAxel Dörfler }
437b76ca311SAxel Dörfler 
438b76ca311SAxel Dörfler 
439b76ca311SAxel Dörfler WizardPageView*
440197f59b0SAxel Dörfler BootManagerController::_CreateUninstalledPage()
441b76ca311SAxel Dörfler {
442b76ca311SAxel Dörfler 	BString description;
443b76ca311SAxel Dörfler 	BString disk;
444b76ca311SAxel Dörfler 	BString file;
445b76ca311SAxel Dörfler 	fSettings.FindString("disk", &disk);
446b76ca311SAxel Dörfler 	fSettings.FindString("file", &file);
447b76ca311SAxel Dörfler 
448b76ca311SAxel Dörfler 	if (fRestoreMBRStatus == B_OK) {
449b76ca311SAxel Dörfler 		description << B_TRANSLATE_COMMENT("Uninstallation of boot menu "
450197f59b0SAxel Dörfler 				"completed", "Title") << "\n"
451b76ca311SAxel Dörfler 			<< B_TRANSLATE("The Master Boot Record of the boot device "
452b76ca311SAxel Dörfler 				"(%DISK) has been successfully restored from %FILE.");
453b76ca311SAxel Dörfler 		description.ReplaceFirst("%DISK", disk);
454b76ca311SAxel Dörfler 		description.ReplaceFirst("%FILE", file);
455b76ca311SAxel Dörfler 	} else {
456b76ca311SAxel Dörfler 		description << B_TRANSLATE_COMMENT("Uninstallation of boot menu "
457197f59b0SAxel Dörfler 				"failed", "Title") << "\n"
458b76ca311SAxel Dörfler 			<< B_TRANSLATE("The Master Boot Record could not be restored!");
459b76ca311SAxel Dörfler 	}
460b76ca311SAxel Dörfler 
461197f59b0SAxel Dörfler 	return new DescriptionPage("summary", description.String(), true);
462b76ca311SAxel Dörfler }
463