From 9593e7c0415b7df4a5bd791a98fc06e3ee87f2f7 Mon Sep 17 00:00:00 2001 From: sunglocto Date: Thu, 7 May 2026 09:16:38 +0100 Subject: [PATCH] some lag fixes and begin work on jingle --- gtk-helpers.go | 1 + gtk-message.go | 6 ++-- main.go | 2 +- xmpp-jingle.go | 76 ++++++++++++++++++++++++++++++++++++++++++++++++++ xmpp-vcard.go | 30 ++++++++++---------- 5 files changed, 95 insertions(+), 20 deletions(-) create mode 100644 xmpp-jingle.go diff --git a/gtk-helpers.go b/gtk-helpers.go index 963a4d3..806d62e 100644 --- a/gtk-helpers.go +++ b/gtk-helpers.go @@ -163,6 +163,7 @@ func switchToTab(jid string, w *gtk.Window) { photo := vcu.Photo go func() { new_im := getAvatar(u.From, photo) + glib.IdleAdd(func() { userbox.Remove(default_av) userbox.Prepend(new_im) diff --git a/gtk-message.go b/gtk-message.go index ce0404d..a1a9439 100644 --- a/gtk-message.go +++ b/gtk-message.go @@ -53,7 +53,6 @@ func generateMessageWidget(p stanza.Packet) gtk.Widgetter { if !ok { return gtk.NewLabel("Unsupported message.") } - fmt.Println(m.Body) readmarker := Marker{} ok = m.Get(&readmarker) @@ -93,6 +92,8 @@ func generateMessageWidget(p stanza.Packet) gtk.Widgetter { popover.SetParent(mainBox) popover.SetHasArrow(false) + + gesture.Connect("pressed", func(n_press, x, y int) { rc_box := gtk.NewBox(gtk.OrientationVertical, 0) reactions := gtk.NewBox(gtk.OrientationHorizontal, 0) @@ -131,8 +132,6 @@ func generateMessageWidget(p stanza.Packet) gtk.Widgetter { rc_box.Append(quote) popover.SetChild(rc_box) - - gesture.Connect("pressed", func(n_press, x, y int) { rect := gdk.NewRectangle(x, y, 1, 1) popover.SetPointingTo(&rect) popover.Popup() @@ -228,7 +227,6 @@ func generateMessageWidget(p stanza.Packet) gtk.Widgetter { mainBox.Append(authorBox) mainBox.Append(contentBox) - mainBox.Append(reactions) oob := stanza.OOB{} ok = m.Get(&oob) diff --git a/main.go b/main.go index d971be7..572cf41 100644 --- a/main.go +++ b/main.go @@ -859,7 +859,7 @@ func activate(app *gtk.Application) { switchToTab(t, &window.Window) }) - b.AddController(gesture1) + box.AddController(gesture1) menu.Append(box) menu.Append(gtk.NewSeparator(gtk.OrientationHorizontal)) } diff --git a/xmpp-jingle.go b/xmpp-jingle.go new file mode 100644 index 0000000..9021fa3 --- /dev/null +++ b/xmpp-jingle.go @@ -0,0 +1,76 @@ +package main + +// Very experimental implementation of XEP-0166: Jingle +// https://xmpp.org/extensions/xep-0166.html + +import ( + "encoding/xml" + "gosrc.io/xmpp/stanza" +) + +type Jingle struct { + XMLName xml.Name `xml:"urn:xmpp:jingle:1 jingle"` + Action string `xml:"action,attr"` + Initiator string `xml:"initiator,attr,omitempty"` + Responder string `xml:"responder,attr,omitempty"` + Sid string `xml:"sid,attr"` + Reason *JingleReason `xml:"reason,omitempty"` +} + +type JingleReason struct { + XMLName xml.Name `xml:"reason"` + AlternativeSession *string `xml:"alternative-session,omitempty"` + Busy *string `xml:"busy,omitempty"` + Cancelled *string `xml:"cancelled,omitempty"` + Decline *string `xml:"decline,omitempty"` + FailedTransport *string `xml:"failed-transport,omitempty"` + GeneralError *string `xml:"general-error,omitempty"` + IncompatibleParameters *string `xml:"incompatible-parameters,omitempty"` + SecurityError *string `xml:"security-error,omitempty"` +} + +type JingleContent struct { + XMLName xml.Name `xml:"content"` + Name string `xml:"name,attr"` + Creator string `xml:"creator,attr"` + Description JingleContentDescription `xml:"description"` + Transport JingleContentTransport `xml:"transport"` +} + +type JingleContentDescription struct { + XMLName xml.Name `xml:"urn:xmpp:jingle:apps:rtp:1 description"` + Media string `xml:"media,attr"` + Payloads []JingleContentDescriptionPayload `xml:"payload-type"` +} + +type JingleContentDescriptionPayload struct { + XMLName xml.Name `xml:"payload-type"` + ID int `xml:"id,attr"` + Name string `xml:"name,attr"` + ClockRate int `xml:"clockrate,attr,omitempty"` + Channels int `xml:"channels,attr,omitempty"` +} + +type JingleContentTransport struct { + XMLName xml.Name `xml:"urn:xmpp:jingle:transports:ice-udp:1 transport"` + Ufrag string `xml:"ufrag,attr"` + Pwd string `xml:"pwd,attr"` + Candidates []JingleContentTransportCandidate `xml:"candidate"` +} + +type JingleContentTransportCandidate struct { + XMLName xml.Name `xml:"candidate"` + ID string `xml:"id,attr"` + Component int `xml:"component,attr"` + Foundation string `xml:"foundation,attr"` + Generation int `xml:"generation,attr"` + IP string `xml:"ip,attr"` + Port int `xml:"port,attr"` + Priority int `xml:"priority,attr"` + Protocol string `xml:"protocol,attr"` + Type string `xml:"type,attr"` +} + +func init() { + stanza.TypeRegistry.MapExtension(stanza.PKTIQ, xml.Name{Space: "urn:xmpp:jingle:1", Local: "jingle"}, Jingle{}) +} diff --git a/xmpp-vcard.go b/xmpp-vcard.go index 34ae7b4..98eca16 100644 --- a/xmpp-vcard.go +++ b/xmpp-vcard.go @@ -10,21 +10,21 @@ import ( type VCard struct { XMLName xml.Name `xml:"vcard-temp vCard"` - FirstName string `xml:"FN"` - LastName string `xml:"N>FAMILY"` - GivenName string `xml:"N>GIVEN"` - MiddleName string `xml:"N>MIDDLE"` - Nickname string `xml:"NICKNAME"` - URI string `xml:"URL"` - Birthday string `xml:"BDAY"` - OrgName string `xml:"ORG>ORGNAME"` - OrgUnit string `xml:"ORG>ORGUNIT"` - Title string `xml:"TITLE"` - Role string `xml:"ROLE"` - Description string `xml:"DESC"` - Jid string `xml:"JABBERID"` - Photo Photo `xml:"PHOTO"` - Email string `xml:"EMAIL>USERID"` + FirstName string `xml:"FN,omitempty"` + LastName string `xml:"N>FAMILY,omitempty"` + GivenName string `xml:"N>GIVEN,omitempty"` + MiddleName string `xml:"N>MIDDLE,omitempty"` + Nickname string `xml:"NICKNAME,omitempty"` + URI string `xml:"URL,omitempty"` + Birthday string `xml:"BDAY,omitempty"` + OrgName string `xml:"ORG>ORGNAME,omitempty"` + OrgUnit string `xml:"ORG>ORGUNIT,omitempty"` + Title string `xml:"TITLE,omitempty"` + Role string `xml:"ROLE,omitempty"` + Description string `xml:"DESC,omitempty"` + Jid string `xml:"JABBERID,omitempty"` + Photo Photo `xml:"PHOTO,omitempty"` + Email string `xml:"EMAIL>USERID,omitempty"` ResultSet *stanza.ResultSet `xml:"set,omitempty"` }