github.com/keybase/client/go@v0.0.0-20241007131713-f10651d043c8/protocol/keybase1/rekey_ui.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/rekey_ui.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 RekeyEventType int
    14  
    15  const (
    16  	RekeyEventType_NONE                     RekeyEventType = 0
    17  	RekeyEventType_NOT_LOGGED_IN            RekeyEventType = 1
    18  	RekeyEventType_API_ERROR                RekeyEventType = 2
    19  	RekeyEventType_NO_PROBLEMS              RekeyEventType = 3
    20  	RekeyEventType_LOAD_ME_ERROR            RekeyEventType = 4
    21  	RekeyEventType_CURRENT_DEVICE_CAN_REKEY RekeyEventType = 5
    22  	RekeyEventType_DEVICE_LOAD_ERROR        RekeyEventType = 6
    23  	RekeyEventType_HARASS                   RekeyEventType = 7
    24  	RekeyEventType_NO_GREGOR_MESSAGES       RekeyEventType = 8
    25  )
    26  
    27  func (o RekeyEventType) DeepCopy() RekeyEventType { return o }
    28  
    29  var RekeyEventTypeMap = map[string]RekeyEventType{
    30  	"NONE":                     0,
    31  	"NOT_LOGGED_IN":            1,
    32  	"API_ERROR":                2,
    33  	"NO_PROBLEMS":              3,
    34  	"LOAD_ME_ERROR":            4,
    35  	"CURRENT_DEVICE_CAN_REKEY": 5,
    36  	"DEVICE_LOAD_ERROR":        6,
    37  	"HARASS":                   7,
    38  	"NO_GREGOR_MESSAGES":       8,
    39  }
    40  
    41  var RekeyEventTypeRevMap = map[RekeyEventType]string{
    42  	0: "NONE",
    43  	1: "NOT_LOGGED_IN",
    44  	2: "API_ERROR",
    45  	3: "NO_PROBLEMS",
    46  	4: "LOAD_ME_ERROR",
    47  	5: "CURRENT_DEVICE_CAN_REKEY",
    48  	6: "DEVICE_LOAD_ERROR",
    49  	7: "HARASS",
    50  	8: "NO_GREGOR_MESSAGES",
    51  }
    52  
    53  func (e RekeyEventType) String() string {
    54  	if v, ok := RekeyEventTypeRevMap[e]; ok {
    55  		return v
    56  	}
    57  	return fmt.Sprintf("%v", int(e))
    58  }
    59  
    60  type RekeyEvent struct {
    61  	EventType     RekeyEventType `codec:"eventType" json:"eventType"`
    62  	InterruptType int            `codec:"interruptType" json:"interruptType"`
    63  }
    64  
    65  func (o RekeyEvent) DeepCopy() RekeyEvent {
    66  	return RekeyEvent{
    67  		EventType:     o.EventType.DeepCopy(),
    68  		InterruptType: o.InterruptType,
    69  	}
    70  }
    71  
    72  type DelegateRekeyUIArg struct {
    73  }
    74  
    75  type RefreshArg struct {
    76  	SessionID         int               `codec:"sessionID" json:"sessionID"`
    77  	ProblemSetDevices ProblemSetDevices `codec:"problemSetDevices" json:"problemSetDevices"`
    78  }
    79  
    80  type RekeySendEventArg struct {
    81  	SessionID int        `codec:"sessionID" json:"sessionID"`
    82  	Event     RekeyEvent `codec:"event" json:"event"`
    83  }
    84  
    85  type RekeyUIInterface interface {
    86  	DelegateRekeyUI(context.Context) (int, error)
    87  	// Refresh is called whenever Electron should refresh the UI, either
    88  	// because a change came in, or because there was a timeout poll.
    89  	Refresh(context.Context, RefreshArg) error
    90  	// RekeySendEvent sends updates as to what's going on in the rekey
    91  	// thread. This is mainly useful in testing.
    92  	RekeySendEvent(context.Context, RekeySendEventArg) error
    93  }
    94  
    95  func RekeyUIProtocol(i RekeyUIInterface) rpc.Protocol {
    96  	return rpc.Protocol{
    97  		Name: "keybase.1.rekeyUI",
    98  		Methods: map[string]rpc.ServeHandlerDescription{
    99  			"delegateRekeyUI": {
   100  				MakeArg: func() interface{} {
   101  					var ret [1]DelegateRekeyUIArg
   102  					return &ret
   103  				},
   104  				Handler: func(ctx context.Context, args interface{}) (ret interface{}, err error) {
   105  					ret, err = i.DelegateRekeyUI(ctx)
   106  					return
   107  				},
   108  			},
   109  			"refresh": {
   110  				MakeArg: func() interface{} {
   111  					var ret [1]RefreshArg
   112  					return &ret
   113  				},
   114  				Handler: func(ctx context.Context, args interface{}) (ret interface{}, err error) {
   115  					typedArgs, ok := args.(*[1]RefreshArg)
   116  					if !ok {
   117  						err = rpc.NewTypeError((*[1]RefreshArg)(nil), args)
   118  						return
   119  					}
   120  					err = i.Refresh(ctx, typedArgs[0])
   121  					return
   122  				},
   123  			},
   124  			"rekeySendEvent": {
   125  				MakeArg: func() interface{} {
   126  					var ret [1]RekeySendEventArg
   127  					return &ret
   128  				},
   129  				Handler: func(ctx context.Context, args interface{}) (ret interface{}, err error) {
   130  					typedArgs, ok := args.(*[1]RekeySendEventArg)
   131  					if !ok {
   132  						err = rpc.NewTypeError((*[1]RekeySendEventArg)(nil), args)
   133  						return
   134  					}
   135  					err = i.RekeySendEvent(ctx, typedArgs[0])
   136  					return
   137  				},
   138  			},
   139  		},
   140  	}
   141  }
   142  
   143  type RekeyUIClient struct {
   144  	Cli rpc.GenericClient
   145  }
   146  
   147  func (c RekeyUIClient) DelegateRekeyUI(ctx context.Context) (res int, err error) {
   148  	err = c.Cli.Call(ctx, "keybase.1.rekeyUI.delegateRekeyUI", []interface{}{DelegateRekeyUIArg{}}, &res, 0*time.Millisecond)
   149  	return
   150  }
   151  
   152  // Refresh is called whenever Electron should refresh the UI, either
   153  // because a change came in, or because there was a timeout poll.
   154  func (c RekeyUIClient) Refresh(ctx context.Context, __arg RefreshArg) (err error) {
   155  	err = c.Cli.Call(ctx, "keybase.1.rekeyUI.refresh", []interface{}{__arg}, nil, 0*time.Millisecond)
   156  	return
   157  }
   158  
   159  // RekeySendEvent sends updates as to what's going on in the rekey
   160  // thread. This is mainly useful in testing.
   161  func (c RekeyUIClient) RekeySendEvent(ctx context.Context, __arg RekeySendEventArg) (err error) {
   162  	err = c.Cli.Notify(ctx, "keybase.1.rekeyUI.rekeySendEvent", []interface{}{__arg}, 0*time.Millisecond)
   163  	return
   164  }