Add the ability to join rooms
This commit is contained in:
6
go.mod
6
go.mod
@@ -4,17 +4,16 @@ go 1.24.5
|
|||||||
|
|
||||||
require (
|
require (
|
||||||
fyne.io/fyne/v2 v2.6.2
|
fyne.io/fyne/v2 v2.6.2
|
||||||
fyne.io/x/fyne v0.0.0-20250418202416-58a230ad1acb
|
|
||||||
github.com/rrivera/identicon v0.0.0-20240116195454-d5ba35832c0d
|
github.com/rrivera/identicon v0.0.0-20240116195454-d5ba35832c0d
|
||||||
mellium.im/xmpp v0.22.0
|
mellium.im/xmpp v0.22.0
|
||||||
pain.agency/oasis-sdk v0.0.0-20250808203123-f4b5bab7b040
|
pain.agency/oasis-sdk v0.0.0-20250809192709-a3e5dff1aa61
|
||||||
)
|
)
|
||||||
|
|
||||||
require (
|
require (
|
||||||
fyne.io/systray v1.11.0 // indirect
|
fyne.io/systray v1.11.0 // indirect
|
||||||
github.com/BurntSushi/toml v1.5.0 // indirect
|
github.com/BurntSushi/toml v1.5.0 // indirect
|
||||||
github.com/davecgh/go-spew v1.1.1 // indirect
|
github.com/davecgh/go-spew v1.1.1 // indirect
|
||||||
github.com/fredbi/uri v1.1.0 // indirect
|
github.com/fredbi/uri v1.1.1 // indirect
|
||||||
github.com/fsnotify/fsnotify v1.9.0 // indirect
|
github.com/fsnotify/fsnotify v1.9.0 // indirect
|
||||||
github.com/fyne-io/gl-js v0.2.0 // indirect
|
github.com/fyne-io/gl-js v0.2.0 // indirect
|
||||||
github.com/fyne-io/glfw-js v0.3.0 // indirect
|
github.com/fyne-io/glfw-js v0.3.0 // indirect
|
||||||
@@ -29,6 +28,7 @@ require (
|
|||||||
github.com/hack-pad/safejs v0.1.1 // indirect
|
github.com/hack-pad/safejs v0.1.1 // indirect
|
||||||
github.com/jeandeaual/go-locale v0.0.0-20250612000132-0ef82f21eade // indirect
|
github.com/jeandeaual/go-locale v0.0.0-20250612000132-0ef82f21eade // indirect
|
||||||
github.com/jsummers/gobmp v0.0.0-20230614200233-a9de23ed2e25 // indirect
|
github.com/jsummers/gobmp v0.0.0-20230614200233-a9de23ed2e25 // indirect
|
||||||
|
github.com/kr/text v0.2.0 // indirect
|
||||||
github.com/nfnt/resize v0.0.0-20180221191011-83c6a9932646 // indirect
|
github.com/nfnt/resize v0.0.0-20180221191011-83c6a9932646 // indirect
|
||||||
github.com/nicksnyder/go-i18n/v2 v2.6.0 // indirect
|
github.com/nicksnyder/go-i18n/v2 v2.6.0 // indirect
|
||||||
github.com/pmezard/go-difflib v1.0.0 // indirect
|
github.com/pmezard/go-difflib v1.0.0 // indirect
|
||||||
|
11
go.sum
11
go.sum
@@ -2,16 +2,15 @@ fyne.io/fyne/v2 v2.6.2 h1:RPgwmXWn+EuP/TKwO7w5p73ILVC26qHD9j3CZUZNwgM=
|
|||||||
fyne.io/fyne/v2 v2.6.2/go.mod h1:9IJ8uWgzfcMossFoUkLiOrUIEtaDvF4nML114WiCtXU=
|
fyne.io/fyne/v2 v2.6.2/go.mod h1:9IJ8uWgzfcMossFoUkLiOrUIEtaDvF4nML114WiCtXU=
|
||||||
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-20250418202416-58a230ad1acb h1:2BazNmb/kwgqRdvE9L+NgW8sfoWGn3iy1Ox8R4+CSmc=
|
|
||||||
fyne.io/x/fyne v0.0.0-20250418202416-58a230ad1acb/go.mod h1:u3LF1EkElytjOT8OHxft16trctGndF9qpsoH6YIDOUU=
|
|
||||||
github.com/BurntSushi/toml v1.5.0 h1:W5quZX/G/csjUnuI8SUYlsHs9M38FC7znL0lIO+DvMg=
|
github.com/BurntSushi/toml v1.5.0 h1:W5quZX/G/csjUnuI8SUYlsHs9M38FC7znL0lIO+DvMg=
|
||||||
github.com/BurntSushi/toml v1.5.0/go.mod h1:ukJfTF/6rtPPRCnwkur4qwRxa8vTRFBF0uk2lLoLwho=
|
github.com/BurntSushi/toml v1.5.0/go.mod h1:ukJfTF/6rtPPRCnwkur4qwRxa8vTRFBF0uk2lLoLwho=
|
||||||
|
github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
|
||||||
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
||||||
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||||
github.com/felixge/fgprof v0.9.3 h1:VvyZxILNuCiUCSXtPtYmmtGvb65nqXh2QFWc0Wpf2/g=
|
github.com/felixge/fgprof v0.9.3 h1:VvyZxILNuCiUCSXtPtYmmtGvb65nqXh2QFWc0Wpf2/g=
|
||||||
github.com/felixge/fgprof v0.9.3/go.mod h1:RdbpDgzqYVh/T9fPELJyV7EYJuHB55UTEULNun8eiPw=
|
github.com/felixge/fgprof v0.9.3/go.mod h1:RdbpDgzqYVh/T9fPELJyV7EYJuHB55UTEULNun8eiPw=
|
||||||
github.com/fredbi/uri v1.1.0 h1:OqLpTXtyRg9ABReqvDGdJPqZUxs8cyBDOMXBbskCaB8=
|
github.com/fredbi/uri v1.1.1 h1:xZHJC08GZNIUhbP5ImTHnt5Ya0T8FI2VAwI/37kh2Ko=
|
||||||
github.com/fredbi/uri v1.1.0/go.mod h1:aYTUoAXBOq7BLfVJ8GnKmfcuURosB1xyHDIfWeC/iW4=
|
github.com/fredbi/uri v1.1.1/go.mod h1:4+DZQ5zBjEwQCDmXW5JdIjz0PUA+yJbvtBv+u+adr5o=
|
||||||
github.com/fsnotify/fsnotify v1.9.0 h1:2Ml+OJNzbYCTzsxtv8vKSFD9PbJjmhYF14k/jKC7S9k=
|
github.com/fsnotify/fsnotify v1.9.0 h1:2Ml+OJNzbYCTzsxtv8vKSFD9PbJjmhYF14k/jKC7S9k=
|
||||||
github.com/fsnotify/fsnotify v1.9.0/go.mod h1:8jBTzvmWwFyi3Pb8djgCCO5IBqzKJ/Jwo8TRcHyHii0=
|
github.com/fsnotify/fsnotify v1.9.0/go.mod h1:8jBTzvmWwFyi3Pb8djgCCO5IBqzKJ/Jwo8TRcHyHii0=
|
||||||
github.com/fyne-io/gl-js v0.2.0 h1:+EXMLVEa18EfkXBVKhifYB6OGs3HwKO3lUElA0LlAjs=
|
github.com/fyne-io/gl-js v0.2.0 h1:+EXMLVEa18EfkXBVKhifYB6OGs3HwKO3lUElA0LlAjs=
|
||||||
@@ -99,5 +98,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-20250808203123-f4b5bab7b040 h1:NcLVvJf5LwygyA7sXqc2dnJKWl9KJ2uChR3Wvr0kelM=
|
pain.agency/oasis-sdk v0.0.0-20250809192709-a3e5dff1aa61 h1:7zb69SAfLAJhXoqXZaS0pq/p1Y9W19Pm4FjcwWjTVoE=
|
||||||
pain.agency/oasis-sdk v0.0.0-20250808203123-f4b5bab7b040/go.mod h1:eyvDgfpHo+9bdB/AkMEMZ3ETeoSONTULVx9X4w9kGAU=
|
pain.agency/oasis-sdk v0.0.0-20250809192709-a3e5dff1aa61/go.mod h1:eyvDgfpHo+9bdB/AkMEMZ3ETeoSONTULVx9X4w9kGAU=
|
||||||
|
86
main.go
86
main.go
@@ -4,7 +4,7 @@ import (
|
|||||||
//core - required
|
//core - required
|
||||||
"encoding/xml"
|
"encoding/xml"
|
||||||
"fmt"
|
"fmt"
|
||||||
"image/color"
|
_ "image/color"
|
||||||
"io"
|
"io"
|
||||||
"log"
|
"log"
|
||||||
"math/rand/v2"
|
"math/rand/v2"
|
||||||
@@ -29,10 +29,8 @@ import (
|
|||||||
"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"
|
||||||
|
|
||||||
// gui - optional
|
// gui - optional
|
||||||
// catppuccin "github.com/mbaklor/fyne-catppuccin"
|
// catppuccin "github.com/mbaklor/fyne-catppuccin"
|
||||||
adwaita "fyne.io/x/fyne/theme"
|
|
||||||
// TODO: integrated theme switcher
|
// TODO: integrated theme switcher
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -73,35 +71,35 @@ type ChatTabUI struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type CustomMultiLineEntry struct {
|
type CustomMultiLineEntry struct {
|
||||||
widget.Entry
|
widget.Entry
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewCustomMultiLineEntry() *CustomMultiLineEntry {
|
func NewCustomMultiLineEntry() *CustomMultiLineEntry {
|
||||||
entry := &CustomMultiLineEntry{}
|
entry := &CustomMultiLineEntry{}
|
||||||
entry.ExtendBaseWidget(entry)
|
entry.ExtendBaseWidget(entry)
|
||||||
entry.MultiLine = true
|
entry.MultiLine = true
|
||||||
return entry
|
return entry
|
||||||
}
|
}
|
||||||
|
|
||||||
func (e *CustomMultiLineEntry) TypedShortcut(sc fyne.Shortcut) {
|
func (e *CustomMultiLineEntry) TypedShortcut(sc fyne.Shortcut) {
|
||||||
|
|
||||||
// Custom shortcut: Ctrl+Enter for newline
|
// Custom shortcut: Ctrl+Enter for newline
|
||||||
if sc.ShortcutName() == "CustomDesktop:Control+Return" {
|
if sc.ShortcutName() == "CustomDesktop:Control+Return" {
|
||||||
e.Entry.TypedRune('\n')
|
e.Entry.TypedRune('\n')
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
e.Entry.TypedShortcut(sc)
|
e.Entry.TypedShortcut(sc)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (e *CustomMultiLineEntry) TypedKey(ev *fyne.KeyEvent) {
|
func (e *CustomMultiLineEntry) TypedKey(ev *fyne.KeyEvent) {
|
||||||
if ev.Name == fyne.KeyReturn || ev.Name == fyne.KeyEnter {
|
if ev.Name == fyne.KeyReturn || ev.Name == fyne.KeyEnter {
|
||||||
// Normal Enter (no modifier) = submit
|
// Normal Enter (no modifier) = submit
|
||||||
if e.OnSubmitted != nil {
|
if e.OnSubmitted != nil {
|
||||||
e.OnSubmitted(e.Text)
|
e.OnSubmitted(e.Text)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
e.Entry.TypedKey(ev)
|
e.Entry.TypedKey(ev)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
type piConfig struct {
|
type piConfig struct {
|
||||||
@@ -123,7 +121,10 @@ var replying bool = false
|
|||||||
var notifications bool
|
var notifications bool
|
||||||
var connection bool = true
|
var connection bool = true
|
||||||
|
|
||||||
type myTheme struct{}
|
/*
|
||||||
|
func (m myTheme) Font(style fyne.TextStyle) fyne.Resource {
|
||||||
|
return resourceAppleColorEmojiTtf
|
||||||
|
}
|
||||||
|
|
||||||
func (m myTheme) Color(name fyne.ThemeColorName, variant fyne.ThemeVariant) color.Color {
|
func (m myTheme) Color(name fyne.ThemeColorName, variant fyne.ThemeVariant) color.Color {
|
||||||
return adwaita.AdwaitaTheme().Color(name, fyne.CurrentApp().Settings().ThemeVariant())
|
return adwaita.AdwaitaTheme().Color(name, fyne.CurrentApp().Settings().ThemeVariant())
|
||||||
@@ -133,16 +134,11 @@ func (m myTheme) Icon(name fyne.ThemeIconName) fyne.Resource {
|
|||||||
return theme.DefaultTheme().Icon(name)
|
return theme.DefaultTheme().Icon(name)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
func (m myTheme) Font(style fyne.TextStyle) fyne.Resource {
|
func (m myTheme) Font(style fyne.TextStyle) fyne.Resource {
|
||||||
return theme.DefaultTheme().Font(style)
|
return theme.DefaultTheme().Font(style)
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
func (m myTheme) Size(name fyne.ThemeSizeName) float32 {
|
|
||||||
if name == theme.SizeNameHeadingText {
|
|
||||||
return 18
|
|
||||||
}
|
|
||||||
return theme.DefaultTheme().Size(name)
|
|
||||||
}
|
|
||||||
|
|
||||||
var scrollDownOnNewMessage bool = true
|
var scrollDownOnNewMessage bool = true
|
||||||
var w fyne.Window
|
var w fyne.Window
|
||||||
@@ -244,7 +240,7 @@ func CreateUITab(chatJidStr string) ChatTabUI {
|
|||||||
|
|
||||||
sl := strings.Split(msgContent, " ")
|
sl := strings.Split(msgContent, " ")
|
||||||
if sl[0] == "/me" {
|
if sl[0] == "/me" {
|
||||||
author.SetText(author.Text + strings.Join(sl[1:], " "))
|
author.SetText(author.Text + " " + strings.Join(sl[1:], " "))
|
||||||
content.SetText(" ")
|
content.SetText(" ")
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -599,7 +595,7 @@ func main() {
|
|||||||
}()
|
}()
|
||||||
|
|
||||||
a = app.New()
|
a = app.New()
|
||||||
a.Settings().SetTheme(myTheme{})
|
//a.Settings().SetTheme(myTheme{})
|
||||||
w = a.NewWindow("pi")
|
w = a.NewWindow("pi")
|
||||||
w.Resize(fyne.NewSize(500, 500))
|
w.Resize(fyne.NewSize(500, 500))
|
||||||
|
|
||||||
@@ -835,6 +831,30 @@ func main() {
|
|||||||
}, w)
|
}, w)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
joinARoom := fyne.NewMenuItem("Join a room", func() {
|
||||||
|
dialog.ShowEntryDialog("Join a room", "JID:", func(s string) {
|
||||||
|
go func() {
|
||||||
|
myjid, err := jid.Parse(s)
|
||||||
|
if err != nil {
|
||||||
|
dialog.ShowError(err, w)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
joinjid, err := myjid.WithResource(login.DisplayName)
|
||||||
|
if err != nil {
|
||||||
|
dialog.ShowError(err, w)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
ch, err := client.MucClient.Join(client.Ctx, joinjid, client.Session)
|
||||||
|
if err != nil {
|
||||||
|
dialog.ShowError(err, w)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
client.MucChannels[s] = ch
|
||||||
|
addChatTab(true, myjid, login.DisplayName)
|
||||||
|
}()
|
||||||
|
}, w)
|
||||||
|
})
|
||||||
|
|
||||||
servDisc := fyne.NewMenuItem("Disco features", func() {
|
servDisc := fyne.NewMenuItem("Disco features", func() {
|
||||||
var search jid.JID
|
var search jid.JID
|
||||||
dialog.ShowEntryDialog("Disco features", "JID: ", func(s string) { // TODO: replace with undeprecated widget
|
dialog.ShowEntryDialog("Disco features", "JID: ", func(s string) { // TODO: replace with undeprecated widget
|
||||||
@@ -876,7 +896,7 @@ func main() {
|
|||||||
})
|
})
|
||||||
menu_help := fyne.NewMenu("π", mit, reconnect, savedata)
|
menu_help := fyne.NewMenu("π", mit, reconnect, savedata)
|
||||||
|
|
||||||
menu_changeroom := fyne.NewMenu("Α", mic, servDisc)
|
menu_changeroom := fyne.NewMenu("Α", mic, servDisc, joinARoom)
|
||||||
menu_configureview := fyne.NewMenu("Β", mia, mis, jtt, jtb)
|
menu_configureview := fyne.NewMenu("Β", mia, mis, jtt, jtb)
|
||||||
hafjag := fyne.NewMenuItem("Hafjag", func() {
|
hafjag := fyne.NewMenuItem("Hafjag", func() {
|
||||||
entry.Text = "Hafjag"
|
entry.Text = "Hafjag"
|
||||||
|
Reference in New Issue
Block a user