forked from keybase/client
/
appstate.go
89 lines (75 loc) · 2.02 KB
/
appstate.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
// Auto-generated by avdl-compiler v1.3.20 (https://github.com/keybase/node-avdl-compiler)
// Input file: avdl/keybase1/appstate.avdl
package keybase1
import (
"github.com/keybase/go-framed-msgpack-rpc/rpc"
context "golang.org/x/net/context"
)
type AppState int
const (
AppState_FOREGROUND AppState = 0
AppState_BACKGROUND AppState = 1
AppState_INACTIVE AppState = 2
AppState_BACKGROUNDACTIVE AppState = 3
)
func (o AppState) DeepCopy() AppState { return o }
var AppStateMap = map[string]AppState{
"FOREGROUND": 0,
"BACKGROUND": 1,
"INACTIVE": 2,
"BACKGROUNDACTIVE": 3,
}
var AppStateRevMap = map[AppState]string{
0: "FOREGROUND",
1: "BACKGROUND",
2: "INACTIVE",
3: "BACKGROUNDACTIVE",
}
func (e AppState) String() string {
if v, ok := AppStateRevMap[e]; ok {
return v
}
return ""
}
type UpdateAppStateArg struct {
State AppState `codec:"state" json:"state"`
}
func (o UpdateAppStateArg) DeepCopy() UpdateAppStateArg {
return UpdateAppStateArg{
State: o.State.DeepCopy(),
}
}
type AppStateInterface interface {
UpdateAppState(context.Context, AppState) error
}
func AppStateProtocol(i AppStateInterface) rpc.Protocol {
return rpc.Protocol{
Name: "keybase.1.appState",
Methods: map[string]rpc.ServeHandlerDescription{
"updateAppState": {
MakeArg: func() interface{} {
ret := make([]UpdateAppStateArg, 1)
return &ret
},
Handler: func(ctx context.Context, args interface{}) (ret interface{}, err error) {
typedArgs, ok := args.(*[]UpdateAppStateArg)
if !ok {
err = rpc.NewTypeError((*[]UpdateAppStateArg)(nil), args)
return
}
err = i.UpdateAppState(ctx, (*typedArgs)[0].State)
return
},
MethodType: rpc.MethodCall,
},
},
}
}
type AppStateClient struct {
Cli rpc.GenericClient
}
func (c AppStateClient) UpdateAppState(ctx context.Context, state AppState) (err error) {
__arg := UpdateAppStateArg{State: state}
err = c.Cli.Call(ctx, "keybase.1.appState.updateAppState", []interface{}{__arg}, nil)
return
}