()
| 309 | } |
| 310 | |
| 311 | func (dlg *EditDialog) onSaveButtonClicked() { |
| 312 | newName := dlg.nameEdit.Text() |
| 313 | if newName == "" { |
| 314 | showWarningCustom(dlg, l18n.Sprintf("Invalid name"), l18n.Sprintf("A name is required.")) |
| 315 | return |
| 316 | } |
| 317 | if !conf.TunnelNameIsValid(newName) { |
| 318 | showWarningCustom(dlg, l18n.Sprintf("Invalid name"), l18n.Sprintf("Tunnel name ‘%s’ is invalid.", newName)) |
| 319 | return |
| 320 | } |
| 321 | newNameLower := strings.ToLower(newName) |
| 322 | |
| 323 | if newNameLower != strings.ToLower(dlg.config.Name) { |
| 324 | existingTunnelList, err := manager.IPCClientTunnels() |
| 325 | if err != nil { |
| 326 | showWarningCustom(dlg, l18n.Sprintf("Unable to list existing tunnels"), err.Error()) |
| 327 | return |
| 328 | } |
| 329 | for _, tunnel := range existingTunnelList { |
| 330 | if strings.ToLower(tunnel.Name) == newNameLower { |
| 331 | showWarningCustom(dlg, l18n.Sprintf("Tunnel already exists"), l18n.Sprintf("Another tunnel already exists with the name ‘%s’.", newName)) |
| 332 | return |
| 333 | } |
| 334 | } |
| 335 | } |
| 336 | |
| 337 | cfg, err := conf.FromWgQuick(dlg.syntaxEdit.Text(), newName) |
| 338 | if err != nil { |
| 339 | showErrorCustom(dlg, l18n.Sprintf("Unable to create new configuration"), err.Error()) |
| 340 | return |
| 341 | } |
| 342 | |
| 343 | dlg.config = *cfg |
| 344 | dlg.Accept() |
| 345 | } |
nothing calls this directly
no test coverage detected