Update to match current oasisSdk version, fix bookmarks, update deps, and introduce a new bug

This commit is contained in:
2025-09-27 09:45:53 +01:00
parent f4d3f76841
commit 3f157d06c7
3 changed files with 58 additions and 33 deletions

6
go.mod
View File

@@ -1,15 +1,15 @@
module pi-im module pi-im
go 1.24.6 go 1.25.1
require ( require (
fyne.io/fyne/v2 v2.6.3 fyne.io/fyne/v2 v2.6.3
fyne.io/x/fyne v0.0.0-20250827163406-39fd826f385e fyne.io/x/fyne v0.0.0-20250910205345-ecc79984d005
github.com/makeworld-the-better-one/go-isemoji v1.3.0 github.com/makeworld-the-better-one/go-isemoji v1.3.0
github.com/rrivera/identicon v0.0.0-20240116195454-d5ba35832c0d github.com/rrivera/identicon v0.0.0-20240116195454-d5ba35832c0d
github.com/shreve/musicwand v0.0.1 github.com/shreve/musicwand v0.0.1
mellium.im/xmpp v0.22.0 mellium.im/xmpp v0.22.0
pain.agency/oasis-sdk v0.0.0-20250831105702-85385dca3a95 pain.agency/oasis-sdk v0.0.0-20250918002549-5a45c8afedcd
) )
require ( require (

8
go.sum
View File

@@ -2,8 +2,8 @@ fyne.io/fyne/v2 v2.6.3 h1:cvtM2KHeRuH+WhtHiA63z5wJVBkQ9+Ay0UMl9PxFHyA=
fyne.io/fyne/v2 v2.6.3/go.mod h1:NGSurpRElVoI1G3h+ab2df3O5KLGh1CGbsMMcX0bPIs= fyne.io/fyne/v2 v2.6.3/go.mod h1:NGSurpRElVoI1G3h+ab2df3O5KLGh1CGbsMMcX0bPIs=
fyne.io/systray v1.11.0 h1:D9HISlxSkx+jHSniMBR6fCFOUjk1x/OOOJLa9lJYAKg= fyne.io/systray v1.11.0 h1:D9HISlxSkx+jHSniMBR6fCFOUjk1x/OOOJLa9lJYAKg=
fyne.io/systray v1.11.0/go.mod h1:RVwqP9nYMo7h5zViCBHri2FgjXF7H2cub7MAq4NSoLs= fyne.io/systray v1.11.0/go.mod h1:RVwqP9nYMo7h5zViCBHri2FgjXF7H2cub7MAq4NSoLs=
fyne.io/x/fyne v0.0.0-20250827163406-39fd826f385e h1:oJM+HGkpSuq1J+JqUq/jo7KPrKj2K2/VIZlyus04w3Y= fyne.io/x/fyne v0.0.0-20250910205345-ecc79984d005 h1:CmdApAnt07juL0dhcFReFGpADUdRjjm0eDVJDS01uKE=
fyne.io/x/fyne v0.0.0-20250827163406-39fd826f385e/go.mod h1:u3LF1EkElytjOT8OHxft16trctGndF9qpsoH6YIDOUU= fyne.io/x/fyne v0.0.0-20250910205345-ecc79984d005/go.mod h1:kQFmF5meMIXnyCioLoCrXol5opruSS/PHYGKMBIE3SU=
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
github.com/BurntSushi/toml v1.4.0 h1:kuoIxZQy2WRRk1pttg9asf+WVv6tWQuBNVmK8+nqPr0= github.com/BurntSushi/toml v1.4.0 h1:kuoIxZQy2WRRk1pttg9asf+WVv6tWQuBNVmK8+nqPr0=
github.com/BurntSushi/toml v1.4.0/go.mod h1:ukJfTF/6rtPPRCnwkur4qwRxa8vTRFBF0uk2lLoLwho= github.com/BurntSushi/toml v1.4.0/go.mod h1:ukJfTF/6rtPPRCnwkur4qwRxa8vTRFBF0uk2lLoLwho=
@@ -113,5 +113,5 @@ mellium.im/xmlstream v0.15.4 h1:gLKxcWl4rLMUpKgtzrTBvr4OexPeO/edYus+uK3F6ZI=
mellium.im/xmlstream v0.15.4/go.mod h1:yXaCW2++fmVO4L9piKVkyLDqnCmictVYF7FDQW8prb4= mellium.im/xmlstream v0.15.4/go.mod h1:yXaCW2++fmVO4L9piKVkyLDqnCmictVYF7FDQW8prb4=
mellium.im/xmpp v0.22.0 h1:UthQVSwEAr7SNrmyc90c2ykGpVHxjn/3yw8Ey4+Im8s= mellium.im/xmpp v0.22.0 h1:UthQVSwEAr7SNrmyc90c2ykGpVHxjn/3yw8Ey4+Im8s=
mellium.im/xmpp v0.22.0/go.mod h1:WSjq12nhREFD88Vy/0WD6Q8inE8t6a8w7QjzwivWitw= mellium.im/xmpp v0.22.0/go.mod h1:WSjq12nhREFD88Vy/0WD6Q8inE8t6a8w7QjzwivWitw=
pain.agency/oasis-sdk v0.0.0-20250831105702-85385dca3a95 h1:BcB7/hnMnQIU+pERvQRGFMt9i0/o8XCnHbK1kYG3/K4= pain.agency/oasis-sdk v0.0.0-20250918002549-5a45c8afedcd h1:oLKI4XqaHpJeegwRxRYH9hepFO4GYKCr6C7cLwqXTK8=
pain.agency/oasis-sdk v0.0.0-20250831105702-85385dca3a95/go.mod h1:eyvDgfpHo+9bdB/AkMEMZ3ETeoSONTULVx9X4w9kGAU= pain.agency/oasis-sdk v0.0.0-20250918002549-5a45c8afedcd/go.mod h1:eyvDgfpHo+9bdB/AkMEMZ3ETeoSONTULVx9X4w9kGAU=

75
main.go
View File

@@ -2,6 +2,7 @@ package main
import ( import (
//core - required //core - required
"context"
"encoding/xml" "encoding/xml"
"errors" "errors"
"fmt" "fmt"
@@ -29,6 +30,7 @@ import (
"github.com/shreve/musicwand/pkg/mpris" "github.com/shreve/musicwand/pkg/mpris"
// xmpp - required // xmpp - required
"mellium.im/xmpp/bookmarks"
"mellium.im/xmpp/jid" "mellium.im/xmpp/jid"
"mellium.im/xmpp/muc" "mellium.im/xmpp/muc"
oasisSdk "pain.agency/oasis-sdk" oasisSdk "pain.agency/oasis-sdk"
@@ -294,9 +296,9 @@ func CreateUITab(chatJidStr string) ChatTabUI {
scroller.CreateItem().Refresh() scroller.CreateItem().Refresh()
vbox.Refresh() vbox.Refresh()
/* /*
fyne.Do(func() { fyne.Do(func() {
scroller.RefreshItem(i) scroller.RefreshItem(i)
}) })
*/ */
}, },
) )
@@ -305,7 +307,6 @@ func CreateUITab(chatJidStr string) ChatTabUI {
selectedId = id selectedId = id
} }
myUITab := ChatTabUI{} myUITab := ChatTabUI{}
scroller.CreateItem() scroller.CreateItem()
@@ -452,8 +453,7 @@ func main() {
newlineIcon = " ⮡ " newlineIcon = " ⮡ "
} }
client, err := oasisSdk.CreateClient( client, err := oasisSdk.CreateClient(&login)
&login)
client.SetDmHandler(func(client *oasisSdk.XmppClient, msg *oasisSdk.XMPPChatMessage) { client.SetDmHandler(func(client *oasisSdk.XmppClient, msg *oasisSdk.XMPPChatMessage) {
correction := false correction := false
@@ -645,6 +645,24 @@ func main() {
}) })
} }
}) })
client.SetPresenceHandler(func(client *oasisSdk.XmppClient, from jid.JID, p oasisSdk.UserPresence) {
fmt.Println(p, p.Indicator, p.Status)
})
client.SetBookmarkHandler(false, func(client *oasisSdk.XmppClient, bookmark bookmarks.Channel) {
if bookmark.Autojoin {
if bookmark.Nick == "" {
bookmark.Nick = client.Login.DisplayName
}
_, err := client.ConnectMuc(bookmark, oasisSdk.MucLegacyHistoryConfig{}, context.TODO())
if err != nil {
fmt.Println("ERROR: " + err.Error())
return
}
addChatTab(true, bookmark.JID, client.Login.DisplayName)
}
})
client.SetDeliveryReceiptHandler( client.SetDeliveryReceiptHandler(
func(_ *oasisSdk.XmppClient, from jid.JID, id string) { func(_ *oasisSdk.XmppClient, from jid.JID, id string) {
fmt.Printf("Delivered %s to %s", id, from.String()) fmt.Printf("Delivered %s to %s", id, from.String())
@@ -674,11 +692,13 @@ func main() {
err = client.Connect() err = client.Connect()
if err != nil { if err != nil {
responseChan := make(chan bool) responseChan := make(chan bool)
fyne.Do(func() {
dialog.ShowConfirm("disconnected", fmt.Sprintf("the client disconnected. would you like to try and reconnect?\nreason:\n%s", err.Error()), func(b bool) { //fyne.Do(func() {
responseChan <- b fmt.Println(err)
}, w) dialog.ShowConfirm("disconnected", fmt.Sprintf("the client disconnected. would you like to try and reconnect?\nreason:\n%s", err.Error()), func(b bool) {
}) responseChan <- b
}, w)
//})
if !<-responseChan { if !<-responseChan {
connection = false connection = false
} }
@@ -688,7 +708,6 @@ func main() {
a = app.New() a = app.New()
w = a.NewWindow("pi") w = a.NewWindow("pi")
w.Resize(fyne.NewSize(500, 500)) w.Resize(fyne.NewSize(500, 500))
@@ -945,9 +964,13 @@ func main() {
} }
} }
AppTabs.Selected().Text = fmt.Sprintf("%s (disconnected)", AppTabs.Selected().Text) AppTabs.Selected().Text = fmt.Sprintf("%s (disconnected)", AppTabs.Selected().Text)
AppTabs.Items = append(AppTabs.Items[:AppTabs.SelectedIndex()], AppTabs.Items[AppTabs.SelectedIndex()+1:]...)
AppTabs.SelectIndex(0) AppTabs.SelectIndex(0)
delete(client.MucChannels, activeMucJid) err1, err2 := client.LeaveMuc(activeMucJid, "cya suckers!", context.TODO())
//delete(chatTabs, activeMucJid) if err1 != nil || err2 != nil {
dialog.ShowError(errors.Join(err1, err2), w) // beautiful...
}
delete(UITabs, activeMucJid)
}) })
joinARoom := fyne.NewMenuItem("Join a room", func() { joinARoom := fyne.NewMenuItem("Join a room", func() {
@@ -1087,7 +1110,7 @@ func main() {
os.WriteFile("text.xml", b, os.ModeAppend) os.WriteFile("text.xml", b, os.ModeAppend)
}) })
jbookmarks := fyne.NewMenuItem("Join rooms in bookmarks", func() { /*jbookmarks := fyne.NewMenuItem("Join rooms in bookmarks", func() {
// FIXME: Race condition // FIXME: Race condition
client.FetchBookmarks() client.FetchBookmarks()
rooms := client.BookmarkCache() rooms := client.BookmarkCache()
@@ -1110,10 +1133,11 @@ func main() {
}() }()
} }
}) })
*/
menu_help := fyne.NewMenu("π", mit, reconnect, licensesbtn, savedata) menu_help := fyne.NewMenu("π", mit, reconnect, licensesbtn, savedata)
menu_changeroom := fyne.NewMenu("Α", mic, beginADM, joinARoom, leaveRoom, jbookmarks) menu_changeroom := fyne.NewMenu("Α", mic, beginADM, joinARoom, leaveRoom)
menu_configureview := fyne.NewMenu("Β", mia, jtt, jtb) menu_configureview := fyne.NewMenu("Β", mia, jtt, jtb)
hafjag := fyne.NewMenuItem("Hafjag", func() { hafjag := fyne.NewMenuItem("Hafjag", func() {
entry.Text = "Hafjag" entry.Text = "Hafjag"
@@ -1153,8 +1177,8 @@ func main() {
mycurrentplayingsong := fyne.NewMenuItem("Get currently playing song", func() { mycurrentplayingsong := fyne.NewMenuItem("Get currently playing song", func() {
// BEGIN PLATFORM SPECIFIC CODE // BEGIN PLATFORM SPECIFIC CODE
if isWindows() { if isWindows() {
dialog.ShowError(errors.New("This feature is not supported on your operating system"), w) dialog.ShowError(errors.New("this feature is not supported on your operating system"), w)
return return
} }
// END PLATFORM SPECIFIC CODE // END PLATFORM SPECIFIC CODE
@@ -1187,7 +1211,7 @@ func main() {
} else if a_ok { } else if a_ok {
newtext = fmt.Sprintf("I'm currently listening to a song by %s", artists[0]) newtext = fmt.Sprintf("I'm currently listening to a song by %s", artists[0])
} else { } else {
dialog.ShowError(errors.New("error: There's a playing song, but we could not get any information."), w) dialog.ShowError(errors.New("error: There's a playing song, but we could not get any information"), w)
return return
} }
@@ -1302,12 +1326,13 @@ func main() {
`)), `)),
) )
for _, mucJidStr := range login.MucsToJoin { /*
mucJid, err := jid.Parse(mucJidStr) for _, mucJidStr := range login.MucsToJoin {
if err == nil { mucJid, err := jid.Parse(mucJidStr)
addChatTab(true, mucJid, login.DisplayName) if err == nil {
} addChatTab(true, mucJid, login.DisplayName)
} }
}*/
for _, userJidStr := range DMs { for _, userJidStr := range DMs {
fmt.Println(userJidStr) fmt.Println(userJidStr)