diff --git a/gui/v2/actions/menu_coordinator.py b/gui/v2/actions/menu_coordinator.py index e4bc4b5..8a55b89 100644 --- a/gui/v2/actions/menu_coordinator.py +++ b/gui/v2/actions/menu_coordinator.py @@ -1,7 +1,7 @@ # core +from core.controllers.SessionStateController import SessionStateController from core.infrastructure.global_state_coordinator import connected_system_profile_id, connected_session_profile_ids - # from core.services.networking.systemwide.systemwide_wireguard import change_port_then_reconnect # from core.services.networking.ports.port_orchestrator import change_wg_port from core.controllers.ConfigurationController import ConfigurationController @@ -177,7 +177,6 @@ def literally_connect(profile_id: int) -> Result: final_result = enable_profile( profile=profile, ignore=ignored, - asynchronous=False, profile_observer=profile_observer, application_version_observer=application_version_observer, connection_observer=connection_observer, @@ -187,6 +186,9 @@ def literally_connect(profile_id: int) -> Result: if final_result: return final_result else: + Notifications.emit(EventType.SESSION_PROFILE_DISABLE, profile.id) + notification = f"{profile.name} Disconnected." + Notifications.emit(EventType.STATUS_UPDATE, notification) return Result(valid=True) except Exception as error: return translate_error(error=error, profile_id=profile.id) @@ -347,3 +349,14 @@ def sync_now(ui_caller: Callable): connection_observer=connection_observer ) + +def kill_profile_from_grave(profile_id: int) -> Result: + killed = SessionStateController.scortched_earth_kill_profile(profile_id) + + if killed: + logger.info("psutil worked to kill it.") + return Result(valid=True) + else: + error_msg = "Even psutil scortched earth failed to kill the profile." + logger.error(error_msg) + return Result(valid=False, error_type=ResultError.STATE, message=error_msg) \ No newline at end of file diff --git a/gui/v2/ui/pages/menu_page.py b/gui/v2/ui/pages/menu_page.py index 1ec9ecc..b7b865c 100755 --- a/gui/v2/ui/pages/menu_page.py +++ b/gui/v2/ui/pages/menu_page.py @@ -1,6 +1,8 @@ from core.infrastructure.global_state_coordinator import connected_session_profile_ids, verified_system_profile_id, is_systemwide_on, is_connected, evaluate_state_on_startup + from gui.v2.infrastructure.take_plumbing_action import take_action from gui.v2.actions.error_handlers import post_state_evaluation + from core.controllers.ProfileController import ProfileController from core.models.BaseProfile import ProfileType from core.models.Result import Result, ResultError @@ -18,7 +20,7 @@ from PyQt6.QtWidgets import ( QMessageBox, QPushButton, QScrollArea, QTextEdit, QVBoxLayout, QWidget, ) -from gui.v2.actions.menu_coordinator import connect_profile, disconnect_profile +from gui.v2.actions.menu_coordinator import connect_profile, disconnect_profile, kill_profile_from_grave from gui.v2.actions.menu_profiles import find_verification_icon, get_profile_details, load_menu_profiles, menu_icons from gui.v2.actions.menu_tasks import ( @@ -887,7 +889,7 @@ class MenuPage(Page): def observers_subscribe(self): Notifications.subscribe(EventType.SESSION_PROFILE_ENABLE, self.turn_on_session_visuals) Notifications.subscribe(EventType.SESSION_PROFILE_DISABLE, self.turn_off_session_visuals) - Notifications.subscribe(EventType.SESSION_PROFILE_KILL, self.disconnect) + Notifications.subscribe(EventType.SESSION_PROFILE_KILL, kill_profile_from_grave) Notifications.subscribe(EventType.SYSTEM_ENABLE, self.turn_on_system_visuals) Notifications.subscribe(EventType.SYSTEM_DISABLE, self.turn_off_system_visuals) Notifications.subscribe(EventType.RESUME_ACTIONS, self.trigger_action_button_visuals)