bool BrowsingHistory::_AddItem(const BrowsingHistoryItem& item, bool internal) { int32 count = CountItems(); int32 insertionIndex = count; for (int32 i = 0; i < count; i++) { BrowsingHistoryItem* existingItem = reinterpret_cast<BrowsingHistoryItem*>( fHistoryItems.ItemAtFast(i)); if (item.URL() == existingItem->URL()) { if (!internal) { existingItem->Invoked(); _SaveSettings(); } return true; } if (item < *existingItem) insertionIndex = i; } BrowsingHistoryItem* newItem = new(std::nothrow) BrowsingHistoryItem(item); if (!newItem || !fHistoryItems.AddItem(newItem, insertionIndex)) { delete newItem; return false; } if (!internal) { newItem->Invoked(); _SaveSettings(); } return true; }
void DownloadWindow::_DownloadFinished(BWebDownload* download) { int32 finishedCount = 0; int32 missingCount = 0; for (int32 i = 0; BLayoutItem* item = fDownloadViewsLayout->ItemAt(i); i++) { DownloadProgressView* view = dynamic_cast<DownloadProgressView*>( item->View()); if (!view) continue; if (download && view->Download() == download) { view->DownloadFinished(); finishedCount++; continue; } if (view->IsFinished()) finishedCount++; if (view->IsMissing()) missingCount++; } fRemoveFinishedButton->SetEnabled(finishedCount > 0); fRemoveMissingButton->SetEnabled(missingCount > 0); if (download) _SaveSettings(); }
void CDbConnectionDlg::OnOK() { _SaveSettings(); CString strError; bool bValid; { CWaitCursor wait; bValid = m_dbConnSettings.CheckConnection(strError); } if(!bValid) { strError += _T(" Save changes?"); int iResult = MessageBox(strError, NULL, MB_ICONSTOP | MB_YESNOCANCEL); if(iResult == IDCANCEL) return; if(iResult == IDNO) { CDialog::OnCancel(); return; } } CDialog::OnOK(); }
void BrowsingHistory::Clear() { BAutolock _(this); _Clear(); _SaveSettings(); }
bool CharacterWindow::QuitRequested() { _SaveSettings(); be_app->PostMessage(B_QUIT_REQUESTED); return true; }
bool TeamsWindow::QuitRequested() { _SaveSettings(); be_app_messenger.SendMessage(MSG_TEAMS_WINDOW_CLOSED); return true; }
bool CalcApplication::QuitRequested() { // save current user preferences _SaveSettings(); return true; }
void BrowsingHistory::SetMaxHistoryItemAge(int32 days) { BAutolock _(this); if (fMaxHistoryItemAge != days) { fMaxHistoryItemAge = days; _SaveSettings(); } }
void DownloadWindow::_DownloadStarted(BWebDownload* download) { download->Start(BPath(fDownloadPath.String())); int32 finishedCount = 0; int32 missingCount = 0; int32 index = 0; for (int32 i = fDownloadViewsLayout->CountItems() - 1; BLayoutItem* item = fDownloadViewsLayout->ItemAt(i); i--) { DownloadProgressView* view = dynamic_cast<DownloadProgressView*>( item->View()); if (!view) continue; if (view->URL() == download->URL()) { index = i; view->RemoveSelf(); delete view; continue; } if (view->IsFinished()) finishedCount++; if (view->IsMissing()) missingCount++; } fRemoveFinishedButton->SetEnabled(finishedCount > 0); fRemoveMissingButton->SetEnabled(missingCount > 0); DownloadProgressView* view = new DownloadProgressView(download); if (!view->Init()) { delete view; return; } fDownloadViewsLayout->AddView(index, view); // Scroll new download into view if (BScrollBar* scrollBar = fDownloadsScrollView->ScrollBar(B_VERTICAL)) { float min; float max; scrollBar->GetRange(&min, &max); float viewHeight = view->MinSize().height + 1; float scrollOffset = min + index * viewHeight; float scrollBarHeight = scrollBar->Bounds().Height() - 1; float value = scrollBar->Value(); if (scrollOffset < value) scrollBar->SetValue(scrollOffset); else if (scrollOffset + viewHeight > value + scrollBarHeight) { float diff = scrollOffset + viewHeight - (value + scrollBarHeight); scrollBar->SetValue(value + diff); } } _SaveSettings(); SetWorkspaces(B_CURRENT_WORKSPACE); if (IsHidden()) Show(); }
PowerStatusReplicant::~PowerStatusReplicant() { if (fMessengerExist) delete fExtWindowMessenger; fDriverInterface->StopWatching(this); fDriverInterface->Disconnect(); fDriverInterface->ReleaseReference(); _SaveSettings(); }
/* virtual */ void MidiSettingsView::MessageReceived(BMessage* message) { switch (message->what) { case kSelectSoundFont: _SaveSettings(); break; default: SettingsView::MessageReceived(message); break; } }
TeamDebugger::~TeamDebugger() { if (fTeam != NULL) _SaveSettings(); AutoLocker<BLooper> locker(this); fTerminating = true; if (fDebuggerInterface != NULL) { fDebuggerInterface->Close(fKillTeamOnQuit); fDebuggerInterface->ReleaseReference(); } if (fWorker != NULL) fWorker->ShutDown(); locker.Unlock(); if (fDebugEventListener >= 0) wait_for_thread(fDebugEventListener, NULL); // terminate UI fUserInterface->Terminate(); fUserInterface->ReleaseReference(); ThreadHandler* threadHandler = fThreadHandlers.Clear(true); while (threadHandler != NULL) { ThreadHandler* next = threadHandler->fNext; threadHandler->ReleaseReference(); threadHandler = next; } ImageHandler* imageHandler = fImageHandlers->Clear(true); while (imageHandler != NULL) { ImageHandler* next = imageHandler->fNext; imageHandler->ReleaseReference(); imageHandler = next; } delete fImageHandlers; delete fBreakpointManager; delete fMemoryBlockManager; delete fWorker; delete fTeam; delete fFileManager; fListener->TeamDebuggerQuit(this); }
void DownloadWindow::_RemoveMissingDownloads() { int32 finishedCount = 0; for (int32 i = fDownloadViewsLayout->CountItems() - 1; BLayoutItem* item = fDownloadViewsLayout->ItemAt(i); i--) { DownloadProgressView* view = dynamic_cast<DownloadProgressView*>( item->View()); if (!view) continue; if (view->IsMissing()) { view->RemoveSelf(); delete view; } else if (view->IsFinished()) finishedCount++; } fRemoveMissingButton->SetEnabled(false); fRemoveFinishedButton->SetEnabled(finishedCount > 0); _SaveSettings(); }
bool BoardWindow::QuitRequested() { Hide(); if (fICSMainWindow != NULL) { fICSMainWindow->PostMessage(MSG_WINDOW_CLOSED); if (fTimeView->IsStarted()) { BString str; str << BLK_RESIGN << " resign"; SendICS(str, fICSMainWindow); } return false; } else { if (fEngine != NULL) fEngine->PostMessage(MSG_QUIT); if (fICSConnectMI->IsMarked() == false) _SaveSettings(); return true; } }
MediaReplicant::~MediaReplicant() { delete fIcon; _SaveSettings(); }
void DownloadWindow::MessageReceived(BMessage* message) { switch (message->what) { case INIT: { _LoadSettings(); // Small trick to get the correct enabled status of the Remove // finished button _DownloadFinished(NULL); break; } case B_DOWNLOAD_ADDED: { BWebDownload* download; if (message->FindPointer("download", reinterpret_cast<void**>( &download)) == B_OK) { _DownloadStarted(download); } break; } case B_DOWNLOAD_REMOVED: { BWebDownload* download; if (message->FindPointer("download", reinterpret_cast<void**>( &download)) == B_OK) { _DownloadFinished(download); } break; } case OPEN_DOWNLOADS_FOLDER: { entry_ref ref; status_t status = get_ref_for_path(fDownloadPath.String(), &ref); if (status == B_OK) status = be_roster->Launch(&ref); if (status != B_OK && status != B_ALREADY_RUNNING) { BString errorString(B_TRANSLATE_COMMENT("The downloads folder could " "not be opened.\n\nError: %error", "Don't translate " "variable %error")); errorString.ReplaceFirst("%error", strerror(status)); BAlert* alert = new BAlert(B_TRANSLATE("Error opening downloads " "folder"), errorString.String(), B_TRANSLATE("OK")); alert->SetFlags(alert->Flags() | B_CLOSE_ON_ESCAPE); alert->Go(NULL); } break; } case REMOVE_FINISHED_DOWNLOADS: _RemoveFinishedDownloads(); break; case REMOVE_MISSING_DOWNLOADS: _RemoveMissingDownloads(); break; case SAVE_SETTINGS: _ValidateButtonStatus(); _SaveSettings(); break; case SETTINGS_VALUE_CHANGED: { BString string; if (message->FindString("name", &string) == B_OK && string == kSettingsKeyDownloadPath && message->FindString("value", &string) == B_OK) { fDownloadPath = string; } break; } default: BWindow::MessageReceived(message); break; } }
BrowsingHistory::~BrowsingHistory() { _SaveSettings(); _Clear(); }
MouseSettings::~MouseSettings() { _SaveSettings(); }
// MessageReceived void NetFSServer::MessageReceived(BMessage* message) { switch (message->what) { case NETFS_REQUEST_GET_MESSENGER: { // for the time being we process all requests here BMessage reply; reply.AddMessenger("messenger", be_app_messenger); _SendReply(message, &reply); break; } case NETFS_REQUEST_ADD_USER: { // get user name and password const char* user; const char* password; if (message->FindString("user", &user) != B_OK) { _SendReply(message, B_BAD_VALUE); break; } if (message->FindString("password", &password) != B_OK) password = NULL; // add the user status_t error = fSecurityContext->AddUser(user, password); _SendReply(message, error); break; } case NETFS_REQUEST_REMOVE_USER: { // get user name const char* userName; if (message->FindString("user", &userName) != B_OK) { _SendReply(message, B_BAD_VALUE); break; } // remove the user User* user; status_t error = fSecurityContext->RemoveUser(userName, &user); if (error == B_OK) { // propagate the information to the client connections AutoLocker<Locker> _(fLock); for (int32 i = 0; ClientConnection* connection = (ClientConnection*)fClientConnections.ItemAt(i); i++) { connection->UserRemoved(user); } user->RemoveReference(); } _SendReply(message, error); break; } case NETFS_REQUEST_GET_USERS: { // get the users BMessage reply; BMessage users; status_t error = fSecurityContext->GetUsers(&users); if (error == B_OK) error = reply.AddMessage("users", &users); if (error == B_OK) _SendReply(message, &reply); else _SendReply(message, error); break; } case NETFS_REQUEST_GET_USER_STATISTICS: { // get user name const char* userName; if (message->FindString("user", &userName) != B_OK) { _SendReply(message, B_BAD_VALUE); break; } // get the user User* user = fSecurityContext->FindUser(userName); if (!user) { _SendReply(message, B_ENTRY_NOT_FOUND); break; } Reference<User> userReference(user, true); // get the statistics BMessage statistics; status_t error = StatisticsManager::GetDefault() ->GetUserStatistics(user, &statistics); // prepare the reply BMessage reply; if (error == B_OK) error = reply.AddMessage("statistics", &statistics); // send the reply if (error == B_OK) _SendReply(message, &reply); else _SendReply(message, error); break; } case NETFS_REQUEST_ADD_SHARE: { // get share name and path const char* share; const char* path; if (message->FindString("share", &share) != B_OK || message->FindString("path", &path) != B_OK) { _SendReply(message, B_BAD_VALUE); break; } // add the share status_t error = fSecurityContext->AddShare(share, path); if (error == B_OK) _ServerInfoUpdated(); _SendReply(message, error); break; } case NETFS_REQUEST_REMOVE_SHARE: { // get share name const char* shareName; if (message->FindString("share", &shareName) != B_OK) { _SendReply(message, B_BAD_VALUE); break; } // remove the share Share* share; status_t error = fSecurityContext->RemoveShare(shareName, &share); if (error == B_OK) { // propagate the information to the client connections AutoLocker<Locker> _(fLock); for (int32 i = 0; ClientConnection* connection = (ClientConnection*)fClientConnections.ItemAt(i); i++) { connection->ShareRemoved(share); } share->RemoveReference(); } if (error == B_OK) _ServerInfoUpdated(); _SendReply(message, error); break; } case NETFS_REQUEST_GET_SHARES: { // get the shares BMessage reply; BMessage shares; status_t error = fSecurityContext->GetShares(&shares); if (error == B_OK) error = reply.AddMessage("shares", &shares); if (error == B_OK) _SendReply(message, &reply); else _SendReply(message, error); break; } case NETFS_REQUEST_GET_SHARE_USERS: { // get share name const char* shareName; if (message->FindString("share", &shareName) != B_OK) { _SendReply(message, B_BAD_VALUE); break; } AutoLocker<Locker> securityContextLocker(fSecurityContext); // get the share Share* share = fSecurityContext->FindShare(shareName); if (!share) { _SendReply(message, B_ENTRY_NOT_FOUND); break; } Reference<Share> shareReference(share, true); // get all users BMessage allUsers; status_t error = fSecurityContext->GetUsers(&allUsers); if (error != B_OK) { _SendReply(message, error); break; } // filter the users with mount permission BMessage users; const char* userName; for (int32 i = 0; allUsers.FindString("users", i, &userName) == B_OK; i++) { if (User* user = fSecurityContext->FindUser(userName)) { // get the user's permissions Permissions permissions = fSecurityContext ->GetNodePermissions(share->GetPath(), user); user->RemoveReference(); // add the user, if they have the permission to mount the // share if (permissions.ImpliesMountSharePermission()) { error = users.AddString("users", userName); if (error != B_OK) { _SendReply(message, error); break; } } } } securityContextLocker.Unlock(); // prepare the reply BMessage reply; if (error == B_OK) error = reply.AddMessage("users", &users); // send the reply if (error == B_OK) _SendReply(message, &reply); else _SendReply(message, error); break; } case NETFS_REQUEST_GET_SHARE_STATISTICS: { // get share name const char* shareName; if (message->FindString("share", &shareName) != B_OK) { _SendReply(message, B_BAD_VALUE); break; } // get the share Share* share = fSecurityContext->FindShare(shareName); if (!share) { _SendReply(message, B_ENTRY_NOT_FOUND); break; } Reference<Share> shareReference(share, true); // get the statistics BMessage statistics; status_t error = StatisticsManager::GetDefault() ->GetShareStatistics(share, &statistics); // prepare the reply BMessage reply; if (error == B_OK) error = reply.AddMessage("statistics", &statistics); // send the reply if (error == B_OK) _SendReply(message, &reply); else _SendReply(message, error); break; } case NETFS_REQUEST_SET_USER_PERMISSIONS: { // get share and user name, and the permissions const char* shareName; const char* userName; uint32 permissions; if (message->FindString("share", &shareName) != B_OK || message->FindString("user", &userName) != B_OK || message->FindInt32("permissions", (int32*)&permissions) != B_OK) { _SendReply(message, B_BAD_VALUE); break; } // get the share and the user Share* share = fSecurityContext->FindShare(shareName); User* user = fSecurityContext->FindUser(userName); Reference<Share> shareReference(share); Reference<User> userReference(user); if (!share || !user) { _SendReply(message, B_ENTRY_NOT_FOUND); break; } // set the permissions status_t error = B_OK; if (permissions == 0) { fSecurityContext->ClearNodePermissions(share->GetPath(), user); } else { error = fSecurityContext->SetNodePermissions(share->GetPath(), user, permissions); } if (error == B_OK) { // propagate the information to the client connections AutoLocker<Locker> _(fLock); for (int32 i = 0; ClientConnection* connection = (ClientConnection*)fClientConnections.ItemAt(i); i++) { connection->UserPermissionsChanged(share, user, permissions); } } _SendReply(message, error); break; } case NETFS_REQUEST_GET_USER_PERMISSIONS: { // get share and user name const char* shareName; const char* userName; if (message->FindString("share", &shareName) != B_OK || message->FindString("user", &userName) != B_OK) { _SendReply(message, B_BAD_VALUE); break; } // get the share and the user Share* share = fSecurityContext->FindShare(shareName); User* user = fSecurityContext->FindUser(userName); Reference<Share> shareReference(share); Reference<User> userReference(user); if (!share || !user) { _SendReply(message, B_ENTRY_NOT_FOUND); break; } // get the permissions Permissions permissions = fSecurityContext->GetNodePermissions( share->GetPath(), user); // prepare the reply BMessage reply; status_t error = reply.AddInt32("permissions", (int32)permissions.GetPermissions()); // send it if (error == B_OK) _SendReply(message, &reply); else _SendReply(message, error); break; } case NETFS_REQUEST_SAVE_SETTINGS: { status_t error = _SaveSettings(); // send a reply _SendReply(message, error); break; } } }
DownloadWindow::~DownloadWindow() { // Only necessary to save the current progress of unfinished downloads: _SaveSettings(); }