* Localized.

* Text of boot menu items is encoded using code page 437 (for example
  umlaute can now be used). 
* On the last wizard page before writing the boot menu a preview is 
  shown of the boot menu items. 
* Enforce menu item size limit of 70 bytes. 


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@35771 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Michael Pfeiffer
2010-03-07 11:28:24 +00:00
parent 5edde94cab
commit 09ccc66ea0
16 changed files with 302 additions and 120 deletions
+3
View File
@@ -40,6 +40,9 @@ public:
virtual status_t WriteBootMenu(BMessage* settings) = 0; virtual status_t WriteBootMenu(BMessage* settings) = 0;
virtual status_t SaveMasterBootRecord(BMessage* settings, BFile* file) = 0; virtual status_t SaveMasterBootRecord(BMessage* settings, BFile* file) = 0;
virtual status_t RestoreMasterBootRecord(BMessage* settings, BFile* file) = 0; virtual status_t RestoreMasterBootRecord(BMessage* settings, BFile* file) = 0;
// Converts the specified text into a text as it will be shown
// in the boot menu.
virtual status_t GetDisplayText(const char* text, BString& displayText) = 0;
}; };
#endif // BOOT_DRIVE_H #endif // BOOT_DRIVE_H
+12 -2
View File
@@ -11,9 +11,14 @@
#include <Alert.h> #include <Alert.h>
#include <Application.h> #include <Application.h>
#include <Catalog.h>
#include <Locale.h>
#include <TextView.h> #include <TextView.h>
#define TR_CONTEXT "BootManager"
static const char* kSignature = "application/x-vnd.Haiku-bootman"; static const char* kSignature = "application/x-vnd.Haiku-bootman";
@@ -24,12 +29,16 @@ public:
virtual void ReadyToRun(); virtual void ReadyToRun();
virtual void AboutRequested(); virtual void AboutRequested();
private:
BCatalog fCatalog;
}; };
BootManager::BootManager() BootManager::BootManager()
: BApplication(kSignature) : BApplication(kSignature)
{ {
be_locale->GetAppCatalog(&fCatalog);
} }
@@ -44,12 +53,13 @@ BootManager::ReadyToRun()
void void
BootManager::AboutRequested() BootManager::AboutRequested()
{ {
BAlert *alert = new BAlert("about", "Haiku Boot Manager\n\n" BAlert *alert = new BAlert("about",
TR("Haiku Boot Manager\n\n"
"written by\n" "written by\n"
"\tDavid Dengg\n" "\tDavid Dengg\n"
"\tMichael Pfeiffer\n" "\tMichael Pfeiffer\n"
"\n" "\n"
"Copyright 2008-10, Haiku Inc.\n", "OK"); "Copyright 2008-10, Haiku Inc.\n"), TR("OK"));
BTextView *view = alert->TextView(); BTextView *view = alert->TextView();
BFont font; BFont font;
+72 -52
View File
@@ -28,12 +28,16 @@
#include <Alert.h> #include <Alert.h>
#include <Application.h> #include <Application.h>
#include <Catalog.h>
#include <File.h> #include <File.h>
#include <FindDirectory.h> #include <FindDirectory.h>
#include <Path.h> #include <Path.h>
#include <String.h> #include <String.h>
#define TR_CONTEXT "BootManagerController"
BootManagerController::BootManagerController() BootManagerController::BootManagerController()
{ {
#if USE_TEST_BOOT_DRIVE #if USE_TEST_BOOT_DRIVE
@@ -150,8 +154,9 @@ BootManagerController::_HasSelectedPartitions()
return true; return true;
} }
BAlert* alert = new BAlert("info", "At least one partition must be " BAlert* alert = new BAlert("info",
"selected!", "OK"); TR("At least one partition must be selected!"),
TR("OK"));
alert->Go(); alert->Go();
return false; return false;
@@ -161,9 +166,10 @@ BootManagerController::_HasSelectedPartitions()
bool bool
BootManagerController::_WriteBootMenu() BootManagerController::_WriteBootMenu()
{ {
BAlert* alert = new BAlert("confirm", "About to write the boot menu " BAlert* alert = new BAlert("confirm", TR("About to write the boot menu "
"to disk. Are you sure you want to continue?", "Write boot menu", "to disk. Are you sure you want to continue?"),
"Back", NULL, B_WIDTH_AS_USUAL, B_WARNING_ALERT); TR("Write boot menu"),
TR("Back"), NULL, B_WIDTH_AS_USUAL, B_WARNING_ALERT);
if (alert->Go() == 1) if (alert->Go() == 1)
return false; return false;
@@ -193,11 +199,11 @@ BootManagerController::_RestoreMBR()
fSettings.FindString("file", &path); fSettings.FindString("file", &path);
BString message; BString message;
message << "About to restore the Master Boot Record (MBR) of " message << TR("About to restore the Master Boot Record (MBR) of")
<< disk << " from " << path << ". " << " " << disk << " " << TR("from") << " " << path << ". " <<
"Do you wish to continue?"; TR("Do you wish to continue?");
BAlert* alert = new BAlert("confirm", message.String(), BAlert* alert = new BAlert("confirm", message.String(),
"Restore MBR", "Back", TR("Restore MBR"), TR("Back"),
NULL, B_WIDTH_AS_USUAL, B_WARNING_ALERT); NULL, B_WIDTH_AS_USUAL, B_WARNING_ALERT);
if (alert->Go() == 1) if (alert->Go() == 1)
return false; return false;
@@ -222,7 +228,7 @@ BootManagerController::CreatePage(int32 state, WizardView* wizard)
case kStateErrorEntry: case kStateErrorEntry:
page = _CreateErrorEntryPage(frame); page = _CreateErrorEntryPage(frame);
wizard->SetPreviousButtonHidden(true); wizard->SetPreviousButtonHidden(true);
wizard->SetNextButtonLabel("Done"); wizard->SetNextButtonLabel(TR("Done"));
break; break;
case kStateSaveMBR: case kStateSaveMBR:
page = _CreateSaveMBRPage(frame); page = _CreateSaveMBRPage(frame);
@@ -240,21 +246,21 @@ BootManagerController::CreatePage(int32 state, WizardView* wizard)
break; break;
case kStateInstallSummary: case kStateInstallSummary:
page = _CreateInstallSummaryPage(frame); page = _CreateInstallSummaryPage(frame);
wizard->SetNextButtonLabel("Next"); wizard->SetNextButtonLabel(TR("Next"));
break; break;
case kStateInstalled: case kStateInstalled:
page = _CreateInstalledPage(frame); page = _CreateInstalledPage(frame);
wizard->SetNextButtonLabel("Done"); wizard->SetNextButtonLabel(TR("Done"));
break; break;
case kStateUninstall: case kStateUninstall:
page = _CreateUninstallPage(frame); page = _CreateUninstallPage(frame);
wizard->SetPreviousButtonHidden(false); wizard->SetPreviousButtonHidden(false);
wizard->SetNextButtonLabel("Next"); wizard->SetNextButtonLabel(TR("Next"));
break; break;
case kStateUninstalled: case kStateUninstalled:
// TODO prevent overwriting MBR after clicking "Previous" // TODO prevent overwriting MBR after clicking "Previous"
page = _CreateUninstalledPage(frame); page = _CreateUninstalledPage(frame);
wizard->SetNextButtonLabel("Done"); wizard->SetNextButtonLabel(TR("Done"));
break; break;
} }
@@ -269,14 +275,15 @@ BootManagerController::_CreateErrorEntryPage(BRect frame)
if (fReadPartitionsStatus == kErrorBootSectorTooSmall) if (fReadPartitionsStatus == kErrorBootSectorTooSmall)
description << description <<
"Partition table not compatible\n\n" TR("Partition table not compatible") << "\n\n" <<
"The partition table of the first hard disk is not compatible " TR("The partition table of the first hard disk is not compatible "
"with Boot Manager.\n" "with Boot Manager.\n"
"Boot Manager needs 2 KB available space before the first partition."; "Boot Manager needs 2 KB available space before the first "
"partition.");
else else
description << description <<
"Error reading partition table\n\n" TR("Error reading partition table") << "\n\n" <<
"Boot Manager is unable to read the partition table!"; TR("Boot Manager is unable to read the partition table!");
return new DescriptionPage(frame, "errorEntry", description.String(), true); return new DescriptionPage(frame, "errorEntry", description.String(), true);
} }
@@ -290,16 +297,18 @@ BootManagerController::_CreateSaveMBRPage(BRect frame)
fSettings.FindString("disk", &disk); fSettings.FindString("disk", &disk);
description << description <<
"Backup Master Boot Record\n\n" TR("Backup Master Boot Record") << "\n\n" <<
"The Master Boot Record (MBR) of the boot device:\n" TR("The Master Boot Record (MBR) of the boot device:\n"
"\t" << disk << "\n" "\t%s\n"
"will now be saved to disk. Please select a file to " "will now be saved to disk. Please select a file to "
"save the MBR into.\n\n" "save the MBR into.\n\n"
"If something goes wrong with the installation or if " "If something goes wrong with the installation or if "
"you later wish to remove the boot menu, simply run the " "you later wish to remove the boot menu, simply run the "
"bootman program and choose the 'Uninstall' option."; "bootman program and choose the 'Uninstall' option.");
description.ReplaceFirst("%s", disk);
return new FileSelectionPage(&fSettings, frame, "saveMBR", description.String(), return new FileSelectionPage(&fSettings, frame, "saveMBR",
description.String(),
B_SAVE_PANEL); B_SAVE_PANEL);
} }
@@ -313,15 +322,16 @@ BootManagerController::_CreateMBRSavedPage(BRect frame)
if (fSaveMBRStatus == B_OK) { if (fSaveMBRStatus == B_OK) {
description << description <<
"Old Master Boot Record saved\n\n" TR("Old Master Boot Record saved") << "\n\n" <<
"The old Master Boot Record was successfully save to " TR("The old Master Boot Record was successfully save to %s.") <<
<< file << ".\n"; "\n";
} else { } else {
description << description <<
"Old Master Boot Record Saved failure\n\n" TR("Old Master Boot Record Saved failure") << "\n\n" <<
"The old Master Boot Record could not be saved to " TR("The old Master Boot Record could not be saved to %s") <<
<< file << ".\n"; "\n";
} }
description.ReplaceFirst("%s", file);
return new DescriptionPage(frame, "summary", description.String(), true); return new DescriptionPage(frame, "summary", description.String(), true);
} }
@@ -335,10 +345,11 @@ BootManagerController::_CreateInstallSummaryPage(BRect frame)
fSettings.FindString("disk", &disk); fSettings.FindString("disk", &disk);
description << description <<
"Summary\n\n" TR("Summary") << "\n\n" <<
"About to write the following boot menu to the boot disk " TR("About to write the following boot menu to the boot disk "
"(" << disk << "). Please verify the information below " "(%s). Please verify the information below before continuing.") <<
"before continuing.\n\n"; "\n\n";
description.ReplaceFirst("%s", disk);
BMessage message; BMessage message;
for (int32 i = 0; fSettings.FindMessage("partition", i, &message) == B_OK; i ++) { for (int32 i = 0; fSettings.FindMessage("partition", i, &message) == B_OK; i ++) {
@@ -351,7 +362,12 @@ BootManagerController::_CreateInstallSummaryPage(BRect frame)
BString path; BString path;
message.FindString("name", &name); message.FindString("name", &name);
message.FindString("path", &path); message.FindString("path", &path);
description << name << "\t(" << path << ")\n";
BString displayName;
if (fBootDrive->GetDisplayText(name.String(), displayName))
description << displayName << "\t(" << path << ")\n";
else
description << name << "\t(" << path << ")\n";
} }
return new DescriptionPage(frame, "summary", description.String(), true); return new DescriptionPage(frame, "summary", description.String(), true);
@@ -361,16 +377,19 @@ BootManagerController::_CreateInstallSummaryPage(BRect frame)
WizardPageView* WizardPageView*
BootManagerController::_CreateInstalledPage(BRect frame) BootManagerController::_CreateInstalledPage(BRect frame)
{ {
const char* description; BString description;
if (fWriteBootMenuStatus == B_OK) { if (fWriteBootMenuStatus == B_OK) {
description = "Installation of boot menu completed\n\n" description <<
"The boot manager has been successfully installed " TR("Installation of boot menu completed") << "\n\n" <<
"on your system."; TR("The boot manager has been successfully installed "
"on your system.");
} else { } else {
description = "Installation of boot menu failed\n\n" description <<
"An error occured writing the boot menu. The Master Boot Record " TR("Installation of boot menu failed") << "\n\n" <<
"might be destroyed, you should restore the MBR now!"; TR("An error occurred writing the boot menu. "
"The Master Boot Record might be destroyed, "
"you should restore the MBR now!");
} }
return new DescriptionPage(frame, "done", description, true); return new DescriptionPage(frame, "done", description, true);
@@ -383,10 +402,10 @@ BootManagerController::_CreateUninstallPage(BRect frame)
BString description; BString description;
description << description <<
"Uninstall boot manager\n\n" TR("Uninstall boot manager") << "\n\n" <<
"Please locate the Master Boot Record (MBR) save file to " TR("Please locate the Master Boot Record (MBR) save file to "
"restore from. This is the file that was created when the " "restore from. This is the file that was created when the "
"boot manager was first installed."; "boot manager was first installed.");
return new FileSelectionPage(&fSettings, frame, "restoreMBR", description.String(), return new FileSelectionPage(&fSettings, frame, "restoreMBR", description.String(),
B_OPEN_PANEL); B_OPEN_PANEL);
@@ -404,14 +423,15 @@ BootManagerController::_CreateUninstalledPage(BRect frame)
if (fRestoreMBRStatus == B_OK) { if (fRestoreMBRStatus == B_OK) {
description << description <<
"Uninstallation of boot menu completed\n\n" TR("Uninstallation of boot menu completed") << "\n\n" <<
"The Master Boot Record of the boot device " TR("The Master Boot Record of the boot device "
"(" << disk << ") has been successfully restored from " "(%s) has been successfully restored from %s.");
<< file << "."; description.ReplaceFirst("%s", disk);
description.ReplaceLast("%s", file);
} else { } else {
description << description <<
"Uninstallation of boot menu failed\n\n" TR("Uninstallation of boot menu failed") << "\n\n" <<
"The Master Boot Record could not be restored!"; TR("The Master Boot Record could not be restored!");
} }
return new DescriptionPage(frame, "summary", description.String(), true); return new DescriptionPage(frame, "summary", description.String(), true);
+7 -1
View File
@@ -16,12 +16,18 @@
#include "DefaultPartitionPage.h" #include "DefaultPartitionPage.h"
#include <Application.h> #include <Application.h>
#include <Catalog.h>
#include <Screen.h> #include <Screen.h>
#include <math.h> #include <math.h>
#define TR_CONTEXT "BootManagerWindow"
BootManagerWindow::BootManagerWindow() BootManagerWindow::BootManagerWindow()
: BWindow(BRect(100, 100, 500, 400), "Boot Manager", B_TITLED_WINDOW, : BWindow(BRect(100, 100, 500, 400), TR("Boot Manager"), B_TITLED_WINDOW,
B_ASYNCHRONOUS_CONTROLS | B_NOT_ZOOMABLE) B_ASYNCHRONOUS_CONTROLS | B_NOT_ZOOMABLE)
{ {
float minWidth, maxWidth, minHeight, maxHeight; float minWidth, maxWidth, minHeight, maxHeight;
+22 -12
View File
@@ -10,6 +10,7 @@
#include "DefaultPartitionPage.h" #include "DefaultPartitionPage.h"
#include <Catalog.h>
#include <Message.h> #include <Message.h>
#include <MenuItem.h> #include <MenuItem.h>
@@ -22,6 +23,9 @@
#include <String.h> #include <String.h>
#define TR_CONTEXT "DefaultPartitionPage"
const uint32 kMsgPartition = 'part'; const uint32 kMsgPartition = 'part';
const uint32 kMsgTimeout = 'time'; const uint32 kMsgTimeout = 'time';
@@ -89,22 +93,24 @@ DefaultPartitionPage::_BuildUI()
{ {
BRect rect(Bounds()); BRect rect(Bounds());
fDescription = CreateDescription(rect, "description", BString text;
"Default Partition\n\n" text <<
"Please specify a default partition and a timeout.\n" TR("Default Partition") << "\n\n" <<
TR("Please specify a default partition and a timeout.\n"
"The boot menu will load the default partition after " "The boot menu will load the default partition after "
"the timeout unless you select another partition. You " "the timeout unless you select another partition. You "
"can also have the boot menu wait indefinitely for you " "can also have the boot menu wait indefinitely for you "
"to select a partition." "to select a partition.");
);
fDescription = CreateDescription(rect, "description", text);
MakeHeading(fDescription); MakeHeading(fDescription);
AddChild(fDescription); AddChild(fDescription);
LayoutDescriptionVertically(fDescription); LayoutDescriptionVertically(fDescription);
rect.top = fDescription->Frame().bottom + kTextDistance; rect.top = fDescription->Frame().bottom + kTextDistance;
BPopUpMenu* popUpMenu = _CreatePopUpMenu(); BPopUpMenu* popUpMenu = _CreatePopUpMenu();
fDefaultPartition = new BMenuField(rect, "partitions", "Default Partition:", fDefaultPartition = new BMenuField(rect, "partitions",
popUpMenu); TR("Default Partition:"), popUpMenu);
float divider = be_plain_font->StringWidth(fDefaultPartition->Label()) + 3; float divider = be_plain_font->StringWidth(fDefaultPartition->Label()) + 3;
fDefaultPartition->SetDivider(divider); fDefaultPartition->SetDivider(divider);
AddChild(fDefaultPartition); AddChild(fDefaultPartition);
@@ -113,10 +119,14 @@ DefaultPartitionPage::_BuildUI()
rect.top = fDefaultPartition->Frame().bottom + kTextDistance; rect.top = fDefaultPartition->Frame().bottom + kTextDistance;
int32 timeout; int32 timeout;
fSettings->FindInt32("timeout", &timeout); fSettings->FindInt32("timeout", &timeout);
fWait0 = _CreateWaitRadioButton(rect, "wait0", "Wait Indefinitely", -1, timeout); fWait0 = _CreateWaitRadioButton(rect, "wait0", TR("Wait Indefinitely"),
fWait5 = _CreateWaitRadioButton(rect, "wait5", "Wait 5 Seconds", 5, timeout); -1, timeout);
fWait10 = _CreateWaitRadioButton(rect, "wait10", "Wait 10 Seconds", 10, timeout); fWait5 = _CreateWaitRadioButton(rect, "wait5", TR("Wait 5 Seconds"),
fWait15 = _CreateWaitRadioButton(rect, "wait15", "Wait 15 Seconds", 15, timeout); 5, timeout);
fWait10 = _CreateWaitRadioButton(rect, "wait10", TR("Wait 10 Seconds"),
10, timeout);
fWait15 = _CreateWaitRadioButton(rect, "wait15", TR("Wait 15 Seconds"),
15, timeout);
_Layout(); _Layout();
} }
@@ -131,7 +141,7 @@ DefaultPartitionPage::_CreatePopUpMenu()
BMenuItem* selectedItem = NULL; BMenuItem* selectedItem = NULL;
int32 selectedItemIndex = 0; int32 selectedItemIndex = 0;
BPopUpMenu* menu = new BPopUpMenu("Partitions"); BPopUpMenu* menu = new BPopUpMenu(TR("Partitions"));
BMessage message; BMessage message;
for (int32 i = 0; fSettings->FindMessage("partition", i, &message) == B_OK; i ++) { for (int32 i = 0; fSettings->FindMessage("partition", i, &message) == B_OK; i ++) {
+18 -9
View File
@@ -10,12 +10,16 @@
#include "EntryPage.h" #include "EntryPage.h"
#include <Catalog.h>
#include <RadioButton.h> #include <RadioButton.h>
#include <TextView.h> #include <TextView.h>
#include <string.h> #include <string.h>
#define TR_CONTEXT "EntryPage"
EntryPage::EntryPage(BMessage* settings, BRect frame, const char* name) EntryPage::EntryPage(BMessage* settings, BRect frame, const char* name)
: WizardPageView(settings, frame, name, B_FOLLOW_ALL, : WizardPageView(settings, frame, name, B_FOLLOW_ALL,
B_WILL_DRAW | B_FRAME_EVENTS | B_FULL_UPDATE_ON_RESIZE) B_WILL_DRAW | B_FRAME_EVENTS | B_FULL_UPDATE_ON_RESIZE)
@@ -59,12 +63,14 @@ EntryPage::_BuildUI()
BRect textRect(rect); BRect textRect(rect);
textRect.left = fInstall->Frame().right + kTextDistance; textRect.left = fInstall->Frame().right + kTextDistance;
fInstallText = CreateDescription(textRect, "installText", BString text;
"Install boot menu\n\n" text <<
"Choose this option to install a boot menu, " TR("Install boot menu") << "\n\n" <<
TR("Choose this option to install a boot menu, "
"allowing you to select which operating " "allowing you to select which operating "
"system to boot when you turn on your " "system to boot when you turn on your "
"computer.\n"); "computer.") << "\n";
fInstallText = CreateDescription(textRect, "installText", text);
MakeHeading(fInstallText); MakeHeading(fInstallText);
AddChild(fInstallText); AddChild(fInstallText);
@@ -74,11 +80,14 @@ EntryPage::_BuildUI()
AddChild(fUninstall); AddChild(fUninstall);
fUninstall->ResizeToPreferred(); fUninstall->ResizeToPreferred();
fUninstallText = CreateDescription(textRect, "uninstallText", text.Truncate(0);
"Uninstall boot menu\n\n" text <<
"Choose this option to remove the boot menu " TR("Install boot menu") << "\n\n" <<
"previously installed by this program.\n" TR("Choose this option to install a boot menu, "
); "allowing you to select which operating "
"system to boot when you turn on your "
"computer.") << "\n";
fUninstallText = CreateDescription(textRect, "uninstallText", text);
MakeHeading(fUninstallText); MakeHeading(fUninstallText);
AddChild(fUninstallText); AddChild(fUninstallText);
+8 -2
View File
@@ -11,6 +11,7 @@
#include <Button.h> #include <Button.h>
#include <Catalog.h>
#include <Path.h> #include <Path.h>
#include <RadioButton.h> #include <RadioButton.h>
#include <TextControl.h> #include <TextControl.h>
@@ -20,6 +21,9 @@
#include <String.h> #include <String.h>
#define TR_CONTEXT "FileSelectionPage"
const uint32 kMsgOpenFilePanel = 'open'; const uint32 kMsgOpenFilePanel = 'open';
@@ -98,11 +102,13 @@ FileSelectionPage::_BuildUI(const char* description)
fSettings->FindString("file", &file); fSettings->FindString("file", &file);
// TODO align text and button // TODO align text and button
fFile = new BTextControl(rect, "file", "File:", file.String(), new BMessage()); fFile = new BTextControl(rect, "file", TR("File:"), file.String(),
new BMessage());
fFile->SetDivider(be_plain_font->StringWidth(fFile->Label()) + 5); fFile->SetDivider(be_plain_font->StringWidth(fFile->Label()) + 5);
AddChild(fFile); AddChild(fFile);
fSelect = new BButton(rect, "select", "Select", new BMessage(kMsgOpenFilePanel), fSelect = new BButton(rect, "select", TR("Select"),
new BMessage(kMsgOpenFilePanel),
B_FOLLOW_RIGHT); B_FOLLOW_RIGHT);
fSelect->ResizeToPreferred(); fSelect->ResizeToPreferred();
float left = rect.right - fSelect->Frame().Width(); float left = rect.right - fSelect->Frame().Width();
+26 -2
View File
@@ -18,6 +18,30 @@ Application bootman :
WizardController.cpp WizardController.cpp
WizardPageView.cpp WizardPageView.cpp
WizardView.cpp WizardView.cpp
: be tracker $(TARGET_LIBSUPC++) :
: bootman.rdef be
textencoding
tracker
liblocale.so
$(TARGET_LIBSUPC++)
:
bootman.rdef
; ;
DoCatalogs bootman :
x-vnd.Haiku-bootman
:
BootManager.cpp
BootManagerController.cpp
BootManagerWindow.cpp
DefaultPartitionPage.cpp
EntryPage.cpp
FileSelectionPage.cpp
LegacyBootDrive.cpp
PartitionsPage.cpp
UninstallPage.cpp
WizardView.cpp
:
en.catalog
:
;
+85 -14
View File
@@ -10,6 +10,7 @@
#include "LegacyBootDrive.h" #include "LegacyBootDrive.h"
#include <Catalog.h>
#include <Drivers.h> #include <Drivers.h>
#include <DiskDevice.h> #include <DiskDevice.h>
#include <DiskDeviceRoster.h> #include <DiskDeviceRoster.h>
@@ -20,6 +21,7 @@
#include <errno.h> #include <errno.h>
#include <fcntl.h> #include <fcntl.h>
#include <memory>
#include <new> #include <new>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
@@ -30,10 +32,12 @@
#include <DataIO.h> #include <DataIO.h>
#include <File.h> #include <File.h>
#include <String.h> #include <String.h>
#include <UTF8.h>
#include "BootLoader.h" #include "BootLoader.h"
#define TR_CONTEXT "LegacyBootDrive"
#define USE_SECOND_DISK 0 #define USE_SECOND_DISK 0
#define GET_FIRST_BIOS_DRIVE 1 #define GET_FIRST_BIOS_DRIVE 1
@@ -62,15 +66,18 @@ Buffer::WriteInt8(int8 value)
bool bool
Buffer::WriteInt16(int16 value) Buffer::WriteInt16(int16 value)
{ {
return WriteInt8(value & 0xff) && WriteInt8(value >> 8); return WriteInt8(value & 0xff)
&& WriteInt8(value >> 8);
} }
bool bool
Buffer::WriteInt32(int32 value) Buffer::WriteInt32(int32 value)
{ {
return WriteInt8(value & 0xff) && WriteInt8(value >> 8) && return WriteInt8(value & 0xff)
WriteInt8(value >> 16) && WriteInt8(value >> 24); && WriteInt8(value >> 8)
&& WriteInt8(value >> 16)
&& WriteInt8(value >> 24);
} }
@@ -85,7 +92,8 @@ bool
Buffer::WriteString(const char* value) Buffer::WriteString(const char* value)
{ {
int len = strlen(value) + 1; int len = strlen(value) + 1;
return WriteInt8(len) && Write(value, len) == len; return WriteInt8(len)
&& Write(value, len) == len;
} }
@@ -180,13 +188,18 @@ PartitionRecorder::_Record(BPartition* partition)
const char* name = partition->ContentName(); const char* name = partition->ContentName();
if (name == NULL) { if (name == NULL) {
fIndex ++; fIndex ++;
buffer << "Unnamed " << fIndex; BString number;
number << fIndex;
buffer << TR_CMT("Unnamed %d",
"Default name of a partition whose name could not be read from "
"disk");
buffer.ReplaceFirst("%d", number);
name = buffer.String(); name = buffer.String();
} }
const char* type = partition->Type(); const char* type = partition->Type();
if (type == NULL) if (type == NULL)
type = "Unknown"; type = TR("Unknown");
BMessage message; BMessage message;
// Data as required by BootLoader.h // Data as required by BootLoader.h
@@ -280,10 +293,6 @@ LegacyBootDrive::ReadPartitions(BMessage *settings)
status_t status_t
LegacyBootDrive::WriteBootMenu(BMessage *settings) LegacyBootDrive::WriteBootMenu(BMessage *settings)
{ {
printf("WriteBootMenu:\n");
// TODO fix crash since AddInt8("drive", ...)
// settings->PrintToStream();
BString path; BString path;
if (settings->FindString("disk", &path) != B_OK) if (settings->FindString("disk", &path) != B_OK)
return B_BAD_VALUE; return B_BAD_VALUE;
@@ -355,7 +364,10 @@ LegacyBootDrive::WriteBootMenu(BMessage *settings)
if (!show) if (!show)
continue; continue;
newBootLoader.WriteString(name.String()); BString biosName;
_ConvertToBIOSText(name.String(), biosName);
newBootLoader.WriteString(biosName.String());
newBootLoader.WriteInt8(drive); newBootLoader.WriteInt8(drive);
newBootLoader.WriteInt64(offset / kBlockSize); newBootLoader.WriteInt64(offset / kBlockSize);
} }
@@ -466,6 +478,62 @@ LegacyBootDrive::RestoreMasterBootRecord(BMessage* settings, BFile* file)
} }
status_t
LegacyBootDrive::GetDisplayText(const char* text, BString& displayText)
{
BString biosText;
if (!_ConvertToBIOSText(text, biosText)) {
displayText = "???";
return B_ERROR;
}
// convert back to UTF-8
int32 biosTextLength = biosText.Length();
int32 bufferLength = strlen(text);
char* buffer = displayText.LockBuffer(bufferLength + 1);
int32 state = 0;
if (convert_to_utf8(B_MS_DOS_CONVERSION,
biosText.String(), &biosTextLength,
buffer, &bufferLength, &state) != B_OK) {
displayText.UnlockBuffer(0);
displayText = "???";
return B_ERROR;
}
buffer[bufferLength] = '\0';
bufferLength ++;
displayText.UnlockBuffer(bufferLength);
return B_OK;
}
bool
LegacyBootDrive::_ConvertToBIOSText(const char* text, BString& biosText)
{
// convert text in UTF-8 to 'code page 437'
int32 textLength = strlen(text);
int32 biosTextLength = textLength;
char* buffer = biosText.LockBuffer(biosTextLength + 1);
if (buffer == NULL) {
biosText.UnlockBuffer(0);
return false;
}
int32 state = 0;
if (convert_from_utf8(B_MS_DOS_CONVERSION, text, &textLength,
buffer, &biosTextLength, &state) != B_OK) {
biosText.UnlockBuffer(0);
return false;
}
buffer[biosTextLength] = '\0';
biosTextLength ++;
biosText.UnlockBuffer(biosTextLength);
return biosTextLength <= kMaxBootMenuItemLength;
}
bool bool
LegacyBootDrive::_GetBiosDrive(const char* device, int8* drive) LegacyBootDrive::_GetBiosDrive(const char* device, int8* drive)
{ {
@@ -487,7 +555,8 @@ status_t
LegacyBootDrive::_ReadBlocks(int fd, uint8* buffer, size_t size) LegacyBootDrive::_ReadBlocks(int fd, uint8* buffer, size_t size)
{ {
if (size % kBlockSize != 0) { if (size % kBlockSize != 0) {
fprintf(stderr, "_ReadBlocks buffer size must be a multiple of %d\n", (int)kBlockSize); fprintf(stderr, "_ReadBlocks buffer size must be a multiple of %d\n",
(int)kBlockSize);
return B_BAD_VALUE; return B_BAD_VALUE;
} }
const size_t blocks = size / kBlockSize; const size_t blocks = size / kBlockSize;
@@ -504,7 +573,8 @@ status_t
LegacyBootDrive::_WriteBlocks(int fd, const uint8* buffer, size_t size) LegacyBootDrive::_WriteBlocks(int fd, const uint8* buffer, size_t size)
{ {
if (size % kBlockSize != 0) { if (size % kBlockSize != 0) {
fprintf(stderr, "_WriteBlocks buffer size must be a multiple of %d\n", (int)kBlockSize); fprintf(stderr, "_WriteBlocks buffer size must be a multiple of %d\n",
(int)kBlockSize);
return B_BAD_VALUE; return B_BAD_VALUE;
} }
const size_t blocks = size / kBlockSize; const size_t blocks = size / kBlockSize;
@@ -522,7 +592,8 @@ LegacyBootDrive::_CopyPartitionTable(MasterBootRecord* destination,
const MasterBootRecord* source) const MasterBootRecord* source)
{ {
memcpy(destination->diskSignature, source->diskSignature, memcpy(destination->diskSignature, source->diskSignature,
sizeof(source->diskSignature) + sizeof(source->reserved) + sizeof(source->partition)); sizeof(source->diskSignature) + sizeof(source->reserved) +
sizeof(source->partition));
} }
+10 -6
View File
@@ -18,6 +18,8 @@ const uint32 kBlockSize = 512;
const uint32 kNumberOfBootLoaderBlocks = 4; const uint32 kNumberOfBootLoaderBlocks = 4;
const uint32 kMBRSignature = 0xAA55; const uint32 kMBRSignature = 0xAA55;
const int32 kMaxBootMenuItemLength = 70;
typedef struct { typedef struct {
uint8 bootLoader[440]; uint8 bootLoader[440];
@@ -31,15 +33,17 @@ class LegacyBootDrive : public BootDrive
{ {
public: public:
LegacyBootDrive(); LegacyBootDrive();
virtual ~LegacyBootDrive(); ~LegacyBootDrive();
virtual bool IsBootMenuInstalled(BMessage* settings); bool IsBootMenuInstalled(BMessage* settings);
virtual status_t ReadPartitions(BMessage* settings); status_t ReadPartitions(BMessage* settings);
virtual status_t WriteBootMenu(BMessage* settings); status_t WriteBootMenu(BMessage* settings);
virtual status_t SaveMasterBootRecord(BMessage* settings, BFile* file); status_t SaveMasterBootRecord(BMessage* settings, BFile* file);
virtual status_t RestoreMasterBootRecord(BMessage* settings, BFile* file); status_t RestoreMasterBootRecord(BMessage* settings, BFile* file);
status_t GetDisplayText(const char* text, BString& displayText);
private: private:
bool _ConvertToBIOSText(const char* text, BString& biosText);
bool _GetBiosDrive(const char* device, int8* drive); bool _GetBiosDrive(const char* device, int8* drive);
status_t _ReadBlocks(int fd, uint8* buffer, size_t size); status_t _ReadBlocks(int fd, uint8* buffer, size_t size);
status_t _WriteBlocks(int fd, const uint8* buffer, size_t size); status_t _WriteBlocks(int fd, const uint8* buffer, size_t size);
+10 -8
View File
@@ -11,6 +11,7 @@
#include "PartitionsPage.h" #include "PartitionsPage.h"
#include <Catalog.h>
#include <CheckBox.h> #include <CheckBox.h>
#include <RadioButton.h> #include <RadioButton.h>
#include <ScrollView.h> #include <ScrollView.h>
@@ -23,6 +24,9 @@
#include <String.h> #include <String.h>
#define TR_CONTEXT "PartitionsPage"
const uint32 kMessageShow = 'show'; const uint32 kMessageShow = 'show';
const uint32 kMessageName = 'name'; const uint32 kMessageName = 'name';
@@ -92,14 +96,15 @@ PartitionsPage::_BuildUI()
{ {
BRect rect(Bounds()); BRect rect(Bounds());
fDescription = CreateDescription(rect, "description", BString text;
"Partitions\n\n" text <<
"The following partitions were detected. Please " TR("Partitions") << "\n\n" <<
TR("The following partitions were detected. Please "
"check the box next to the partitions to be included " "check the box next to the partitions to be included "
"in the boot menu. You can also set the names of the " "in the boot menu. You can also set the names of the "
"partitions as you would like them to appear in the " "partitions as you would like them to appear in the "
"boot menu." "boot menu.");
); fDescription = CreateDescription(rect, "description", text);
MakeHeading(fDescription); MakeHeading(fDescription);
AddChild(fDescription); AddChild(fDescription);
LayoutDescriptionVertically(fDescription); LayoutDescriptionVertically(fDescription);
@@ -302,9 +307,6 @@ PartitionsPage::_ComputeColumnWidths(int32& showWidth, int32& nameWidth,
} }
static const char kPrefix[] = " KMGTPE";
void void
PartitionsPage::_CreateSizeText(int64 _size, BString* text) PartitionsPage::_CreateSizeText(int64 _size, BString* text)
{ {
+5
View File
@@ -107,5 +107,10 @@ TestBootDrive::RestoreMasterBootRecord(BMessage* settings, BFile* file)
} }
status_t
TestBootDrive::GetDisplayText(const char* text, BString& displayText)
{
displayText = text;
}
+7 -6
View File
@@ -14,13 +14,14 @@ class TestBootDrive : public BootDrive
{ {
public: public:
TestBootDrive(); TestBootDrive();
virtual ~TestBootDrive(); ~TestBootDrive();
virtual bool IsBootMenuInstalled(BMessage* settings); bool IsBootMenuInstalled(BMessage* settings);
virtual status_t ReadPartitions(BMessage* settings); status_t ReadPartitions(BMessage* settings);
virtual status_t WriteBootMenu(BMessage* settings); status_t WriteBootMenu(BMessage* settings);
virtual status_t SaveMasterBootRecord(BMessage* settings, BFile* file); status_t SaveMasterBootRecord(BMessage* settings, BFile* file);
virtual status_t RestoreMasterBootRecord(BMessage* settings, BFile* file); status_t RestoreMasterBootRecord(BMessage* settings, BFile* file);
status_t GetDisplayText(const char* text, BString& displayText);
}; };
#endif // TEST_BOOT_DRIVE_H #endif // TEST_BOOT_DRIVE_H
+9 -3
View File
@@ -10,12 +10,16 @@
#include "UninstallPage.h" #include "UninstallPage.h"
#include <Catalog.h>
#include <RadioButton.h> #include <RadioButton.h>
#include <TextView.h> #include <TextView.h>
#include <string.h> #include <string.h>
#define TR_CONTEXT "UninstallPage"
UninstallPage::UninstallPage(BMessage* settings, BRect frame, const char* name) UninstallPage::UninstallPage(BMessage* settings, BRect frame, const char* name)
: WizardPageView(settings, frame, name, B_FOLLOW_ALL, : WizardPageView(settings, frame, name, B_FOLLOW_ALL,
B_WILL_DRAW | B_FRAME_EVENTS | B_FULL_UPDATE_ON_RESIZE) B_WILL_DRAW | B_FRAME_EVENTS | B_FULL_UPDATE_ON_RESIZE)
@@ -44,11 +48,13 @@ UninstallPage::_BuildUI()
{ {
BRect rect(Bounds()); BRect rect(Bounds());
fDescription = CreateDescription(rect, "description", BString text;
"Uninstall Boot Manager\n\n" text <<
"Please locate the Master Boot Record (MBR) save file to " TR("Uninstall Boot Manager") << "\n\n" <<
TR("Please locate the Master Boot Record (MBR) save file to "
"restore from. This is the file that was created when the " "restore from. This is the file that was created when the "
"boot manager was first installed."); "boot manager was first installed.");
fDescription = CreateDescription(rect, "description", text);
MakeHeading(fDescription); MakeHeading(fDescription);
AddChild(fDescription); AddChild(fDescription);
+1 -1
View File
@@ -21,7 +21,7 @@ WizardController::StateStack::MakeEmpty()
next = stack->Next(); next = stack->Next();
delete stack; delete stack;
stack = next; stack = next;
} while (next != NULL); } while (next != NULL);
} }
+7 -2
View File
@@ -12,6 +12,11 @@
#include "WizardPageView.h" #include "WizardPageView.h"
#include <Box.h> #include <Box.h>
#include <Catalog.h>
#define TR_CONTEXT "WizardView"
static const float kSeparatorHeight = 2; static const float kSeparatorHeight = 2;
static const float kSeparatorDistance = 5; static const float kSeparatorDistance = 5;
@@ -138,13 +143,13 @@ WizardView::_BuildUI()
B_FOLLOW_LEFT_RIGHT | B_FOLLOW_BOTTOM); B_FOLLOW_LEFT_RIGHT | B_FOLLOW_BOTTOM);
AddChild(fSeparator); AddChild(fSeparator);
fPrevious = new BButton(BRect(0, 0, 100, 20), "previous", "Previous", fPrevious = new BButton(BRect(0, 0, 100, 20), "previous", TR("Previous"),
new BMessage(kMessagePrevious), new BMessage(kMessagePrevious),
B_FOLLOW_LEFT | B_FOLLOW_BOTTOM); B_FOLLOW_LEFT | B_FOLLOW_BOTTOM);
AddChild(fPrevious); AddChild(fPrevious);
fPrevious->ResizeToPreferred(); fPrevious->ResizeToPreferred();
fNext = new BButton(BRect(0, 0, 100, 20), "next", "Next", fNext = new BButton(BRect(0, 0, 100, 20), "next", TR("Next"),
new BMessage(kMessageNext), new BMessage(kMessageNext),
B_FOLLOW_RIGHT | B_FOLLOW_BOTTOM); B_FOLLOW_RIGHT | B_FOLLOW_BOTTOM);
AddChild(fNext); AddChild(fNext);