diff --git a/gui/v2/actions/disable_profiles.py b/gui/v2/actions/disable_profiles.py index cfa912e..9188822 100755 --- a/gui/v2/actions/disable_profiles.py +++ b/gui/v2/actions/disable_profiles.py @@ -1,3 +1,4 @@ +from core.services.profiles.profile_connections import disable_profile from core.models.session.SessionProfile import SessionProfile from core.models.system.SystemProfile import SystemProfile from core.controllers.ProfileController import ProfileController @@ -56,8 +57,8 @@ def disable_profile_via_controller(profile: BaseProfile): 'ticket_observer': ticket_observer, 'connection_observer': connection_observer, } - supported = inspect.signature(ProfileController.disable).parameters - ProfileController.disable( + supported = inspect.signature(disable_profile).parameters + disable_profile( profile, **{key: value for key, value in kwargs.items() if key in supported} ) diff --git a/gui/v2/actions/menu_coordinator.py b/gui/v2/actions/menu_coordinator.py index 33e5f40..fec3df7 100644 --- a/gui/v2/actions/menu_coordinator.py +++ b/gui/v2/actions/menu_coordinator.py @@ -1,4 +1,5 @@ # core +from core.services.profiles.profile_connections import enable_profile #, disable_profile from core.controllers.ProfileController import ProfileController from core.models.Configuration import Configuration, ConnectionChoice from core.services.subscriptions.subscriptions_by_protocol import get_profile_subscription, start_new_payment_cycle @@ -21,6 +22,8 @@ from gui.v2.infrastructure.setup_observers import ( profile_observer, ticket_observer, ) + + # generic from typing import Callable, Optional, Type @@ -132,8 +135,11 @@ def literally_connect( ignore_state_conflict: Optional[bool] = False ) -> Result: - # PROFILE + # Step 1: Get the Profile profile_result = get_profile(profile_id) + if not profile_result: + return Result(valid=False, error_type=ResultError.INVALID_INPUT, message="This profile does not match one of your configuration files.") + profile = profile_result.data # EXCEPTIONS @@ -143,8 +149,8 @@ def literally_connect( max_resolution = get_max_screensize() try: - final_result = ProfileController.enable( - profile, + final_result = enable_profile( + profile=profile, ignore=ignored, profile_observer=profile_observer, application_version_observer=application_version_observer, @@ -211,12 +217,19 @@ def _enable_error(error: Type[Exception], profile_id: int) -> Result: def _connect_profile(profile_id: int) -> Result: """Background Threaded Orchestration to Start a Connection""" - # Step 1: Subscription filter: + # # Step 1: Get the Profile + # profile_result = get_profile(profile_id) + # if not profile_result: + # return Result(valid=False, error_type=ResultError.INVALID_INPUT, message="This profile does not match one of your configuration files.") + + # profile = profile_result.data + + # Step 2: Subscription filter: sub_result = filter_subscription(profile_id=profile_id) if not sub_result.valid: return sub_result - # Step 2: Tor filter check: + # Step 3: Tor filter check: result = NOT_need_tor_warnings(profile_id=profile_id) if not result.valid: return result diff --git a/gui/v2/actions/profile_operations.py b/gui/v2/actions/profile_operations.py index 188fd64..4f34f32 100755 --- a/gui/v2/actions/profile_operations.py +++ b/gui/v2/actions/profile_operations.py @@ -8,6 +8,9 @@ from core.controllers.ClientController import ClientController from core.controllers.ConfigurationController import ConfigurationController from core.controllers.LocationController import LocationController from core.controllers.ProfileController import ProfileController + +from core.services.profiles.profile_connections import enable_profile, disable_profile, destroy_profile + from core.controllers.SubscriptionController import SubscriptionController from core.controllers.SyncController import new_sync from core.controllers.tickets.UseTicketController import do_we_use_a_random_ticket, get_unused_tickets, use_ticket @@ -219,7 +222,7 @@ def _enable(request: dict[str, Any], emit: MenuCallback, max_resolution: str | N print("doing the enable") try: - ProfileController.enable(profile, ignore=tuple(error for flag, error in ignored.items() if request.get(flag)), + enable_profile(profile, ignore=tuple(error for flag, error in ignored.items() if request.get(flag)), profile_observer=observer, application_version_observer=application_version_observer, connection_observer=connection_observer, ticket_observer=ticket_observer, max_resolution=max_resolution) @@ -277,7 +280,8 @@ def _delete(request: dict[str, Any]) -> MenuResult: if not request.get("confirmed"): return _confirmation(request, "delete", "Are you sure you want to delete this profile?", "Delete") profile = _require_profile(request["id"]) - ProfileController.destroy(profile, profile_observer, ticket_observer, connection_observer) + destroy_profile(profile, profile_observer, ticket_observer, connection_observer) + # ProfileController.destroy(profile, profile_observer, ticket_observer, connection_observer) return {"status": "success", "message": f"Profile {profile.id} deleted", "profile_id": profile.id, "refresh": True, "clear_selection": True}