From 3f5e695e6d772f46ef3596f83c9d2c26ebcbab35 Mon Sep 17 00:00:00 2001 From: xengineering Date: Sun, 9 Jul 2023 17:23:28 +0200 Subject: Pass roster result to limox struct This is needed to display the roster in the context of GUI. --- limox.go | 6 +++++- xmpp/iq.go | 5 +---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/limox.go b/limox.go index d1cbd79..040eef2 100644 --- a/limox.go +++ b/limox.go @@ -27,6 +27,7 @@ type Limox struct { PwdEditor widget.Editor ConnectButton widget.Clickable DisconnectButton widget.Clickable + Roster []xmpp.RosterItem sessionIn chan<- any sessionOut chan any State LimoxState @@ -70,11 +71,14 @@ func (l *Limox) run() error { l.draw(e) } case data := <-l.sessionOut: - switch data.(type) { + switch d := data.(type) { case xmpp.SessionDisconnect: l.State = Disconnected + l.Roster = make([]xmpp.RosterItem, 0) case xmpp.SessionConnect: l.State = Connected + case []xmpp.RosterItem: + l.Roster = d default: log.Printf("Unknown XMPP data '%d'\n", data) } diff --git a/xmpp/iq.go b/xmpp/iq.go index 1cb7fd5..8683a21 100644 --- a/xmpp/iq.go +++ b/xmpp/iq.go @@ -32,10 +32,7 @@ func (i iqRx) handle(s *session) { } if len(i.Query) > 0 { - log.Println("Got roster:") - for _, v := range i.Query { - log.Printf("- %s\n", v.Jid) - } + s.out <- i.Query } } -- cgit v1.2.3-70-g09d2