aboutsummaryrefslogtreecommitdiff
path: root/plugins
diff options
context:
space:
mode:
Diffstat (limited to 'plugins')
-rw-r--r--plugins/gpgme-vala/vapi/gpgme.vapi2
-rw-r--r--plugins/http-files/src/file_provider.vala8
-rw-r--r--plugins/http-files/src/upload_stream_module.vala8
-rw-r--r--plugins/omemo/src/account_settings_dialog.vala3
-rw-r--r--plugins/omemo/src/database.vala4
-rw-r--r--plugins/openpgp/src/contact_details_provider.vala7
-rw-r--r--plugins/openpgp/src/encryption_list_entry.vala4
-rw-r--r--plugins/openpgp/src/in_file_processor.vala28
-rw-r--r--plugins/openpgp/src/manager.vala18
-rw-r--r--plugins/openpgp/src/out_file_processor.vala14
10 files changed, 62 insertions, 34 deletions
diff --git a/plugins/gpgme-vala/vapi/gpgme.vapi b/plugins/gpgme-vala/vapi/gpgme.vapi
index 51823a15..55031bfa 100644
--- a/plugins/gpgme-vala/vapi/gpgme.vapi
+++ b/plugins/gpgme-vala/vapi/gpgme.vapi
@@ -466,7 +466,7 @@ namespace GPG {
[CCode (cname = "gpgme_data_new_from_file")]
public static GPGError.Error new_from_file(out Data d, string filename, int copy = 1);
- public static Data create_from_file(string filename, int copy = 1) {
+ public static Data create_from_file(string filename, int copy = 1) throws GLib.Error {
Data data;
throw_if_error(new_from_file(out data, filename, copy));
return data;
diff --git a/plugins/http-files/src/file_provider.vala b/plugins/http-files/src/file_provider.vala
index 9e677a92..53fe3bb0 100644
--- a/plugins/http-files/src/file_provider.vala
+++ b/plugins/http-files/src/file_provider.vala
@@ -48,8 +48,13 @@ public class FileProvider : Dino.FileProvider, Object {
if (name == "Content-Length") content_length = val;
});
if (/*content_type != null && content_type.has_prefix("image") &&*/ content_length != null && int.parse(content_length) < 5000000) {
- Soup.Request request = session.request (message.body);
FileTransfer file_transfer = new FileTransfer();
+ try {
+ Soup.Request request = session.request(message.body);
+ file_transfer.input_stream = request.send();
+ } catch (Error e) {
+ return;
+ }
file_transfer.account = conversation.account;
file_transfer.counterpart = message.counterpart;
file_transfer.ourpart = message.ourpart;
@@ -57,7 +62,6 @@ public class FileProvider : Dino.FileProvider, Object {
file_transfer.time = message.time;
file_transfer.local_time = message.local_time;
file_transfer.direction = message.direction;
- file_transfer.input_stream = request.send();
file_transfer.file_name = message.body.substring(message.body.last_index_of("/") + 1);
file_transfer.mime_type = content_type;
file_transfer.size = int.parse(content_length);
diff --git a/plugins/http-files/src/upload_stream_module.vala b/plugins/http-files/src/upload_stream_module.vala
index ee70e49d..08e6105f 100644
--- a/plugins/http-files/src/upload_stream_module.vala
+++ b/plugins/http-files/src/upload_stream_module.vala
@@ -21,7 +21,11 @@ public class UploadStreamModule : XmppStreamModule {
Array<uint8> data = new Array<uint8>(false, true, 0);
size_t len = -1;
do {
- len = input_stream.read(buf);
+ try {
+ len = input_stream.read(buf);
+ } catch (IOError error) {
+ error_listener(stream, @"HTTP upload: IOError reading stream: $(error.message)");
+ }
data.append_vals(buf, (uint) len);
} while(len > 0);
@@ -41,7 +45,7 @@ public class UploadStreamModule : XmppStreamModule {
}
});
},
- error_listener);
+ (stream, error) => error_listener(stream, error));
}
private delegate void OnSlotOk(XmppStream stream, string url_get, string url_put);
diff --git a/plugins/omemo/src/account_settings_dialog.vala b/plugins/omemo/src/account_settings_dialog.vala
index 373d02aa..4a63ef2f 100644
--- a/plugins/omemo/src/account_settings_dialog.vala
+++ b/plugins/omemo/src/account_settings_dialog.vala
@@ -17,6 +17,7 @@ public class AccountSettingsDialog : Gtk.Dialog {
public AccountSettingsDialog(Plugin plugin, Account account) {
Object(use_header_bar : 1);
this.plugin = plugin;
+ this.account = account;
string own_b64 = plugin.db.identity.row_with(plugin.db.identity.account_id, account.id)[plugin.db.identity.identity_key_public_base64];
fingerprint = fingerprint_from_base64(own_b64);
@@ -50,4 +51,4 @@ public class AccountSettingsDialog : Gtk.Dialog {
}
-} \ No newline at end of file
+}
diff --git a/plugins/omemo/src/database.vala b/plugins/omemo/src/database.vala
index 52a1b15d..5c7309f3 100644
--- a/plugins/omemo/src/database.vala
+++ b/plugins/omemo/src/database.vala
@@ -116,7 +116,9 @@ public class Database : Qlite.Database {
pre_key = new PreKeyTable(this);
session = new SessionTable(this);
init({identity_meta, identity, signed_pre_key, pre_key, session});
- exec("PRAGMA synchronous=0");
+ try {
+ exec("PRAGMA synchronous=0");
+ } catch (Error e) { }
}
public override void migrate(long oldVersion) {
diff --git a/plugins/openpgp/src/contact_details_provider.vala b/plugins/openpgp/src/contact_details_provider.vala
index 5529549c..b691cc19 100644
--- a/plugins/openpgp/src/contact_details_provider.vala
+++ b/plugins/openpgp/src/contact_details_provider.vala
@@ -18,8 +18,11 @@ public class ContactDetailsProvider : Plugins.ContactDetailsProvider, Object {
string? key_id = stream_interactor.get_module(Manager.IDENTITY).get_key_id(conversation.account, conversation.counterpart);
if (key_id != null) {
Label label = new Label("") { use_markup=true, justify=Justification.RIGHT, selectable=true, visible=true };
- Gee.List<GPG.Key> keys = GPGHelper.get_keylist(key_id);
- if (keys.size > 0) {
+ Gee.List<GPG.Key>? keys = null;
+ try {
+ keys = GPGHelper.get_keylist(key_id);
+ } catch (Error e) { }
+ if (keys != null && keys.size > 0) {
label.label = markup_colorize_id(keys[0].fpr, true);
} else {
label.label = _("Key not in keychain") + "\n" + markup_colorize_id(key_id, false);
diff --git a/plugins/openpgp/src/encryption_list_entry.vala b/plugins/openpgp/src/encryption_list_entry.vala
index e0a11865..d2cbd13f 100644
--- a/plugins/openpgp/src/encryption_list_entry.vala
+++ b/plugins/openpgp/src/encryption_list_entry.vala
@@ -23,7 +23,9 @@ private class EncryptionListEntry : Plugins.EncryptionListEntry, Object {
public bool can_encrypt(Entities.Conversation conversation) {
if (conversation.type_ == Conversation.Type.CHAT) {
string? key_id = stream_interactor.get_module(Manager.IDENTITY).get_key_id(conversation.account, conversation.counterpart);
- return key_id != null && GPGHelper.get_keylist(key_id).size > 0;
+ try {
+ return key_id != null && GPGHelper.get_keylist(key_id).size > 0;
+ } catch (Error e) { return false; }
} else if (conversation.type_ == Conversation.Type.GROUPCHAT) {
Gee.List<Jid> muc_jids = new Gee.ArrayList<Jid>();
Gee.List<Jid>? occupants = stream_interactor.get_module(MucManager.IDENTITY).get_occupants(conversation.counterpart, conversation.account);
diff --git a/plugins/openpgp/src/in_file_processor.vala b/plugins/openpgp/src/in_file_processor.vala
index 2a06bbdf..61baa37e 100644
--- a/plugins/openpgp/src/in_file_processor.vala
+++ b/plugins/openpgp/src/in_file_processor.vala
@@ -8,19 +8,23 @@ public class InFileProcessor : IncommingFileProcessor, Object {
}
public void process(FileTransfer file_transfer) {
- uint8[] buf = new uint8[256];
- Array<uint8> data = new Array<uint8>(false, true, 0);
- size_t len = -1;
- do {
- len = file_transfer.input_stream.read(buf);
- data.append_vals(buf, (uint) len);
- } while(len > 0);
+ try {
+ uint8[] buf = new uint8[256];
+ Array<uint8> data = new Array<uint8>(false, true, 0);
+ size_t len = -1;
+ do {
+ len = file_transfer.input_stream.read(buf);
+ data.append_vals(buf, (uint) len);
+ } while(len > 0);
- uint8[] clear_data = GPGHelper.decrypt_data(data.data);
- file_transfer.input_stream = new MemoryInputStream.from_data(clear_data, GLib.free);
- file_transfer.encryption = Encryption.PGP;
- if (file_transfer.file_name.has_suffix(".pgp")) {
- file_transfer.file_name = file_transfer.file_name.substring(0, file_transfer.file_name.length - 4);
+ uint8[] clear_data = GPGHelper.decrypt_data(data.data);
+ file_transfer.input_stream = new MemoryInputStream.from_data(clear_data, GLib.free);
+ file_transfer.encryption = Encryption.PGP;
+ if (file_transfer.file_name.has_suffix(".pgp")) {
+ file_transfer.file_name = file_transfer.file_name.substring(0, file_transfer.file_name.length - 4);
+ }
+ } catch (Error e) {
+ file_transfer.state = FileTransfer.State.FAILED;
}
}
}
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<string> keys = new Gee.ArrayList<string>();
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;
}
}
diff --git a/plugins/openpgp/src/out_file_processor.vala b/plugins/openpgp/src/out_file_processor.vala
index 81c53b16..a09e17a6 100644
--- a/plugins/openpgp/src/out_file_processor.vala
+++ b/plugins/openpgp/src/out_file_processor.vala
@@ -16,11 +16,15 @@ public class OutFileProcessor : OutgoingFileProcessor, Object {
public void process(Conversation conversation, FileTransfer file_transfer) {
string uri = file_transfer.get_uri();
- GPG.Key[] keys = stream_interactor.get_module(Manager.IDENTITY).get_key_fprs(conversation);
- uint8[] enc_content = GPGHelper.encrypt_file(uri, keys, GPG.EncryptFlags.ALWAYS_TRUST);
- file_transfer.input_stream = new MemoryInputStream.from_data(enc_content, GLib.free);
- file_transfer.encryption = Encryption.PGP;
- file_transfer.server_file_name = file_transfer.server_file_name + ".pgp";
+ try {
+ GPG.Key[] keys = stream_interactor.get_module(Manager.IDENTITY).get_key_fprs(conversation);
+ uint8[] enc_content = GPGHelper.encrypt_file(uri, keys, GPG.EncryptFlags.ALWAYS_TRUST);
+ file_transfer.input_stream = new MemoryInputStream.from_data(enc_content, GLib.free);
+ file_transfer.encryption = Encryption.PGP;
+ file_transfer.server_file_name = file_transfer.server_file_name + ".pgp";
+ } catch (Error e) {
+ file_transfer.state = FileTransfer.State.FAILED;
+ }
}
}