Improved Systemwide feedback errors to GUI

This commit is contained in:
SimplifiedPrivacy 2026-07-27 19:54:22 -04:00
parent 19b3925bd1
commit a76ef50ed7
2 changed files with 22 additions and 8 deletions

View file

@ -91,13 +91,13 @@ class ProfileController:
if profile.is_system_profile(): if profile.is_system_profile():
try: try:
establish_connection(profile, ignore=ignore, connection_observer=connection_observer) establish_connection(profile, ignore=ignore, connection_observer=connection_observer)
if profile_observer is not None:
profile_observer.notify('enabled', profile)
except FirewallError: except FirewallError:
raise ProfileActivationError('Firewall could not be enabled.') raise
except ConnectionError: except ConnectionError:
raise ProfileActivationError('The profile could not be enabled.') raise ProfileActivationError('The profile could not be enabled.')
if profile_observer is not None:
profile_observer.notify('enabled', profile)
@staticmethod @staticmethod
def disable(profile: Union[SessionProfile, SystemProfile], explicitly: bool = True, ignore: tuple[type[Exception]] = (), profile_observer: ProfileObserver = None): def disable(profile: Union[SessionProfile, SystemProfile], explicitly: bool = True, ignore: tuple[type[Exception]] = (), profile_observer: ProfileObserver = None):
@ -117,6 +117,15 @@ class ProfileController:
session_state.dissolve(session_state.id) session_state.dissolve(session_state.id)
if profile_observer is not None:
profile_observer.notify('disabled', profile, dict(
explicitly=explicitly,
))
# ============================================================================
# SYSTEMWIDE
# ============================================================================
if profile.is_system_profile(): if profile.is_system_profile():
subjects = ProfileController.get_all().values() subjects = ProfileController.get_all().values()
@ -137,14 +146,20 @@ class ProfileController:
try: try:
terminate_system_connection() terminate_system_connection()
except ConnectionTerminationError:
raise ProfileDeactivationError('The profile could not be disabled.')
if profile_observer is not None: if profile_observer is not None:
profile_observer.notify('disabled', profile, dict( profile_observer.notify('disabled', profile, dict(
explicitly=explicitly, explicitly=explicitly,
)) ))
except ConnectionTerminationError:
raise ProfileDeactivationError('The profile could not be disabled.')
except FirewallError:
raise
# if profile_observer is not None:
# profile_observer.notify('disabled', profile, dict(
# explicitly=explicitly,
# ))
time.sleep(1.0) time.sleep(1.0)

View file

@ -233,7 +233,6 @@ def establish_system_connection(
2) Pass to private function 2) Pass to private function
3) Retry on failure 3) Retry on failure
""" """
# ================= VERIFY ENDPOINT ================= # ================= VERIFY ENDPOINT =================
if ConfigurationController.get_endpoint_verification_enabled(): if ConfigurationController.get_endpoint_verification_enabled():
verify_wireguard_endpoint(profile, ignore=ignore) verify_wireguard_endpoint(profile, ignore=ignore)