Add nickname fallback for rooms that don't have XEP-0421
This commit is contained in:
@@ -67,6 +67,10 @@ func switchToTab(jid string, w *gtk.Window) {
|
|||||||
var ocu OccupantID
|
var ocu OccupantID
|
||||||
u.Get(&mu)
|
u.Get(&mu)
|
||||||
u.Get(&ocu)
|
u.Get(&ocu)
|
||||||
|
id := ocu.ID
|
||||||
|
if id == "" {
|
||||||
|
id = JidMustParse(u.From).Resource
|
||||||
|
}
|
||||||
|
|
||||||
nick_label := gtk.NewLabel(JidMustParse(u.From).Resource)
|
nick_label := gtk.NewLabel(JidMustParse(u.From).Resource)
|
||||||
nick_label.SetEllipsize(pango.EllipsizeEnd)
|
nick_label.SetEllipsize(pango.EllipsizeEnd)
|
||||||
@@ -176,7 +180,7 @@ func switchToTab(jid string, w *gtk.Window) {
|
|||||||
mo, _ := mucmembers.Load(JidMustParse(u.From).Bare())
|
mo, _ := mucmembers.Load(JidMustParse(u.From).Bare())
|
||||||
mm := mo.(mucUnit)
|
mm := mo.(mucUnit)
|
||||||
mmm := mm.Members
|
mmm := mm.Members
|
||||||
mmmm, ok := mmm.Load(ocu.ID)
|
mmmm, ok := mmm.Load(id)
|
||||||
if ok {
|
if ok {
|
||||||
pres := mmmm.(stanza.Presence)
|
pres := mmmm.(stanza.Presence)
|
||||||
|
|
||||||
|
|||||||
@@ -145,6 +145,10 @@ func generateMessageWidget(p stanza.Packet) gtk.Widgetter {
|
|||||||
ocu := OccupantID{}
|
ocu := OccupantID{}
|
||||||
|
|
||||||
m.Get(&ocu)
|
m.Get(&ocu)
|
||||||
|
id := ocu.ID
|
||||||
|
if id == "" {
|
||||||
|
id = JidMustParse(m.From).Resource
|
||||||
|
}
|
||||||
|
|
||||||
authorBox := gtk.NewBox(gtk.OrientationHorizontal, 10)
|
authorBox := gtk.NewBox(gtk.OrientationHorizontal, 10)
|
||||||
contentBox := gtk.NewBox(gtk.OrientationHorizontal, 0)
|
contentBox := gtk.NewBox(gtk.OrientationHorizontal, 0)
|
||||||
@@ -159,7 +163,7 @@ func generateMessageWidget(p stanza.Packet) gtk.Widgetter {
|
|||||||
mo, _ := mucmembers.Load(jid.MustParse(m.From).Bare().String())
|
mo, _ := mucmembers.Load(jid.MustParse(m.From).Bare().String())
|
||||||
mm := mo.(mucUnit)
|
mm := mo.(mucUnit)
|
||||||
mmm := mm.Members
|
mmm := mm.Members
|
||||||
mmmm, ok := mmm.Load(ocu.ID)
|
mmmm, ok := mmm.Load(id)
|
||||||
if ok {
|
if ok {
|
||||||
pres := mmmm.(stanza.Presence)
|
pres := mmmm.(stanza.Presence)
|
||||||
|
|
||||||
@@ -267,7 +271,7 @@ func getAvatar(j, hash string) *gtk.Image { // TODO: This function probably shou
|
|||||||
}
|
}
|
||||||
|
|
||||||
base64_data := card.Photo.Binval
|
base64_data := card.Photo.Binval
|
||||||
if card.Photo.Binval == "" || (card.Photo.Type == "image/svg+xml" && runtime.GOOS == "windows") {
|
if card.Photo.Binval == "" || ((card.Photo.Type == "image/svg+xml" || card.Photo.Type == "image/webp") && (runtime.GOOS == "windows")) {
|
||||||
return gtk.NewImageFromPaintable(clientAssets["DefaultAvatar"])
|
return gtk.NewImageFromPaintable(clientAssets["DefaultAvatar"])
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
24
main.go
24
main.go
@@ -187,7 +187,7 @@ func main() {
|
|||||||
Jid: loadedConfig.Username + "/lambda." + str,
|
Jid: loadedConfig.Username + "/lambda." + str,
|
||||||
Credential: xmpp.Password(loadedConfig.Password),
|
Credential: xmpp.Password(loadedConfig.Password),
|
||||||
Insecure: loadedConfig.Insecure,
|
Insecure: loadedConfig.Insecure,
|
||||||
// StreamLogger: os.Stdout,
|
StreamLogger: os.Stdout,
|
||||||
}
|
}
|
||||||
router := xmpp.NewRouter()
|
router := xmpp.NewRouter()
|
||||||
|
|
||||||
@@ -304,6 +304,10 @@ func main() {
|
|||||||
|
|
||||||
if ok { // This is a presence stanza from a user in a MUC
|
if ok { // This is a presence stanza from a user in a MUC
|
||||||
presence.Get(&ocu)
|
presence.Get(&ocu)
|
||||||
|
id := ocu.ID
|
||||||
|
if id == "" {
|
||||||
|
id = JidMustParse(presence.From).Resource
|
||||||
|
}
|
||||||
from, _ := stanza.NewJid(presence.From)
|
from, _ := stanza.NewJid(presence.From)
|
||||||
muc := from.Bare()
|
muc := from.Bare()
|
||||||
_, ok = mucmembers.Load(muc)
|
_, ok = mucmembers.Load(muc)
|
||||||
@@ -319,9 +323,9 @@ func main() {
|
|||||||
typed_unit := unit.(mucUnit)
|
typed_unit := unit.(mucUnit)
|
||||||
|
|
||||||
if presence.Type != "unavailable" {
|
if presence.Type != "unavailable" {
|
||||||
typed_unit.Members.Store(ocu.ID, presence)
|
typed_unit.Members.Store(id, presence)
|
||||||
} else {
|
} else {
|
||||||
typed_unit.Members.Delete(ocu.ID)
|
typed_unit.Members.Delete(id)
|
||||||
glib.IdleAdd(func() {
|
glib.IdleAdd(func() {
|
||||||
b := gtk.NewLabel("")
|
b := gtk.NewLabel("")
|
||||||
ba, ok := generatePresenceWidget(p).(*gtk.Label)
|
ba, ok := generatePresenceWidget(p).(*gtk.Label)
|
||||||
@@ -431,6 +435,15 @@ func activate(app *gtk.Application) {
|
|||||||
fileMenu.Append("Join MUC", "app.join")
|
fileMenu.Append("Join MUC", "app.join")
|
||||||
fileMenu.Append("Start DM", "app.dm")
|
fileMenu.Append("Start DM", "app.dm")
|
||||||
|
|
||||||
|
helpMenu := gio.NewMenu()
|
||||||
|
helpMenu.Append("About", "app.about")
|
||||||
|
|
||||||
|
aboutAction := gio.NewSimpleAction("about", nil)
|
||||||
|
aboutAction.ConnectActivate(func(p *glib.Variant) {
|
||||||
|
a := gtk.AboutDialog{}
|
||||||
|
a.SetVisible(true)
|
||||||
|
})
|
||||||
|
|
||||||
joinAction := gio.NewSimpleAction("join", nil)
|
joinAction := gio.NewSimpleAction("join", nil)
|
||||||
joinAction.ConnectActivate(func(p *glib.Variant) {
|
joinAction.ConnectActivate(func(p *glib.Variant) {
|
||||||
box := gtk.NewBox(gtk.OrientationVertical, 0)
|
box := gtk.NewBox(gtk.OrientationVertical, 0)
|
||||||
@@ -464,7 +477,7 @@ func activate(app *gtk.Application) {
|
|||||||
|
|
||||||
win := gtk.NewWindow()
|
win := gtk.NewWindow()
|
||||||
win.SetTitle("Join MUC")
|
win.SetTitle("Join MUC")
|
||||||
win.SetDefaultSize(200, 200)
|
win.SetDefaultSize(400, 1)
|
||||||
win.SetChild(box)
|
win.SetChild(box)
|
||||||
|
|
||||||
btn.ConnectClicked(func() {
|
btn.ConnectClicked(func() {
|
||||||
@@ -492,8 +505,11 @@ func activate(app *gtk.Application) {
|
|||||||
})
|
})
|
||||||
|
|
||||||
app.AddAction(joinAction)
|
app.AddAction(joinAction)
|
||||||
|
app.AddAction(aboutAction)
|
||||||
|
|
||||||
the_menu.AppendSubmenu("File", fileMenu)
|
the_menu.AppendSubmenu("File", fileMenu)
|
||||||
|
the_menu.AppendSubmenu("Help", helpMenu)
|
||||||
|
|
||||||
|
|
||||||
the_menuBar := gtk.NewPopoverMenuBarFromModel(the_menu)
|
the_menuBar := gtk.NewPopoverMenuBarFromModel(the_menu)
|
||||||
app.SetMenubar(gio.NewMenu())
|
app.SetMenubar(gio.NewMenu())
|
||||||
|
|||||||
Reference in New Issue
Block a user