* Make the source selection not accidentally reject the boot partition because

it isn't BFS... (like perhaps ISO9660 with write-overlay ;-)
* Reject a lot more situations as valid targets. (No more devices when they
  already have child partitions, no more extended partitions themselves, also
  use a minimum size.)
* Remove the partition ID from the menu item name. I don't know why the user
  would be interested in this.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@30335 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Stephan Aßmus
2009-04-22 20:21:39 +00:00
parent bbab3b46ce
commit 3861c65e89
+50 -38
View File
@@ -332,45 +332,44 @@ SourceVisitor::SourceVisitor(BMenu *menu)
bool bool
SourceVisitor::Visit(BDiskDevice *device) SourceVisitor::Visit(BDiskDevice *device)
{ {
if (!device->ContentType() return Visit(device, 0);
|| strcmp(device->ContentType(), kPartitionTypeBFS) != 0)
return false;
BPath path;
if (device->GetPath(&path) == B_OK)
printf("SourceVisitor::Visit(BDiskDevice *) : %s type:%s, "
"contentType:%s\n", path.Path(), device->Type(),
device->ContentType());
PartitionMenuItem *item = new PartitionMenuItem(NULL, device->ContentName(), NULL, new BMessage(SRC_PARTITION), device->ID());
if (device->IsMounted()) {
BPath mountPoint;
device->GetMountPoint(&mountPoint);
if (strcmp(BOOT_PATH, mountPoint.Path()) == 0)
item->SetMarked(true);
}
fMenu->AddItem(item);
return false;
} }
bool bool
SourceVisitor::Visit(BPartition *partition, int32 level) SourceVisitor::Visit(BPartition *partition, int32 level)
{ {
if (!partition->ContentType()
|| strcmp(partition->ContentType(), kPartitionTypeBFS) != 0)
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->ContentName());
PartitionMenuItem *item = new PartitionMenuItem(NULL,
partition->ContentName(), NULL, new BMessage(SRC_PARTITION), if (!partition->ContentType())
partition->ID()); return false;
bool isBootPartition = false;
if (partition->IsMounted()) { if (partition->IsMounted()) {
BPath mountPoint; BPath mountPoint;
partition->GetMountPoint(&mountPoint); partition->GetMountPoint(&mountPoint);
if (strcmp(BOOT_PATH, mountPoint.Path()) == 0) isBootPartition = strcmp(BOOT_PATH, mountPoint.Path()) == 0;
item->SetMarked(true);
} }
if (!isBootPartition
&& strcmp(partition->ContentType(), kPartitionTypeBFS) != 0) {
// Except only BFS partitions, except this is the boot partition
// (ISO9660 with write overlay for example).
return false;
}
// TODO: We could probably check if this volume contains
// the Haiku kernel or something. Does it make sense to "install"
// from your BFS volume containing the music collection?
// TODO: Then the check for BFS could also be removed above.
PartitionMenuItem *item = new PartitionMenuItem(NULL,
partition->ContentName(), NULL, new BMessage(SRC_PARTITION),
partition->ID());
item->SetMarked(isBootPartition);
fMenu->AddItem(item); fMenu->AddItem(item);
return false; return false;
} }
@@ -388,28 +387,41 @@ TargetVisitor::TargetVisitor(BMenu *menu)
bool bool
TargetVisitor::Visit(BDiskDevice *device) TargetVisitor::Visit(BDiskDevice *device)
{ {
if (device->IsReadOnly() || device->IsReadOnlyMedia()) if (device->IsReadOnlyMedia())
return false; return false;
BPath path; return Visit(device, 0);
if (device->GetPath(&path) == B_OK)
printf("TargetVisitor::Visit(BDiskDevice *) : %s\n", path.Path());
char label[255], menuLabel[255];
_MakeLabel(device, label, menuLabel);
fMenu->AddItem(new PartitionMenuItem(device->ContentName(), label,
menuLabel, new BMessage(TARGET_PARTITION), device->ID()));
return false;
} }
bool bool
TargetVisitor::Visit(BPartition *partition, int32 level) TargetVisitor::Visit(BPartition *partition, int32 level)
{ {
// TODO: This check does not work on non-mounted partitions!
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->ContentName());
if (partition->ContentSize() < 20 * 1024 * 1024) {
// reject partitions which are too small anyways
// TODO: Could depend on the source size
printf(" too small\n");
return false;
}
if (partition->CountChildren() > 0) {
// Looks like an extended partition, or the device itself.
// Do not accept this as target...
printf(" no leaf partition\n");
return false;
}
// TODO: After running DriveSetup and doing another scan, it would
// be great to pick the partition which just appeared!
char label[255], menuLabel[255]; char label[255], menuLabel[255];
_MakeLabel(partition, label, menuLabel); _MakeLabel(partition, label, menuLabel);
fMenu->AddItem(new PartitionMenuItem(partition->ContentName(), label, fMenu->AddItem(new PartitionMenuItem(partition->ContentName(), label,
@@ -427,8 +439,8 @@ TargetVisitor::_MakeLabel(BPartition *partition, char *label, char *menuLabel)
if (partition->Parent()) if (partition->Parent())
partition->Parent()->GetPath(&path); partition->Parent()->GetPath(&path);
sprintf(label, "%s - %s [%s] [%s partition:%li]", partition->ContentName(), sprintf(label, "%s - %s [%s] [%s]", partition->ContentName(),
size, partition->ContentType(), path.Path(), partition->ID()); size, partition->ContentType(), path.Path());
sprintf(menuLabel, "%s - %s [%s]", partition->ContentName(), size, sprintf(menuLabel, "%s - %s [%s]", partition->ContentName(), size,
partition->ContentType()); partition->ContentType());