void ProcessController::MessageReceived(BMessage *message) { team_id team; thread_id thread; BAlert *alert; char question[1000]; switch (message->what) { case 'Puls': Update (); DoDraw (false); break; case 'QtTm': if (message->FindInt32("team", &team) == B_OK) { resume_thread(spawn_thread(thread_quit_application, B_TRANSLATE("Quit application"), B_NORMAL_PRIORITY, (void*)(addr_t)team)); } break; case 'KlTm': if (message->FindInt32("team", &team) == B_OK) { info_pack infos; if (get_team_info(team, &infos.team_info) == B_OK) { get_team_name_and_icon(infos); snprintf(question, sizeof(question), B_TRANSLATE("What do you want to do with the team \"%s\"?"), infos.team_name); alert = new BAlert(B_TRANSLATE("Please confirm"), question, B_TRANSLATE("Cancel"), B_TRANSLATE("Debug this team!"), B_TRANSLATE("Kill this team!"), B_WIDTH_AS_USUAL, B_STOP_ALERT); alert->SetShortcut(0, B_ESCAPE); int result = alert->Go(); switch (result) { case 1: _HandleDebugRequest(team, -1); break; case 2: kill_team(team); break; default: break; } } else { alert = new BAlert(B_TRANSLATE("Info"), B_TRANSLATE("This team is already gone" B_UTF8_ELLIPSIS), B_TRANSLATE("Ok!"), NULL, NULL, B_WIDTH_AS_USUAL, B_STOP_ALERT); alert->SetFlags(alert->Flags() | B_CLOSE_ON_ESCAPE); alert->Go(); } } break; case 'KlTh': if (message->FindInt32("thread", &thread) == B_OK) { thread_info thinfo; if (get_thread_info(thread, &thinfo) == B_OK) { #if DEBUG_THREADS snprintf(question, sizeof(question), B_TRANSLATE("What do you want to do " "with the thread \"%s\"?"), thinfo.name); alert = new BAlert(B_TRANSLATE("Please confirm"), question, B_TRANSLATE("Cancel"), B_TRANSLATE("Debug this thread!"), B_TRANSLATE("Kill this thread!"), B_WIDTH_AS_USUAL, B_STOP_ALERT); alert->SetShortcut(0, B_ESCAPE); #define KILL 2 #else snprintf(question, sizeof(question), B_TRANSLATE("Are you sure you want " "to kill the thread \"%s\"?"), thinfo.name); alert = new BAlert(B_TRANSLATE("Please confirm"), question, B_TRANSLATE("Cancel"), B_TRANSLATE("Kill this thread!"), NULL, B_WIDTH_AS_USUAL, B_STOP_ALERT); alert->SetShortcut(0, B_ESCAPE); #define KILL 1 #endif alert->SetShortcut(0, B_ESCAPE); int r = alert->Go(); if (r == KILL) kill_thread(thread); #if DEBUG_THREADS else if (r == 1) _HandleDebugRequest(thinfo.team, thinfo.thread); #endif } else { alert = new BAlert(B_TRANSLATE("Info"), B_TRANSLATE("This thread is already gone" B_UTF8_ELLIPSIS), B_TRANSLATE("Ok!"), NULL, NULL, B_WIDTH_AS_USUAL, B_STOP_ALERT); alert->SetFlags(alert->Flags() | B_CLOSE_ON_ESCAPE); alert->Go(); } } break; case 'PrTh': if (message->FindInt32("thread", &thread) == B_OK) { int32 new_priority; if (message->FindInt32("priority", &new_priority) == B_OK) set_thread_priority(thread, new_priority); } break; case 'Trac': { BPath trackerPath; if (find_directory(B_SYSTEM_DIRECTORY, &trackerPath) == B_OK && trackerPath.Append("Tracker") == B_OK) { launch(kTrackerSig, trackerPath.Path()); } break; } case 'Dbar': { BPath deskbarPath; if (find_directory(B_SYSTEM_DIRECTORY, &deskbarPath) == B_OK && deskbarPath.Append("Deskbar") == B_OK) { launch(kDeskbarSig, deskbarPath.Path()); } break; } case 'Term': { BPath terminalPath; if (find_directory(B_SYSTEM_APPS_DIRECTORY, &terminalPath) == B_OK && terminalPath.Append("Terminal") == B_OK) { launch(kTerminalSig, terminalPath.Path()); } break; } case 'AlDb': { if (!be_roster->IsRunning(kDeskbarSig)) { BPath deskbarPath; if (find_directory(B_SYSTEM_DIRECTORY, &deskbarPath) == B_OK && deskbarPath.Append("Deskbar") == B_OK) { launch(kDeskbarSig, deskbarPath.Path()); } } BDeskbar deskbar; if (gInDeskbar || deskbar.HasItem (kDeskbarItemName)) deskbar.RemoveItem (kDeskbarItemName); else move_to_deskbar(deskbar); break; } case 'CPU ': { uint32 cpu; if (message->FindInt32("cpu", (int32*)&cpu) == B_OK) { bool last = true; for (unsigned int p = 0; p < gCPUcount; p++) { if (p != cpu && _kern_cpu_enabled(p)) { last = false; break; } } if (last) { alert = new BAlert(B_TRANSLATE("Info"), B_TRANSLATE("This is the last active processor...\n" "You can't turn it off!"), B_TRANSLATE("That's no Fun!"), NULL, NULL, B_WIDTH_AS_USUAL, B_WARNING_ALERT); alert->SetFlags(alert->Flags() | B_CLOSE_ON_ESCAPE); alert->Go(); } else _kern_set_cpu_enabled(cpu, !_kern_cpu_enabled(cpu)); } break; } case 'Schd': { int32 mode; if (message->FindInt32 ("mode", &mode) == B_OK) set_scheduler_mode(mode); break; } case B_ABOUT_REQUESTED: AboutRequested(); break; default: BView::MessageReceived(message); } }
void ProcessController::MessageReceived(BMessage *message) { team_id team; thread_id thread; BAlert *alert; char question[1000]; switch (message->what) { case 'Puls': Update (); DoDraw (false); break; case 'QtTm': if (message->FindInt32("team", &team) == B_OK) { resume_thread(spawn_thread(thread_quit_application, B_TRANSLATE("Quit application"), B_NORMAL_PRIORITY, (void*) team)); } break; case 'KlTm': if (message->FindInt32("team", &team) == B_OK) { info_pack infos; if (get_team_info(team, &infos.team_info) == B_OK) { get_team_name_and_icon(infos); snprintf(question, sizeof(question), B_TRANSLATE("Do you really want to kill the team \"%s\"?"), infos.team_name); alert = new BAlert(B_TRANSLATE("Please confirm"), question, B_TRANSLATE("Cancel"), B_TRANSLATE("Yes, kill this team!"), NULL, B_WIDTH_AS_USUAL, B_STOP_ALERT); alert->SetShortcut(0, B_ESCAPE); if (alert->Go()) kill_team(team); } else { alert = new BAlert(B_TRANSLATE("Info"), B_TRANSLATE("This team is already gone"B_UTF8_ELLIPSIS), B_TRANSLATE("Ok!"), NULL, NULL, B_WIDTH_AS_USUAL, B_STOP_ALERT); alert->SetShortcut(0, B_ESCAPE); alert->Go(); } } break; case 'KlTh': if (message->FindInt32("thread", &thread) == B_OK) { thread_info thinfo; if (get_thread_info(thread, &thinfo) == B_OK) { #if DEBUG_THREADS snprintf(question, sizeof(question), B_TRANSLATE("What do you want to do " "with the thread \"%s\"?"), thinfo.name); alert = new BAlert(B_TRANSLATE("Please confirm"), question, B_TRANSLATE("Cancel"), B_TRANSLATE("Debug this thread!"), B_TRANSLATE("Kill this thread!"), B_WIDTH_AS_USUAL, B_STOP_ALERT); #define KILL 2 #else snprintf(question, sizeof(question), B_TRANSLATE("Are you sure you want " "to kill the thread \"%s\"?"), thinfo.name); alert = new BAlert(B_TRANSLATE("Please confirm"), question, B_TRANSLATE("Cancel"), B_TRANSLATE("Kill this thread!"), NULL, B_WIDTH_AS_USUAL, B_STOP_ALERT); #define KILL 1 #endif alert->SetShortcut(0, B_ESCAPE); int r = alert->Go(); if (r == KILL) kill_thread(thread); #if DEBUG_THREADS else if (r == 1) { Tdebug_thead_param* param = new Tdebug_thead_param; param->thread = thread; if (thinfo.state == B_THREAD_WAITING) param->sem = thinfo.sem; else param->sem = -1; param->totalTime = thinfo.user_time+thinfo.kernel_time; resume_thread(spawn_thread(thread_debug_thread, B_TRANSLATE("Debug thread"), B_NORMAL_PRIORITY, param)); } #endif } else { alert = new BAlert(B_TRANSLATE("Info"), B_TRANSLATE("This thread is already gone"B_UTF8_ELLIPSIS), B_TRANSLATE("Ok!"), NULL, NULL, B_WIDTH_AS_USUAL, B_STOP_ALERT); alert->SetShortcut(0, B_ESCAPE); alert->Go(); } } break; case 'PrTh': if (message->FindInt32("thread", &thread) == B_OK) { long new_priority; if (message->FindInt32("priority", &new_priority) == B_OK) set_thread_priority(thread, new_priority); } break; case 'Trac': launch(kTrackerSig, "/boot/system/Tracker"); break; case 'Dbar': launch(kDeskbarSig, "/boot/system/Deskbar"); break; case 'Term': launch(kTerminalSig, "/boot/system/apps/Terminal"); break; case 'AlDb': { if (!be_roster->IsRunning(kDeskbarSig)) launch(kDeskbarSig, "/boot/system/Deskbar"); BDeskbar deskbar; if (gInDeskbar || deskbar.HasItem (kDeskbarItemName)) deskbar.RemoveItem (kDeskbarItemName); else move_to_deskbar(deskbar); break; } case 'CPU ': { int32 cpu; if (message->FindInt32 ("cpu", &cpu) == B_OK) { bool last = true; for (int p = 0; p < gCPUcount; p++) { if (p != cpu && _kern_cpu_enabled(p)) { last = false; break; } } if (last) { alert = new BAlert(B_TRANSLATE("Info"), B_TRANSLATE("This is the last active processor...\n" "You can't turn it off!"), B_TRANSLATE("That's no Fun!"), NULL, NULL, B_WIDTH_AS_USUAL, B_WARNING_ALERT); alert->SetShortcut(0, B_ESCAPE); alert->Go(); } else _kern_set_cpu_enabled(cpu, !_kern_cpu_enabled(cpu)); } break; } case B_ABOUT_REQUESTED: AboutRequested(); break; default: BView::MessageReceived(message); } }