From 6c7926dbcffa047512c4c3e8d89754986e93de1e Mon Sep 17 00:00:00 2001 From: Sarah Jamie Lewis Date: Wed, 13 Feb 2019 20:38:29 +0000 Subject: [PATCH 1/4] Update 'README.md' --- README.md | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 5333dae6..8e831719 100644 --- a/README.md +++ b/README.md @@ -1,12 +1,26 @@ -# Setup +# Cwtch - UI -## Android +This codebase provides a graphical user interface for Desktop and Android for [Cwtch: Privacy Preserving Infrastructure for Asynchronous, Decentralized and Metadata Resistant Applications](https://git.openprivacy.ca/cwtch.im/cwtch) -A arm-pie version of tor like [tor-0.3.4.8.arm-pie](https://git.openprivacy.ca/openprivacy/buildfiles/raw/master/tor/tor-0.3.4.8.arm-pie) is required to be placed in `android/libs/armeabi-v7a` with the name `libtor.so` +# Security -# Deployment +**Cwtch is an experimental concept and prototype. We do not recommend you use Cwtch today if you require secure communication.** At least, not yet. + + If you discover a security issue, please log an issue above, or email team@cwtch.im. + +# Compiling & Running +This code relies on [therecipe/qt](https://github.com/therecipe/qt) before getting started consult the [Installation](https://github.com/therecipe/qt/wiki/Installation) and [Getting Started](https://github.com/therecipe/qt/wiki/Getting-Started) documentation to get that up and running. It will make building this much easier. + +## Desktop + qtdeploy build desktop + ./deploy/linux/ui.sh -local -debug 2>&1 | grep -v 'Detected anchors on an item that is managed by a layout.' + + +The -local and -debug flags are helpful when developing. ## Android +A arm-pie version of tor like [tor-0.3.4.8.arm-pie](https://git.openprivacy.ca/openprivacy/buildfiles/raw/master/tor/tor-0.3.4.8.arm-pie) is required to be placed in `android/libs/armeabi-v7a` with the name `libtor.so` + qtdeploy -docker build android adb install deploy/android/build-debug.apk From c8605a952dd03352c528e1b12f5ba1a8512beb1f Mon Sep 17 00:00:00 2001 From: Sarah Jamie Lewis Date: Wed, 13 Feb 2019 20:39:32 +0000 Subject: [PATCH 2/4] Update 'README.md' --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 8e831719..3d8d5d0b 100644 --- a/README.md +++ b/README.md @@ -20,7 +20,7 @@ The -local and -debug flags are helpful when developing. ## Android -A arm-pie version of tor like [tor-0.3.4.8.arm-pie](https://git.openprivacy.ca/openprivacy/buildfiles/raw/master/tor/tor-0.3.4.8.arm-pie) is required to be placed in `android/libs/armeabi-v7a` with the name `libtor.so` +A arm-pie version of tor like [tor-0.3.5.7.arm-pie](https://git.openprivacy.ca/openprivacy/buildfiles/raw/master/tor/tor-0.3.5.7.arm-pie) is required to be placed in `android/libs/armeabi-v7a` with the name `libtor.so` qtdeploy -docker build android adb install deploy/android/build-debug.apk From 0568c9744aa673754b1a294861392091dd93c38a Mon Sep 17 00:00:00 2001 From: Sarah Jamie Lewis Date: Wed, 13 Feb 2019 20:40:50 +0000 Subject: [PATCH 3/4] Update 'README.md' --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 3d8d5d0b..1aa723d6 100644 --- a/README.md +++ b/README.md @@ -20,7 +20,7 @@ The -local and -debug flags are helpful when developing. ## Android -A arm-pie version of tor like [tor-0.3.5.7.arm-pie](https://git.openprivacy.ca/openprivacy/buildfiles/raw/master/tor/tor-0.3.5.7.arm-pie) is required to be placed in `android/libs/armeabi-v7a` with the name `libtor.so` +A arm-pie version of tor like [tor-0.3.5.7-armeabi-v7a](https://git.openprivacy.ca/openprivacy/buildfiles/src/master/tor/tor-0.3.5.7-armeabi-v7a.so) is required to be placed in `android/libs/armeabi-v7a` with the name `libtor.so` qtdeploy -docker build android adb install deploy/android/build-debug.apk From 25083878abaad40348ad9bc732e97c0ded151376 Mon Sep 17 00:00:00 2001 From: Sarah Jamie Lewis Date: Wed, 13 Feb 2019 18:42:13 -0800 Subject: [PATCH 4/4] Accept/Reject Invitations and Remove Game 2 --- go/gothings/gcd.go | 25 +++++++++++------ go/gothings/uistate.go | 6 ++-- main.go | 19 ++++++++++--- qml/panes/GroupSettingsPane.qml | 2 +- qml/panes/OverlayPane.qml | 50 +++++++++++++++++++++++++-------- qml/widgets/ContactRow.qml | 3 ++ 6 files changed, 77 insertions(+), 28 deletions(-) diff --git a/go/gothings/gcd.go b/go/gothings/gcd.go index 0e95add1..bab9b22b 100644 --- a/go/gothings/gcd.go +++ b/go/gothings/gcd.go @@ -41,9 +41,9 @@ type GrandCentralDispatcher struct { _ func(name, onion, image string) `signal:"UpdateMyProfile"` _ func(status int, str string) `signal:"TorStatus"` - // other stuff i can't ontologize atm + // settings helpers _ func(str string) `signal:"InvokePopup"` - _ func(groupID, name, server, invitation string, addrbooknames, addrbookaddrs []string) `signal:"SupplyGroupSettings"` + _ func(groupID, name, server, invitation string, accepted bool, addrbooknames, addrbookaddrs []string) `signal:"SupplyGroupSettings"` _ func(onion, nick string) `signal:"SupplyPeerSettings"` // signals emitted from the ui (written in go, below) @@ -55,7 +55,8 @@ type GrandCentralDispatcher struct { _ func(nick string) `signal:"updateNick,auto"` _ func(server, groupName string) `signal:"createGroup,auto"` _ func(groupID string) `signal:"leaveGroup,auto"` - _ func() `signal:"requestGroupSettings,auto"` + _ func(groupID string) `signal:"acceptGroup,auto"` + _ func(groupID string) `signal:"requestGroupSettings,auto"` _ func(groupID, nick string) `signal:"saveGroupSettings,auto"` _ func() `signal:"requestPeerSettings,auto"` _ func(onion, nick string) `signal:"savePeerSettings,auto"` @@ -251,16 +252,16 @@ func (this *GrandCentralDispatcher) savePeerSettings(onion, nick string) { this.UIState.UpdateContact(onion) } -func (this *GrandCentralDispatcher) requestGroupSettings() { - group := the.Peer.GetGroup(this.CurrentOpenConversation()) +func (this *GrandCentralDispatcher) requestGroupSettings(groupID string) { + group := the.Peer.GetGroup(groupID) if group == nil { - log.Errorf("couldn't find group %v", this.CurrentOpenConversation()) + log.Errorf("couldn't find group %v", groupID) return } nick, _ := group.GetAttribute("nick") - invite, _ := the.Peer.ExportGroup(this.CurrentOpenConversation()) + invite, _ := the.Peer.ExportGroup(groupID) contactaddrs := the.Peer.GetContacts() contactnames := make([]string, len(contactaddrs)) @@ -273,7 +274,7 @@ func (this *GrandCentralDispatcher) requestGroupSettings() { } } - this.SupplyGroupSettings(group.GroupID, nick, group.GroupServer, invite, contactnames, contactaddrs) + this.SupplyGroupSettings(group.GroupID, nick, group.GroupServer, invite, group.Accepted, contactnames, contactaddrs) } func (this *GrandCentralDispatcher) saveGroupSettings(groupID, nick string) { @@ -430,6 +431,14 @@ func (this *GrandCentralDispatcher) leaveGroup(groupID string) { this.UIState.UpdateContactAttribute(groupID, "deleted", "deleted") } +func (this *GrandCentralDispatcher) acceptGroup(groupID string) { + if the.Peer.GetGroup(groupID) != nil { + the.Peer.AcceptInvite(groupID) + the.Peer.JoinServer(the.Peer.GetGroup(groupID).GroupServer) + this.UIState.UpdateContact(groupID) + } +} + func (this *GrandCentralDispatcher) setAttribute(onion, key, value string) { pp,_ := the.Peer.GetProfile().GetContact(onion) if pp != nil { diff --git a/go/gothings/uistate.go b/go/gothings/uistate.go index e9ed0de8..4405d6a6 100644 --- a/go/gothings/uistate.go +++ b/go/gothings/uistate.go @@ -55,10 +55,10 @@ func (this *InterfaceState) GetContact(handle string) *gobjects.Contact { handle, handle, cwutil.RandomGroupImage(handle), - "", + group.GroupServer, 0, 0, - false, + group.Accepted, }) go the.Peer.JoinServer(group.GroupServer) @@ -78,7 +78,7 @@ func (this *InterfaceState) GetContact(handle string) *gobjects.Contact { false, }) } else if contact == nil { - log.Errorf("Attempting to add non existent contact to ui %v", handle) + //log.Errorf("Attempting to add non existent contact to ui %v", handle) } } } diff --git a/main.go b/main.go index 913571bf..8624c580 100644 --- a/main.go +++ b/main.go @@ -26,7 +26,13 @@ func init() { } func main() { - log.SetLevel(log.LevelInfo) + + if len(os.Args) >= 3 && os.Args[2] == "-debug" { + log.SetLevel(log.LevelDebug) + } else { + log.SetLevel(log.LevelInfo) + } + // our globals gcd := gothings.NewGrandCentralDispatcher(nil) @@ -39,7 +45,7 @@ func main() { // this is to load local qml files quickly when developing var qmlSource *core.QUrl - if len(os.Args) == 2 && os.Args[1] == "-local" { + if len(os.Args) >= 2 && os.Args[1] == "-local" { qmlSource = core.QUrl_FromLocalFile("./qml/main.qml") } else { qmlSource = core.NewQUrl3("qrc:/qml/main.qml", 0) @@ -160,8 +166,9 @@ func loadCwtchData(gcd *gothings.GrandCentralDispatcher, acn connectivity.ACN) { nick = group.GroupID[:12] } deleted,_ := group.GetAttribute("deleted") - if deleted != "deleted" { - the.Peer.JoinServer(group.GroupServer) + // Only join servers for active and explicitly accepted groups. + if deleted != "deleted"{ + gcd.UIState.AddContact(&gobjects.Contact{ Handle: group.GroupID, DisplayName: nick, @@ -170,5 +177,9 @@ func loadCwtchData(gcd *gothings.GrandCentralDispatcher, acn connectivity.ACN) { Trusted: group.Accepted, }) } + + if group.Accepted { + the.Peer.JoinServer(group.GroupServer) + } } } diff --git a/qml/panes/GroupSettingsPane.qml b/qml/panes/GroupSettingsPane.qml index b3440e64..c8b55d8b 100644 --- a/qml/panes/GroupSettingsPane.qml +++ b/qml/panes/GroupSettingsPane.qml @@ -120,7 +120,7 @@ ColumnLayout { // groupSettingsPane Connections { target: gcd - onSupplyGroupSettings: function(gid, name, server, invite, addrbooknames, addrbookaddrs) { + onSupplyGroupSettings: function(gid, name, server, invite, accepted, addrbooknames, addrbookaddrs) { console.log("Supplied " + gid + " " + name) gsp.groupID = gid toolbar.text = name diff --git a/qml/panes/OverlayPane.qml b/qml/panes/OverlayPane.qml index f9836dfc..f3703be1 100644 --- a/qml/panes/OverlayPane.qml +++ b/qml/panes/OverlayPane.qml @@ -10,7 +10,9 @@ import "../overlays" ColumnLayout { Layout.fillWidth: true property alias title: toolbar.text - + id: overlay + property string name + property bool accepted StackToolbar { id: toolbar @@ -19,7 +21,7 @@ ColumnLayout { aux.onClicked: { if (gcd.currentOpenConversation.length == 32) { theStack.pane = theStack.groupProfilePane - gcd.requestGroupSettings() + gcd.requestGroupSettings(gcd.currentOpenConversation) } else { theStack.pane = theStack.userProfilePane gcd.requestPeerSettings() @@ -28,6 +30,29 @@ ColumnLayout { back.visible: false } + RowLayout { + visible:!overlay.accepted + Text { + text: "Do you want to accept the invitation to " + overlay.name + "?" + } + SimpleButton { + text: "Accept" + icon: "regular/heart" + onClicked: { + gcd.acceptGroup(gcd.currentOpenConversation) + gcd.requestGroupSettings(gcd.currentOpenConversation) + } + } + SimpleButton { + text: "Reject" + icon: "regular/trash-alt" + onClicked: { + gcd.leaveGroup(gcd.currentOpenConversation) + theStack.pane = theStack.emptyPane + } + } + } + RowLayout { id: switcher @@ -54,18 +79,12 @@ ColumnLayout { } SimpleButton { - text: "Game 1" + text: "Puzzle Game" onClicked: overlayStack.overlay = overlayStack.game1Overlay } - SimpleButton { - text: "Game 2" - - - onClicked: overlayStack.overlay = overlayStack.game2Overlay - } } StackLayout { @@ -81,7 +100,6 @@ ColumnLayout { readonly property int listOverlay: 1 readonly property int bulletinOverlay: 2 readonly property int game1Overlay: 3 - readonly property int game2Overlay: 4 ChatOverlay {} //0 @@ -91,7 +109,15 @@ ColumnLayout { BulletinOverlay{} //2 Game1Overlay{} //3 - - Game2Overlay{} //4 } + + Connections { + target: gcd + + onSupplyGroupSettings: function(gid, name, server, invite, accepted, addrbooknames, addrbookaddrs) { + console.log("Supplied " + gid + " " + name + "Accepted " + accepted) + overlay.name = name + overlay.accepted = accepted + } + } } \ No newline at end of file diff --git a/qml/widgets/ContactRow.qml b/qml/widgets/ContactRow.qml index ea2f9417..64f3ad73 100644 --- a/qml/widgets/ContactRow.qml +++ b/qml/widgets/ContactRow.qml @@ -88,6 +88,9 @@ RowLayout { // LOTS OF NESTING TO DEAL WITH QT WEIRDNESS, SORRY isActive = true theStack.pane = theStack.messagePane gcd.loadMessagesPane(handle) + if (handle.length == 32) { + gcd.requestGroupSettings(handle) + } } onEntered: {