* Applied patch by idefix that fixes IDE. Nah, that fixes launching BootManager

when mimset didn't run yet. This obviously cleans up after a change that I
  did, thanks a lot!
* This closes bug #7595.
* Also took the opportunity to clean up a bit more in this regard, and fixed a
  few coding style violations.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@41837 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Axel Dörfler
2011-05-30 21:17:10 +00:00
parent b5274bc4f6
commit 3feabba6d9
2 changed files with 57 additions and 50 deletions
+48 -44
View File
@@ -49,9 +49,10 @@
#undef B_TRANSLATE_CONTEXT #undef B_TRANSLATE_CONTEXT
#define B_TRANSLATE_CONTEXT "InstallerWindow" #define B_TRANSLATE_CONTEXT "InstallerWindow"
#define DRIVESETUP_SIG "application/x-vnd.Haiku-DriveSetup"
#define BOOTMAN_SIG "application/x-vnd.Haiku-BootManager"
static const char* kDriveSetupSignature = "application/x-vnd.Haiku-DriveSetup";
static const char* kBootManagerSignature
= "application/x-vnd.Haiku-BootManager";
const uint32 BEGIN_MESSAGE = 'iBGN'; const uint32 BEGIN_MESSAGE = 'iBGN';
const uint32 SHOW_BOTTOM_MESSAGE = 'iSBT'; const uint32 SHOW_BOTTOM_MESSAGE = 'iSBT';
@@ -160,7 +161,7 @@ InstallerWindow::InstallerWindow()
B_NOT_ZOOMABLE | B_AUTO_UPDATE_SIZE_LIMITS), B_NOT_ZOOMABLE | B_AUTO_UPDATE_SIZE_LIMITS),
fEncouragedToSetupPartitions(false), fEncouragedToSetupPartitions(false),
fDriveSetupLaunched(false), fDriveSetupLaunched(false),
fBootmanLaunched(false), fBootManagerLaunched(false),
fInstallStatus(kReadyForInstall), fInstallStatus(kReadyForInstall),
fWorkerThread(new WorkerThread(this)), fWorkerThread(new WorkerThread(this)),
fCopyEngineCancelSemaphore(-1) fCopyEngineCancelSemaphore(-1)
@@ -225,16 +226,16 @@ InstallerWindow::InstallerWindow()
B_TRANSLATE("Set up partitions" B_UTF8_ELLIPSIS), B_TRANSLATE("Set up partitions" B_UTF8_ELLIPSIS),
new BMessage(LAUNCH_DRIVE_SETUP)); new BMessage(LAUNCH_DRIVE_SETUP));
fLaunchBootmanItem = new BMenuItem(B_TRANSLATE("Set up boot menu"), fLaunchBootManagerItem = new BMenuItem(B_TRANSLATE("Set up boot menu"),
new BMessage(LAUNCH_BOOTMAN)); new BMessage(LAUNCH_BOOTMAN));
fLaunchBootmanItem->SetEnabled(false); fLaunchBootManagerItem->SetEnabled(false);
fMakeBootableItem = new BMenuItem(B_TRANSLATE("Write boot sector"), fMakeBootableItem = new BMenuItem(B_TRANSLATE("Write boot sector"),
new BMessage(MSG_WRITE_BOOT_SECTOR)); new BMessage(MSG_WRITE_BOOT_SECTOR));
fMakeBootableItem->SetEnabled(false); fMakeBootableItem->SetEnabled(false);
BMenuBar* mainMenu = new BMenuBar("main menu"); BMenuBar* mainMenu = new BMenuBar("main menu");
BMenu* toolsMenu = new BMenu(B_TRANSLATE("Tools")); BMenu* toolsMenu = new BMenu(B_TRANSLATE("Tools"));
toolsMenu->AddItem(fLaunchBootmanItem); toolsMenu->AddItem(fLaunchBootManagerItem);
toolsMenu->AddItem(fMakeBootableItem); toolsMenu->AddItem(fMakeBootableItem);
mainMenu->AddItem(toolsMenu); mainMenu->AddItem(toolsMenu);
@@ -289,7 +290,7 @@ InstallerWindow::InstallerWindow()
"Partitions can be initialized with the\n" "Partitions can be initialized with the\n"
"Be File System needed for a Haiku boot\n" "Be File System needed for a Haiku boot\n"
"partition.")); "partition."));
// fLaunchBootmanItem->SetToolTip( // fLaunchBootManagerItem->SetToolTip(
// B_TRANSLATE("Install or uninstall the Haiku boot menu, which allows " // B_TRANSLATE("Install or uninstall the Haiku boot menu, which allows "
// "to choose an operating system to boot when the computer starts.\n" // "to choose an operating system to boot when the computer starts.\n"
// "If this computer already has a boot manager such as GRUB installed, " // "If this computer already has a boot manager such as GRUB installed, "
@@ -311,12 +312,12 @@ InstallerWindow::InstallerWindow()
// Register to receive notifications when apps launch or quit... // Register to receive notifications when apps launch or quit...
be_roster->StartWatching(this); be_roster->StartWatching(this);
// ... and check the two we are interested in. // ... and check the two we are interested in.
fDriveSetupLaunched = be_roster->IsRunning(DRIVESETUP_SIG); fDriveSetupLaunched = be_roster->IsRunning(kDriveSetupSignature);
fBootmanLaunched = be_roster->IsRunning(BOOTMAN_SIG); fBootManagerLaunched = be_roster->IsRunning(kBootManagerSignature);
if (Lock()) { if (Lock()) {
fLaunchDriveSetupButton->SetEnabled(!fDriveSetupLaunched); fLaunchDriveSetupButton->SetEnabled(!fDriveSetupLaunched);
fLaunchBootmanItem->SetEnabled(!fBootmanLaunched); fLaunchBootManagerItem->SetEnabled(!fBootManagerLaunched);
Unlock(); Unlock();
} }
@@ -412,7 +413,7 @@ InstallerWindow::MessageReceived(BMessage *msg)
_LaunchDriveSetup(); _LaunchDriveSetup();
break; break;
case LAUNCH_BOOTMAN: case LAUNCH_BOOTMAN:
_LaunchBootman(); _LaunchBootManager();
break; break;
case PACKAGE_CHECKBOX: case PACKAGE_CHECKBOX:
{ {
@@ -512,9 +513,9 @@ InstallerWindow::MessageReceived(BMessage *msg)
const char *signature; const char *signature;
if (msg->FindString("be:signature", &signature) != B_OK) if (msg->FindString("be:signature", &signature) != B_OK)
break; break;
bool isDriveSetup = strcasecmp(signature, DRIVESETUP_SIG) == 0; bool isDriveSetup = !strcasecmp(signature, kDriveSetupSignature);
bool isBootman = strcasecmp(signature, BOOTMAN_SIG) == 0; bool isBootManager = !strcasecmp(signature, kBootManagerSignature);
if (isDriveSetup || isBootman) { if (isDriveSetup || isBootManager) {
bool scanPartitions = false; bool scanPartitions = false;
if (isDriveSetup) { if (isDriveSetup) {
bool launched = msg->what == B_SOME_APP_LAUNCHED; bool launched = msg->what == B_SOME_APP_LAUNCHED;
@@ -522,13 +523,13 @@ InstallerWindow::MessageReceived(BMessage *msg)
scanPartitions = fDriveSetupLaunched && !launched; scanPartitions = fDriveSetupLaunched && !launched;
fDriveSetupLaunched = launched; fDriveSetupLaunched = launched;
} }
if (isBootman) if (isBootManager)
fBootmanLaunched = msg->what == B_SOME_APP_LAUNCHED; fBootManagerLaunched = msg->what == B_SOME_APP_LAUNCHED;
fBeginButton->SetEnabled( fBeginButton->SetEnabled(
!fDriveSetupLaunched && !fBootmanLaunched); !fDriveSetupLaunched && !fBootManagerLaunched);
_DisableInterface(fDriveSetupLaunched || fBootmanLaunched); _DisableInterface(fDriveSetupLaunched || fBootManagerLaunched);
if (fDriveSetupLaunched && fBootmanLaunched) { if (fDriveSetupLaunched && fBootManagerLaunched) {
_SetStatusMessage(B_TRANSLATE("Running Boot Manager and " _SetStatusMessage(B_TRANSLATE("Running Boot Manager and "
"DriveSetup" B_UTF8_ELLIPSIS "DriveSetup" B_UTF8_ELLIPSIS
"\n\nClose both applications to continue with the " "\n\nClose both applications to continue with the "
@@ -538,7 +539,7 @@ InstallerWindow::MessageReceived(BMessage *msg)
B_UTF8_ELLIPSIS B_UTF8_ELLIPSIS
"\n\nClose DriveSetup to continue with the " "\n\nClose DriveSetup to continue with the "
"installation.")); "installation."));
} else if (fBootmanLaunched) { } else if (fBootManagerLaunched) {
_SetStatusMessage(B_TRANSLATE("Running Boot Manager" _SetStatusMessage(B_TRANSLATE("Running Boot Manager"
B_UTF8_ELLIPSIS B_UTF8_ELLIPSIS
"\n\nClose Boot Manager to continue with the " "\n\nClose Boot Manager to continue with the "
@@ -573,37 +574,39 @@ InstallerWindow::QuitRequested()
// This means Deskbar is not running, i.e. Installer is the only // This means Deskbar is not running, i.e. Installer is the only
// thing on the screen and we will reboot the machine once it quits. // thing on the screen and we will reboot the machine once it quits.
if (fDriveSetupLaunched && fBootmanLaunched) { if (fDriveSetupLaunched && fBootManagerLaunched) {
(new BAlert(B_TRANSLATE("Quit Boot Manager and DriveSetup"), (new BAlert(B_TRANSLATE("Quit Boot Manager and DriveSetup"),
B_TRANSLATE("Please close the Boot Manager and DriveSetup " B_TRANSLATE("Please close the Boot Manager and DriveSetup "
"windows before closing the Installer window."), "windows before closing the Installer window."),
B_TRANSLATE("OK")))->Go(); B_TRANSLATE("OK")))->Go();
return false; return false;
} else if (fDriveSetupLaunched) { }
if (fDriveSetupLaunched) {
(new BAlert(B_TRANSLATE("Quit DriveSetup"), (new BAlert(B_TRANSLATE("Quit DriveSetup"),
B_TRANSLATE("Please close the DriveSetup window before closing " B_TRANSLATE("Please close the DriveSetup window before closing "
"the Installer window."), B_TRANSLATE("OK")))->Go(); "the Installer window."), B_TRANSLATE("OK")))->Go();
return false; return false;
} else if (fBootmanLaunched) { }
if (fBootManagerLaunched) {
(new BAlert(B_TRANSLATE("Quit Boot Manager"), (new BAlert(B_TRANSLATE("Quit Boot Manager"),
B_TRANSLATE("Please close the Boot Manager window before " B_TRANSLATE("Please close the Boot Manager window before "
"closing the Installer window."), B_TRANSLATE("OK")))->Go(); "closing the Installer window."), B_TRANSLATE("OK")))->Go();
return false; return false;
} }
if (fInstallStatus != kFinished) if (fInstallStatus != kFinished
if ((new BAlert(B_TRANSLATE_SYSTEM_NAME("Installer"), && (new BAlert(B_TRANSLATE_SYSTEM_NAME("Installer"),
B_TRANSLATE("Are you sure you want to abort the installation " B_TRANSLATE("Are you sure you want to abort the "
"and restart the system?"), "installation and restart the system?"),
B_TRANSLATE("Cancel"), B_TRANSLATE("Restart system"), NULL, B_TRANSLATE("Cancel"), B_TRANSLATE("Restart system"), NULL,
B_WIDTH_AS_USUAL, B_STOP_ALERT))->Go() == 0) B_WIDTH_AS_USUAL, B_STOP_ALERT))->Go() == 0) {
return false; return false;
}
} else if (fInstallStatus == kInstalling) { } else if (fInstallStatus == kInstalling
if ((new BAlert(B_TRANSLATE_SYSTEM_NAME("Installer"), && (new BAlert(B_TRANSLATE_SYSTEM_NAME("Installer"),
B_TRANSLATE("Are you sure you want to abort the installation?"), B_TRANSLATE("Are you sure you want to abort the installation?"),
B_TRANSLATE("Cancel"), B_TRANSLATE("Abort"), NULL, B_TRANSLATE("Cancel"), B_TRANSLATE("Abort"), NULL,
B_WIDTH_AS_USUAL, B_STOP_ALERT))->Go() == 0) B_WIDTH_AS_USUAL, B_STOP_ALERT))->Go() == 0) {
return false; return false;
} }
@@ -630,7 +633,7 @@ InstallerWindow::_ShowOptionalPackages()
void void
InstallerWindow::_LaunchDriveSetup() InstallerWindow::_LaunchDriveSetup()
{ {
if (be_roster->Launch(DRIVESETUP_SIG) != B_OK) { if (be_roster->Launch(kDriveSetupSignature) != B_OK) {
// Try really hard to launch it. It's very likely that this fails, // Try really hard to launch it. It's very likely that this fails,
// when we run from the CD and there is only an incomplete mime // when we run from the CD and there is only an incomplete mime
// database for example... // database for example...
@@ -652,24 +655,25 @@ InstallerWindow::_LaunchDriveSetup()
void void
InstallerWindow::_LaunchBootman() InstallerWindow::_LaunchBootManager()
{ {
// TODO: Currently bootman always tries to install to the "first" harddisk. // TODO: Currently BootManager always tries to install to the "first"
// If/when it later supports being installed to a certain harddisk, we // harddisk. If/when it later supports being installed to a certain
// would have to pass it the disk that contains the target partition here. // harddisk, we would have to pass it the disk that contains the target
if (be_roster->Launch(BOOTMAN_SIG) != B_OK) { // partition here.
if (be_roster->Launch(kBootManagerSignature) != B_OK) {
// Try really hard to launch it. It's very likely that this fails, // Try really hard to launch it. It's very likely that this fails,
// when we run from the CD and there is only an incomplete mime // when we run from the CD and there is only an incomplete mime
// database for example... // database for example...
BPath path; BPath path;
if (find_directory(B_SYSTEM_BIN_DIRECTORY, &path) != B_OK if (find_directory(B_SYSTEM_APPS_DIRECTORY, &path) != B_OK
|| path.Append("bootman") != B_OK) { || path.Append("BootManager") != B_OK) {
path.SetTo("/boot/system/bin/bootman"); path.SetTo("/boot/system/apps/BootManager");
} }
BEntry entry(path.Path()); BEntry entry(path.Path());
entry_ref ref; entry_ref ref;
if (entry.GetRef(&ref) != B_OK || be_roster->Launch(&ref) != B_OK) { if (entry.GetRef(&ref) != B_OK || be_roster->Launch(&ref) != B_OK) {
BAlert* alert = new BAlert("error", B_TRANSLATE("Bootman, the " BAlert* alert = new BAlert("error", B_TRANSLATE("BootManager, the "
"application to configure the Haiku boot menu, could not be " "application to configure the Haiku boot menu, could not be "
"launched."), B_TRANSLATE("OK")); "launched."), B_TRANSLATE("OK"));
alert->Go(); alert->Go();
@@ -682,7 +686,7 @@ void
InstallerWindow::_DisableInterface(bool disable) InstallerWindow::_DisableInterface(bool disable)
{ {
fLaunchDriveSetupButton->SetEnabled(!disable); fLaunchDriveSetupButton->SetEnabled(!disable);
fLaunchBootmanItem->SetEnabled(!disable); fLaunchBootManagerItem->SetEnabled(!disable);
fMakeBootableItem->SetEnabled(!disable); fMakeBootableItem->SetEnabled(!disable);
fSrcMenuField->SetEnabled(!disable); fSrcMenuField->SetEnabled(!disable);
fDestMenuField->SetEnabled(!disable); fDestMenuField->SetEnabled(!disable);
@@ -785,7 +789,7 @@ InstallerWindow::_UpdateControls()
fMakeBootableItem->SetLabel(label.String()); fMakeBootableItem->SetLabel(label.String());
// TODO: Once bootman support writing to specific disks, enable this, since // TODO: Once bootman support writing to specific disks, enable this, since
// we would pass it the disk which contains the target partition. // we would pass it the disk which contains the target partition.
// fLaunchBootmanItem->SetEnabled(dstItem != NULL); // fLaunchBootManagerItem->SetEnabled(dstItem != NULL);
if (!fEncouragedToSetupPartitions && !foundOneSuitableTarget) { if (!fEncouragedToSetupPartitions && !foundOneSuitableTarget) {
// Focus the users attention on the DriveSetup button // Focus the users attention on the DriveSetup button
+6 -3
View File
@@ -6,9 +6,11 @@
#ifndef INSTALLER_WINDOW_H #ifndef INSTALLER_WINDOW_H
#define INSTALLER_WINDOW_H #define INSTALLER_WINDOW_H
#include <String.h> #include <String.h>
#include <Window.h> #include <Window.h>
namespace BPrivate { namespace BPrivate {
class PaneSwitch; class PaneSwitch;
}; };
@@ -55,7 +57,7 @@ public:
private: private:
void _ShowOptionalPackages(); void _ShowOptionalPackages();
void _LaunchDriveSetup(); void _LaunchDriveSetup();
void _LaunchBootman(); void _LaunchBootManager();
void _DisableInterface(bool disable); void _DisableInterface(bool disable);
void _ScanPartitions(); void _ScanPartitions();
void _UpdateControls(); void _UpdateControls();
@@ -88,13 +90,13 @@ private:
BButton* fBeginButton; BButton* fBeginButton;
BButton* fLaunchDriveSetupButton; BButton* fLaunchDriveSetupButton;
BMenuItem* fLaunchBootmanItem; BMenuItem* fLaunchBootManagerItem;
BMenuItem* fMakeBootableItem; BMenuItem* fMakeBootableItem;
bool fEncouragedToSetupPartitions; bool fEncouragedToSetupPartitions;
bool fDriveSetupLaunched; bool fDriveSetupLaunched;
bool fBootmanLaunched; bool fBootManagerLaunched;
InstallStatus fInstallStatus; InstallStatus fInstallStatus;
WorkerThread* fWorkerThread; WorkerThread* fWorkerThread;
@@ -102,4 +104,5 @@ private:
sem_id fCopyEngineCancelSemaphore; sem_id fCopyEngineCancelSemaphore;
}; };
#endif // INSTALLER_WINDOW_H #endif // INSTALLER_WINDOW_H