diff options
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 } } |