GUI type checking for core's model changes, with Location & Operator being turned into SQLAlchemy models.

This commit is contained in:
SimplifiedPrivacy 2026-06-27 17:11:35 -04:00
parent 86348ce2e3
commit b13c355888
12 changed files with 134 additions and 12373 deletions

1
.gitignore vendored
View file

@ -1,3 +1,4 @@
.dev
may23.py may23.py
old_main.py old_main.py
.idea .idea

View file

@ -23,6 +23,7 @@ from core.errors.logger import logger as core_logger
core_logger.propagate = False core_logger.propagate = False
from gui.v2.infrastructure import orm
from gui.v2.infrastructure.navigator import Navigator from gui.v2.infrastructure.navigator import Navigator
from gui.v2.infrastructure.setup_observers import setup_observers from gui.v2.infrastructure.setup_observers import setup_observers
from gui.v2.infrastructure.connection_manager import ConnectionManager from gui.v2.infrastructure.connection_manager import ConnectionManager
@ -72,6 +73,9 @@ class CustomWindow(QMainWindow):
gui_dir = os.path.dirname(os.path.abspath(__file__)) gui_dir = os.path.dirname(os.path.abspath(__file__))
font_path = os.path.join(gui_dir, 'resources', 'fonts') font_path = os.path.join(gui_dir, 'resources', 'fonts')
# Get's SQLAlchemy going,
orm.start()
retro_gaming_path = os.path.join(font_path, 'retro-gaming.ttf') retro_gaming_path = os.path.join(font_path, 'retro-gaming.ttf')
font_id = QFontDatabase.addApplicationFont(retro_gaming_path) font_id = QFontDatabase.addApplicationFont(retro_gaming_path)
font_family = QFontDatabase.applicationFontFamilies(font_id)[0] font_family = QFontDatabase.applicationFontFamilies(font_id)[0]
@ -649,6 +653,10 @@ class CustomWindow(QMainWindow):
def closeEvent(self, event=None): def closeEvent(self, event=None):
core_logger.info("HydraVeil application closing") core_logger.info("HydraVeil application closing")
# Close SQLAlchemy,
orm.stop()
connected_profiles = self.connection_manager.get_connected_profiles() connected_profiles = self.connection_manager.get_connected_profiles()
if connected_profiles: if connected_profiles:
self.update_status('Profiles are still connected (disconnect flow lands in Chunk 9).') self.update_status('Profiles are still connected (disconnect flow lands in Chunk 9).')

View file

@ -0,0 +1,54 @@
fields:
- name: country_code
path: ['country', 'code']
required: true
- name: code # this is city code
path: ['code']
required: true
- name: id
path: ['id']
- name: country_name
path: ['country', 'name']
- name: name # this is CITY name
path: ['name']
- name: time_zone
path: ['time_zone', 'code']
- name: operator_id
path: ['operator_id']
required: true
- name: provider_name
path: ['provider', 'name']
- name: is_proxy_capable
path: ['is_proxy_capable']
- name: is_wireguard_capable
path: ['is_wireguard_capable']
required: true
- name: is_hysteria2_capable
path: ['is_hysteria2_capable']
- name: is_vless_capable
path: ['is_vless_capable']
# original version:
# locations.append((
# location['country']['code'],
# location['code'],
# location['id'],
# location['country']['name'],
# location['name'],
# location['time_zone']['code'],
# location['operator_id'],
# location['provider']['name'],
# location['is_proxy_capable'],
# location['is_wireguard_capable']))

View file

@ -0,0 +1,8 @@
fields:
- name: group_a_code
path: ['group_a', 'code']
- name: code
path: ['code']
- name: id
path: ['id']
required: true

View file

@ -0,0 +1,19 @@
fields:
- name: id
path: ['id']
required: true
- name: name
path: ['name']
- name: public_key # this is ed25519
path: ['public_key']
- name: nostr_public_key
path: ['nostr_public_key']
- name: nostr_profile_reference
path: ['nostr_profile_reference']
- name: nostr_attestation_event_reference
path: ['nostr_attestation', 'event_reference']

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,8 @@
from core.models.manage.session_management import init_session, close_session
def start():
init_session()
def stop():
close_session()

View file

@ -6,7 +6,6 @@ from core.observers.ProfileObserver import ProfileObserver
from core.observers.TicketObserver import TicketObserver from core.observers.TicketObserver import TicketObserver
from core.controllers.ApplicationController import ApplicationController from core.controllers.ApplicationController import ApplicationController
application_version_observer = ApplicationVersionObserver() application_version_observer = ApplicationVersionObserver()
client_observer = ClientObserver() client_observer = ClientObserver()
connection_observer = ConnectionObserver() connection_observer = ConnectionObserver()
@ -41,6 +40,7 @@ def setup_observers(update_status):
f'Downloading {ApplicationController.get(event.subject.application_code).name}')) f'Downloading {ApplicationController.get(event.subject.application_code).name}'))
application_version_observer.subscribe('download_progressing', lambda event: update_status( application_version_observer.subscribe('download_progressing', lambda event: update_status(
f'Downloading {ApplicationController.get(event.subject.application_code).name} {event.meta.get('progress'):.2f}%')) f'Downloading {ApplicationController.get(event.subject.application_code).name} {event.meta.get('progress'):.2f}%'))
application_version_observer.subscribe('downloaded', lambda event: update_status( application_version_observer.subscribe('downloaded', lambda event: update_status(
f'Downloaded {ApplicationController.get(event.subject.application_code).name}')) f'Downloaded {ApplicationController.get(event.subject.application_code).name}'))

View file

@ -68,6 +68,7 @@ class LocationPage(Page):
self.verification_button.setEnabled(False) self.verification_button.setEnabled(False)
def create_interface_elements(self, available_locations): def create_interface_elements(self, available_locations):
self.buttonGroup = QButtonGroup(self) self.buttonGroup = QButtonGroup(self)
self.buttons = [] self.buttons = []
@ -84,8 +85,15 @@ class LocationPage(Page):
boton.setIcon(QIcon(icon_path)) boton.setIcon(QIcon(icon_path))
fallback_path = os.path.join( fallback_path = os.path.join(
self.btn_path, "default_location_button.png") self.btn_path, "default_location_button.png")
if locations:
try:
provider = locations.operator.name if locations and hasattr( provider = locations.operator.name if locations and hasattr(
locations, 'operator') else None locations, 'operator') else None
except:
print("Assign none")
provider = None
if boton.icon().isNull(): if boton.icon().isNull():
if locations and hasattr(locations, 'country_name'): if locations and hasattr(locations, 'country_name'):
location_name = locations.country_name location_name = locations.country_name

View file

@ -213,12 +213,26 @@ class MenuPage(Page):
profiles_dict.keys()) profiles_dict.keys())
for idx in profile_ids: for idx in profile_ids:
try:
profile = profiles_dict[idx] profile = profiles_dict[idx]
new_profile = {} new_profile = {}
protocol = profile.connection.code protocol = profile.connection.code
# print(f"DEBUG: the type is = {type(profile.location)}, value = {profile.location}")
if isinstance(profile.location, dict):
# Fake/missing data — show placeholders from data,
country_code = profile.location.get("country_code", "na")
code = profile.location.get("code", "na")
location = f'{country_code}_{code}'
else:
# Proper Location object
location = f'{profile.location.country_code}_{profile.location.code}' location = f'{profile.location.country_code}_{profile.location.code}'
except:
import sys
print(f"idx: {idx}")
sys.exit("STOPPING TO READ PRINTS FOR IDX. this failed on getting the location data inside match_core_profiles")
new_profile['location'] = location new_profile['location'] = location
@ -255,6 +269,7 @@ class MenuPage(Page):
new_profile['name'] = profile.name new_profile['name'] = profile.name
new_dict[f'Profile_{idx}'] = new_profile new_dict[f'Profile_{idx}'] = new_profile
return new_dict return new_dict

View file

@ -229,9 +229,12 @@ class WorkerThread(QThread):
else: else:
ConfigurationController.set_connection('system') ConfigurationController.set_connection('system')
self.check_for_update() self.check_for_update()
locations = LocationController.get_all() locations = LocationController.get_all()
browser = ApplicationVersionController.get_all() browser = ApplicationVersionController.get_all()
print('the browser is: ', browser) # print('the browser is: ', browser)
all_browser_versions = [ all_browser_versions = [
f"{browser.application_code}:{browser.version_number}" for browser in browser if browser.supported] f"{browser.application_code}:{browser.version_number}" for browser in browser if browser.supported]
all_location_codes = [ all_location_codes = [

View file

@ -1,6 +1,6 @@
[project] [project]
name = "hydraveil-gui" name = "sp-hydra-veil-gui"
version = "2.4.2" version = "2.4.3"
authors = [ authors = [
{ name = "Simplified Privacy" }, { name = "Simplified Privacy" },
] ]