-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathbridges.go
More file actions
59 lines (49 loc) · 1.59 KB
/
Copy pathbridges.go
File metadata and controls
59 lines (49 loc) · 1.59 KB
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
package main
import (
"github.com/katzenpost/catshadow"
"github.com/therecipe/qt/core"
)
// AccountBridge makes an account available in QML
type AccountBridge struct {
core.QObject
_ string `property:"nickname"`
_ string `property:"avatar"`
_ string `property:"error"`
_ string `property:"recipient"`
_ func(passphrase string, nickname string) bool `slot:"addContact"`
_ func(contact string) `slot:"loadConversation"`
_ func(recipient string, message string) `slot:"sendMessage"`
_ *core.QAbstractListModel `property:"contactListModel"`
_ *core.QAbstractListModel `property:"conversationModel"`
}
// ConfigBridge allows QML to access the app's config
type ConfigBridge struct {
core.QObject
_ bool `property:"firstRun"`
_ string `property:"authURL"`
_ string `property:"redirectURL"`
_ string `property:"theme"`
_ string `property:"style"`
_ int `property:"positionX"`
_ int `property:"positionY"`
_ int `property:"width"`
_ int `property:"height"`
}
var (
accountBridge *AccountBridge
configBridge *ConfigBridge
)
// setupQmlBridges initializes the QML bridges
func setupQmlBridges(client *catshadow.Client) {
accountBridge = NewAccountBridge(nil)
configBridge = NewConfigBridge(nil)
accountBridge.ConnectAddContact(func(passphrase string, nickname string) bool {
return addContact(client, nickname, passphrase)
})
accountBridge.ConnectLoadConversation(func(nickname string) {
loadConversation(client, nickname)
})
accountBridge.ConnectSendMessage(func(recipient string, message string) {
sendMessage(client, recipient, message)
})
}