From 3f57e258e10e584c029764bc1a8b2dd01de78d98 Mon Sep 17 00:00:00 2001 From: Sarah Jamie Lewis Date: Mon, 21 Sep 2020 14:31:45 -0700 Subject: [PATCH 1/2] Tapir Integtation II --- Makefile | 2 +- go.mod | 4 +- go.sum | 2 + go/handlers/appHandler.go | 1 - go/handlers/peerHandler.go | 2 +- go/ui/gcd.go | 54 ++++++++- go/ui/manager.go | 11 +- i18n/translation_de.qm | Bin 3050 -> 3003 bytes i18n/translation_de.ts | 51 ++++++--- i18n/translation_en.qm | Bin 7469 -> 7802 bytes i18n/translation_en.ts | 51 ++++++--- i18n/translation_fr.qm | Bin 2970 -> 2925 bytes i18n/translation_fr.ts | 51 ++++++--- i18n/translation_pt.qm | Bin 2844 -> 2763 bytes i18n/translation_pt.ts | 51 ++++++--- main.go | 2 +- qml/main.qml | 7 +- qml/opaque | 2 +- qml/panes/GroupSettingsPane.qml | 189 ++++++++++++++++++++------------ qml/panes/OverlayPane.qml | 14 ++- qml/panes/ServerInfoPane.qml | 78 +++++++++++++ qml/widgets/ProfileList.qml | 2 + 22 files changed, 436 insertions(+), 138 deletions(-) create mode 100644 qml/panes/ServerInfoPane.qml diff --git a/Makefile b/Makefile index 6a66eee2..e59e97d1 100644 --- a/Makefile +++ b/Makefile @@ -18,7 +18,7 @@ android: linux_build: date - qtdeploy -qt_version "5.13.0" build linux 2>&1 | tee qtdeploy.log | pv + qtdeploy -qt_version "5.13.2" build linux 2>&1 | tee qtdeploy.log | pv date cp -R assets deploy/linux/ $(MAKE) linux_clean diff --git a/go.mod b/go.mod index e71241b9..2aba8d3d 100644 --- a/go.mod +++ b/go.mod @@ -4,7 +4,7 @@ go 1.12 require ( cwtch.im/cwtch v0.3.16 - git.openprivacy.ca/openprivacy/connectivity v1.1.4 + git.openprivacy.ca/openprivacy/connectivity v1.2.0 git.openprivacy.ca/openprivacy/log v1.0.1 github.com/gopherjs/gopherjs v0.0.0-20200209183636-89e6cbcd0b6d // indirect github.com/therecipe/qt v0.0.0-20200126204426-5074eb6d8c41 @@ -12,3 +12,5 @@ require ( github.com/therecipe/qt/internal/binding/files/docs/5.13.0 v0.0.0-20200126204426-5074eb6d8c41 // indirect golang.org/x/crypto v0.0.0-20200420104511-884d27f42877 // indirect ) + +replace cwtch.im/cwtch => /home/sarah/workspace/src/cwtch.im/cwtch diff --git a/go.sum b/go.sum index 127c46e7..b6fa1c25 100644 --- a/go.sum +++ b/go.sum @@ -14,6 +14,8 @@ cwtch.im/tapir v0.1.17 h1:2jVZUe1a88tMI4aJPvRTO4Id3NN3PsM62cT5lntEChk= cwtch.im/tapir v0.1.17/go.mod h1:HzezugpEx+nZ3LdyDsl0w6n45IJYnOt8uqldkLWmaqs= cwtch.im/tapir v0.1.18 h1:Fs/jL9ZRyel/A1D/BYzIPEVQau8y5BJg44yA+GQDbSM= cwtch.im/tapir v0.1.18/go.mod h1:/IrAI6CBHfgzsfgRT8WHVb1P9fCCz7+45hfsdkKn8Zg= +cwtch.im/tapir v0.2.0 h1:7MkoR5+uEuPW34/O0GZRidnIjq/01Cfm8nl5IRuqpGc= +cwtch.im/tapir v0.2.0/go.mod h1:xzzZ28adyUXNkYL1YodcHsAiTt3IJ8Loc29YVn9mIEQ= git.openprivacy.ca/openprivacy/connectivity v1.1.0/go.mod h1:4P8mirZZslKbo2zBrXXVjgEdqGwHo/6qoFBwFQW6d6E= git.openprivacy.ca/openprivacy/connectivity v1.1.1 h1:hKxBOmxP7Jdu3K1BJ93mRtKNiWUoP6YHt/o2snE2Z0w= git.openprivacy.ca/openprivacy/connectivity v1.1.1/go.mod h1:4P8mirZZslKbo2zBrXXVjgEdqGwHo/6qoFBwFQW6d6E= diff --git a/go/handlers/appHandler.go b/go/handlers/appHandler.go index 851f0fc3..43414c91 100644 --- a/go/handlers/appHandler.go +++ b/go/handlers/appHandler.go @@ -87,7 +87,6 @@ func App(gcd *ui.GrandCentralDispatcher, subscribed chan bool, reloadingAccounts if e.Data[event.Status] != "running" { p.Listen() p.StartPeersConnections() - p.StartGroupConnections() } blockUnkownPeers, exists := p.GetAttribute(constants.BlockUnknownPeersSetting) diff --git a/go/handlers/peerHandler.go b/go/handlers/peerHandler.go index c4f940db..30637f95 100644 --- a/go/handlers/peerHandler.go +++ b/go/handlers/peerHandler.go @@ -127,7 +127,7 @@ func PeerHandler(onion string, uiManager ui.Manager, subscribed chan bool) { if state == connections.AUTHENTICATED { loading = true } - uiManager.UpdateContactStatus(group.GroupID, int(state), loading) + uiManager.UpdateContactStatus(serverOnion, int(state), loading) } else { log.Errorf("found group that is nil :/") } diff --git a/go/ui/gcd.go b/go/ui/gcd.go index 3a855d0a..1e7fd2a7 100644 --- a/go/ui/gcd.go +++ b/go/ui/gcd.go @@ -1,6 +1,7 @@ package ui import ( + "encoding/base64" "sync" "cwtch.im/cwtch/app" @@ -82,6 +83,7 @@ type GrandCentralDispatcher struct { _ func(locale string, zoom float32, theme string) `signal:"SupplySettings"` _ func(groupID, name, server, invitation string, accepted bool, addrbooknames, addrbookaddrs []string) `signal:"SupplyGroupSettings"` _ func(onion, nick string, authorization string, storage string) `signal:"SupplyPeerSettings"` + _ func(server string, key_types []string, keys []string) `signal:"SupplyServerSettings"` // signals emitted from the ui (written in go, below) // ui @@ -118,6 +120,8 @@ type GrandCentralDispatcher struct { _ func(onion string) `signal:"storeHistoryForPeer,auto"` _ func(onion string) `signal:"deleteHistoryForPeer,auto"` + _ func(handle string) `signal:"requestServerSettings,auto"` + _ func() `constructor:"init"` } @@ -380,6 +384,31 @@ func (this *GrandCentralDispatcher) deleteHistoryForPeer(onion string) { the.Peer.SetContactAttribute(onion, event.SaveHistoryKey, event.DeleteHistoryConfirmed) } +func (this *GrandCentralDispatcher) requestServerSettings(groupID string) { + group := the.Peer.GetGroup(groupID) + + if group == nil { + log.Errorf("couldn't find group %v", groupID) + return + } + + serverInfo := the.Peer.GetContact(group.GroupServer) + + key_types := []model.KeyType{model.KeyTypeServerOnion, model.KeyTypeTokenOnion, model.KeyTypePrivacyPass} + var keyNames []string + var keys []string + + for _,key_type := range key_types { + log.Debugf("Looking up %v %v", key_type, keyNames) + if key,has := serverInfo.GetAttribute(string(key_type)); has { + keyNames = append(keyNames, string(key_type)) + keys = append(keys, key) + } + } + + this.SupplyServerSettings(group.GroupServer, keyNames, keys) +} + func (this *GrandCentralDispatcher) requestGroupSettings(groupID string) { group := the.Peer.GetGroup(groupID) @@ -397,6 +426,9 @@ func (this *GrandCentralDispatcher) requestGroupSettings(groupID string) { contactnames[i] = getNick(contact) } this.SupplyGroupSettings(group.GroupID, nick, group.GroupServer, invite, group.Accepted, contactnames, contactaddrs) + status := connections.ConnectionStateToType[group.State] + log.Debugf("Sending New Group Status: %v %v", group.GroupServer, status) + this.UpdateContactStatus(group.GroupServer, int(status), false) } func (this *GrandCentralDispatcher) saveGroupSettings(groupID, nick string) { @@ -429,6 +461,23 @@ func (this *GrandCentralDispatcher) importString(str string) { return } + + // Server Key Bundles are prefixed with + if strings.HasPrefix(str, "server:") { + bundle, err := base64.StdEncoding.DecodeString(str[7:]) + if err == nil { + err := the.Peer.AddServer(string(bundle)) + if err == nil { + this.InvokePopup("Successfully Imported Server Key Bundle") + return + } + this.InvokePopup("Error Importing Server Key Bundle: " + err.Error()) + return + } + this.InvokePopup("Invalid Server Key Bundle: " + err.Error()) + return + } + log.Debugf("importing: %s\n", str) onion := str name := onion @@ -441,6 +490,7 @@ func (this *GrandCentralDispatcher) importString(str string) { this.InvokePopup("not a valid group invite") return } + return } @@ -650,7 +700,9 @@ func (this *GrandCentralDispatcher) loadProfile(onion string) { contacts := the.Peer.GetContacts() for i := range contacts { - this.GetUiManager(this.selectedProfile()).AddContact(contacts[i]) + if the.Peer.GetContact(contacts[i]).IsServer() == false { + this.GetUiManager(this.selectedProfile()).AddContact(contacts[i]) + } } groups := the.Peer.GetGroups() diff --git a/go/ui/manager.go b/go/ui/manager.go index b88f70e1..880bb4f2 100644 --- a/go/ui/manager.go +++ b/go/ui/manager.go @@ -14,11 +14,18 @@ import ( ) func isGroup(id string) bool { - return len(id) == 32 + return len(id) == 32 && !isServer(id) } func isPeer(id string) bool { - return len(id) == 56 + return len(id) == 56 && !isServer(id) +} + +// Check if the id is associated with a contact with a KeyTypeServerOnion attribute (which indicates that this +// is a server, not a regular contact or a group +func isServer(id string) bool { + _,ok := the.Peer.GetContactAttribute(id, string(model.KeyTypeServerOnion)) + return ok } func getOrDefault(id, key string, defaultVal string) string { diff --git a/i18n/translation_de.qm b/i18n/translation_de.qm index d3f984f6c3eb9adb4f9106512df8b9373c52e452..0085085b23c3198a016f4449c0b49f18f1394403 100644 GIT binary patch delta 304 zcmaDQzFWNBW=D#|srPfHo>i3DpRjQ6T_*+xh98V|Vpbz!<@}_OcEG z1M@%Tm0xNY7&zjY->?+{#ZR;BdjjM$T!hdpZ7iRUonv5NIl_9e{0svFS2|mbJs(h? z8HDDPWBa}r$YHK zGl34_oWZrtYaP%5THGn!4nTbZ+{GVqfcgS>M6SO9s_TN#%$s-?P3;3(Tmqpvqj?Vg z0XayI&n7Gc=l}t}7(pPPk&90xas4}>Mh3oid!WVazcPWU7HyVd+{HBc31{ZyRu=Ki OSC|DDH+QqfvjG4kU{-km delta 405 zcmdlj{z|;wW=D#|srPfHo>i3DpRjQ6T_*+xMg|74+c^vjENl!5ZR!{pn2#~Co%qAR zz~0NKvwICtK7w)WWgVb+9rMaBH4F?KZOm`jih$y$S@t~v@)<5dXqL4spO2jbn)90V zV)+>c2ChD~8hbtl2BvKgn$wl-d;MOZ0LL-*>7sc+3m$QFa|Og3PVanoV&1S(SiD#`>ZQ($ms hC}JpOC;&nbFBOL&qEJIh@^#aT@=FUgTeCK>0RTM#Y3cv~ diff --git a/i18n/translation_de.ts b/i18n/translation_de.ts index d978b4a6..2f254c9a 100644 --- a/i18n/translation_de.ts +++ b/i18n/translation_de.ts @@ -69,44 +69,69 @@ GroupSettingsPane - + server-label Server - - + + copy-btn Kopieren - + + + copied-to-clipboard-notification + notification: copied to clipboard + in die Zwischenablage kopiert + + + invitation-label Einladung - + + server-info + + + + + server-connectiivity + + + + + server-synced + + + + + view-server-info + + + + group-name-label Gruppenname - + save-btn Speichern - invite-to-group-label Invite someone to the group - In die Gruppe einladen + In die Gruppe einladen - invite-btn - Einladen + Einladen - + delete-btn Löschen @@ -184,7 +209,7 @@ peer-blocked-message - Peer is blockced + Peer is blocked @@ -418,7 +443,7 @@ ProfileList - + add-new-profile-btn diff --git a/i18n/translation_en.qm b/i18n/translation_en.qm index e1871aa5cc5214dd2159b9f495d2edbf8bc99285..4e71436ce9664bedb3b83eb4e65a5547f8d1ff9f 100644 GIT binary patch delta 934 zcmZ8fX-HI27(MgGx6E5+Mw@A@i8ickvHFogo9$4R5VT2q>8P(|jG0L@iYZ&5q^MpI z6$J)uViA~;L_(ygWl9(n{V*iM77L-Gh^UT@NcH2rbHB@X&Uene_uAy|Q;&M0M-jiZ z5|HNEr1~F#W1(%#opQjo%(iEh2qZSy%11v1TphM+En@)tdt3dRCcx_xCM0m*+bm?x zSq}8yELhLU>+{4udgDdFf5^U1S^)H$X}|h;C!qQ5ol=Op6>-(=tkE39s5m(8(*p|1 z!$rS8l>!IE^NY@tuu^}dhSUkpQa8w(+U`s>crFKQ9$3Wmgg)465gq|(rH9}qdru5l&;@`|m@~yb0ILDf&sZ(cV2m?o`x19}+F=i}W( zcZy4YH4BJubN$KNXS~UG(ok_+s1vN8`cmtr=(9{?khNXxuns!A(Z_wsS~9>rE`odv z#$p5zLP7UmVL(XyJmEm7AP`E)$`1wuSrOALFe63Q4beY2>F<8B=Oc(5>V&Wb>k)y; zb+A`Q>(McTIr-gmYm}TeK9Ledq-7zGG`5qpgX6P%X+{q%TolX-WOoy1Cu14g0x0~~ caZeTbGdYM{gnLEY1!kZybpEN8glUxhNK*>T{2_fneyl{7Zq^TLW9wt(5GbN2*W}vp^glqANPGY=RMCk&vV}UE3I36ftK@I3T`_@u$83)B&b1oJMs%X7qCi zi2b13WTCvZU00lQ09dg_r@bbgstQ$z!&z|S=0K3BWe6I(@Pi%y*0ennAKQv7V zOhi%Nte<~O4Y_YzVxp58?BhE2b^y{kZt~I>;18kLs$c@v)Hwp z$@V`Rh_GHxzT%}P>5`8&Z6~2qa_w9tVXAy{PDcao$kUc#GLoxUUqxup#VE2)CCKcgrMN^s6+r@;lv!=-U5_+m8G4gscoV}9!{T2-;JsdI+nyT<;*^oBx# zG5nVP0hL$NU2P=%s+w6;NDUooiJAC}pdPtJ&Z*);Hf>Hkr;d3-^dyDqvj#$S(WHFb z0mS%CQNzDoV3E)q=+!;ZX@hE#w#3aOD%g!G)WHQ0N`>WaJbjX@s?MdQ^T`>j{=dg+ vs;Z{595sYqxc@P1%M4Gc!&B`juc`LBwOK>5_R^H3W$^J@$dDBX3M00^&-cn@ diff --git a/i18n/translation_en.ts b/i18n/translation_en.ts index a62f2a31..c0b75962 100644 --- a/i18n/translation_en.ts +++ b/i18n/translation_en.ts @@ -157,44 +157,69 @@ Right-click to reset. GroupSettingsPane - + server-label Server - - + + copy-btn Copy - + + + copied-to-clipboard-notification + notification: copied to clipboard + Copied to Clipboard + + + invitation-label Invitation - + + server-info + Server Information + + + + server-connectiivity + Connected to Server + + + + server-synced + Synchronized + + + + view-server-info + View Server Settings + + + group-name-label Group Name - + save-btn Save - invite-to-group-label Invite someone to the group - Invite to group + Invite to group - invite-btn - Invite + Invite - + delete-btn Delete @@ -264,7 +289,7 @@ Right-click to reset. peer-blocked-message - Peer is blockced + Peer is blocked Peer is blocked @@ -510,7 +535,7 @@ Right-click to reset. ProfileList - + add-new-profile-btn Add new profile diff --git a/i18n/translation_fr.qm b/i18n/translation_fr.qm index d20f24f0333859483ad29804708d96137192a80f..68489cad2d33f4c0b5e737f20e6715f266245079 100644 GIT binary patch delta 305 zcmbOw{#LBsW=D#|srPfHo>i3DpRjQ6T_*+xh98V|Vpbz!=52_OcEG z1M@HDm0xNY7&z3K->?+{#ZR;BdjjM$oP^LU9W0-Zonv5NIl+3d{0svFmn2(_Js(h? z5rpP=#P)qJkk7OYLUW|EPp=ov16owg(akNyz`$0i3DpRjQ6T_*+xMg|74+c^vjEIbSgZR!{pm`^aWo%qAR zz@E&gvwICtK8kVeWgVb+9rMaBH4F?KKFn{}ih$y$S@t~v@)=G-XqL4spO2jbn)8c1};0c8hbtl2BvKgnv|>B7$*y`%CT}~=9Ohm zp3kCaqr~9JkjGHQkjYTOkjhZRpukYbPzq$_fN6CgJC6fsCj%Q0i-L5Or0SOB>!ugw QmljNZ&!V_FidC2m0Gys-C;$Ke diff --git a/i18n/translation_fr.ts b/i18n/translation_fr.ts index 10aa6cd7..45bdbc95 100644 --- a/i18n/translation_fr.ts +++ b/i18n/translation_fr.ts @@ -69,44 +69,69 @@ GroupSettingsPane - + server-label Serveur - - + + copy-btn Copier - + + + copied-to-clipboard-notification + notification: copied to clipboard + Copié dans le presse-papier + + + invitation-label Invitation - + + server-info + + + + + server-connectiivity + + + + + server-synced + + + + + view-server-info + + + + group-name-label Nom du groupe - + save-btn Sauvegarder - invite-to-group-label Invite someone to the group - Inviter quelqu'un + Inviter quelqu'un - invite-btn - Invitation + Invitation - + delete-btn Effacer @@ -184,7 +209,7 @@ peer-blocked-message - Peer is blockced + Peer is blocked @@ -418,7 +443,7 @@ ProfileList - + add-new-profile-btn diff --git a/i18n/translation_pt.qm b/i18n/translation_pt.qm index 3480551addc526c818dcd04f9b963bc556bef0aa..3207ff3cdce01a08351e9cee83116fdb995ec88c 100644 GIT binary patch delta 309 zcmbOuc3QOFW=D#|srPfHo>i3DpRjQ6T_*+xh98VNe#2G-6hFwa?+K94a1}zc*s***c8-C8rGfQg`56WV&SJJ2dp-sR zrXLWR!+`DkUJ!o?gl50XKD}Nv4`|U(j&5!tAkD#X!p;t801JfX_{+tUJ{4$zHJ8~; zphGy8ac%Qj2XsIhcS^SdP<3zbN~xqj3AKDD8x6JjggPdEE6cVX|ojL3Z}^}oVJsnGK){1&Z#{4JB#?_ R3!Lg;+KOe$=4{rDtN=vLS-SuL delta 381 zcmX>tI!CPDW=D#|srPfHo>i3DpRjQ6T_*+xMg|74+c^vj%pVvQ+SCE*4UB9j{xC4G zb294eUIUa*U|f4y2PmGyyz)y8Q2Yt=8@3{#_(7I^Pk?-es}P!{o#pefa|{eDCs{9+ zpJ8C&+{0F5&&R;Pv;;zPRI+`q-wPDrP-CAing=wbsICh_Gt2NSn%W1n z@E(Nb*u-=256B_)d^TYrKyenniQmN7>N9~tzc&jpu3(z%#;H7+nN@spJ*WEQe3sR! z0u0U!`3!jsWek}NDGZ4WMI1om8Q6fBD>JVwvm{kFsU&ame->#`C3KYx3Ji&p*D{I= Vh(cACgHQ6#xyiY7YPa diff --git a/i18n/translation_pt.ts b/i18n/translation_pt.ts index 36119bb0..bef4c8cc 100644 --- a/i18n/translation_pt.ts +++ b/i18n/translation_pt.ts @@ -69,44 +69,69 @@ GroupSettingsPane - + server-label Servidor - - + + copy-btn Copiar - + + + copied-to-clipboard-notification + notification: copied to clipboard + Copiado + + + invitation-label Convite - + + server-info + + + + + server-connectiivity + + + + + server-synced + + + + + view-server-info + + + + group-name-label Nome do Grupo - + save-btn Salvar - invite-to-group-label Invite someone to the group - Convidar ao grupo + Convidar ao grupo - invite-btn - Convidar + Convidar - + delete-btn Deletar @@ -184,7 +209,7 @@ peer-blocked-message - Peer is blockced + Peer is blocked @@ -418,7 +443,7 @@ ProfileList - + add-new-profile-btn diff --git a/main.go b/main.go index b2b987a7..857150d0 100644 --- a/main.go +++ b/main.go @@ -65,7 +65,7 @@ func main() { log.ExcludeFromPattern("service.go") log.ExcludeFromPattern("tor/BaseOnionService.go") log.ExcludeFromPattern("applications/auth.go") - log.ExcludeFromPattern("connections/engine.go") + //log.ExcludeFromPattern("connections/engine.go") if os.Getenv("CWTCH_FOLDER") != "" { the.CwtchDir = os.Getenv("CWTCH_FOLDER") diff --git a/qml/main.qml b/qml/main.qml index 319c4602..fd7401ec 100644 --- a/qml/main.qml +++ b/qml/main.qml @@ -111,6 +111,7 @@ ApplicationWindow { readonly property int settingsPane: 2 readonly property int addEditProfilePane: 3 readonly property int profilePane: 4 + readonly property int serverPane: 5 property alias pane: parentStack.currentIndex Rectangle { // Splash pane @@ -164,7 +165,6 @@ ApplicationWindow { } } - RowLayout { // Profile Pane (contact list + overlays) Layout.fillHeight: true Layout.fillWidth: true @@ -215,6 +215,7 @@ ApplicationWindow { readonly property int userProfilePane: 2 readonly property int groupProfilePane: 3 readonly property int addGroupPane: 4 + readonly property int serverInfoPane: 5 Item { anchors.fill: parent } // empty @@ -235,6 +236,8 @@ ApplicationWindow { AddGroupPane { anchors.fill: parent } + ServerInfoPane {anchors.fill :parent} + onCurrentIndexChanged: { parentStack.updateToolbar() if (currentIndex == emptyPane) { @@ -316,7 +319,7 @@ ApplicationWindow { gcd.selectedProfile = "none" gcd.reloadProfileList() parentStack.pane = parentStack.managementPane - } else if (theStack.currentIndex == theStack.userProfilePane || theStack.currentIndex == theStack.groupProfilePane) { + } else if (theStack.currentIndex == theStack.userProfilePane || theStack.currentIndex == theStack.groupProfilePane ) { theStack.currentIndex = theStack.messagePane } else { theStack.currentIndex = theStack.emptyPane diff --git a/qml/opaque b/qml/opaque index ec21dcbf..5c33d6ed 160000 --- a/qml/opaque +++ b/qml/opaque @@ -1 +1 @@ -Subproject commit ec21dcbf8e20f4f894ba0dc829ccf18f56e0d27a +Subproject commit 5c33d6ed2c46f5fe039fc6fee3cb690cb562cb23 diff --git a/qml/panes/GroupSettingsPane.qml b/qml/panes/GroupSettingsPane.qml index d7ece6c2..f6ef5123 100644 --- a/qml/panes/GroupSettingsPane.qml +++ b/qml/panes/GroupSettingsPane.qml @@ -9,128 +9,175 @@ import QtQuick.Controls 1.4 import "../opaque" as Opaque import "../opaque/styles" import "../utils.js" as Utils +import "../opaque/theme" +import "../const" -ColumnLayout { // groupSettingsPane +Opaque.SettingsList { // groupSettingsPane id: gsp anchors.fill: parent property string groupID property variant addrbook - Flickable { + settings: Column { anchors.fill: parent - boundsBehavior: Flickable.StopAtBounds - clip:true - contentWidth: tehcol.width - contentHeight: tehcol.height - Column { - id: tehcol - width: gsp.width - leftPadding: 10 - spacing: 5 - - Opaque.ScalingLabel { - text: qsTr("server-label") + ":" - } - - TextField { - id: txtServer - style: CwtchTextFieldStyle{ width: tehcol.width * 0.8 } - readOnly: true - } - - Opaque.Button { - icon: "regular/clipboard" - text: qsTr("copy-btn") + Opaque.Setting { + inline: false + label: qsTr("group-name-label") + field: Opaque.ButtonTextField { + id: txtGroupName + readOnly: false + button_text: qsTr("save-btn") + dropShadowColor: Theme.dropShadowPaneColor onClicked: { - gcd.popup("copied-clipboard-notification") + //: notification: copied to clipboard + gcd.saveGroupSettings(groupID, txtGroupName.text) + theStack.title = txtGroupName.text + } + } + } + + Opaque.Setting { + inline: false + label: qsTr("server-label") + + field: Opaque.ButtonTextField { + id: txtServer + readOnly: true + button_text: qsTr("copy-btn") + dropShadowColor: Theme.dropShadowPaneColor + onClicked: { + //: notification: copied to clipboard + gcd.popup(qsTr("copied-to-clipboard-notification")) txtServer.selectAll() txtServer.copy() } } + } - Opaque.ScalingLabel { - text: qsTr("invitation-label") + ":" - } + Opaque.Setting { + inline: false + label: qsTr("invitation-label") - TextField { + field: Opaque.ButtonTextField { id: txtInvitation - style: CwtchTextFieldStyle{ width: tehcol.width * 0.8 } readOnly: true - } - - Opaque.Button { - icon: "regular/clipboard" - text: qsTr("copy-btn") - + button_text: qsTr("copy-btn") + dropShadowColor: Theme.dropShadowPaneColor onClicked: { - gcd.popup("copied-clipboard-notification") + //: notification: copied to clipboard + gcd.popup(qsTr("copied-to-clipboard-notification")) txtInvitation.selectAll() txtInvitation.copy() } } + } - Opaque.ScalingLabel{ - text: qsTr("group-name-label") + ":" - } + Opaque.Setting { + property color backgroundColor: parent.color + inline: true + label: qsTr("server-info") + field: Column { + width: parent.width + spacing:10 + RowLayout { + width: parent.width + Layout.fillWidth: true + Opaque.ScalingLabel { + text: qsTr("server-connectiivity") + Layout.alignment: Qt.AlignLeft + } + Opaque.Icon { + backgroundColor: Theme.backgroundPaneColor + id: serverStatusIcon + height: 18 + width: 18 + Layout.alignment: Qt.AlignRight + } + } + RowLayout { + width: parent.width + Layout.fillWidth: true - TextField { - id: txtGroupName - style: CwtchTextFieldStyle{ width: tehcol.width * 0.8 } - } + Opaque.ScalingLabel { + text: qsTr("server-synced") + Layout.alignment: Qt.AlignLeft + } + Opaque.Icon { + id: serverSyncedStatusIcon + backgroundColor: Theme.backgroundPaneColor + height: 18 + width: 18 + Layout.alignment: Qt.AlignRight + } + } - Opaque.Button { - text: qsTr("save-btn") + Opaque.Button { + icon: "regular/hdd" + text: qsTr("view-server-info") + anchors.right: parent.right - onClicked: { - gcd.saveGroupSettings(groupID, txtGroupName.text) - theStack.title = txtGroupName.text - theStack.pane = theStack.messagePane - } - } + onClicked: { + gcd.requestServerSettings(gcd.selectedConversation) + theStack.pane = theStack.serverInfoPane + } + } - //: Invite someone to the group - Opaque.ScalingLabel { text: qsTr("invite-to-group-label") } + } + } - ComboBox { - id: cbInvite - //popup.font.pixelSize: 12 - width: 200 - //font.pixelSize: 20 - style: CwtchComboBoxStyle{} - } - Opaque.Button { - text: qsTr("invite-btn") - onClicked: { - gcd.inviteToGroup(addrbook[cbInvite.currentIndex], groupID) - } - } + Column { + width:parent.width * 0.95 + anchors.horizontalCenter: parent.horizontalCenter Opaque.Button { icon: "regular/trash-alt" text: qsTr("delete-btn") + anchors.right: parent.right + onClicked: { gcd.leaveGroup(groupID) theStack.pane = theStack.emptyPane } } + } - }//end of column with padding - }//end of flickable + } Connections { target: gcd + onUpdateContactStatus: function(_handle, _status, _loading) { + if (txtServer.text == _handle) { + if (_status >= Const.state_connected) { + serverStatusIcon.iconColor = Theme.statusbarOnlineFontColor + serverStatusIcon.source = gcd.assetPath + "core/signal_cellular_4_bar-24px.svg" + if (_status != Const.state_synced) { + serverSyncedStatusIcon.iconColor = Theme.statusbarConnectingFontColor + serverSyncedStatusIcon.source = gcd.assetPath + "core/syncing-03.svg" + } else { + serverSyncedStatusIcon.iconColor = Theme.statusbarOnlineFontColor + serverSyncedStatusIcon.source = gcd.assetPath + "core/syncing-01.svg" + } + } else { + serverStatusIcon.iconColor = Theme.statusbarDisconnectedTorFontColor + serverStatusIcon.source = gcd.assetPath + "core/signal_cellular_connected_no_internet_4_bar-24px.svg" + serverSyncedStatusIcon.iconColor = Theme.statusbarDisconnectedTorFontColor + serverSyncedStatusIcon.source = gcd.assetPath + "core/syncing-03.svg" + } + } + } + onSupplyGroupSettings: function(gid, name, server, invite, accepted, addrbooknames, addrbookaddrs) { gsp.groupID = gid txtGroupName.text = name txtServer.text = server txtInvitation.text = invite - cbInvite.model = addrbooknames.map(function(e){return Utils.htmlEscaped(e)}) + //cbInvite.model = addrbooknames.map(function(e){return Utils.htmlEscaped(e)}) addrbook = addrbookaddrs } } diff --git a/qml/panes/OverlayPane.qml b/qml/panes/OverlayPane.qml index 293ebd96..911b0db1 100644 --- a/qml/panes/OverlayPane.qml +++ b/qml/panes/OverlayPane.qml @@ -33,10 +33,10 @@ ColumnLayout { //: Accept group invite button text: qsTr("accept-group-btn") icon: "regular/heart" - onClicked: { - gcd.acceptGroup(gcd.selectedConversation) - gcd.requestGroupSettings(gcd.selectedConversation) - } + onClicked: { + gcd.acceptGroup(gcd.selectedConversation) + gcd.requestGroupSettings(gcd.selectedConversation) + } } Opaque.Button { @@ -147,5 +147,11 @@ ColumnLayout { overlay.accepted = accepted overlay.inGroup = true } + + onSupplyServerSettings: function(server) { + overlay.name = server + } + + } } diff --git a/qml/panes/ServerInfoPane.qml b/qml/panes/ServerInfoPane.qml new file mode 100644 index 00000000..0ac3e10c --- /dev/null +++ b/qml/panes/ServerInfoPane.qml @@ -0,0 +1,78 @@ +import QtGraphicalEffects 1.0 +import QtQuick 2.7 +import QtQuick.Controls 2.4 +import QtQuick.Controls.Material 2.0 +import QtQuick.Layouts 1.3 +import QtQuick.Window 2.11 +import QtQuick.Controls 1.4 + +import "../opaque" as Opaque +import "../opaque/styles" +import "../utils.js" as Utils +import "../opaque/theme" +import "../const" + +Opaque.SettingsList { // groupSettingsPane + id: gsp + anchors.fill: parent + property string serverName + property color backgroundColor: parent.color + + settings: Column { + anchors.fill: parent + + Opaque.Setting { + inline: false + label: qsTr("server-label") + + field: Opaque.ButtonTextField { + id: txtServer + readOnly: true + text: serverName; + button_text: qsTr("copy-btn") + dropShadowColor: Theme.dropShadowPaneColor + onClicked: { + //: notification: copied to clipboard + gcd.popup(qsTr("copied-to-clipboard-notification")) + txtServer.selectAll() + txtServer.copy() + } + } + } + } + + Connections { + target: gcd + + onUpdateContactStatus: function(_handle, _status, _loading) { + if (txtServer.text == _handle) { + if (_status >= Const.state_connected) { + serverStatusIcon.iconColor = Theme.statusbarOnlineFontColor + serverStatusIcon.source = gcd.assetPath + "core/signal_cellular_4_bar-24px.svg" + if (_status != Const.state_synced) { + serverSyncedStatusIcon.iconColor = Theme.statusbarConnectingFontColor + serverSyncedStatusIcon.source = gcd.assetPath + "core/syncing-03.svg" + } else { + serverSyncedStatusIcon.iconColor = Theme.statusbarOnlineFontColor + serverSyncedStatusIcon.source = gcd.assetPath + "core/syncing-01.svg" + } + } else { + serverStatusIcon.iconColor = Theme.statusbarDisconnectedTorFontColor + serverStatusIcon.source = gcd.assetPath + "core/signal_cellular_connected_no_internet_4_bar-24px.svg" + serverSyncedStatusIcon.iconColor = Theme.statusbarDisconnectedTorFontColor + serverSyncedStatusIcon.source = gcd.assetPath + "core/syncing-03.svg" + } + } + } + + onSupplyServerSettings: function(server, key_names, keys) { + gsp.serverName = server; + toolbar.setTitle(qsTr("server-settings")); + console.log("Servers: " + key_names); + for (let i=0; i Date: Mon, 21 Sep 2020 16:49:24 -0700 Subject: [PATCH 2/2] Using connectivity NoTorrcErr typed error and stubbing torrc --- go.mod | 5 +++-- go.sum | 2 ++ main.go | 13 +++++++++++++ 3 files changed, 18 insertions(+), 2 deletions(-) diff --git a/go.mod b/go.mod index 2aba8d3d..84c19a07 100644 --- a/go.mod +++ b/go.mod @@ -4,7 +4,7 @@ go 1.12 require ( cwtch.im/cwtch v0.3.16 - git.openprivacy.ca/openprivacy/connectivity v1.2.0 + git.openprivacy.ca/openprivacy/connectivity v1.2.1 git.openprivacy.ca/openprivacy/log v1.0.1 github.com/gopherjs/gopherjs v0.0.0-20200209183636-89e6cbcd0b6d // indirect github.com/therecipe/qt v0.0.0-20200126204426-5074eb6d8c41 @@ -13,4 +13,5 @@ require ( golang.org/x/crypto v0.0.0-20200420104511-884d27f42877 // indirect ) -replace cwtch.im/cwtch => /home/sarah/workspace/src/cwtch.im/cwtch + +replace cwtch.im/cwtch => /home/dan/src/go/src/cwtch.im/cwtch diff --git a/go.sum b/go.sum index b6fa1c25..ed5b7bcb 100644 --- a/go.sum +++ b/go.sum @@ -27,6 +27,8 @@ git.openprivacy.ca/openprivacy/connectivity v1.1.4 h1:/I9epvNNjM8rR/q5y9Y63D9/aP git.openprivacy.ca/openprivacy/connectivity v1.1.4/go.mod h1:4P8mirZZslKbo2zBrXXVjgEdqGwHo/6qoFBwFQW6d6E= git.openprivacy.ca/openprivacy/connectivity v1.2.0 h1:dbZ5CRl11vg3BNHdzRKSlDP8OUtDB+mf6FkxMVf73qw= git.openprivacy.ca/openprivacy/connectivity v1.2.0/go.mod h1:B7vzuVmChJtSKoh0ezph5vu6DQ0gIk0zHUNG6IgXCcA= +git.openprivacy.ca/openprivacy/connectivity v1.2.1 h1:oRL56TR9ZQnKkGkTIQ9wYbJ2IkOOsi/zLYExYiAS+sE= +git.openprivacy.ca/openprivacy/connectivity v1.2.1/go.mod h1:B7vzuVmChJtSKoh0ezph5vu6DQ0gIk0zHUNG6IgXCcA= git.openprivacy.ca/openprivacy/libricochet-go v1.0.11 h1:C7QFFzG0p5XKu0zcOIdLGwEpA9uU0BceBM7CfVK5D40= git.openprivacy.ca/openprivacy/libricochet-go v1.0.11/go.mod h1:yTMps/ZpYS+BNBBvANsNAft28FXrBvFHQauMYNWPrwE= git.openprivacy.ca/openprivacy/libricochet-go v1.0.13 h1:Z86uL9K47onznY1wP1P/wWfWMbbyvk6xnCp94R180os= diff --git a/main.go b/main.go index 857150d0..77046c17 100644 --- a/main.go +++ b/main.go @@ -8,6 +8,7 @@ import ( "cwtch.im/ui/go/ui" "cwtch.im/ui/go/ui/android" "flag" + "fmt" "git.openprivacy.ca/openprivacy/connectivity/tor" "git.openprivacy.ca/openprivacy/log" "github.com/therecipe/qt/androidextras" @@ -16,6 +17,8 @@ import ( "github.com/therecipe/qt/network" "github.com/therecipe/qt/qml" "github.com/therecipe/qt/quickcontrols2" + "io/ioutil" + "math/rand" "os" "os/user" "path" @@ -233,6 +236,16 @@ func loadACN() { } var err error the.ACN, err = tor.NewTorACN(the.CwtchDir, torpath) + if _, ok := err.(*tor.NoTorrcError); ok { + // Stopgap: just dump a basic torrc for now + port := rand.Intn(1000) + 9600 + controlPort := port + 1 + + ioutil.WriteFile(path.Join(the.CwtchDir, "tor", "torrc"), []byte(fmt.Sprintf(`SOCKSPort %v \ +ControlPort %v`, port, controlPort)), 0600) + + the.ACN, err = tor.NewTorACNWithAuth(the.CwtchDir, torpath, controlPort, tor.NullAuthenticator{}) + } if err != nil { // TODO: turn into UI error: status panel? log.Errorf("Could not start Tor: %v", err) -- 2.25.1