status_t TeamSettings::SetTo(Team* team) { _Unset(); AutoLocker<Team> locker(team); fTeamName = team->Name(); // add breakpoints for (UserBreakpointList::ConstIterator it = team->UserBreakpoints().GetIterator(); UserBreakpoint* breakpoint = it.Next();) { BreakpointSetting* breakpointSetting = new(std::nothrow) BreakpointSetting; if (breakpointSetting == NULL) return B_NO_MEMORY; status_t error = breakpointSetting->SetTo(breakpoint->Location(), breakpoint->IsEnabled(), breakpoint->IsHidden()); if (error == B_OK && !fBreakpoints.AddItem(breakpointSetting)) error = B_NO_MEMORY; if (error != B_OK) { delete breakpointSetting; return error; } } return B_OK; }
status_t TeamSettings::SetTo(const BMessage& archive, const TeamUiSettingsFactory& factory) { _Unset(); status_t error = archive.FindString("teamName", &fTeamName); if (error != B_OK) return error; // add breakpoints BMessage childArchive; for (int32 i = 0; archive.FindMessage("breakpoints", i, &childArchive) == B_OK; i++) { BreakpointSetting* breakpointSetting = new(std::nothrow) BreakpointSetting; if (breakpointSetting == NULL) return B_NO_MEMORY; error = breakpointSetting->SetTo(childArchive); if (error == B_OK && !fBreakpoints.AddItem(breakpointSetting)) error = B_NO_MEMORY; if (error != B_OK) { delete breakpointSetting; return error; } } // add UI settings for (int32 i = 0; archive.FindMessage("uisettings", i, &childArchive) == B_OK; i++) { TeamUiSettings* setting = NULL; error = factory.Create(childArchive, setting); if (error == B_OK && !fUiSettings.AddItem(setting)) error = B_NO_MEMORY; if (error != B_OK) { delete setting; return error; } } if (archive.FindMessage("filemanagersettings", &childArchive) == B_OK) { error = fFileManagerSettings->SetTo(childArchive); if (error != B_OK) return error; } if (archive.FindMessage("signalsettings", &childArchive) == B_OK) { error = fSignalSettings->SetTo(childArchive); if (error != B_OK) return error; } return B_OK; }
status_t TeamSettings::SetTo(Team* team) { _Unset(); AutoLocker<Team> locker(team); fTeamName = team->Name(); // add breakpoints for (UserBreakpointList::ConstIterator it = team->UserBreakpoints().GetIterator(); UserBreakpoint* breakpoint = it.Next();) { BreakpointSetting* breakpointSetting = new(std::nothrow) BreakpointSetting; if (breakpointSetting == NULL) return B_NO_MEMORY; status_t error = breakpointSetting->SetTo(breakpoint->Location(), breakpoint->IsEnabled(), breakpoint->IsHidden(), breakpoint->Condition()); if (error == B_OK && !fBreakpoints.AddItem(breakpointSetting)) error = B_NO_MEMORY; if (error != B_OK) { delete breakpointSetting; return error; } } // add signal configuration fSignalSettings->SetDefaultSignalDisposition( team->DefaultSignalDisposition()); const SignalDispositionMappings& mappings = team->GetSignalDispositionMappings(); for (SignalDispositionMappings::const_iterator it = mappings.begin(); it != mappings.end(); ++it) { status_t error = fSignalSettings->AddCustomSignalDisposition( it->first, it->second); if (error != B_OK) return error; } return B_OK; }