code style update

now mount the target partition before copying


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@21113 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Jérôme Duval
2007-05-12 13:37:02 +00:00
parent 140334f858
commit 9f3d8cb64f
14 changed files with 315 additions and 282 deletions
+87 -54
View File
@@ -16,11 +16,15 @@
#include <String.h> #include <String.h>
#include <VolumeRoster.h> #include <VolumeRoster.h>
//#define COPY_TRACE #define COPY_TRACE
#ifdef COPY_TRACE #ifdef COPY_TRACE
#define CALLED() printf("CALLED %s\n",__PRETTY_FUNCTION__) #define CALLED() printf("CALLED %s\n",__PRETTY_FUNCTION__)
#define ERR2(x, y...) fprintf(stderr, "CopyEngine: "x" %s\n", y, strerror(err))
#define ERR(x) fprintf(stderr, "CopyEngine: "x" %s\n", strerror(err))
#else #else
#define CALLED() #define CALLED()
#define ERR(x)
#define ERR2(x, y...)
#endif #endif
const char BOOT_PATH[] = "/boot"; const char BOOT_PATH[] = "/boot";
@@ -29,24 +33,24 @@ extern void SizeAsString(off_t size, char *string);
class SourceVisitor : public BDiskDeviceVisitor class SourceVisitor : public BDiskDeviceVisitor
{ {
public: public:
SourceVisitor(BMenu *menu); SourceVisitor(BMenu *menu);
virtual bool Visit(BDiskDevice *device); virtual bool Visit(BDiskDevice *device);
virtual bool Visit(BPartition *partition, int32 level); virtual bool Visit(BPartition *partition, int32 level);
private: private:
BMenu *fMenu; BMenu *fMenu;
}; };
class TargetVisitor : public BDiskDeviceVisitor class TargetVisitor : public BDiskDeviceVisitor
{ {
public: public:
TargetVisitor(BMenu *menu); TargetVisitor(BMenu *menu);
virtual bool Visit(BDiskDevice *device); virtual bool Visit(BDiskDevice *device);
virtual bool Visit(BPartition *partition, int32 level); virtual bool Visit(BPartition *partition, int32 level);
private: private:
void MakeLabel(BPartition *partition, char *label, char *menuLabel); void MakeLabel(BPartition *partition, char *label, char *menuLabel);
BMenu *fMenu; BMenu *fMenu;
}; };
@@ -67,7 +71,9 @@ CopyEngine::MessageReceived(BMessage*msg)
CALLED(); CALLED();
switch (msg->what) { switch (msg->what) {
case ENGINE_START: case ENGINE_START:
Start(fWindow->GetSourceMenu(), fWindow->GetTargetMenu()); status_t err = Start(fWindow->GetSourceMenu(), fWindow->GetTargetMenu());
if (err != B_OK)
ERR("Start failed");
break; break;
} }
} }
@@ -110,15 +116,16 @@ CopyEngine::LaunchFinishScript(BPath &path)
} }
void status_t
CopyEngine::Start(BMenu *srcMenu, BMenu *targetMenu) CopyEngine::Start(BMenu *srcMenu, BMenu *targetMenu)
{ {
CALLED(); CALLED();
status_t err = B_OK;
PartitionMenuItem *targetItem = (PartitionMenuItem *)targetMenu->FindMarked(); PartitionMenuItem *targetItem = (PartitionMenuItem *)targetMenu->FindMarked();
PartitionMenuItem *srcItem = (PartitionMenuItem *)srcMenu->FindMarked(); PartitionMenuItem *srcItem = (PartitionMenuItem *)srcMenu->FindMarked();
if (!srcItem || !targetItem) { if (!srcItem || !targetItem) {
fprintf(stderr, "bad menu items\n"); ERR("bad menu items\n");
return; return B_BAD_VALUE;
} }
// check if target is initialized // check if target is initialized
@@ -130,49 +137,75 @@ CopyEngine::Start(BMenu *srcMenu, BMenu *targetMenu)
BVolume targetVolume; BVolume targetVolume;
if (fDDRoster.GetPartitionWithID(targetItem->ID(), &device, &partition) == B_OK) { if (fDDRoster.GetPartitionWithID(targetItem->ID(), &device, &partition) == B_OK) {
if (partition->GetVolume(&targetVolume)!=B_OK) if (!partition->IsMounted()) {
return; if ((err = partition->Mount()) < B_OK) {
if (partition->GetMountPoint(&targetDirectory)!=B_OK) SetStatusMessage("The disk can't be mounted. Please choose a different disk.");
return; ERR("BPartition::Mount");
return err;
}
}
if ((err = partition->GetVolume(&targetVolume)) != B_OK) {
ERR("BPartition::GetVolume");
return err;
}
if ((err = partition->GetMountPoint(&targetDirectory)) != B_OK) {
ERR("BPartition::GetMountPoint");
return err;
}
} else if (fDDRoster.GetDeviceWithID(targetItem->ID(), &device) == B_OK) { } else if (fDDRoster.GetDeviceWithID(targetItem->ID(), &device) == B_OK) {
if (device.GetVolume(&targetVolume)!=B_OK) if (!device.IsMounted()) {
return; if ((err = device.Mount()) < B_OK) {
if (device.GetMountPoint(&targetDirectory)!=B_OK) SetStatusMessage("The disk can't be mounted. Please choose a different disk.");
return; ERR("BDiskDevice::Mount");
return err;
}
}
if ((err = device.GetVolume(&targetVolume)) != B_OK) {
ERR("BDiskDevice::GetVolume");
return err;
}
if ((err = device.GetMountPoint(&targetDirectory)) != B_OK) {
ERR("BDiskDevice::GetMountPoint");
return err;
}
} else } else
return; // shouldn't happen return B_ERROR; // shouldn't happen
// check if target has enough space // check if target has enough space
if ((fSpaceRequired > 0 && targetVolume.FreeBytes() < fSpaceRequired) if ((fSpaceRequired > 0 && targetVolume.FreeBytes() < fSpaceRequired)
&& ((new BAlert("", "The destination disk may not have enough space. Try choosing a different disk or \ && ((new BAlert("", "The destination disk may not have enough space. Try choosing a different disk or \
choose to not install optional items.", "Try installing anyway", "Cancel", 0, choose to not install optional items.", "Try installing anyway", "Cancel", 0,
B_WIDTH_AS_USUAL, B_STOP_ALERT))->Go() != 0)) { B_WIDTH_AS_USUAL, B_STOP_ALERT))->Go() != 0)) {
return; return B_OK;
} }
BPath srcDirectory; BPath srcDirectory;
if (fDDRoster.GetPartitionWithID(srcItem->ID(), &device, &partition) == B_OK) { if (fDDRoster.GetPartitionWithID(srcItem->ID(), &device, &partition) == B_OK) {
if (partition->GetMountPoint(&srcDirectory)!=B_OK) if ((err = partition->GetMountPoint(&srcDirectory)) != B_OK) {
return; ERR("BPartition::GetMountPoint");
} else if (fDDRoster.GetDeviceWithID(srcItem->ID(), &device) == B_OK) { return err;
if (device.GetMountPoint(&srcDirectory)!=B_OK) }
return; } else if (fDDRoster.GetDeviceWithID(srcItem->ID(), &device) == B_OK) {
} else if ((err = device.GetMountPoint(&srcDirectory)) != B_OK) {
return; // shouldn't happen ERR("BDiskDevice::GetMountPoint");
return err;
}
} else
return B_ERROR; // shouldn't happen
// check not installing on itself // check not installing on itself
if (strcmp(srcDirectory.Path(), targetDirectory.Path()) == 0) { if (strcmp(srcDirectory.Path(), targetDirectory.Path()) == 0) {
SetStatusMessage("You can't install the contents of a disk onto itself. Please choose a different disk."); SetStatusMessage("You can't install the contents of a disk onto itself. Please choose a different disk.");
return; return B_OK;
} }
// check not installing on boot volume // check not installing on boot volume
if ((strncmp(BOOT_PATH, targetDirectory.Path(), strlen(BOOT_PATH)) == 0) if ((strncmp(BOOT_PATH, targetDirectory.Path(), strlen(BOOT_PATH)) == 0)
&& ((new BAlert("", "Are you sure you want to install onto the current boot disk? \ && ((new BAlert("", "Are you sure you want to install onto the current boot disk? \
The installer will have to reboot your machine if you proceed.", "OK", "Cancel", 0, The installer will have to reboot your machine if you proceed.", "OK", "Cancel", 0,
B_WIDTH_AS_USUAL, B_STOP_ALERT))->Go() != 0)) { B_WIDTH_AS_USUAL, B_STOP_ALERT))->Go() != 0)) {
SetStatusMessage("Installation stopped."); SetStatusMessage("Installation stopped.");
return; return B_OK;
} }
LaunchInitScript(targetDirectory); LaunchInitScript(targetDirectory);
@@ -188,7 +221,7 @@ The installer will have to reboot your machine if you proceed.", "OK", "Cancel",
srcDir.SetTo(srcDirectory.Path()); srcDir.SetTo(srcDirectory.Path());
BDirectory packageDir; BDirectory packageDir;
int32 count = fPackages->CountItems(); int32 count = fPackages->CountItems();
for (int32 i=0; i<count; i++) { for (int32 i = 0; i < count; i++) {
Package *p = static_cast<Package*>(fPackages->ItemAt(i)); Package *p = static_cast<Package*>(fPackages->ItemAt(i));
packageDir.SetTo(&srcDir, p->Folder()); packageDir.SetTo(&srcDir, p->Folder());
CopyFolder(packageDir, targetDir); CopyFolder(packageDir, targetDir);
@@ -206,7 +239,7 @@ void
CopyEngine::CopyFolder(BDirectory &srcDir, BDirectory &targetDir) CopyEngine::CopyFolder(BDirectory &srcDir, BDirectory &targetDir)
{ {
BEntry entry; BEntry entry;
status_t status; status_t err;
while (srcDir.GetNextEntry(&entry) == B_OK) { while (srcDir.GetNextEntry(&entry) == B_OK) {
char name[B_FILE_NAME_LENGTH]; char name[B_FILE_NAME_LENGTH];
entry.GetName(name); entry.GetName(name);
@@ -214,11 +247,11 @@ CopyEngine::CopyFolder(BDirectory &srcDir, BDirectory &targetDir)
continue; continue;
Undo undo; Undo undo;
status = FSCopyFolder(&entry, &targetDir, fControl, NULL, false, undo); err = FSCopyFolder(&entry, &targetDir, fControl, NULL, false, undo);
if (status != B_OK) { if (err != B_OK) {
BPath path; BPath path;
entry.GetPath(&path); entry.GetPath(&path);
fprintf(stderr, "error while copying %s : %s\n", path.Path(), strerror(status)); ERR2("error while copying %s", path.Path());
} }
} }
} }
@@ -257,17 +290,17 @@ SourceVisitor::SourceVisitor(BMenu *menu)
bool bool
SourceVisitor::Visit(BDiskDevice *device) SourceVisitor::Visit(BDiskDevice *device)
{ {
if (!device->ContentType() || strcmp(device->ContentType(), kPartitionTypeBFS)!=0) if (!device->ContentType() || strcmp(device->ContentType(), kPartitionTypeBFS) != 0)
return false; return false;
BPath path; BPath path;
if (device->GetPath(&path)==B_OK) if (device->GetPath(&path) == B_OK)
printf("SourceVisitor::Visit(BDiskDevice *) : %s type:%s, contentType:%s\n", printf("SourceVisitor::Visit(BDiskDevice *) : %s type:%s, contentType:%s\n",
path.Path(), device->Type(), device->ContentType()); path.Path(), device->Type(), device->ContentType());
PartitionMenuItem *item = new PartitionMenuItem(NULL, device->ContentName(), NULL, new BMessage(SRC_PARTITION), device->ID()); PartitionMenuItem *item = new PartitionMenuItem(NULL, device->ContentName(), NULL, new BMessage(SRC_PARTITION), device->ID());
if (device->IsMounted()) { if (device->IsMounted()) {
BPath mountPoint; BPath mountPoint;
device->GetMountPoint(&mountPoint); device->GetMountPoint(&mountPoint);
if (strcmp(BOOT_PATH, mountPoint.Path())==0) if (strcmp(BOOT_PATH, mountPoint.Path()) == 0)
item->SetMarked(true); item->SetMarked(true);
} }
fMenu->AddItem(item); fMenu->AddItem(item);
@@ -278,17 +311,17 @@ SourceVisitor::Visit(BDiskDevice *device)
bool bool
SourceVisitor::Visit(BPartition *partition, int32 level) SourceVisitor::Visit(BPartition *partition, int32 level)
{ {
if (!partition->ContentType() || strcmp(partition->ContentType(), kPartitionTypeBFS)!=0) if (!partition->ContentType() || strcmp(partition->ContentType(), kPartitionTypeBFS) != 0)
return false; return false;
BPath path; BPath path;
if (partition->GetPath(&path)==B_OK) if (partition->GetPath(&path) == B_OK)
printf("SourceVisitor::Visit(BPartition *) : %s\n", path.Path()); printf("SourceVisitor::Visit(BPartition *) : %s\n", path.Path());
printf("SourceVisitor::Visit(BPartition *) : %s\n", partition->Name()); printf("SourceVisitor::Visit(BPartition *) : %s\n", partition->Name());
PartitionMenuItem *item = new PartitionMenuItem(NULL, partition->ContentName(), NULL, new BMessage(SRC_PARTITION), partition->ID()); PartitionMenuItem *item = new PartitionMenuItem(NULL, partition->ContentName(), NULL, new BMessage(SRC_PARTITION), partition->ID());
if (partition->IsMounted()) { if (partition->IsMounted()) {
BPath mountPoint; BPath mountPoint;
partition->GetMountPoint(&mountPoint); partition->GetMountPoint(&mountPoint);
if (strcmp(BOOT_PATH, mountPoint.Path())==0) if (strcmp(BOOT_PATH, mountPoint.Path()) == 0)
item->SetMarked(true); item->SetMarked(true);
} }
fMenu->AddItem(item); fMenu->AddItem(item);
@@ -308,7 +341,7 @@ TargetVisitor::Visit(BDiskDevice *device)
if (device->IsReadOnly() || device->IsReadOnlyMedia()) if (device->IsReadOnly() || device->IsReadOnlyMedia())
return false; return false;
BPath path; BPath path;
if (device->GetPath(&path)==B_OK) if (device->GetPath(&path) == B_OK)
printf("TargetVisitor::Visit(BDiskDevice *) : %s\n", path.Path()); printf("TargetVisitor::Visit(BDiskDevice *) : %s\n", path.Path());
char label[255], menuLabel[255]; char label[255], menuLabel[255];
MakeLabel(device, label, menuLabel); MakeLabel(device, label, menuLabel);
@@ -323,7 +356,7 @@ TargetVisitor::Visit(BPartition *partition, int32 level)
if (partition->IsReadOnly()) if (partition->IsReadOnly())
return false; return false;
BPath path; BPath path;
if (partition->GetPath(&path)==B_OK) if (partition->GetPath(&path) == B_OK)
printf("TargetVisitor::Visit(BPartition *) : %s\n", path.Path()); printf("TargetVisitor::Visit(BPartition *) : %s\n", path.Path());
printf("TargetVisitor::Visit(BPartition *) : %s\n", partition->Name()); printf("TargetVisitor::Visit(BPartition *) : %s\n", partition->Name());
char label[255], menuLabel[255]; char label[255], menuLabel[255];
@@ -343,7 +376,7 @@ TargetVisitor::MakeLabel(BPartition *partition, char *label, char *menuLabel)
partition->Parent()->GetPath(&path); partition->Parent()->GetPath(&path);
sprintf(label, "%s - %s [%s] [%s partition:%li]", partition->ContentName(), size, partition->ContentType(), sprintf(label, "%s - %s [%s] [%s partition:%li]", partition->ContentName(), size, partition->ContentType(),
path.Path(), partition->ID()); path.Path(), partition->ID());
sprintf(menuLabel, "%s - %s [%s]", partition->ContentName(), size, partition->ContentType()); sprintf(menuLabel, "%s - %s [%s]", partition->ContentName(), size, partition->ContentType());
} }
+17 -17
View File
@@ -20,24 +20,24 @@ class InstallerWindow;
const uint32 ENGINE_START = 'eSRT'; const uint32 ENGINE_START = 'eSRT';
class CopyEngine : public BLooper { class CopyEngine : public BLooper {
public: public:
CopyEngine(InstallerWindow *window); CopyEngine(InstallerWindow *window);
void MessageReceived(BMessage *msg); void MessageReceived(BMessage *msg);
void SetStatusMessage(char *status); void SetStatusMessage(char *status);
void Start(BMenu *srcMenu, BMenu *targetMenu); status_t Start(BMenu *srcMenu, BMenu *targetMenu);
void ScanDisksPartitions(BMenu *srcMenu, BMenu *targetMenu); void ScanDisksPartitions(BMenu *srcMenu, BMenu *targetMenu);
void SetPackagesList(BList *list); void SetPackagesList(BList *list);
void SetSpaceRequired(off_t bytes) { fSpaceRequired = bytes; }; void SetSpaceRequired(off_t bytes) { fSpaceRequired = bytes; };
private: private:
void LaunchInitScript(BPath &path); void LaunchInitScript(BPath &path);
void LaunchFinishScript(BPath &path); void LaunchFinishScript(BPath &path);
void CopyFolder(BDirectory &srcDir, BDirectory &targetDir); void CopyFolder(BDirectory &srcDir, BDirectory &targetDir);
InstallerWindow *fWindow; InstallerWindow *fWindow;
BDiskDeviceRoster fDDRoster; BDiskDeviceRoster fDDRoster;
InstallerCopyLoopControl *fControl; InstallerCopyLoopControl *fControl;
BList *fPackages; BList *fPackages;
off_t fSpaceRequired; off_t fSpaceRequired;
}; };
#endif /* _CopyEngine_h */ #endif /* _CopyEngine_h */
+2 -2
View File
@@ -9,7 +9,7 @@
#include "DrawButton.h" #include "DrawButton.h"
DrawButton::DrawButton(BRect frame, const char *name, const char *labelOn, const char* labelOff, DrawButton::DrawButton(BRect frame, const char *name, const char *labelOn, const char* labelOff,
BMessage *msg, int32 resize, int32 flags) BMessage *msg, int32 resize, int32 flags)
: PaneSwitch(frame, name, "", resize, flags) : PaneSwitch(frame, name, "", resize, flags)
{ {
fLabelOn = strdup(labelOn); fLabelOn = strdup(labelOn);
@@ -28,7 +28,7 @@ DrawButton::~DrawButton(void)
void void
DrawButton::Draw(BRect update) DrawButton::Draw(BRect update)
{ {
BPoint point(18,9); BPoint point(18, 9);
if (Value()) { if (Value()) {
DrawString(fLabelOn, point); DrawString(fLabelOn, point);
} else { } else {
+8 -8
View File
@@ -12,15 +12,15 @@
class DrawButton : public PaneSwitch class DrawButton : public PaneSwitch
{ {
public: public:
DrawButton(BRect frame, const char *name, const char *labelOn, const char* labelOff, DrawButton(BRect frame, const char *name, const char *labelOn, const char* labelOff,
BMessage *msg, int32 resize = B_FOLLOW_LEFT|B_FOLLOW_TOP, BMessage *msg, int32 resize = B_FOLLOW_LEFT | B_FOLLOW_TOP,
int32 flags = B_WILL_DRAW | B_NAVIGABLE); int32 flags = B_WILL_DRAW | B_NAVIGABLE);
~DrawButton(void); ~DrawButton(void);
void Draw(BRect update); void Draw(BRect update);
private: private:
char* fLabelOn, *fLabelOff; char *fLabelOn, *fLabelOff;
}; };
#endif #endif
+11 -11
View File
@@ -28,30 +28,30 @@ int main(int, char **)
InstallerApp::InstallerApp() InstallerApp::InstallerApp()
: BApplication(APP_SIG) : BApplication(APP_SIG)
{ {
BRect windowFrame(0,0,INSTALLER_RIGHT, 160); BRect windowFrame(0, 0, INSTALLER_RIGHT, 160);
BRect frame = BScreen().Frame(); BRect frame = BScreen().Frame();
windowFrame.OffsetBy((frame.Width() - windowFrame.Width())/2, windowFrame.OffsetBy((frame.Width() - windowFrame.Width()) / 2,
frame.Height()/2 - windowFrame.Height()/4 - 113); frame.Height() / 2 - windowFrame.Height() / 4 - 113);
fWindow = new InstallerWindow(windowFrame); fWindow = new InstallerWindow(windowFrame);
// show the EULA // show the EULA
BAlert *alert = new BAlert("", EULA_TEXT, " Disagree ", " Agree ", NULL, BAlert *alert = new BAlert("", EULA_TEXT, " Disagree ", " Agree ", NULL,
B_WIDTH_FROM_WIDEST, B_EMPTY_ALERT); B_WIDTH_FROM_WIDEST, B_EMPTY_ALERT);
BTextView *alertView = alert->TextView(); BTextView *alertView = alert->TextView();
alertView->SetViewColor(255,255,255); alertView->SetViewColor(255, 255, 255);
BView *parent = alertView->Parent(); BView *parent = alertView->Parent();
alertView->RemoveSelf(); alertView->RemoveSelf();
alertView->MoveBy(3,7); alertView->MoveBy(3, 7);
alertView->ResizeTo(460,283); alertView->ResizeTo(460, 283);
alertView->SetResizingMode(B_FOLLOW_ALL_SIDES); alertView->SetResizingMode(B_FOLLOW_ALL_SIDES);
alert->ResizeTo(500,350); alert->ResizeTo(500, 350);
BScrollView *scroll = new BScrollView("", alertView, B_FOLLOW_ALL_SIDES, B_FRAME_EVENTS, false, true, B_FANCY_BORDER); BScrollView *scroll = new BScrollView("", alertView, B_FOLLOW_ALL_SIDES, B_FRAME_EVENTS, false, true, B_FANCY_BORDER);
parent->AddChild(scroll); parent->AddChild(scroll);
BRect alertFrame = alert->Frame(); BRect alertFrame = alert->Frame();
alertFrame.OffsetTo((frame.Width() - alertFrame.Width())/2, alertFrame.OffsetTo((frame.Width() - alertFrame.Width()) / 2,
(frame.Height() - alertFrame.Height())/2); (frame.Height() - alertFrame.Height()) / 2);
alert->MoveTo(alertFrame.LeftTop()); alert->MoveTo(alertFrame.LeftTop());
if (alert->Go()!=1) if (alert->Go() != 1)
PostMessage(B_QUIT_REQUESTED); PostMessage(B_QUIT_REQUESTED);
} }
+7 -7
View File
@@ -10,15 +10,15 @@
#include "InstallerWindow.h" #include "InstallerWindow.h"
class InstallerApp : public BApplication { class InstallerApp : public BApplication {
public: public:
InstallerApp(); InstallerApp();
public: public:
virtual void AboutRequested(); virtual void AboutRequested();
virtual void ReadyToRun(); virtual void ReadyToRun();
private: private:
InstallerWindow *fWindow; InstallerWindow *fWindow;
}; };
#endif /* _InstallerApp_h */ #endif /* _InstallerApp_h */
@@ -16,7 +16,7 @@ InstallerCopyLoopControl::InstallerCopyLoopControl(InstallerWindow *window)
bool bool
InstallerCopyLoopControl::FileError(const char *message, const char *name, status_t error, InstallerCopyLoopControl::FileError(const char *message, const char *name, status_t error,
bool allowContinue) bool allowContinue)
{ {
char buffer[512]; char buffer[512];
sprintf(buffer, message, name, strerror(error)); sprintf(buffer, message, name, strerror(error));
@@ -33,7 +33,7 @@ InstallerCopyLoopControl::FileError(const char *message, const char *name, statu
void void
InstallerCopyLoopControl::UpdateStatus(const char *name, entry_ref ref, int32 count, InstallerCopyLoopControl::UpdateStatus(const char *name, entry_ref ref, int32 count,
bool optional) bool optional)
{ {
if (name) { if (name) {
BMessage msg(STATUS_MESSAGE); BMessage msg(STATUS_MESSAGE);
@@ -54,8 +54,8 @@ InstallerCopyLoopControl::CheckUserCanceled()
InstallerCopyLoopControl::OverwriteMode InstallerCopyLoopControl::OverwriteMode
InstallerCopyLoopControl::OverwriteOnConflict(const BEntry *srcEntry, InstallerCopyLoopControl::OverwriteOnConflict(const BEntry *srcEntry,
const char *destName, const BDirectory *destDir, bool srcIsDir, const char *destName, const BDirectory *destDir, bool srcIsDir,
bool dstIsDir) bool dstIsDir)
{ {
if (srcIsDir && dstIsDir) if (srcIsDir && dstIsDir)
return kMerge; return kMerge;
@@ -13,7 +13,7 @@ class InstallerWindow;
class InstallerCopyLoopControl : public CopyLoopControl class InstallerCopyLoopControl : public CopyLoopControl
{ {
public: public:
InstallerCopyLoopControl(InstallerWindow *window); InstallerCopyLoopControl(InstallerWindow *window);
virtual ~InstallerCopyLoopControl() {}; virtual ~InstallerCopyLoopControl() {};
@@ -36,9 +36,9 @@ public:
virtual bool SkipAttribute(const char *attributeName); virtual bool SkipAttribute(const char *attributeName);
virtual bool PreserveAttribute(const char *attributeName); virtual bool PreserveAttribute(const char *attributeName);
private: private:
InstallerWindow *fWindow; InstallerWindow *fWindow;
BMessenger fMessenger; BMessenger fMessenger;
}; };
#endif #endif
+28 -28
View File
@@ -28,8 +28,8 @@ const uint32 PACKAGE_CHECKBOX = 'iPCB';
class LogoView : public BBox { class LogoView : public BBox {
public: public:
LogoView(const BRect &r); LogoView(const BRect &r);
~LogoView(void); ~LogoView(void);
virtual void Draw(BRect update); virtual void Draw(BRect update);
private: private:
BBitmap *fLogo; BBitmap *fLogo;
@@ -38,7 +38,7 @@ class LogoView : public BBox {
LogoView::LogoView(const BRect &r) LogoView::LogoView(const BRect &r)
: BBox(r, "logoview", B_FOLLOW_LEFT|B_FOLLOW_TOP, B_WILL_DRAW, B_NO_BORDER) : BBox(r, "logoview", B_FOLLOW_LEFT | B_FOLLOW_TOP, B_WILL_DRAW, B_NO_BORDER)
{ {
fLogo = BTranslationUtils::GetBitmap('PNG ', "haikulogo.png"); fLogo = BTranslationUtils::GetBitmap('PNG ', "haikulogo.png");
if (fLogo) { if (fLogo) {
@@ -84,53 +84,53 @@ InstallerWindow::InstallerWindow(BRect frame_rect)
LogoView *logoView = new LogoView(logoRect); LogoView *logoView = new LogoView(logoRect);
fBackBox->AddChild(logoView); fBackBox->AddChild(logoView);
BRect statusRect(bounds.right-222, logoRect.top+2, bounds.right-14, logoRect.bottom - B_H_SCROLL_BAR_HEIGHT+4); BRect statusRect(bounds.right - 222, logoRect.top + 2, bounds.right - 14, logoRect.bottom - B_H_SCROLL_BAR_HEIGHT + 4);
BRect textRect(statusRect); BRect textRect(statusRect);
textRect.OffsetTo(B_ORIGIN); textRect.OffsetTo(B_ORIGIN);
textRect.InsetBy(2,2); textRect.InsetBy(2, 2);
fStatusView = new BTextView(statusRect, "statusView", textRect, fStatusView = new BTextView(statusRect, "statusView", textRect,
be_plain_font, NULL, B_FOLLOW_LEFT | B_FOLLOW_TOP, B_WILL_DRAW); be_plain_font, NULL, B_FOLLOW_LEFT | B_FOLLOW_TOP, B_WILL_DRAW);
fStatusView->MakeEditable(false); fStatusView->MakeEditable(false);
fStatusView->MakeSelectable(false); fStatusView->MakeSelectable(false);
BScrollView *scroll = new BScrollView("statusScroll", fStatusView, B_FOLLOW_LEFT|B_FOLLOW_TOP, B_WILL_DRAW|B_FRAME_EVENTS); BScrollView *scroll = new BScrollView("statusScroll", fStatusView, B_FOLLOW_LEFT | B_FOLLOW_TOP, B_WILL_DRAW | B_FRAME_EVENTS);
fBackBox->AddChild(scroll); fBackBox->AddChild(scroll);
fBeginButton = new BButton(BRect(bounds.right-90, bounds.bottom-35, bounds.right-11, bounds.bottom-11), fBeginButton = new BButton(BRect(bounds.right - 90, bounds.bottom - 35, bounds.right - 11, bounds.bottom - 11),
"begin_button", "Begin", new BMessage(BEGIN_MESSAGE), B_FOLLOW_RIGHT | B_FOLLOW_BOTTOM); "begin_button", "Begin", new BMessage(BEGIN_MESSAGE), B_FOLLOW_RIGHT | B_FOLLOW_BOTTOM);
fBeginButton->MakeDefault(true); fBeginButton->MakeDefault(true);
fBackBox->AddChild(fBeginButton); fBackBox->AddChild(fBeginButton);
fSetupButton = new BButton(BRect(bounds.left+11, bounds.bottom-35, fSetupButton = new BButton(BRect(bounds.left + 11, bounds.bottom - 35,
bounds.left + be_plain_font->StringWidth("Setup partitions") + 36, bounds.bottom-22), bounds.left + be_plain_font->StringWidth("Setup partitions") + 36, bounds.bottom - 22),
"setup_button", "Setup partitions" B_UTF8_ELLIPSIS, new BMessage(SETUP_MESSAGE), B_FOLLOW_LEFT|B_FOLLOW_BOTTOM); "setup_button", "Setup partitions" B_UTF8_ELLIPSIS, new BMessage(SETUP_MESSAGE), B_FOLLOW_LEFT | B_FOLLOW_BOTTOM);
fBackBox->AddChild(fSetupButton); fBackBox->AddChild(fSetupButton);
fSetupButton->Hide(); fSetupButton->Hide();
fPackagesView = new PackagesView(BRect(bounds.left+12, bounds.top+4, bounds.right-15-B_V_SCROLL_BAR_WIDTH, bounds.bottom-61), "packages_view"); fPackagesView = new PackagesView(BRect(bounds.left + 12, bounds.top + 4, bounds.right - 15 - B_V_SCROLL_BAR_WIDTH, bounds.bottom - 61), "packages_view");
fPackagesScrollView = new BScrollView("packagesScroll", fPackagesView, B_FOLLOW_LEFT | B_FOLLOW_BOTTOM, B_WILL_DRAW, fPackagesScrollView = new BScrollView("packagesScroll", fPackagesView, B_FOLLOW_LEFT | B_FOLLOW_BOTTOM, B_WILL_DRAW,
false, true); false, true);
fBackBox->AddChild(fPackagesScrollView); fBackBox->AddChild(fPackagesScrollView);
fPackagesScrollView->Hide(); fPackagesScrollView->Hide();
fDrawButton = new DrawButton(BRect(bounds.left+12, bounds.bottom-33, bounds.left+120, bounds.bottom-20), fDrawButton = new DrawButton(BRect(bounds.left + 12, bounds.bottom - 33, bounds.left + 120, bounds.bottom - 20),
"options_button", "Fewer options", "More options", new BMessage(SHOW_BOTTOM_MESSAGE)); "options_button", "Fewer options", "More options", new BMessage(SHOW_BOTTOM_MESSAGE));
fBackBox->AddChild(fDrawButton); fBackBox->AddChild(fDrawButton);
fDestMenu = new BPopUpMenu("scanning" B_UTF8_ELLIPSIS, true, false); fDestMenu = new BPopUpMenu("scanning" B_UTF8_ELLIPSIS, true, false);
fSrcMenu = new BPopUpMenu("scanning" B_UTF8_ELLIPSIS, true, false); fSrcMenu = new BPopUpMenu("scanning" B_UTF8_ELLIPSIS, true, false);
BRect fieldRect(bounds.left+50, bounds.top+70, bounds.right-13, bounds.top+90); BRect fieldRect(bounds.left + 50, bounds.top + 70, bounds.right - 13, bounds.top + 90);
fSrcMenuField = new BMenuField(fieldRect, "srcMenuField", fSrcMenuField = new BMenuField(fieldRect, "srcMenuField",
"Install from: ", fSrcMenu); "Install from: ", fSrcMenu);
fSrcMenuField->SetDivider(bounds.right-274); fSrcMenuField->SetDivider(bounds.right - 274);
fSrcMenuField->SetAlignment(B_ALIGN_RIGHT); fSrcMenuField->SetAlignment(B_ALIGN_RIGHT);
fBackBox->AddChild(fSrcMenuField); fBackBox->AddChild(fSrcMenuField);
fieldRect.OffsetBy(0,23); fieldRect.OffsetBy(0, 23);
fDestMenuField = new BMenuField(fieldRect, "destMenuField", fDestMenuField = new BMenuField(fieldRect, "destMenuField",
"Onto: ", fDestMenu); "Onto: ", fDestMenu);
fDestMenuField->SetDivider(bounds.right-274); fDestMenuField->SetDivider(bounds.right - 274);
fDestMenuField->SetAlignment(B_ALIGN_RIGHT); fDestMenuField->SetAlignment(B_ALIGN_RIGHT);
fBackBox->AddChild(fDestMenuField); fBackBox->AddChild(fDestMenuField);
@@ -219,17 +219,17 @@ InstallerWindow::MessageReceived(BMessage *msg)
case B_SOME_APP_QUIT: case B_SOME_APP_QUIT:
{ {
const char *signature; const char *signature;
if (msg->FindString("be:signature", &signature)==B_OK if (msg->FindString("be:signature", &signature) == B_OK
&& strcasecmp(signature, DRIVESETUP_SIG)==0) { && strcasecmp(signature, DRIVESETUP_SIG) == 0) {
fDriveSetupLaunched = msg->what == B_SOME_APP_LAUNCHED; fDriveSetupLaunched = msg->what == B_SOME_APP_LAUNCHED;
DisableInterface(fDriveSetupLaunched); DisableInterface(fDriveSetupLaunched);
if (fDriveSetupLaunched) if (fDriveSetupLaunched)
SetStatusMessage("Running DriveSetup" B_UTF8_ELLIPSIS "\nClose DriveSetup to continue with the\ninstallation."); SetStatusMessage("Running DriveSetup" B_UTF8_ELLIPSIS "\nClose DriveSetup to continue with the\ninstallation.");
else else
StartScan(); StartScan();
} }
break; break;
} }
default: default:
BWindow::MessageReceived(msg); BWindow::MessageReceived(msg);
break; break;
@@ -276,7 +276,7 @@ InstallerWindow::ShowBottom()
void void
InstallerWindow::LaunchDriveSetup() InstallerWindow::LaunchDriveSetup()
{ {
if (be_roster->Launch(DRIVESETUP_SIG)!=B_OK) if (be_roster->Launch(DRIVESETUP_SIG) != B_OK)
fprintf(stderr, "There was an error while launching DriveSetup\n"); fprintf(stderr, "There was an error while launching DriveSetup\n");
} }
@@ -355,10 +355,10 @@ InstallerWindow::PublishPackages()
BDiskDevice device; BDiskDevice device;
BPartition *partition; BPartition *partition;
if (roster.GetPartitionWithID(item->ID(), &device, &partition) == B_OK) { if (roster.GetPartitionWithID(item->ID(), &device, &partition) == B_OK) {
if (partition->GetMountPoint(&directory)!=B_OK) if (partition->GetMountPoint(&directory) != B_OK)
return; return;
} else if (roster.GetDeviceWithID(item->ID(), &device) == B_OK) { } else if (roster.GetDeviceWithID(item->ID(), &device) == B_OK) {
if (device.GetMountPoint(&directory)!=B_OK) if (device.GetMountPoint(&directory) != B_OK)
return; return;
} else } else
return; // shouldn't happen return; // shouldn't happen
@@ -368,12 +368,12 @@ InstallerWindow::PublishPackages()
directory.Append(PACKAGES_DIRECTORY); directory.Append(PACKAGES_DIRECTORY);
BDirectory dir(directory.Path()); BDirectory dir(directory.Path());
if (dir.InitCheck()!=B_OK) if (dir.InitCheck() != B_OK)
return; return;
BEntry packageEntry; BEntry packageEntry;
BList packages; BList packages;
while (dir.GetNextEntry(&packageEntry)==B_OK) { while (dir.GetNextEntry(&packageEntry) == B_OK) {
Package *package = Package::PackageFromEntry(packageEntry); Package *package = Package::PackageFromEntry(packageEntry);
if (package) { if (package) {
packages.AddItem(package); packages.AddItem(package);
+31 -31
View File
@@ -25,39 +25,39 @@ const uint32 INSTALL_FINISHED = 'iIFN';
const char PACKAGES_DIRECTORY[] = "_packages_"; const char PACKAGES_DIRECTORY[] = "_packages_";
class InstallerWindow : public BWindow { class InstallerWindow : public BWindow {
public: public:
InstallerWindow(BRect frameRect); InstallerWindow(BRect frameRect);
virtual ~InstallerWindow(); virtual ~InstallerWindow();
virtual void MessageReceived(BMessage *msg); virtual void MessageReceived(BMessage *msg);
virtual bool QuitRequested(); virtual bool QuitRequested();
BMenu *GetSourceMenu() { return fSrcMenu; }; BMenu *GetSourceMenu() { return fSrcMenu; };
BMenu *GetTargetMenu() { return fDestMenu; }; BMenu *GetTargetMenu() { return fDestMenu; };
private: private:
void DisableInterface(bool disable); void DisableInterface(bool disable);
void LaunchDriveSetup(); void LaunchDriveSetup();
void PublishPackages(); void PublishPackages();
void ShowBottom(); void ShowBottom();
void StartScan(); void StartScan();
void AdjustMenus(); void AdjustMenus();
void SetStatusMessage(const char *text); void SetStatusMessage(const char *text);
static int ComparePackages(const void *firstArg, const void *secondArg); static int ComparePackages(const void *firstArg, const void *secondArg);
BBox *fBackBox; BBox *fBackBox;
BButton *fBeginButton, *fSetupButton; BButton *fBeginButton, *fSetupButton;
DrawButton *fDrawButton; DrawButton *fDrawButton;
bool fDriveSetupLaunched; bool fDriveSetupLaunched;
BTextView *fStatusView; BTextView *fStatusView;
BMenu* fSrcMenu, *fDestMenu; BMenu* fSrcMenu, *fDestMenu;
BMenuField* fSrcMenuField, *fDestMenuField; BMenuField* fSrcMenuField, *fDestMenuField;
PackagesView *fPackagesView; PackagesView *fPackagesView;
BScrollView *fPackagesScrollView; BScrollView *fPackagesScrollView;
BStringView *fSizeView; BStringView *fSizeView;
BBitmap *fLogo; BBitmap *fLogo;
BPoint fDrawPoint; BPoint fDrawPoint;
CopyEngine *fCopyEngine; CopyEngine *fCopyEngine;
BString fLastStatus; BString fLastStatus;
BMenuItem *fLastSrcItem, *fLastTargetItem; BMenuItem *fLastSrcItem, *fLastTargetItem;
}; };
#endif /* _InstallerWindow_h */ #endif /* _InstallerWindow_h */
+15 -15
View File
@@ -66,7 +66,7 @@ Package::PackageFromEntry(BEntry &entry)
char folder[B_FILE_NAME_LENGTH]; char folder[B_FILE_NAME_LENGTH];
entry.GetName(folder); entry.GetName(folder);
BDirectory directory(&entry); BDirectory directory(&entry);
if (directory.InitCheck()!=B_OK) if (directory.InitCheck() != B_OK)
return NULL; return NULL;
Package *package = new Package(folder); Package *package = new Package(folder);
bool alwaysOn; bool alwaysOn;
@@ -74,17 +74,17 @@ Package::PackageFromEntry(BEntry &entry)
int32 size; int32 size;
char group[64]; char group[64];
memset(group, 0, 64); memset(group, 0, 64);
if (directory.ReadAttr("INSTALLER PACKAGE: NAME", B_STRING_TYPE, 0, package->fName, 64)<0) if (directory.ReadAttr("INSTALLER PACKAGE: NAME", B_STRING_TYPE, 0, package->fName, 64) < 0)
goto err; goto err;
if (directory.ReadAttr("INSTALLER PACKAGE: GROUP", B_STRING_TYPE, 0, group, 64)<0) if (directory.ReadAttr("INSTALLER PACKAGE: GROUP", B_STRING_TYPE, 0, group, 64) < 0)
goto err; goto err;
if (directory.ReadAttr("INSTALLER PACKAGE: DESCRIPTION", B_STRING_TYPE, 0, package->fDescription, 64)<0) if (directory.ReadAttr("INSTALLER PACKAGE: DESCRIPTION", B_STRING_TYPE, 0, package->fDescription, 64) < 0)
goto err; goto err;
if (directory.ReadAttr("INSTALLER PACKAGE: ON_BY_DEFAULT", B_BOOL_TYPE, 0, &onByDefault, sizeof(onByDefault))<0) if (directory.ReadAttr("INSTALLER PACKAGE: ON_BY_DEFAULT", B_BOOL_TYPE, 0, &onByDefault, sizeof(onByDefault)) < 0)
goto err; goto err;
if (directory.ReadAttr("INSTALLER PACKAGE: ALWAYS_ON", B_BOOL_TYPE, 0, &alwaysOn, sizeof(alwaysOn))<0) if (directory.ReadAttr("INSTALLER PACKAGE: ALWAYS_ON", B_BOOL_TYPE, 0, &alwaysOn, sizeof(alwaysOn)) < 0)
goto err; goto err;
if (directory.ReadAttr("INSTALLER PACKAGE: SIZE", B_INT32_TYPE, 0, &size, sizeof(size))<0) if (directory.ReadAttr("INSTALLER PACKAGE: SIZE", B_INT32_TYPE, 0, &size, sizeof(size)) < 0)
goto err; goto err;
package->SetGroupName(group); package->SetGroupName(group);
package->SetSize(size); package->SetSize(size);
@@ -125,7 +125,7 @@ Group::~Group()
PackageCheckBox::PackageCheckBox(BRect rect, Package *item) PackageCheckBox::PackageCheckBox(BRect rect, Package *item)
: BCheckBox(rect.OffsetBySelf(7,0), "pack_cb", item->Name(), NULL), : BCheckBox(rect.OffsetBySelf(7, 0), "pack_cb", item->Name(), NULL),
fPackage(item) fPackage(item)
{ {
} }
@@ -182,7 +182,7 @@ GroupView::~GroupView()
PackagesView::PackagesView(BRect rect, const char* name) PackagesView::PackagesView(BRect rect, const char* name)
: BView(rect, name, B_FOLLOW_ALL_SIDES, B_WILL_DRAW|B_FRAME_EVENTS) : BView(rect, name, B_FOLLOW_ALL_SIDES, B_WILL_DRAW | B_FRAME_EVENTS)
{ {
} }
@@ -203,7 +203,7 @@ PackagesView::Clean()
delete view; delete view;
} }
} }
ScrollTo(0,0); ScrollTo(0, 0);
} }
@@ -217,9 +217,9 @@ PackagesView::AddPackages(BList &packages, BMessage *msg)
rect.bottom = 15; rect.bottom = 15;
rect.top = 0; rect.top = 0;
BString lastGroup = ""; BString lastGroup = "";
for (int32 i=0; i<count; i++) { for (int32 i = 0; i < count; i++) {
void *item = packages.ItemAt(i); void *item = packages.ItemAt(i);
Package *package = static_cast<Package *> (item); Package *package = static_cast<Package *>(item);
if (lastGroup != BString(package->GroupName())) { if (lastGroup != BString(package->GroupName())) {
rect.OffsetBy(0, 1); rect.OffsetBy(0, 1);
lastGroup = package->GroupName(); lastGroup = package->GroupName();
@@ -246,7 +246,7 @@ PackagesView::AddPackages(BList &packages, BMessage *msg)
} else { } else {
vertScroller->SetRange(0.0f, rect.top - vertScroller->Bounds().Height()); vertScroller->SetRange(0.0f, rect.top - vertScroller->Bounds().Height());
vertScroller->SetProportion(vertScroller->Bounds().Height() / rect.top); vertScroller->SetProportion(vertScroller->Bounds().Height() / rect.top);
} }
vertScroller->SetSteps(15, vertScroller->Bounds().Height()); vertScroller->SetSteps(15, vertScroller->Bounds().Height());
@@ -259,7 +259,7 @@ PackagesView::GetTotalSizeAsString(char *string)
{ {
int32 count = CountChildren(); int32 count = CountChildren();
int32 size = 0; int32 size = 0;
for (int32 i=0; i<count; i++) { for (int32 i = 0; i < count; i++) {
PackageCheckBox *cb = dynamic_cast<PackageCheckBox*>(ChildAt(i)); PackageCheckBox *cb = dynamic_cast<PackageCheckBox*>(ChildAt(i));
if (cb && cb->Value()) if (cb && cb->Value())
size += cb->GetPackage()->Size(); size += cb->GetPackage()->Size();
@@ -273,7 +273,7 @@ PackagesView::GetPackagesToInstall(BList *list, int32 *size)
{ {
int32 count = CountChildren(); int32 count = CountChildren();
*size = 0; *size = 0;
for (int32 i=0; i<count; i++) { for (int32 i = 0; i < count; i++) {
PackageCheckBox *cb = dynamic_cast<PackageCheckBox*>(ChildAt(i)); PackageCheckBox *cb = dynamic_cast<PackageCheckBox*>(ChildAt(i));
if (cb && cb->Value()) { if (cb && cb->Value()) {
list->AddItem(cb->GetPackage()); list->AddItem(cb->GetPackage());
+42 -42
View File
@@ -15,44 +15,44 @@
#include <string.h> #include <string.h>
class Group { class Group {
public: public:
Group(); Group();
virtual ~Group(); virtual ~Group();
void SetGroupName(const char *group) { strcpy(fGroup, group); }; void SetGroupName(const char *group) { strcpy(fGroup, group); };
const char * GroupName() const { return fGroup; }; const char * GroupName() const { return fGroup; };
private: private:
char fGroup[64]; char fGroup[64];
}; };
class Package : public Group { class Package : public Group {
public: public:
Package(const char *folder); Package(const char *folder);
virtual ~Package(); virtual ~Package();
void SetFolder(const char *folder) { strcpy(fFolder, folder); }; void SetFolder(const char *folder) { strcpy(fFolder, folder); };
void SetName(const char *name) { strcpy(fName, name);}; void SetName(const char *name) { strcpy(fName, name);};
void SetDescription(const char *description) { strcpy(fDescription, description);}; void SetDescription(const char *description) { strcpy(fDescription, description);};
void SetSize(const int32 size) { fSize = size; }; void SetSize(const int32 size) { fSize = size; };
void SetIcon(BBitmap * icon) { delete fIcon; fIcon = icon; }; void SetIcon(BBitmap * icon) { delete fIcon; fIcon = icon; };
void SetOnByDefault(bool onByDefault) { fOnByDefault = onByDefault; }; void SetOnByDefault(bool onByDefault) { fOnByDefault = onByDefault; };
void SetAlwaysOn(bool alwaysOn) { fAlwaysOn = alwaysOn; }; void SetAlwaysOn(bool alwaysOn) { fAlwaysOn = alwaysOn; };
const char * Folder() const { return fFolder; }; const char * Folder() const { return fFolder; };
const char * Name() const { return fName; }; const char * Name() const { return fName; };
const char * Description() const { return fDescription; }; const char * Description() const { return fDescription; };
const int32 Size() const { return fSize; }; const int32 Size() const { return fSize; };
void GetSizeAsString(char *string); void GetSizeAsString(char *string);
const BBitmap * Icon() const { return fIcon; }; const BBitmap * Icon() const { return fIcon; };
bool OnByDefault() const { return fOnByDefault; }; bool OnByDefault() const { return fOnByDefault; };
bool AlwaysOn() const { return fAlwaysOn; }; bool AlwaysOn() const { return fAlwaysOn; };
static Package *PackageFromEntry(BEntry &dir); static Package *PackageFromEntry(BEntry &dir);
private: private:
char fFolder[64]; char fFolder[64];
char fName[64]; char fName[64];
char fDescription[64]; char fDescription[64];
int32 fSize; int32 fSize;
BBitmap *fIcon; BBitmap *fIcon;
bool fAlwaysOn, fOnByDefault; bool fAlwaysOn, fOnByDefault;
}; };
@@ -78,15 +78,15 @@ class GroupView : public BStringView {
class PackagesView : public BView { class PackagesView : public BView {
public: public:
PackagesView(BRect rect, const char* name); PackagesView(BRect rect, const char* name);
virtual ~PackagesView(); virtual ~PackagesView();
void Clean(); void Clean();
void AddPackages(BList &list, BMessage *msg); void AddPackages(BList &list, BMessage *msg);
void GetTotalSizeAsString(char *string); void GetTotalSizeAsString(char *string);
void GetPackagesToInstall(BList *list, int32 *size); void GetPackagesToInstall(BList *list, int32 *size);
private: private:
BList fViews; BList fViews;
}; };
#endif /* __PACKAGEVIEWS_H__ */ #endif /* __PACKAGEVIEWS_H__ */
+2 -2
View File
@@ -18,8 +18,8 @@ class PartitionMenuItem : public BMenuItem {
const char* menuLabel, BMessage *msg, partition_id id); const char* menuLabel, BMessage *msg, partition_id id);
~PartitionMenuItem(); ~PartitionMenuItem();
partition_id ID() const { return fID; }; partition_id ID() const { return fID; };
const char *MenuLabel() { return fMenuLabel ? fMenuLabel : Label(); }; const char *MenuLabel() { return fMenuLabel ? fMenuLabel : Label(); };
const char *Name() { return fName ? fName : Label(); }; const char *Name() { return fName ? fName : Label(); };
private: private:
partition_id fID; partition_id fID;
char *fMenuLabel; char *fMenuLabel;