diff --git a/gui/main_ui.py b/gui/main_ui.py index 5d34969..3ced655 100755 --- a/gui/main_ui.py +++ b/gui/main_ui.py @@ -24,7 +24,7 @@ from core.Errors import UnknownConnectionTypeError from core.errors.logger import logger as core_logger from core.models.Result import Result, ResultError from core.observers.Notifications import Notifications, EventType -from core.infrastructure.global_state_coordinator import quantity_connected +from core.infrastructure.state_management.global_state_controller import quantity_connected core_logger.propagate = False @@ -34,7 +34,7 @@ from gui.v2.infrastructure.thread_singleton import get_main_thread_dispatcher mainthread = get_main_thread_dispatcher() # Sync: -from gui.v2.actions.menu_coordinator import sync_now +from gui.v2.actions.menu_coordinator import sync_now, disconnect_active from gui.v2.actions.sync import generate_grid_positions from gui.v2.infrastructure import orm @@ -78,7 +78,6 @@ from gui.v2.actions.ticket_failure import ( clear_ticket_verification_failure, ) from gui.v2.actions.should_be_synchronized import should_be_synchronized -from gui.v2.actions.menu_coordinator import disconnect_active from gui.v2.ui.presenters.main_presenters import disconnect_message from gui.v2.ui.popups.confirmation_popup import ConfirmationPopup diff --git a/gui/v2/actions/error_handlers.py b/gui/v2/actions/error_handlers.py index 146536e..a3e2634 100644 --- a/gui/v2/actions/error_handlers.py +++ b/gui/v2/actions/error_handlers.py @@ -1,3 +1,6 @@ +from gui.v2.infrastructure.thread_singleton import get_main_thread_dispatcher +from core.infrastructure.state_management.state_poll_loop import PollState + from core.services.helpers.install_dependencies import setup_singbox_binary from core.utils.basic_operations.does_file_exist import does_file_exist from core.services.helpers.install_dependencies import SUDO_SINGBOX_LOCATION @@ -13,7 +16,11 @@ from gui.v2.infrastructure.take_plumbing_action import take_action def post_state_evaluation(result: Result): """Success path for initial state evaluation""" - print("Initial State evaluation complete.") + print("Initial State evaluation complete, starting to poll..") + poll_state = PollState(ui_dispatcher=get_main_thread_dispatcher()) + poll_state.start_polling() + + # if not result.valid and result.error_type == ResultError.ZOMBIE_SESSION and result.data: # active_session_profiles = result.data diff --git a/gui/v2/actions/menu_coordinator.py b/gui/v2/actions/menu_coordinator.py index 8a55b89..67e47f1 100644 --- a/gui/v2/actions/menu_coordinator.py +++ b/gui/v2/actions/menu_coordinator.py @@ -1,6 +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.infrastructure.state_management.global_state_controller import connected_system_profile_id, connected_session_profile_ids +from core.observers.Notifications import Notifications, EventType +# from core.controllers.SessionStateController import SessionStateController # from core.services.networking.systemwide.systemwide_wireguard import change_port_then_reconnect # from core.services.networking.ports.port_orchestrator import change_wg_port @@ -36,6 +37,7 @@ from gui.v2.actions.error_handlers import navigate_to_new_sub_page # generic from typing import Callable from functools import partial +import atexit @type_checker def get_profile(profile_id: int): @@ -349,14 +351,8 @@ def sync_now(ui_caller: Callable): connection_observer=connection_observer ) +# def finish(result: Result): +# print("goodbye") -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 +# atexit.register(disconnect_active(ui_caller=finish)) diff --git a/gui/v2/ui/pages/menu_page.py b/gui/v2/ui/pages/menu_page.py index b7b865c..7a68302 100755 --- a/gui/v2/ui/pages/menu_page.py +++ b/gui/v2/ui/pages/menu_page.py @@ -1,5 +1,6 @@ -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 core.infrastructure.state_management.global_state_controller import connected_session_profile_ids, verified_system_profile_id, is_systemwide_on, is_connected +from core.infrastructure.global_state_coordinator import evaluate_state_on_startup +from core.services.networking.general_connection_tools.disconnect import kill_profile_from_grave from gui.v2.infrastructure.take_plumbing_action import take_action from gui.v2.actions.error_handlers import post_state_evaluation @@ -20,7 +21,7 @@ from PyQt6.QtWidgets import ( QMessageBox, QPushButton, QScrollArea, QTextEdit, QVBoxLayout, QWidget, ) -from gui.v2.actions.menu_coordinator import connect_profile, disconnect_profile, kill_profile_from_grave +from gui.v2.actions.menu_coordinator import connect_profile, disconnect_profile 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 (