From e7c628edcdf708f9e75a1f738f54787d06e9f3a7 Mon Sep 17 00:00:00 2001 From: erinn Date: Tue, 5 Feb 2019 12:09:31 -0800 Subject: [PATCH 1/5] who knows what this change is. git is terrible --- go/characters/torstatuspoller.go | 48 +++++++++++++++----------------- main.go | 2 +- qml/panes/GroupSettingsPane.qml | 33 ++++++++++++++++++++++ 3 files changed, 56 insertions(+), 27 deletions(-) diff --git a/go/characters/torstatuspoller.go b/go/characters/torstatuspoller.go index 95c408f..135f441 100644 --- a/go/characters/torstatuspoller.go +++ b/go/characters/torstatuspoller.go @@ -1,32 +1,28 @@ package characters -func TorStatusPoller(setTorStatus func(int, string)) { - //TODO: convert this from asaur to bine - /* - for { - time.Sleep(time.Second) - //todo: this should use a config manager - //todo: also, try dialing the proxy to differentiate tor not running vs control port not configured - rawStatus, err := asaur.GetInfo("localhost:9051", "tcp4", "", "status/bootstrap-phase") - if err != nil { - setTorStatus(0, "can't find tor. is it running? is the controlport configured?") - continue - } +import ( + "git.openprivacy.ca/openprivacy/libricochet-go/connectivity" + "time" +) - status := asaur.ParseBootstrapPhase(rawStatus) - progress, _ := strconv.Atoi(status["PROGRESS"]) +func TorStatusPoller(setTorStatus func(int, string), acn connectivity.ACN) { + for { + time.Sleep(time.Second) - if status["TAG"] == "done" { - setTorStatus(3, "tor appears to be running just fine!") - continue - } - - if progress == 0 { - setTorStatus(1, "tor is trying to start up") - continue - } - - setTorStatus(2, status["SUMMARY"]) + percent, message := acn.GetBootstrapStatus() + var statuscode int + if percent == 0 { + statuscode = 0 + message = "can't find tor. is it running? is the controlport configured?" + } else if percent == 100 { + statuscode = 3 + message = "tor appears to be running just fine!" + } else if percent < 80 { + statuscode = 1 + } else { + statuscode = 2 } - */ + + setTorStatus(statuscode, message) + } } diff --git a/main.go b/main.go index 1d3b914..6c6c6c4 100644 --- a/main.go +++ b/main.go @@ -66,7 +66,7 @@ func main() { loadCwtchData(gcd, acn) go characters.IncomingListener(gcd.UIState.AddMessage) go characters.PostmanPat(gcd.OutgoingMessages) - go characters.TorStatusPoller(gcd.TorStatus) + go characters.TorStatusPoller(gcd.TorStatus, acn) go characters.PresencePoller(gcd.UIState.GetContact, gcd.UIState.AddContact, gcd.UIState.UpdateContact) go characters.GroupPoller(gcd.UIState.GetContact, gcd.UIState.UpdateContact) diff --git a/qml/panes/GroupSettingsPane.qml b/qml/panes/GroupSettingsPane.qml index 2ffbb14..952eb23 100644 --- a/qml/panes/GroupSettingsPane.qml +++ b/qml/panes/GroupSettingsPane.qml @@ -54,6 +54,39 @@ ColumnLayout { // groupSettingsPane } } + ScalingLabel{ + text: "Group name:" + } + + TextEdit { + id: txtGroupName + width: 100 + } + + SimpleButton { + text: "Save" + + onClicked: { + gcd.saveGroupSettings(groupID, txtGroupName.text) + theStack.title = txtGroupName.text + theStack.pane = theStack.messagePane + } + } + + ScalingLabel { text: "Invite someone to the group:" } + + ComboBox { + id: cbInvite + popup.font.pixelSize: 12 + width: 200 + font.pixelSize: 20 + model: ["erinn", "erinn (open privacy)", "supergirl", "someone else..."] + + onCurrentTextChanged: { + console.log(cbInvite.text) + } + } + Connections { target: gcd From bac22f7551f7e672fb2894a4fc2dca46f9d7b47e Mon Sep 17 00:00:00 2001 From: erinn Date: Tue, 5 Feb 2019 12:09:31 -0800 Subject: [PATCH 2/5] who knows what this change is. git is terrible --- go/characters/torstatuspoller.go | 48 +++++++++++++++----------------- main.go | 2 +- qml/panes/GroupSettingsPane.qml | 14 ++++++++++ 3 files changed, 37 insertions(+), 27 deletions(-) diff --git a/go/characters/torstatuspoller.go b/go/characters/torstatuspoller.go index 95c408f..135f441 100644 --- a/go/characters/torstatuspoller.go +++ b/go/characters/torstatuspoller.go @@ -1,32 +1,28 @@ package characters -func TorStatusPoller(setTorStatus func(int, string)) { - //TODO: convert this from asaur to bine - /* - for { - time.Sleep(time.Second) - //todo: this should use a config manager - //todo: also, try dialing the proxy to differentiate tor not running vs control port not configured - rawStatus, err := asaur.GetInfo("localhost:9051", "tcp4", "", "status/bootstrap-phase") - if err != nil { - setTorStatus(0, "can't find tor. is it running? is the controlport configured?") - continue - } +import ( + "git.openprivacy.ca/openprivacy/libricochet-go/connectivity" + "time" +) - status := asaur.ParseBootstrapPhase(rawStatus) - progress, _ := strconv.Atoi(status["PROGRESS"]) +func TorStatusPoller(setTorStatus func(int, string), acn connectivity.ACN) { + for { + time.Sleep(time.Second) - if status["TAG"] == "done" { - setTorStatus(3, "tor appears to be running just fine!") - continue - } - - if progress == 0 { - setTorStatus(1, "tor is trying to start up") - continue - } - - setTorStatus(2, status["SUMMARY"]) + percent, message := acn.GetBootstrapStatus() + var statuscode int + if percent == 0 { + statuscode = 0 + message = "can't find tor. is it running? is the controlport configured?" + } else if percent == 100 { + statuscode = 3 + message = "tor appears to be running just fine!" + } else if percent < 80 { + statuscode = 1 + } else { + statuscode = 2 } - */ + + setTorStatus(statuscode, message) + } } diff --git a/main.go b/main.go index 01fd0d7..1d706ed 100644 --- a/main.go +++ b/main.go @@ -66,7 +66,7 @@ func main() { loadCwtchData(gcd, acn) go characters.IncomingListener(gcd.UIState.AddMessage) go characters.PostmanPat(gcd.OutgoingMessages) - go characters.TorStatusPoller(gcd.TorStatus) + go characters.TorStatusPoller(gcd.TorStatus, acn) go characters.PresencePoller(gcd.UIState.GetContact, gcd.UIState.AddContact, gcd.UIState.UpdateContact) go characters.GroupPoller(gcd.UIState.GetContact, gcd.UIState.UpdateContact) diff --git a/qml/panes/GroupSettingsPane.qml b/qml/panes/GroupSettingsPane.qml index e999167..98129dc 100644 --- a/qml/panes/GroupSettingsPane.qml +++ b/qml/panes/GroupSettingsPane.qml @@ -67,6 +67,20 @@ ColumnLayout { // groupSettingsPane } } + ScalingLabel { text: "Invite someone to the group:" } + + ComboBox { + id: cbInvite + popup.font.pixelSize: 12 + width: 200 + font.pixelSize: 20 + model: ["erinn", "erinn (open privacy)", "supergirl", "someone else..."] + + onCurrentTextChanged: { + console.log(cbInvite.text) + } + } + Connections { target: gcd From 098273e480d3a744659aa32958460eab6f0aeeb5 Mon Sep 17 00:00:00 2001 From: erinn Date: Tue, 5 Feb 2019 12:22:33 -0800 Subject: [PATCH 3/5] ok --- qml/panes/GroupSettingsPane.qml | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/qml/panes/GroupSettingsPane.qml b/qml/panes/GroupSettingsPane.qml index 98129dc..9aa8f27 100644 --- a/qml/panes/GroupSettingsPane.qml +++ b/qml/panes/GroupSettingsPane.qml @@ -77,7 +77,15 @@ ColumnLayout { // groupSettingsPane model: ["erinn", "erinn (open privacy)", "supergirl", "someone else..."] onCurrentTextChanged: { - console.log(cbInvite.text) + console.log(cbInvite.currentText) + } + } + + SimpleButton { + text: "Invite" + + onClicked: { + console.log("inviting " + cbInvite.currentText) } } From aa3c833c25c4d2809cf6f0e917b1df7155913c27 Mon Sep 17 00:00:00 2001 From: erinn Date: Mon, 11 Feb 2019 12:23:31 -0800 Subject: [PATCH 4/5] . --- go/characters/incominglistener.go | 4 ++++ go/gothings/gcd.go | 24 ++++++++++++++++++++++-- qml/panes/GroupSettingsPane.qml | 13 +++++-------- 3 files changed, 31 insertions(+), 10 deletions(-) diff --git a/go/characters/incominglistener.go b/go/characters/incominglistener.go index 19ba293..f0c47ea 100644 --- a/go/characters/incominglistener.go +++ b/go/characters/incominglistener.go @@ -5,6 +5,7 @@ import ( "cwtch.im/ui/go/cwutil" "cwtch.im/ui/go/gobjects" "cwtch.im/ui/go/the" + "git.openprivacy.ca/openprivacy/libricochet-go/log" "time" ) @@ -12,6 +13,7 @@ func IncomingListener(callback func(*gobjects.Message)) { q := event.NewEventQueue(1000) the.CwtchApp.EventBus().Subscribe(event.NewMessageFromPeer, q.EventChannel) the.CwtchApp.EventBus().Subscribe(event.NewMessageFromGroup, q.EventChannel) + the.CwtchApp.EventBus().Subscribe(event.NewGroupInvite, q.EventChannel) for { e := q.Next() @@ -40,6 +42,8 @@ func IncomingListener(callback func(*gobjects.Message)) { FromMe: e.Data[event.RemotePeer] == the.Peer.GetProfile().Onion, Timestamp: ts, }) + case event.NewGroupInvite: + log.Debugf("got a group invite!") } } } \ No newline at end of file diff --git a/go/gothings/gcd.go b/go/gothings/gcd.go index 1481211..099e947 100644 --- a/go/gothings/gcd.go +++ b/go/gothings/gcd.go @@ -43,7 +43,7 @@ type GrandCentralDispatcher struct { // other stuff i can't ontologize atm _ 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"` // signals emitted from the ui (written in go, below) @@ -58,6 +58,7 @@ type GrandCentralDispatcher struct { _ func(groupID, nick string) `signal:"saveGroupSettings,auto"` _ func() `signal:"requestPeerSettings,auto"` _ func(onion, nick string) `signal:"savePeerSettings,auto"` + _ func(onion, groupID string) `signal:"inviteToGroup,auto"` } func (this *GrandCentralDispatcher) sendMessage(message string, mID uint) { @@ -235,7 +236,19 @@ func (this *GrandCentralDispatcher) requestGroupSettings() { nick, _ := group.GetAttribute("nick") 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) { @@ -393,3 +406,10 @@ func (this *GrandCentralDispatcher) createGroup(server, groupName string) { group.NewMessage = make(chan model.Message) 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) + } +} \ No newline at end of file diff --git a/qml/panes/GroupSettingsPane.qml b/qml/panes/GroupSettingsPane.qml index 9aa8f27..3ac786e 100644 --- a/qml/panes/GroupSettingsPane.qml +++ b/qml/panes/GroupSettingsPane.qml @@ -10,7 +10,7 @@ import "../widgets" ColumnLayout { // groupSettingsPane anchors.fill: parent property string groupID - + property variant addrbook StackToolbar { id: toolbar @@ -74,18 +74,13 @@ ColumnLayout { // groupSettingsPane popup.font.pixelSize: 12 width: 200 font.pixelSize: 20 - model: ["erinn", "erinn (open privacy)", "supergirl", "someone else..."] - - onCurrentTextChanged: { - console.log(cbInvite.currentText) - } } SimpleButton { text: "Invite" onClicked: { - console.log("inviting " + cbInvite.currentText) + gcd.inviteToGroup(addrbook[cbInvite.currentIndex], groupID) } } @@ -93,12 +88,14 @@ ColumnLayout { // groupSettingsPane Connections { target: gcd - onSupplyGroupSettings: function(gid, name, server, invite) { + onSupplyGroupSettings: function(gid, name, server, invite, addrbooknames, addrbookaddrs) { groupID = gid toolbar.text = name txtGroupName.text = name txtServer.text = server txtInvitation.text = invite + cbInvite.model = addrbooknames + addrbook = addrbookaddrs } } } \ No newline at end of file From 3eaa4cdf9be93f77b9e3a49d80f8f6b1ed1cd6f7 Mon Sep 17 00:00:00 2001 From: erinn Date: Mon, 11 Feb 2019 13:33:07 -0800 Subject: [PATCH 5/5] bugfixen --- qml/widgets/MyProfile.qml | 1 + 1 file changed, 1 insertion(+) diff --git a/qml/widgets/MyProfile.qml b/qml/widgets/MyProfile.qml index d4400cd..d4ed233 100644 --- a/qml/widgets/MyProfile.qml +++ b/qml/widgets/MyProfile.qml @@ -101,6 +101,7 @@ ColumnLayout { width: parent.width onUpdated: { + nick = lblNick.text gcd.updateNick(lblNick.text) } }