actually uses the copyengine looper to handle the copy process

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@16011 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Jérôme Duval 2006-01-20 13:33:42 +00:00
parent e9e5c69a25
commit 4606537811
4 changed files with 53 additions and 6 deletions

View File

@ -15,6 +15,13 @@
#include <String.h>
#include <VolumeRoster.h>
//#define COPY_TRACE
#ifdef COPY_TRACE
#define CALLED() printf("CALLED %s\n",__PRETTY_FUNCTION__)
#else
#define CALLED()
#endif
extern void SizeAsString(off_t size, char *string);
class SourceVisitor : public BDiskDeviceVisitor
@ -45,6 +52,28 @@ CopyEngine::CopyEngine(InstallerWindow *window)
fWindow(window)
{
fControl = new InstallerCopyLoopControl(window);
Run();
}
void
CopyEngine::MessageReceived(BMessage*msg)
{
CALLED();
switch (msg->what) {
case ENGINE_START:
Start(fWindow->GetSourceMenu(), fWindow->GetTargetMenu());
break;
}
}
void
CopyEngine::SetStatusMessage(char *status)
{
BMessage msg(STATUS_MESSAGE);
msg.AddString("status", status);
BMessenger(fWindow).SendMessage(&msg);
}
@ -56,7 +85,7 @@ CopyEngine::LaunchInitScript(BPath &path)
BString command(bootPath.Path());
command += "/InstallerInitScript ";
command += path.Path();
fWindow->SetStatusMessage("Starting Installation.");
SetStatusMessage("Starting Installation.");
system(command.String());
}
@ -69,7 +98,7 @@ CopyEngine::LaunchFinishScript(BPath &path)
BString command(bootPath.Path());
command += "/InstallerFinishScript ";
command += path.Path();
fWindow->SetStatusMessage("Finishing Installation.");
SetStatusMessage("Finishing Installation.");
system(command.String());
}
@ -77,10 +106,13 @@ CopyEngine::LaunchFinishScript(BPath &path)
void
CopyEngine::Start(BMenu *srcMenu, BMenu *targetMenu)
{
CALLED();
PartitionMenuItem *targetItem = (PartitionMenuItem *)targetMenu->FindMarked();
PartitionMenuItem *srcItem = (PartitionMenuItem *)srcMenu->FindMarked();
if (!srcItem || !targetItem)
if (!srcItem || !targetItem) {
fprintf(stderr, "bad menu items\n");
return;
}
BPath targetDirectory;
BDiskDevice device;
@ -113,6 +145,7 @@ CopyEngine::Start(BMenu *srcMenu, BMenu *targetMenu)
bootVolume.GetRootDirectory(&bootDir);
bootDir.GetEntry(&bootEntry);
bootEntry.GetPath(&bootPath);
printf("Copying to boot disk ? '%s' / '%s'\n", bootPath.Path(), targetDirectory.Path());
if (strncmp(bootPath.Path(), targetDirectory.Path(), strlen(bootPath.Path())) == 0) {
}

View File

@ -17,9 +17,13 @@
class InstallerWindow;
const uint32 ENGINE_START = 'eSRT';
class CopyEngine : public BLooper {
public:
CopyEngine(InstallerWindow *window);
void MessageReceived(BMessage *msg);
void SetStatusMessage(char *status);
void Start(BMenu *srcMenu, BMenu *targetMenu);
void ScanDisksPartitions(BMenu *srcMenu, BMenu *targetMenu);

View File

@ -164,7 +164,8 @@ InstallerWindow::MessageReceived(BMessage *msg)
StartScan();
break;
case BEGIN_MESSAGE:
fCopyEngine.Start(fSrcMenu, fDestMenu);
printf("BEGIN_MESSAGE\n");
BMessenger(&fCopyEngine).SendMessage(ENGINE_START);
break;
case SHOW_BOTTOM_MESSAGE:
ShowBottom();
@ -187,6 +188,11 @@ InstallerWindow::MessageReceived(BMessage *msg)
fSizeView->SetText(string);
break;
}
case STATUS_MESSAGE: {
const char *status;
if (msg->FindString("status", &status) == B_OK)
SetStatusMessage(status);
}
case B_SOME_APP_LAUNCHED:
case B_SOME_APP_QUIT:
{
@ -373,7 +379,7 @@ InstallerWindow::ComparePackages(const void *firstArg, const void *secondArg)
void
InstallerWindow::SetStatusMessage(char *text)
InstallerWindow::SetStatusMessage(const char *text)
{
BAutolock(this);
fStatusView->SetText(text);

View File

@ -19,6 +19,8 @@
#define INSTALLER_RIGHT 402
const uint32 STATUS_MESSAGE = 'iSTM';
class InstallerWindow : public BWindow {
public:
InstallerWindow(BRect frameRect);
@ -26,7 +28,9 @@ public:
virtual void MessageReceived(BMessage *msg);
virtual bool QuitRequested();
void SetStatusMessage(char *text);
void SetStatusMessage(const char *text);
BMenu *GetSourceMenu() { return fSrcMenu; };
BMenu *GetTargetMenu() { return fDestMenu; };
private:
void DisableInterface(bool disable);
void LaunchDriveSetup();