forked from cwtch.im/ui
This commit is contained in:
parent
098273e480
commit
aa3c833c25
|
@ -5,6 +5,7 @@ import (
|
||||||
"cwtch.im/ui/go/cwutil"
|
"cwtch.im/ui/go/cwutil"
|
||||||
"cwtch.im/ui/go/gobjects"
|
"cwtch.im/ui/go/gobjects"
|
||||||
"cwtch.im/ui/go/the"
|
"cwtch.im/ui/go/the"
|
||||||
|
"git.openprivacy.ca/openprivacy/libricochet-go/log"
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -12,6 +13,7 @@ func IncomingListener(callback func(*gobjects.Message)) {
|
||||||
q := event.NewEventQueue(1000)
|
q := event.NewEventQueue(1000)
|
||||||
the.CwtchApp.EventBus().Subscribe(event.NewMessageFromPeer, q.EventChannel)
|
the.CwtchApp.EventBus().Subscribe(event.NewMessageFromPeer, q.EventChannel)
|
||||||
the.CwtchApp.EventBus().Subscribe(event.NewMessageFromGroup, q.EventChannel)
|
the.CwtchApp.EventBus().Subscribe(event.NewMessageFromGroup, q.EventChannel)
|
||||||
|
the.CwtchApp.EventBus().Subscribe(event.NewGroupInvite, q.EventChannel)
|
||||||
|
|
||||||
for {
|
for {
|
||||||
e := q.Next()
|
e := q.Next()
|
||||||
|
@ -40,6 +42,8 @@ func IncomingListener(callback func(*gobjects.Message)) {
|
||||||
FromMe: e.Data[event.RemotePeer] == the.Peer.GetProfile().Onion,
|
FromMe: e.Data[event.RemotePeer] == the.Peer.GetProfile().Onion,
|
||||||
Timestamp: ts,
|
Timestamp: ts,
|
||||||
})
|
})
|
||||||
|
case event.NewGroupInvite:
|
||||||
|
log.Debugf("got a group invite!")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -43,7 +43,7 @@ type GrandCentralDispatcher struct {
|
||||||
|
|
||||||
// other stuff i can't ontologize atm
|
// other stuff i can't ontologize atm
|
||||||
_ func(str string) `signal:"InvokePopup"`
|
_ func(str string) `signal:"InvokePopup"`
|
||||||
_ func(groupID, name, server, invitation string) `signal:"SupplyGroupSettings"`
|
_ func(groupID, name, server, invitation string, addrbooknames, addrbookaddrs []string) `signal:"SupplyGroupSettings"`
|
||||||
_ func(onion, nick string) `signal:"SupplyPeerSettings"`
|
_ func(onion, nick string) `signal:"SupplyPeerSettings"`
|
||||||
|
|
||||||
// signals emitted from the ui (written in go, below)
|
// signals emitted from the ui (written in go, below)
|
||||||
|
@ -58,6 +58,7 @@ type GrandCentralDispatcher struct {
|
||||||
_ func(groupID, nick string) `signal:"saveGroupSettings,auto"`
|
_ func(groupID, nick string) `signal:"saveGroupSettings,auto"`
|
||||||
_ func() `signal:"requestPeerSettings,auto"`
|
_ func() `signal:"requestPeerSettings,auto"`
|
||||||
_ func(onion, nick string) `signal:"savePeerSettings,auto"`
|
_ func(onion, nick string) `signal:"savePeerSettings,auto"`
|
||||||
|
_ func(onion, groupID string) `signal:"inviteToGroup,auto"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this *GrandCentralDispatcher) sendMessage(message string, mID uint) {
|
func (this *GrandCentralDispatcher) sendMessage(message string, mID uint) {
|
||||||
|
@ -235,7 +236,19 @@ func (this *GrandCentralDispatcher) requestGroupSettings() {
|
||||||
|
|
||||||
nick, _ := group.GetAttribute("nick")
|
nick, _ := group.GetAttribute("nick")
|
||||||
invite, _ := the.Peer.ExportGroup(this.CurrentOpenConversation())
|
invite, _ := the.Peer.ExportGroup(this.CurrentOpenConversation())
|
||||||
this.SupplyGroupSettings(this.CurrentOpenConversation(), nick, group.GroupServer, invite)
|
|
||||||
|
contactaddrs := the.Peer.GetContacts()
|
||||||
|
contactnames := make([]string, len(contactaddrs))
|
||||||
|
for i, contact := range contactaddrs {
|
||||||
|
name, hasname := the.Peer.GetContact(contact).GetAttribute("nick")
|
||||||
|
if hasname {
|
||||||
|
contactnames[i] = name
|
||||||
|
} else {
|
||||||
|
contactnames[i] = contact
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
this.SupplyGroupSettings(this.CurrentOpenConversation(), nick, group.GroupServer, invite, contactnames, contactaddrs)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this *GrandCentralDispatcher) saveGroupSettings(groupID, nick string) {
|
func (this *GrandCentralDispatcher) saveGroupSettings(groupID, nick string) {
|
||||||
|
@ -393,3 +406,10 @@ func (this *GrandCentralDispatcher) createGroup(server, groupName string) {
|
||||||
group.NewMessage = make(chan model.Message)
|
group.NewMessage = make(chan model.Message)
|
||||||
go characters.CwtchListener(this.UIState.AddMessage, group.GroupID, group.NewMessage)
|
go characters.CwtchListener(this.UIState.AddMessage, group.GroupID, group.NewMessage)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (this *GrandCentralDispatcher) inviteToGroup(onion, groupID string) {
|
||||||
|
err := the.Peer.InviteOnionToGroup(onion, groupID)
|
||||||
|
if err != nil {
|
||||||
|
log.Errorf("inviting %v to %v: %v", onion, groupID, err)
|
||||||
|
}
|
||||||
|
}
|
|
@ -10,7 +10,7 @@ import "../widgets"
|
||||||
ColumnLayout { // groupSettingsPane
|
ColumnLayout { // groupSettingsPane
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
property string groupID
|
property string groupID
|
||||||
|
property variant addrbook
|
||||||
|
|
||||||
StackToolbar {
|
StackToolbar {
|
||||||
id: toolbar
|
id: toolbar
|
||||||
|
@ -74,18 +74,13 @@ ColumnLayout { // groupSettingsPane
|
||||||
popup.font.pixelSize: 12
|
popup.font.pixelSize: 12
|
||||||
width: 200
|
width: 200
|
||||||
font.pixelSize: 20
|
font.pixelSize: 20
|
||||||
model: ["erinn", "erinn (open privacy)", "supergirl", "someone else..."]
|
|
||||||
|
|
||||||
onCurrentTextChanged: {
|
|
||||||
console.log(cbInvite.currentText)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
SimpleButton {
|
SimpleButton {
|
||||||
text: "Invite"
|
text: "Invite"
|
||||||
|
|
||||||
onClicked: {
|
onClicked: {
|
||||||
console.log("inviting " + cbInvite.currentText)
|
gcd.inviteToGroup(addrbook[cbInvite.currentIndex], groupID)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -93,12 +88,14 @@ ColumnLayout { // groupSettingsPane
|
||||||
Connections {
|
Connections {
|
||||||
target: gcd
|
target: gcd
|
||||||
|
|
||||||
onSupplyGroupSettings: function(gid, name, server, invite) {
|
onSupplyGroupSettings: function(gid, name, server, invite, addrbooknames, addrbookaddrs) {
|
||||||
groupID = gid
|
groupID = gid
|
||||||
toolbar.text = name
|
toolbar.text = name
|
||||||
txtGroupName.text = name
|
txtGroupName.text = name
|
||||||
txtServer.text = server
|
txtServer.text = server
|
||||||
txtInvitation.text = invite
|
txtInvitation.text = invite
|
||||||
|
cbInvite.model = addrbooknames
|
||||||
|
addrbook = addrbookaddrs
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue