Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions build_support/localization.rs
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,10 @@ const MENU_STATUS_HELP_KEYS: &[(&str, &str)] = &[
"IDM_SERVICE_CONTINUE",
"crate::ui::resource_ids::IDM_SERVICE_CONTINUE",
),
(
"IDM_SERVICE_RESTART",
"crate::ui::resource_ids::IDM_SERVICE_RESTART",
),
(
"IDM_SERVICE_GOTOPROCESS",
"crate::ui::resource_ids::IDM_SERVICE_GOTOPROCESS",
Expand Down
3 changes: 3 additions & 0 deletions localization/de.toml
Original file line number Diff line number Diff line change
Expand Up @@ -330,6 +330,7 @@ ServicesPageTitle = "Dienste"
ServicesMenu = "&Dienste"
ServiceStart = "&Starten"
ServiceStop = "S&toppen"
ServiceRestart = "&Neu starten"
ServicePause = "&Anhalten"
ServiceContinue = "&Fortsetzen"
ServiceColumnName = "Name"
Expand All @@ -349,6 +350,7 @@ ServiceStartupManual = "Manuell"
ServiceStartupDisabled = "Deaktiviert"
ServiceStartFailed = "Der Dienst konnte nicht gestartet werden."
ServiceStopFailed = "Der Dienst konnte nicht beendet werden."
ServiceRestartFailed = "Der Dienst konnte nicht neu gestartet werden."
ServicePauseFailed = "Der Dienst konnte nicht angehalten werden."
ServiceContinueFailed = "Der Dienst konnte nicht fortgesetzt werden."
ServiceStateUnchanged = "Der Dienst hat den angeforderten Zustand nicht erreicht."
Expand Down Expand Up @@ -417,6 +419,7 @@ IDM_TASK_TILEVERT = "Tiles the windows vertically on the desktop"
IDM_TASK_BRINGTOFRONT = "Brings the window front, but does not switch to it"
IDM_SERVICE_START = "Startet den ausgewählten Dienst"
IDM_SERVICE_STOP = "Beendet den ausgewählten Dienst"
IDM_SERVICE_RESTART = "Startet den ausgewählten Dienst neu"
IDM_SERVICE_PAUSE = "Hält den ausgewählten Dienst an"
IDM_SERVICE_CONTINUE = "Setzt den ausgewählten Dienst fort"
IDM_SERVICE_GOTOPROCESS = "Wählt den Prozess des Diensts auf der Seite Prozesse aus"
Expand Down
3 changes: 3 additions & 0 deletions localization/en_us.toml
Original file line number Diff line number Diff line change
Expand Up @@ -337,6 +337,7 @@ ServicesPageTitle = "Services"
ServicesMenu = "&Services"
ServiceStart = "&Start"
ServiceStop = "&Stop"
ServiceRestart = "&Restart"
ServicePause = "&Pause"
ServiceContinue = "&Continue"
ServiceColumnName = "Name"
Expand All @@ -356,6 +357,7 @@ ServiceStartupManual = "Manual"
ServiceStartupDisabled = "Disabled"
ServiceStartFailed = "Unable to start the service."
ServiceStopFailed = "Unable to stop the service."
ServiceRestartFailed = "Unable to restart the service."
ServicePauseFailed = "Unable to pause the service."
ServiceContinueFailed = "Unable to continue the service."
ServiceStateUnchanged = "The service did not enter the requested state."
Expand Down Expand Up @@ -424,6 +426,7 @@ IDM_TASK_TILEVERT = "Tiles the windows vertically on the desktop"
IDM_TASK_BRINGTOFRONT = "Brings the window front, but does not switch to it"
IDM_SERVICE_START = "Starts the selected service"
IDM_SERVICE_STOP = "Stops the selected service"
IDM_SERVICE_RESTART = "Restarts the selected service"
IDM_SERVICE_PAUSE = "Pauses the selected service"
IDM_SERVICE_CONTINUE = "Continues the selected service"
IDM_SERVICE_GOTOPROCESS = "Selects the service process on the Processes page"
Expand Down
3 changes: 3 additions & 0 deletions localization/es.toml
Original file line number Diff line number Diff line change
Expand Up @@ -330,6 +330,7 @@ ServicesPageTitle = "Servicios"
ServicesMenu = "&Servicios"
ServiceStart = "&Iniciar"
ServiceStop = "&Detener"
ServiceRestart = "&Reiniciar"
ServicePause = "&Pausar"
ServiceContinue = "&Continuar"
ServiceColumnName = "Nombre"
Expand All @@ -349,6 +350,7 @@ ServiceStartupManual = "Manual"
ServiceStartupDisabled = "Deshabilitado"
ServiceStartFailed = "No se pudo iniciar el servicio."
ServiceStopFailed = "No se pudo detener el servicio."
ServiceRestartFailed = "No se pudo reiniciar el servicio."
ServicePauseFailed = "No se pudo pausar el servicio."
ServiceContinueFailed = "No se pudo continuar el servicio."
ServiceStateUnchanged = "El servicio no entró en el estado solicitado."
Expand Down Expand Up @@ -417,6 +419,7 @@ IDM_TASK_TILEVERT = "Tiles the windows vertically on the desktop"
IDM_TASK_BRINGTOFRONT = "Brings the window front, but does not switch to it"
IDM_SERVICE_START = "Inicia el servicio seleccionado"
IDM_SERVICE_STOP = "Detiene el servicio seleccionado"
IDM_SERVICE_RESTART = "Reinicia el servicio seleccionado"
IDM_SERVICE_PAUSE = "Pausa el servicio seleccionado"
IDM_SERVICE_CONTINUE = "Continúa el servicio seleccionado"
IDM_SERVICE_GOTOPROCESS = "Selecciona el proceso del servicio en la página Procesos"
Expand Down
3 changes: 3 additions & 0 deletions localization/fr.toml
Original file line number Diff line number Diff line change
Expand Up @@ -330,6 +330,7 @@ ServicesPageTitle = "Services"
ServicesMenu = "&Services"
ServiceStart = "&Démarrer"
ServiceStop = "&Arrêter"
ServiceRestart = "&Redémarrer"
ServicePause = "&Suspendre"
ServiceContinue = "&Continuer"
ServiceColumnName = "Nom"
Expand All @@ -349,6 +350,7 @@ ServiceStartupManual = "Manuel"
ServiceStartupDisabled = "Désactivé"
ServiceStartFailed = "Impossible de démarrer le service."
ServiceStopFailed = "Impossible d'arrêter le service."
ServiceRestartFailed = "Impossible de redémarrer le service."
ServicePauseFailed = "Impossible de suspendre le service."
ServiceContinueFailed = "Impossible de continuer le service."
ServiceStateUnchanged = "Le service n'a pas atteint l'état demandé."
Expand Down Expand Up @@ -417,6 +419,7 @@ IDM_TASK_TILEVERT = "Tiles the windows vertically on the desktop"
IDM_TASK_BRINGTOFRONT = "Brings the window front, but does not switch to it"
IDM_SERVICE_START = "Démarre le service sélectionné"
IDM_SERVICE_STOP = "Arrête le service sélectionné"
IDM_SERVICE_RESTART = "Redémarre le service sélectionné"
IDM_SERVICE_PAUSE = "Suspend le service sélectionné"
IDM_SERVICE_CONTINUE = "Reprend le service sélectionné"
IDM_SERVICE_GOTOPROCESS = "Sélectionne le processus du service dans la page Processus"
Expand Down
3 changes: 3 additions & 0 deletions localization/pt.toml
Original file line number Diff line number Diff line change
Expand Up @@ -330,6 +330,7 @@ ServicesPageTitle = "Serviços"
ServicesMenu = "&Serviços"
ServiceStart = "&Iniciar"
ServiceStop = "&Parar"
ServiceRestart = "&Reiniciar"
ServicePause = "&Pausar"
ServiceContinue = "&Continuar"
ServiceColumnName = "Nome"
Expand All @@ -349,6 +350,7 @@ ServiceStartupManual = "Manual"
ServiceStartupDisabled = "Desativado"
ServiceStartFailed = "Não foi possível iniciar o serviço."
ServiceStopFailed = "Não foi possível parar o serviço."
ServiceRestartFailed = "Não foi possível reiniciar o serviço."
ServicePauseFailed = "Não foi possível pausar o serviço."
ServiceContinueFailed = "Não foi possível continuar o serviço."
ServiceStateUnchanged = "O serviço não entrou no estado solicitado."
Expand Down Expand Up @@ -417,6 +419,7 @@ IDM_TASK_TILEVERT = "Tiles the windows vertically on the desktop"
IDM_TASK_BRINGTOFRONT = "Brings the window front, but does not switch to it"
IDM_SERVICE_START = "Inicia o serviço selecionado"
IDM_SERVICE_STOP = "Para o serviço selecionado"
IDM_SERVICE_RESTART = "Reinicia o serviço selecionado"
IDM_SERVICE_PAUSE = "Pausa o serviço selecionado"
IDM_SERVICE_CONTINUE = "Continua o serviço selecionado"
IDM_SERVICE_GOTOPROCESS = "Seleciona o processo do serviço na página Processos"
Expand Down
3 changes: 3 additions & 0 deletions localization/ru.toml
Original file line number Diff line number Diff line change
Expand Up @@ -330,6 +330,7 @@ ServicesPageTitle = "Службы"
ServicesMenu = "&Службы"
ServiceStart = "&Запустить"
ServiceStop = "&Остановить"
ServiceRestart = "Пере&запустить"
ServicePause = "&Приостановить"
ServiceContinue = "&Продолжить"
ServiceColumnName = "Имя"
Expand All @@ -349,6 +350,7 @@ ServiceStartupManual = "Вручную"
ServiceStartupDisabled = "Отключена"
ServiceStartFailed = "Не удалось запустить службу."
ServiceStopFailed = "Не удалось остановить службу."
ServiceRestartFailed = "Не удалось перезапустить службу."
ServicePauseFailed = "Не удалось приостановить службу."
ServiceContinueFailed = "Не удалось возобновить службу."
ServiceStateUnchanged = "Служба не перешла в запрошенное состояние."
Expand Down Expand Up @@ -417,6 +419,7 @@ IDM_TASK_TILEVERT = "Tiles the windows vertically on the desktop"
IDM_TASK_BRINGTOFRONT = "Brings the window front, but does not switch to it"
IDM_SERVICE_START = "Запускает выбранную службу"
IDM_SERVICE_STOP = "Останавливает выбранную службу"
IDM_SERVICE_RESTART = "Перезапускает выбранную службу"
IDM_SERVICE_PAUSE = "Приостанавливает выбранную службу"
IDM_SERVICE_CONTINUE = "Возобновляет выбранную службу"
IDM_SERVICE_GOTOPROCESS = "Выбирает процесс службы на странице процессов"
Expand Down
3 changes: 3 additions & 0 deletions localization/zh_cn.toml
Original file line number Diff line number Diff line change
Expand Up @@ -327,6 +327,7 @@ ServicesPageTitle = "服务"
ServicesMenu = "服务(&S)"
ServiceStart = "启动(&S)"
ServiceStop = "停止(&T)"
ServiceRestart = "重新启动(&R)"
ServicePause = "暂停(&P)"
ServiceContinue = "继续(&C)"
ServiceColumnName = "名称"
Expand All @@ -346,6 +347,7 @@ ServiceStartupManual = "手动"
ServiceStartupDisabled = "禁用"
ServiceStartFailed = "无法启动该服务。"
ServiceStopFailed = "无法停止该服务。"
ServiceRestartFailed = "无法重新启动该服务。"
ServicePauseFailed = "无法暂停该服务。"
ServiceContinueFailed = "无法继续该服务。"
ServiceStateUnchanged = "该服务没有进入请求的状态。"
Expand Down Expand Up @@ -414,6 +416,7 @@ IDM_TASK_TILEVERT = "Tiles the windows vertically on the desktop"
IDM_TASK_BRINGTOFRONT = "Brings the window front, but does not switch to it"
IDM_SERVICE_START = "启动所选服务"
IDM_SERVICE_STOP = "停止所选服务"
IDM_SERVICE_RESTART = "重新启动所选服务"
IDM_SERVICE_PAUSE = "暂停所选服务"
IDM_SERVICE_CONTINUE = "继续所选服务"
IDM_SERVICE_GOTOPROCESS = "在进程页选中该服务的进程"
Expand Down
3 changes: 3 additions & 0 deletions localization/zh_tw.toml
Original file line number Diff line number Diff line change
Expand Up @@ -327,6 +327,7 @@ ServicesPageTitle = "服務"
ServicesMenu = "服務(&S)"
ServiceStart = "啟動(&S)"
ServiceStop = "停止(&T)"
ServiceRestart = "重新啟動(&R)"
ServicePause = "暫停(&P)"
ServiceContinue = "繼續(&C)"
ServiceColumnName = "名稱"
Expand All @@ -346,6 +347,7 @@ ServiceStartupManual = "手動"
ServiceStartupDisabled = "已停用"
ServiceStartFailed = "無法啟動服務。"
ServiceStopFailed = "無法停止服務。"
ServiceRestartFailed = "無法重新啟動服務。"
ServicePauseFailed = "無法暫停服務。"
ServiceContinueFailed = "無法繼續服務。"
ServiceStateUnchanged = "服務沒有進入要求的狀態。"
Expand Down Expand Up @@ -414,6 +416,7 @@ IDM_TASK_TILEVERT = "Tiles the windows vertically on the desktop"
IDM_TASK_BRINGTOFRONT = "Brings the window front, but does not switch to it"
IDM_SERVICE_START = "啟動選取的服務"
IDM_SERVICE_STOP = "停止選取的服務"
IDM_SERVICE_RESTART = "重新啟動選取的服務"
IDM_SERVICE_PAUSE = "暫停選取的服務"
IDM_SERVICE_CONTINUE = "繼續選取的服務"
IDM_SERVICE_GOTOPROCESS = "在處理程序頁選取該服務的處理程序"
Expand Down
2 changes: 2 additions & 0 deletions src/app/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1180,6 +1180,7 @@ impl App {
.unwrap_or_default();
self.enable_menu_item(menu, IDM_SERVICE_START, commands.start);
self.enable_menu_item(menu, IDM_SERVICE_STOP, commands.stop);
self.enable_menu_item(menu, IDM_SERVICE_RESTART, commands.restart);
self.enable_menu_item(menu, IDM_SERVICE_PAUSE, commands.pause);
self.enable_menu_item(menu, IDM_SERVICE_CONTINUE, commands.continue_service);
self.enable_menu_item(menu, IDM_SERVICE_GOTOPROCESS, commands.go_to_process);
Expand Down Expand Up @@ -2306,6 +2307,7 @@ impl App {
}
IDM_SERVICE_START
| IDM_SERVICE_STOP
| IDM_SERVICE_RESTART
| IDM_SERVICE_PAUSE
| IDM_SERVICE_CONTINUE
| IDM_SERVICE_GOTOPROCESS => {
Expand Down
42 changes: 39 additions & 3 deletions src/pages/services/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
mod model;
mod sampler;

// 服务页列出本机 Win32 服务,并在后台 worker 上启动、停止、暂停或继续服务。
// 服务页列出本机 Win32 服务,并在后台 worker 上启动、停止、重新启动、暂停或继续服务。
// UI 线程只提交请求、维护列表选择和绘制。刷新保留服务名对应的选择、焦点和滚动位置。
// “转到进程”只使用带创建时间的 ProcIdentity;没有校验过的进程时该命令保持禁用。

Expand Down Expand Up @@ -48,8 +48,8 @@ use crate::ui::localization::{TextKey, service_column_titles, text};
use crate::ui::menus::build_popup_menu;
use crate::ui::resource_ids::{
IDC_SERVICELIST, IDM_SERVICE_CONTINUE, IDM_SERVICE_GOTOPROCESS, IDM_SERVICE_PAUSE,
IDM_SERVICE_START, IDM_SERVICE_STOP, IDR_SERVICE_CONTEXT, PWM_SERVICE_WORKER_COMPLETE,
WM_FINDPROC,
IDM_SERVICE_RESTART, IDM_SERVICE_START, IDM_SERVICE_STOP, IDR_SERVICE_CONTEXT,
PWM_SERVICE_WORKER_COMPLETE, WM_FINDPROC,
};

pub(crate) use self::model::ServiceCommandState;
Expand Down Expand Up @@ -172,6 +172,7 @@ impl ServicePageState {
state.start = false;
state.stop = false;
}
state.restart = state.stop;
state
}

Expand All @@ -185,6 +186,10 @@ impl ServicePageState {
self.request_control(ServiceControlAction::Stop);
true
}
IDM_SERVICE_RESTART => {
self.request_control(ServiceControlAction::Restart);
true
}
IDM_SERVICE_PAUSE => {
self.request_control(ServiceControlAction::Pause);
true
Expand Down Expand Up @@ -268,6 +273,7 @@ impl ServicePageState {
unsafe {
enable_command(popup.as_raw(), IDM_SERVICE_START, state.start);
enable_command(popup.as_raw(), IDM_SERVICE_STOP, state.stop);
enable_command(popup.as_raw(), IDM_SERVICE_RESTART, state.restart);
enable_command(popup.as_raw(), IDM_SERVICE_PAUSE, state.pause);
enable_command(popup.as_raw(), IDM_SERVICE_CONTINUE, state.continue_service);
enable_command(popup.as_raw(), IDM_SERVICE_GOTOPROCESS, state.go_to_process);
Expand Down Expand Up @@ -378,6 +384,7 @@ impl ServicePageState {
let allowed = match action {
ServiceControlAction::Start => state.start,
ServiceControlAction::Stop => state.stop,
ServiceControlAction::Restart => state.restart,
ServiceControlAction::Pause => state.pause,
ServiceControlAction::Continue => state.continue_service,
};
Expand Down Expand Up @@ -704,6 +711,7 @@ impl ServicePageState {
let summary = match action {
ServiceControlAction::Start => text(TextKey::ServiceStartFailed),
ServiceControlAction::Stop => text(TextKey::ServiceStopFailed),
ServiceControlAction::Restart => text(TextKey::ServiceRestartFailed),
ServiceControlAction::Pause => text(TextKey::ServicePauseFailed),
ServiceControlAction::Continue => text(TextKey::ServiceContinueFailed),
};
Expand Down Expand Up @@ -870,6 +878,34 @@ mod tests {
assert_eq!(page.last_refresh_error, Some(ERROR_BROKEN_PIPE));
}

#[test]
fn restart_is_enabled_exactly_when_stop_is_and_a_pending_control_disables_it() {
let mut page = ServicePageState {
rows: vec![service_row(
self::sampler::ServiceRecord {
service_name: "test-service".to_string(),
description: String::new(),
status: ServiceRunState::Running,
startup: ServiceStartupType::Manual,
accepts_stop: true,
accepts_pause_continue: false,
process: None,
},
"PID",
)],
selected_service: Some("test-service".to_string()),
..ServicePageState::default()
};
let enabled = page.command_state();
assert!(enabled.stop);
assert!(enabled.restart);
page.pending_control = Some(ServiceControlAction::Restart);
let pending = page.command_state();
assert!(!pending.stop);
assert!(!pending.restart);
assert!(!pending.start);
}

#[test]
fn a_queued_service_control_cannot_be_overwritten_by_another_selection() {
let (started_sender, started_receiver) = crossbeam_channel::bounded(1);
Expand Down
Loading