|
1 | 1 | import Foundation |
| 2 | +import SwiftUI |
2 | 3 | import VPNLib |
3 | 4 |
|
4 | 5 | @MainActor |
@@ -29,32 +30,36 @@ class URLHandler { |
29 | 30 |
|
30 | 31 | switch route{ |
31 | 32 | caselet.open(workspace, agent, type): |
32 | | -switch type{ |
33 | | -caselet.rdp(creds): |
34 | | -tryhandleRDP(workspace: workspace, agent: agent, creds: creds) |
| 33 | +do{ |
| 34 | +switch type{ |
| 35 | +caselet.rdp(creds): |
| 36 | +tryhandleRDP(workspace: workspace, agent: agent, creds: creds) |
| 37 | +} |
| 38 | +}catch{ |
| 39 | +throw.openError(error) |
35 | 40 | } |
36 | 41 | } |
37 | 42 | } |
38 | 43 |
|
39 | | -privatefunc handleRDP(workspace:String, agent:String, creds:RDPCredentials)throws(URLError){ |
| 44 | +privatefunc handleRDP(workspace:String, agent:String, creds:RDPCredentials)throws(OpenError){ |
40 | 45 | guard vpn.state==.connectedelse{ |
41 | | -throw.openError(.coderConnectOffline) |
| 46 | +throw.coderConnectOffline |
42 | 47 | } |
43 | 48 |
|
44 | 49 | guardlet workspace= vpn.menuState.findWorkspace(name: workspace)else{ |
45 | | -throw.openError(.invalidWorkspace(workspace: workspace)) |
| 50 | +throw.invalidWorkspace(workspace: workspace) |
46 | 51 | } |
47 | 52 |
|
48 | 53 | guardlet agent= vpn.menuState.findAgent(workspaceID: workspace.id, name: agent)else{ |
49 | | -throw.openError(.invalidAgent(workspace: workspace.name, agent: agent)) |
| 54 | +throw.invalidAgent(workspace: workspace.name, agent: agent) |
50 | 55 | } |
51 | 56 |
|
52 | 57 | varrdpString="rdp:full address=s:\(agent.primaryHost):3389" |
53 | 58 | iflet username= creds.username{ |
54 | 59 | rdpString+="&username=s:\(username)" |
55 | 60 | } |
56 | 61 | guardlet url=URL(string: rdpString)else{ |
57 | | -throw.openError(.couldNotCreateRDPURL(rdpString)) |
| 62 | +throw.couldNotCreateRDPURL(rdpString) |
58 | 63 | } |
59 | 64 |
|
60 | 65 | letalert=NSAlert() |
|