From 0102abeec1d2055b19dccbb7edc7f06e527642b1 Mon Sep 17 00:00:00 2001 From: fiaxh Date: Sun, 29 Oct 2017 15:15:28 +0100 Subject: Fix warnings --- plugins/openpgp/src/manager.vala | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) (limited to 'plugins/openpgp/src/manager.vala') diff --git a/plugins/openpgp/src/manager.vala b/plugins/openpgp/src/manager.vala index 74f6027c..3f0fe3dd 100644 --- a/plugins/openpgp/src/manager.vala +++ b/plugins/openpgp/src/manager.vala @@ -30,7 +30,7 @@ public class Manager : StreamInteractionModule, Object { stream_interactor.get_module(MessageProcessor.IDENTITY).pre_message_send.connect(check_encypt); } - public GPG.Key[] get_key_fprs(Conversation conversation) { + public GPG.Key[] get_key_fprs(Conversation conversation) throws Error { Gee.List keys = new Gee.ArrayList(); keys.add(db.get_account_key(conversation.account)); if (conversation.type_ == Conversation.Type.GROUPCHAT) { @@ -70,13 +70,17 @@ public class Manager : StreamInteractionModule, Object { } private void check_encypt(Entities.Message message, Xmpp.Message.Stanza message_stanza, Conversation conversation) { - if (message.encryption == Encryption.PGP) { - GPG.Key[] keys = get_key_fprs(conversation); - Core.XmppStream? stream = stream_interactor.get_stream(conversation.account); - if (stream != null) { - bool encrypted = stream.get_module(Module.IDENTITY).encrypt(message_stanza, keys); - if (!encrypted) message.marked = Entities.Message.Marked.WONTSEND; + try { + if (message.encryption == Encryption.PGP) { + GPG.Key[] keys = get_key_fprs(conversation); + Core.XmppStream? stream = stream_interactor.get_stream(conversation.account); + if (stream != null) { + bool encrypted = stream.get_module(Module.IDENTITY).encrypt(message_stanza, keys); + if (!encrypted) message.marked = Entities.Message.Marked.WONTSEND; + } } + } catch (Error e) { + message.marked = Entities.Message.Marked.WONTSEND; } } -- cgit v1.2.3-70-g09d2