diff --git a/src/apps/bootman/BootManager.cpp b/src/apps/bootman/BootManager.cpp index 30bccf3536..abf9625b8e 100644 --- a/src/apps/bootman/BootManager.cpp +++ b/src/apps/bootman/BootManager.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2008-2009, Haiku, Inc. All rights reserved. + * Copyright 2008-2010, Haiku, Inc. All rights reserved. * Distributed under the terms of the MIT License. * * Authors: @@ -7,6 +7,7 @@ * Axel Dörfler */ + #include "BootManagerWindow.h" #include @@ -20,21 +21,21 @@ #define B_TRANSLATE_CONTEXT "BootManager" -static const char* kSignature = "application/x-vnd.Haiku-bootman"; +static const char* kSignature = "application/x-vnd.Haiku-BootManager"; class BootManager : public BApplication { public: - BootManager(); + BootManager(); - virtual void ReadyToRun(); - - virtual void AboutRequested(); + virtual void ReadyToRun(); + virtual void AboutRequested(); }; BootManager::BootManager() - : BApplication(kSignature) + : + BApplication(kSignature) { } @@ -42,7 +43,7 @@ BootManager::BootManager() void BootManager::ReadyToRun() { - BootManagerWindow * window = new BootManagerWindow(); + BootManagerWindow* window = new BootManagerWindow(); window->Show(); } @@ -51,16 +52,15 @@ void BootManager::AboutRequested() { BString aboutText; - const char* title = B_TRANSLATE_COMMENT("Haiku Boot Manager", - "About text title"); - aboutText << - title << "\n\n" << - B_TRANSLATE("written by") << "\n" - "\tDavid Dengg\n" - "\tMichael Pfeiffer\n" - "\n" << - B_TRANSLATE_COMMENT("Copyright %year, Haiku Inc.\n", - "Leave %year untranslated"); + const char* title = B_TRANSLATE_COMMENT("BootManager", "Application name"); + aboutText << title << "\n\n" + << B_TRANSLATE("written by") + << "\n" + "\tDavid Dengg\n" + "\tMichael Pfeiffer\n" + "\n" + << B_TRANSLATE_COMMENT("Copyright %year, Haiku Inc.\n", + "Leave %year untranslated"); aboutText.ReplaceLast("%year", "2008-2010"); BAlert *alert = new BAlert("about", aboutText.String(), B_TRANSLATE("OK")); diff --git a/src/apps/bootman/BootManagerController.cpp b/src/apps/bootman/BootManagerController.cpp index 445b81700e..8e395f81a5 100644 --- a/src/apps/bootman/BootManagerController.cpp +++ b/src/apps/bootman/BootManagerController.cpp @@ -1,5 +1,5 @@ /* - * Copyright 20082009, Haiku, Inc. All rights reserved. + * Copyright 2008-2010, Haiku, Inc. All rights reserved. * Distributed under the terms of the MIT License. * * Authors: @@ -9,23 +9,6 @@ #include "BootManagerController.h" -#include "WizardView.h" - -#include "EntryPage.h" -#include "PartitionsPage.h" -#include "DefaultPartitionPage.h" -#include "DescriptionPage.h" -#include "FileSelectionPage.h" -#include "LegacyBootDrive.h" - - -#define USE_TEST_BOOT_DRIVE 0 - -#if USE_TEST_BOOT_DRIVE - #include "TestBootDrive.h" -#endif - - #include #include #include @@ -35,6 +18,21 @@ #include #include +#include "DefaultPartitionPage.h" +#include "DescriptionPage.h" +#include "EntryPage.h" +#include "FileSelectionPage.h" +#include "LegacyBootDrive.h" +#include "PartitionsPage.h" +#include "WizardView.h" + + +#define USE_TEST_BOOT_DRIVE 0 + +#if USE_TEST_BOOT_DRIVE +# include "TestBootDrive.h" +#endif + #undef B_TRANSLATE_CONTEXT #define B_TRANSLATE_CONTEXT "BootManagerController" @@ -90,19 +88,19 @@ BootManagerController::NextState(int32 state) { switch (state) { case kStateEntry: - { - bool install; - fSettings.FindBool("install", &install); - if (install) { - if (fBootDrive->IsBootMenuInstalled(&fSettings)) - return kStatePartitions; - else - return kStateSaveMBR; - } - else - return kStateUninstall; + { + bool install; + fSettings.FindBool("install", &install); + if (install) { + if (fBootDrive->IsBootMenuInstalled(&fSettings)) + return kStatePartitions; + + return kStateSaveMBR; } + return kStateUninstall; + } + case kStateErrorEntry: be_app->PostMessage(B_QUIT_REQUESTED); break; @@ -150,7 +148,8 @@ bool BootManagerController::_HasSelectedPartitions() { 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++) { bool show; if (message.FindBool("show", &show) == B_OK && show) return true; @@ -168,16 +167,17 @@ BootManagerController::_HasSelectedPartitions() bool BootManagerController::_WriteBootMenu() { - BAlert* alert = new BAlert("confirm", B_TRANSLATE("About to write the " + BAlert* alert = new BAlert("confirm", B_TRANSLATE("About to write the " "boot menu to disk. Are you sure you want to continue?"), - B_TRANSLATE_COMMENT("Write boot menu", "Button"), - B_TRANSLATE_COMMENT("Back", "Button"), NULL, B_WIDTH_AS_USUAL, B_WARNING_ALERT); + B_TRANSLATE_COMMENT("Write boot menu", "Button"), + B_TRANSLATE_COMMENT("Back", "Button"), NULL, B_WIDTH_AS_USUAL, + B_WARNING_ALERT); - if (alert->Go() == 1) - return false; + if (alert->Go() == 1) + return false; - fWriteBootMenuStatus = fBootDrive->WriteBootMenu(&fSettings); - return true; + fWriteBootMenuStatus = fBootDrive->WriteBootMenu(&fSettings); + return true; } @@ -279,19 +279,19 @@ BootManagerController::_CreateErrorEntryPage(BRect frame) { BString description; - if (fReadPartitionsStatus == kErrorBootSectorTooSmall) - description << - B_TRANSLATE_COMMENT("Partition table not compatible", "Title") << - "\n\n" << - B_TRANSLATE("The partition table of the first hard disk is not " - "compatible with Boot Manager.\n" - "Boot Manager needs 2 KB available space before the first " - "partition."); - else - description << - B_TRANSLATE_COMMENT("Error reading partition table", "Title") << - "\n\n" << - B_TRANSLATE("Boot Manager is unable to read the partition table!"); + if (fReadPartitionsStatus == kErrorBootSectorTooSmall) { + description << B_TRANSLATE_COMMENT("Partition table not compatible", + "Title") << "\n\n" + << B_TRANSLATE("The partition table of the first hard disk is not " + "compatible with Boot Manager.\n" + "Boot Manager needs 2 KB available space before the first " + "partition."); + } else { + description << B_TRANSLATE_COMMENT("Error reading partition table", + "Title") << "\n\n" + << B_TRANSLATE("Boot Manager is unable to read the partition " + "table!"); + } return new DescriptionPage(frame, "errorEntry", description.String(), true); } @@ -304,15 +304,15 @@ BootManagerController::_CreateSaveMBRPage(BRect frame) BString disk; fSettings.FindString("disk", &disk); - description << - B_TRANSLATE_COMMENT("Backup Master Boot Record", "Title") << "\n\n" << - B_TRANSLATE("The Master Boot Record (MBR) of the boot device:\n" - "\t%s\n" - "will now be saved to disk. Please select a file to " - "save the MBR into.\n\n" - "If something goes wrong with the installation or if " - "you later wish to remove the boot menu, simply run the " - "bootman program and choose the 'Uninstall' option."); + description << B_TRANSLATE_COMMENT("Backup Master Boot Record", "Title") + << "\n\n" << B_TRANSLATE("The Master Boot Record (MBR) of the boot " + "device:\n" + "\t%s\n" + "will now be saved to disk. Please select a file to " + "save the MBR into.\n\n" + "If something goes wrong with the installation or if " + "you later wish to remove the boot menu, simply run the " + "bootman program and choose the 'Uninstall' option."); description.ReplaceFirst("%s", disk); return new FileSelectionPage(&fSettings, frame, "saveMBR", @@ -329,17 +329,15 @@ BootManagerController::_CreateMBRSavedPage(BRect frame) fSettings.FindString("file", &file); if (fSaveMBRStatus == B_OK) { - description << - B_TRANSLATE_COMMENT("Old Master Boot Record saved", "Title") << - "\n\n" << - B_TRANSLATE("The old Master Boot Record was successfully saved to " - "%s.") << "\n"; + description << B_TRANSLATE_COMMENT("Old Master Boot Record saved", + "Title") << "\n\n" + << B_TRANSLATE("The old Master Boot Record was successfully " + "saved to %s.") << "\n"; } else { - description << - B_TRANSLATE_COMMENT("Old Master Boot Record Saved failure", "Title") << - "\n\n" << - B_TRANSLATE("The old Master Boot Record could not be saved to %s") << - "\n"; + description << B_TRANSLATE_COMMENT("Old Master Boot Record Saved " + "failure", "Title") << "\n\n" + << B_TRANSLATE("The old Master Boot Record could not be saved " + "to %s") << "\n"; } description.ReplaceFirst("%s", file); @@ -354,16 +352,15 @@ BootManagerController::_CreateInstallSummaryPage(BRect frame) BString disk; fSettings.FindString("disk", &disk); - description << - B_TRANSLATE_COMMENT("Summary", "Title") << "\n\n" << - B_TRANSLATE("About to write the following boot menu to the boot disk " - "(%s). Please verify the information below before continuing.") << - "\n\n"; + description << B_TRANSLATE_COMMENT("Summary", "Title") << "\n\n" + << B_TRANSLATE("About to write the following boot menu to the boot " + "disk (%s). Please verify the information below before continuing.") + << "\n\n"; description.ReplaceFirst("%s", disk); 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++) { bool show; if (message.FindBool("show", &show) != B_OK || !show) continue; @@ -390,14 +387,14 @@ BootManagerController::_CreateInstalledPage(BRect frame) BString description; if (fWriteBootMenuStatus == B_OK) { - description << - B_TRANSLATE_COMMENT("Installation of boot menu completed", "Title") << "\n\n" << - B_TRANSLATE("The boot manager has been successfully installed " + description << B_TRANSLATE_COMMENT("Installation of boot menu " + "completed", "Title") << "\n\n" + << B_TRANSLATE("The boot manager has been successfully installed " "on your system."); } else { - description << - B_TRANSLATE_COMMENT("Installation of boot menu failed", "Title") << "\n\n" << - B_TRANSLATE("An error occurred writing the boot menu. " + description << B_TRANSLATE_COMMENT("Installation of boot menu failed", + "Title") << "\n\n" + << B_TRANSLATE("An error occurred writing the boot menu. " "The Master Boot Record might be destroyed, " "you should restore the MBR now!"); } @@ -410,11 +407,10 @@ WizardPageView* BootManagerController::_CreateUninstallPage(BRect frame) { BString description; - - description << - B_TRANSLATE_COMMENT("Uninstall boot manager", "Title") << "\n\n" << - B_TRANSLATE("Please locate the Master Boot Record (MBR) save file to " - "restore from. This is the file that was created when the " + description << B_TRANSLATE_COMMENT("Uninstall boot manager", "Title") + << "\n\n" + << B_TRANSLATE("Please locate the Master Boot Record (MBR) save file " + "to restore from. This is the file that was created when the " "boot manager was first installed."); return new FileSelectionPage(&fSettings, frame, "restoreMBR", @@ -432,17 +428,16 @@ BootManagerController::_CreateUninstalledPage(BRect frame) fSettings.FindString("file", &file); if (fRestoreMBRStatus == B_OK) { - description << - B_TRANSLATE_COMMENT("Uninstallation of boot menu completed", "Title") << - "\n\n" << - B_TRANSLATE("The Master Boot Record of the boot device " - "(%s) has been successfully restored from %s."); - description.ReplaceFirst("%s", disk); - description.ReplaceLast("%s", file); + description << B_TRANSLATE_COMMENT("Uninstallation of boot menu " + "completed", "Title") << "\n\n" + << B_TRANSLATE("The Master Boot Record of the boot device " + "(%DISK) has been successfully restored from %FILE."); + description.ReplaceFirst("%DISK", disk); + description.ReplaceFirst("%FILE", file); } else { - description << - B_TRANSLATE_COMMENT("Uninstallation of boot menu failed", "Title") << "\n\n" << - B_TRANSLATE("The Master Boot Record could not be restored!"); + description << B_TRANSLATE_COMMENT("Uninstallation of boot menu " + "failed", "Title") << "\n\n" + << B_TRANSLATE("The Master Boot Record could not be restored!"); } return new DescriptionPage(frame, "summary", description.String(), true); diff --git a/src/apps/bootman/BootManagerController.h b/src/apps/bootman/BootManagerController.h index f36bb1969f..f23af7f28e 100644 --- a/src/apps/bootman/BootManagerController.h +++ b/src/apps/bootman/BootManagerController.h @@ -1,49 +1,49 @@ /* - * Copyright 2008, Haiku, Inc. All rights reserved. + * Copyright 2008-2010, Haiku, Inc. All rights reserved. * Distributed under the terms of the MIT License. - * + * * Authors: * Michael Pfeiffer */ #ifndef BOOT_MANAGER_CONTROLLER_H #define BOOT_MANAGER_CONTROLLER_H + #include "WizardController.h" #include + class BootDrive; class WizardView; class WizardPageView; class BRect; -/* - Remainder of Settings Message Format: - (See also BootDrive.h) + +/* Remainder of Settings Message Format: + (See also BootDrive.h) "install" bool (whether install or uninstall should be performed) "file" String (the file where the backup of the MBR is saved) "defaultPartition" int32 (index of default partition) "timeout" int32 (timeout in seconds, -1 for no timeout) - */ +*/ -class BootManagerController : public WizardController -{ +class BootManagerController : public WizardController { public: - BootManagerController(); - virtual ~BootManagerController(); + BootManagerController(); + virtual ~BootManagerController(); protected: - virtual int32 InitialState(); - virtual int32 NextState(int32 state); - virtual WizardPageView* CreatePage(int32 state, WizardView* wizard); + virtual int32 InitialState(); + virtual int32 NextState(int32 state); + virtual WizardPageView* CreatePage(int32 state, WizardView* wizard); private: - enum State { kStateEntry, kStateErrorEntry, - + // Install states kStateSaveMBR, kStateMBRSaved, @@ -51,32 +51,32 @@ private: kStateDefaultPartitions, kStateInstallSummary, kStateInstalled, - + // Uninstall states kStateUninstall, kStateUninstalled }; - - bool _HasSelectedPartitions(); - bool _WriteBootMenu(); - bool _SaveMBR(); - bool _RestoreMBR(); - - WizardPageView* _CreateErrorEntryPage(BRect frame); - WizardPageView* _CreateSaveMBRPage(BRect frame); - WizardPageView* _CreateMBRSavedPage(BRect frame); - WizardPageView* _CreateInstallSummaryPage(BRect frame); - WizardPageView* _CreateInstalledPage(BRect frame); - WizardPageView* _CreateUninstallPage(BRect frame); - WizardPageView* _CreateUninstalledPage(BRect frame); - - BMessage fSettings; - BootDrive* fBootDrive; - - status_t fReadPartitionsStatus; - status_t fWriteBootMenuStatus; - status_t fSaveMBRStatus; - status_t fRestoreMBRStatus; + + bool _HasSelectedPartitions(); + bool _WriteBootMenu(); + bool _SaveMBR(); + bool _RestoreMBR(); + + WizardPageView* _CreateErrorEntryPage(BRect frame); + WizardPageView* _CreateSaveMBRPage(BRect frame); + WizardPageView* _CreateMBRSavedPage(BRect frame); + WizardPageView* _CreateInstallSummaryPage(BRect frame); + WizardPageView* _CreateInstalledPage(BRect frame); + WizardPageView* _CreateUninstallPage(BRect frame); + WizardPageView* _CreateUninstalledPage(BRect frame); + + BMessage fSettings; + BootDrive* fBootDrive; + + status_t fReadPartitionsStatus; + status_t fWriteBootMenuStatus; + status_t fSaveMBRStatus; + status_t fRestoreMBRStatus; }; diff --git a/src/apps/bootman/BootManagerWindow.cpp b/src/apps/bootman/BootManagerWindow.cpp index 5724eb7b40..b8bfbc5081 100644 --- a/src/apps/bootman/BootManagerWindow.cpp +++ b/src/apps/bootman/BootManagerWindow.cpp @@ -33,7 +33,7 @@ BootManagerWindow::BootManagerWindow() : - BWindow(BRect(100, 100, 500, 400), B_TRANSLATE_COMMENT("Boot Manager", + BWindow(BRect(100, 100, 500, 400), B_TRANSLATE_COMMENT("BootManager", "Window Title"), B_TITLED_WINDOW, B_ASYNCHRONOUS_CONTROLS | B_NOT_ZOOMABLE) diff --git a/src/apps/bootman/BootManagerWindow.h b/src/apps/bootman/BootManagerWindow.h index c09885bcc4..65c036676d 100644 --- a/src/apps/bootman/BootManagerWindow.h +++ b/src/apps/bootman/BootManagerWindow.h @@ -1,7 +1,7 @@ /* - * Copyright 2008, Haiku, Inc. All rights reserved. + * Copyright 2008-2010, Haiku, Inc. All rights reserved. * Distributed under the terms of the MIT License. - * + * * Authors: * Michael Pfeiffer */ @@ -13,21 +13,22 @@ #include "BootManagerController.h" + class WizardView; -class BootManagerWindow : public BWindow -{ + +class BootManagerWindow : public BWindow { public: - BootManagerWindow(); - virtual ~BootManagerWindow(); + BootManagerWindow(); + virtual ~BootManagerWindow(); + + virtual void MessageReceived(BMessage* message); + virtual bool QuitRequested(); - virtual void MessageReceived(BMessage* message); - virtual bool QuitRequested(); - private: - - BootManagerController fController; - WizardView* fWizardView; + BootManagerController fController; + WizardView* fWizardView; }; + #endif // BOOT_MANAGER_WINDOW_H