/
gregor_ui.go
108 lines (93 loc) · 2.75 KB
/
gregor_ui.go
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
// Auto-generated by avdl-compiler v1.3.25 (https://github.com/keybase/node-avdl-compiler)
// Input file: avdl/keybase1/gregor_ui.avdl
package keybase1
import (
gregor1 "github.com/keybase/client/go/protocol/gregor1"
"github.com/keybase/go-framed-msgpack-rpc/rpc"
context "golang.org/x/net/context"
)
type PushReason int
const (
PushReason_NONE PushReason = 0
PushReason_RECONNECTED PushReason = 1
PushReason_NEW_DATA PushReason = 2
)
func (o PushReason) DeepCopy() PushReason { return o }
var PushReasonMap = map[string]PushReason{
"NONE": 0,
"RECONNECTED": 1,
"NEW_DATA": 2,
}
var PushReasonRevMap = map[PushReason]string{
0: "NONE",
1: "RECONNECTED",
2: "NEW_DATA",
}
func (e PushReason) String() string {
if v, ok := PushReasonRevMap[e]; ok {
return v
}
return ""
}
type PushStateArg struct {
State gregor1.State `codec:"state" json:"state"`
Reason PushReason `codec:"reason" json:"reason"`
}
type PushOutOfBandMessagesArg struct {
Oobm []gregor1.OutOfBandMessage `codec:"oobm" json:"oobm"`
}
type GregorUIInterface interface {
PushState(context.Context, PushStateArg) error
PushOutOfBandMessages(context.Context, []gregor1.OutOfBandMessage) error
}
func GregorUIProtocol(i GregorUIInterface) rpc.Protocol {
return rpc.Protocol{
Name: "keybase.1.gregorUI",
Methods: map[string]rpc.ServeHandlerDescription{
"pushState": {
MakeArg: func() interface{} {
var ret [1]PushStateArg
return &ret
},
Handler: func(ctx context.Context, args interface{}) (ret interface{}, err error) {
typedArgs, ok := args.(*[1]PushStateArg)
if !ok {
err = rpc.NewTypeError((*[1]PushStateArg)(nil), args)
return
}
err = i.PushState(ctx, typedArgs[0])
return
},
MethodType: rpc.MethodNotify,
},
"pushOutOfBandMessages": {
MakeArg: func() interface{} {
var ret [1]PushOutOfBandMessagesArg
return &ret
},
Handler: func(ctx context.Context, args interface{}) (ret interface{}, err error) {
typedArgs, ok := args.(*[1]PushOutOfBandMessagesArg)
if !ok {
err = rpc.NewTypeError((*[1]PushOutOfBandMessagesArg)(nil), args)
return
}
err = i.PushOutOfBandMessages(ctx, typedArgs[0].Oobm)
return
},
MethodType: rpc.MethodNotify,
},
},
}
}
type GregorUIClient struct {
Cli rpc.GenericClient
}
func (c GregorUIClient) PushState(ctx context.Context, __arg PushStateArg) (err error) {
err = c.Cli.Notify(ctx, "keybase.1.gregorUI.pushState", []interface{}{__arg})
return
}
func (c GregorUIClient) PushOutOfBandMessages(ctx context.Context, oobm []gregor1.OutOfBandMessage) (err error) {
__arg := PushOutOfBandMessagesArg{Oobm: oobm}
err = c.Cli.Notify(ctx, "keybase.1.gregorUI.pushOutOfBandMessages", []interface{}{__arg})
return
}