From 2e94a324a6a7f70c4ef31cba7c1daa6e937791bc Mon Sep 17 00:00:00 2001
From: punix <polunga40@unity-mail.de>
Date: Wed, 30 Apr 2025 09:48:40 +0200
Subject: [PATCH] add wp_app_config.py for central configuration

---
 app_config.py | 78 +++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 78 insertions(+)
 create mode 100644 app_config.py

diff --git a/app_config.py b/app_config.py
new file mode 100644
index 0000000..54f97a7
--- /dev/null
+++ b/app_config.py
@@ -0,0 +1,78 @@
+from pathlib import Path
+from typing import Dict, Any
+
+class AppConfig:
+    """Central configuration class for the application"""
+    
+    # Base paths
+    BASE_DIR = Path.home()
+    CONFIG_DIR = BASE_DIR / ".config/wire_py"
+    TEMP_DIR = Path("/tmp/tlecdcwg")
+    
+    # Configuration files
+    SETTINGS_FILE = CONFIG_DIR / "settings"
+    KEYS_FILE = CONFIG_DIR / "keys"
+    AUTOSTART_SERVICE = Path.home() / ".config/systemd/user/wg_start.service"
+    
+    # Localization
+    APP_NAME = "wirepy"
+    LOCALE_DIR = "/usr/share/locale/"
+    
+    # Default settings
+    DEFAULT_SETTINGS = {
+        "updates": "on",
+        "theme": "light",
+        "tooltip": True,
+        "autostart": "off"
+    }
+    
+    # UI configuration
+    UI_CONFIG = {
+        "window_title": "Wire-Py",
+        "window_size": (800, 600),
+        "font_family": "Ubuntu",
+        "font_size": 11
+    }
+    
+    # System-dependent paths
+    SYSTEM_PATHS = {
+        "ssl_decrypt": "/usr/local/bin/ssl_decrypt.py",
+        "ssl_encrypt": "/usr/local/bin/ssl_encrypt.py"
+    }
+    
+    @classmethod
+    def ensure_directories(cls) -> None:
+        """Ensures that all required directories exist"""
+        cls.CONFIG_DIR.mkdir(parents=True, exist_ok=True)
+        cls.TEMP_DIR.mkdir(parents=True, exist_ok=True)
+    
+    @classmethod
+    def create_default_settings(cls) -> None:
+        """Creates default settings if they don't exist"""
+        if not cls.SETTINGS_FILE.exists():
+            content = "\n".join(f"[{k.upper()}]\n{v}" for k, v in cls.DEFAULT_SETTINGS.items())
+            cls.SETTINGS_FILE.write_text(content)
+    
+    @classmethod
+    def get_image_paths(cls) -> Dict[str, Path]:
+        """Returns paths to UI images"""
+        return {
+            "main_icon": cls.CONFIG_DIR / "images/main.png",
+            "warning": cls.CONFIG_DIR / "images/warning.png",
+            "success": cls.CONFIG_DIR / "images/success.png",
+            "error": cls.CONFIG_DIR / "images/error.png"
+        }
+    
+    @classmethod
+    def get_autostart_content(cls) -> str:
+        """Returns the content for the autostart service file"""
+        return """[Unit]
+Description=Automatic Tunnel Start
+After=network-online.target
+
+[Service]
+Type=oneshot
+ExecStartPre=/bin/sleep 5
+ExecStart=/usr/local/bin/start_wg.py
+[Install]
+WantedBy=default.target"""
\ No newline at end of file