/
delegate_ui.go
82 lines (68 loc) · 2.5 KB
/
delegate_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
// Copyright 2015 Keybase, Inc. All rights reserved. Use of
// this source code is governed by the included BSD license.
package service
import (
"github.com/keybase/client/go/libkb"
"github.com/keybase/go-framed-msgpack-rpc/rpc"
context "golang.org/x/net/context"
)
// DelegateUICtlHandler is the RPC handler for notify control messages
type DelegateUICtlHandler struct {
libkb.Contextified
*BaseHandler
id libkb.ConnectionID
rekeyMaster *rekeyMaster
}
// NewDelegateUICtlHandler creates a new handler for setting up notification
// channels
func NewDelegateUICtlHandler(xp rpc.Transporter, id libkb.ConnectionID, g *libkb.GlobalContext, rekeyMaster *rekeyMaster) *DelegateUICtlHandler {
return &DelegateUICtlHandler{
Contextified: libkb.NewContextified(g),
BaseHandler: NewBaseHandler(g, xp),
id: id,
rekeyMaster: rekeyMaster,
}
}
func (d *DelegateUICtlHandler) RegisterIdentifyUI(_ context.Context) error {
d.G().UIRouter.SetUI(d.id, libkb.IdentifyUIKind)
// Let Gregor related code know that a IdentifyUI client
// (probably Electron) has connected, and to sync out state to it
if d.G().GregorListener != nil {
d.G().GregorListener.PushHandler(NewIdentifyUIHandler(d.G(), d.id))
}
return nil
}
func (d *DelegateUICtlHandler) RegisterSecretUI(_ context.Context) error {
d.G().UIRouter.SetUI(d.id, libkb.SecretUIKind)
return nil
}
func (d *DelegateUICtlHandler) RegisterUpdateUI(_ context.Context) error {
d.G().UIRouter.SetUI(d.id, libkb.UpdateUIKind)
return nil
}
func (d *DelegateUICtlHandler) RegisterHomeUI(_ context.Context) error {
d.G().UIRouter.SetUI(d.id, libkb.HomeUIKind)
return nil
}
func (d *DelegateUICtlHandler) RegisterGregorFirehose(ctx context.Context) error {
return d.registerGregorFirehose(ctx, nil)
}
func (d *DelegateUICtlHandler) RegisterGregorFirehoseFiltered(ctx context.Context, oobmSystems []string) error {
return d.registerGregorFirehose(ctx, oobmSystems)
}
func (d *DelegateUICtlHandler) registerGregorFirehose(ctx context.Context, oobmSystems []string) error {
if d.G().GregorListener != nil {
d.G().Log.Debug("Registering firehose on connection %d", d.id)
d.G().GregorListener.PushFirehoseHandler(newGregorFirehoseHandler(d.G(), d.id, d.xp, oobmSystems))
} else {
d.G().Log.Info("Failed to register firehose on connection %d", d.id)
}
return nil
}
func (d *DelegateUICtlHandler) RegisterRekeyUI(_ context.Context) error {
d.G().UIRouter.SetUI(d.id, libkb.RekeyUIKind)
if d.rekeyMaster != nil {
d.rekeyMaster.newUIRegistered()
}
return nil
}