aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--main/src/ui/chat_input/chat_input_controller.vala6
-rw-r--r--plugins/openpgp/src/account_settings_entry.vala16
-rw-r--r--plugins/openpgp/src/encryption_list_entry.vala9
-rw-r--r--plugins/openpgp/src/gpgme_helper.vala8
4 files changed, 35 insertions, 4 deletions
diff --git a/main/src/ui/chat_input/chat_input_controller.vala b/main/src/ui/chat_input/chat_input_controller.vala
index d1c42d35..025834d6 100644
--- a/main/src/ui/chat_input/chat_input_controller.vala
+++ b/main/src/ui/chat_input/chat_input_controller.vala
@@ -25,6 +25,7 @@ public class ChatInputController : Object {
private ChatTextViewController chat_text_view_controller;
private ContentItem? quoted_content_item = null;
+ private Encryption encryption;
public ChatInputController(ChatInput.View chat_input, StreamInteractor stream_interactor) {
this.chat_input = chat_input;
@@ -102,7 +103,7 @@ public class ChatInputController : Object {
private void on_encryption_changed(Encryption encryption) {
reset_input_field_status();
-
+ this.encryption = encryption;
if (encryption == Encryption.NONE) return;
Application app = GLib.Application.get_default() as Application;
@@ -127,6 +128,9 @@ public class ChatInputController : Object {
}
private void send_text() {
+ // Double check GPG keys before sending in case of expired / revoked keys while Dino is in use
+ if (this.encryption == Encryption.PGP) on_encryption_changed(this.encryption);
+
// Don't do anything if we're in a NO_SEND state. Don't clear the chat input, don't send.
if (input_field_status.input_state == Plugins.InputFieldStatus.InputState.NO_SEND) {
chat_input.highlight_state_description();
diff --git a/plugins/openpgp/src/account_settings_entry.vala b/plugins/openpgp/src/account_settings_entry.vala
index 7c99942f..0e28c68e 100644
--- a/plugins/openpgp/src/account_settings_entry.vala
+++ b/plugins/openpgp/src/account_settings_entry.vala
@@ -69,7 +69,7 @@ public class AccountSettingsEntry : Plugins.AccountSettingsEntry {
return;
}
if (keys.size == 0) {
- label.set_markup(build_markup_string(_("Key publishing disabled"), _("No keys available. Generate one!")));
+ label.set_markup(build_markup_string(_("Key publishing disabled"), _("No keys available. Generate one or check if your keys aren't expired or revoked!")));
return;
}
@@ -88,6 +88,18 @@ public class AccountSettingsEntry : Plugins.AccountSettingsEntry {
set_label_active(selected);
combobox.changed.connect(key_changed);
+ if (account_key != null){
+ try {
+ GPG.Key key_check = GPGHelper.get_public_key(account_key);
+ if(key_check.expired || key_check.revoked) {
+ string status_str = key_check.expired ? _("expired!") : _("revoked!");
+ label.set_markup(build_markup_string(_("Attention required!"), _("Your key <span color='red'><b>"+ key_check.fpr +"</b></span> is " + status_str)));
+ }
+ }
+ catch {
+ debug("Coudn't check GPG key status.");
+ }
+ }
}
private void populate_list_store() {
@@ -160,4 +172,4 @@ public class AccountSettingsEntry : Plugins.AccountSettingsEntry {
return stack;
}
}
-} \ No newline at end of file
+}
diff --git a/plugins/openpgp/src/encryption_list_entry.vala b/plugins/openpgp/src/encryption_list_entry.vala
index cf5da8c4..5e61df8d 100644
--- a/plugins/openpgp/src/encryption_list_entry.vala
+++ b/plugins/openpgp/src/encryption_list_entry.vala
@@ -32,6 +32,7 @@ private class EncryptionListEntry : Plugins.EncryptionListEntry, Object {
return null;
}
+
public void encryption_activated(Entities.Conversation conversation, Plugins.SetInputFieldStatus input_status_callback) {
try {
GPGHelper.get_public_key(db.get_account_key(conversation.account) ?? "");
@@ -40,6 +41,14 @@ private class EncryptionListEntry : Plugins.EncryptionListEntry, Object {
return;
}
+ GPG.Key key_check = GPGHelper.get_public_key(db.get_account_key(conversation.account));
+ if (key_check.expired || key_check.revoked){
+ string status_str = key_check.expired ? " has expired." : " has been revoked.";
+ debug("GPG public key %s is NOT fine for encryption: it %s.\n", key_check.fpr, status_str);
+ input_status_callback(new Plugins.InputFieldStatus("Your GPG key " + key_check.fpr + status_str, Plugins.InputFieldStatus.MessageType.ERROR, Plugins.InputFieldStatus.InputState.NO_SEND));
+ return;
+ }
+
if (conversation.type_ == Conversation.Type.CHAT) {
string? key_id = stream_interactor.get_module(Manager.IDENTITY).get_key_id(conversation.account, conversation.counterpart);
if (key_id == null) {
diff --git a/plugins/openpgp/src/gpgme_helper.vala b/plugins/openpgp/src/gpgme_helper.vala
index 18d07c06..c53437d3 100644
--- a/plugins/openpgp/src/gpgme_helper.vala
+++ b/plugins/openpgp/src/gpgme_helper.vala
@@ -112,7 +112,13 @@ public static Gee.List<Key> get_keylist(string? pattern = null, bool secret_only
try {
while (true) {
Key key = context.op_keylist_next();
- keys.add(key);
+ if (!key.expired && !key.revoked){
+ debug("PGP Key " + key.fpr + " is valid!");
+ keys.add(key);
+ }
+ else {
+ debug("PGP Key " + key.fpr + " is either expired or revoked!");
+ }
}
} catch (Error e) {
if (e.code != GPGError.ErrorCode.EOF) throw e;