Compare commits
43 commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2e026c5287 | ||
|
|
3483b51200 | ||
| b444ff9218 | |||
| 1633562325 | |||
| b8d8689885 | |||
| 75bd51b8f8 | |||
|
|
ab23fc958e | ||
| d52ca4842c | |||
|
|
cfd9a92a24 | ||
| c3cf7e241e | |||
| 9cacab4d71 | |||
| 95e0f676df | |||
| baf7f7cec1 | |||
| 0a6280276f | |||
| 25489bf203 | |||
| e5c83e72b1 | |||
| 59cac90c58 | |||
| b536204048 | |||
| f8a09858cc | |||
| 50e9469178 | |||
| 332a84f187 | |||
| 8d08d71a48 | |||
|
|
95f753f1fb | ||
| 7cb9f903db | |||
| 716b62a465 | |||
| 2f0ffe0351 | |||
|
|
8b17b74e56 | ||
| 7cedecd281 | |||
|
|
91e657a06d | ||
| 7910586e1a | |||
|
|
42e06b71c2 | ||
|
|
7a8c4ded60 | ||
| 80c1d2c4e6 | |||
| c508dddcac | |||
| 33301b0da8 | |||
| b13c355888 | |||
|
|
28a9787658 | ||
| 86348ce2e3 | |||
|
|
e98f2c99d2 | ||
|
|
ed79aae5a3 | ||
| dc1182234a | |||
| 1c79df8433 | |||
| b50d0768b2 |
39 changed files with 2024 additions and 12762 deletions
17
.gitignore
vendored
17
.gitignore
vendored
|
|
@ -1,5 +1,18 @@
|
|||
may23.py
|
||||
old_main.py
|
||||
.dev
|
||||
.idea
|
||||
.venv
|
||||
dist
|
||||
gui/__pycache__/
|
||||
gui/__pycache__
|
||||
__pycache__
|
||||
*.pyc
|
||||
__pycache__/
|
||||
*.pyo
|
||||
*.pyd
|
||||
.Python
|
||||
*.egg-info/
|
||||
dist/
|
||||
build/
|
||||
venv/
|
||||
.env
|
||||
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
This is the second version with isolated UI elements from action functions.
|
||||
|
||||
# sp-hydra-veil-gui
|
||||
|
||||
The `sp-hydra-veil-gui` graphical user interface implements the `sp-hydra-veil-core` library.
|
||||
|
|
|
|||
12363
gui/___main__.py
12363
gui/___main__.py
File diff suppressed because it is too large
Load diff
205
gui/__main__.py
Normal file
205
gui/__main__.py
Normal file
|
|
@ -0,0 +1,205 @@
|
|||
from core.errors.logger import logger
|
||||
from core.models.manage.session_management import init_session, get_session, close_session, create_ALL_tables, create_ONLY_db_version_table, get_path, does_it_exist, does_db_version_table_exist
|
||||
from core.models.manage.version_check import check_database_compatibility, insert_new_version, get_custom_message
|
||||
from core.services.helpers.manage_assets import assets_folder_setup
|
||||
from core.Constants import Constants
|
||||
from core.models.DatabaseOperation import DatabaseOperation, DBErrorType
|
||||
from core.models.manage.migrations import migrate_sql
|
||||
from core.models.manage.clear_sql_model import clear_sql_model
|
||||
|
||||
# generic
|
||||
import os
|
||||
import sys
|
||||
from pathlib import Path
|
||||
|
||||
|
||||
# ============================================================================
|
||||
# UTIL FUNCTIONS AND RECOVERY UI
|
||||
# ============================================================================
|
||||
def clear_sync_cache():
|
||||
"""
|
||||
Purpose:
|
||||
Clear CachedSync
|
||||
If that fails, prompt for a database wipe.
|
||||
|
||||
Why:
|
||||
If they migrated, they have new schemas, but old data.
|
||||
The problem with that, is the newest CachedSync entry will fool the sync data functions into thinking they don't need to sync new data,
|
||||
Even though they do need to sync with the new schema.
|
||||
"""
|
||||
from core.models.orm_models.CachedSync import CachedSync
|
||||
result = clear_sql_model(CachedSync)
|
||||
if result:
|
||||
logger.info(f"[DB MANAGEMENT] After Migration cleared the CachedSync table: {result}.")
|
||||
else:
|
||||
custom_error = "There were issues with clearing the Sync Cache in your database. Please delete the old version and fetch the new public data (what locations, browsers, ect) This will NOT affect your profiles or browser sessions."
|
||||
recovery_dialog(custom_error, "CachedSync Issue")
|
||||
|
||||
def failed_migration(db_version_you_have):
|
||||
close_session() # shut down db connection
|
||||
custom_error = "There were issues with migrating your database. We transitioned to a new Database format for new features! Please delete the old version and fetch the new public data (what locations, browsers, ect) This will NOT affect your profiles or browser sessions."
|
||||
recovery_dialog(custom_error, db_version_you_have)
|
||||
|
||||
def recovery_dialog(custom_error, db_version_you_have):
|
||||
"""This ends the app by forcing them to delete the database, move it, or just quit."""
|
||||
|
||||
from gui.v2.ui.popups.Database_version import show_recovery_dialog
|
||||
choice = show_recovery_dialog({"message": custom_error, "db_version": db_version_you_have, "status": "version_mismatch"})
|
||||
logger.info(f"[DB MANAGEMENT] From the database error options, the user picked {choice}")
|
||||
|
||||
if choice == 1:
|
||||
if os.path.exists(database_path):
|
||||
os.remove(database_path)
|
||||
logger.info(f"[DB MANAGEMENT] Deleted the DB file at {database_path}. Now putting lock on for forced sync..")
|
||||
lock_file.touch()
|
||||
logger.info(f"[DB MANAGEMENT] Closing the app gracefully, for them to reboot..")
|
||||
sys.exit()
|
||||
|
||||
elif choice == 2:
|
||||
logger.info(f"[DB MANAGEMENT] User opted to move the DB file.")
|
||||
from gui.v2.ui.popups.pick_folder_to_move import launch_file_picker
|
||||
launch_file_picker(database_path)
|
||||
sys.exit()
|
||||
|
||||
else:
|
||||
logger.error(f"[DB MANAGEMENT] User opted to close the app WITHOUT wiping the database, even though they need to.")
|
||||
sys.exit()
|
||||
|
||||
# ============================================================================
|
||||
# ASSETS FOLDER
|
||||
# ============================================================================
|
||||
logger.info("Welcome, checking assets..")
|
||||
if not assets_folder_setup():
|
||||
from gui.v2.ui.popups.generic_error_popup import show_error
|
||||
custom_error = "Unable to Setup your Assets Folder. Please create an assets directory at ~/.local/share/hydra-veil/assets"
|
||||
show_error(custom_error, "Critical Error")
|
||||
|
||||
# ============================================================================
|
||||
# INITIALIZE DATABASE
|
||||
# ============================================================================
|
||||
lock_file = Path(f"{Constants.HV_DATA_HOME}/deleted_db.lock")
|
||||
logger.info("[DB MANAGEMENT] Starting DB init..")
|
||||
try:
|
||||
# Does the database exist?
|
||||
system_path = get_path()
|
||||
database_path = system_path / "storage.db"
|
||||
main_db_exists = does_it_exist(database_path)
|
||||
|
||||
# Setup operations on the main DB which create it
|
||||
init_session() # (engine, Session, _session all initialized from session_management)
|
||||
session = get_session()
|
||||
|
||||
# does the version checker table exist?
|
||||
version_table_exists = does_db_version_table_exist()
|
||||
except:
|
||||
logger.error("Critical Error with database initialization!")
|
||||
sys.exit()
|
||||
|
||||
# ============================================================================
|
||||
# LEGACY DATABASE CHECKS
|
||||
# ============================================================================
|
||||
migration_happened = False
|
||||
|
||||
# are they upgrading from a legacy version? that would mean the table existed, but not the version table,
|
||||
if not version_table_exists and main_db_exists:
|
||||
logger.info(f"[DB MANAGEMENT] We are dealing with a legacy database, we need to transition the user.")
|
||||
|
||||
migration = migrate_sql()
|
||||
|
||||
logger.info(f"[DB MANAGEMENT] Migration result is {migration.valid}.")
|
||||
if migration.valid:
|
||||
migration_happened = True
|
||||
force_sync = True
|
||||
clear_sync_cache()
|
||||
else:
|
||||
# THEN DISPLAY CHOICES AND RECOVERY UI
|
||||
db_version_you_have = "Old System"
|
||||
failed_migration(db_version_you_have)
|
||||
|
||||
# If they're still here, then if it's NOT a legacy version,
|
||||
|
||||
# and the new version table doesn't exist, then create it:
|
||||
if not version_table_exists:
|
||||
create_ONLY_db_version_table()
|
||||
|
||||
# ============================================================================
|
||||
# COMPARE DB VERISONS
|
||||
# ============================================================================
|
||||
compatability_dict = check_database_compatibility(session)
|
||||
reason = compatability_dict.get("reason", "error")
|
||||
is_compatable = compatability_dict.get("result", False)
|
||||
logger.info(f"[DB MANAGEMENT] The result of the check is {is_compatable} and the reason is {reason}")
|
||||
|
||||
# ============================================================================
|
||||
# IF THE VERSIONS MATCH
|
||||
# ============================================================================
|
||||
if is_compatable:
|
||||
try:
|
||||
made_tables = create_ALL_tables()
|
||||
# SCREEN FAILED TABLES
|
||||
if not made_tables:
|
||||
custom_error = "Critical Failure with starting the models of the database."
|
||||
logger.error(f"[DB MANAGEMENT] {custom_error}")
|
||||
close_session()
|
||||
from gui.v2.ui.popups.Database_version import show_recovery_dialog
|
||||
choice = show_recovery_dialog({"message": custom_error, "db_version": 0, "status": "cant_make"})
|
||||
logger.info(f"[DB MANAGEMENT] From the database error options, the user picked {choice}")
|
||||
sys.exit()
|
||||
|
||||
except:
|
||||
logger.info(f"[DB MANAGEMENT] create ALL tables failed. Running migrations...")
|
||||
migration = migrate_sql()
|
||||
logger.info(f"[DB MANAGEMENT] Results of migration is {migration.valid}")
|
||||
|
||||
if not migration.valid:
|
||||
db_version_you_have = 0
|
||||
failed_migration(db_version_you_have)
|
||||
|
||||
# ASSUME TABLES CREATED
|
||||
logger.info("[DB MANAGEMENT] Tables successfully made or initialized if pre-existing")
|
||||
|
||||
# UPDATE DATA
|
||||
did_it_insert = insert_new_version(session, Constants.DB_VERSION_THIS_APP_WANTS)
|
||||
if not did_it_insert:
|
||||
logger.error(f"[DB MANAGEMENT] Critical Failure with updating/inserting the new DB version into the database.")
|
||||
|
||||
# Load GUI either way:
|
||||
from gui.main_ui import start_ui
|
||||
|
||||
# If the user lacks a database, we want to force them to sync the new data, to avoid NoneType errors when enabling existing profiles,
|
||||
if reason == "no_database":
|
||||
logger.info(f"[DB MANAGEMENT] User had no database to begin with, so now we're entering GUI with sync on..")
|
||||
force_sync = True
|
||||
else:
|
||||
logger.info(f"[DB MANAGEMENT] Launcher is now passing it off to launch the main GUI window WITHOUT force sync..")
|
||||
if migration_happened:
|
||||
force_sync = True
|
||||
clear_sync_cache()
|
||||
else:
|
||||
force_sync = False
|
||||
|
||||
# if we deleted their DB, we want to force sync,
|
||||
if lock_file.exists():
|
||||
force_sync = True
|
||||
lock_file.unlink() # unlock for next time
|
||||
|
||||
# Start GUI either way:
|
||||
logger.info(f"[DB MANAGEMENT] Starting GUI..")
|
||||
start_ui(force_sync)
|
||||
|
||||
# ============================================================================
|
||||
# but IF the versions do NOT match
|
||||
# ============================================================================
|
||||
else:
|
||||
logger.error(f"[DB MANAGEMENT] The App is expecting a different DB version than the real database. The reason is {reason}")
|
||||
db_version_you_have = compatability_dict.get("old_db_version", "Error getting the Version")
|
||||
|
||||
# WHAT IS THE REASON?
|
||||
custom_error = get_custom_message(reason, compatability_dict)
|
||||
|
||||
# shut down db connection
|
||||
close_session()
|
||||
|
||||
# THEN DISPLAY CHOICES AND RECOVERY UI
|
||||
recovery_dialog(custom_error, db_version_you_have)
|
||||
|
||||
54
gui/assets/yaml_mappings/locations.yaml
Normal file
54
gui/assets/yaml_mappings/locations.yaml
Normal 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']))
|
||||
8
gui/assets/yaml_mappings/mapping_one.yaml
Normal file
8
gui/assets/yaml_mappings/mapping_one.yaml
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
fields:
|
||||
- name: group_a_code
|
||||
path: ['group_a', 'code']
|
||||
- name: code
|
||||
path: ['code']
|
||||
- name: id
|
||||
path: ['id']
|
||||
required: true
|
||||
19
gui/assets/yaml_mappings/operators.yaml
Normal file
19
gui/assets/yaml_mappings/operators.yaml
Normal 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']
|
||||
|
|
@ -1,11 +1,16 @@
|
|||
import logging
|
||||
import os
|
||||
import sys
|
||||
|
||||
_WORKSPACE_ROOT = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
||||
if _WORKSPACE_ROOT not in sys.path:
|
||||
sys.path.insert(0, _WORKSPACE_ROOT)
|
||||
|
||||
import logging
|
||||
import traceback
|
||||
|
||||
from PyQt6.QtWidgets import (
|
||||
QApplication, QMainWindow, QStackedWidget, QLabel, QPushButton,
|
||||
QDialog, QVBoxLayout, QHBoxLayout
|
||||
QDialog, QVBoxLayout, QHBoxLayout, QMessageBox
|
||||
)
|
||||
from PyQt6.QtGui import QPixmap, QFont, QFontDatabase
|
||||
from PyQt6 import QtGui
|
||||
|
|
@ -13,11 +18,16 @@ from PyQt6.QtCore import Qt, QTimer, QEvent
|
|||
|
||||
from core.Constants import Constants
|
||||
from core.controllers.ConfigurationController import ConfigurationController
|
||||
from core.controllers.ProfileController import ProfileController
|
||||
from core.Errors import UnknownConnectionTypeError
|
||||
from core.errors.logger import logger as core_logger
|
||||
|
||||
core_logger.propagate = False
|
||||
|
||||
from gui.v2.infrastructure.ThreadSafetyTool import ThreadSafetyTool
|
||||
mainthread = ThreadSafetyTool()
|
||||
|
||||
from gui.v2.infrastructure import orm
|
||||
from gui.v2.infrastructure.navigator import Navigator
|
||||
from gui.v2.infrastructure.setup_observers import setup_observers
|
||||
from gui.v2.infrastructure.connection_manager import ConnectionManager
|
||||
|
|
@ -58,14 +68,13 @@ from gui.v2.actions.should_be_synchronized import should_be_synchronized
|
|||
|
||||
|
||||
class CustomWindow(QMainWindow):
|
||||
def __init__(self):
|
||||
def __init__(self, force_sync=False):
|
||||
super().__init__()
|
||||
sys.excepthook = self._handle_exception
|
||||
self.setWindowFlags(Qt.WindowType.Window)
|
||||
|
||||
current_dir = os.path.dirname(os.path.abspath(__file__))
|
||||
parent_dir = os.path.dirname(current_dir)
|
||||
font_path = os.path.join(parent_dir, 'resources', 'fonts')
|
||||
gui_dir = os.path.dirname(os.path.abspath(__file__))
|
||||
font_path = os.path.join(gui_dir, 'resources', 'fonts')
|
||||
|
||||
retro_gaming_path = os.path.join(font_path, 'retro-gaming.ttf')
|
||||
font_id = QFontDatabase.addApplicationFont(retro_gaming_path)
|
||||
|
|
@ -101,10 +110,11 @@ class CustomWindow(QMainWindow):
|
|||
self.gui_cache_home, self.gui_config_home, self.gui_config_file)
|
||||
|
||||
self.btn_path = os.getenv('BTN_PATH', os.path.join(
|
||||
parent_dir, 'resources', 'images'))
|
||||
gui_dir, 'resources', 'images'))
|
||||
self.css_path = os.getenv('CSS_PATH', os.path.join(
|
||||
parent_dir, 'resources', 'styles'))
|
||||
gui_dir, 'resources', 'styles'))
|
||||
|
||||
self.force_sync = force_sync
|
||||
self.is_downloading = False
|
||||
self.current_profile_id = None
|
||||
self.connection_manager = ConnectionManager()
|
||||
|
|
@ -116,6 +126,9 @@ class CustomWindow(QMainWindow):
|
|||
self.animation_step = 0
|
||||
self.page_history = []
|
||||
self.log_path = None
|
||||
self._close_confirmation_pending = False
|
||||
self._close_disconnect_in_progress = False
|
||||
self._closing_after_disconnect = False
|
||||
|
||||
self.setFixedSize(800, 570)
|
||||
|
||||
|
|
@ -158,7 +171,8 @@ class CustomWindow(QMainWindow):
|
|||
self.animation_timer.timeout.connect(self.animate_toggle)
|
||||
self.check_logging()
|
||||
|
||||
self.navigator = Navigator(self.page_stack, self)
|
||||
self.navigator = Navigator(self)
|
||||
|
||||
self.page_stack.currentChanged.connect(self.page_changed)
|
||||
|
||||
self.show()
|
||||
|
|
@ -181,15 +195,51 @@ class CustomWindow(QMainWindow):
|
|||
self.navigator.navigate("welcome")
|
||||
else:
|
||||
self.navigator.navigate("menu")
|
||||
self.navigator.start_preload()
|
||||
if self.force_sync:
|
||||
QTimer.singleShot(0, self._prompt_force_sync)
|
||||
|
||||
|
||||
def _prompt_force_sync(self):
|
||||
"""
|
||||
Popup to encourage remote database sync
|
||||
|
||||
Context:
|
||||
Database loader in __main__ passes in the 'forced_sync' variable,
|
||||
If true, this popup encourages sync to avoid NoneType errors.
|
||||
"""
|
||||
connection = ConfigurationController.get_connection()
|
||||
box = QMessageBox(self)
|
||||
box.setWindowTitle("Data Update Needed")
|
||||
box.setText(
|
||||
"Please download the new data to avoid errors. You have profiles that need the data to function.\n\n"
|
||||
f"Connection type: {connection}")
|
||||
|
||||
# Apply styling
|
||||
# import it inside the function to reduce load on non-display flows.
|
||||
from gui.v2.ui.styles.css.main_ui_css import forced_sync_popup_style
|
||||
stylesheet = forced_sync_popup_style
|
||||
box.setStyleSheet(stylesheet)
|
||||
|
||||
# Add styled buttons
|
||||
sync_button = box.addButton("Ok Fetch", QMessageBox.ButtonRole.AcceptRole)
|
||||
sync_button.setCursor(Qt.CursorShape.PointingHandCursor)
|
||||
cancel_button = box.addButton("Cancel", QMessageBox.ButtonRole.RejectRole)
|
||||
cancel_button.setCursor(Qt.CursorShape.PointingHandCursor)
|
||||
box.setMinimumWidth(450) # button size
|
||||
box.exec()
|
||||
|
||||
if box.clickedButton() == sync_button:
|
||||
self.sync()
|
||||
|
||||
|
||||
def perform_update_check(self):
|
||||
from core.controllers.ClientController import ClientController
|
||||
update_available = ClientController.can_be_updated()
|
||||
|
||||
if update_available:
|
||||
menu_page = self.navigator.get_cached("menu")
|
||||
if menu_page is not None:
|
||||
menu_page.on_update_check_finished()
|
||||
self.navigator.update_if_cached(
|
||||
"menu", lambda p: p.on_update_check_finished())
|
||||
|
||||
def update_values(self, available_locations, available_browsers, status, is_tor, locations, all_browsers):
|
||||
if not status:
|
||||
|
|
@ -214,34 +264,27 @@ class CustomWindow(QMainWindow):
|
|||
for i, brw in enumerate(available_browsers)
|
||||
]
|
||||
|
||||
browser_page = self.navigator.get_cached("browser")
|
||||
if browser_page is not None:
|
||||
browser_page.create_interface_elements(available_browsers_list)
|
||||
self.navigator.update_if_cached(
|
||||
"browser", lambda p: p.create_interface_elements(available_browsers_list))
|
||||
self.navigator.update_if_cached(
|
||||
"location", lambda p: p.create_interface_elements(available_locations_list))
|
||||
self.navigator.update_if_cached(
|
||||
"hidetor", lambda p: p.create_interface_elements(available_locations_list))
|
||||
self.navigator.update_if_cached(
|
||||
"protocol", lambda p: p.enable_protocol_buttons())
|
||||
self.navigator.update_if_cached("menu", self._enable_menu_verification_icons)
|
||||
|
||||
location_page = self.navigator.get_cached("location")
|
||||
if location_page is not None:
|
||||
location_page.create_interface_elements(available_locations_list)
|
||||
|
||||
hidetor_page = self.navigator.get_cached("hidetor")
|
||||
if hidetor_page is not None:
|
||||
hidetor_page.create_interface_elements(available_locations_list)
|
||||
|
||||
protocol_page = self.navigator.get_cached("protocol")
|
||||
if protocol_page is not None:
|
||||
protocol_page.enable_protocol_buttons()
|
||||
|
||||
menu_page = self.navigator.get_cached("menu")
|
||||
if menu_page is not None:
|
||||
if hasattr(menu_page, 'refresh_profiles_data'):
|
||||
menu_page.refresh_profiles_data()
|
||||
if hasattr(menu_page, 'buttons'):
|
||||
for button in menu_page.buttons:
|
||||
parent = button.parent()
|
||||
if parent:
|
||||
verification_icons = parent.findChildren(QPushButton)
|
||||
for icon in verification_icons:
|
||||
if icon.geometry().width() == 20 and icon.geometry().height() == 20:
|
||||
icon.setEnabled(True)
|
||||
def _enable_menu_verification_icons(self, menu_page):
|
||||
if hasattr(menu_page, 'refresh_profiles_data'):
|
||||
menu_page.refresh_profiles_data()
|
||||
if hasattr(menu_page, 'buttons'):
|
||||
for button in menu_page.buttons:
|
||||
parent = button.parent()
|
||||
if parent:
|
||||
verification_icons = parent.findChildren(QPushButton)
|
||||
for icon in verification_icons:
|
||||
if icon.geometry().width() == 20 and icon.geometry().height() == 20:
|
||||
icon.setEnabled(True)
|
||||
|
||||
def sync(self):
|
||||
core_logger.info("User clicked sync button")
|
||||
|
|
@ -584,14 +627,95 @@ class CustomWindow(QMainWindow):
|
|||
|
||||
def closeEvent(self, event=None):
|
||||
core_logger.info("HydraVeil application closing")
|
||||
connected_profiles = self.connection_manager.get_connected_profiles()
|
||||
|
||||
if self._closing_after_disconnect:
|
||||
orm.stop()
|
||||
if event is not None:
|
||||
event.accept()
|
||||
return
|
||||
|
||||
if self._close_confirmation_pending or self._close_disconnect_in_progress:
|
||||
if event is not None:
|
||||
event.ignore()
|
||||
return
|
||||
|
||||
connected_profiles = self._get_enabled_profile_ids()
|
||||
if connected_profiles:
|
||||
self.update_status('Profiles are still connected (disconnect flow lands in Chunk 9).')
|
||||
if event is not None:
|
||||
event.accept()
|
||||
else:
|
||||
if event is not None:
|
||||
event.accept()
|
||||
event.ignore()
|
||||
self._show_close_disconnect_confirmation(connected_profiles)
|
||||
return
|
||||
|
||||
orm.stop()
|
||||
if event is not None:
|
||||
event.accept()
|
||||
|
||||
def _get_enabled_profile_ids(self):
|
||||
try:
|
||||
profiles = ProfileController.get_all()
|
||||
except Exception:
|
||||
return self.connection_manager.get_connected_profiles()
|
||||
|
||||
connected_profiles = []
|
||||
self.connection_manager._connected_profiles.clear()
|
||||
for profile_id, profile in profiles.items():
|
||||
try:
|
||||
if ProfileController.is_enabled(profile):
|
||||
connected_profiles.append(profile_id)
|
||||
self.connection_manager.add_connected_profile(profile_id)
|
||||
except Exception:
|
||||
pass
|
||||
return connected_profiles
|
||||
|
||||
def _show_close_disconnect_confirmation(self, connected_profiles):
|
||||
from gui.v2.ui.popups.confirmation_popup import ConfirmationPopup
|
||||
|
||||
self._close_confirmation_pending = True
|
||||
message = self._create_close_disconnect_message(connected_profiles)
|
||||
self.popup = ConfirmationPopup(
|
||||
self, message=message, action_button_text="Exit", cancel_button_text="Cancel")
|
||||
self.popup.setWindowModality(Qt.WindowModality.ApplicationModal)
|
||||
self.popup.setAttribute(Qt.WidgetAttribute.WA_DeleteOnClose)
|
||||
self.popup.finished.connect(
|
||||
lambda result: self._handle_close_disconnect_result(result, connected_profiles))
|
||||
self.popup.destroyed.connect(
|
||||
lambda *_: self._handle_close_disconnect_popup_closed())
|
||||
self.popup.show()
|
||||
|
||||
def _create_close_disconnect_message(self, connected_profiles):
|
||||
profile_numbers = ', '.join(str(profile_id)
|
||||
for profile_id in connected_profiles)
|
||||
is_are = "is" if len(connected_profiles) == 1 else "are"
|
||||
return f'Profile{"" if len(connected_profiles) == 1 else "s"} {profile_numbers} {is_are} still connected.\nAll connected profiles will be disconnected on exit.\nDo you want to proceed?'
|
||||
|
||||
def _handle_close_disconnect_result(self, result, connected_profiles):
|
||||
self._close_confirmation_pending = False
|
||||
if not result:
|
||||
return
|
||||
|
||||
self._close_disconnect_in_progress = True
|
||||
self.update_status('Disabling profiles...')
|
||||
self.worker_thread = WorkerThread(
|
||||
'DISABLE_ALL_PROFILES', profile_data=connected_profiles)
|
||||
self.worker_thread.text_output.connect(self.update_status)
|
||||
self.worker_thread.finished.connect(self._finish_close_disconnect)
|
||||
self.worker_thread.start()
|
||||
|
||||
def _handle_close_disconnect_popup_closed(self):
|
||||
if self._close_confirmation_pending:
|
||||
self._close_confirmation_pending = False
|
||||
self.popup = None
|
||||
|
||||
def _finish_close_disconnect(self, _ok=True):
|
||||
self._close_disconnect_in_progress = False
|
||||
connected_profiles = self._get_enabled_profile_ids()
|
||||
if connected_profiles:
|
||||
self.update_status('Could not disconnect all profiles. Exit canceled.')
|
||||
return
|
||||
|
||||
self.update_status('All profiles disabled. Bye!')
|
||||
self._closing_after_disconnect = True
|
||||
QTimer.singleShot(0, self.close)
|
||||
|
||||
def update_image(self, appearance_value="original"):
|
||||
image_path = os.path.join(self.btn_path, f"{appearance_value}.png")
|
||||
|
|
@ -612,7 +736,21 @@ class CustomWindow(QMainWindow):
|
|||
self.status_label.setStyleSheet(
|
||||
f"color: rgb(0, 255, 255); font-size: {font_size}px;")
|
||||
|
||||
@mainthread # wrapper of ThreadSafetyTool
|
||||
def update_status(self, text, clear=False):
|
||||
"""
|
||||
Purpose:
|
||||
Update the bottom left status bar
|
||||
|
||||
Features:
|
||||
Forced on the main Thread by ThreadSafetyTool
|
||||
|
||||
Depends on:
|
||||
v2.infrastructure.ThreadSafetyTool
|
||||
|
||||
Called by:
|
||||
v2.infrastructure.setup_observers (outside this class)
|
||||
"""
|
||||
if text is None:
|
||||
self._set_status_font_size(16)
|
||||
self.status_label.setText('Status:')
|
||||
|
|
@ -650,9 +788,9 @@ class CustomWindow(QMainWindow):
|
|||
if not self.has_shown_fast_mode_prompt():
|
||||
self.navigator.navigate("fast_mode_prompt")
|
||||
else:
|
||||
menu_page = self.navigator.get_cached("menu")
|
||||
if menu_page is not None and hasattr(menu_page, 'refresh_menu_buttons'):
|
||||
menu_page.refresh_menu_buttons()
|
||||
self.navigator.update_if_cached(
|
||||
"menu",
|
||||
lambda p: p.refresh_menu_buttons() if hasattr(p, 'refresh_menu_buttons') else None)
|
||||
self.navigator.navigate("menu")
|
||||
|
||||
def enable_marquee(self, text):
|
||||
|
|
@ -753,7 +891,7 @@ class CustomWindow(QMainWindow):
|
|||
self.page_history.append(current_page)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
def start_ui(force_sync):
|
||||
app = QApplication(sys.argv)
|
||||
window = CustomWindow()
|
||||
window = CustomWindow(force_sync=force_sync)
|
||||
sys.exit(app.exec())
|
||||
|
|
@ -1,35 +0,0 @@
|
|||
def interpret_key_results(result: dict) -> str:
|
||||
if not isinstance(result, dict):
|
||||
return "There was an error with the format of the reply from the operation."
|
||||
|
||||
# unpack results:
|
||||
valid = result.get('valid', False)
|
||||
comparison = result.get('comparison', 'error')
|
||||
error_msg = result.get('message', None)
|
||||
|
||||
# errors:
|
||||
if error_msg:
|
||||
if error_msg == "api_connection_issue":
|
||||
return "There was a connection error with connecting to the API."
|
||||
elif error_msg == "invalid_key":
|
||||
return "Your original public key is in an invalid format to begin with."
|
||||
else:
|
||||
return "Unknown Error."
|
||||
|
||||
# comparison:
|
||||
if comparison == "same":
|
||||
first_sentence = "The key you had locally matched what the server had also."
|
||||
elif comparison == "different":
|
||||
first_sentence = "Your local key was different than the server's key."
|
||||
else:
|
||||
first_sentence = "There was an error with the comparison."
|
||||
|
||||
# validity:
|
||||
if valid:
|
||||
second_sentence = "The signature now matches with the new key."
|
||||
else:
|
||||
second_sentence = "But the signature still does not match, even with the new key. If you prepare tickets anyway, they might not verify when used."
|
||||
|
||||
# final return
|
||||
final_msg = first_sentence + " " + second_sentence
|
||||
return final_msg
|
||||
BIN
gui/resources/images/networking_shield.png
Executable file
BIN
gui/resources/images/networking_shield.png
Executable file
Binary file not shown.
|
After Width: | Height: | Size: 1.6 KiB |
|
|
@ -35,6 +35,20 @@ def mark_fast_mode_prompt_shown(gui_config_file):
|
|||
save_gui_config(gui_config_file, config)
|
||||
|
||||
|
||||
def is_fast_registration_enabled(gui_config_file):
|
||||
config = load_gui_config(gui_config_file)
|
||||
if not config:
|
||||
return False
|
||||
return config.get("registrations", {}).get("fast_registration_enabled", False)
|
||||
|
||||
|
||||
def is_auto_sync_enabled(gui_config_file):
|
||||
config = load_gui_config(gui_config_file)
|
||||
if not config:
|
||||
return False
|
||||
return config.get("registrations", {}).get("auto_sync_enabled", False)
|
||||
|
||||
|
||||
def set_fast_mode_enabled(gui_config_file, enabled):
|
||||
config = load_gui_config(gui_config_file)
|
||||
if config is None:
|
||||
|
|
|
|||
151
gui/v2/actions/settings_data.py
Executable file
151
gui/v2/actions/settings_data.py
Executable file
|
|
@ -0,0 +1,151 @@
|
|||
import json
|
||||
import os
|
||||
|
||||
from core.Constants import Constants
|
||||
from core.controllers.ConfigurationController import ConfigurationController
|
||||
from core.controllers.PolicyController import PolicyController
|
||||
from core.controllers.ProfileController import ProfileController
|
||||
from core.services.networking.systemwide.systemwide_utils import get_firewall_setting
|
||||
|
||||
from gui.v2.actions.config import load_gui_config
|
||||
from gui.v2.actions.profile_order import normalize_profile_order
|
||||
from gui.v2.actions.ticket_failure import get_ticket_verification_failure
|
||||
|
||||
|
||||
|
||||
def read_firewall_setting():
|
||||
try:
|
||||
firewall_setting = get_firewall_setting()
|
||||
return firewall_setting
|
||||
except Exception:
|
||||
pass
|
||||
return False
|
||||
|
||||
|
||||
def read_systemwide_enabled():
|
||||
try:
|
||||
privilege_policy = PolicyController.get('privilege')
|
||||
if privilege_policy is not None:
|
||||
return PolicyController.is_instated(privilege_policy)
|
||||
except Exception:
|
||||
pass
|
||||
return False
|
||||
|
||||
|
||||
def read_bwrap_enabled():
|
||||
try:
|
||||
capability_policy = PolicyController.get('capability')
|
||||
if capability_policy is not None:
|
||||
return PolicyController.is_instated(capability_policy)
|
||||
except Exception:
|
||||
pass
|
||||
return False
|
||||
|
||||
|
||||
def prepare(gui_config_file):
|
||||
profiles = ProfileController.get_all()
|
||||
profile_order = normalize_profile_order(gui_config_file, profiles.keys())
|
||||
try:
|
||||
endpoint_verification_enabled = ConfigurationController.get_endpoint_verification_enabled()
|
||||
except Exception:
|
||||
endpoint_verification_enabled = False
|
||||
return {
|
||||
"profiles": profiles,
|
||||
"profile_order": profile_order,
|
||||
"current_connection": ConfigurationController.get_connection(),
|
||||
"endpoint_verification_enabled": endpoint_verification_enabled,
|
||||
"systemwide_enabled": read_systemwide_enabled(),
|
||||
"bwrap_enabled": read_bwrap_enabled(),
|
||||
"firewall_setting": read_firewall_setting(),
|
||||
"gui_config": load_gui_config(gui_config_file),
|
||||
"ticket_failure": get_ticket_verification_failure(gui_config_file),
|
||||
}
|
||||
|
||||
|
||||
def empty_payload():
|
||||
return {
|
||||
"profiles": {},
|
||||
"profile_order": [],
|
||||
"current_connection": None,
|
||||
"endpoint_verification_enabled": False,
|
||||
"systemwide_enabled": False,
|
||||
"bwrap_enabled": False,
|
||||
"firewall_setting": False,
|
||||
"gui_config": None,
|
||||
"ticket_failure": None,
|
||||
}
|
||||
|
||||
|
||||
def extract_endpoint_ip(profile):
|
||||
try:
|
||||
profile_path = Constants.HV_PROFILE_CONFIG_HOME + f'/{profile.id}'
|
||||
wg_conf_path = f'{profile_path}/wg.conf.bak'
|
||||
if not os.path.exists(wg_conf_path):
|
||||
return None
|
||||
with open(wg_conf_path, 'r') as f:
|
||||
content = f.read()
|
||||
for line in content.split('\n'):
|
||||
if line.strip().startswith('Endpoint = '):
|
||||
endpoint = line.strip().split(' = ')[1]
|
||||
return endpoint.split(':')[0]
|
||||
return None
|
||||
except Exception:
|
||||
return None
|
||||
|
||||
|
||||
def truncate_key(text, max_length=50):
|
||||
if not text or text == "N/A" or len(text) <= max_length:
|
||||
return text
|
||||
start_len = max_length // 2 - 2
|
||||
end_len = max_length // 2 - 2
|
||||
return text[:start_len] + "....." + text[-end_len:]
|
||||
|
||||
|
||||
def build_verification_view(profile):
|
||||
operator = None
|
||||
if profile and getattr(profile, 'location', None) and profile.location.operator:
|
||||
operator = profile.location.operator
|
||||
if not operator:
|
||||
return {
|
||||
"operator_name": "N/A",
|
||||
"nostr_public_key": "N/A",
|
||||
"hydraveil_public_key": "N/A",
|
||||
"nostr_attestation_event_reference": "N/A",
|
||||
}
|
||||
return {
|
||||
"operator_name": operator.name or "N/A",
|
||||
"nostr_public_key": operator.nostr_public_key or "N/A",
|
||||
"hydraveil_public_key": operator.public_key or "N/A",
|
||||
"nostr_attestation_event_reference": operator.nostr_attestation_event_reference or "N/A",
|
||||
}
|
||||
|
||||
|
||||
def build_subscription_view(profile):
|
||||
subscription = profile.subscription
|
||||
billing_code = str(subscription.billing_code)
|
||||
if hasattr(subscription, 'expires_at') and subscription.expires_at:
|
||||
expires_at = subscription.expires_at.strftime("%Y-%m-%d %H:%M:%S UTC")
|
||||
else:
|
||||
expires_at = "Not available"
|
||||
return {"billing_code": billing_code, "expires_at": expires_at}
|
||||
|
||||
|
||||
def format_ticket_failure_status(failure):
|
||||
if not failure:
|
||||
return "No saved verification failure. If ticket preparation fails validation, recovery data will appear here."
|
||||
failed_validations = failure.get("failed_validations", [])
|
||||
how_many_failed = failure.get("how_many_failed", len(failed_validations))
|
||||
updated_at = failure.get("updated_at", "unknown time")
|
||||
failed_text = ", ".join(str(item) for item in failed_validations)
|
||||
return (
|
||||
f"Saved verification failure: {how_many_failed} failed. "
|
||||
f"Failed validation indices: {failed_text}. Saved: {updated_at}"
|
||||
)
|
||||
|
||||
|
||||
def format_ticket_recovery_result(label, result):
|
||||
try:
|
||||
payload = json.dumps(result, indent=2, default=str)
|
||||
except TypeError:
|
||||
payload = str(result)
|
||||
return f"{label}:\n{payload}"
|
||||
21
gui/v2/infrastructure/ThreadSafetyTool.py
Executable file
21
gui/v2/infrastructure/ThreadSafetyTool.py
Executable file
|
|
@ -0,0 +1,21 @@
|
|||
import sys
|
||||
import time
|
||||
from PyQt6.QtWidgets import QApplication, QMainWindow, QVBoxLayout, QWidget, QPushButton, QLabel
|
||||
from PyQt6.QtCore import QObject, pyqtSignal, Qt
|
||||
|
||||
class ThreadSafetyTool(QObject):
|
||||
"""Marshal function calls to the main thread."""
|
||||
_signal = pyqtSignal(object, tuple, dict)
|
||||
|
||||
def __init__(self):
|
||||
super().__init__()
|
||||
self._signal.connect(self._execute, Qt.ConnectionType.QueuedConnection)
|
||||
|
||||
def _execute(self, func, args, kwargs):
|
||||
func(*args, **kwargs)
|
||||
|
||||
def __call__(self, func):
|
||||
"""Decorator that forces a function to run on the main thread."""
|
||||
def wrapper(*args, **kwargs):
|
||||
self._signal.emit(func, args, kwargs)
|
||||
return wrapper
|
||||
|
|
@ -1,33 +1,224 @@
|
|||
import importlib
|
||||
import time
|
||||
import traceback
|
||||
|
||||
from gui.v2.infrastructure.page_registry import PAGE_REGISTRY
|
||||
from PyQt6.QtCore import QObject, QTimer
|
||||
|
||||
from gui.v2.infrastructure.page_registry import (
|
||||
PAGE_REGISTRY,
|
||||
ASYNC_PREPARE,
|
||||
REGULAR_FLOW_ONLY,
|
||||
PRELOAD_ORDER,
|
||||
PRELOAD_SKIP,
|
||||
)
|
||||
from gui.v2.workers.page_data_worker import PageDataWorker
|
||||
from gui.v2.actions.flags import is_fast_registration_enabled
|
||||
from core.errors.logger import logger
|
||||
|
||||
|
||||
class Navigator:
|
||||
def __init__(self, page_stack, custom_window):
|
||||
self.page_stack = page_stack
|
||||
class Navigator(QObject):
|
||||
def __init__(self, custom_window):
|
||||
super().__init__()
|
||||
self.custom_window = custom_window
|
||||
self.page_stack = custom_window.page_stack
|
||||
self._instances = {}
|
||||
|
||||
self._preload_queue = []
|
||||
self._preload_total = 0
|
||||
self._preload_done = 0
|
||||
self._preload_failed = 0
|
||||
self._preload_skipped_runtime = 0
|
||||
self._preload_dispatched = 0
|
||||
self._preload_inflight = 0
|
||||
self._preload_workers = {}
|
||||
self._preload_summary_emitted = False
|
||||
self._preload_t_start = 0.0
|
||||
self._preload_timer = QTimer(self)
|
||||
self._preload_timer.setSingleShot(True)
|
||||
self._preload_timer.timeout.connect(self._preload_next)
|
||||
|
||||
def get_class(self, name):
|
||||
module_path, class_name = PAGE_REGISTRY[name]
|
||||
module = importlib.import_module(module_path)
|
||||
return getattr(module, class_name)
|
||||
|
||||
def _instantiate(self, name, prepared=None):
|
||||
cls = self.get_class(name)
|
||||
if name in ASYNC_PREPARE:
|
||||
return cls(self.page_stack, self.custom_window, prepared=prepared)
|
||||
return cls(self.page_stack, self.custom_window)
|
||||
|
||||
def register_instance(self, name, page):
|
||||
self.page_stack.addWidget(page)
|
||||
self._instances[name] = page
|
||||
|
||||
def navigate(self, name):
|
||||
page = self._instances.get(name)
|
||||
if page is None:
|
||||
if name not in PAGE_REGISTRY:
|
||||
self._warn_not_migrated(name)
|
||||
return
|
||||
module_path, class_name = PAGE_REGISTRY[name]
|
||||
module = importlib.import_module(module_path)
|
||||
cls = getattr(module, class_name)
|
||||
page = cls(self.page_stack, self.custom_window)
|
||||
self.page_stack.addWidget(page)
|
||||
self._instances[name] = page
|
||||
return None
|
||||
page = self._instantiate(name)
|
||||
self.register_instance(name, page)
|
||||
self.page_stack.setCurrentIndex(self.page_stack.indexOf(page))
|
||||
return page
|
||||
|
||||
def get_cached(self, name):
|
||||
return self._instances.get(name)
|
||||
|
||||
def update_if_cached(self, name, fn):
|
||||
page = self._instances.get(name)
|
||||
if page is not None:
|
||||
fn(page)
|
||||
return page
|
||||
|
||||
def _warn_not_migrated(self, name):
|
||||
try:
|
||||
self.custom_window.update_status(f"Page '{name}' not migrated yet.")
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
def _preload_one(self, name):
|
||||
if name in self._instances:
|
||||
logger.debug(f"[preload] {name:30s} SKIP (already cached)")
|
||||
return False
|
||||
if name not in PAGE_REGISTRY:
|
||||
logger.debug(f"[preload] {name:30s} SKIP (not in registry)")
|
||||
return False
|
||||
module_path, class_name = PAGE_REGISTRY[name]
|
||||
logger.debug(f"[preload] {name:30s} LOAD {module_path}.{class_name}")
|
||||
t0 = time.perf_counter()
|
||||
try:
|
||||
page = self._instantiate(name)
|
||||
self.register_instance(name, page)
|
||||
dt_ms = (time.perf_counter() - t0) * 1000.0
|
||||
logger.debug(f"[preload] {name:30s} OK ({dt_ms:6.1f} ms, "
|
||||
f"cached={len(self._instances)}, stack_size={self.page_stack.count()})")
|
||||
return True
|
||||
except Exception as e:
|
||||
dt_ms = (time.perf_counter() - t0) * 1000.0
|
||||
logger.debug(f"[preload] {name:30s} FAIL ({dt_ms:6.1f} ms) "
|
||||
f"{type(e).__name__}: {e}")
|
||||
traceback.print_exc()
|
||||
from core.errors.logger import logger as core_logger
|
||||
core_logger.warning(f"Background preload failed for '{name}': "
|
||||
f"{type(e).__name__}: {e}")
|
||||
return False
|
||||
|
||||
def start_preload(self, fast_mode=None):
|
||||
if fast_mode is None:
|
||||
fast_mode = is_fast_registration_enabled(self.custom_window.gui_config_file)
|
||||
self._preload_queue = [n for n in PRELOAD_ORDER if n not in PRELOAD_SKIP]
|
||||
skipped_regular = []
|
||||
if fast_mode:
|
||||
skipped_regular = [n for n in self._preload_queue if n in REGULAR_FLOW_ONLY]
|
||||
self._preload_queue = [n for n in self._preload_queue if n not in REGULAR_FLOW_ONLY]
|
||||
self._preload_total = len(self._preload_queue)
|
||||
self._preload_done = 0
|
||||
self._preload_failed = 0
|
||||
self._preload_skipped_runtime = 0
|
||||
self._preload_dispatched = 0
|
||||
self._preload_inflight = 0
|
||||
self._preload_summary_emitted = False
|
||||
self._preload_t_start = time.perf_counter()
|
||||
logger.debug(f"[preload] ============================================================")
|
||||
logger.debug(f"[preload] starting background preload: {self._preload_total} pages queued")
|
||||
logger.debug(f"[preload] order : {', '.join(self._preload_queue)}")
|
||||
logger.debug(f"[preload] skipped : {', '.join(sorted(PRELOAD_SKIP))} (unsafe init)")
|
||||
if fast_mode:
|
||||
logger.debug(f"[preload] fastmode: ON -> skipping regular-flow pages: "
|
||||
f"{', '.join(skipped_regular) if skipped_regular else '(none)'}")
|
||||
logger.debug(f"[preload] gap : 250 ms between loads, 700 ms initial delay")
|
||||
logger.debug(f"[preload] ============================================================")
|
||||
self._preload_timer.start(700)
|
||||
|
||||
def _preload_next(self):
|
||||
while self._preload_queue and self._preload_queue[0] in self._instances:
|
||||
skipped = self._preload_queue.pop(0)
|
||||
self._preload_skipped_runtime += 1
|
||||
logger.debug(f"[preload] {skipped:30s} SKIP (user navigated here first)")
|
||||
if not self._preload_queue:
|
||||
self._maybe_emit_preload_summary()
|
||||
return
|
||||
self._preload_dispatched += 1
|
||||
idx = self._preload_dispatched
|
||||
name = self._preload_queue.pop(0)
|
||||
logger.debug(f"[preload] ---- {idx}/{self._preload_total} ----")
|
||||
if name in ASYNC_PREPARE:
|
||||
self._dispatch_async_preload(name)
|
||||
else:
|
||||
ok = self._preload_one(name)
|
||||
if ok:
|
||||
self._preload_done += 1
|
||||
else:
|
||||
self._preload_failed += 1
|
||||
if self._preload_queue:
|
||||
self._preload_timer.start(250)
|
||||
else:
|
||||
self._maybe_emit_preload_summary()
|
||||
|
||||
def _prepare_page_data(self, name):
|
||||
module_path, class_name = PAGE_REGISTRY[name]
|
||||
module = importlib.import_module(module_path)
|
||||
cls = getattr(module, class_name)
|
||||
return cls.prepare_data(self.custom_window)
|
||||
|
||||
def _dispatch_async_preload(self, name):
|
||||
module_path, class_name = PAGE_REGISTRY[name]
|
||||
logger.debug(f"[preload] {name:30s} ASYNC {module_path}.{class_name}")
|
||||
worker = PageDataWorker(name, self._prepare_page_data, name)
|
||||
worker.data_ready.connect(self._on_preload_data_ready)
|
||||
worker.failed.connect(self._on_preload_failed)
|
||||
worker.finished.connect(lambda n=name: self._cleanup_preload_worker(n))
|
||||
self._preload_workers[name] = worker
|
||||
self._preload_inflight += 1
|
||||
worker.start()
|
||||
|
||||
def _on_preload_data_ready(self, name, payload):
|
||||
self._preload_inflight -= 1
|
||||
if name in self._instances:
|
||||
logger.debug(f"[preload] {name:30s} SKIP (already cached, async result dropped)")
|
||||
else:
|
||||
try:
|
||||
page = self._instantiate(name, prepared=payload)
|
||||
self.register_instance(name, page)
|
||||
self._preload_done += 1
|
||||
logger.debug(f"[preload] {name:30s} OK (async, cached={len(self._instances)}, "
|
||||
f"stack_size={self.page_stack.count()})")
|
||||
except Exception as e:
|
||||
self._preload_failed += 1
|
||||
logger.debug(f"[preload] {name:30s} FAIL (async build) {type(e).__name__}: {e}")
|
||||
self._maybe_emit_preload_summary()
|
||||
|
||||
def _on_preload_failed(self, name, error):
|
||||
self._preload_inflight -= 1
|
||||
logger.debug(f"[preload] {name:30s} FAIL (async prepare) {error}")
|
||||
if name not in self._instances:
|
||||
ok = self._preload_one(name)
|
||||
if ok:
|
||||
self._preload_done += 1
|
||||
else:
|
||||
self._preload_failed += 1
|
||||
self._maybe_emit_preload_summary()
|
||||
|
||||
def _cleanup_preload_worker(self, name):
|
||||
worker = self._preload_workers.pop(name, None)
|
||||
if worker is not None:
|
||||
worker.deleteLater()
|
||||
|
||||
def _maybe_emit_preload_summary(self):
|
||||
if self._preload_summary_emitted:
|
||||
return
|
||||
if not self._preload_queue and self._preload_inflight == 0:
|
||||
self._preload_summary_emitted = True
|
||||
self._emit_preload_summary()
|
||||
|
||||
def _emit_preload_summary(self):
|
||||
total_s = time.perf_counter() - self._preload_t_start
|
||||
logger.debug(f"[preload] ============================================================")
|
||||
logger.debug(f"[preload] complete: {self._preload_done} loaded, "
|
||||
f"{self._preload_failed} failed, "
|
||||
f"{self._preload_skipped_runtime} skipped (user beat us to it) "
|
||||
f"in {total_s:.2f}s")
|
||||
logger.debug(f"[preload] cached pages now: {sorted(self._instances.keys())}")
|
||||
logger.debug(f"[preload] ============================================================")
|
||||
|
|
|
|||
8
gui/v2/infrastructure/orm.py
Executable file
8
gui/v2/infrastructure/orm.py
Executable file
|
|
@ -0,0 +1,8 @@
|
|||
|
||||
from core.models.manage.session_management import init_session, close_session
|
||||
|
||||
def start():
|
||||
init_session()
|
||||
|
||||
def stop():
|
||||
close_session()
|
||||
|
|
@ -1,6 +1,7 @@
|
|||
PAGE_REGISTRY = {
|
||||
"blank": ("gui.v2.ui.pages._blank_page", "BlankPage"),
|
||||
"welcome": ("gui.v2.ui.pages.welcome_page", "WelcomePage"),
|
||||
"networking_setup": ("gui.v2.ui.pages.networking_setup_page", "NetworkingSetupPage"),
|
||||
"menu": ("gui.v2.ui.pages.menu_page", "MenuPage"),
|
||||
"protocol": ("gui.v2.ui.pages.protocol_page", "ProtocolPage"),
|
||||
"hidetor": ("gui.v2.ui.pages.hidetor_page", "HidetorPage"),
|
||||
|
|
@ -30,3 +31,57 @@ PAGE_REGISTRY = {
|
|||
"fast_registration": ("gui.v2.ui.pages.fast_registration_page", "FastRegistrationPage"),
|
||||
"fast_mode_prompt": ("gui.v2.ui.pages.fast_mode_prompt_page", "FastModePromptPage"),
|
||||
}
|
||||
|
||||
PRELOAD_SKIP = {
|
||||
"blank",
|
||||
"welcome",
|
||||
"payment_confirmed",
|
||||
"ticket_prep",
|
||||
}
|
||||
|
||||
ASYNC_PREPARE = {
|
||||
"settings",
|
||||
"fast_registration",
|
||||
"editor",
|
||||
}
|
||||
|
||||
REGULAR_FLOW_ONLY = {
|
||||
"protocol",
|
||||
"location",
|
||||
"hidetor",
|
||||
"residential",
|
||||
"tor",
|
||||
"connection",
|
||||
"screen",
|
||||
"browser",
|
||||
"wireguard",
|
||||
"sync_screen",
|
||||
}
|
||||
|
||||
PRELOAD_ORDER = [
|
||||
"settings",
|
||||
"editor",
|
||||
"ticket_or_billing_choice",
|
||||
"payment_details",
|
||||
"plan_picker",
|
||||
"ticket_crypto_picker",
|
||||
"duration_selection",
|
||||
"currency_selection",
|
||||
"policy_suggestion",
|
||||
"systemwide_prompt",
|
||||
"fast_mode_prompt",
|
||||
"fast_registration",
|
||||
"id",
|
||||
"protocol",
|
||||
"location",
|
||||
"hidetor",
|
||||
"residential",
|
||||
"tor",
|
||||
"connection",
|
||||
"screen",
|
||||
"browser",
|
||||
"resume",
|
||||
"wireguard",
|
||||
"install_system_package",
|
||||
"sync_screen",
|
||||
]
|
||||
|
|
|
|||
|
|
@ -6,7 +6,6 @@ from core.observers.ProfileObserver import ProfileObserver
|
|||
from core.observers.TicketObserver import TicketObserver
|
||||
from core.controllers.ApplicationController import ApplicationController
|
||||
|
||||
|
||||
application_version_observer = ApplicationVersionObserver()
|
||||
client_observer = ClientObserver()
|
||||
connection_observer = ConnectionObserver()
|
||||
|
|
@ -21,8 +20,12 @@ def setup_observers(update_status):
|
|||
profile_observer.subscribe(
|
||||
'destroyed', lambda event: update_status('Profile destroyed'))
|
||||
|
||||
# client_observer.subscribe(
|
||||
# 'synchronizing', lambda event: update_status('Sync in progress...'))
|
||||
|
||||
client_observer.subscribe(
|
||||
'synchronizing', lambda event: update_status('Sync in progress...'))
|
||||
'synchronizing', lambda event: update_status(f'{event.subject if event.subject else "Sync in progress..."}'))
|
||||
|
||||
client_observer.subscribe(
|
||||
'synchronized', lambda event: update_status('Sync complete'))
|
||||
|
||||
|
|
@ -33,10 +36,14 @@ def setup_observers(update_status):
|
|||
client_observer.subscribe('updated', lambda event: update_status(
|
||||
'Restart client to apply update.'))
|
||||
|
||||
client_observer.subscribe(
|
||||
'custom_message', lambda event: update_status(f'{event.subject if event.subject else "Error, check logs"}'))
|
||||
|
||||
application_version_observer.subscribe('downloading', lambda event: update_status(
|
||||
f'Downloading {ApplicationController.get(event.subject.application_code).name}'))
|
||||
application_version_observer.subscribe('download_progressing', lambda event: update_status(
|
||||
f'Downloading {ApplicationController.get(event.subject.application_code).name} {event.meta.get('progress'):.2f}%'))
|
||||
|
||||
application_version_observer.subscribe('downloaded', lambda event: update_status(
|
||||
f'Downloaded {ApplicationController.get(event.subject.application_code).name}'))
|
||||
|
||||
|
|
@ -46,12 +53,19 @@ def setup_observers(update_status):
|
|||
connection_observer.subscribe('tor_bootstrapping', lambda event: update_status(
|
||||
'Establishing Tor connection...'))
|
||||
|
||||
connection_observer.subscribe('tor_bootstrap_progressing', lambda event: update_status(
|
||||
f'Bootstrapping Tor {event.meta.get('progress'):.2f}%'))
|
||||
connection_observer.subscribe(
|
||||
'tor_bootstrap_progressing', lambda event: update_status(f'{event.subject if event.subject else "Tor Bootstrapping.."}'))
|
||||
|
||||
# original replaced version:
|
||||
# connection_observer.subscribe('tor_bootstrap_progressing', lambda event: update_status(
|
||||
# f'Bootstrapping Tor {event.meta.get('progress'):.2f}%'))
|
||||
|
||||
connection_observer.subscribe(
|
||||
'tor_bootstrapped', lambda event: update_status('Tor connection established.'))
|
||||
|
||||
client_observer.subscribe(
|
||||
'custom_message', lambda event: update_status(f'{event.subject if event.subject else ""}'))
|
||||
|
||||
ticket_observer.subscribe('connecting', lambda event: update_status('Connecting to ticket server...'))
|
||||
ticket_observer.subscribe('sync_done', lambda event: update_status('Ticket prices synced.'))
|
||||
ticket_observer.subscribe('waiting', lambda event: update_status('Waiting for payment...'))
|
||||
|
|
|
|||
|
|
@ -13,12 +13,22 @@ class Page(QWidget):
|
|||
self.btn_path = custom_window.btn_path
|
||||
self.name = name
|
||||
self.page_stack = page_stack
|
||||
self._prepared = None
|
||||
self.init_ui()
|
||||
self.selected_profiles = []
|
||||
self.selected_wireguard = []
|
||||
self.selected_residential = []
|
||||
self.buttons = []
|
||||
|
||||
@staticmethod
|
||||
def prepare_data(custom_window):
|
||||
return None
|
||||
|
||||
def _prepared_value(self, key, loader):
|
||||
if self._prepared is not None and key in self._prepared:
|
||||
return self._prepared[key]
|
||||
return loader()
|
||||
|
||||
def add_selected_profile(self, profile):
|
||||
self.selected_profiles.clear()
|
||||
self.selected_wireguard.clear()
|
||||
|
|
|
|||
|
|
@ -10,16 +10,19 @@ from PyQt6 import QtCore, QtGui
|
|||
|
||||
from core.controllers.ProfileController import ProfileController
|
||||
from core.controllers.LocationController import LocationController
|
||||
from core.models.Result import Result, ResultError
|
||||
from core.controllers.profile_state.update_profile import update_profile
|
||||
|
||||
from gui.v2.ui.pages.Page import Page
|
||||
from gui.v2.ui.pages.browser_page import BrowserPage
|
||||
from gui.v2.ui.pages.location_page import LocationPage
|
||||
from gui.v2.ui.pages.screen_page import ScreenPage
|
||||
from gui.v2.ui.popups.confirmation_popup import ConfirmationPopup
|
||||
from gui.v2.workers.page_data_worker import PageDataWorker
|
||||
|
||||
|
||||
class EditorPage(Page):
|
||||
def __init__(self, page_stack, main_window):
|
||||
def __init__(self, page_stack, main_window, prepared=None):
|
||||
super().__init__("Editor", page_stack, main_window)
|
||||
self.page_stack = page_stack
|
||||
self.update_status = main_window
|
||||
|
|
@ -80,6 +83,13 @@ class EditorPage(Page):
|
|||
self.brow_disp.hide()
|
||||
self.brow_disp.lower()
|
||||
|
||||
self._prefetched_profiles = prepared
|
||||
self._editor_workers = set()
|
||||
|
||||
@staticmethod
|
||||
def prepare_data(custom_window):
|
||||
return ProfileController.get_all()
|
||||
|
||||
def _selected_profiles_str(self):
|
||||
menu_page = self.find_menu_page()
|
||||
if menu_page is not None and menu_page.selected_profiles:
|
||||
|
|
@ -117,8 +127,43 @@ class EditorPage(Page):
|
|||
def showEvent(self, event):
|
||||
super().showEvent(event)
|
||||
self.res_hint_shown = False
|
||||
if self._selected_profile_in_cache():
|
||||
self.extraccion()
|
||||
return
|
||||
worker = PageDataWorker("editor", EditorPage.prepare_data, self.custom_window)
|
||||
worker.data_ready.connect(
|
||||
lambda name, profiles: self._on_editor_data_ready(profiles))
|
||||
worker.failed.connect(
|
||||
lambda name, error: self._on_editor_data_failed(error))
|
||||
worker.finished.connect(
|
||||
lambda w=worker: self._cleanup_editor_worker(w))
|
||||
self._editor_workers.add(worker)
|
||||
worker.start()
|
||||
|
||||
def _on_editor_data_ready(self, profiles):
|
||||
self._prefetched_profiles = profiles
|
||||
self.extraccion()
|
||||
|
||||
def _on_editor_data_failed(self, error):
|
||||
self.update_status.update_status(f"Editor data load failed: {error}")
|
||||
self.extraccion()
|
||||
|
||||
def _cleanup_editor_worker(self, worker):
|
||||
self._editor_workers.discard(worker)
|
||||
worker.deleteLater()
|
||||
|
||||
def _selected_profile_in_cache(self):
|
||||
if not self._prefetched_profiles:
|
||||
return False
|
||||
selected = self._selected_profiles_str()
|
||||
if not selected:
|
||||
return False
|
||||
try:
|
||||
profile_id = int(selected.split('_')[1])
|
||||
except (IndexError, ValueError):
|
||||
return False
|
||||
return profile_id in self._prefetched_profiles
|
||||
|
||||
def extraccion(self):
|
||||
self.data_profile = {}
|
||||
for label in self.labels:
|
||||
|
|
@ -131,7 +176,10 @@ class EditorPage(Page):
|
|||
selected_profiles_str = self._selected_profiles_str()
|
||||
menu_page = self.find_menu_page()
|
||||
if menu_page:
|
||||
new_profiles = ProfileController.get_all()
|
||||
if self._prefetched_profiles is not None:
|
||||
new_profiles = self._prefetched_profiles
|
||||
else:
|
||||
new_profiles = ProfileController.get_all()
|
||||
self.profiles_data = menu_page.match_core_profiles(
|
||||
profiles_dict=new_profiles)
|
||||
self.data_profile = self.profiles_data[selected_profiles_str].copy(
|
||||
|
|
@ -746,51 +794,27 @@ class EditorPage(Page):
|
|||
|
||||
self.temp_changes.pop(selected_profiles_str, None)
|
||||
self.original_values.pop(selected_profiles_str, None)
|
||||
self._prefetched_profiles = None
|
||||
|
||||
def update_core_profiles(self, key, new_value):
|
||||
profile = ProfileController.get(
|
||||
int(self.update_status.current_profile_id))
|
||||
self.update_res = False
|
||||
if key == 'dimentions':
|
||||
profile.resolution = new_value
|
||||
self.update_res = True
|
||||
profile_id = int(self.update_status.current_profile_id)
|
||||
|
||||
elif key == 'name':
|
||||
profile.name = new_value
|
||||
# Sends to core directly,
|
||||
result = update_profile(profile_id, key, new_value)
|
||||
|
||||
elif key == 'connection':
|
||||
if new_value == 'tor':
|
||||
profile.connection.code = new_value
|
||||
profile.connection.masked = True
|
||||
elif new_value == 'just proxy':
|
||||
profile.connection.code = 'system'
|
||||
profile.connection.masked = True
|
||||
else:
|
||||
self.update_status.update_status(
|
||||
'System wide profiles not supported atm')
|
||||
if result.valid:
|
||||
self.update_status.update_status(
|
||||
f'Updated profile {profile_id}')
|
||||
|
||||
elif key == 'browser':
|
||||
browser_type, browser_version = new_value.split(':', 1)
|
||||
profile.application_version.application_code = browser_type
|
||||
profile.application_version.version_number = browser_version
|
||||
if key == "resolution":
|
||||
self.update_res = True
|
||||
|
||||
elif key == 'protocol':
|
||||
if self.data_profile.get('connection') == 'system-wide':
|
||||
if result.data == "edit_to_session":
|
||||
self.edit_to_session()
|
||||
else:
|
||||
profile.connection.code = 'wireguard' if new_value == 'wireguard' else 'tor'
|
||||
profile.connection.masked = False if new_value == 'wireguard' else True
|
||||
|
||||
else:
|
||||
location = self.connection_manager.get_location_info(new_value)
|
||||
self.update_status.update_status(result.message)
|
||||
|
||||
if location:
|
||||
profile.location.code = location.code
|
||||
profile.location.country_code = location.country_code
|
||||
profile.location.time_zone = location.time_zone
|
||||
profile.subscription = None
|
||||
|
||||
ProfileController.update(profile)
|
||||
|
||||
def edit_to_session(self):
|
||||
id = int(self.update_status.current_profile_id)
|
||||
|
|
|
|||
|
|
@ -15,11 +15,12 @@ from gui.v2.ui.pages.Page import Page
|
|||
from gui.v2.ui.pages.browser_page import BrowserPage
|
||||
from gui.v2.ui.pages.location_page import LocationPage
|
||||
from gui.v2.ui.pages.location_verification_page import LocationVerificationPage
|
||||
from gui.v2.workers.page_data_worker import PageDataWorker
|
||||
from gui.v2.workers.worker_thread import WorkerThread
|
||||
|
||||
|
||||
class FastRegistrationPage(Page):
|
||||
def __init__(self, page_stack, main_window):
|
||||
def __init__(self, page_stack, main_window, prepared=None):
|
||||
super().__init__("FastRegistration", page_stack, main_window)
|
||||
self.page_stack = page_stack
|
||||
self.update_status = main_window
|
||||
|
|
@ -73,9 +74,15 @@ class FastRegistrationPage(Page):
|
|||
'resolution': '1024x760'
|
||||
}
|
||||
self.res_index = 1
|
||||
self._prefetched_profiles = prepared
|
||||
self._fast_reg_workers = set()
|
||||
|
||||
self.initialize_default_selections()
|
||||
|
||||
@staticmethod
|
||||
def prepare_data(custom_window):
|
||||
return ProfileController.get_all()
|
||||
|
||||
def initialize_default_selections(self):
|
||||
if not self.selected_values['location']:
|
||||
locations = self.connection_manager.get_location_list()
|
||||
|
|
@ -107,6 +114,24 @@ class FastRegistrationPage(Page):
|
|||
super().showEvent(event)
|
||||
self.initialize_default_selections()
|
||||
self.create_interface_elements()
|
||||
self._start_profiles_prefetch()
|
||||
|
||||
def _start_profiles_prefetch(self):
|
||||
worker = PageDataWorker(
|
||||
"fast_registration", FastRegistrationPage.prepare_data, self.custom_window)
|
||||
worker.data_ready.connect(
|
||||
lambda name, profiles: self._on_profiles_prefetched(profiles))
|
||||
worker.finished.connect(
|
||||
lambda w=worker: self._cleanup_fast_reg_worker(w))
|
||||
self._fast_reg_workers.add(worker)
|
||||
worker.start()
|
||||
|
||||
def _on_profiles_prefetched(self, profiles):
|
||||
self._prefetched_profiles = profiles
|
||||
|
||||
def _cleanup_fast_reg_worker(self, worker):
|
||||
self._fast_reg_workers.discard(worker)
|
||||
worker.deleteLater()
|
||||
|
||||
def create_interface_elements(self):
|
||||
for label in self.labels:
|
||||
|
|
@ -728,7 +753,7 @@ class FastRegistrationPage(Page):
|
|||
self.update_status.update_status('Invalid location selected')
|
||||
return
|
||||
|
||||
profiles = ProfileController.get_all()
|
||||
profiles = self._prefetched_profiles if self._prefetched_profiles is not None else ProfileController.get_all()
|
||||
profile_id = self.get_next_available_profile_id(profiles)
|
||||
profile_data_for_resume = {
|
||||
'id': profile_id,
|
||||
|
|
@ -762,7 +787,7 @@ class FastRegistrationPage(Page):
|
|||
|
||||
connection_type = 'tor' if profile_data['connection'] == 'tor' else 'system'
|
||||
|
||||
profiles = ProfileController.get_all()
|
||||
profiles = self._prefetched_profiles if self._prefetched_profiles is not None else ProfileController.get_all()
|
||||
profile_id = self.get_next_available_profile_id(profiles)
|
||||
profile_data_for_resume = {
|
||||
'id': profile_id,
|
||||
|
|
|
|||
|
|
@ -2,13 +2,16 @@ import os
|
|||
import re
|
||||
|
||||
from PyQt6.QtWidgets import (
|
||||
QButtonGroup, QFrame, QLabel, QPushButton, QTextEdit,
|
||||
QButtonGroup, QFrame, QLabel, QMessageBox, QPushButton, QTextEdit,
|
||||
)
|
||||
from PyQt6.QtGui import QIcon, QPixmap
|
||||
from PyQt6.QtCore import Qt
|
||||
from PyQt6 import QtCore
|
||||
|
||||
from core.services.payment_phase.do_we_have_billing_id import do_we_have_billing_id
|
||||
|
||||
from gui.v2.ui.pages.Page import Page
|
||||
from gui.v2.ui.popups.message_box import style_message_box, mark_confirm_button
|
||||
|
||||
|
||||
HOW_MANY_PROFILES_DEFAULT = 6
|
||||
|
|
@ -150,11 +153,44 @@ class IdPage(Page):
|
|||
self.custom_window.navigator.navigate("duration_selection")
|
||||
|
||||
def go_multiple_profiles(self):
|
||||
billing_id = do_we_have_billing_id()
|
||||
if billing_id:
|
||||
self._prompt_existing_tickets(billing_id)
|
||||
else:
|
||||
self._continue_multiple_flow()
|
||||
|
||||
def _continue_multiple_flow(self):
|
||||
self.custom_window.navigator.navigate("plan_picker")
|
||||
plan_page = self.custom_window.navigator.get_cached("plan_picker")
|
||||
if plan_page is not None:
|
||||
plan_page.start_sync()
|
||||
|
||||
def _prompt_existing_tickets(self, billing_id):
|
||||
box = QMessageBox(self)
|
||||
box.setWindowTitle("Existing ticket purchase found")
|
||||
box.setText(
|
||||
"You already have a pending ticket purchase. Continue to check if it's paid, "
|
||||
"or wipe it and start over?")
|
||||
style_message_box(box)
|
||||
check_button = box.addButton(
|
||||
"Check payment", QMessageBox.ButtonRole.AcceptRole)
|
||||
mark_confirm_button(check_button)
|
||||
wipe_button = box.addButton(
|
||||
"Wipe and start over", QMessageBox.ButtonRole.DestructiveRole)
|
||||
box.exec()
|
||||
clicked = box.clickedButton()
|
||||
if clicked == check_button:
|
||||
self._resume_existing_ticket(billing_id)
|
||||
elif clicked == wipe_button:
|
||||
self._continue_multiple_flow()
|
||||
|
||||
def _resume_existing_ticket(self, billing_id):
|
||||
self.update_status.update_status("Checking existing ticket payment...")
|
||||
self.custom_window.navigator.navigate("payment_details")
|
||||
payment_page = self.custom_window.navigator.get_cached("payment_details")
|
||||
if payment_page is not None:
|
||||
payment_page.resume_ticket_billing(billing_id)
|
||||
|
||||
def toggle_button_state(self):
|
||||
text = self.text_edit.toPlainText()
|
||||
if text.strip():
|
||||
|
|
|
|||
|
|
@ -68,6 +68,7 @@ class LocationPage(Page):
|
|||
self.verification_button.setEnabled(False)
|
||||
|
||||
def create_interface_elements(self, available_locations):
|
||||
|
||||
self.buttonGroup = QButtonGroup(self)
|
||||
self.buttons = []
|
||||
|
||||
|
|
@ -84,8 +85,15 @@ class LocationPage(Page):
|
|||
boton.setIcon(QIcon(icon_path))
|
||||
fallback_path = os.path.join(
|
||||
self.btn_path, "default_location_button.png")
|
||||
provider = locations.operator.name if locations and hasattr(
|
||||
locations, 'operator') else None
|
||||
|
||||
if locations:
|
||||
try:
|
||||
provider = locations.operator.name if locations and hasattr(
|
||||
locations, 'operator') else None
|
||||
except:
|
||||
print("Assign none")
|
||||
provider = None
|
||||
|
||||
if boton.icon().isNull():
|
||||
if locations and hasattr(locations, 'country_name'):
|
||||
location_name = locations.country_name
|
||||
|
|
|
|||
|
|
@ -213,12 +213,26 @@ class MenuPage(Page):
|
|||
profiles_dict.keys())
|
||||
|
||||
for idx in profile_ids:
|
||||
profile = profiles_dict[idx]
|
||||
new_profile = {}
|
||||
try:
|
||||
profile = profiles_dict[idx]
|
||||
new_profile = {}
|
||||
|
||||
protocol = profile.connection.code
|
||||
protocol = profile.connection.code
|
||||
|
||||
location = f'{profile.location.country_code}_{profile.location.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}'
|
||||
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
|
||||
|
||||
|
|
@ -255,6 +269,7 @@ class MenuPage(Page):
|
|||
|
||||
new_profile['name'] = profile.name
|
||||
|
||||
|
||||
new_dict[f'Profile_{idx}'] = new_profile
|
||||
|
||||
return new_dict
|
||||
|
|
|
|||
191
gui/v2/ui/pages/networking_setup_page.py
Executable file
191
gui/v2/ui/pages/networking_setup_page.py
Executable file
|
|
@ -0,0 +1,191 @@
|
|||
import os
|
||||
|
||||
from PyQt6.QtWidgets import QLabel, QPushButton, QWidget
|
||||
from PyQt6.QtGui import QPixmap
|
||||
from PyQt6.QtCore import Qt, QTimer
|
||||
|
||||
from core.services.helpers.setup_sudo_scripts import auto_install_sudo_script, test_if_in_sudo_folder
|
||||
from core.services.helpers.manage_assets import sudo_assets_folder_setup
|
||||
from core.models.Result import Result, ResultError
|
||||
|
||||
import sys
|
||||
|
||||
from gui.v2.ui.pages.Page import Page
|
||||
|
||||
|
||||
class NetworkingSetupPage(Page):
|
||||
def __init__(self, page_stack, main_window=None, parent=None):
|
||||
super().__init__("NetworkingSetup", page_stack, main_window, parent)
|
||||
self.btn_path = main_window.btn_path
|
||||
self.update_status = main_window
|
||||
self.manual_scripts_ready = False
|
||||
self.button_next.setVisible(True)
|
||||
self.button_next.clicked.connect(self.go_to_install)
|
||||
self._setup_ui()
|
||||
|
||||
def _setup_ui(self):
|
||||
header_icon = self._icon_label("networking_shield.png", 48, self)
|
||||
header_icon.setGeometry(74, 66, 48, 48)
|
||||
|
||||
title = QLabel("Firewall & Managed-DNS Setup", self)
|
||||
title.setGeometry(138, 68, 590, 44)
|
||||
title.setStyleSheet("font-size: 26px; font-weight: bold; color: cyan;")
|
||||
|
||||
subtitle = QLabel(
|
||||
"Optional privileged networking helpers",
|
||||
self)
|
||||
subtitle.setGeometry(140, 108, 560, 24)
|
||||
subtitle.setStyleSheet("font-size: 14px; color: #d8ffff;")
|
||||
|
||||
description = QLabel(
|
||||
"These firewall and managed-DNS helpers are separate bash scripts. "
|
||||
"They stay outside the AppImage Python runtime, and if installed they are placed "
|
||||
"in sudo-protected folders owned by root.",
|
||||
self)
|
||||
description.setGeometry(80, 152, 640, 72)
|
||||
description.setWordWrap(True)
|
||||
description.setStyleSheet("font-size: 15px; color: cyan;")
|
||||
|
||||
manual_panel = self._option_panel(74, 248, "Option 1", "Manual review")
|
||||
manual_text = QLabel(
|
||||
"Copy the scripts to Downloads, review them, then run sudo bash setup.sh yourself.",
|
||||
manual_panel)
|
||||
manual_text.setGeometry(24, 76, 252, 48)
|
||||
manual_text.setWordWrap(True)
|
||||
manual_text.setStyleSheet("font-size: 13px; color: #d8ffff;")
|
||||
|
||||
self.manual_button = QPushButton("Get scripts", manual_panel)
|
||||
self.manual_button.setGeometry(24, 132, 252, 38)
|
||||
self.manual_button.setStyleSheet(self._button_style("#007AFF", "#0056CC"))
|
||||
self.manual_button.clicked.connect(self.handle_manual_setup)
|
||||
|
||||
auto_panel = self._option_panel(426, 248, "Option 2", "Automated installer")
|
||||
auto_text = QLabel(
|
||||
"Let HydraVeil run the installer, then test that the scripts reached the sudo folder.",
|
||||
auto_panel)
|
||||
auto_text.setGeometry(24, 76, 252, 48)
|
||||
auto_text.setWordWrap(True)
|
||||
auto_text.setStyleSheet("font-size: 13px; color: #d8ffff;")
|
||||
|
||||
self.auto_button = QPushButton("Automated installer", auto_panel)
|
||||
self.auto_button.setGeometry(24, 132, 252, 38)
|
||||
self.auto_button.setStyleSheet(self._button_style("#16a085", "#117a65"))
|
||||
self.auto_button.clicked.connect(self.install_sudo_scripts_automatically)
|
||||
|
||||
self.status_label = QLabel("Choose manual or automated setup, or press Next to skip and continue.", self)
|
||||
self.status_label.setGeometry(82, 462, 636, 38)
|
||||
self.status_label.setWordWrap(True)
|
||||
self.status_label.setStyleSheet("font-size: 13px; color: #d8ffff;")
|
||||
|
||||
|
||||
def _option_panel(self, x, y, label, title):
|
||||
panel = QWidget(self)
|
||||
panel.setObjectName("networkingOptionPanel")
|
||||
panel.setGeometry(x, y, 300, 186)
|
||||
panel.setStyleSheet("""
|
||||
QWidget#networkingOptionPanel {
|
||||
background-color: #17323d;
|
||||
border: 1px solid #2c7a8d;
|
||||
border-radius: 6px;
|
||||
}
|
||||
""")
|
||||
|
||||
option_label = QLabel(label, panel)
|
||||
option_label.setGeometry(24, 20, 120, 20)
|
||||
option_label.setStyleSheet("font-size: 11px; font-weight: bold; color: #8de9ff; border: none;")
|
||||
|
||||
title_label = QLabel(title, panel)
|
||||
title_label.setGeometry(24, 42, 240, 28)
|
||||
title_label.setStyleSheet("font-size: 18px; font-weight: bold; color: cyan; border: none;")
|
||||
|
||||
return panel
|
||||
|
||||
def _icon_label(self, icon_name, size, parent):
|
||||
label = QLabel(parent)
|
||||
icon_path = os.path.join(self.btn_path, icon_name)
|
||||
label.setPixmap(QPixmap(icon_path).scaled(
|
||||
size, size, Qt.AspectRatioMode.KeepAspectRatio, Qt.TransformationMode.SmoothTransformation))
|
||||
label.setFixedSize(size, size)
|
||||
label.setStyleSheet("border: none;")
|
||||
return label
|
||||
|
||||
def _button_style(self, background, hover):
|
||||
return f"""
|
||||
QPushButton {{
|
||||
background: {background};
|
||||
color: #f4ffff;
|
||||
border: none;
|
||||
border-radius: 4px;
|
||||
font-size: 12px;
|
||||
font-weight: bold;
|
||||
padding: 4px 8px;
|
||||
}}
|
||||
QPushButton:hover {{
|
||||
background: {hover};
|
||||
}}
|
||||
QPushButton:disabled {{
|
||||
background: #3f4954;
|
||||
color: #94a3ad;
|
||||
}}
|
||||
"""
|
||||
|
||||
def _set_status(self, message, color="#d8ffff"):
|
||||
self.status_label.setText(message)
|
||||
self.status_label.setStyleSheet(f"font-size: 13px; color: {color};")
|
||||
self.update_status.update_status(message)
|
||||
|
||||
def _result_is_valid(self, result: Result):
|
||||
if hasattr(result, "valid"):
|
||||
return result.valid
|
||||
if result is None:
|
||||
return True
|
||||
return bool(result)
|
||||
|
||||
def _result_message(self, result: Result, fallback):
|
||||
return getattr(result, "message", fallback)
|
||||
|
||||
def handle_manual_setup(self):
|
||||
if self.manual_scripts_ready:
|
||||
self.confirm_sudo_scripts()
|
||||
return
|
||||
results = sudo_assets_folder_setup()
|
||||
if not self._result_is_valid(results):
|
||||
self._set_status(
|
||||
f"Could not copy scripts: {self._result_message(results, 'Unknown error')}", "#ff6b6b")
|
||||
return
|
||||
self.manual_scripts_ready = True
|
||||
self.manual_button.setText("Confirm manual install")
|
||||
self._set_status(
|
||||
"Copied to Downloads/hydraveil_sudo_scripts. Review them, run 'sudo bash setup.sh', then click Confirm manual install.", "#d8ffff")
|
||||
|
||||
def confirm_sudo_scripts(self):
|
||||
confirmed = test_if_in_sudo_folder()
|
||||
if confirmed.valid:
|
||||
self._set_status("Confirmed it worked. Continuing to prerequisite installation.", "#2ecc71")
|
||||
QTimer.singleShot(600, self.go_to_install)
|
||||
else:
|
||||
self._set_status(
|
||||
f"I'm sorry it did not work, {confirmed.message}", "#ff6b6b")
|
||||
|
||||
def install_sudo_scripts_automatically(self):
|
||||
results = auto_install_sudo_script()
|
||||
if results.valid:
|
||||
confirmed = test_if_in_sudo_folder()
|
||||
if confirmed.valid:
|
||||
self._set_status("The setup script ran successfully. Continuing to prerequisite installation.", "#2ecc71")
|
||||
QTimer.singleShot(600, self.go_to_install)
|
||||
else:
|
||||
self._set_status(
|
||||
f"I'm sorry it did not work, {confirmed.message}", "#ff6b6b")
|
||||
else:
|
||||
self._set_status(
|
||||
f"Setup script did NOT work because {results.message}", "#ff6b6b")
|
||||
|
||||
def go_to_install(self):
|
||||
self.custom_window.navigator.navigate("install_system_package")
|
||||
install_page = self.custom_window.navigator.get_cached("install_system_package")
|
||||
if install_page is not None:
|
||||
install_page.configure(package_name='all', distro='debian')
|
||||
|
||||
def back_to_welcome(self):
|
||||
self.custom_window.navigator.navigate("welcome")
|
||||
|
|
@ -343,6 +343,16 @@ class PaymentDetailsPage(Page):
|
|||
self.ticket_poll_timer.start(3000)
|
||||
self.update_status.update_status('Awaiting ticket payment...')
|
||||
|
||||
def resume_ticket_billing(self, temp_billing_code):
|
||||
self.ticketing = True
|
||||
self.temp_billing_code = temp_billing_code
|
||||
self.selected_currency = None
|
||||
self.text_fields[0].setText(str(temp_billing_code or ''))
|
||||
if self.ticket_poll_timer.isActive():
|
||||
self.ticket_poll_timer.stop()
|
||||
self.ticket_poll_timer.start(3000)
|
||||
self.update_status.update_status('Checking existing ticket payment...')
|
||||
|
||||
def _populate_ticket_fields(self, invoice):
|
||||
self.text_fields[0].setText(str(getattr(invoice, 'temp_billing_code', '') or ''))
|
||||
self.text_fields[1].setText(self.selected_duration)
|
||||
|
|
@ -405,7 +415,7 @@ class PaymentDetailsPage(Page):
|
|||
self.update_status.update_status('Awaiting ticket payment...')
|
||||
|
||||
def _on_ticket_check_failed(self, msg):
|
||||
self.update_status.update_status(f'Payment check failed: {msg}')
|
||||
self.update_status.update_status('Not Paid')
|
||||
|
||||
def show_qr_code(self):
|
||||
full_amount = self.text_fields[2].text()
|
||||
|
|
|
|||
|
|
@ -1,11 +1,9 @@
|
|||
import json
|
||||
import logging
|
||||
import os
|
||||
import subprocess
|
||||
import sys
|
||||
import threading
|
||||
from datetime import datetime, timezone
|
||||
from typing import Union
|
||||
|
||||
from PyQt6.QtWidgets import (
|
||||
QApplication, QButtonGroup, QCheckBox, QComboBox, QFrame, QGridLayout,
|
||||
|
|
@ -33,7 +31,9 @@ from core.Errors import (
|
|||
PolicyRevocationError,
|
||||
)
|
||||
from core.errors.logger import logger as core_logger
|
||||
from core.services.networking.systemwide.systemwide_utils import get_firewall_setting
|
||||
|
||||
from gui.v2.actions import settings_data
|
||||
from gui.v2.actions.key_interpretation import interpret_key_results
|
||||
from gui.v2.actions.profile_order import normalize_profile_order
|
||||
from gui.v2.infrastructure.setup_observers import ticket_observer
|
||||
|
|
@ -43,20 +43,25 @@ from gui.v2.ui.styles.styles import (
|
|||
SCROLLBAR_CYAN_QSS,
|
||||
TERMINAL_LIST_QSS,
|
||||
checkbox_style,
|
||||
combobox_style,
|
||||
)
|
||||
from gui.v2.ui.widgets.clickable_label import ClickableValueLabel
|
||||
from gui.v2.ui.widgets.terminal_widget import TerminalWidget
|
||||
from gui.v2.workers.page_data_worker import PageDataWorker
|
||||
from gui.v2.workers.ticketing_worker_thread import TicketingWorkerThread
|
||||
from gui.v2.workers.worker_thread import WorkerThread
|
||||
|
||||
|
||||
class Settings(Page):
|
||||
def __init__(self, page_stack, main_window, parent=None):
|
||||
def __init__(self, page_stack, main_window, parent=None, prepared=None):
|
||||
super().__init__("Settings", page_stack, main_window, parent)
|
||||
self.font_style = f"font-family: '{self.custom_window.open_sans_family}';"
|
||||
|
||||
self.update_status = main_window
|
||||
self.update_logging = main_window
|
||||
self._prepared = prepared if prepared is not None else settings_data.empty_payload()
|
||||
self._settings_refresh_seq = 0
|
||||
self._settings_workers = set()
|
||||
self.button_reverse.setVisible(True)
|
||||
self.button_reverse.setEnabled(True)
|
||||
self.button_reverse.clicked.connect(self.reverse)
|
||||
|
|
@ -64,6 +69,10 @@ class Settings(Page):
|
|||
self.title.setText("Settings")
|
||||
self.setup_ui()
|
||||
|
||||
@staticmethod
|
||||
def prepare_data(custom_window):
|
||||
return settings_data.prepare(custom_window.gui_config_file)
|
||||
|
||||
def setup_ui(self):
|
||||
main_container = QWidget(self)
|
||||
main_container.setGeometry(0, 0, 800, 520)
|
||||
|
|
@ -95,6 +104,7 @@ class Settings(Page):
|
|||
("Verification", self.show_verification_page),
|
||||
("Legacy-Version", self.show_systemwide_page),
|
||||
("Bwrap Permission", self.show_bwrap_page),
|
||||
("Connections", self.show_connection_page),
|
||||
("Delete Profile", self.show_delete_page),
|
||||
("Error Logs", self.show_logs_page),
|
||||
("Debug Help", self.show_debug_page)
|
||||
|
|
@ -198,11 +208,13 @@ class Settings(Page):
|
|||
return page
|
||||
|
||||
def create_delete_profile_buttons(self):
|
||||
profiles = ProfileController.get_all()
|
||||
profiles = self._prepared_value("profiles", ProfileController.get_all)
|
||||
|
||||
profile_ids = normalize_profile_order(
|
||||
getattr(self.update_status, 'gui_config_file', None),
|
||||
profiles.keys())
|
||||
profile_ids = self._prepared_value(
|
||||
"profile_order",
|
||||
lambda: normalize_profile_order(
|
||||
getattr(self.update_status, 'gui_config_file', None),
|
||||
profiles.keys()))
|
||||
|
||||
for index, profile_id in enumerate(profile_ids):
|
||||
profile = profiles[profile_id]
|
||||
|
|
@ -291,7 +303,7 @@ class Settings(Page):
|
|||
profile_selection_layout.addWidget(profile_label)
|
||||
|
||||
self.debug_profile_selector = QComboBox()
|
||||
self.debug_profile_selector.setStyleSheet(self.get_combobox_style())
|
||||
self.debug_profile_selector.setStyleSheet(combobox_style(self.font_style))
|
||||
self.debug_profile_selector.currentTextChanged.connect(
|
||||
self.on_debug_profile_selected)
|
||||
profile_selection_layout.addWidget(self.debug_profile_selector)
|
||||
|
|
@ -600,7 +612,7 @@ class Settings(Page):
|
|||
|
||||
def update_debug_profile_list(self):
|
||||
self.debug_profile_selector.clear()
|
||||
profiles = ProfileController.get_all()
|
||||
profiles = self._prepared_value("profiles", ProfileController.get_all)
|
||||
system_profiles = {pid: profile for pid, profile in profiles.items(
|
||||
) if isinstance(profile, SystemProfile)}
|
||||
|
||||
|
|
@ -637,7 +649,7 @@ class Settings(Page):
|
|||
self.cli_command.setText(
|
||||
f"'{app_path}' --cli profile enable -i {profile_id}")
|
||||
self.cli_copy_button.setEnabled(True)
|
||||
ip_address = self.extract_endpoint_ip(profile)
|
||||
ip_address = settings_data.extract_endpoint_ip(profile)
|
||||
if ip_address:
|
||||
self.ping_instruction_label.setText(
|
||||
f"Step 1, Can you Ping it? Copy-paste the command below into your terminal. This VPN Node's IP address is {ip_address}")
|
||||
|
|
@ -669,25 +681,6 @@ class Settings(Page):
|
|||
self.wg_quick_up_button.setEnabled(False)
|
||||
self.wg_quick_down_button.setEnabled(False)
|
||||
|
||||
def extract_endpoint_ip(self, profile):
|
||||
try:
|
||||
profile_path = Constants.HV_PROFILE_CONFIG_HOME + f'/{profile.id}'
|
||||
wg_conf_path = f'{profile_path}/wg.conf.bak'
|
||||
if not os.path.exists(wg_conf_path):
|
||||
return None
|
||||
|
||||
with open(wg_conf_path, 'r') as f:
|
||||
content = f.read()
|
||||
|
||||
for line in content.split('\n'):
|
||||
if line.strip().startswith('Endpoint = '):
|
||||
endpoint = line.strip().split(' = ')[1]
|
||||
ip_address = endpoint.split(':')[0]
|
||||
return ip_address
|
||||
return None
|
||||
except Exception:
|
||||
return None
|
||||
|
||||
def copy_ping_command(self):
|
||||
profile_id = self.debug_profile_selector.currentData()
|
||||
if profile_id is None:
|
||||
|
|
@ -695,7 +688,7 @@ class Settings(Page):
|
|||
|
||||
profile = ProfileController.get(profile_id)
|
||||
if profile and isinstance(profile, SystemProfile):
|
||||
ip_address = self.extract_endpoint_ip(profile)
|
||||
ip_address = settings_data.extract_endpoint_ip(profile)
|
||||
if ip_address:
|
||||
ping_command = f"ping {ip_address}"
|
||||
clipboard = QApplication.clipboard()
|
||||
|
|
@ -710,7 +703,7 @@ class Settings(Page):
|
|||
|
||||
profile = ProfileController.get(profile_id)
|
||||
if profile and isinstance(profile, SystemProfile):
|
||||
ip_address = self.extract_endpoint_ip(profile)
|
||||
ip_address = settings_data.extract_endpoint_ip(profile)
|
||||
if ip_address:
|
||||
self.test_ping_button.setEnabled(False)
|
||||
self.ping_result_label.setText("Testing ping...")
|
||||
|
|
@ -800,75 +793,9 @@ class Settings(Page):
|
|||
self.content_layout.addWidget(self.delete_page)
|
||||
self.content_layout.setCurrentWidget(self.delete_page)
|
||||
|
||||
def get_combobox_style(self) -> str:
|
||||
return f"""
|
||||
QComboBox {{
|
||||
color: black;
|
||||
background: #f0f0f0;
|
||||
padding: 5px 30px 5px 10px;
|
||||
border: 1px solid #ccc;
|
||||
border-radius: 4px;
|
||||
min-width: 120px;
|
||||
margin-bottom: 10px;
|
||||
{self.font_style}
|
||||
}}
|
||||
QComboBox:disabled {{
|
||||
color: #666;
|
||||
background: #e0e0e0;
|
||||
}}
|
||||
QComboBox::drop-down {{
|
||||
border: none;
|
||||
width: 30px;
|
||||
}}
|
||||
QComboBox::down-arrow {{
|
||||
image: url(assets/down_arrow.png);
|
||||
width: 12px;
|
||||
height: 12px;
|
||||
}}
|
||||
QComboBox QAbstractItemView {{
|
||||
color: black;
|
||||
background: white;
|
||||
selection-background-color: #007bff;
|
||||
selection-color: white;
|
||||
border: 1px solid #ccc;
|
||||
{self.font_style}
|
||||
}}
|
||||
"""
|
||||
|
||||
def get_checkbox_style(self) -> str:
|
||||
return checkbox_style(self.font_style)
|
||||
|
||||
def populate_wireguard_profiles(self) -> None:
|
||||
self.wireguard_profile_selector.clear()
|
||||
profiles = ProfileController.get_all()
|
||||
for profile_id, profile in profiles.items():
|
||||
if profile.connection.code == 'wireguard':
|
||||
|
||||
self.wireguard_profile_selector.addItem(
|
||||
f"Profile {profile_id}: {profile.name}", profile_id)
|
||||
|
||||
def convert_duration(self, value: Union[str, int], to_hours: bool = True) -> Union[str, int]:
|
||||
if to_hours:
|
||||
number, unit = value.split(' ')
|
||||
number = int(number)
|
||||
if unit in ['day', 'days']:
|
||||
return number * 24
|
||||
elif unit in ['week', 'weeks']:
|
||||
return number * 7 * 24
|
||||
else:
|
||||
raise ValueError(f"Unsupported duration unit: {unit}")
|
||||
else:
|
||||
hours = int(value)
|
||||
if hours % (7 * 24) == 0:
|
||||
weeks = hours // (7 * 24)
|
||||
return f"{weeks} {'week' if weeks == 1 else 'weeks'}"
|
||||
elif hours % 24 == 0:
|
||||
days = hours // 24
|
||||
return f"{days} {'day' if days == 1 else 'days'}"
|
||||
else:
|
||||
raise ValueError(
|
||||
f"Hours value {hours} cannot be converted to days or weeks cleanly")
|
||||
|
||||
def reverse(self):
|
||||
self.custom_window.navigator.navigate("menu")
|
||||
|
||||
|
|
@ -903,8 +830,8 @@ class Settings(Page):
|
|||
profile_layout = QVBoxLayout(profile_group)
|
||||
|
||||
self.profile_selector = QComboBox()
|
||||
self.profile_selector.setStyleSheet(self.get_combobox_style())
|
||||
profiles = ProfileController.get_all()
|
||||
self.profile_selector.setStyleSheet(combobox_style(self.font_style))
|
||||
profiles = self._prepared_value("profiles", ProfileController.get_all)
|
||||
if profiles:
|
||||
for profile_id, profile in profiles.items():
|
||||
self.profile_selector.addItem(
|
||||
|
|
@ -1038,8 +965,8 @@ class Settings(Page):
|
|||
|
||||
self.verification_profile_selector = QComboBox()
|
||||
self.verification_profile_selector.setStyleSheet(
|
||||
self.get_combobox_style())
|
||||
profiles = ProfileController.get_all()
|
||||
combobox_style(self.font_style))
|
||||
profiles = self._prepared_value("profiles", ProfileController.get_all)
|
||||
if profiles:
|
||||
for profile_id, profile in profiles.items():
|
||||
self.verification_profile_selector.addItem(
|
||||
|
|
@ -1134,7 +1061,9 @@ class Settings(Page):
|
|||
self.endpoint_verification_checkbox = QCheckBox(page)
|
||||
self.endpoint_verification_checkbox.setGeometry(180, 415, 30, 30)
|
||||
self.endpoint_verification_checkbox.setChecked(
|
||||
ConfigurationController.get_endpoint_verification_enabled())
|
||||
self._prepared_value(
|
||||
"endpoint_verification_enabled",
|
||||
ConfigurationController.get_endpoint_verification_enabled))
|
||||
self.endpoint_verification_checkbox.setStyleSheet(
|
||||
self.get_checkbox_style())
|
||||
self.endpoint_verification_checkbox.show()
|
||||
|
|
@ -1155,72 +1084,30 @@ class Settings(Page):
|
|||
|
||||
return page
|
||||
|
||||
def truncate_key(self, text, max_length=50):
|
||||
if not text or text == "N/A" or len(text) <= max_length:
|
||||
return text
|
||||
start_len = max_length // 2 - 2
|
||||
end_len = max_length // 2 - 2
|
||||
return text[:start_len] + "....." + text[-end_len:]
|
||||
|
||||
def update_verification_info(self, index):
|
||||
if index < 0:
|
||||
return
|
||||
|
||||
profile_id = self.verification_profile_selector.itemData(index)
|
||||
if profile_id is None:
|
||||
for key, widget in self.verification_info.items():
|
||||
widget.setText("N/A")
|
||||
self.verification_full_values[key] = "N/A"
|
||||
if key in self.verification_checkmarks:
|
||||
self.verification_checkmarks[key].hide()
|
||||
return
|
||||
profile = None
|
||||
if profile_id is not None:
|
||||
profile = ProfileController.get(profile_id)
|
||||
|
||||
profile = ProfileController.get(profile_id)
|
||||
if not profile:
|
||||
for key, widget in self.verification_info.items():
|
||||
widget.setText("N/A")
|
||||
self.verification_full_values[key] = "N/A"
|
||||
if key in self.verification_checkmarks:
|
||||
self.verification_checkmarks[key].hide()
|
||||
return
|
||||
|
||||
operator = None
|
||||
if profile.location and profile.location.operator:
|
||||
operator = profile.location.operator
|
||||
|
||||
if operator:
|
||||
operator_name = operator.name or "N/A"
|
||||
self.verification_full_values["operator_name"] = operator_name
|
||||
self.verification_info["operator_name"].setText(operator_name)
|
||||
|
||||
nostr_key = operator.nostr_public_key or "N/A"
|
||||
self.verification_full_values["nostr_public_key"] = nostr_key
|
||||
self.verification_info["nostr_public_key"].setText(
|
||||
self.truncate_key(nostr_key) if nostr_key != "N/A" else nostr_key)
|
||||
|
||||
hydraveil_key = operator.public_key or "N/A"
|
||||
self.verification_full_values["hydraveil_public_key"] = hydraveil_key
|
||||
self.verification_info["hydraveil_public_key"].setText(
|
||||
self.truncate_key(hydraveil_key) if hydraveil_key != "N/A" else hydraveil_key)
|
||||
|
||||
nostr_verification = operator.nostr_attestation_event_reference or "N/A"
|
||||
self.verification_full_values["nostr_attestation_event_reference"] = nostr_verification
|
||||
self.verification_info["nostr_attestation_event_reference"].setText(self.truncate_key(
|
||||
nostr_verification) if nostr_verification != "N/A" else nostr_verification)
|
||||
else:
|
||||
self.verification_info["operator_name"].setText("N/A")
|
||||
self.verification_full_values["operator_name"] = "N/A"
|
||||
self.verification_info["nostr_public_key"].setText("N/A")
|
||||
self.verification_full_values["nostr_public_key"] = "N/A"
|
||||
self.verification_info["hydraveil_public_key"].setText("N/A")
|
||||
self.verification_full_values["hydraveil_public_key"] = "N/A"
|
||||
self.verification_info["nostr_attestation_event_reference"].setText(
|
||||
"N/A")
|
||||
self.verification_full_values["nostr_attestation_event_reference"] = "N/A"
|
||||
view = settings_data.build_verification_view(profile)
|
||||
truncated_keys = (
|
||||
"nostr_public_key",
|
||||
"hydraveil_public_key",
|
||||
"nostr_attestation_event_reference",
|
||||
)
|
||||
|
||||
for key, widget in self.verification_info.items():
|
||||
full_value = view.get(key, "N/A")
|
||||
self.verification_full_values[key] = full_value
|
||||
if key in truncated_keys and full_value != "N/A":
|
||||
widget.setText(settings_data.truncate_key(full_value))
|
||||
else:
|
||||
widget.setText(full_value)
|
||||
if key in self.verification_checkmarks:
|
||||
full_value = self.verification_full_values.get(key, "")
|
||||
if full_value and full_value != "N/A":
|
||||
self.verification_checkmarks[key].show()
|
||||
else:
|
||||
|
|
@ -1265,16 +1152,9 @@ class Settings(Page):
|
|||
|
||||
if profile and hasattr(profile, 'subscription') and profile.subscription:
|
||||
try:
|
||||
self.subscription_info["billing_code"].setText(
|
||||
str(profile.subscription.billing_code))
|
||||
|
||||
if hasattr(profile.subscription, 'expires_at') and profile.subscription.expires_at:
|
||||
expires_at = profile.subscription.expires_at.strftime(
|
||||
"%Y-%m-%d %H:%M:%S UTC")
|
||||
self.subscription_info["expires_at"].setText(expires_at)
|
||||
else:
|
||||
self.subscription_info["expires_at"].setText(
|
||||
"Not available")
|
||||
view = settings_data.build_subscription_view(profile)
|
||||
self.subscription_info["billing_code"].setText(view["billing_code"])
|
||||
self.subscription_info["expires_at"].setText(view["expires_at"])
|
||||
except Exception as e:
|
||||
print(f"Error updating subscription info: {e}")
|
||||
else:
|
||||
|
|
@ -1295,6 +1175,30 @@ class Settings(Page):
|
|||
|
||||
def showEvent(self, event):
|
||||
super().showEvent(event)
|
||||
self._settings_refresh_seq += 1
|
||||
seq = self._settings_refresh_seq
|
||||
worker = PageDataWorker(
|
||||
"settings", settings_data.prepare, self.custom_window.gui_config_file)
|
||||
worker.data_ready.connect(
|
||||
lambda name, payload, s=seq: self._on_settings_data_ready(payload, s))
|
||||
worker.failed.connect(
|
||||
lambda name, error: self._on_settings_data_failed(error))
|
||||
worker.finished.connect(
|
||||
lambda w=worker: self._cleanup_settings_worker(w))
|
||||
self._settings_workers.add(worker)
|
||||
worker.start()
|
||||
|
||||
def _on_settings_data_failed(self, error):
|
||||
core_logger.warning(f"Settings data refresh failed: {error}")
|
||||
|
||||
def _cleanup_settings_worker(self, worker):
|
||||
self._settings_workers.discard(worker)
|
||||
worker.deleteLater()
|
||||
|
||||
def _on_settings_data_ready(self, payload, seq):
|
||||
if seq != self._settings_refresh_seq:
|
||||
return
|
||||
self._prepared = payload
|
||||
|
||||
current_index = self.content_layout.currentIndex()
|
||||
|
||||
|
|
@ -1326,6 +1230,10 @@ class Settings(Page):
|
|||
self.bwrap_page = self.create_bwrap_page()
|
||||
self.content_layout.addWidget(self.bwrap_page)
|
||||
|
||||
self.content_layout.removeWidget(self.connection_page)
|
||||
self.connection_page = self.create_connection_page()
|
||||
self.content_layout.addWidget(self.connection_page)
|
||||
|
||||
self.content_layout.removeWidget(self.delete_page)
|
||||
self.delete_page = self.create_delete_page()
|
||||
self.content_layout.addWidget(self.delete_page)
|
||||
|
|
@ -1407,7 +1315,7 @@ class Settings(Page):
|
|||
layout = QGridLayout(widget)
|
||||
layout.setSpacing(10)
|
||||
|
||||
profiles = ProfileController.get_all()
|
||||
profiles = self._prepared_value("profiles", ProfileController.get_all)
|
||||
total_profiles = len(profiles)
|
||||
session_profiles = sum(1 for p in profiles.values()
|
||||
if isinstance(p, SessionProfile))
|
||||
|
|
@ -1439,7 +1347,8 @@ class Settings(Page):
|
|||
|
||||
config_path = Constants.HV_CONFIG_HOME
|
||||
|
||||
current_connection = self.update_status.get_current_connection()
|
||||
current_connection = self._prepared_value(
|
||||
"current_connection", self.update_status.get_current_connection)
|
||||
|
||||
if current_connection is not None:
|
||||
current_connection = current_connection.capitalize()
|
||||
|
|
@ -1539,6 +1448,7 @@ class Settings(Page):
|
|||
self.verification_page = self.create_verification_page()
|
||||
self.systemwide_page = self.create_systemwide_page()
|
||||
self.bwrap_page = self.create_bwrap_page()
|
||||
self.connection_page = self.create_connection_page()
|
||||
self.logs_page = self.create_logs_page()
|
||||
self.delete_page = self.create_delete_page()
|
||||
self.debug_page = self.create_debug_page()
|
||||
|
|
@ -1550,6 +1460,7 @@ class Settings(Page):
|
|||
self.content_layout.addWidget(self.verification_page)
|
||||
self.content_layout.addWidget(self.systemwide_page)
|
||||
self.content_layout.addWidget(self.bwrap_page)
|
||||
self.content_layout.addWidget(self.connection_page)
|
||||
self.content_layout.addWidget(self.logs_page)
|
||||
self.content_layout.addWidget(self.delete_page)
|
||||
self.content_layout.addWidget(self.debug_page)
|
||||
|
|
@ -1608,6 +1519,11 @@ class Settings(Page):
|
|||
self.content_layout.setCurrentWidget(self.bwrap_page)
|
||||
self._select_menu_button("Bwrap Permission")
|
||||
|
||||
def show_connection_page(self):
|
||||
core_logger.info("User navigated to Settings -> Connection")
|
||||
self.content_layout.setCurrentWidget(self.connection_page)
|
||||
self._select_menu_button("Connection Page")
|
||||
|
||||
def show_logs_page(self):
|
||||
core_logger.info("User navigated to Settings -> Error Logs")
|
||||
self.content_layout.setCurrentWidget(self.logs_page)
|
||||
|
|
@ -1697,7 +1613,8 @@ class Settings(Page):
|
|||
inventory_layout.addWidget(self.refresh_tickets_button)
|
||||
layout.addWidget(inventory_group)
|
||||
|
||||
saved_failure = self.update_status.get_ticket_verification_failure()
|
||||
saved_failure = self._prepared_value(
|
||||
"ticket_failure", self.update_status.get_ticket_verification_failure)
|
||||
has_failure = saved_failure is not None
|
||||
|
||||
recovery_group = QGroupBox("Verification Failure Recovery")
|
||||
|
|
@ -1705,7 +1622,7 @@ class Settings(Page):
|
|||
f"QGroupBox {{ color: white; padding: 15px; {self.font_style} }}")
|
||||
recovery_layout = QVBoxLayout(recovery_group)
|
||||
|
||||
self.ticket_recovery_status_label = QLabel(self._format_ticket_failure_status(saved_failure))
|
||||
self.ticket_recovery_status_label = QLabel(settings_data.format_ticket_failure_status(saved_failure))
|
||||
self.ticket_recovery_status_label.setStyleSheet(
|
||||
f"color: white; font-size: 12px; {self.font_style}")
|
||||
self.ticket_recovery_status_label.setWordWrap(True)
|
||||
|
|
@ -1759,23 +1676,11 @@ class Settings(Page):
|
|||
page_layout.addWidget(scroll_area)
|
||||
return page
|
||||
|
||||
def _format_ticket_failure_status(self, failure):
|
||||
if not failure:
|
||||
return "No saved verification failure. If ticket preparation fails validation, recovery data will appear here."
|
||||
failed_validations = failure.get("failed_validations", [])
|
||||
how_many_failed = failure.get("how_many_failed", len(failed_validations))
|
||||
updated_at = failure.get("updated_at", "unknown time")
|
||||
failed_text = ", ".join(str(item) for item in failed_validations)
|
||||
return (
|
||||
f"Saved verification failure: {how_many_failed} failed. "
|
||||
f"Failed validation indices: {failed_text}. Saved: {updated_at}"
|
||||
)
|
||||
|
||||
def _refresh_ticket_recovery_controls(self):
|
||||
failure = self.update_status.get_ticket_verification_failure()
|
||||
has_failure = failure is not None
|
||||
if hasattr(self, 'ticket_recovery_status_label'):
|
||||
self.ticket_recovery_status_label.setText(self._format_ticket_failure_status(failure))
|
||||
self.ticket_recovery_status_label.setText(settings_data.format_ticket_failure_status(failure))
|
||||
if hasattr(self, 'evaluate_public_key_button'):
|
||||
self.evaluate_public_key_button.setEnabled(has_failure)
|
||||
if hasattr(self, 'prepare_saved_blind_sigs_button'):
|
||||
|
|
@ -1791,13 +1696,6 @@ class Settings(Page):
|
|||
if hasattr(self, 'ticket_recovery_output'):
|
||||
self.ticket_recovery_output.setPlainText(text)
|
||||
|
||||
def _format_ticket_recovery_result(self, label, result):
|
||||
try:
|
||||
payload = json.dumps(result, indent=2, default=str)
|
||||
except TypeError:
|
||||
payload = str(result)
|
||||
return f"{label}:\n{payload}"
|
||||
|
||||
def _get_ticket_failure_for_action(self):
|
||||
failure = self.update_status.get_ticket_verification_failure()
|
||||
if failure is None:
|
||||
|
|
@ -1859,7 +1757,7 @@ class Settings(Page):
|
|||
self.ticket_recovery_worker.start()
|
||||
|
||||
def on_saved_blind_prep_done(self, result):
|
||||
self._write_ticket_recovery_output(self._format_ticket_recovery_result("Results of preparation", result))
|
||||
self._write_ticket_recovery_output(settings_data.format_ticket_recovery_result("Results of preparation", result))
|
||||
if isinstance(result, dict) and result.get('valid') is True:
|
||||
self.update_status.clear_ticket_verification_failure()
|
||||
self.update_status.update_status("Tickets prepared from saved blind signatures.")
|
||||
|
|
@ -1954,7 +1852,8 @@ class Settings(Page):
|
|||
|
||||
def load_logs_settings(self) -> None:
|
||||
try:
|
||||
config = self.update_status._load_gui_config()
|
||||
config = self._prepared_value(
|
||||
"gui_config", self.update_status._load_gui_config)
|
||||
if config and "logging" in config:
|
||||
self.enable_gui_logging.setChecked(
|
||||
config["logging"]["gui_logging_enabled"])
|
||||
|
|
@ -2103,7 +2002,8 @@ class Settings(Page):
|
|||
layout.addLayout(button_layout)
|
||||
|
||||
layout.addStretch()
|
||||
self.load_systemwide_settings()
|
||||
self.load_systemwide_settings(
|
||||
self._prepared_value("systemwide_enabled", settings_data.read_systemwide_enabled))
|
||||
return page
|
||||
|
||||
def create_bwrap_page(self):
|
||||
|
|
@ -2155,17 +2055,13 @@ class Settings(Page):
|
|||
layout.addLayout(button_layout)
|
||||
|
||||
layout.addStretch()
|
||||
self.load_bwrap_settings()
|
||||
self.load_bwrap_settings(
|
||||
self._prepared_value("bwrap_enabled", settings_data.read_bwrap_enabled))
|
||||
return page
|
||||
|
||||
def load_systemwide_settings(self):
|
||||
enabled = False
|
||||
try:
|
||||
privilege_policy = PolicyController.get('privilege')
|
||||
if privilege_policy is not None:
|
||||
enabled = PolicyController.is_instated(privilege_policy)
|
||||
except Exception:
|
||||
enabled = False
|
||||
def load_systemwide_settings(self, enabled=None):
|
||||
if enabled is None:
|
||||
enabled = settings_data.read_systemwide_enabled()
|
||||
self.systemwide_toggle.setChecked(enabled)
|
||||
if enabled:
|
||||
self.systemwide_status_value.setText("Enabled")
|
||||
|
|
@ -2202,14 +2098,9 @@ class Settings(Page):
|
|||
self.systemwide_status_value.setStyleSheet(
|
||||
f"color: red; font-size: 14px; {self.font_style}")
|
||||
|
||||
def load_bwrap_settings(self):
|
||||
enabled = False
|
||||
try:
|
||||
capability_policy = PolicyController.get('capability')
|
||||
if capability_policy is not None:
|
||||
enabled = PolicyController.is_instated(capability_policy)
|
||||
except Exception:
|
||||
enabled = False
|
||||
def load_bwrap_settings(self, enabled=None):
|
||||
if enabled is None:
|
||||
enabled = settings_data.read_bwrap_enabled()
|
||||
self.bwrap_toggle.setChecked(enabled)
|
||||
if enabled:
|
||||
self.bwrap_status_value.setText("Enabled")
|
||||
|
|
@ -2220,6 +2111,21 @@ class Settings(Page):
|
|||
self.bwrap_status_value.setStyleSheet(
|
||||
f"color: #e67e22; font-size: 14px; {self.font_style}")
|
||||
|
||||
|
||||
def load_firewall_settings(self, enabled=None):
|
||||
if enabled is None:
|
||||
enabled = settings_data.load(read_firewall_setting)
|
||||
self.firewall_toggle.setChecked(enabled)
|
||||
if enabled:
|
||||
self.firewall_status_value.setText("Enabled")
|
||||
self.firewall_status_value.setStyleSheet(
|
||||
f"color: #2ecc71; font-size: 14px; {self.font_style}")
|
||||
else:
|
||||
self.firewall_status_value.setText("Disabled")
|
||||
self.firewall_status_value.setStyleSheet(
|
||||
f"color: #e67e22; font-size: 14px; {self.font_style}")
|
||||
|
||||
|
||||
def save_bwrap_settings(self):
|
||||
enable = self.bwrap_toggle.isChecked()
|
||||
try:
|
||||
|
|
@ -2246,9 +2152,33 @@ class Settings(Page):
|
|||
self.bwrap_status_value.setStyleSheet(
|
||||
f"color: red; font-size: 14px; {self.font_style}")
|
||||
|
||||
|
||||
def save_firewall_settings(self):
|
||||
enable = self.firewall_toggle.isChecked()
|
||||
try:
|
||||
if enable:
|
||||
ConfigurationController.change_firewall(True)
|
||||
self.firewall_status_value.setText("Enabled")
|
||||
else:
|
||||
ConfigurationController.change_firewall(False)
|
||||
self.firewall_status_value.setText("Disabled")
|
||||
self.update_status.update_status(
|
||||
"Firewall settings updated")
|
||||
except CommandNotFoundError as e:
|
||||
self.firewall_status_value.setText(str(e))
|
||||
self.firewall_status_value.setStyleSheet(
|
||||
f"color: red; font-size: 14px; {self.font_style}")
|
||||
except Exception as e:
|
||||
print(e)
|
||||
self.firewall_status_value.setText(f"Failed to update firewall setting {e}")
|
||||
self.firewall_status_value.setStyleSheet(
|
||||
f"color: red; font-size: 14px; {self.font_style}")
|
||||
|
||||
|
||||
def load_registrations_settings(self) -> None:
|
||||
try:
|
||||
config = self.update_status._load_gui_config()
|
||||
config = self._prepared_value(
|
||||
"gui_config", self.update_status._load_gui_config)
|
||||
if config and "registrations" in config:
|
||||
registrations = config["registrations"]
|
||||
auto_sync = registrations.get("auto_sync_enabled", False)
|
||||
|
|
@ -2307,25 +2237,57 @@ class Settings(Page):
|
|||
self.update_status.update_status(
|
||||
"Error saving registration settings")
|
||||
|
||||
def is_auto_sync_enabled(self) -> bool:
|
||||
try:
|
||||
config = self.update_status._load_gui_config()
|
||||
if config and "registrations" in config:
|
||||
registrations = config["registrations"]
|
||||
return registrations.get("auto_sync_enabled", False)
|
||||
return False
|
||||
except Exception as e:
|
||||
logging.error(f"Error checking auto-sync setting: {str(e)}")
|
||||
return False
|
||||
|
||||
def is_fast_registration_enabled(self) -> bool:
|
||||
try:
|
||||
config = self.update_status._load_gui_config()
|
||||
if config and "registrations" in config:
|
||||
registrations = config["registrations"]
|
||||
return registrations.get("fast_registration_enabled", False)
|
||||
return False
|
||||
except Exception as e:
|
||||
logging.error(
|
||||
f"Error checking fast registration setting: {str(e)}")
|
||||
return False
|
||||
|
||||
def create_connection_page(self):
|
||||
page = QWidget()
|
||||
layout = QVBoxLayout(page)
|
||||
layout.setSpacing(20)
|
||||
layout.setContentsMargins(20, 20, 20, 20)
|
||||
|
||||
title = QLabel("CONNECTION PAGE")
|
||||
title.setStyleSheet(
|
||||
f"color: #808080; font-size: 12px; font-weight: bold; {self.font_style}")
|
||||
layout.addWidget(title)
|
||||
|
||||
description = QLabel(
|
||||
"Control connection settings such as the firewall.")
|
||||
description.setWordWrap(True)
|
||||
description.setStyleSheet(
|
||||
f"color: white; font-size: 14px; {self.font_style}")
|
||||
layout.addWidget(description)
|
||||
|
||||
status_layout = QHBoxLayout()
|
||||
status_label = QLabel("Current status:")
|
||||
status_label.setStyleSheet(
|
||||
f"color: white; font-size: 14px; {self.font_style}")
|
||||
self.firewall_status_value = QLabel("")
|
||||
self.firewall_status_value.setStyleSheet(
|
||||
f"color: #e67e22; font-size: 14px; {self.font_style}")
|
||||
status_layout.addWidget(status_label)
|
||||
status_layout.addWidget(self.firewall_status_value)
|
||||
status_layout.addStretch()
|
||||
layout.addLayout(status_layout)
|
||||
|
||||
toggle_layout = QHBoxLayout()
|
||||
self.firewall_toggle = QCheckBox("Enable Firewall Automatically when Systemwide Profiles are Activated")
|
||||
self.firewall_toggle.setStyleSheet(self.get_checkbox_style())
|
||||
toggle_layout.addWidget(self.firewall_toggle)
|
||||
toggle_layout.addStretch()
|
||||
layout.addLayout(toggle_layout)
|
||||
|
||||
save_button = QPushButton()
|
||||
save_button.setFixedSize(75, 46)
|
||||
save_button.setIcon(QIcon(os.path.join(self.btn_path, "save.png")))
|
||||
save_button.setIconSize(QSize(75, 46))
|
||||
save_button.clicked.connect(self.save_firewall_settings)
|
||||
|
||||
button_layout = QHBoxLayout()
|
||||
button_layout.addWidget(save_button)
|
||||
button_layout.addStretch()
|
||||
layout.addLayout(button_layout)
|
||||
|
||||
layout.addStretch()
|
||||
self.load_firewall_settings(
|
||||
self._prepared_value("firewall_setting", settings_data.read_firewall_setting))
|
||||
return page
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@ from core.controllers.tickets.TicketPayController import check_if_paid
|
|||
|
||||
from gui.v2.infrastructure.setup_observers import connection_observer, ticket_observer
|
||||
from gui.v2.ui.pages.Page import Page
|
||||
from gui.v2.ui.popups.message_box import style_message_box, mark_confirm_button
|
||||
from gui.v2.workers.ticketing_worker_thread import TicketingWorkerThread
|
||||
|
||||
|
||||
|
|
@ -77,7 +78,13 @@ class TicketCryptoPickerPage(Page):
|
|||
clipboard = QApplication.clipboard()
|
||||
clipboard.setText(temp_billing_code)
|
||||
not_paid_msg = f"The billing code is not yet showing paid for {temp_billing_code}. Right now, your clipboard has the billing code, to paste it in any text editor. If you did pay, either wait longer for blockchain confirmation, or contact customer support with the code in your clipboard now."
|
||||
QMessageBox.information(None, "Not Paid", not_paid_msg)
|
||||
info = QMessageBox(self)
|
||||
info.setWindowTitle("Not Paid")
|
||||
info.setText(not_paid_msg)
|
||||
info.setStandardButtons(QMessageBox.StandardButton.Ok)
|
||||
style_message_box(info)
|
||||
mark_confirm_button(info.button(QMessageBox.StandardButton.Ok))
|
||||
info.exec()
|
||||
|
||||
def start_initiate_payment(self, currency):
|
||||
self.update_status.update_status("Initiating payment...")
|
||||
|
|
@ -121,6 +128,8 @@ class TicketCryptoPickerPage(Page):
|
|||
msg.setWindowTitle("Existing tickets found")
|
||||
msg.setText("You already have ticket data. Wipe it and start over?")
|
||||
msg.setStandardButtons(QMessageBox.StandardButton.Yes | QMessageBox.StandardButton.No)
|
||||
style_message_box(msg)
|
||||
mark_confirm_button(msg.button(QMessageBox.StandardButton.Yes))
|
||||
result = msg.exec()
|
||||
if result == QMessageBox.StandardButton.Yes:
|
||||
self.bypass_existing = True
|
||||
|
|
@ -135,6 +144,8 @@ class TicketCryptoPickerPage(Page):
|
|||
msg.setWindowTitle("Existing billing code found")
|
||||
msg.setText("You already have a ticket billing code. Do you want to use it? Only hit YES if you ALREADY paid.")
|
||||
msg.setStandardButtons(QMessageBox.StandardButton.Yes | QMessageBox.StandardButton.No)
|
||||
style_message_box(msg)
|
||||
mark_confirm_button(msg.button(QMessageBox.StandardButton.Yes))
|
||||
result = msg.exec()
|
||||
if result == QMessageBox.StandardButton.Yes:
|
||||
self.update_status.update_status("Reusing same code")
|
||||
|
|
|
|||
|
|
@ -109,6 +109,7 @@ class TicketOrBillingChoicePage(Page):
|
|||
if menu_page:
|
||||
self.update_status.update_status(f"Using ticket #{which_ticket}...")
|
||||
menu_page.enabling_profile(profile_data)
|
||||
self.custom_window.navigator.navigate("menu")
|
||||
|
||||
def on_use_billing(self):
|
||||
self.custom_window.navigator.navigate("id")
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ class WelcomePage(Page):
|
|||
self.btn_path = main_window.btn_path
|
||||
self.update_status = main_window
|
||||
self.ui_elements = []
|
||||
self.button_next.clicked.connect(self.go_to_install)
|
||||
self.button_next.clicked.connect(self.go_to_networking_setup)
|
||||
self.button_next.setVisible(True)
|
||||
self._setup_welcome_ui()
|
||||
self._setup_stats_display()
|
||||
|
|
@ -30,7 +30,7 @@ class WelcomePage(Page):
|
|||
|
||||
welcome_msg = QLabel(
|
||||
"Before we begin your journey, we need to set up a few essential components. "
|
||||
"Click 'Next' to take you to the installation page.", self)
|
||||
"Click 'Next' to review the optional networking setup.", self)
|
||||
welcome_msg.setGeometry(40, 100, 720, 80)
|
||||
welcome_msg.setWordWrap(True)
|
||||
welcome_msg.setStyleSheet("""
|
||||
|
|
@ -95,7 +95,7 @@ class WelcomePage(Page):
|
|||
"font-size: 16px; font-weight: bold; color: #2c3e50;")
|
||||
title_layout.addWidget(title_label)
|
||||
|
||||
status_indicator = QLabel("●")
|
||||
status_indicator = QLabel(chr(9679))
|
||||
status_indicator.setStyleSheet("color: #2ecc71; font-size: 16px;")
|
||||
title_layout.addWidget(status_indicator)
|
||||
|
||||
|
|
@ -117,8 +117,5 @@ class WelcomePage(Page):
|
|||
|
||||
grid_layout.addWidget(stat_widget, row, col)
|
||||
|
||||
def go_to_install(self):
|
||||
self.custom_window.navigator.navigate("install_system_package")
|
||||
install_page = self.custom_window.navigator.get_cached("install_system_package")
|
||||
if install_page is not None:
|
||||
install_page.configure(package_name='all', distro='debian')
|
||||
def go_to_networking_setup(self):
|
||||
self.custom_window.navigator.navigate("networking_setup")
|
||||
|
|
|
|||
290
gui/v2/ui/popups/Database_version.py
Executable file
290
gui/v2/ui/popups/Database_version.py
Executable file
|
|
@ -0,0 +1,290 @@
|
|||
from core.Constants import Constants
|
||||
|
||||
from PyQt6.QtWidgets import QApplication, QDialog, QVBoxLayout, QHBoxLayout, QLabel, QPushButton, QFrame, QScrollArea
|
||||
from PyQt6.QtCore import Qt, QSize
|
||||
from PyQt6.QtGui import QIcon, QFont, QColor, QPalette, QPixmap, QPainter
|
||||
import sys
|
||||
|
||||
APP_VERSION = Constants.DB_VERSION_THIS_APP_WANTS
|
||||
|
||||
class DatabaseConflictDialog(QDialog):
|
||||
WIPE = 1
|
||||
MOVE_DB = 2
|
||||
EXIT = 3
|
||||
|
||||
def __init__(self, check: dict, parent=None):
|
||||
super().__init__(parent)
|
||||
self.setWindowTitle("Database Recovery")
|
||||
self.setModal(True)
|
||||
self.user_choice = self.EXIT
|
||||
self.setMinimumWidth(550)
|
||||
self.setMinimumHeight(400)
|
||||
self.setMaximumWidth(750)
|
||||
self.setMaximumHeight(600)
|
||||
|
||||
# Modern dark theme
|
||||
self.setStyleSheet("""
|
||||
DatabaseConflictDialog {
|
||||
background: qlineargradient(x1:0, y1:0, x2:1, y2:1,
|
||||
stop:0 #0f172a, stop:1 #1e293b);
|
||||
}
|
||||
""")
|
||||
|
||||
main_layout = QVBoxLayout()
|
||||
main_layout.setContentsMargins(0, 0, 0, 0)
|
||||
main_layout.setSpacing(0)
|
||||
|
||||
# Header with gradient and icon
|
||||
header = QFrame()
|
||||
header.setStyleSheet("""
|
||||
QFrame {
|
||||
background: qlineargradient(x1:0, y1:0, x2:1, y2:0,
|
||||
stop:0 #3b82f6, stop:1 #1e40af);
|
||||
border: none;
|
||||
}
|
||||
""")
|
||||
header.setFixedHeight(100)
|
||||
header_layout = QHBoxLayout()
|
||||
header_layout.setContentsMargins(30, 20, 30, 20)
|
||||
|
||||
# Warning icon (using unicode)
|
||||
icon_label = QLabel("⚠️")
|
||||
icon_label.setFont(QFont("Segoe UI", 48))
|
||||
header_layout.addWidget(icon_label, 0, Qt.AlignmentFlag.AlignLeft | Qt.AlignmentFlag.AlignVCenter)
|
||||
|
||||
######## Title Section. ##############
|
||||
|
||||
# First which messages to display,
|
||||
if check["status"] == "version_mismatch":
|
||||
error_title = "Upgrade Time!"
|
||||
error_subtitle = "Your App version and Database don't match"
|
||||
else:
|
||||
error_title = "Database Error"
|
||||
error_subtitle = "The Database can't properly start"
|
||||
|
||||
# then display them:
|
||||
title_layout = QVBoxLayout()
|
||||
title_layout.setSpacing(5)
|
||||
|
||||
title = QLabel(error_title)
|
||||
title.setFont(QFont("Segoe UI", 18, QFont.Weight.Bold))
|
||||
title.setStyleSheet("color: white;")
|
||||
title_layout.addWidget(title)
|
||||
|
||||
subtitle = QLabel(error_subtitle)
|
||||
subtitle.setFont(QFont("Segoe UI", 11))
|
||||
subtitle.setStyleSheet("color: rgba(255, 255, 255, 0.8);")
|
||||
title_layout.addWidget(subtitle)
|
||||
|
||||
header_layout.addLayout(title_layout, 1)
|
||||
header.setLayout(header_layout)
|
||||
main_layout.addWidget(header)
|
||||
|
||||
# Content area with scroll support
|
||||
content = QFrame()
|
||||
content.setStyleSheet("""
|
||||
QFrame {
|
||||
background: #1e293b;
|
||||
border: none;
|
||||
}
|
||||
""")
|
||||
content_layout = QVBoxLayout()
|
||||
content_layout.setContentsMargins(0, 0, 0, 0)
|
||||
content_layout.setSpacing(0)
|
||||
|
||||
# Scrollable area for dynamic content
|
||||
scroll_area = QScrollArea()
|
||||
scroll_area.setWidgetResizable(True)
|
||||
scroll_area.setStyleSheet("""
|
||||
QScrollArea {
|
||||
background: #1e293b;
|
||||
border: none;
|
||||
}
|
||||
QScrollBar:vertical {
|
||||
background: #1e293b;
|
||||
width: 12px;
|
||||
}
|
||||
QScrollBar::handle:vertical {
|
||||
background: #475569;
|
||||
border-radius: 6px;
|
||||
min-height: 20px;
|
||||
}
|
||||
QScrollBar::handle:vertical:hover {
|
||||
background: #64748b;
|
||||
}
|
||||
QScrollBar::add-line:vertical, QScrollBar::sub-line:vertical {
|
||||
border: none;
|
||||
}
|
||||
""")
|
||||
|
||||
# Inner scrollable widget
|
||||
scroll_widget = QFrame()
|
||||
scroll_widget.setStyleSheet("background: #1e293b; border: none;")
|
||||
scroll_layout = QVBoxLayout()
|
||||
scroll_layout.setContentsMargins(40, 30, 40, 30)
|
||||
scroll_layout.setSpacing(15)
|
||||
|
||||
# Main message
|
||||
message = QLabel(check["message"])
|
||||
message.setFont(QFont("Segoe UI", 12))
|
||||
message.setStyleSheet("color: #e2e8f0; line-height: 1.6;")
|
||||
message.setWordWrap(True)
|
||||
scroll_layout.addWidget(message)
|
||||
|
||||
# Version info
|
||||
if check.get("db_version"):
|
||||
info_frame = QFrame()
|
||||
info_frame.setStyleSheet("""
|
||||
QFrame {
|
||||
background: rgba(59, 130, 246, 0.1);
|
||||
border: 1px solid rgba(59, 130, 246, 0.3);
|
||||
border-radius: 6px;
|
||||
}
|
||||
""")
|
||||
info_layout = QVBoxLayout()
|
||||
info_layout.setContentsMargins(15, 12, 15, 12)
|
||||
info_layout.setSpacing(5)
|
||||
|
||||
app_ver = QLabel(f"App is looking for database version: {APP_VERSION}")
|
||||
app_ver.setFont(QFont("Segoe UI", 10))
|
||||
app_ver.setStyleSheet("color: #94a3b8;")
|
||||
info_layout.addWidget(app_ver)
|
||||
|
||||
db_ver = QLabel(f"Your Actual Database version: {check['db_version']}")
|
||||
db_ver.setFont(QFont("Segoe UI", 10))
|
||||
db_ver.setStyleSheet("color: #94a3b8;")
|
||||
info_layout.addWidget(db_ver)
|
||||
|
||||
info_frame.setLayout(info_layout)
|
||||
scroll_layout.addWidget(info_frame)
|
||||
|
||||
scroll_layout.addStretch()
|
||||
scroll_widget.setLayout(scroll_layout)
|
||||
scroll_area.setWidget(scroll_widget)
|
||||
content_layout.addWidget(scroll_area, 1)
|
||||
|
||||
content.setLayout(content_layout)
|
||||
main_layout.addWidget(content, 1)
|
||||
|
||||
# Button area
|
||||
button_area = QFrame()
|
||||
button_area.setStyleSheet("""
|
||||
QFrame {
|
||||
background: #0f172a;
|
||||
border-top: 1px solid #334155;
|
||||
}
|
||||
""")
|
||||
button_layout = QVBoxLayout()
|
||||
button_layout.setContentsMargins(40, 20, 40, 20)
|
||||
button_layout.setSpacing(12)
|
||||
|
||||
if check["status"] == "version_mismatch":
|
||||
btn_backup = self._create_button(
|
||||
"Create a Fresh Database. Then restart (recommended)",
|
||||
"primary",
|
||||
"✅"
|
||||
)
|
||||
btn_backup.clicked.connect(self.on_wipe_create)
|
||||
button_layout.addWidget(btn_backup)
|
||||
|
||||
btn_different = self._create_button(
|
||||
"Move the Stale Database for Debug Purposes",
|
||||
"secondary",
|
||||
"📁"
|
||||
)
|
||||
btn_different.clicked.connect(self.on_move_db)
|
||||
button_layout.addWidget(btn_different)
|
||||
|
||||
btn_exit = self._create_button(
|
||||
"Exit App without action.",
|
||||
"danger",
|
||||
"❌"
|
||||
)
|
||||
btn_exit.clicked.connect(self.on_exit)
|
||||
button_layout.addWidget(btn_exit)
|
||||
|
||||
button_area.setLayout(button_layout)
|
||||
main_layout.addWidget(button_area)
|
||||
|
||||
self.setLayout(main_layout)
|
||||
|
||||
def _create_button(self, text, style_type, icon):
|
||||
"""Create a styled button"""
|
||||
btn = QPushButton(f" {icon} {text}")
|
||||
btn.setFont(QFont("Segoe UI", 11, QFont.Weight.Medium))
|
||||
btn.setFixedHeight(45)
|
||||
btn.setCursor(Qt.CursorShape.PointingHandCursor)
|
||||
|
||||
if style_type == "primary":
|
||||
btn.setStyleSheet("""
|
||||
QPushButton {
|
||||
background: qlineargradient(x1:0, y1:0, x2:1, y2:0,
|
||||
stop:0 #3b82f6, stop:1 #2563eb);
|
||||
color: white;
|
||||
border: none;
|
||||
border-radius: 6px;
|
||||
font-weight: 600;
|
||||
}
|
||||
QPushButton:hover {
|
||||
background: qlineargradient(x1:0, y1:0, x2:1, y2:0,
|
||||
stop:0 #2563eb, stop:1 #1d4ed8);
|
||||
}
|
||||
QPushButton:pressed {
|
||||
background: #1d4ed8;
|
||||
}
|
||||
""")
|
||||
elif style_type == "secondary":
|
||||
btn.setStyleSheet("""
|
||||
QPushButton {
|
||||
background: #334155;
|
||||
color: #e2e8f0;
|
||||
border: 1px solid #475569;
|
||||
border-radius: 6px;
|
||||
font-weight: 600;
|
||||
}
|
||||
QPushButton:hover {
|
||||
background: #475569;
|
||||
border: 1px solid #64748b;
|
||||
}
|
||||
QPushButton:pressed {
|
||||
background: #1e293b;
|
||||
}
|
||||
""")
|
||||
elif style_type == "danger":
|
||||
btn.setStyleSheet("""
|
||||
QPushButton {
|
||||
background: #64748b;
|
||||
color: #e2e8f0;
|
||||
border: 1px solid #475569;
|
||||
border-radius: 6px;
|
||||
font-weight: 600;
|
||||
}
|
||||
QPushButton:hover {
|
||||
background: #ef4444;
|
||||
border: 1px solid #dc2626;
|
||||
}
|
||||
QPushButton:pressed {
|
||||
background: #dc2626;
|
||||
}
|
||||
""")
|
||||
|
||||
return btn
|
||||
|
||||
def on_wipe_create(self):
|
||||
self.user_choice = self.WIPE
|
||||
self.accept()
|
||||
|
||||
def on_move_db(self):
|
||||
self.user_choice = self.MOVE_DB
|
||||
self.accept()
|
||||
|
||||
def on_exit(self):
|
||||
self.user_choice = self.EXIT
|
||||
self.reject()
|
||||
|
||||
def show_recovery_dialog(check: dict):
|
||||
"""Show recovery dialog as standalone app and return user choice"""
|
||||
app = QApplication.instance() or QApplication(sys.argv)
|
||||
dialog = DatabaseConflictDialog(check)
|
||||
dialog.exec()
|
||||
return dialog.user_choice
|
||||
10
gui/v2/ui/popups/generic_error_popup.py
Executable file
10
gui/v2/ui/popups/generic_error_popup.py
Executable file
|
|
@ -0,0 +1,10 @@
|
|||
from PyQt6.QtWidgets import QApplication, QMessageBox
|
||||
import sys
|
||||
|
||||
def show_error(error_text, title="Error"):
|
||||
app = QApplication.instance()
|
||||
if app is None:
|
||||
app = QApplication(sys.argv)
|
||||
|
||||
QMessageBox.critical(None, title, error_text)
|
||||
app.quit()
|
||||
18
gui/v2/ui/popups/message_box.py
Executable file
18
gui/v2/ui/popups/message_box.py
Executable file
|
|
@ -0,0 +1,18 @@
|
|||
MESSAGE_BOX_QSS = (
|
||||
"QMessageBox { background-color: white; }"
|
||||
"QMessageBox QLabel { color: black; }"
|
||||
"QMessageBox QPushButton { color: black; padding: 5px 14px; }"
|
||||
)
|
||||
|
||||
CONFIRM_BUTTON_QSS = "color: #2e7d32; font-weight: bold; padding: 5px 14px;"
|
||||
|
||||
|
||||
def style_message_box(box):
|
||||
box.setStyleSheet(MESSAGE_BOX_QSS)
|
||||
|
||||
|
||||
def mark_confirm_button(button):
|
||||
if button is None:
|
||||
return
|
||||
button.setText(f"✓ {button.text()}")
|
||||
button.setStyleSheet(CONFIRM_BUTTON_QSS)
|
||||
50
gui/v2/ui/popups/pick_folder_to_move.py
Executable file
50
gui/v2/ui/popups/pick_folder_to_move.py
Executable file
|
|
@ -0,0 +1,50 @@
|
|||
import shutil
|
||||
import sys
|
||||
from pathlib import Path
|
||||
from PyQt6.QtWidgets import QApplication, QFileDialog
|
||||
|
||||
def move_database_file(original_filepath: str) -> bool:
|
||||
"""
|
||||
Prompts the user to select a destination for a .db file and moves it there.
|
||||
|
||||
Args:
|
||||
original_filepath: The current path to the .db file
|
||||
|
||||
Returns:
|
||||
True if the move was successful, False otherwise
|
||||
"""
|
||||
# Create a QApplication if one doesn't already exist
|
||||
app = QApplication.instance()
|
||||
if app is None:
|
||||
app = QApplication(sys.argv)
|
||||
|
||||
# Validate that the original file exists
|
||||
if not Path(original_filepath).exists():
|
||||
print(f"Error: File not found at {original_filepath}")
|
||||
return False
|
||||
|
||||
# Open the file save dialog
|
||||
destination, _ = QFileDialog.getSaveFileName(
|
||||
None,
|
||||
"Select destination for database file",
|
||||
str(Path(original_filepath).parent), # Start in the original file's directory
|
||||
"Database Files (*.db);;All Files (*)"
|
||||
)
|
||||
|
||||
# If the user cancelled the dialog
|
||||
if not destination:
|
||||
print("Operation cancelled by user")
|
||||
return False
|
||||
|
||||
try:
|
||||
# Move the file
|
||||
shutil.move(original_filepath, destination)
|
||||
print(f"File successfully moved to: {destination}")
|
||||
return True
|
||||
except Exception as e:
|
||||
print(f"Error moving file: {e}")
|
||||
return False
|
||||
|
||||
|
||||
def launch_file_picker(original_path):
|
||||
move_database_file(original_path)
|
||||
22
gui/v2/ui/styles/css/main_ui_css.py
Executable file
22
gui/v2/ui/styles/css/main_ui_css.py
Executable file
|
|
@ -0,0 +1,22 @@
|
|||
|
||||
|
||||
forced_sync_popup_style = """
|
||||
QPushButton {
|
||||
background-color: #3498db;
|
||||
color: white;
|
||||
border: none;
|
||||
border-radius: 5px;
|
||||
padding: 8px 20px;
|
||||
font-weight: bold;
|
||||
min-width: 80px;
|
||||
}
|
||||
QPushButton:hover {
|
||||
background-color: #2980b9;
|
||||
}
|
||||
QPushButton[text="Cancel"] {
|
||||
background-color: #e74c3c;
|
||||
}
|
||||
QPushButton[text="Cancel"]:hover {
|
||||
background-color: #c0392b;
|
||||
}
|
||||
"""
|
||||
|
|
@ -116,6 +116,42 @@ POPUP_ACTION_BUTTON_RED_QSS = """
|
|||
"""
|
||||
|
||||
|
||||
def combobox_style(font_style=""):
|
||||
return f"""
|
||||
QComboBox {{
|
||||
color: black;
|
||||
background: #f0f0f0;
|
||||
padding: 5px 30px 5px 10px;
|
||||
border: 1px solid #ccc;
|
||||
border-radius: 4px;
|
||||
min-width: 120px;
|
||||
margin-bottom: 10px;
|
||||
{font_style}
|
||||
}}
|
||||
QComboBox:disabled {{
|
||||
color: #666;
|
||||
background: #e0e0e0;
|
||||
}}
|
||||
QComboBox::drop-down {{
|
||||
border: none;
|
||||
width: 30px;
|
||||
}}
|
||||
QComboBox::down-arrow {{
|
||||
image: url(assets/down_arrow.png);
|
||||
width: 12px;
|
||||
height: 12px;
|
||||
}}
|
||||
QComboBox QAbstractItemView {{
|
||||
color: black;
|
||||
background: white;
|
||||
selection-background-color: #007bff;
|
||||
selection-color: white;
|
||||
border: 1px solid #ccc;
|
||||
{font_style}
|
||||
}}
|
||||
"""
|
||||
|
||||
|
||||
def checkbox_style(font_style=""):
|
||||
return f"""
|
||||
QCheckBox {{
|
||||
|
|
|
|||
19
gui/v2/workers/page_data_worker.py
Executable file
19
gui/v2/workers/page_data_worker.py
Executable file
|
|
@ -0,0 +1,19 @@
|
|||
from PyQt6.QtCore import QThread, pyqtSignal
|
||||
|
||||
|
||||
class PageDataWorker(QThread):
|
||||
data_ready = pyqtSignal(str, object)
|
||||
failed = pyqtSignal(str, str)
|
||||
|
||||
def __init__(self, name, fn, *args):
|
||||
super().__init__()
|
||||
self.name = name
|
||||
self.fn = fn
|
||||
self.args = args
|
||||
|
||||
def run(self):
|
||||
try:
|
||||
payload = self.fn(*self.args)
|
||||
self.data_ready.emit(self.name, payload)
|
||||
except Exception as error:
|
||||
self.failed.emit(self.name, f"{type(error).__name__}: {error}")
|
||||
|
|
@ -10,6 +10,8 @@ from core.controllers.tickets.UseTicketController import (
|
|||
)
|
||||
from core.models.session.SessionProfile import SessionProfile
|
||||
from core.models.system.SystemProfile import SystemProfile
|
||||
from core.models.Result import Result, ResultError
|
||||
from core.errors.exceptions import SudoScript, MissingPreReqs
|
||||
from core.Errors import (
|
||||
CommandNotFoundError,
|
||||
EndpointVerificationError,
|
||||
|
|
@ -114,6 +116,10 @@ class Worker(QObject):
|
|||
"PROFILE_STATE_CONFLICT_ERROR", False, self.profile_data['id'], None, None)
|
||||
except CommandNotFoundError as e:
|
||||
self.update_signal.emit(str(e.subject), False, -1, None, None)
|
||||
except SudoScript as e:
|
||||
self.update_signal.emit(str(e), False, None, None, None)
|
||||
except MissingPreReqs as e:
|
||||
self.update_signal.emit(str(e), False, None, None, None)
|
||||
except Exception as e:
|
||||
print(e)
|
||||
self.update_signal.emit(
|
||||
|
|
|
|||
|
|
@ -14,7 +14,10 @@ from core.controllers.SubscriptionPlanController import SubscriptionPlanControll
|
|||
from core.models.session.SessionConnection import SessionConnection
|
||||
from core.models.session.SessionProfile import SessionProfile
|
||||
from core.models.system.SystemConnection import SystemConnection
|
||||
from core.models.BaseProfile import ProfileType
|
||||
from core.models.system.SystemProfile import SystemProfile
|
||||
from core.errors.exceptions import SudoScript, MissingPreReqs
|
||||
from core.models.Result import Result, ResultError
|
||||
|
||||
from gui.v2.infrastructure.setup_observers import (
|
||||
client_observer,
|
||||
|
|
@ -132,6 +135,10 @@ class WorkerThread(QThread):
|
|||
ProfileController.disable(
|
||||
profile, ignore=True, profile_observer=profile_observer)
|
||||
self.text_output.emit("All profiles were successfully disabled")
|
||||
# except SudoScript as e:
|
||||
# self.text_output.emit(e)
|
||||
# except MissingPreReqs as e:
|
||||
# self.text_output.emit(e)
|
||||
except Exception:
|
||||
self.text_output.emit("An error occurred when disabling profile")
|
||||
finally:
|
||||
|
|
@ -189,12 +196,23 @@ class WorkerThread(QThread):
|
|||
resolution = self.profile_data['resolution']
|
||||
connection = SessionConnection(connection_type, mask_connection)
|
||||
profile = SessionProfile(
|
||||
profile_id, name, None, location, resolution, application_version, connection)
|
||||
id=profile_id,
|
||||
name=name,
|
||||
subscription=None,
|
||||
type=ProfileType.SESSION,
|
||||
location=location,
|
||||
resolution=resolution,
|
||||
application_version=application_version,
|
||||
connection=connection)
|
||||
elif profile_type == "system":
|
||||
connection = SystemConnection(connection_type)
|
||||
profile = SystemProfile(
|
||||
profile_id, name, None, location, connection)
|
||||
|
||||
id=profile_id,
|
||||
name=name,
|
||||
type=ProfileType.SYSTEM,
|
||||
subscription=None,
|
||||
location=location,
|
||||
connection=connection)
|
||||
else:
|
||||
self.text_output.emit(f"Invalid profile type: {profile_type}")
|
||||
return
|
||||
|
|
@ -217,6 +235,10 @@ class WorkerThread(QThread):
|
|||
else:
|
||||
self.text_output.emit(
|
||||
f"No profile found with ID: {self.profile_data['id']}")
|
||||
# except SudoScript as e:
|
||||
# self.text_output.emit(str(e))
|
||||
# except MissingPreReqs as e:
|
||||
# self.text_output.emit(str(e))
|
||||
except Exception as e:
|
||||
self.text_output.emit("An error occurred when disabling profile")
|
||||
finally:
|
||||
|
|
@ -229,8 +251,12 @@ class WorkerThread(QThread):
|
|||
else:
|
||||
ConfigurationController.set_connection('system')
|
||||
self.check_for_update()
|
||||
|
||||
locations = LocationController.get_all()
|
||||
|
||||
|
||||
browser = ApplicationVersionController.get_all()
|
||||
# print('the browser is: ', browser)
|
||||
all_browser_versions = [
|
||||
f"{browser.application_code}:{browser.version_number}" for browser in browser if browser.supported]
|
||||
all_location_codes = [
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
[project]
|
||||
name = "sp-hydra-veil-gui"
|
||||
version = "2.3.1"
|
||||
version = "2.4.7"
|
||||
authors = [
|
||||
{ name = "Simplified Privacy" },
|
||||
]
|
||||
|
|
@ -12,7 +12,7 @@ classifiers = [
|
|||
"Operating System :: POSIX :: Linux",
|
||||
]
|
||||
dependencies = [
|
||||
"sp-hydra-veil-core == 2.3.4",
|
||||
"sp-hydra-veil-core == 2.4.3",
|
||||
"pyperclip ~= 1.9.0",
|
||||
"pyqt6 ~= 6.7.1",
|
||||
"qrcode[pil] ~= 8.2"
|
||||
|
|
|
|||
Loading…
Reference in a new issue