i forgor to commit sorry
This commit is contained in:
@@ -40,6 +40,8 @@ var connectionIcon *gtk.Image
|
||||
var mStatus *gtk.Label
|
||||
var mIcon *gtk.Image
|
||||
|
||||
var typingStatus *gtk.Label
|
||||
|
||||
var pingStatus *gtk.Label
|
||||
|
||||
// var msgs *gtk.ListBox
|
||||
@@ -225,7 +227,9 @@ func main() {
|
||||
if ok {
|
||||
if JidMustParse(fm.From).Bare() == JidMustParse(m.From).Bare() {
|
||||
p = sc.Forwarded.Stanza
|
||||
orig := m.To
|
||||
m = sc.Forwarded.Stanza.(stanza.Message)
|
||||
m.To = orig
|
||||
} else {
|
||||
panic(fmt.Sprintln("Impersonation: ", fm.From, m.From))
|
||||
}
|
||||
@@ -245,6 +249,19 @@ func main() {
|
||||
}
|
||||
}
|
||||
}
|
||||
composing := stanza.StateComposing{}
|
||||
ok = m.Get(&composing)
|
||||
if ok && current == JidMustParse(m.From).Bare() {
|
||||
typingStatus.SetText(fmt.Sprintf("%s is typing...", m.From))
|
||||
return
|
||||
}
|
||||
|
||||
inactive := stanza.StateInactive{}
|
||||
ok = m.Get(&inactive)
|
||||
if ok && current == JidMustParse(m.From).Bare() {
|
||||
typingStatus.SetText("")
|
||||
return
|
||||
}
|
||||
|
||||
glib.IdleAdd(func() {
|
||||
//uiQueue <- func() {
|
||||
@@ -674,22 +691,97 @@ func activate(app *gtk.Application) {
|
||||
btn.ConnectClicked(func() {
|
||||
t := jid_entry.Text()
|
||||
_, ok := tabs.Load(t)
|
||||
jm := func() {
|
||||
|
||||
err := joinMuc(client, clientroot.Session.BindJid, t, nick_entry.Text())
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
createTab(t, true)
|
||||
b := gtk.NewLabel(t)
|
||||
gesture1 := gtk.NewGestureClick()
|
||||
gesture1.SetButton(1)
|
||||
gesture1.Connect("pressed", func() {
|
||||
switchToTab(t, &window.Window)
|
||||
})
|
||||
|
||||
b.AddController(gesture1)
|
||||
menu.Append(b)
|
||||
}
|
||||
if !ok {
|
||||
err := joinMuc(client, clientroot.Session.BindJid, t, nick_entry.Text())
|
||||
// First check the MUC's disco and see if it's semianon
|
||||
allowed := true
|
||||
fmt.Println("Attempting to get Disco info")
|
||||
|
||||
myIQ, err := stanza.NewIQ(stanza.Attrs{
|
||||
Type: "get",
|
||||
From: clientroot.Session.BindJid,
|
||||
To: t,
|
||||
Id: "dicks",
|
||||
Lang: "en",
|
||||
})
|
||||
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
createTab(t, true)
|
||||
b := gtk.NewLabel(t)
|
||||
gesture1 := gtk.NewGestureClick()
|
||||
gesture1.SetButton(1)
|
||||
gesture1.Connect("pressed", func() {
|
||||
switchToTab(t, &window.Window)
|
||||
})
|
||||
myIQ.Payload = &stanza.DiscoInfo{}
|
||||
|
||||
b.AddController(gesture1)
|
||||
menu.Append(b)
|
||||
ctx := context.TODO()
|
||||
mychan, err := client.SendIQ(ctx, myIQ)
|
||||
if err == nil {
|
||||
result := <-mychan
|
||||
res, ok := result.Payload.(*stanza.DiscoInfo)
|
||||
if ok {
|
||||
semianon := false
|
||||
features := res.Features
|
||||
for _, feature := range features {
|
||||
if feature.Var == "muc_nonanonymous" {
|
||||
semianon = false
|
||||
break
|
||||
} else if feature.Var == "muc_semianonymous" {
|
||||
semianon = true
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
if !semianon {
|
||||
allowed = false
|
||||
warning_win := gtk.NewWindow()
|
||||
warning_win.SetTitle("Warning")
|
||||
warning_win.SetDefaultSize(400, 400)
|
||||
warning_win.SetResizable(false)
|
||||
|
||||
warning_box := gtk.NewBox(gtk.OrientationVertical, 0)
|
||||
warning_label := gtk.NewLabel("This muc is not semi-anonymous. Your JID will be revealed to non-moderators if you join. Continue?")
|
||||
|
||||
buttons := gtk.NewBox(gtk.OrientationHorizontal, 0)
|
||||
join_button := gtk.NewButtonWithLabel("Join")
|
||||
join_button.ConnectClicked(func() {
|
||||
warning_win.SetVisible(false)
|
||||
jm()
|
||||
})
|
||||
|
||||
cancel_button := gtk.NewButtonWithLabel("Cancel")
|
||||
cancel_button.ConnectClicked(func() {
|
||||
warning_win.SetVisible(false)
|
||||
})
|
||||
|
||||
buttons.Append(join_button)
|
||||
buttons.Append(cancel_button)
|
||||
|
||||
warning_box.Append(warning_label)
|
||||
warning_box.Append(buttons)
|
||||
warning_win.SetChild(warning_box)
|
||||
warning_win.Present()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if allowed {
|
||||
jm()
|
||||
}
|
||||
}
|
||||
win.SetVisible(false)
|
||||
})
|
||||
@@ -884,7 +976,7 @@ func activate(app *gtk.Application) {
|
||||
end := start + len("@everyone")
|
||||
|
||||
new_mention := new(Mention)
|
||||
new_mention.Type = "urn:xmpp:mentions:0#channel"
|
||||
new_mention.Mentions = "urn:xmpp:mentions:0#channel"
|
||||
|
||||
new_mention.Begin = start
|
||||
new_mention.End = end
|
||||
@@ -915,6 +1007,9 @@ func activate(app *gtk.Application) {
|
||||
|
||||
box.Append(entry_box)
|
||||
|
||||
typingStatus = gtk.NewLabel("")
|
||||
box.Append(typingStatus)
|
||||
|
||||
window.SetChild(box)
|
||||
|
||||
window.SetVisible(true)
|
||||
|
||||
Reference in New Issue
Block a user