diff options
author | xengineering <me@xengineering.eu> | 2023-05-15 21:09:26 +0200 |
---|---|---|
committer | xengineering <me@xengineering.eu> | 2023-05-15 21:09:26 +0200 |
commit | 8023777ac1b0171783e1c55f67a6179d63708272 (patch) | |
tree | 38b43dff5cb3e846f018f9b77c0c76734bb0f832 /limox.go | |
parent | 1769afe3009b5b3cfa3beb3dcf051e41487be113 (diff) | |
download | limox-8023777ac1b0171783e1c55f67a6179d63708272.tar limox-8023777ac1b0171783e1c55f67a6179d63708272.tar.zst limox-8023777ac1b0171783e1c55f67a6179d63708272.zip |
Introduce package xengineering.eu/limox/xmpp
The XMPP logic is now big enough to create a corresponding package for
it.
Diffstat (limited to 'limox.go')
-rw-r--r-- | limox.go | 18 |
1 files changed, 10 insertions, 8 deletions
@@ -11,6 +11,8 @@ import ( "gioui.org/unit" "gioui.org/widget" "gioui.org/widget/material" + + "xengineering.eu/limox/xmpp" ) type LimoxState uint8 @@ -26,7 +28,7 @@ type Limox struct { PwdEditor widget.Editor MainButton widget.Clickable XmppEvents chan any - GuiEvents chan GuiEvent + GuiEvents chan xmpp.Event State LimoxState Window *app.Window Operations op.Ops @@ -42,7 +44,7 @@ func NewLimox() Limox { Operations: op.Ops{}, Theme: material.NewTheme(gofont.Collection()), XmppEvents: make(chan any), - GuiEvents: make(chan GuiEvent), + GuiEvents: make(chan xmpp.Event), State: Disconnected, } } @@ -65,14 +67,14 @@ func (l *Limox) run() error { case error: log.Print(ev) l.State = Disconnected - case XmppEvent: + case xmpp.Event: switch ev { - case XmppDisconnect: + case xmpp.DisconnectEvent: l.State = Disconnected - case XmppConnect: + case xmpp.ConnectEvent: l.State = Connected default: - log.Printf("Unknown XmppEvent '%d'\n", ev) + log.Printf("Unknown xmpp.Event '%d'\n", ev) } default: log.Printf("Unknown event type '%s'.\n", reflect.TypeOf(ev)) @@ -86,14 +88,14 @@ func (l *Limox) buttonCallback() { switch l.State { case Disconnected: log.Println("Starting connection establishment ...") - go xmpp(l.GuiEvents, l.XmppEvents, l.JidEditor.Text(), l.PwdEditor.Text()) + go xmpp.Run(l.GuiEvents, l.XmppEvents, l.JidEditor.Text(), l.PwdEditor.Text()) l.State = Connecting case Connecting: log.Println("Aborted connection establishment") l.State = Disconnected case Connected: log.Println("Disconnecting ...") - l.GuiEvents <- Disconnect + l.GuiEvents <- xmpp.ShouldDisconnectEvent l.State = Disconnected } } |