Singbox error handler coordinates a singbox setup

This commit is contained in:
SimplifiedPrivacy 2026-10-30 08:56:05 -04:00
parent ec90b2bf7a
commit 3315cffda3

View file

@ -1,12 +1,13 @@
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
from gui.v2.infrastructure.action_registry import register_action from gui.v2.infrastructure.action_registry import register_action
from core.infrastructure.global_state_coordinator import coordinate_evaluation from core.infrastructure.global_state_coordinator import coordinate_evaluation
from core.models.Result import Result, ResultError from core.models.Result import Result, ResultError
from core.errors.logger import logger from core.errors.logger import logger
from gui.v2.infrastructure.setup_observers import connection_observer from gui.v2.infrastructure.setup_observers import connection_observer, application_version_observer
# from gui.v2.infrastructure.ThreadSafetyTool import ThreadSafetyTool
# mainthread = ThreadSafetyTool()
from gui.v2.infrastructure.take_plumbing_action import take_action from gui.v2.infrastructure.take_plumbing_action import take_action
@ -36,3 +37,23 @@ def evaluate_bad_state():
@register_action(ResultError.SUBSCRIPTION) @register_action(ResultError.SUBSCRIPTION)
def navigate_to_new_sub_page() -> Result: def navigate_to_new_sub_page() -> Result:
return Result(valid=False, error_type=ResultError.NAVIGATE_TO, navigate_to="id") return Result(valid=False, error_type=ResultError.NAVIGATE_TO, navigate_to="id")
def generic_result_reciever(result: Result) -> Result:
if not result.valid:
return Result(valid=False, error_type=ResultError.NAVIGATE_TO, navigate_to="menu")
@register_action(ResultError.SETUP_SINGBOX)
def navigate_to_singbox_setup() -> Result:
if not does_file_exist(SUDO_SINGBOX_LOCATION):
logger.info("Installing Singbox Binary.")
take_action(
action=setup_singbox_binary,
ui_caller=generic_result_reciever,
application_version_observer=application_version_observer,
connection_observer=connection_observer
)
return Result(valid=False, error_type=ResultError.NAVIGATE_TO, navigate_to="networking_setup")