37 lines
1.2 KiB
Python
37 lines
1.2 KiB
Python
from core.models.system.SystemState import SystemState
|
|
from core.models.enum_models import ProtocolChoice
|
|
# from core.controllers.ProfileController import ProfileController
|
|
from core.infrastructure.global_state import ProfileStateRepository
|
|
|
|
|
|
class SystemStateController:
|
|
@staticmethod
|
|
def get():
|
|
return SystemState.get()
|
|
|
|
@staticmethod
|
|
def exists():
|
|
return SystemState.exists()
|
|
|
|
@staticmethod
|
|
def create(profile_id: int, firewalled: bool, dns_set: bool, protocol: ProtocolChoice, process_id: int = None) -> SystemState:
|
|
current_state = SystemState(profile_id, firewalled, dns_set, protocol, process_id)
|
|
current_state.save()
|
|
|
|
# Sync to Repo
|
|
ProfileStateRepository().sync_system_state(current_state)
|
|
return current_state
|
|
|
|
@staticmethod
|
|
def update_or_create(system_state):
|
|
system_state.save()
|
|
# Sync to Repo
|
|
ProfileStateRepository().sync_system_state(system_state)
|
|
|
|
@staticmethod
|
|
def dissolve():
|
|
res = SystemState.dissolve()
|
|
# Sync to Repo: clear system ID
|
|
ProfileStateRepository().global_state.systemwide_profile_id = None
|
|
return res
|
|
|