* Cleanup.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@40113 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Axel Dörfler 2011-01-04 19:14:39 +00:00
parent 0341cc7868
commit 5b788d58b7
25 changed files with 528 additions and 514 deletions

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2008, Haiku, Inc. All rights reserved. * Copyright 2008-2010, Haiku, Inc. All rights reserved.
* Distributed under the terms of the MIT License. * Distributed under the terms of the MIT License.
* *
* Authors: * Authors:
@ -8,11 +8,12 @@
#ifndef BOOT_DRIVE_H #ifndef BOOT_DRIVE_H
#define BOOT_DRIVE_H #define BOOT_DRIVE_H
#include <File.h> #include <File.h>
#include <Message.h> #include <Message.h>
/*
Setting BMessage Format: /* Setting BMessage Format:
"disk" String (path to boot disk) "disk" String (path to boot disk)
@ -22,15 +23,16 @@
"type" String (short name of file system: bfs, dos) "type" String (short name of file system: bfs, dos)
"path" String (path to partition in /dev/...) "path" String (path to partition in /dev/...)
"size" long (size of partition in bytes) "size" long (size of partition in bytes)
*/ */
enum { enum {
// Not enough space free before first partition for boot loader // Not enough space free before first partition for boot loader
kErrorBootSectorTooSmall = B_ERRORS_END + 1, kErrorBootSectorTooSmall = B_ERRORS_END + 1,
}; };
class BootDrive
{ class BootDrive {
public: public:
BootDrive() {} BootDrive() {}
virtual ~BootDrive() {} virtual ~BootDrive() {}
@ -38,11 +40,16 @@ public:
virtual bool IsBootMenuInstalled(BMessage* settings) = 0; virtual bool IsBootMenuInstalled(BMessage* settings) = 0;
virtual status_t ReadPartitions(BMessage* settings) = 0; virtual status_t ReadPartitions(BMessage* settings) = 0;
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,
virtual status_t RestoreMasterBootRecord(BMessage* settings, BFile* file) = 0; BFile* file) = 0;
virtual status_t RestoreMasterBootRecord(BMessage* settings,
BFile* file) = 0;
// Converts the specified text into a text as it will be shown // Converts the specified text into a text as it will be shown
// in the boot menu. // in the boot menu.
virtual status_t GetDisplayText(const char* text, BString& displayText) = 0; virtual status_t GetDisplayText(const char* text,
BString& displayText) = 0;
}; };
#endif // BOOT_DRIVE_H #endif // BOOT_DRIVE_H

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2008, Haiku, Inc. All rights reserved. * Copyright 2008-2010, Haiku, Inc. All rights reserved.
* Distributed under the terms of the MIT License. * Distributed under the terms of the MIT License.
* *
* Authors: * Authors:
@ -9,28 +9,23 @@
#include "BootManagerWindow.h" #include "BootManagerWindow.h"
#include "WizardView.h"
#include "EntryPage.h"
#include "PartitionsPage.h"
#include "DefaultPartitionPage.h"
#include <Application.h> #include <Application.h>
#include <Catalog.h> #include <Catalog.h>
#include <Locale.h>
#include <Roster.h> #include <Roster.h>
#include <Screen.h> #include <Screen.h>
#include <math.h> #include <tracker_private.h>
#include "tracker_private.h" #include "DefaultPartitionPage.h"
#include "EntryPage.h"
#include "PartitionsPage.h"
#include "WizardView.h"
#undef B_TRANSLATE_CONTEXT #undef B_TRANSLATE_CONTEXT
#define B_TRANSLATE_CONTEXT "BootManagerWindow" #define B_TRANSLATE_CONTEXT "BootManagerWindow"
BootManagerWindow::BootManagerWindow() BootManagerWindow::BootManagerWindow()
: :
BWindow(BRect(100, 100, 500, 400), B_TRANSLATE_COMMENT("BootManager", BWindow(BRect(100, 100, 500, 400), B_TRANSLATE_COMMENT("BootManager",

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2008, Haiku, Inc. All rights reserved. * Copyright 2008-2010, Haiku, Inc. All rights reserved.
* Distributed under the terms of the MIT License. * Distributed under the terms of the MIT License.
* *
* Authors: * Authors:
@ -39,13 +39,12 @@ enum {
const int32 kTimeoutIndefinitely = -1; const int32 kTimeoutIndefinitely = -1;
const int32 kDefaultTimeout = kTimeoutIndefinitely; const int32 kDefaultTimeout = kTimeoutIndefinitely;
typedef struct { struct TimeoutOption {
int32 timeout; int32 timeout;
const char* label; const char* label;
} TimeoutOption; };
static const TimeoutOption gTimeoutOptions[] = static const TimeoutOption gTimeoutOptions[] = {
{
{ 0, B_TRANSLATE_MARK("Immediately")}, { 0, B_TRANSLATE_MARK("Immediately")},
{ 1, B_TRANSLATE_MARK("After one second")}, { 1, B_TRANSLATE_MARK("After one second")},
{ 2, B_TRANSLATE_MARK("After two seconds")}, { 2, B_TRANSLATE_MARK("After two seconds")},
@ -95,8 +94,13 @@ get_label_for_timeout(int32 timeout)
} }
DefaultPartitionPage::DefaultPartitionPage(BMessage* settings, BRect frame, const char* name) // #pragma mark -
: WizardPageView(settings, frame, name, B_FOLLOW_ALL,
DefaultPartitionPage::DefaultPartitionPage(BMessage* settings, BRect frame,
const char* name)
:
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)
{ {
_BuildUI(); _BuildUI();
@ -133,8 +137,8 @@ DefaultPartitionPage::MessageReceived(BMessage* msg)
int32 index; int32 index;
msg->FindInt32("index", &index); msg->FindInt32("index", &index);
fSettings->ReplaceInt32("defaultPartition", index); fSettings->ReplaceInt32("defaultPartition", index);
}
break; break;
}
case kMsgTimeout: case kMsgTimeout:
{ {
int32 sliderValue = fTimeoutSlider->Value(); int32 sliderValue = fTimeoutSlider->Value();
@ -144,19 +148,19 @@ DefaultPartitionPage::MessageReceived(BMessage* msg)
BString label; BString label;
_GetTimeoutLabel(timeout, label); _GetTimeoutLabel(timeout, label);
fTimeoutSlider->SetLabel(label.String()); fTimeoutSlider->SetLabel(label.String());
}
break; break;
}
default: default:
WizardPageView::MessageReceived(msg); WizardPageView::MessageReceived(msg);
} }
} }
#define kTextDistance be_control_look->DefaultItemSpacing();
void void
DefaultPartitionPage::_BuildUI() DefaultPartitionPage::_BuildUI()
{ {
const float kTextDistance = be_control_look->DefaultItemSpacing();
BRect rect(Bounds()); BRect rect(Bounds());
BString text; BString text;
@ -223,8 +227,7 @@ DefaultPartitionPage::_CreatePopUpMenu()
"Pop up menu title")); "Pop up menu title"));
BMessage message; BMessage message;
for (int32 i = 0; fSettings->FindMessage("partition", i, &message) == B_OK; for (int32 i = 0; fSettings->FindMessage("partition", i, &message) == B_OK;
i ++) { i++) {
bool show; bool show;
if (message.FindBool("show", &show) != B_OK || !show) if (message.FindBool("show", &show) != B_OK || !show)
continue; continue;
@ -261,6 +264,7 @@ DefaultPartitionPage::_Layout()
{ {
LayoutDescriptionVertically(fDescription); LayoutDescriptionVertically(fDescription);
const float kTextDistance = be_control_look->DefaultItemSpacing();
float left = fDefaultPartition->Frame().left; float left = fDefaultPartition->Frame().left;
float top = fDescription->Frame().bottom + kTextDistance; float top = fDescription->Frame().bottom + kTextDistance;
@ -269,4 +273,3 @@ DefaultPartitionPage::_Layout()
fTimeoutSlider->MoveTo(left, top); fTimeoutSlider->MoveTo(left, top);
} }

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2008, Haiku, Inc. All rights reserved. * Copyright 2008-2010, Haiku, Inc. All rights reserved.
* Distributed under the terms of the MIT License. * Distributed under the terms of the MIT License.
* *
* Authors: * Authors:
@ -20,10 +20,10 @@ class BSlider;
class BTextView; class BTextView;
class DefaultPartitionPage : public WizardPageView class DefaultPartitionPage : public WizardPageView {
{
public: public:
DefaultPartitionPage(BMessage* settings, BRect frame, const char* name); DefaultPartitionPage(BMessage* settings,
BRect frame, const char* name);
virtual ~DefaultPartitionPage(); virtual ~DefaultPartitionPage();
virtual void FrameResized(float width, float height); virtual void FrameResized(float width, float height);
@ -32,15 +32,16 @@ public:
virtual void MessageReceived(BMessage* msg); virtual void MessageReceived(BMessage* msg);
private: private:
void _BuildUI(); void _BuildUI();
BPopUpMenu* _CreatePopUpMenu(); BPopUpMenu* _CreatePopUpMenu();
void _GetTimeoutLabel(int32 timeout, BString& label); void _GetTimeoutLabel(int32 timeout, BString& label);
void _Layout(); void _Layout();
private:
BTextView* fDescription; BTextView* fDescription;
BMenuField* fDefaultPartition; BMenuField* fDefaultPartition;
BSlider* fTimeoutSlider; BSlider* fTimeoutSlider;
}; };
#endif // DEFAULT_PARTITON_PAGE_H #endif // DEFAULT_PARTITON_PAGE_H

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2008, Haiku, Inc. All rights reserved. * Copyright 2008-2010, Haiku, Inc. All rights reserved.
* Distributed under the terms of the MIT License. * Distributed under the terms of the MIT License.
* *
* Authors: * Authors:
@ -9,16 +9,16 @@
#include "DescriptionPage.h" #include "DescriptionPage.h"
#include <string.h>
#include <RadioButton.h> #include <RadioButton.h>
#include <TextView.h> #include <TextView.h>
#include <string.h>
DescriptionPage::DescriptionPage(BRect frame, const char* name, DescriptionPage::DescriptionPage(BRect frame, const char* name,
const char* description, bool hasHeading) const char* description, bool hasHeading)
: WizardPageView(NULL, frame, name, B_FOLLOW_ALL, :
WizardPageView(NULL, 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)
{ {
_BuildUI(description, hasHeading); _BuildUI(description, hasHeading);
@ -38,8 +38,6 @@ DescriptionPage::FrameResized(float width, float height)
} }
static const float kTextDistance = 10;
void void
DescriptionPage::_BuildUI(const char* description, bool hasHeading) DescriptionPage::_BuildUI(const char* description, bool hasHeading)
{ {

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2008, Haiku, Inc. All rights reserved. * Copyright 2008-2010, Haiku, Inc. All rights reserved.
* Distributed under the terms of the MIT License. * Distributed under the terms of the MIT License.
* *
* Authors: * Authors:
@ -14,20 +14,22 @@
class BTextView; class BTextView;
class DescriptionPage : public WizardPageView class DescriptionPage : public WizardPageView {
{
public: public:
DescriptionPage(BRect frame, const char* name, const char* description, bool hasHeading); DescriptionPage(BRect frame, const char* name,
const char* description, bool hasHeading);
virtual ~DescriptionPage(); virtual ~DescriptionPage();
virtual void FrameResized(float width, float height); virtual void FrameResized(float width, float height);
private: private:
void _BuildUI(const char* description,
void _BuildUI(const char* description, bool hasHeading); bool hasHeading);
void _Layout(); void _Layout();
private:
BTextView* fDescription; BTextView* fDescription;
}; };
#endif // DESCRIPTION_PAGE_H #endif // DESCRIPTION_PAGE_H

View File

@ -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. * Distributed under the terms of the MIT License.
* *
* Authors: * Authors:
@ -9,21 +9,21 @@
#include "EntryPage.h" #include "EntryPage.h"
#include <string.h>
#include <Catalog.h> #include <Catalog.h>
#include <Locale.h> #include <ControlLook.h>
#include <RadioButton.h> #include <RadioButton.h>
#include <TextView.h> #include <TextView.h>
#include <string.h>
#undef B_TRANSLATE_CONTEXT #undef B_TRANSLATE_CONTEXT
#define B_TRANSLATE_CONTEXT "EntryPage" #define B_TRANSLATE_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)
{ {
_BuildUI(); _BuildUI();
@ -49,7 +49,6 @@ EntryPage::PageCompleted()
fSettings->ReplaceBool("install", fInstall->Value() != 0); fSettings->ReplaceBool("install", fInstall->Value() != 0);
} }
static const float kTextDistance = 10;
void void
EntryPage::_BuildUI() EntryPage::_BuildUI()
@ -63,7 +62,8 @@ EntryPage::_BuildUI()
fInstall->ResizeToPreferred(); fInstall->ResizeToPreferred();
BRect textRect(rect); BRect textRect(rect);
textRect.left = fInstall->Frame().right + kTextDistance; textRect.left = fInstall->Frame().right
+ be_control_look->DefaultItemSpacing();
BString text; BString text;
text << text <<

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2008, Haiku, Inc. All rights reserved. * Copyright 2008-2010, Haiku, Inc. All rights reserved.
* Distributed under the terms of the MIT License. * Distributed under the terms of the MIT License.
* *
* Authors: * Authors:
@ -15,10 +15,11 @@
class BRadioButton; class BRadioButton;
class BTextView; class BTextView;
class EntryPage : public WizardPageView
{ class EntryPage : public WizardPageView {
public: public:
EntryPage(BMessage* settings, BRect frame, const char* name); EntryPage(BMessage* settings, BRect frame,
const char* name);
virtual ~EntryPage(); virtual ~EntryPage();
virtual void FrameResized(float width, float height); virtual void FrameResized(float width, float height);
@ -26,14 +27,15 @@ public:
virtual void PageCompleted(); virtual void PageCompleted();
private: private:
void _BuildUI(); void _BuildUI();
void _Layout(); void _Layout();
private:
BRadioButton* fInstall; BRadioButton* fInstall;
BTextView* fInstallText; BTextView* fInstallText;
BRadioButton* fUninstall; BRadioButton* fUninstall;
BTextView* fUninstallText; BTextView* fUninstallText;
}; };
#endif // ENTRY_PAGE_H #endif // ENTRY_PAGE_H

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2008, Haiku, Inc. All rights reserved. * Copyright 2008-2010, Haiku, Inc. All rights reserved.
* Distributed under the terms of the MIT License. * Distributed under the terms of the MIT License.
* *
* Authors: * Authors:
@ -9,18 +9,16 @@
#include "FileSelectionPage.h" #include "FileSelectionPage.h"
#include <string.h>
#include <Button.h> #include <Button.h>
#include <Catalog.h> #include <Catalog.h>
#include <Locale.h> #include <ControlLook.h>
#include <Path.h> #include <Path.h>
#include <RadioButton.h> #include <RadioButton.h>
#include <TextControl.h> #include <TextControl.h>
#include <TextView.h> #include <TextView.h>
#include <string.h>
#include <String.h>
#undef B_TRANSLATE_CONTEXT #undef B_TRANSLATE_CONTEXT
#define B_TRANSLATE_CONTEXT "FileSelectionPage" #define B_TRANSLATE_CONTEXT "FileSelectionPage"
@ -29,12 +27,13 @@
const uint32 kMsgOpenFilePanel = 'open'; const uint32 kMsgOpenFilePanel = 'open';
FileSelectionPage::FileSelectionPage(BMessage* settings, BRect frame, const char* name, FileSelectionPage::FileSelectionPage(BMessage* settings, BRect frame,
const char* description, file_panel_mode mode) const char* name, const char* description, file_panel_mode mode)
: WizardPageView(settings, frame, name, B_FOLLOW_ALL, :
B_WILL_DRAW | B_FRAME_EVENTS | B_FULL_UPDATE_ON_RESIZE) WizardPageView(settings, frame, name, B_FOLLOW_ALL,
, fMode(mode) B_WILL_DRAW | B_FRAME_EVENTS | B_FULL_UPDATE_ON_RESIZE),
, fFilePanel(NULL) fMode(mode),
fFilePanel(NULL)
{ {
_BuildUI(description); _BuildUI(description);
} }
@ -87,12 +86,12 @@ FileSelectionPage::PageCompleted()
} }
const float kTextDistance = 10;
const float kFileButtonDistance = 10; const float kFileButtonDistance = 10;
void void
FileSelectionPage::_BuildUI(const char* description) FileSelectionPage::_BuildUI(const char* description)
{ {
const float kSpacing = be_control_look->DefaultItemSpacing();
BRect rect(Bounds()); BRect rect(Bounds());
fDescription = CreateDescription(rect, "description", description); fDescription = CreateDescription(rect, "description", description);
@ -110,7 +109,7 @@ FileSelectionPage::_BuildUI(const char* description)
fSelect->ResizeToPreferred(); fSelect->ResizeToPreferred();
float selectLeft = rect.right - fSelect->Bounds().Width(); float selectLeft = rect.right - fSelect->Bounds().Width();
rect.right = selectLeft - kFileButtonDistance; rect.right = selectLeft - kSpacing;
fFile = new BTextControl(rect, "file", fFile = new BTextControl(rect, "file",
B_TRANSLATE_COMMENT("File:", "Text control label"), B_TRANSLATE_COMMENT("File:", "Text control label"),
file.String(), new BMessage()); file.String(), new BMessage());
@ -127,10 +126,11 @@ FileSelectionPage::_BuildUI(const char* description)
void void
FileSelectionPage::_Layout() FileSelectionPage::_Layout()
{ {
const float kSpacing = be_control_look->DefaultItemSpacing();
LayoutDescriptionVertically(fDescription); LayoutDescriptionVertically(fDescription);
float left = fFile->Frame().left; float left = fFile->Frame().left;
float top = fDescription->Frame().bottom + kTextDistance; float top = fDescription->Frame().bottom + kSpacing;
// center "file" text field and "select" button vertically // center "file" text field and "select" button vertically
float selectTop = top; float selectTop = top;
@ -147,7 +147,7 @@ FileSelectionPage::_Layout()
fFile->MoveTo(left, fileTop); fFile->MoveTo(left, fileTop);
float width = fSelect->Frame().left - kFileButtonDistance - left; float width = fSelect->Frame().left - kSpacing - left;
fFile->ResizeTo(width, fileHeight); fFile->ResizeTo(width, fileHeight);
left = fSelect->Frame().left; left = fSelect->Frame().left;
@ -172,11 +172,7 @@ FileSelectionPage::_OpenFilePanel()
BMessenger messenger(this); BMessenger messenger(this);
fFilePanel = new BFilePanel(fMode, &messenger, directory, fFilePanel = new BFilePanel(fMode, &messenger, directory,
B_FILE_NODE, B_FILE_NODE, false, NULL, NULL, true);
false,
NULL,
NULL,
true);
if (fMode == B_SAVE_PANEL && file.Leaf() != NULL) if (fMode == B_SAVE_PANEL && file.Leaf() != NULL)
fFilePanel->SetSaveText(file.Leaf()); fFilePanel->SetSaveText(file.Leaf());
fFilePanel->Show(); fFilePanel->Show();

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2008, Haiku, Inc. All rights reserved. * Copyright 2008-2010, Haiku, Inc. All rights reserved.
* Distributed under the terms of the MIT License. * Distributed under the terms of the MIT License.
* *
* Authors: * Authors:
@ -18,10 +18,12 @@ class BButton;
class BTextControl; class BTextControl;
class BTextView; class BTextView;
class FileSelectionPage : public WizardPageView
{ class FileSelectionPage : public WizardPageView {
public: public:
FileSelectionPage(BMessage* settings, BRect frame, const char* name, const char* description, FileSelectionPage(BMessage* settings,
BRect frame, const char* name,
const char* description,
file_panel_mode mode); file_panel_mode mode);
virtual ~FileSelectionPage(); virtual ~FileSelectionPage();
@ -32,13 +34,13 @@ public:
virtual void PageCompleted(); virtual void PageCompleted();
private: private:
void _BuildUI(const char* description); void _BuildUI(const char* description);
void _Layout(); void _Layout();
void _OpenFilePanel(); void _OpenFilePanel();
void _SetFileFromFilePanelMessage(BMessage* message); void _SetFileFromFilePanelMessage(BMessage* message);
void _FilePanelCanceled(); void _FilePanelCanceled();
private:
file_panel_mode fMode; file_panel_mode fMode;
BFilePanel* fFilePanel; BFilePanel* fFilePanel;
@ -47,4 +49,5 @@ private:
BButton* fSelect; BButton* fSelect;
}; };
#endif // FILE_SELECTION_PAGE_H #endif // FILE_SELECTION_PAGE_H

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2008, Haiku, Inc. All rights reserved. * Copyright 2008-2010, Haiku, Inc. All rights reserved.
* Distributed under the terms of the MIT License. * Distributed under the terms of the MIT License.
* *
* Authors: * Authors:
@ -9,30 +9,18 @@
#include "LegacyBootDrive.h" #include "LegacyBootDrive.h"
#include <new>
#include <stdio.h>
#include <Catalog.h> #include <Catalog.h>
#include <Drivers.h> #include <DataIO.h>
#include <DiskDevice.h> #include <DiskDevice.h>
#include <DiskDeviceRoster.h> #include <DiskDeviceRoster.h>
#include <DiskDeviceVisitor.h> #include <DiskDeviceVisitor.h>
#include <Locale.h> #include <File.h>
#include <Partition.h> #include <Partition.h>
#include <Path.h> #include <Path.h>
#include <String.h> #include <String.h>
#include <errno.h>
#include <fcntl.h>
#include <memory>
#include <new>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <ByteOrder.h>
#include <DataIO.h>
#include <File.h>
#include <String.h>
#include <UTF8.h> #include <UTF8.h>
#include "BootLoader.h" #include "BootLoader.h"
@ -44,10 +32,17 @@
#define GET_FIRST_BIOS_DRIVE 1 #define GET_FIRST_BIOS_DRIVE 1
class Buffer : public BMallocIO struct MasterBootRecord {
{ uint8 bootLoader[440];
uint8 diskSignature[4];
uint8 reserved[2];
uint8 partition[64];
uint8 signature[2];
};
class LittleEndianMallocIO : public BMallocIO {
public: public:
Buffer() : BMallocIO() {}
bool WriteInt8(int8 value); bool WriteInt8(int8 value);
bool WriteInt16(int16 value); bool WriteInt16(int16 value);
bool WriteInt32(int32 value); bool WriteInt32(int32 value);
@ -58,71 +53,10 @@ public:
}; };
bool class PartitionRecorder : public BDiskDeviceVisitor {
Buffer::WriteInt8(int8 value)
{
return Write(&value, sizeof(value)) == sizeof(value);
}
bool
Buffer::WriteInt16(int16 value)
{
return WriteInt8(value & 0xff)
&& WriteInt8(value >> 8);
}
bool
Buffer::WriteInt32(int32 value)
{
return WriteInt8(value & 0xff)
&& WriteInt8(value >> 8)
&& WriteInt8(value >> 16)
&& WriteInt8(value >> 24);
}
bool
Buffer::WriteInt64(int64 value)
{
return WriteInt32(value) && WriteInt32(value >> 32);
}
bool
Buffer::WriteString(const char* value)
{
int len = strlen(value) + 1;
return WriteInt8(len)
&& Write(value, len) == len;
}
bool
Buffer::Align(int16 alignment)
{
if ((Position() % alignment) == 0)
return true;
return Fill(alignment - (Position() % alignment), 0);
}
bool
Buffer::Fill(int16 size, int8 fillByte)
{
for (int i = 0; i < size; i ++) {
if (!WriteInt8(fillByte))
return false;
}
return true;
}
class PartitionRecorder : public BDiskDeviceVisitor
{
public: public:
PartitionRecorder(BMessage* settings, int8 drive); PartitionRecorder(BMessage* settings,
int8 drive);
virtual bool Visit(BDiskDevice* device); virtual bool Visit(BDiskDevice* device);
virtual bool Visit(BPartition* partition, int32 level); virtual bool Visit(BPartition* partition, int32 level);
@ -133,6 +67,7 @@ public:
private: private:
bool _Record(BPartition* partition); bool _Record(BPartition* partition);
private:
BMessage* fSettings; BMessage* fSettings;
int8 fDrive; int8 fDrive;
int32 fIndex; int32 fIndex;
@ -140,11 +75,86 @@ private:
}; };
static const uint32 kBlockSize = 512;
static const uint32 kNumberOfBootLoaderBlocks = 4;
// The number of blocks required to store the
// MBR including the Haiku boot loader.
static const uint32 kMBRSignature = 0xAA55;
static const int32 kMaxBootMenuItemLength = 70;
bool
LittleEndianMallocIO::WriteInt8(int8 value)
{
return Write(&value, sizeof(value)) == sizeof(value);
}
bool
LittleEndianMallocIO::WriteInt16(int16 value)
{
return WriteInt8(value & 0xff)
&& WriteInt8(value >> 8);
}
bool
LittleEndianMallocIO::WriteInt32(int32 value)
{
return WriteInt8(value & 0xff)
&& WriteInt8(value >> 8)
&& WriteInt8(value >> 16)
&& WriteInt8(value >> 24);
}
bool
LittleEndianMallocIO::WriteInt64(int64 value)
{
return WriteInt32(value) && WriteInt32(value >> 32);
}
bool
LittleEndianMallocIO::WriteString(const char* value)
{
int len = strlen(value) + 1;
return WriteInt8(len)
&& Write(value, len) == len;
}
bool
LittleEndianMallocIO::Align(int16 alignment)
{
if ((Position() % alignment) == 0)
return true;
return Fill(alignment - (Position() % alignment), 0);
}
bool
LittleEndianMallocIO::Fill(int16 size, int8 fillByte)
{
for (int i = 0; i < size; i ++) {
if (!WriteInt8(fillByte))
return false;
}
return true;
}
// #pragma mark -
PartitionRecorder::PartitionRecorder(BMessage* settings, int8 drive) PartitionRecorder::PartitionRecorder(BMessage* settings, int8 drive)
: fSettings(settings) :
, fDrive(drive) fSettings(settings),
, fIndex(0) fDrive(drive),
, fFirstOffset(LONGLONG_MAX) fIndex(0),
fFirstOffset(LONGLONG_MAX)
{ {
} }
@ -225,6 +235,9 @@ PartitionRecorder::_Record(BPartition* partition)
} }
// #pragma mark -
LegacyBootDrive::LegacyBootDrive() LegacyBootDrive::LegacyBootDrive()
{ {
} }
@ -323,21 +336,22 @@ LegacyBootDrive::WriteBootMenu(BMessage *settings)
return B_BAD_VALUE; return B_BAD_VALUE;
} }
Buffer newBootLoader; LittleEndianMallocIO newBootLoader;
ssize_t size = sizeof(kBootLoader); ssize_t size = sizeof(kBootLoader);
if (newBootLoader.Write(kBootLoader, size) != size) { if (newBootLoader.Write(kBootLoader, size) != size) {
close(fd); close(fd);
return B_NO_MEMORY; return B_NO_MEMORY;
} }
MasterBootRecord* newMBR = (MasterBootRecord*)newBootLoader.BMallocIO::Buffer(); MasterBootRecord* newMBR = (MasterBootRecord*)newBootLoader.Buffer();
_CopyPartitionTable(newMBR, &oldMBR); _CopyPartitionTable(newMBR, &oldMBR);
int menuEntries = 0; int menuEntries = 0;
int defaultMenuEntry = 0; int defaultMenuEntry = 0;
BMessage partition; BMessage partition;
int32 index; int32 index;
for (index = 0; settings->FindMessage("partition", index, &partition) == B_OK; index ++) { for (index = 0; settings->FindMessage("partition", index,
&partition) == B_OK; index ++) {
bool show; bool show;
partition.FindBool("show", &show); partition.FindBool("show", &show);
if (!show) if (!show)
@ -351,8 +365,8 @@ LegacyBootDrive::WriteBootMenu(BMessage *settings)
newBootLoader.WriteInt16(defaultMenuEntry); newBootLoader.WriteInt16(defaultMenuEntry);
newBootLoader.WriteInt16(timeout); newBootLoader.WriteInt16(timeout);
for (index = 0; settings->FindMessage("partition", index,
for (index = 0; settings->FindMessage("partition", index, &partition) == B_OK; index ++) { &partition) == B_OK; index ++) {
bool show; bool show;
BString name; BString name;
BString path; BString path;
@ -381,7 +395,7 @@ LegacyBootDrive::WriteBootMenu(BMessage *settings)
} }
lseek(fd, 0, SEEK_SET); lseek(fd, 0, SEEK_SET);
const uint8* buffer = (uint8*)newBootLoader.BMallocIO::Buffer(); const uint8* buffer = (const uint8*)newBootLoader.Buffer();
status_t status = _WriteBlocks(fd, buffer, newBootLoader.Position()); status_t status = _WriteBlocks(fd, buffer, newBootLoader.Position());
close(fd); close(fd);
return status; return status;
@ -593,14 +607,14 @@ 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->diskSignature) + sizeof(source->reserved)
sizeof(source->partition)); + sizeof(source->partition));
} }
bool bool
LegacyBootDrive::_IsValid(const MasterBootRecord* mbr) LegacyBootDrive::_IsValid(const MasterBootRecord* mbr)
{ {
return mbr->signature[0] == (kMBRSignature & 0xff) && return mbr->signature[0] == (kMBRSignature & 0xff)
mbr->signature[1] == (kMBRSignature >> 8); && mbr->signature[1] == (kMBRSignature >> 8);
} }

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2008, Haiku, Inc. All rights reserved. * Copyright 2008-2010, Haiku, Inc. All rights reserved.
* Distributed under the terms of the MIT License. * Distributed under the terms of the MIT License.
* *
* Authors: * Authors:
@ -8,48 +8,42 @@
#ifndef LEGACY_BOOT_DRIVE_H #ifndef LEGACY_BOOT_DRIVE_H
#define LEGACY_BOOT_DRIVE_H #define LEGACY_BOOT_DRIVE_H
#include "BootDrive.h" #include "BootDrive.h"
#include <SupportDefs.h> #include <SupportDefs.h>
const uint32 kBlockSize = 512;
// The number of blocks required to store the
// MBR including the Haiku boot loader.
const uint32 kNumberOfBootLoaderBlocks = 4;
const uint32 kMBRSignature = 0xAA55; struct MasterBootRecord;
const int32 kMaxBootMenuItemLength = 70;
typedef struct { class LegacyBootDrive : public BootDrive {
uint8 bootLoader[440];
uint8 diskSignature[4];
uint8 reserved[2];
uint8 partition[64];
uint8 signature[2];
} MasterBootRecord;
class LegacyBootDrive : public BootDrive
{
public: public:
LegacyBootDrive(); LegacyBootDrive();
~LegacyBootDrive(); virtual ~LegacyBootDrive();
bool IsBootMenuInstalled(BMessage* settings); virtual bool IsBootMenuInstalled(BMessage* settings);
status_t ReadPartitions(BMessage* settings); virtual status_t ReadPartitions(BMessage* settings);
status_t WriteBootMenu(BMessage* settings); virtual status_t WriteBootMenu(BMessage* settings);
status_t SaveMasterBootRecord(BMessage* settings, BFile* file); virtual status_t SaveMasterBootRecord(BMessage* settings,
status_t RestoreMasterBootRecord(BMessage* settings, BFile* file); BFile* file);
status_t GetDisplayText(const char* text, BString& displayText); virtual status_t RestoreMasterBootRecord(BMessage* settings,
BFile* file);
virtual status_t GetDisplayText(const char* text,
BString& displayText);
private: private:
bool _ConvertToBIOSText(const char* text, BString& biosText); 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,
void _CopyPartitionTable(MasterBootRecord* destination, size_t size);
void _CopyPartitionTable(
MasterBootRecord* destination,
const MasterBootRecord* source); const MasterBootRecord* source);
bool _IsValid(const MasterBootRecord* mbr); bool _IsValid(const MasterBootRecord* mbr);
}; };
#endif // LEGACY_BOOT_DRIVE_H #endif // LEGACY_BOOT_DRIVE_H

View File

@ -1,8 +1,10 @@
#include <fcntl.h>
#include <stdio.h> #include <stdio.h>
#include <unistd.h> #include <unistd.h>
#include <fcntl.h>
int main(int argc, char* argv[])
int
main(int argc, char* argv[])
{ {
const char* application = argv[0]; const char* application = argv[0];
if (argc != 3) { if (argc != 3) {
@ -14,7 +16,8 @@ int main(int argc, char* argv[])
int fd = open(fileName, 0); int fd = open(fileName, 0);
if (fd < 0) { if (fd < 0) {
fprintf(stderr, "%s: Error opening file '%s'!\n", application, fileName); fprintf(stderr, "%s: Error opening file '%s'!\n", application,
fileName);
return 1; return 1;
} }

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2008, Haiku, Inc. All rights reserved. * Copyright 2008-2010, Haiku, Inc. All rights reserved.
* Distributed under the terms of the MIT License. * Distributed under the terms of the MIT License.
* *
* Authors: * Authors:
@ -10,20 +10,18 @@
#include "PartitionsPage.h" #include "PartitionsPage.h"
#include <stdio.h>
#include <string.h>
#include <Catalog.h> #include <Catalog.h>
#include <CheckBox.h> #include <CheckBox.h>
#include <Locale.h> #include <ControlLook.h>
#include <RadioButton.h> #include <RadioButton.h>
#include <ScrollView.h> #include <ScrollView.h>
#include <StringView.h> #include <StringView.h>
#include <TextControl.h> #include <TextControl.h>
#include <TextView.h> #include <TextView.h>
#include <stdio.h>
#include <string.h>
#include <String.h>
#undef B_TRANSLATE_CONTEXT #undef B_TRANSLATE_CONTEXT
#define B_TRANSLATE_CONTEXT "PartitionsPage" #define B_TRANSLATE_CONTEXT "PartitionsPage"
@ -33,8 +31,10 @@ const uint32 kMessageShow = 'show';
const uint32 kMessageName = 'name'; const uint32 kMessageName = 'name';
PartitionsPage::PartitionsPage(BMessage* settings, BRect frame, const char* name) PartitionsPage::PartitionsPage(BMessage* settings, BRect frame,
: WizardPageView(settings, frame, name, B_FOLLOW_ALL, const char* name)
:
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)
{ {
_BuildUI(); _BuildUI();
@ -91,17 +91,15 @@ PartitionsPage::FrameResized(float width, float height)
} }
static const float kTextDistance = 10;
void void
PartitionsPage::_BuildUI() PartitionsPage::_BuildUI()
{ {
const float kTextDistance = be_control_look->DefaultItemSpacing();
BRect rect(Bounds()); BRect rect(Bounds());
BString text; BString text;
text << text << B_TRANSLATE_COMMENT("Partitions", "Title") << "\n\n"
B_TRANSLATE_COMMENT("Partitions", "Title") << "\n\n" << << B_TRANSLATE("The following partitions were detected. Please "
B_TRANSLATE("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 "
@ -116,13 +114,10 @@ PartitionsPage::_BuildUI()
rect.right -= B_V_SCROLL_BAR_WIDTH; rect.right -= B_V_SCROLL_BAR_WIDTH;
rect.bottom -= B_H_SCROLL_BAR_HEIGHT + 3; rect.bottom -= B_H_SCROLL_BAR_HEIGHT + 3;
fPartitions = new BView(rect, "partitions", B_FOLLOW_ALL, fPartitions = new BView(rect, "partitions", B_FOLLOW_ALL, B_WILL_DRAW);
B_WILL_DRAW);
fPartitionsScrollView = new BScrollView("scrollView", fPartitions, fPartitionsScrollView = new BScrollView("scrollView", fPartitions,
B_FOLLOW_ALL, B_FOLLOW_ALL, 0, true, true);
0,
true, true);
fPartitionsScrollView->SetViewColor(ViewColor()); fPartitionsScrollView->SetViewColor(ViewColor());
AddChild(fPartitionsScrollView); AddChild(fPartitionsScrollView);
@ -137,6 +132,7 @@ PartitionsPage::_Layout()
{ {
LayoutDescriptionVertically(fDescription); LayoutDescriptionVertically(fDescription);
const float kTextDistance = be_control_look->DefaultItemSpacing();
float left = fPartitionsScrollView->Frame().left; float left = fPartitionsScrollView->Frame().left;
float top = fDescription->Frame().bottom + kTextDistance; float top = fDescription->Frame().bottom + kTextDistance;
fPartitionsScrollView->MoveTo(left, top); fPartitionsScrollView->MoveTo(left, top);
@ -173,10 +169,6 @@ PartitionsPage::_Layout()
} }
const rgb_color kOddRowColor = {224, 255, 224};
const rgb_color kEvenRowColor = {224, 224, 255};
void void
PartitionsPage::_FillPartitionsView(BView* view) PartitionsPage::_FillPartitionsView(BView* view)
{ {
@ -215,7 +207,8 @@ PartitionsPage::_FillPartitionsView(BView* view)
frame.right = frame.left + 65000; frame.right = frame.left + 65000;
BMessage message; BMessage message;
for (int32 i = 0; fSettings->FindMessage("partition", i, &message) == B_OK; i ++, rowNumber ++) { for (int32 i = 0; fSettings->FindMessage("partition", i, &message) == B_OK;
i++, rowNumber++) {
// get partition data // get partition data
bool show; bool show;
BString name; BString name;
@ -230,7 +223,6 @@ PartitionsPage::_FillPartitionsView(BView* view)
// create row for partition data // create row for partition data
BView* row = new BView(frame, "row", B_FOLLOW_TOP | B_FOLLOW_LEFT, 0); BView* row = new BView(frame, "row", B_FOLLOW_TOP | B_FOLLOW_LEFT, 0);
row->SetViewColor(((rowNumber % 2) == 0) ? kEvenRowColor : kOddRowColor);
view->AddChild(row); view->AddChild(row);
frame.OffsetBy(0, height + 1); frame.OffsetBy(0, height + 1);
@ -252,8 +244,8 @@ PartitionsPage::_FillPartitionsView(BView* view)
// name // name
rect.right = rect.left + nameWidth; rect.right = rect.left + nameWidth;
BTextControl* nameControl = new BTextControl(rect, "name", "", name.String(), BTextControl* nameControl = new BTextControl(rect, "name", "",
_CreateControlMessage(kMessageName, i)); name.String(), _CreateControlMessage(kMessageName, i));
nameControl->SetDivider(0); nameControl->SetDivider(0);
row->AddChild(nameControl); row->AddChild(nameControl);
rect.OffsetBy(nameWidth + kDistance, 0); rect.OffsetBy(nameWidth + kDistance, 0);
@ -268,7 +260,8 @@ PartitionsPage::_FillPartitionsView(BView* view)
BString sizeText; BString sizeText;
_CreateSizeText(size, &sizeText); _CreateSizeText(size, &sizeText);
rect.right = rect.left + sizeWidth; rect.right = rect.left + sizeWidth;
BStringView* sizeView = new BStringView(rect, "type", sizeText.String()); BStringView* sizeView = new BStringView(rect, "type",
sizeText.String());
sizeView->SetAlignment(B_ALIGN_RIGHT); sizeView->SetAlignment(B_ALIGN_RIGHT);
row->AddChild(sizeView); row->AddChild(sizeView);
rect.OffsetBy(sizeWidth + kDistance, 0); rect.OffsetBy(sizeWidth + kDistance, 0);
@ -279,7 +272,6 @@ PartitionsPage::_FillPartitionsView(BView* view)
row->AddChild(pathView); row->AddChild(pathView);
} }
fPartitionsWidth = totalWidth; fPartitionsWidth = totalWidth;
fPartitionsHeight = frame.top; fPartitionsHeight = frame.top;
} }
@ -298,7 +290,8 @@ PartitionsPage::_ComputeColumnWidths(int32& showWidth, int32& nameWidth,
const int32 kStringViewInsets = 2; const int32 kStringViewInsets = 2;
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++) {
// get partition data // get partition data
BString type; BString type;
BString path; BString path;
@ -309,18 +302,18 @@ PartitionsPage::_ComputeColumnWidths(int32& showWidth, int32& nameWidth,
BString sizeText; BString sizeText;
_CreateSizeText(size, &sizeText); _CreateSizeText(size, &sizeText);
int32 width = (int32)ceil(be_plain_font->StringWidth(type.String())) + int32 width = (int32)ceil(be_plain_font->StringWidth(type.String()))
kStringViewInsets; + kStringViewInsets;
if (typeWidth < width) if (typeWidth < width)
typeWidth = width; typeWidth = width;
width = (int32)ceil(be_plain_font->StringWidth(path.String())) + width = (int32)ceil(be_plain_font->StringWidth(path.String()))
kStringViewInsets; + kStringViewInsets;
if (pathWidth < width) if (pathWidth < width)
pathWidth = width; pathWidth = width;
width = (int32)ceil(be_plain_font->StringWidth(sizeText.String())) + width = (int32)ceil(be_plain_font->StringWidth(sizeText.String()))
kStringViewInsets; + kStringViewInsets;
if (sizeWidth < width) if (sizeWidth < width)
sizeWidth = width; sizeWidth = width;
} }

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2008, Haiku, Inc. All rights reserved. * Copyright 2008-2010, Haiku, Inc. All rights reserved.
* Distributed under the terms of the MIT License. * Distributed under the terms of the MIT License.
* *
* Authors: * Authors:
@ -15,10 +15,11 @@
class BTextView; class BTextView;
class BScrollView; class BScrollView;
class PartitionsPage : public WizardPageView
{ class PartitionsPage : public WizardPageView {
public: public:
PartitionsPage(BMessage* settings, BRect frame, const char* name); PartitionsPage(BMessage* settings, BRect frame,
const char* name);
virtual ~PartitionsPage(); virtual ~PartitionsPage();
virtual void PageCompleted(); virtual void PageCompleted();
@ -26,15 +27,17 @@ public:
virtual void FrameResized(float width, float height); virtual void FrameResized(float width, float height);
private: private:
void _BuildUI(); void _BuildUI();
void _Layout(); void _Layout();
void _FillPartitionsView(BView* view); void _FillPartitionsView(BView* view);
void _CreateSizeText(int64 size, BString* text); void _CreateSizeText(int64 size, BString* text);
BMessage* _CreateControlMessage(uint32 what, int32 partitionIndex); BMessage* _CreateControlMessage(uint32 what,
void _ComputeColumnWidths(int32& showWidth, int32& nameWidth, int32& typeWidth, int32 partitionIndex);
void _ComputeColumnWidths(int32& showWidth,
int32& nameWidth, int32& typeWidth,
int32& sizeWidth, int32& pathWidth); int32& sizeWidth, int32& pathWidth);
private:
BTextView* fDescription; BTextView* fDescription;
BView* fPartitions; BView* fPartitions;
BScrollView* fPartitionsScrollView; BScrollView* fPartitionsScrollView;
@ -42,4 +45,5 @@ private:
float fPartitionsHeight; float fPartitionsHeight;
}; };
#endif // PARTITONS_PAGE_H #endif // PARTITONS_PAGE_H

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2008, Haiku, Inc. All rights reserved. * Copyright 2008-2010, Haiku, Inc. All rights reserved.
* Distributed under the terms of the MIT License. * Distributed under the terms of the MIT License.
* *
* Authors: * Authors:
@ -9,20 +9,6 @@
#include "TestBootDrive.h" #include "TestBootDrive.h"
#include <errno.h>
#include <fcntl.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <ByteOrder.h>
#include <DataIO.h>
#include <File.h>
#include <String.h>
#include "BootLoader.h"
TestBootDrive::TestBootDrive() TestBootDrive::TestBootDrive()
{ {
@ -49,7 +35,7 @@ TestBootDrive::ReadPartitions(BMessage *settings)
BMessage partition; BMessage partition;
partition.AddBool("show", true); partition.AddBool("show", true);
partition.AddString("name", "Haiku"); partition.AddString("name", "TEST Haiku");
partition.AddString("type", "bfs"); partition.AddString("type", "bfs");
partition.AddString("path", "/dev/disk/ide/ata/0/master/0/0_0"); partition.AddString("path", "/dev/disk/ide/ata/0/master/0/0_0");
partition.AddInt64("size", 3 * (int64)1024 * 1024 * 1024); partition.AddInt64("size", 3 * (int64)1024 * 1024 * 1024);
@ -58,7 +44,7 @@ TestBootDrive::ReadPartitions(BMessage *settings)
partition.MakeEmpty(); partition.MakeEmpty();
partition.AddBool("show", true); partition.AddBool("show", true);
partition.AddString("name", "no name"); partition.AddString("name", "TEST no name");
partition.AddString("type", "dos"); partition.AddString("type", "dos");
partition.AddString("path", "/dev/disk/ide/ata/0/slave/0/0_0"); partition.AddString("path", "/dev/disk/ide/ata/0/slave/0/0_0");
partition.AddInt64("size", 10 * (int64)1024 * 1024 * 1024); partition.AddInt64("size", 10 * (int64)1024 * 1024 * 1024);
@ -66,7 +52,7 @@ TestBootDrive::ReadPartitions(BMessage *settings)
partition.MakeEmpty(); partition.MakeEmpty();
partition.AddBool("show", true); partition.AddBool("show", true);
partition.AddString("name", "Data"); partition.AddString("name", "TEST Data");
partition.AddString("type", "unknown"); partition.AddString("type", "unknown");
partition.AddString("path", "/dev/disk/ide/ata/0/slave/0/0_1"); partition.AddString("path", "/dev/disk/ide/ata/0/slave/0/0_1");
partition.AddInt64("size", 250 * (int64)1024 * 1024 * 1024); partition.AddInt64("size", 250 * (int64)1024 * 1024 * 1024);
@ -84,7 +70,8 @@ TestBootDrive::WriteBootMenu(BMessage *settings)
BMessage partition; BMessage partition;
int32 index = 0; int32 index = 0;
for (; settings->FindMessage("partition", index, &partition) == B_OK; index ++) { for (; settings->FindMessage("partition", index, &partition) == B_OK;
index++) {
printf("Partition %d:\n", (int)index); printf("Partition %d:\n", (int)index);
partition.PrintToStream(); partition.PrintToStream();
} }
@ -112,5 +99,3 @@ TestBootDrive::GetDisplayText(const char* text, BString& displayText)
{ {
displayText = text; displayText = text;
} }

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2008, Haiku, Inc. All rights reserved. * Copyright 2008-2010, Haiku, Inc. All rights reserved.
* Distributed under the terms of the MIT License. * Distributed under the terms of the MIT License.
* *
* Authors: * Authors:
@ -8,20 +8,25 @@
#ifndef TEST_BOOT_DRIVE_H #ifndef TEST_BOOT_DRIVE_H
#define TEST_BOOT_DRIVE_H #define TEST_BOOT_DRIVE_H
#include "BootDrive.h" #include "BootDrive.h"
class TestBootDrive : public BootDrive
{ class TestBootDrive : public BootDrive {
public: public:
TestBootDrive(); TestBootDrive();
~TestBootDrive(); virtual ~TestBootDrive();
bool IsBootMenuInstalled(BMessage* settings); virtual bool IsBootMenuInstalled(BMessage* settings);
status_t ReadPartitions(BMessage* settings); virtual status_t ReadPartitions(BMessage* settings);
status_t WriteBootMenu(BMessage* settings); virtual status_t WriteBootMenu(BMessage* settings);
status_t SaveMasterBootRecord(BMessage* settings, BFile* file); virtual status_t SaveMasterBootRecord(BMessage* settings,
status_t RestoreMasterBootRecord(BMessage* settings, BFile* file); BFile* file);
status_t GetDisplayText(const char* text, BString& displayText); virtual status_t RestoreMasterBootRecord(BMessage* settings,
BFile* file);
virtual status_t GetDisplayText(const char* text,
BString& displayText);
}; };
#endif // TEST_BOOT_DRIVE_H #endif // TEST_BOOT_DRIVE_H

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2008, Haiku, Inc. All rights reserved. * Copyright 2008-2010, Haiku, Inc. All rights reserved.
* Distributed under the terms of the MIT License. * Distributed under the terms of the MIT License.
* *
* Authors: * Authors:
@ -9,21 +9,23 @@
#include "UninstallPage.h" #include "UninstallPage.h"
#include <string.h>
#include <Catalog.h> #include <Catalog.h>
#include <Locale.h>
#include <RadioButton.h> #include <RadioButton.h>
#include <TextView.h> #include <TextView.h>
#include <string.h>
#undef B_TRANSLATE_CONTEXT #undef B_TRANSLATE_CONTEXT
#define B_TRANSLATE_CONTEXT "UninstallPage" #define B_TRANSLATE_CONTEXT "UninstallPage"
static const float kTextDistance = 10;
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)
{ {
_BuildUI(); _BuildUI();
@ -43,18 +45,15 @@ UninstallPage::FrameResized(float width, float height)
} }
static const float kTextDistance = 10;
void void
UninstallPage::_BuildUI() UninstallPage::_BuildUI()
{ {
BRect rect(Bounds()); BRect rect(Bounds());
BString text; BString text;
text << text << B_TRANSLATE_COMMENT("Uninstall Boot Manager", "Title") << "\n\n"
B_TRANSLATE_COMMENT("Uninstall Boot Manager", "Title") << "\n\n" << << B_TRANSLATE("Please locate the Master Boot Record (MBR) save file "
B_TRANSLATE("Please locate the Master Boot Record (MBR) save file to " "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); fDescription = CreateDescription(rect, "description", text);
@ -70,4 +69,3 @@ UninstallPage::_Layout()
{ {
LayoutDescriptionVertically(fDescription); LayoutDescriptionVertically(fDescription);
} }

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2008, Haiku, Inc. All rights reserved. * Copyright 2008-2010, Haiku, Inc. All rights reserved.
* Distributed under the terms of the MIT License. * Distributed under the terms of the MIT License.
* *
* Authors: * Authors:
@ -14,20 +14,22 @@
class BTextView; class BTextView;
class UninstallPage : public WizardPageView
{ class UninstallPage : public WizardPageView {
public: public:
UninstallPage(BMessage* settings, BRect frame, const char* name); UninstallPage(BMessage* settings, BRect frame,
const char* name);
virtual ~UninstallPage(); virtual ~UninstallPage();
virtual void FrameResized(float width, float height); virtual void FrameResized(float width, float height);
private: private:
void _BuildUI(); void _BuildUI();
void _Layout(); void _Layout();
private:
BTextView* fDescription; BTextView* fDescription;
}; };
#endif // UNINSTALL_PAGE_H #endif // UNINSTALL_PAGE_H

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2008, Haiku, Inc. All rights reserved. * Copyright 2008-2010, Haiku, Inc. All rights reserved.
* Distributed under the terms of the MIT License. * Distributed under the terms of the MIT License.
* *
* Authors: * Authors:
@ -12,6 +12,7 @@
#include "WizardView.h" #include "WizardView.h"
#include "WizardPageView.h" #include "WizardPageView.h"
void void
WizardController::StateStack::MakeEmpty() WizardController::StateStack::MakeEmpty()
{ {
@ -26,7 +27,8 @@ WizardController::StateStack::MakeEmpty()
WizardController::WizardController() WizardController::WizardController()
: fStack(NULL) :
fStack(NULL)
{ {
} }

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2008, Haiku, Inc. All rights reserved. * Copyright 2008-2010, Haiku, Inc. All rights reserved.
* Distributed under the terms of the MIT License. * Distributed under the terms of the MIT License.
* *
* Authors: * Authors:
@ -11,12 +11,12 @@
#include <SupportDefs.h> #include <SupportDefs.h>
class WizardView; class WizardView;
class WizardPageView; class WizardPageView;
class WizardController class WizardController {
{
public: public:
WizardController(); WizardController();
virtual ~WizardController(); virtual ~WizardController();
@ -25,28 +25,28 @@ public:
virtual void Next(WizardView* wizard); virtual void Next(WizardView* wizard);
virtual void Previous(WizardView* wizard); virtual void Previous(WizardView* wizard);
protected: protected:
virtual int32 InitialState() = 0; virtual int32 InitialState() = 0;
virtual int32 NextState(int32 state) = 0; virtual int32 NextState(int32 state) = 0;
virtual WizardPageView* CreatePage(int32 state, WizardView* wizard) = 0; virtual WizardPageView* CreatePage(int32 state, WizardView* wizard) = 0;
private: private:
class StateStack { class StateStack {
public: public:
StateStack(int32 state, StateStack* next) StateStack(int32 state, StateStack* next)
: fState(state) :
, fNext(next) fState(state),
fNext(next)
{ {
} }
int32 State() { int32 State()
{
return fState; return fState;
} }
StateStack* Next() { StateStack* Next()
{
return fNext; return fNext;
} }
@ -60,6 +60,7 @@ private:
void _PushState(int32 state); void _PushState(int32 state);
void _ShowPage(WizardView* wizard); void _ShowPage(WizardView* wizard);
private:
StateStack* fStack; StateStack* fStack;
}; };

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2008, Haiku, Inc. All rights reserved. * Copyright 2008-2010, Haiku, Inc. All rights reserved.
* Distributed under the terms of the MIT License. * Distributed under the terms of the MIT License.
* *
* Authors: * Authors:
@ -9,17 +9,17 @@
#include "WizardPageView.h" #include "WizardPageView.h"
#include <TextView.h>
#include <math.h> #include <math.h>
#include <string.h> #include <string.h>
#include <TextView.h>
WizardPageView::WizardPageView(BMessage* settings, BRect frame, const char* name,
uint32 resizingMode, uint32 flags) WizardPageView::WizardPageView(BMessage* settings, BRect frame,
: BView(frame, name, resizingMode, flags) const char* name, uint32 resizingMode, uint32 flags)
, fSettings(settings) :
BView(frame, name, resizingMode, flags),
fSettings(settings)
{ {
SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
} }

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2008, Haiku, Inc. All rights reserved. * Copyright 2008-2010, Haiku, Inc. All rights reserved.
* Distributed under the terms of the MIT License. * Distributed under the terms of the MIT License.
* *
* Authors: * Authors:
@ -15,11 +15,12 @@
#include <View.h> #include <View.h>
class WizardPageView : public BView class WizardPageView : public BView {
{
public: public:
WizardPageView(BMessage* settings, BRect frame, const char* name, WizardPageView(BMessage* settings, BRect frame,
uint32 resizingMode = B_FOLLOW_ALL, uint32 flags = B_WILL_DRAW); const char* name,
uint32 resizingMode = B_FOLLOW_ALL,
uint32 flags = B_WILL_DRAW);
virtual ~WizardPageView(); virtual ~WizardPageView();
virtual void PageCompleted(); virtual void PageCompleted();
@ -30,11 +31,12 @@ public:
virtual void MakeHeading(BTextView* view); virtual void MakeHeading(BTextView* view);
virtual void LayoutDescriptionVertically(BTextView* view); virtual void LayoutDescriptionVertically(BTextView* view);
protected:
BMessage* fSettings;
private: private:
void _BuildUI(); void _BuildUI();
protected:
BMessage* fSettings;
}; };
#endif // WIZARD_PAGE_VIEW_H #endif // WIZARD_PAGE_VIEW_H

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2008, Haiku, Inc. All rights reserved. * Copyright 2008-2010, Haiku, Inc. All rights reserved.
* Distributed under the terms of the MIT License. * Distributed under the terms of the MIT License.
* *
* Authors: * Authors:
@ -9,11 +9,10 @@
#include "WizardView.h" #include "WizardView.h"
#include "WizardPageView.h"
#include <Box.h> #include <Box.h>
#include <Catalog.h> #include <Catalog.h>
#include <Locale.h>
#include "WizardPageView.h"
#undef B_TRANSLATE_CONTEXT #undef B_TRANSLATE_CONTEXT
@ -27,11 +26,12 @@ static const float kBorderHeight = 5;
WizardView::WizardView(BRect frame, const char* name, uint32 resizingMode) WizardView::WizardView(BRect frame, const char* name, uint32 resizingMode)
: BView(frame, name, resizingMode, 0) :
, fSeparator(NULL) BView(frame, name, resizingMode, 0),
, fPrevious(NULL) fSeparator(NULL),
, fNext(NULL) fPrevious(NULL),
, fPage(NULL) fNext(NULL),
fPage(NULL)
{ {
_BuildUI(); _BuildUI();
SetPreviousButtonHidden(true); SetPreviousButtonHidden(true);
@ -164,7 +164,9 @@ WizardView::_BuildUI()
float buttonTop = height - 1 - buttonHeight - kBorderHeight; float buttonTop = height - 1 - buttonHeight - kBorderHeight;
fPrevious->MoveTo(kBorderWidth, buttonTop); fPrevious->MoveTo(kBorderWidth, buttonTop);
fSeparator->MoveTo(kBorderWidth, buttonTop - kSeparatorDistance - kSeparatorHeight); fSeparator->MoveTo(kBorderWidth,
buttonTop - kSeparatorDistance - kSeparatorHeight);
fNext->MoveTo(width - fNext->Bounds().Width() - kBorderWidth - 1, buttonTop); fNext->MoveTo(width - fNext->Bounds().Width() - kBorderWidth - 1,
buttonTop);
} }

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2008, Haiku, Inc. All rights reserved. * Copyright 2008-2010, Haiku, Inc. All rights reserved.
* Distributed under the terms of the MIT License. * Distributed under the terms of the MIT License.
* *
* Authors: * Authors:
@ -22,10 +22,10 @@ const uint32 kMessageNext = 'next';
const uint32 kMessagePrevious = 'prev'; const uint32 kMessagePrevious = 'prev';
class WizardView : public BView class WizardView : public BView {
{
public: public:
WizardView(BRect frame, const char* name, uint32 resizingMode); WizardView(BRect frame, const char* name,
uint32 resizingMode);
virtual ~WizardView(); virtual ~WizardView();
virtual BRect PageFrame(); virtual BRect PageFrame();
@ -43,6 +43,7 @@ public:
private: private:
void _BuildUI(); void _BuildUI();
private:
BBox* fSeparator; BBox* fSeparator;
BButton* fPrevious; BButton* fPrevious;
BButton* fNext; BButton* fNext;
@ -50,4 +51,5 @@ private:
WizardPageView* fPage; WizardPageView* fPage;
}; };
#endif // WIZARD_VIEW_H #endif // WIZARD_VIEW_H