diff --git a/libbalsa/autocrypt.c b/libbalsa/autocrypt.c index cfcb6aae5..6c6c5f5a7 100644 --- a/libbalsa/autocrypt.c +++ b/libbalsa/autocrypt.c @@ -32,6 +32,7 @@ #include "libbalsa-gpgme-keys.h" #include "libbalsa-gpgme-widgets.h" #include "identity.h" +#include "geometry-manager.h" #include "autocrypt.h" @@ -297,7 +298,6 @@ autocrypt_header(const LibBalsaIdentity *identity, GError **error) const gchar *mailbox; gchar *use_fpr = NULL; gchar *result = NULL; - gchar *keydata; g_return_val_if_fail((identity != NULL) && (identity->autocrypt_mode != AUTOCRYPT_DISABLE), NULL); mailbox = internet_address_mailbox_get_addr(INTERNET_ADDRESS_MAILBOX(identity->ia)); @@ -321,27 +321,38 @@ autocrypt_header(const LibBalsaIdentity *identity, GError **error) } gpgme_release(ctx); } - g_debug("found fingerprint %s for '%s'", use_fpr, mailbox); + + if (use_fpr == NULL) { + g_set_error(error, AUTOCRYPT_ERROR_QUARK, -1, + _("No usable private key for ā€œ%sā€ found! Please create a key or disable Autocrypt."), mailbox); + } else { + g_debug("found fingerprint %s for '%s'", use_fpr, mailbox); + } } else { use_fpr = g_strdup(identity->force_gpg_key_id); } - keydata = libbalsa_gpgme_export_autocrypt_key(use_fpr, mailbox, error); - g_free(use_fpr); - if (keydata != NULL) { - GString *buffer; - gssize ins_fws; + if (use_fpr != NULL) { + gchar *keydata; - buffer = g_string_new(NULL); - g_string_append_printf(buffer, "addr=%s;", mailbox); - if (identity->autocrypt_mode == AUTOCRYPT_PREFER_ENCRYPT) { - g_string_append(buffer, "prefer-encrypt=mutual;"); - } - g_string_append_printf(buffer, "keydata=%s", keydata); - for (ins_fws = 66U; ins_fws < (gssize) buffer->len; ins_fws += 78) { - g_string_insert(buffer, ins_fws, "\n\t"); + keydata = libbalsa_gpgme_export_autocrypt_key(use_fpr, mailbox, error); + g_free(use_fpr); + if (keydata != NULL) { + GString *buffer; + gssize ins_fws; + + buffer = g_string_new(NULL); + g_string_append_printf(buffer, "addr=%s;", mailbox); + if (identity->autocrypt_mode == AUTOCRYPT_PREFER_ENCRYPT) { + g_string_append(buffer, "prefer-encrypt=mutual;"); + } + g_string_append_printf(buffer, "keydata=%s", keydata); + for (ins_fws = 66; ins_fws < (gssize) buffer->len; ins_fws += 78) { + g_string_insert(buffer, ins_fws, "\n\t"); + } + result = g_string_free(buffer, FALSE); + g_free(keydata); } - result = g_string_free(buffer, FALSE); } return result; @@ -444,6 +455,7 @@ autocrypt_db_dialog_run(const gchar *date_string, GtkWindow *parent) dialog = gtk_dialog_new_with_buttons(_("Autocrypt database"), parent, GTK_DIALOG_DESTROY_WITH_PARENT | libbalsa_dialog_flags(), _("_Close"), GTK_RESPONSE_CLOSE, NULL); + geometry_manager_attach(GTK_WINDOW(dialog), "AutocryptDB"); vbox = gtk_box_new(GTK_ORIENTATION_VERTICAL, 12); gtk_container_add(GTK_CONTAINER(gtk_dialog_get_content_area(GTK_DIALOG(dialog))), vbox); diff --git a/libbalsa/send.c b/libbalsa/send.c index 33ed67fed..38947d2af 100644 --- a/libbalsa/send.c +++ b/libbalsa/send.c @@ -1511,9 +1511,9 @@ libbalsa_message_create_mime_message(LibBalsaMessage *message, #ifdef ENABLE_AUTOCRYPT /* add Autocrypt header if requested */ - if ((message->ident != NULL) && (message->ident->autocrypt_mode != AUTOCRYPT_DISABLE) && + if (!postponing && (message->ident != NULL) && (message->ident->autocrypt_mode != AUTOCRYPT_DISABLE) && !autocrypt_ignore(g_mime_object_get_content_type(mime_root))) { - tmp = autocrypt_header(message->ident, NULL); + tmp = autocrypt_header(message->ident, error); if (tmp == NULL) { g_object_unref(G_OBJECT(mime_message)); return LIBBALSA_MESSAGE_CREATE_ERROR; diff --git a/src/save-restore.c b/src/save-restore.c index 4c96754c3..23313fb9c 100644 --- a/src/save-restore.c +++ b/src/save-restore.c @@ -695,7 +695,10 @@ config_global_load(void) #ifdef HAVE_GPGME geometry_manager_init("KeyDialog", 400, 200, FALSE); geometry_manager_init("KeyList", 300, 200, FALSE); -#endif +#ifdef ENABLE_AUTOCRYPT + geometry_manager_init("AutocryptDB", 300, 200, FALSE); +#endif /* ENABLE_AUTOCRYPT */ +#endif /* HAVE_GPGME */ /* FIXME: PKGW: why comment this out? Breaks my Transfer context menu. */ if (balsa_app.mblist_width < 100)