void NetServer::_ConfigureInterfaces(int socket, BMessage* _missingDevice) { BMessage interface; uint32 cookie = 0; bool missing = false; while (fSettings.GetNextInterface(cookie, interface) == B_OK) { const char *device; if (interface.FindString("device", &device) != B_OK) continue; bool disabled = false; if (interface.FindBool("disabled", &disabled) == B_OK && disabled) { // disabled by user request _DisableInterface(socket, device); continue; } if (!strncmp(device, "/dev/net/", 9)) { // it's a kernel device, check if it's present BEntry entry(device); if (!entry.Exists()) { if (!missing && _missingDevice != NULL) { *_missingDevice = interface; missing = true; } continue; } } _ConfigureInterface(socket, interface); } }
void InstallerWindow::MessageReceived(BMessage *msg) { switch (msg->what) { case MSG_RESET: { _SetCopyEngineCancelSemaphore(-1); status_t error; if (msg->FindInt32("error", &error) == B_OK) { char errorMessage[2048]; snprintf(errorMessage, sizeof(errorMessage), TR("An error was " "encountered and the installation was not completed:\n\n" "Error: %s"), strerror(error)); (new BAlert("error", errorMessage, TR("OK")))->Go(); } _DisableInterface(false); fProgressLayoutItem->SetVisible(false); fPkgSwitchLayoutItem->SetVisible(true); _ShowOptionalPackages(); _UpdateControls(); break; } case START_SCAN: _ScanPartitions(); break; case BEGIN_MESSAGE: switch (fInstallStatus) { case kReadyForInstall: { _SetCopyEngineCancelSemaphore(create_sem(1, "copy engine cancel")); BList* list = new BList(); int32 size = 0; fPackagesView->GetPackagesToInstall(list, &size); fWorkerThread->SetLock(fCopyEngineCancelSemaphore); fWorkerThread->SetPackagesList(list); fWorkerThread->SetSpaceRequired(size); fInstallStatus = kInstalling; fWorkerThread->StartInstall(); fBeginButton->SetLabel(TR("Stop")); _DisableInterface(true); fProgressBar->SetTo(0.0, NULL, NULL); fPkgSwitchLayoutItem->SetVisible(false); fPackagesLayoutItem->SetVisible(false); fSizeViewLayoutItem->SetVisible(false); fProgressLayoutItem->SetVisible(true); break; } case kInstalling: { _QuitCopyEngine(true); break; } case kFinished: PostMessage(B_QUIT_REQUESTED); break; case kCancelled: break; } break; case SHOW_BOTTOM_MESSAGE: _ShowOptionalPackages(); break; case SOURCE_PARTITION: _PublishPackages(); _UpdateControls(); break; case TARGET_PARTITION: _UpdateControls(); break; case SETUP_MESSAGE: _LaunchDriveSetup(); break; case PACKAGE_CHECKBOX: { char buffer[15]; fPackagesView->GetTotalSizeAsString(buffer); char string[255]; sprintf(string, TR("Additional disk space required: %s"), buffer); fSizeView->SetText(string); break; } case ENCOURAGE_DRIVESETUP: { (new BAlert("use drive setup", TR("No partitions have been found " "that are suitable for installation. Please set up partitions " "and initialize at least one partition with the Be File " "System."), TR("OK")))->Go(); } case MSG_STATUS_MESSAGE: { // TODO: Was this supposed to prevent status messages still arriving // after the copy engine was shut down? // if (fInstallStatus != kInstalling) // break; float progress; if (msg->FindFloat("progress", &progress) == B_OK) { const char* currentItem; if (msg->FindString("item", ¤tItem) != B_OK) { currentItem = TR_CMT("???", "Unknown currently copied item"); } BString trailingLabel; int32 currentCount; int32 maximumCount; if (msg->FindInt32("current", ¤tCount) == B_OK && msg->FindInt32("maximum", &maximumCount) == B_OK) { char buffer[64]; snprintf(buffer, sizeof(buffer), TR_CMT("%1ld of %2ld", "number of files copied"), currentCount, maximumCount); trailingLabel << buffer; } else { trailingLabel << TR_CMT("?? of ??", "Unknown progress"); } fProgressBar->SetTo(progress, currentItem, trailingLabel.String()); } else { const char *status; if (msg->FindString("status", &status) == B_OK) { fLastStatus = fStatusView->Text(); _SetStatusMessage(status); } else _SetStatusMessage(fLastStatus.String()); } break; } case MSG_INSTALL_FINISHED: { _SetCopyEngineCancelSemaphore(-1); fBeginButton->SetLabel(TR("Quit")); PartitionMenuItem* dstItem = (PartitionMenuItem*)fDestMenu->FindMarked(); char status[1024]; if (be_roster->IsRunning(kDeskbarSignature)) { snprintf(status, sizeof(status), TR("Installation completed. " "Boot sector has been written to '%s'. Press Quit to " "leave the Installer or choose a new target volume to " "perform another installation."), dstItem ? dstItem->Name() : TR_CMT("???", "Unknown partition name")); } else { snprintf(status, sizeof(status), TR("Installation completed. " "Boot sector has been written to '%s'. Press Quit to " "restart the computer or choose a new target volume " "to perform another installation."), dstItem ? dstItem->Name() : TR_CMT("???", "Unknown partition name")); } _SetStatusMessage(status); fInstallStatus = kFinished; _DisableInterface(false); fProgressLayoutItem->SetVisible(false); fPkgSwitchLayoutItem->SetVisible(true); _ShowOptionalPackages(); break; } case B_SOME_APP_LAUNCHED: case B_SOME_APP_QUIT: { const char *signature; if (msg->FindString("be:signature", &signature) == B_OK && strcasecmp(signature, DRIVESETUP_SIG) == 0) { fDriveSetupLaunched = msg->what == B_SOME_APP_LAUNCHED; fBeginButton->SetEnabled(!fDriveSetupLaunched); _DisableInterface(fDriveSetupLaunched); if (fDriveSetupLaunched) _SetStatusMessage(TR("Running DriveSetup" B_UTF8_ELLIPSIS "\n\nClose DriveSetup to continue with the " "installation.")); else _ScanPartitions(); } break; } case MSG_WRITE_BOOT_SECTOR: fWorkerThread->WriteBootSector(fDestMenu); break; default: BWindow::MessageReceived(msg); break; } }