diff --git a/go/characters/appEventListener.go b/go/characters/appEventListener.go index 13d7458d..e9d9d65b 100644 --- a/go/characters/appEventListener.go +++ b/go/characters/appEventListener.go @@ -90,6 +90,7 @@ func AppEventListener(gcd *gothings.GrandCentralDispatcher, subscribed chan bool DisplayName: displayName, Image: cwutil.RandomProfileImage(contacts[i]), Trusted: contact.Trusted, + Blocked: contact.Blocked, Loading: false, }) } diff --git a/go/characters/presencepoller.go b/go/characters/presencepoller.go index 62fedaf5..a4c26bfb 100644 --- a/go/characters/presencepoller.go +++ b/go/characters/presencepoller.go @@ -29,6 +29,7 @@ func PresencePoller(uiState *gothings.InterfaceState) { 0, 0, c.Trusted, + c.Blocked, false, }) diff --git a/go/gobjects/contact.go b/go/gobjects/contact.go index 6493f19c..c038c1de 100644 --- a/go/gobjects/contact.go +++ b/go/gobjects/contact.go @@ -8,5 +8,6 @@ type Contact struct { Badge int Status int Trusted bool + Blocked bool Loading bool } diff --git a/go/gothings/gcd.go b/go/gothings/gcd.go index 29e38e1f..233a3513 100644 --- a/go/gothings/gcd.go +++ b/go/gothings/gcd.go @@ -30,8 +30,8 @@ type GrandCentralDispatcher struct { _ string `property:"buildDate"` // contact list stuff - _ func(handle, displayName, image, server string, badge, status int, trusted bool, loading bool) `signal:"AddContact"` - _ func(handle, displayName, image, server string, badge, status int, trusted bool, loading bool) `signal:"UpdateContact"` + _ func(handle, displayName, image, server string, badge, status int, trusted bool, blocked bool, loading bool) `signal:"AddContact"` + _ func(handle, displayName, image, server string, badge, status int, trusted bool, blocked bool, loading bool) `signal:"UpdateContact"` _ func(handle, key, value string) `signal:"UpdateContactAttribute"` // messages pane stuff @@ -56,6 +56,7 @@ type GrandCentralDispatcher struct { // signals emitted from the ui (written in go, below) _ func(message string, mid string) `signal:"sendMessage,auto"` + _ func(onion string) `signal:"blockPeer,auto"` _ func(onion string) `signal:"loadMessagesPane,auto"` _ func(signal string) `signal:"broadcast,auto"` // convenience relay signal _ func(str string) `signal:"importString,auto"` @@ -170,6 +171,7 @@ func (this *GrandCentralDispatcher) loadMessagesPaneHelper(handle string) { 0, false, false, + false, }) } else { c.Badge = 0 @@ -481,6 +483,15 @@ func (this *GrandCentralDispatcher) createGroup(server, groupName string) { the.Peer.JoinServer(server) } + +func (this *GrandCentralDispatcher) blockPeer(onion string) { + err := the.Peer.BlockPeer(onion) + if err != nil { + this.InvokePopup("Error Blocking Peer: " + err.Error()) + } + this.UIState.UpdateContact(onion) +} + func (this *GrandCentralDispatcher) inviteToGroup(onion, groupID string) { err := the.Peer.InviteOnionToGroup(onion, groupID) if err != nil { diff --git a/go/gothings/uistate.go b/go/gothings/uistate.go index 61581b8e..d4c803c9 100644 --- a/go/gothings/uistate.go +++ b/go/gothings/uistate.go @@ -29,7 +29,7 @@ func (this *InterfaceState) Acknowledge(mID string) { func (this *InterfaceState) AddContact(c *gobjects.Contact) { if len(c.Handle) == 32 { // ADD GROUP if _, found := this.contacts.Load(c.Handle); !found { - this.parentGcd.AddContact(c.Handle, c.DisplayName, c.Image, c.Server, c.Badge, c.Status, c.Trusted, c.Loading) + this.parentGcd.AddContact(c.Handle, c.DisplayName, c.Image, c.Server, c.Badge, c.Status, c.Trusted, c.Blocked, c.Loading) this.contacts.Store(c.Handle, c) } return @@ -41,7 +41,7 @@ func (this *InterfaceState) AddContact(c *gobjects.Contact) { if _, found := this.contacts.Load(c.Handle); !found { this.contacts.Store(c.Handle, c) - this.parentGcd.AddContact(c.Handle, c.DisplayName, c.Image, c.Server, c.Badge, c.Status, c.Trusted, false) + this.parentGcd.AddContact(c.Handle, c.DisplayName, c.Image, c.Server, c.Badge, c.Status, c.Trusted, c.Blocked, false) if the.Peer.GetContact(c.Handle) == nil { the.Peer.AddContact(c.DisplayName, c.Handle, c.Trusted) go the.Peer.PeerWithOnion(c.Handle) @@ -67,6 +67,7 @@ func (this *InterfaceState) GetContact(handle string) *gobjects.Contact { 0, group.Accepted, false, + false, }) } else { log.Errorf("Attempting to add non existent group to ui %v", handle) @@ -86,6 +87,7 @@ func (this *InterfaceState) GetContact(handle string) *gobjects.Contact { 0, 0, false, + contact.Blocked, false, }) } else if contact == nil { @@ -167,10 +169,14 @@ func (this *InterfaceState) GetMessages(handle string) []*gobjects.Message { } func (this *InterfaceState) UpdateContact(handle string) { - cif, found := this.contacts.Load(handle) - if found { - c := cif.(*gobjects.Contact) - this.parentGcd.UpdateContact(c.Handle, c.DisplayName, c.Image, c.Server, c.Badge, c.Status, c.Trusted, c.Loading) + contact := the.Peer.GetContact(handle) + if contact != nil { + cif, found := this.contacts.Load(handle) + if found { + c := cif.(*gobjects.Contact) + c.Blocked = contact.Blocked + this.parentGcd.UpdateContact(c.Handle, c.DisplayName, c.Image, c.Server, c.Badge, c.Status, c.Trusted, c.Blocked, c.Loading) + } } } diff --git a/i18n/translation_de.ts b/i18n/translation_de.ts index 8ade7ff3..6de5c10c 100644 --- a/i18n/translation_de.ts +++ b/i18n/translation_de.ts @@ -4,30 +4,30 @@ AddGroupPane - + create-group-title Gruppe Anlegen - + server-label Server label Server - + group-name-label Group name label Gruppenname - + default-group-name default suggested group name Tolle Gruppe - + create-group-btn create group button Anlegen @@ -36,18 +36,18 @@ BulletinOverlay - + new-bulletin-label Neue Meldung - + post-new-bulletin-label Post a new Bulletin Post Neue Meldung veröffentlichen - + title-placeholder title place holder text Titel... @@ -56,44 +56,44 @@ GroupSettingsPane - + server-label Server - - + + copy-btn Kopieren - + invitation-label Einladung - + group-name-label Gruppenname - + save-btn Speichern - + invite-to-group-label Invite someone to the group In die Gruppe einladen - + invite-btn Einladen - + delete-btn Löschen @@ -101,19 +101,19 @@ ListOverlay - + add-list-item Add a New List Item Liste hinzufügen - + add-new-item Add a new item to the list Neues Listenelement hinzüfgen - + todo-placeholder Todo... placeholder text noch zu erledigen @@ -131,24 +131,24 @@ Message - + dm-tooltip Click to DM Klicken, um DM zu senden - + could-not-send-msg-error Could not send this message Nachricht konnte nicht gesendet werden - + acknowledged-label bestätigt - + pending-label Bestätigung ausstehend @@ -224,33 +224,38 @@ PeerSettingsPane - + address-label Adresse - + copy-btn Kopieren - + copied-to-clipboard-notification notification: copied to clipboard in die Zwischenablage kopiert - + display-name-label Angezeigter Name - + save-btn speichern - + + block-btn + + + + delete-btn löschen @@ -258,36 +263,36 @@ SettingsPane - + cwtch-settings-title Cwtch Settings title Cwtch Einstellungen - + version %1 builddate %2 Version: %1 Built on: %2 - + zoom-label Interface zoom (mostly affects text and button sizes) Benutzeroberflächen-Zoom (betriftt hauptsächlich Text- und Knopgrößen) - + large-text-label Groß - + default-scaling-text "Default size text (scale factor: " defaultmäßige Textgröße (Skalierungsfaktor: - + small-text-label Klein diff --git a/i18n/translation_en.qm b/i18n/translation_en.qm index fc7c40a8..59f64a74 100644 Binary files a/i18n/translation_en.qm and b/i18n/translation_en.qm differ diff --git a/i18n/translation_en.ts b/i18n/translation_en.ts index 71ea1465..38547850 100644 --- a/i18n/translation_en.ts +++ b/i18n/translation_en.ts @@ -4,30 +4,30 @@ AddGroupPane - + create-group-title Create Group - + server-label Server label Server - + group-name-label Group name label Group name - + default-group-name default suggested group name Awesome Group - + create-group-btn create group button Create @@ -36,18 +36,18 @@ BulletinOverlay - + new-bulletin-label New Bulletin - + post-new-bulletin-label Post a new Bulletin Post Post new bulletin - + title-placeholder title place holder text title... @@ -56,44 +56,44 @@ GroupSettingsPane - + server-label Server - - + + copy-btn Copy - + invitation-label Invitation - + group-name-label Group Name - + save-btn Save - + invite-to-group-label Invite someone to the group Invite to group - + invite-btn Invite - + delete-btn Delete @@ -101,19 +101,19 @@ ListOverlay - + add-list-item Add a New List Item Add a New List Item - + add-new-item Add a new item to the list Add a new item to the list - + todo-placeholder Todo... placeholder text Todo... @@ -131,24 +131,24 @@ Message - + dm-tooltip Click to DM Click to DM - + could-not-send-msg-error Could not send this message Could not send this message - + acknowledged-label Acknowledged - + pending-label Pending @@ -224,33 +224,38 @@ PeerSettingsPane - + address-label Address - + copy-btn Copy - + copied-to-clipboard-notification notification: copied to clipboard Copied to Clipboard - + display-name-label Display Name - + save-btn Save - + + block-btn + Block Peer + + + delete-btn Delete @@ -258,36 +263,36 @@ SettingsPane - + cwtch-settings-title Cwtch Settings title Cwtch Settings - + version %1 builddate %2 Version: %1 Built on: %2 Version: %1 Built on: %2 - + zoom-label Interface zoom (mostly affects text and button sizes) Interface zoom (mostly affects text and button sizes) - + large-text-label Large - + default-scaling-text "Default size text (scale factor: " Default size text (scale factor: - + small-text-label Small diff --git a/i18n/translation_fr.ts b/i18n/translation_fr.ts index 96597e65..38d59aa3 100644 --- a/i18n/translation_fr.ts +++ b/i18n/translation_fr.ts @@ -4,30 +4,30 @@ AddGroupPane - + create-group-title Créer un groupe - + server-label Server label Serveur - + group-name-label Group name label Groupe - + default-group-name default suggested group name Un super groupe - + create-group-btn create group button Créer @@ -36,18 +36,18 @@ BulletinOverlay - + new-bulletin-label Nouveau bulletin - + post-new-bulletin-label Post a new Bulletin Post Envoyer un nouveau bulletin - + title-placeholder title place holder text titre... @@ -56,44 +56,44 @@ GroupSettingsPane - + server-label Serveur - - + + copy-btn Copier - + invitation-label Invitation - + group-name-label Nom du groupe - + save-btn Sauvegarder - + invite-to-group-label Invite someone to the group Inviter quelqu'un - + invite-btn Invitation - + delete-btn Effacer @@ -101,19 +101,19 @@ ListOverlay - + add-list-item Add a New List Item Ajouter un nouvel élément - + add-new-item Add a new item to the list Ajouter un nouvel élément à la liste - + todo-placeholder Todo... placeholder text A faire... @@ -131,24 +131,24 @@ Message - + dm-tooltip Click to DM Envoyer un message privé - + could-not-send-msg-error Could not send this message Impossible d'envoyer ce message - + acknowledged-label Confirmé - + pending-label En attente @@ -224,33 +224,38 @@ PeerSettingsPane - + address-label Adresse - + copy-btn Copier - + copied-to-clipboard-notification notification: copied to clipboard Copié dans le presse-papier - + display-name-label Pseudo - + save-btn Sauvegarder - + + block-btn + + + + delete-btn Effacer @@ -258,36 +263,36 @@ SettingsPane - + cwtch-settings-title Cwtch Settings title Préférences Cwtch - + version %1 builddate %2 Version: %1 Built on: %2 - + zoom-label Interface zoom (mostly affects text and button sizes) Interface zoom (essentiellement la taille du texte et des composants de l'interface) - + large-text-label Large - + default-scaling-text "Default size text (scale factor: " Taille par défaut du texte (échelle: - + small-text-label Petit diff --git a/i18n/translation_pt.ts b/i18n/translation_pt.ts index cb7f4574..db0542ef 100644 --- a/i18n/translation_pt.ts +++ b/i18n/translation_pt.ts @@ -4,30 +4,30 @@ AddGroupPane - + create-group-title Criar Grupo - + server-label Server label Servidor - + group-name-label Group name label Nome do grupo - + default-group-name default suggested group name Grupo incrível - + create-group-btn create group button Criar @@ -36,18 +36,18 @@ BulletinOverlay - + new-bulletin-label Novo Boletim - + post-new-bulletin-label Post a new Bulletin Post Postar novo boletim - + title-placeholder title place holder text título… @@ -56,44 +56,44 @@ GroupSettingsPane - + server-label Servidor - - + + copy-btn Copiar - + invitation-label Convite - + group-name-label Nome do Grupo - + save-btn Salvar - + invite-to-group-label Invite someone to the group Convidar ao grupo - + invite-btn Convidar - + delete-btn Deletar @@ -101,19 +101,19 @@ ListOverlay - + add-list-item Add a New List Item Adicionar Item à Lista - + add-new-item Add a new item to the list Adicionar novo item à lista - + todo-placeholder Todo... placeholder text Afazer… @@ -131,24 +131,24 @@ Message - + dm-tooltip Click to DM Clique para DM - + could-not-send-msg-error Could not send this message Não deu para enviar esta mensagem - + acknowledged-label Confirmada - + pending-label Pendente @@ -224,33 +224,38 @@ PeerSettingsPane - + address-label Endereço - + copy-btn Copiar - + copied-to-clipboard-notification notification: copied to clipboard Copiado - + display-name-label Nome de Exibição - + save-btn Salvar - + + block-btn + + + + delete-btn Deletar @@ -258,36 +263,36 @@ SettingsPane - + cwtch-settings-title Cwtch Settings title Configurações do Cwtch - + version %1 builddate %2 Version: %1 Built on: %2 - + zoom-label Interface zoom (mostly affects text and button sizes) Zoom da interface (afeta principalmente tamanho de texto e botões) - + large-text-label Grande - + default-scaling-text "Default size text (scale factor: " Texto tamanho padrão (fator de escala: - + small-text-label Pequeno diff --git a/qml/overlays/MembershipOverlay.qml b/qml/overlays/MembershipOverlay.qml index d24f5d32..d35caef8 100644 --- a/qml/overlays/MembershipOverlay.qml +++ b/qml/overlays/MembershipOverlay.qml @@ -106,6 +106,7 @@ ColumnLayout { displayName: _displayName image: _image trusted: true + blocked: false background: false } } diff --git a/qml/panes/PeerSettingsPane.qml b/qml/panes/PeerSettingsPane.qml index 307c90f9..b2e37023 100644 --- a/qml/panes/PeerSettingsPane.qml +++ b/qml/panes/PeerSettingsPane.qml @@ -79,6 +79,16 @@ ColumnLayout { // peerSettingsPane } } + + SimpleButton { + icon: "solid/hand-paper" + text: qsTr("block-btn") + + onClicked: { + gcd.blockPeer(txtOnion.text) + } + } + SimpleButton { icon: "regular/trash-alt" text: qsTr("delete-btn") diff --git a/qml/widgets/ContactList.qml b/qml/widgets/ContactList.qml index 3f37a053..3ba74972 100644 --- a/qml/widgets/ContactList.qml +++ b/qml/widgets/ContactList.qml @@ -47,17 +47,18 @@ ColumnLayout { Connections { // ADD/REMOVE CONTACT ENTRIES target: gcd - onAddContact: function(handle, displayName, image, server, badge, status, trusted, loading) { + onAddContact: function(handle, displayName, image, server, badge, status, trusted, blocked, loading) { contactsModel.append({ "_handle": handle, - "_displayName": displayName, + "_displayName": displayName + (blocked ? " (blocked)" : "" ), "_image": image, "_server": server, "_badge": badge, "_status": status, "_trusted": trusted, "_deleted": false, - "_loading": loading + "_loading": loading, + "_blocked": blocked }) } @@ -88,6 +89,7 @@ ColumnLayout { badge: _badge status: _status trusted: _trusted + blocked: _blocked deleted: _deleted loading: _loading } diff --git a/qml/widgets/ContactRow.qml b/qml/widgets/ContactRow.qml index a1075644..4a2606d6 100644 --- a/qml/widgets/ContactRow.qml +++ b/qml/widgets/ContactRow.qml @@ -24,6 +24,7 @@ Item { // LOTS OF NESTING TO DEAL WITH QT WEIRDNESS, SORRY property bool isActive property bool isHover property bool trusted + property bool blocked property bool deleted property bool loading property alias status: imgProfile.status @@ -54,6 +55,7 @@ Item { // LOTS OF NESTING TO DEAL WITH QT WEIRDNESS, SORRY anchors.verticalCenter: parent.verticalCenter font.pixelSize: 16 * gcd.themeScale font.italic: !trusted + font.strikeout: blocked textFormat: Text.PlainText //fontSizeMode: Text.HorizontalFit elide: Text.ElideRight @@ -143,16 +145,18 @@ Item { // LOTS OF NESTING TO DEAL WITH QT WEIRDNESS, SORRY isActive = false } - onUpdateContact: function(_handle, _displayName, _image, _server, _badge, _status, _trusted, _loading) { + onUpdateContact: function(_handle, _displayName, _image, _server, _badge, _status, _trusted, _blocked, _loading) { if (handle == _handle) { - displayName = _displayName + displayName = _displayName + (_blocked == true ? " (blocked)" : "") image = _image server = _server badge = _badge status = _status trusted = _trusted + blocked = _blocked loading = _loading + if (loading == true) { loadingProgress.visible = true loadingProgress.running = true