hydraveil-gui/gui/v2/ui/pages/fast_registration_page.py
2026-06-13 16:19:11 -04:00

787 lines
33 KiB
Python
Executable file

import os
import random
from PyQt6.QtWidgets import (
QDialog, QHBoxLayout, QLabel, QLineEdit, QMessageBox, QPushButton, QVBoxLayout
)
from PyQt6.QtGui import QIcon, QPixmap, QTransform
from PyQt6.QtCore import QSize
from PyQt6 import QtCore
from core.controllers.ProfileController import ProfileController
from gui.v2.actions.profile_order import append_profile_to_visual_order
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.worker_thread import WorkerThread
class FastRegistrationPage(Page):
def __init__(self, page_stack, main_window):
super().__init__("FastRegistration", page_stack, main_window)
self.page_stack = page_stack
self.update_status = main_window
self.connection_manager = main_window.connection_manager
self.labels = []
self.buttons = []
self.title.setGeometry(550, 40, 250, 40)
self.title.setText("Fast Creation")
self.button_apply.setVisible(True)
self.button_apply.clicked.connect(self.create_profile)
self.button_back.setVisible(True)
try:
self.button_back.clicked.disconnect()
except TypeError:
pass
self.button_back.clicked.connect(self.go_back)
self.name_handle = QLabel(self)
self.name_handle.setGeometry(110, 70, 400, 30)
self.name_handle.setStyleSheet('color: #cacbcb;')
self.name_handle.setText("Profile Name:")
self.name_hint = QLabel(self)
self.name_hint.setGeometry(265, 100, 190, 20)
self.name_hint.setStyleSheet(
'color: #888888; font-size: 10px; font-style: italic;')
self.name_hint.setText("Click here to edit profile name")
self.name_hint.setAlignment(QtCore.Qt.AlignmentFlag.AlignCenter)
self.name = QLineEdit(self)
self.name.setPlaceholderText("Enter name")
self.name.setGeometry(265, 70, 190, 30)
self.name.setStyleSheet(
"color: cyan; border: 1px solid #666666; border-radius: 3px; background-color: rgba(0, 0, 0, 0.3);")
self.name.setCursor(QtCore.Qt.CursorShape.IBeamCursor)
self.name.focusInEvent = lambda event: self.name_hint.hide()
self.name.focusOutEvent = lambda event: self.name_hint.show(
) if not self.name.text() else self.name_hint.hide()
self.name.textChanged.connect(
lambda text: self.name_hint.hide() if text else self.name_hint.show())
self.profile_data = {}
self.selected_values = {
'protocol': 'wireguard',
'connection': 'browser-only',
'location': '',
'browser': '',
'resolution': '1024x760'
}
self.res_index = 1
self.initialize_default_selections()
def initialize_default_selections(self):
if not self.selected_values['location']:
locations = self.connection_manager.get_location_list()
if locations:
random_index = random.randint(0, len(locations) - 1)
self.selected_values['location'] = locations[random_index]
if not self.selected_values['browser']:
browsers = self.connection_manager.get_browser_list()
if browsers:
random_index = random.randint(0, len(browsers) - 1)
self.selected_values['browser'] = browsers[random_index]
def get_next_available_profile_id(self, profiles=None) -> int:
if profiles is None:
profiles = ProfileController.get_all()
if not profiles:
return 1
existing_ids = sorted(profiles.keys())
for i in range(1, max(existing_ids) + 2):
if i not in existing_ids:
return i
return 1
def showEvent(self, event):
super().showEvent(event)
self.initialize_default_selections()
self.create_interface_elements()
def create_interface_elements(self):
for label in self.labels:
label.deleteLater()
self.labels = []
for button in self.buttons:
button.deleteLater()
self.buttons = []
if not self.name.text():
self.name_hint.show()
else:
self.name_hint.hide()
self.host_info_label = QLabel(
f"Host Screen: {self.update_status.host_screen_width}x{self.update_status.host_screen_height}", self)
self.host_info_label.setGeometry(415, 470, 250, 20)
self.host_info_label.setAlignment(QtCore.Qt.AlignmentFlag.AlignCenter)
self.host_info_label.setStyleSheet(
"color: #00ffff; font-size: 13px; font-weight: bold;")
self.host_info_label.show()
self.labels.append(self.host_info_label)
self.create_protocol_section()
self.create_connection_section()
self.create_location_section()
if self.selected_values['connection'] != 'system-wide':
self.create_browser_section()
self.create_resolution_section()
self.update_ui_state_for_connection()
def create_protocol_section(self):
label = QLabel("Protocol", self)
label.setGeometry(300, 150, 185, 75)
protocol_image = QPixmap(os.path.join(
self.btn_path, f"{self.selected_values['protocol']}_button.png"))
label.setPixmap(protocol_image)
label.setScaledContents(True)
label.show()
self.labels.append(label)
prev_button = QPushButton(self)
prev_button.setGeometry(265, 150, 30, 75)
prev_button.clicked.connect(
lambda: self.show_previous_value('protocol'))
prev_button.show()
icon_path = os.path.join(self.btn_path, "UP_button.png")
icon = QPixmap(icon_path)
transform = QTransform().rotate(180)
rotated_icon = icon.transformed(transform)
prev_button.setIcon(QIcon(rotated_icon))
prev_button.setIconSize(prev_button.size())
self.buttons.append(prev_button)
next_button = QPushButton(self)
next_button.setGeometry(490, 150, 30, 75)
next_button.clicked.connect(lambda: self.show_next_value('protocol'))
next_button.show()
next_button.setIcon(
QIcon(os.path.join(self.btn_path, "UP_button.png")))
next_button.setIconSize(next_button.size())
self.buttons.append(next_button)
def create_connection_section(self):
label = QLabel("Connection", self)
label.setGeometry(150, 250, 185, 75)
if self.selected_values['connection']:
connection_image = QPixmap(os.path.join(
self.btn_path, f"{self.selected_values['connection']}_button.png"))
if connection_image.isNull():
fallback_path = os.path.join(
self.btn_path, "browser-only_button.png")
connection_image = QPixmap(fallback_path)
else:
connection_image = QPixmap(os.path.join(
self.btn_path, "browser-only_button.png"))
label.setPixmap(connection_image)
label.setScaledContents(True)
label.show()
self.labels.append(label)
prev_button = QPushButton(self)
prev_button.setGeometry(115, 250, 30, 75)
prev_button.clicked.connect(
lambda: self.show_previous_value('connection'))
prev_button.show()
icon_path = os.path.join(self.btn_path, "UP_button.png")
icon = QPixmap(icon_path)
transform = QTransform().rotate(180)
rotated_icon = icon.transformed(transform)
prev_button.setIcon(QIcon(rotated_icon))
prev_button.setIconSize(prev_button.size())
self.buttons.append(prev_button)
next_button = QPushButton(self)
next_button.setGeometry(340, 250, 30, 75)
next_button.clicked.connect(lambda: self.show_next_value('connection'))
next_button.show()
next_button.setIcon(
QIcon(os.path.join(self.btn_path, "UP_button.png")))
next_button.setIconSize(next_button.size())
self.buttons.append(next_button)
def create_location_section(self):
info_label = QLabel("Click on the location for more info", self)
info_label.setGeometry(480, 80, 300, 20)
info_label.setStyleSheet(
"color: #888888; font-size: 14px; font-style: italic;")
info_label.setAlignment(QtCore.Qt.AlignmentFlag.AlignRight)
info_label.show()
self.labels.append(info_label)
arrow_label = QLabel(self)
arrow_label.setGeometry(540, 100, 150, 150)
arrow_pixmap = QPixmap(os.path.join(self.btn_path, "arrow.png"))
transform = QTransform().rotate(270)
rotated_arrow = arrow_pixmap.transformed(transform)
arrow_label.setPixmap(rotated_arrow)
arrow_label.setScaledContents(True)
arrow_label.show()
self.labels.append(arrow_label)
label = QPushButton(self)
label.setGeometry(435, 250, 185, 75)
label.setFlat(True)
label.setStyleSheet("background: transparent; border: none;")
if self.selected_values['location']:
image_path = os.path.join(
self.btn_path, f"button_{self.selected_values['location']}.png")
location_image = QPixmap(image_path)
locations = self.connection_manager.get_location_info(
self.selected_values['location'])
provider = locations.operator.name if locations and hasattr(
locations, 'operator') else None
fallback_path = os.path.join(
self.btn_path, "default_location_button.png")
if location_image.isNull():
if locations and hasattr(locations, 'country_name'):
location_name = locations.country_name
location_image = LocationPage.create_location_button_image(
location_name, fallback_path, provider)
else:
location_image = LocationPage.create_location_button_image(
self.selected_values['location'], fallback_path, provider)
else:
if locations and hasattr(locations, 'country_name'):
location_image = LocationPage.create_location_button_image(
f'{locations.country_code}_{locations.code}', fallback_path, provider, image_path)
else:
location_image = LocationPage.create_location_button_image(
self.selected_values['location'], fallback_path, provider, image_path)
else:
location_image = QPixmap(os.path.join(
self.btn_path, "default_location_button.png"))
label.setIcon(QIcon(location_image))
label.setIconSize(QSize(185, 75))
if self.selected_values['location']:
label.location_icon_name = self.selected_values['location']
label.setCursor(QtCore.Qt.CursorShape.PointingHandCursor)
label.clicked.connect(
lambda checked, loc=self.selected_values['location']: self.show_location_verification(loc))
locations = self.connection_manager.get_location_info(
self.selected_values['location'])
if self.selected_values['protocol'] == 'hidetor' and locations and not (hasattr(locations, 'is_proxy_capable') and locations.is_proxy_capable):
label.hide()
else:
label.show()
self.labels.append(label)
prev_button = QPushButton(self)
prev_button.setGeometry(400, 250, 30, 75)
prev_button.clicked.connect(
lambda: self.show_previous_value('location'))
prev_button.show()
icon_path = os.path.join(self.btn_path, "UP_button.png")
icon = QPixmap(icon_path)
transform = QTransform().rotate(180)
rotated_icon = icon.transformed(transform)
prev_button.setIcon(QIcon(rotated_icon))
prev_button.setIconSize(prev_button.size())
self.buttons.append(prev_button)
next_button = QPushButton(self)
next_button.setGeometry(625, 250, 30, 75)
next_button.clicked.connect(lambda: self.show_next_value('location'))
next_button.show()
next_button.setIcon(
QIcon(os.path.join(self.btn_path, "UP_button.png")))
next_button.setIconSize(next_button.size())
self.buttons.append(next_button)
def create_browser_section(self):
label = QLabel("Browser", self)
label.setGeometry(150, 350, 185, 75)
if self.selected_values['browser']:
browser_image = BrowserPage.create_browser_button_image(
self.selected_values['browser'], self.btn_path)
if browser_image.isNull():
fallback_path = os.path.join(
self.btn_path, "default_browser_button.png")
browser_image = BrowserPage.create_browser_button_image(
self.selected_values['browser'], fallback_path, True)
else:
browser_image = QPixmap()
label.setPixmap(browser_image)
label.setScaledContents(True)
label.show()
self.labels.append(label)
prev_button = QPushButton(self)
prev_button.setGeometry(115, 350, 30, 75)
prev_button.clicked.connect(
lambda: self.show_previous_value('browser'))
prev_button.show()
icon_path = os.path.join(self.btn_path, "UP_button.png")
icon = QPixmap(icon_path)
transform = QTransform().rotate(180)
rotated_icon = icon.transformed(transform)
prev_button.setIcon(QIcon(rotated_icon))
prev_button.setIconSize(prev_button.size())
self.buttons.append(prev_button)
next_button = QPushButton(self)
next_button.setGeometry(340, 350, 30, 75)
next_button.clicked.connect(lambda: self.show_next_value('browser'))
next_button.show()
next_button.setIcon(
QIcon(os.path.join(self.btn_path, "UP_button.png")))
next_button.setIconSize(next_button.size())
self.buttons.append(next_button)
def create_resolution_section(self):
from gui.v2.ui.pages.screen_page import ScreenPage
label = QLabel("Resolution", self)
label.setGeometry(435, 350, 185, 75)
screen_page = self.custom_window.navigator.get_cached("screen")
if screen_page is None:
self.custom_window.navigator.navigate("screen")
screen_page = self.custom_window.navigator.get_cached("screen")
self.custom_window.navigator.navigate("fast_registration")
if self.selected_values['resolution']:
resolution_image = screen_page.create_resolution_button_image(
self.selected_values['resolution'])
else:
resolution_image = screen_page.create_resolution_button_image(
"1024x760")
label.setPixmap(resolution_image)
label.setScaledContents(True)
label.show()
self.labels.append(label)
prev_button = QPushButton(self)
prev_button.setGeometry(400, 350, 30, 75)
prev_button.clicked.connect(
lambda: self.show_previous_value('resolution'))
prev_button.show()
icon_path = os.path.join(self.btn_path, "UP_button.png")
icon = QPixmap(icon_path)
transform = QTransform().rotate(180)
rotated_icon = icon.transformed(transform)
prev_button.setIcon(QIcon(rotated_icon))
prev_button.setIconSize(prev_button.size())
self.buttons.append(prev_button)
next_button = QPushButton(self)
next_button.setGeometry(625, 350, 30, 75)
next_button.clicked.connect(lambda: self.show_next_value('resolution'))
next_button.show()
next_button.setIcon(
QIcon(os.path.join(self.btn_path, "UP_button.png")))
next_button.setIconSize(next_button.size())
self.buttons.append(next_button)
custom_button = QPushButton("Custom", self)
custom_button.setGeometry(435, 430, 185, 30)
custom_button.setStyleSheet("""
QPushButton {
background-color: rgba(0, 255, 255, 0.1);
color: #00ffff;
border: 1px solid #00ffff;
border-radius: 5px;
font-size: 12px;
font-weight: bold;
}
QPushButton:hover {
background-color: rgba(0, 255, 255, 0.2);
}
""")
custom_button.clicked.connect(self.show_custom_res_dialog)
custom_button.show()
self.buttons.append(custom_button)
def show_custom_res_dialog(self):
dialog = QDialog(self)
dialog.setWindowTitle("Custom Resolution")
dialog.setFixedSize(300, 150)
dialog.setModal(True)
dialog.setStyleSheet("""
QDialog {
background-color: #2c3e50;
border: 2px solid #00ffff;
border-radius: 10px;
}
QLabel {
color: white;
font-size: 12px;
}
QLineEdit {
background-color: #34495e;
color: white;
border: 1px solid #00ffff;
border-radius: 5px;
padding: 5px;
font-size: 12px;
}
QPushButton {
background-color: #2c3e50;
color: white;
border: 2px solid #00ffff;
border-radius: 5px;
padding: 8px;
font-size: 12px;
}
QPushButton:hover {
background-color: #34495e;
}
""")
layout = QVBoxLayout()
input_layout = QHBoxLayout()
width_label = QLabel("Width:")
width_input = QLineEdit()
width_input.setPlaceholderText("1920")
height_label = QLabel("Height:")
height_input = QLineEdit()
height_input.setPlaceholderText("1080")
input_layout.addWidget(width_label)
input_layout.addWidget(width_input)
input_layout.addWidget(height_label)
input_layout.addWidget(height_input)
button_layout = QHBoxLayout()
ok_button = QPushButton("OK")
cancel_button = QPushButton("Cancel")
button_layout.addWidget(cancel_button)
button_layout.addWidget(ok_button)
layout.addLayout(input_layout)
layout.addLayout(button_layout)
dialog.setLayout(layout)
def validate_and_accept():
try:
width = int(width_input.text())
height = int(height_input.text())
if width <= 0 or height <= 0:
return
host_w = self.update_status.host_screen_width
host_h = self.update_status.host_screen_height
adjusted = False
if width > host_w:
width = host_w - 50
adjusted = True
if height > host_h:
height = host_h - 50
adjusted = True
if adjusted:
QMessageBox.information(
dialog, "Notice", "Adjusted to fit host size")
self.selected_values['resolution'] = f"{width}x{height}"
self.create_interface_elements()
dialog.accept()
except ValueError:
pass
ok_button.clicked.connect(validate_and_accept)
cancel_button.clicked.connect(dialog.reject)
width_input.returnPressed.connect(validate_and_accept)
height_input.returnPressed.connect(validate_and_accept)
dialog.exec()
def update_ui_state_for_connection(self):
is_system_wide = self.selected_values['connection'] == 'system-wide'
for button in self.buttons:
if hasattr(button, 'geometry'):
button_geometry = button.geometry()
if button_geometry.y() == 350:
if button_geometry.x() in [115, 340, 400, 625]:
button.setEnabled(not is_system_wide)
def show_previous_value(self, key):
if key == 'protocol':
protocols = ['wireguard', 'hidetor']
current_index = protocols.index(self.selected_values[key])
previous_index = (current_index - 1) % len(protocols)
self.selected_values[key] = protocols[previous_index]
if self.selected_values[key] == 'wireguard':
self.selected_values['connection'] = 'browser-only'
else:
self.selected_values['connection'] = 'tor'
loc_info = self.connection_manager.get_location_info(
self.selected_values['location'])
if not (loc_info and hasattr(loc_info, 'is_proxy_capable') and loc_info.is_proxy_capable):
locations = self.connection_manager.get_location_list()
proxy_locations = [loc for loc in locations if (l := self.connection_manager.get_location_info(
loc)) and hasattr(l, 'is_proxy_capable') and l.is_proxy_capable]
if proxy_locations:
self.selected_values['location'] = proxy_locations[0]
elif key == 'connection':
if self.selected_values['protocol'] == 'wireguard':
connections = ['browser-only', 'system-wide']
else:
connections = ['tor', 'just proxy']
current_index = connections.index(self.selected_values[key])
previous_index = (current_index - 1) % len(connections)
self.selected_values[key] = connections[previous_index]
self.update_ui_state_for_connection()
elif key == 'location':
locations = self.connection_manager.get_location_list()
if self.selected_values['protocol'] == 'hidetor':
locations = [loc for loc in locations if (l := self.connection_manager.get_location_info(
loc)) and hasattr(l, 'is_proxy_capable') and l.is_proxy_capable]
if locations and self.selected_values[key] in locations:
current_index = locations.index(self.selected_values[key])
previous_index = (current_index - 1) % len(locations)
self.selected_values[key] = locations[previous_index]
elif locations:
self.selected_values[key] = locations[0]
elif key == 'browser':
browsers = self.connection_manager.get_browser_list()
if browsers and self.selected_values[key] in browsers:
current_index = browsers.index(self.selected_values[key])
previous_index = (current_index - 1) % len(browsers)
self.selected_values[key] = browsers[previous_index]
elif browsers:
self.selected_values[key] = browsers[0]
elif key == 'resolution':
config = self.update_status._load_gui_config()
dynamic_enabled = config.get("registrations", {}).get(
"dynamic_larger_profiles", False) if config else False
if dynamic_enabled:
resolutions = []
host_w = self.update_status.host_screen_width
host_h = self.update_status.host_screen_height
for i in range(5):
resolutions.append(
f"{host_w - (50 * (i + 1))}x{host_h - (50 * (i + 1))}")
self.res_index = (self.res_index - 1) % len(resolutions)
self.selected_values[key] = resolutions[self.res_index]
else:
resolutions = ['800x600', '1024x760', '1152x1080', '1280x1024', '1920x1080',
'2560x1440', '2560x1600', '1920x1440', '1792x1344', '2048x1152']
self.res_index = (self.res_index - 1) % len(resolutions)
choice = resolutions[self.res_index]
w, h = map(int, choice.split('x'))
host_w = self.update_status.host_screen_width
host_h = self.update_status.host_screen_height
new_w, new_h = w, h
if w > host_w:
new_w = host_w - 50
if h > host_h:
new_h = host_h - 50
self.selected_values[key] = f"{new_w}x{new_h}"
self.create_interface_elements()
def show_next_value(self, key):
if key == 'protocol':
protocols = ['wireguard', 'hidetor']
current_index = protocols.index(self.selected_values[key])
next_index = (current_index + 1) % len(protocols)
self.selected_values[key] = protocols[next_index]
if self.selected_values[key] == 'wireguard':
self.selected_values['connection'] = 'browser-only'
else:
self.selected_values['connection'] = 'tor'
loc_info = self.connection_manager.get_location_info(
self.selected_values['location'])
if not (loc_info and hasattr(loc_info, 'is_proxy_capable') and loc_info.is_proxy_capable):
locations = self.connection_manager.get_location_list()
proxy_locations = [loc for loc in locations if (l := self.connection_manager.get_location_info(
loc)) and hasattr(l, 'is_proxy_capable') and l.is_proxy_capable]
if proxy_locations:
self.selected_values['location'] = proxy_locations[0]
elif key == 'connection':
if self.selected_values['protocol'] == 'wireguard':
connections = ['browser-only', 'system-wide']
else:
connections = ['tor', 'just proxy']
current_index = connections.index(self.selected_values[key])
next_index = (current_index + 1) % len(connections)
self.selected_values[key] = connections[next_index]
self.update_ui_state_for_connection()
elif key == 'location':
locations = self.connection_manager.get_location_list()
if self.selected_values['protocol'] == 'hidetor':
locations = [loc for loc in locations if (l := self.connection_manager.get_location_info(
loc)) and hasattr(l, 'is_proxy_capable') and l.is_proxy_capable]
if locations and self.selected_values[key] in locations:
current_index = locations.index(self.selected_values[key])
next_index = (current_index + 1) % len(locations)
self.selected_values[key] = locations[next_index]
elif locations:
self.selected_values[key] = locations[0]
elif key == 'browser':
browsers = self.connection_manager.get_browser_list()
if browsers and self.selected_values[key] in browsers:
current_index = browsers.index(self.selected_values[key])
next_index = (current_index + 1) % len(browsers)
self.selected_values[key] = browsers[next_index]
elif browsers:
self.selected_values[key] = browsers[0]
elif key == 'resolution':
config = self.update_status._load_gui_config()
dynamic_enabled = config.get("registrations", {}).get(
"dynamic_larger_profiles", False) if config else False
if dynamic_enabled:
resolutions = []
host_w = self.update_status.host_screen_width
host_h = self.update_status.host_screen_height
for i in range(5):
resolutions.append(
f"{host_w - (50 * (i + 1))}x{host_h - (50 * (i + 1))}")
self.res_index = (self.res_index + 1) % len(resolutions)
self.selected_values[key] = resolutions[self.res_index]
else:
resolutions = ['800x600', '1024x760', '1152x1080', '1280x1024', '1920x1080',
'2560x1440', '2560x1600', '1920x1440', '1792x1344', '2048x1152']
self.res_index = (self.res_index + 1) % len(resolutions)
choice = resolutions[self.res_index]
w, h = map(int, choice.split('x'))
host_w = self.update_status.host_screen_width
host_h = self.update_status.host_screen_height
new_w, new_h = w, h
if w > host_w:
new_w = host_w - 50
if h > host_h:
new_h = host_h - 50
self.selected_values[key] = f"{new_w}x{new_h}"
self.create_interface_elements()
def go_back(self):
menu_page = self.custom_window.navigator.get_cached("menu")
if menu_page is not None and hasattr(menu_page, 'refresh_menu_buttons'):
menu_page.refresh_menu_buttons()
self.custom_window.navigator.navigate("menu")
def show_location_verification(self, location_icon_name):
verification_page = LocationVerificationPage(
self.page_stack, self.custom_window, location_icon_name, self)
self.page_stack.addWidget(verification_page)
self.page_stack.setCurrentIndex(
self.page_stack.indexOf(verification_page))
def create_profile(self):
profile_name = self.name.text()
if not profile_name:
self.update_status.update_status('Please enter a profile name')
return
if not self.selected_values['location']:
self.update_status.update_status('Please select a location')
return
if self.selected_values['connection'] != 'system-wide' and not self.selected_values['browser']:
self.update_status.update_status('Please select a browser')
return
profile_data = {
'name': profile_name,
'protocol': self.selected_values['protocol'],
'connection': self.selected_values['connection'],
'location': self.selected_values['location'],
'browser': self.selected_values['browser'],
'resolution': self.selected_values['resolution']
}
self.profile_data = profile_data
self.update_status.write_data(profile_data)
if self.selected_values['protocol'] == 'wireguard':
self.create_wireguard_profile(profile_data)
else:
self.create_tor_profile(profile_data)
self.go_back()
def _spawn_create_profile_worker(self, action, profile_data, profile_type):
self.worker_thread = WorkerThread(action, profile_data, profile_type)
self.worker_thread.text_output.connect(
self.update_status.update_status)
self.worker_thread.start()
self.worker_thread.wait()
def create_wireguard_profile(self, profile_data):
location_info = self.connection_manager.get_location_info(
profile_data['location'])
if not location_info:
self.update_status.update_status('Invalid location selected')
return
profiles = ProfileController.get_all()
profile_id = self.get_next_available_profile_id(profiles)
profile_data_for_resume = {
'id': profile_id,
'name': profile_data['name'],
'country_code': location_info.country_code,
'code': location_info.code,
'application': profile_data['browser'],
'connection_type': 'wireguard',
'resolution': profile_data['resolution'],
}
if profile_data['connection'] == 'system-wide':
self._spawn_create_profile_worker(
'CREATE_SYSTEM_PROFILE', profile_data_for_resume, 'system')
else:
self._spawn_create_profile_worker(
'CREATE_SESSION_PROFILE', profile_data_for_resume, 'session')
if ProfileController.get(profile_id) is not None:
append_profile_to_visual_order(
getattr(self.update_status, 'gui_config_file', None),
profile_id,
profiles.keys())
def create_tor_profile(self, profile_data):
location_info = self.connection_manager.get_location_info(
profile_data['location'])
if not location_info:
self.update_status.update_status('Invalid location selected')
return
connection_type = 'tor' if profile_data['connection'] == 'tor' else 'system'
profiles = ProfileController.get_all()
profile_id = self.get_next_available_profile_id(profiles)
profile_data_for_resume = {
'id': profile_id,
'name': profile_data['name'],
'country_code': location_info.country_code,
'code': location_info.code,
'application': profile_data['browser'],
'connection_type': connection_type,
'resolution': profile_data['resolution'],
}
self._spawn_create_profile_worker(
'CREATE_SESSION_PROFILE', profile_data_for_resume, 'session')
if ProfileController.get(profile_id) is not None:
append_profile_to_visual_order(
getattr(self.update_status, 'gui_config_file', None),
profile_id,
profiles.keys())
def find_resume_page(self):
return self.custom_window.navigator.get_cached("resume")