From ede81d551cdf05e0134c6ef28a30b1a562de05de Mon Sep 17 00:00:00 2001 From: sunglocto Date: Tue, 14 Jul 2026 16:25:18 +0100 Subject: [PATCH] this commit was sponsored by mizkif --- assets.go | 4 ++++ assets/solar.png | Bin 0 -> 543 bytes gtk-helpers.go | 5 +++- main.go | 59 +++++++++++++++++++++++++++++++++++++++-------- version.go | 2 +- xmpp-helpers.go | 25 ++++++++++++++++++++ 6 files changed, 84 insertions(+), 11 deletions(-) create mode 100644 assets/solar.png diff --git a/assets.go b/assets.go index 57c3556..bcb8214 100644 --- a/assets.go +++ b/assets.go @@ -150,6 +150,9 @@ var pleaseWaitBytes []byte //go:embed assets/update.png var updateBytes []byte +//go:embed assets/solar.png +var solarBytes []byte + // var clientAssets map[string]gdk.Paintabler = make(map[string]gdk.Paintabler) var clientAssets sync.Map @@ -223,6 +226,7 @@ func init() { "fail": failBytes, "please_wait": pleaseWaitBytes, "update": updateBytes, + "solar": solarBytes, } { loadAsset(key, data) } diff --git a/assets/solar.png b/assets/solar.png new file mode 100644 index 0000000000000000000000000000000000000000..1482c9cd57f32f0ef88a1e633c234ea9b289f8f9 GIT binary patch literal 543 zcmeAS@N?(olHy`uVBq!ia0y~yU=RRd4mJh`2Kmqb6B!s7pLx1ChFJ8rUXIT=n<&Bl z;rzLt+@urwr}U;xm=ooDWr=fNqOtV#s8esRxLoWqbJZ+<*krx*PG)#a&eFLHS4{PL zXmRW8l8#MN>`$`3EiJq!zkF-OtLwk3=YOx<_kR2P@0F1jV#nX_4>Zo-&%gU4Z*fG^ zdx@jF|1-WhZgr>YH&59@=}4A62l!(SU;mjfef2-{$68ezG@h9yNJtklZ@qf9yKr6C zNzN;}2P#<4Ef#LSl=60_^1NPt&b_zq_D`8zB+@o(wzGYrHmk|eUo6WFrZDBqlC+g@ z`sgAdFQVYS@XAHOw5n=n!|B}0o6c32oVjyb)|rWale1WqK0EZ{TKiMW^J3h+ty}-8 za58%em3<00dTd$C%87Q0^G$o^&C0l*XA}0Zg0t_jklm5ZUzW*MG= 500 { + + if i >= 1000 { + headerBox.Append(gtk.NewImageFromPaintable(clientAssetsLoad("solar"))) + } else if i >= 500 { headerBox.Append(gtk.NewImageFromPaintable(clientAssetsLoad("world"))) } else if i >= 50 { headerBox.Append(gtk.NewImageFromPaintable(clientAssetsLoad("large_group"))) diff --git a/main.go b/main.go index c087837..12d52e0 100644 --- a/main.go +++ b/main.go @@ -362,9 +362,9 @@ func main() { } tab, ok := tabs.Load(muc) - typed_tab := tab.(*chatTab) + typed_tab, ok2 := tab.(*chatTab) - if ok { + if ok && ok2 { typed_tab.msgs.Append(b) if current == muc { scrollToBottomAfterUpdate(scroller) @@ -1171,6 +1171,7 @@ func activate(app *gtk.Application) { i := gtk.NewPictureForPaintable(gdk.NewTextureForPixbuf(loader.Pixbuf())) win := gtk.NewWindow() win.SetDefaultSize(600, 400) + win.SetResizable(false) win.SetTitle(loadedLocale["pingGraphTitle"]) box := gtk.NewBox(gtk.OrientationVertical, 0) box.Append(i) @@ -1236,13 +1237,6 @@ func activate(app *gtk.Application) { sendtxt := func() { t := message_en.Text() - if t == "" { - dialog := >k.AlertDialog{} - dialog.SetDetail("detail") - dialog.SetMessage("message") - dialog.SetButtons([]string{"yes, no"}) - dialog.Choose(context.TODO(), &window.Window, nil) - } message_type := stanza.MessageTypeChat tab, ok := tabs.Load(current) @@ -1253,6 +1247,51 @@ func activate(app *gtk.Application) { typed_tab := tab.(*chatTab) if typed_tab.isMuc { message_type = stanza.MessageTypeGroupchat + + // First check if the user is a visitor + mu, ok := mucmembers.Load(current) + if ok { + typed_mu := mu.(mucUnit) + typed_mu.Members.Range(func(k, v any) bool { + user, ok := v.(stanza.Presence) + if ok { + var mui MucUser + ok = user.Get(&mui) + if ok && mui.MucUserItem.JID != "" { + if JidMustParse(mui.MucUserItem.JID).Bare() == JidMustParse(clientroot.Session.BindJid).Bare() { + if mui.MucUserItem.Role == "visitor" { + win := gtk.NewWindow() + win.SetDefaultSize(1,1) + box := gtk.NewBox(gtk.OrientationVertical, 5) + txt := gtk.NewLabel("You are a visitor and do not have voice.\nWould you like to request voice from the moderators of this MUC?") + btn := gtk.NewButtonWithLabel("Request voice") + btn.ConnectClicked(func (){ + sendVoiceRequest(client, current) + win.SetVisible(false) + }) + dismiss := gtk.NewButtonWithLabel("Dismiss") + dismiss.ConnectClicked(func() { + win.SetVisible(false) + }) + + + box.Append(txt) + box.Append(btn) + box.Append(dismiss) + + win.SetChild(box) + win.SetResizable(false) + win.SetVisible(true) + } + + return false + } + } + } + + return true + }) + } } exts := []stanza.MsgExtension{} @@ -1278,6 +1317,8 @@ func activate(app *gtk.Application) { exts = append(exts, new_attention) } + + err := sendMessage(client, current, message_type, t, "", "", exts) if err != nil { showErrorDialog(err, &window.Window) diff --git a/version.go b/version.go index 97015df..c592fc9 100644 --- a/version.go +++ b/version.go @@ -1,3 +1,3 @@ package main -var lambda_version string = "1" +var lambda_version string = "2" diff --git a/xmpp-helpers.go b/xmpp-helpers.go index 0f4fd6e..a6db8c6 100644 --- a/xmpp-helpers.go +++ b/xmpp-helpers.go @@ -3,6 +3,7 @@ package main import ( "gosrc.io/xmpp" "gosrc.io/xmpp/stanza" + "fmt" ) // This file has small functions that can be used to do XMPP stuff without writing tons of boilerplate @@ -116,3 +117,27 @@ func JidMustParse(s string) *stanza.Jid { } return j } + +func sendVoiceRequest(c xmpp.Sender, sendTo string) error { + err := c.SendRaw(fmt.Sprintf(` + + + + http://jabber.org/protocol/muc#request + + + participant + + + + `, clientroot.Session.BindJid, sendTo)) + if err != nil { + return err + } + return nil +} +