Ticket #2061: instpatch.patch
File instpatch.patch, 8.5 KB (added by , 17 years ago) |
---|
-
installer/CopyEngine.cpp
74 74 { 75 75 status_t err = Start(fWindow->GetSourceMenu(), 76 76 fWindow->GetTargetMenu()); 77 if (err != B_OK) 77 if (err != B_OK) { 78 78 ERR("Start failed"); 79 BMessenger(fWindow).SendMessage(RESET_INSTALL); 80 } 79 81 break; 80 82 } 81 83 } … … 182 184 "Try choosing a different disk or choose to not install optional " 183 185 "items.", "Try installing anyway", "Cancel", 0, 184 186 B_WIDTH_AS_USUAL, B_STOP_ALERT))->Go() != 0)) { 187 BMessenger(fWindow).SendMessage(RESET_INSTALL); 185 188 return B_OK; 186 189 } 187 190 … … 203 206 if (strcmp(srcDirectory.Path(), targetDirectory.Path()) == 0) { 204 207 SetStatusMessage("You can't install the contents of a disk onto " 205 208 "itself. Please choose a different disk."); 209 BMessenger(fWindow).SendMessage(RESET_INSTALL); 206 210 return B_OK; 207 211 } 208 212 … … 213 217 "machine if you proceed.", "OK", "Cancel", 0, 214 218 B_WIDTH_AS_USUAL, B_STOP_ALERT))->Go() != 0)) { 215 219 SetStatusMessage("Installation stopped."); 220 BMessenger(fWindow).SendMessage(RESET_INSTALL); 216 221 return B_OK; 217 222 } 218 223 … … 230 235 BDirectory packageDir; 231 236 int32 count = fPackages->CountItems(); 232 237 for (int32 i = 0; i < count; i++) { 238 if (fControl->CheckUserCanceled()) 239 return B_OK; 233 240 Package *p = static_cast<Package*>(fPackages->ItemAt(i)); 234 241 packageDir.SetTo(&srcDir, p->Folder()); 235 242 CopyFolder(packageDir, targetDir); 236 243 } 237 244 } 238 245 239 LaunchFinishScript(targetDirectory); 246 if (!fControl->CheckUserCanceled()) { 247 LaunchFinishScript(targetDirectory); 240 248 241 BMessage msg(INSTALL_FINISHED); 242 BMessenger(fWindow).SendMessage(&msg); 249 BMessage msg(INSTALL_FINISHED); 250 BMessenger(fWindow).SendMessage(&msg); 251 } 243 252 244 253 return B_OK; 245 254 } … … 250 259 { 251 260 BEntry entry; 252 261 status_t err; 253 while (srcDir.GetNextEntry(&entry) == B_OK) { 262 while (srcDir.GetNextEntry(&entry) == B_OK 263 && !fControl->CheckUserCanceled()) { 254 264 StatStruct statbuf; 255 265 entry.GetStat(&statbuf); 256 266 … … 299 309 } 300 310 301 311 312 bool 313 CopyEngine::Cancel() 314 { 315 return fControl->Cancel(); 316 } 317 318 302 319 // #pragma mark - 303 320 304 321 -
installer/CopyEngine.h
28 28 void ScanDisksPartitions(BMenu *srcMenu, BMenu *targetMenu); 29 29 void SetPackagesList(BList *list); 30 30 void SetSpaceRequired(off_t bytes) { fSpaceRequired = bytes; }; 31 bool Cancel(); 31 32 private: 32 33 void LaunchInitScript(BPath &path); 33 34 void LaunchFinishScript(BPath &path); -
installer/InstallerCopyLoopControl.cpp
9 9 10 10 InstallerCopyLoopControl::InstallerCopyLoopControl(InstallerWindow *window) 11 11 : fWindow(window), 12 fMessenger(window) 12 fMessenger(window), 13 fUserCanceled(false) 13 14 { 14 15 } 15 16 … … 48 49 bool 49 50 InstallerCopyLoopControl::CheckUserCanceled() 50 51 { 51 return f alse;52 return fUserCanceled; 52 53 } 53 54 54 55 … … 97 98 return false; 98 99 } 99 100 101 102 bool 103 InstallerCopyLoopControl::Cancel() 104 { 105 fUserCanceled = (new BAlert("", 106 "Are you sure you want to to stop the installation?", 107 "Continue", "Stop", 0, 108 B_WIDTH_AS_USUAL, B_STOP_ALERT))->Go() != 0; 109 return fUserCanceled; 110 } 111 -
installer/InstallerWindow.cpp
71 71 : BWindow(frame_rect, "Installer", B_TITLED_WINDOW, 72 72 B_NOT_ZOOMABLE | B_NOT_RESIZABLE), 73 73 fDriveSetupLaunched(false), 74 fInstallStatus(kReadyForInstall), 74 75 fLastSrcItem(NULL), 75 76 fLastTargetItem(NULL) 76 77 { … … 110 111 "begin_button", "Begin", new BMessage(BEGIN_MESSAGE), 111 112 B_FOLLOW_RIGHT | B_FOLLOW_BOTTOM); 112 113 fBeginButton->MakeDefault(true); 114 fBeginButton->SetEnabled(false); 113 115 fBackBox->AddChild(fBeginButton); 114 116 115 117 fSetupButton = new BButton(BRect(bounds.left + 11, bounds.bottom - 35, … … 135 137 fDestMenu = new BPopUpMenu("scanning" B_UTF8_ELLIPSIS, true, false); 136 138 fSrcMenu = new BPopUpMenu("scanning" B_UTF8_ELLIPSIS, true, false); 137 139 138 BRect fieldRect(bounds.left + 50, bounds.top + 70, bounds.right - 13,140 BRect fieldRect(bounds.left + 13, bounds.top + 70, bounds.right - 13, 139 141 bounds.top + 90); 140 142 fSrcMenuField = new BMenuField(fieldRect, "srcMenuField", 141 143 "Install from: ", fSrcMenu); 142 fSrcMenuField->SetDivider(bounds.right - 274);144 fSrcMenuField->SetDivider(bounds.right - 300); 143 145 fSrcMenuField->SetAlignment(B_ALIGN_RIGHT); 144 146 fBackBox->AddChild(fSrcMenuField); 145 147 146 148 fieldRect.OffsetBy(0, 23); 147 149 fDestMenuField = new BMenuField(fieldRect, "destMenuField", 148 150 "Onto: ", fDestMenu); 149 fDestMenuField->SetDivider(bounds.right - 274);151 fDestMenuField->SetDivider(bounds.right - 300); 150 152 fDestMenuField->SetAlignment(B_ALIGN_RIGHT); 151 153 fBackBox->AddChild(fDestMenuField); 152 154 … … 182 184 InstallerWindow::MessageReceived(BMessage *msg) 183 185 { 184 186 switch (msg->what) { 187 case RESET_INSTALL: 188 fInstallStatus = kReadyForInstall; 189 fBeginButton->SetEnabled(true); 190 DisableInterface(false); 191 fBeginButton->SetLabel("Begin"); 192 break; 185 193 case START_SCAN: 186 194 StartScan(); 195 fBeginButton->SetEnabled(true); 187 196 break; 188 197 case BEGIN_MESSAGE: 189 198 { 190 199 BList *list = new BList(); 191 int32 size = 0; 192 fPackagesView->GetPackagesToInstall(list, &size); 193 fCopyEngine->SetPackagesList(list); 194 fCopyEngine->SetSpaceRequired(size); 195 BMessenger(fCopyEngine).SendMessage(ENGINE_START); 196 DisableInterface(true); 200 switch (fInstallStatus) { 201 case kReadyForInstall: 202 { 203 int32 size = 0; 204 fPackagesView->GetPackagesToInstall(list, &size); 205 fCopyEngine->SetPackagesList(list); 206 fCopyEngine->SetSpaceRequired(size); 207 BMessenger(fCopyEngine).SendMessage(ENGINE_START); 208 fBeginButton->SetLabel("Stop"); 209 DisableInterface(true); 210 fInstallStatus = kInstalling; 211 break; 212 } 213 case kInstalling: 214 if (fCopyEngine->Cancel()) 215 PostMessage(INSTALL_FINISHED); 216 break; 217 case kFinished: 218 QuitRequested(); 219 break; 220 } 197 221 break; 198 222 } 199 223 case SHOW_BOTTOM_MESSAGE: … … 230 254 SetStatusMessage(status); 231 255 } else 232 256 SetStatusMessage(fLastStatus.String()); 257 break; 233 258 } 234 259 case INSTALL_FINISHED: 260 fBeginButton->SetLabel("Quit"); 261 fInstallStatus = kFinished; 235 262 DisableInterface(false); 236 263 break; 237 264 case B_SOME_APP_LAUNCHED: … … 241 268 if (msg->FindString("be:signature", &signature) == B_OK 242 269 && strcasecmp(signature, DRIVESETUP_SIG) == 0) { 243 270 fDriveSetupLaunched = msg->what == B_SOME_APP_LAUNCHED; 271 fBeginButton->SetEnabled(!fDriveSetupLaunched); 244 272 DisableInterface(fDriveSetupLaunched); 245 273 if (fDriveSetupLaunched) 246 274 SetStatusMessage("Running DriveSetup" B_UTF8_ELLIPSIS … … 306 334 void 307 335 InstallerWindow::DisableInterface(bool disable) 308 336 { 309 fBeginButton->SetEnabled(!disable);310 337 fSetupButton->SetEnabled(!disable); 311 338 fSrcMenuField->SetEnabled(!disable); 312 339 fDestMenuField->SetEnabled(!disable); -
installer/InstallerCopyLoopControl.h
35 35 virtual bool ChecksumFile(const entry_ref *); 36 36 virtual bool SkipAttribute(const char *attributeName); 37 37 virtual bool PreserveAttribute(const char *attributeName); 38 bool Cancel(); 38 39 39 40 private: 40 41 InstallerWindow *fWindow; 41 42 BMessenger fMessenger; 43 bool fUserCanceled; 42 44 }; 43 45 44 46 #endif -
installer/InstallerWindow.h
20 20 21 21 #define INSTALLER_RIGHT 402 22 22 23 enum InstallStatus { 24 kReadyForInstall, 25 kInstalling, 26 kFinished 27 }; 28 23 29 const uint32 STATUS_MESSAGE = 'iSTM'; 24 30 const uint32 INSTALL_FINISHED = 'iIFN'; 31 const uint32 RESET_INSTALL = 'iRSI'; 25 32 const char PACKAGES_DIRECTORY[] = "_packages_"; 26 33 27 34 class InstallerWindow : public BWindow { … … 46 53 BButton *fBeginButton, *fSetupButton; 47 54 DrawButton *fDrawButton; 48 55 bool fDriveSetupLaunched; 56 InstallStatus fInstallStatus; 49 57 BTextView *fStatusView; 50 58 BMenu* fSrcMenu, *fDestMenu; 51 59 BMenuField* fSrcMenuField, *fDestMenuField;