From 46065378112a4b12be63fcbd5ea3da02f73c9077 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Duval?= Date: Fri, 20 Jan 2006 13:33:42 +0000 Subject: [PATCH] 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 --- src/apps/installer/CopyEngine.cpp | 39 ++++++++++++++++++++++++-- src/apps/installer/CopyEngine.h | 4 +++ src/apps/installer/InstallerWindow.cpp | 10 +++++-- src/apps/installer/InstallerWindow.h | 6 +++- 4 files changed, 53 insertions(+), 6 deletions(-) diff --git a/src/apps/installer/CopyEngine.cpp b/src/apps/installer/CopyEngine.cpp index e41fca6f21..72557a4f85 100644 --- a/src/apps/installer/CopyEngine.cpp +++ b/src/apps/installer/CopyEngine.cpp @@ -15,6 +15,13 @@ #include #include +//#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) { } diff --git a/src/apps/installer/CopyEngine.h b/src/apps/installer/CopyEngine.h index 1af449fd73..b5edaabd57 100644 --- a/src/apps/installer/CopyEngine.h +++ b/src/apps/installer/CopyEngine.h @@ -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); diff --git a/src/apps/installer/InstallerWindow.cpp b/src/apps/installer/InstallerWindow.cpp index 2bb14fb545..cb9916542e 100644 --- a/src/apps/installer/InstallerWindow.cpp +++ b/src/apps/installer/InstallerWindow.cpp @@ -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); diff --git a/src/apps/installer/InstallerWindow.h b/src/apps/installer/InstallerWindow.h index 4e48be42f2..bd65add960 100644 --- a/src/apps/installer/InstallerWindow.h +++ b/src/apps/installer/InstallerWindow.h @@ -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();