|
| 1 | +#include-once |
| 2 | +; ================================================================================================ |
| 3 | +; CONFIGURATION - Configuration loading and validation |
| 4 | +; ================================================================================================ |
| 5 | + |
| 6 | +#include "Globals.au3" |
| 7 | +#include "KeyboardShortcuts.au3" |
| 8 | +#include "UserSettings.au3" |
| 9 | +#include "Utils.au3" |
| 10 | + |
| 11 | +; ================================================================================================ |
| 12 | +; CONFIGURATION LOADING AND SAVING |
| 13 | +; ================================================================================================ |
| 14 | + |
| 15 | +; Loads meeting configuration from INI file |
| 16 | +; If any required settings are missing, opens the configuration GUI |
| 17 | +Func LoadMeetingConfig() |
| 18 | + ; Clear existing settings |
| 19 | + $g_UserSettings.RemoveAll() |
| 20 | + |
| 21 | + ; Load all required settings from INI file |
| 22 | + $g_UserSettings.Add("MeetingID", _UTF8ToString(IniRead($CONFIG_FILE, "ZoomSettings", "MeetingID", ""))) |
| 23 | + $g_UserSettings.Add("MidweekDay", _UTF8ToString(IniRead($CONFIG_FILE, "Meetings", "MidweekDay", ""))) |
| 24 | + $g_UserSettings.Add("MidweekTime", _UTF8ToString(IniRead($CONFIG_FILE, "Meetings", "MidweekTime", ""))) |
| 25 | + $g_UserSettings.Add("WeekendDay", _UTF8ToString(IniRead($CONFIG_FILE, "Meetings", "WeekendDay", ""))) |
| 26 | + $g_UserSettings.Add("WeekendTime", _UTF8ToString(IniRead($CONFIG_FILE, "Meetings", "WeekendTime", ""))) |
| 27 | + $g_UserSettings.Add("HostToolsValue", _UTF8ToString(IniRead($CONFIG_FILE, "ZoomStrings", "HostToolsValue", ""))) |
| 28 | + $g_UserSettings.Add("ParticipantValue", _UTF8ToString(IniRead($CONFIG_FILE, "ZoomStrings", "ParticipantValue", ""))) |
| 29 | + $g_UserSettings.Add("MuteAllValue", _UTF8ToString(IniRead($CONFIG_FILE, "ZoomStrings", "MuteAllValue", ""))) |
| 30 | + $g_UserSettings.Add("MoreMeetingControlsValue", _UTF8ToString(IniRead($CONFIG_FILE, "ZoomStrings", "MoreMeetingControlsValue", ""))) |
| 31 | + $g_UserSettings.Add("YesValue", _UTF8ToString(IniRead($CONFIG_FILE, "ZoomStrings", "YesValue", ""))) |
| 32 | + $g_UserSettings.Add("UncheckedValue", _UTF8ToString(IniRead($CONFIG_FILE, "ZoomStrings", "UncheckedValue", ""))) |
| 33 | + $g_UserSettings.Add("CurrentlyUnmutedValue", _UTF8ToString(IniRead($CONFIG_FILE, "ZoomStrings", "CurrentlyUnmutedValue", ""))) |
| 34 | + $g_UserSettings.Add("UnmuteAudioValue", _UTF8ToString(IniRead($CONFIG_FILE, "ZoomStrings", "UnmuteAudioValue", ""))) |
| 35 | + $g_UserSettings.Add("StopVideoValue", _UTF8ToString(IniRead($CONFIG_FILE, "ZoomStrings", "StopVideoValue", ""))) |
| 36 | + $g_UserSettings.Add("StartVideoValue", _UTF8ToString(IniRead($CONFIG_FILE, "ZoomStrings", "StartVideoValue", ""))) |
| 37 | + $g_UserSettings.Add("ZoomSecurityUnmuteValue", _UTF8ToString(IniRead($CONFIG_FILE, "ZoomStrings", "ZoomSecurityUnmuteValue", ""))) |
| 38 | + $g_UserSettings.Add("ZoomSecurityShareScreenValue", _UTF8ToString(IniRead($CONFIG_FILE, "ZoomStrings", "ZoomSecurityShareScreenValue", ""))) |
| 39 | + $g_UserSettings.Add("KeyboardShortcut", _UTF8ToString(IniRead($CONFIG_FILE, "General", "KeyboardShortcut", ""))) |
| 40 | + |
| 41 | + ; Window snapping preference (Disabled|Left|Right) |
| 42 | + $g_UserSettings.Add("SnapZoomSide", _UTF8ToString(IniRead($CONFIG_FILE, "General", "SnapZoomSide", "Disabled"))) |
| 43 | + |
| 44 | + ; Load language setting |
| 45 | + Local $lang = _UTF8ToString(IniRead($CONFIG_FILE, "General", "Language", "")) |
| 46 | + If $lang = "" Then |
| 47 | + $lang = "en" |
| 48 | + IniWrite($CONFIG_FILE, "General", "Language", _StringToUTF8($lang)) |
| 49 | + EndIf |
| 50 | + $g_UserSettings.Add("Language", $lang) |
| 51 | + $g_CurrentLang = $lang |
| 52 | + |
| 53 | + ; Load keyboard shortcut setting |
| 54 | + $g_KeyboardShortcut = GetUserSetting("KeyboardShortcut") |
| 55 | + If $g_KeyboardShortcut <> "" Then |
| 56 | + _UpdateKeyboardShortcut() |
| 57 | + EndIf |
| 58 | + |
| 59 | + ; Check if all required settings are configured |
| 60 | + If GetUserSetting("MeetingID") = "" Or GetUserSetting("MidweekDay") = "" Or GetUserSetting("MidweekTime") = "" Or GetUserSetting("WeekendDay") = "" Or GetUserSetting("WeekendTime") = "" Or GetUserSetting("HostToolsValue") = "" Or GetUserSetting("ParticipantValue") = "" Or GetUserSetting("MuteAllValue") = "" Or GetUserSetting("YesValue") = "" Or GetUserSetting("MoreMeetingControlsValue") = "" Or GetUserSetting("UncheckedValue") = "" Or GetUserSetting("CurrentlyUnmutedValue") = "" Or GetUserSetting("UnmuteAudioValue") = "" Or GetUserSetting("StopVideoValue") = "" Or GetUserSetting("StartVideoValue") = "" Or GetUserSetting("ZoomSecurityUnmuteValue") = "" Or GetUserSetting("ZoomSecurityShareScreenValue") = "" Then |
| 61 | + ; Open configuration GUI if any settings are missing |
| 62 | + ShowConfigGUI() |
| 63 | + While $g_ConfigGUI |
| 64 | + Sleep(100) |
| 65 | + WEnd |
| 66 | + Else |
| 67 | + Debug(t("INFO_CONFIG_LOADED"), "INFO") |
| 68 | + Debug("Midweek Meeting: " & t("DAY_" & GetUserSetting("MidweekDay")) & " at " & GetUserSetting("MidweekTime"), "VERBOSE", True) |
| 69 | + Debug("Weekend Meeting: " & t("DAY_" & GetUserSetting("WeekendDay")) & " at " & GetUserSetting("WeekendTime"), "VERBOSE", True) |
| 70 | + EndIf |
| 71 | +EndFunc ;==>LoadMeetingConfig |
| 72 | + |
| 73 | + |
| 74 | +; ================================================================================================ |
| 75 | +; INPUT VALIDATION FUNCTIONS |
| 76 | +; ================================================================================================ |
| 77 | + |
| 78 | +; Validates meeting ID format (9-11 digits) |
| 79 | +; @param $s - String to validate |
| 80 | +; @return Boolean - True if valid meeting ID format |
| 81 | +Func _IsValidMeetingID($s) |
| 82 | + $s = StringStripWS($s, 3) ; Remove leading/trailing whitespace |
| 83 | + If $s = "" Then Return False |
| 84 | + If Not StringRegExp($s, "^\d{9,11}$") Then Return False |
| 85 | + Return True |
| 86 | +EndFunc ;==>_IsValidMeetingID |
| 87 | + |
| 88 | +; Validates time format (HH:MM in 24-hour format) |
| 89 | +; @param $s - String to validate |
| 90 | +; @return Boolean - True if valid time format |
| 91 | +Func _IsValidTime($s) |
| 92 | + $s = StringStripWS($s, 3) ; Remove leading/trailing whitespace |
| 93 | + If $s = "" Then Return False |
| 94 | + If Not StringRegExp($s, "^(\d{1,2}):(\d{2})$") Then Return False |
| 95 | + |
| 96 | + ; Validate hour and minute ranges |
| 97 | + Local $a = StringSplit($s, ":") |
| 98 | + Local $h = Number($a[1]) |
| 99 | + Local $m = Number($a[2]) |
| 100 | + If $h < 0 Or $h > 23 Then Return False |
| 101 | + If $m < 0 Or $m > 59 Then Return False |
| 102 | + Return True |
| 103 | +EndFunc ;==>_IsValidTime |
| 104 | + |
| 105 | +; Validates keyboard shortcut format |
| 106 | +; @param $s - String to validate |
| 107 | +; @return Boolean - True if valid keyboard shortcut format |
| 108 | +Func _IsValidKeyboardShortcut($s) |
| 109 | + $s = StringStripWS($s, 3) ; Remove leading/trailing whitespace |
| 110 | + If $s = "" Then Return True ; Empty shortcut is valid (means no hotkey) |
| 111 | + |
| 112 | + ; Basic validation for AutoIt hotkey format: modifiers + key |
| 113 | + ; Valid modifiers: ^ (Ctrl), ! (Alt), + (Shift), # (Win) |
| 114 | + ; Valid keys: a-z, A-Z, 0-9, F1-F12, etc. |
| 115 | + If Not StringRegExp($s, "^[\^\!\+\#]*[a-zA-Z0-9]$") Then Return False |
| 116 | + |
| 117 | + ; Must have at least one modifier key |
| 118 | + If Not StringRegExp($s, "[\^\!\+\#]") Then Return False |
| 119 | + |
| 120 | + Return True |
| 121 | +EndFunc ;==>_IsValidKeyboardShortcut |
0 commit comments