-
Notifications
You must be signed in to change notification settings - Fork 0
/
chax.go
89 lines (75 loc) · 1.96 KB
/
chax.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
package main
import (
"polydawn.net/chax/chaxui"
"polydawn.net/chax/protocol"
"polydawn.net/chax/protocol/xmpp"
"github.com/google/gxui"
"github.com/google/gxui/drivers/gl"
"github.com/google/gxui/math"
"github.com/google/gxui/themes/dark"
"github.com/inconshreveable/log15"
)
var Log = log15.New()
func main() {
gl.StartDriver(appMain)
}
func getTitle() string {
// TODO(lfaraone): include username
return "Chax"
}
func appMain(driver gxui.Driver) {
theme := dark.CreateTheme(driver)
window := theme.CreateWindow(800, 600, getTitle())
window.OnClose(driver.Terminate)
window.SetPadding(math.Spacing{L: 10, T: 10, R: 10, B: 10})
ui := chaxui.New(theme)
window.AddChild(ui.BaseLayout)
Log.SetHandler(log15.MultiHandler(
log15.StdoutHandler,
chaxui.ListDumpHandler(driver, ui.DebugLogCtrl, log15.LogfmtFormat()),
))
Log.Info("chax started")
//go hello()
}
func hello() {
account, serverDesc := testpartner()
conn := xmpp.Dial(serverDesc, account, Log)
// talk to ourselves
// there's no such thing as message acknowledgement, apparently
conv := conn.StartConversation(account)
conv.Send([]byte("hallomsg"))
}
func testpartner() (protocol.Account, protocol.ServerDesc) {
switch 1 {
case 0:
// requires test server on localhost.
// run `sudo scripts/prosody-install.sh && prosody-launch.sh`
return protocol.Account{
Username: "testpilot",
Domain: "localhost",
Password: "asdf",
},
protocol.ServerDesc{
Host: "localhost",
Port: 5222,
}
case 1:
// this one's fun! it doesn't respond to... any... of my IQs, apparently.
return protocol.Account{
Username: "testpilot",
Domain: "crypt.mn",
Password: "asdf",
},
xmpp.ResolveServer("crypt.mn")
case 2:
// this one's fun! "PLAIN authentication is not an option"
return protocol.Account{
Username: "testpilot",
Domain: "im.koderoot.net",
Password: "asdf",
},
xmpp.ResolveServer("im.koderoot.net")
default:
panic("silly")
}
}