diff options
Diffstat (limited to 'plugins/gpgme-vala')
-rw-r--r-- | plugins/gpgme-vala/src/gpgme_helper.vala | 13 | ||||
-rw-r--r-- | plugins/gpgme-vala/vapi/gpgme.vapi | 6 |
2 files changed, 14 insertions, 5 deletions
diff --git a/plugins/gpgme-vala/src/gpgme_helper.vala b/plugins/gpgme-vala/src/gpgme_helper.vala index cc013164..c0121842 100644 --- a/plugins/gpgme-vala/src/gpgme_helper.vala +++ b/plugins/gpgme-vala/src/gpgme_helper.vala @@ -19,11 +19,12 @@ public static string encrypt_armor(string plain, Key[] keys, EncryptFlags flags) } } -public static uint8[] encrypt_file(string uri, Key[] keys, EncryptFlags flags) throws GLib.Error { +public static uint8[] encrypt_file(string uri, Key[] keys, EncryptFlags flags, string file_name) throws GLib.Error { global_mutex.lock(); try { initialize(); Data plain_data = Data.create_from_file(uri); + plain_data.set_file_name(file_name); Context context = Context.create(); context.set_armor(true); Data enc_data = context.op_encrypt(keys, flags, plain_data); @@ -46,14 +47,20 @@ public static string decrypt(string encr) throws GLib.Error { } } -public static uint8[] decrypt_data(uint8[] data) throws GLib.Error { +public class DecryptedData { + public uint8[] data { get; set; } + public string filename { get; set; } +} + +public static DecryptedData decrypt_data(uint8[] data) throws GLib.Error { global_mutex.lock(); try { initialize(); Data enc_data = Data.create_from_memory(data, false); Context context = Context.create(); Data dec_data = context.op_decrypt(enc_data); - return get_uint8_from_data(dec_data); + DecryptResult* dec_res = context.op_decrypt_result(); + return new DecryptedData() { data=get_uint8_from_data(dec_data), filename=dec_res->file_name}; } finally { global_mutex.unlock(); } diff --git a/plugins/gpgme-vala/vapi/gpgme.vapi b/plugins/gpgme-vala/vapi/gpgme.vapi index 55031bfa..e66aee1f 100644 --- a/plugins/gpgme-vala/vapi/gpgme.vapi +++ b/plugins/gpgme-vala/vapi/gpgme.vapi @@ -59,7 +59,7 @@ namespace GPG { string unsupported_algorithm; bool wrong_key_usage; Recipient recipients; - string filename; + string file_name; } [CCode (cname = "struct _gpgme_recipient")] @@ -481,7 +481,9 @@ namespace GPG { public long seek(long offset, int whence=0); - public DataEncoding *get_encoding(); + public GPGError.Error set_file_name(string file_name); + + public DataEncoding* get_encoding(); public GPGError.Error set_encoding(DataEncoding enc); } |