github.com/keybase/client/go@v0.0.0-20241007131713-f10651d043c8/protocol/keybase1/appstate.go (about) 1 // Auto-generated to Go types and interfaces using avdl-compiler v1.4.10 (https://github.com/keybase/node-avdl-compiler) 2 // Input file: avdl/keybase1/appstate.avdl 3 4 package keybase1 5 6 import ( 7 "fmt" 8 "github.com/keybase/go-framed-msgpack-rpc/rpc" 9 context "golang.org/x/net/context" 10 "time" 11 ) 12 13 type MobileAppState int 14 15 const ( 16 MobileAppState_FOREGROUND MobileAppState = 0 17 MobileAppState_BACKGROUND MobileAppState = 1 18 MobileAppState_INACTIVE MobileAppState = 2 19 MobileAppState_BACKGROUNDACTIVE MobileAppState = 3 20 ) 21 22 func (o MobileAppState) DeepCopy() MobileAppState { return o } 23 24 var MobileAppStateMap = map[string]MobileAppState{ 25 "FOREGROUND": 0, 26 "BACKGROUND": 1, 27 "INACTIVE": 2, 28 "BACKGROUNDACTIVE": 3, 29 } 30 31 var MobileAppStateRevMap = map[MobileAppState]string{ 32 0: "FOREGROUND", 33 1: "BACKGROUND", 34 2: "INACTIVE", 35 3: "BACKGROUNDACTIVE", 36 } 37 38 func (e MobileAppState) String() string { 39 if v, ok := MobileAppStateRevMap[e]; ok { 40 return v 41 } 42 return fmt.Sprintf("%v", int(e)) 43 } 44 45 type MobileNetworkState int 46 47 const ( 48 MobileNetworkState_NONE MobileNetworkState = 0 49 MobileNetworkState_WIFI MobileNetworkState = 1 50 MobileNetworkState_CELLULAR MobileNetworkState = 2 51 MobileNetworkState_UNKNOWN MobileNetworkState = 3 52 MobileNetworkState_NOTAVAILABLE MobileNetworkState = 4 53 ) 54 55 func (o MobileNetworkState) DeepCopy() MobileNetworkState { return o } 56 57 var MobileNetworkStateMap = map[string]MobileNetworkState{ 58 "NONE": 0, 59 "WIFI": 1, 60 "CELLULAR": 2, 61 "UNKNOWN": 3, 62 "NOTAVAILABLE": 4, 63 } 64 65 var MobileNetworkStateRevMap = map[MobileNetworkState]string{ 66 0: "NONE", 67 1: "WIFI", 68 2: "CELLULAR", 69 3: "UNKNOWN", 70 4: "NOTAVAILABLE", 71 } 72 73 func (e MobileNetworkState) String() string { 74 if v, ok := MobileNetworkStateRevMap[e]; ok { 75 return v 76 } 77 return fmt.Sprintf("%v", int(e)) 78 } 79 80 type UpdateMobileNetStateArg struct { 81 State string `codec:"state" json:"state"` 82 } 83 84 type PowerMonitorEventArg struct { 85 Event string `codec:"event" json:"event"` 86 } 87 88 type AppStateInterface interface { 89 UpdateMobileNetState(context.Context, string) error 90 PowerMonitorEvent(context.Context, string) error 91 } 92 93 func AppStateProtocol(i AppStateInterface) rpc.Protocol { 94 return rpc.Protocol{ 95 Name: "keybase.1.appState", 96 Methods: map[string]rpc.ServeHandlerDescription{ 97 "updateMobileNetState": { 98 MakeArg: func() interface{} { 99 var ret [1]UpdateMobileNetStateArg 100 return &ret 101 }, 102 Handler: func(ctx context.Context, args interface{}) (ret interface{}, err error) { 103 typedArgs, ok := args.(*[1]UpdateMobileNetStateArg) 104 if !ok { 105 err = rpc.NewTypeError((*[1]UpdateMobileNetStateArg)(nil), args) 106 return 107 } 108 err = i.UpdateMobileNetState(ctx, typedArgs[0].State) 109 return 110 }, 111 }, 112 "powerMonitorEvent": { 113 MakeArg: func() interface{} { 114 var ret [1]PowerMonitorEventArg 115 return &ret 116 }, 117 Handler: func(ctx context.Context, args interface{}) (ret interface{}, err error) { 118 typedArgs, ok := args.(*[1]PowerMonitorEventArg) 119 if !ok { 120 err = rpc.NewTypeError((*[1]PowerMonitorEventArg)(nil), args) 121 return 122 } 123 err = i.PowerMonitorEvent(ctx, typedArgs[0].Event) 124 return 125 }, 126 }, 127 }, 128 } 129 } 130 131 type AppStateClient struct { 132 Cli rpc.GenericClient 133 } 134 135 func (c AppStateClient) UpdateMobileNetState(ctx context.Context, state string) (err error) { 136 __arg := UpdateMobileNetStateArg{State: state} 137 err = c.Cli.Call(ctx, "keybase.1.appState.updateMobileNetState", []interface{}{__arg}, nil, 0*time.Millisecond) 138 return 139 } 140 141 func (c AppStateClient) PowerMonitorEvent(ctx context.Context, event string) (err error) { 142 __arg := PowerMonitorEventArg{Event: event} 143 err = c.Cli.Call(ctx, "keybase.1.appState.powerMonitorEvent", []interface{}{__arg}, nil, 0*time.Millisecond) 144 return 145 }