mirror of
https://github.com/openlibrecommunity/olcrtc.git
synced 2026-06-04 19:39:45 +00:00
feat: add wb_stream provider support and update validation logic
This commit is contained in:
18
ui/config.go
18
ui/config.go
@@ -55,7 +55,6 @@ func (p *Program) getConfigPath() string {
|
||||
log("WARNING: Could not create config directory: %v", err)
|
||||
}
|
||||
return filepath.Join(configDir, "config.json")
|
||||
|
||||
}
|
||||
|
||||
func (p *Program) loadConfig() *Config {
|
||||
@@ -83,10 +82,13 @@ func (p *Program) loadConfig() *Config {
|
||||
return cfg
|
||||
}
|
||||
cfg.ConferenceID = strings.ReplaceAll(cfg.ConferenceID, " ", "")
|
||||
if !isValidConferenceID(cfg.ConferenceID) {
|
||||
log("WARNING: Invalid conference ID in config (must be numbers only)")
|
||||
|
||||
// Validation check for telemost specifically if it was stored
|
||||
if cfg.Provider == "telemost" && !isValidConferenceID(cfg.ConferenceID) {
|
||||
log("WARNING: Invalid conference ID in config (must be numbers only for telemost)")
|
||||
cfg.ConferenceID = ""
|
||||
}
|
||||
|
||||
if !isValidPort(cfg.SocksPort) {
|
||||
log("WARNING: Invalid port in config, using default: 1080")
|
||||
cfg.SocksPort = "1080"
|
||||
@@ -113,15 +115,15 @@ func (p *Program) saveConfig(dns, encryptionKey, socksPort, conferenceID, roomPa
|
||||
return
|
||||
}
|
||||
|
||||
if provider == "jazz" && conferenceID == "" {
|
||||
log("ERROR: Room ID required for jazz provider")
|
||||
p.showError(fmt.Errorf("room ID required for jazz provider"))
|
||||
if (provider == "jazz" || provider == "wb_stream") && conferenceID == "" {
|
||||
log("ERROR: Room ID required for %s provider", provider)
|
||||
p.showError(fmt.Errorf("room ID required for %s provider", provider))
|
||||
return
|
||||
}
|
||||
|
||||
if provider != "telemost" && provider != "jazz" {
|
||||
if provider != "telemost" && provider != "jazz" && provider != "wb_stream" {
|
||||
log("ERROR: Invalid provider: %s", provider)
|
||||
p.showError(fmt.Errorf("invalid provider: must be telemost or jazz"))
|
||||
p.showError(fmt.Errorf("invalid provider: must be telemost, jazz or wb_stream"))
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
10
ui/ui.go
10
ui/ui.go
@@ -13,7 +13,7 @@ import (
|
||||
func (p *Program) settingsWindow() {
|
||||
log("Opening settings dialog...")
|
||||
|
||||
providerSelect := widget.NewSelect([]string{"telemost", "jazz"}, nil)
|
||||
providerSelect := widget.NewSelect([]string{"telemost", "jazz", "wb_stream"}, nil)
|
||||
if p.Config.Provider != "" {
|
||||
providerSelect.SetSelected(p.Config.Provider)
|
||||
} else {
|
||||
@@ -47,7 +47,7 @@ func (p *Program) settingsWindow() {
|
||||
roomPassword.SetText(p.Config.RoomPassword)
|
||||
}
|
||||
|
||||
roomIdLabel := widget.NewLabel("Room ID (telemost: numbers only, jazz: any)")
|
||||
roomIdLabel := widget.NewLabel("Room ID (telemost: numbers only, others: any)")
|
||||
roomPasswordLabel := widget.NewLabel("Room Password (jazz only)")
|
||||
roomPasswordContainer := container.NewVBox(roomPasswordLabel, roomPassword)
|
||||
|
||||
@@ -56,6 +56,9 @@ func (p *Program) settingsWindow() {
|
||||
if value == "jazz" {
|
||||
roomIdLabel.SetText("Room ID (jazz: any)")
|
||||
roomPasswordContainer.Show()
|
||||
} else if value == "wb_stream" {
|
||||
roomIdLabel.SetText("Room ID (wb_stream: any)")
|
||||
roomPasswordContainer.Hide()
|
||||
} else {
|
||||
roomIdLabel.SetText("Room ID (telemost: numbers only)")
|
||||
roomPasswordContainer.Hide()
|
||||
@@ -118,9 +121,6 @@ func (p *Program) showError(err error) {
|
||||
dialog.ShowError(err, p.ParentWindow)
|
||||
}
|
||||
|
||||
// fyne.Do used here to execute function in the main context frame
|
||||
// we can just paste p.RunCheck.SetChecked(false) and that'll work. but if so
|
||||
// there'll be a bunch of warnings(thread safety)
|
||||
func (p *Program) MarkUncheck() {
|
||||
fyne.Do(func() { p.RunCheck.SetChecked(false) })
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user