about summary refs log tree commit diff stats
path: root/ui
diff options
context:
space:
mode:
authorDrew DeVault <sir@cmpwn.com>2018-02-01 19:54:19 -0500
committerDrew DeVault <sir@cmpwn.com>2018-02-01 19:54:19 -0500
commitd603bbe2ce4adebfc9ec0bb708d814fd9152676c (patch)
tree0b6e06a272a68b98608c85b9b6cb21ef04181547 /ui
parentcc03f6f4c802ee0742520145e9cacbd88f78ed9a (diff)
downloadaerc-d603bbe2ce4adebfc9ec0bb708d814fd9152676c.tar.gz
Refactoring; consume listing response
Diffstat (limited to 'ui')
-rw-r--r--ui/account.go37
1 files changed, 22 insertions, 15 deletions
diff --git a/ui/account.go b/ui/account.go
index 8b1d0c5..393a47a 100644
--- a/ui/account.go
+++ b/ui/account.go
@@ -31,12 +31,20 @@ func NewAccountTab(conf *config.AccountConfig,
 		Worker: work,
 		logger: logger,
 	}
-	acc.Worker.PostAction(types.Configure{Config: conf}, nil)
-	acc.Worker.PostAction(types.Connect{}, func(msg types.WorkerMessage) {
-		if _, ok := msg.(types.Ack); ok {
+	acc.Worker.PostAction(&types.Configure{Config: conf}, nil)
+	acc.Worker.PostAction(&types.Connect{}, func(msg types.WorkerMessage) {
+		switch msg := msg.(type) {
+		case *types.Done:
 			acc.logger.Println("Connected.")
-			acc.Worker.PostAction(types.ListDirectories{}, nil)
-		} else {
+			acc.Worker.PostAction(&types.ListDirectories{}, nil)
+		case *types.CertificateApprovalRequest:
+			// TODO: Ask the user
+			acc.logger.Println("Approving certificate")
+			acc.Worker.PostAction(&types.ApproveCertificate{
+				Message:  types.RespondTo(msg),
+				Approved: true,
+			}, nil)
+		default:
 			acc.logger.Println("Connection failed.")
 		}
 	})
@@ -72,18 +80,17 @@ func (acc *AccountTab) GetChannel() chan types.WorkerMessage {
 
 func (acc *AccountTab) HandleMessage(msg types.WorkerMessage) {
 	msg = acc.Worker.ProcessMessage(msg)
-	switch msg.(type) {
-	case types.Ack:
-	case types.Unsupported:
+	switch msg := msg.(type) {
+	case *types.Done:
+	case *types.CertificateApprovalRequest:
+	case *types.Unsupported:
 		// no-op
-	case types.ApproveCertificate:
-		// TODO: Ask the user
-		acc.logger.Println("Approving certificate")
-		acc.Worker.PostAction(types.Ack{
-			Message: types.RespondTo(msg),
-		}, nil)
+	case *types.Error:
+		acc.logger.Printf("Error: %v\n", msg.Error)
+	case *types.Directory:
+		acc.logger.Printf("Directory: %s\n", msg.Name)
 	default:
-		acc.Worker.PostAction(types.Unsupported{
+		acc.Worker.PostAction(&types.Unsupported{
 			Message: types.RespondTo(msg),
 		}, nil)
 	}
ac139beb3dbb296ae795c3'>cf6c849 ^
8630499 ^
cf6c849 ^
69217dd ^


a0be15e ^

cd635e6 ^
06cffd8 ^

d083ce6 ^
06cffd8 ^
bd23ef0 ^

887c25e ^
bd23ef0 ^
920306c ^

efa99ed ^

c896e6b ^
df1d1ef ^
4695425 ^
2b0d4a5 ^
6753171 ^



f2d85b6 ^
1f8b2ce ^
06cffd8 ^
06cffd8 ^
920306c ^
c896e6b ^
71971db ^
5310d08 ^
06cffd8 ^

f2d85b6 ^
1f8b2ce ^
f2d85b6 ^




bd23ef0 ^

f2d85b6 ^
67864b2 ^
cf6c849 ^





f2d85b6 ^

5310d08 ^







5310d08 ^
c896e6b ^
cd635e6 ^
cd635e6 ^
887c25e ^
b29e1c1 ^
887c25e ^








c896e6b ^

cd635e6 ^
d083ce6 ^
5310d08 ^

cd635e6 ^
b29e1c1 ^
d083ce6 ^
efa99ed ^

c896e6b ^
5310d08 ^



1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114