diff --git a/src/composer/e-msg-composer.c b/src/composer/e-msg-composer.c index 4287b6a12c..21ff2a50d4 100644 --- a/src/composer/e-msg-composer.c +++ b/src/composer/e-msg-composer.c @@ -7016,6 +7016,7 @@ void e_msg_composer_check_autocrypt (EMsgComposer *composer, CamelMimeMessage *original_message) { + EAlertBar *alert_bar; gchar *from_email = NULL; gchar *keyid = NULL; gboolean send_public_key = FALSE; @@ -7028,6 +7029,10 @@ e_msg_composer_check_autocrypt (EMsgComposer *composer, e_msg_composer_remove_header (composer, "Autocrypt"); + alert_bar = e_html_editor_get_alert_bar (e_msg_composer_get_editor (composer)); + if (alert_bar) + e_alert_bar_remove_alert_by_tag (alert_bar, "mail-composer:info-autocrypt-header-too-large"); + if (gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (ACTION (SMIME_SIGN))) || gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (ACTION (SMIME_ENCRYPT)))) { /* Autocrypt is about GPG, thus ignore it when the user uses S/MIME */ @@ -7094,7 +7099,13 @@ e_msg_composer_check_autocrypt (EMsgComposer *composer, g_string_append (value, "; keydata="); g_string_append (value, keydata); - e_msg_composer_add_header (composer, "Autocrypt", value->str); + /* Ignore headers above 10KB in size. See: + https://autocrypt.org/level1.html#id74 */ + if (value->len <= 10240) + e_msg_composer_add_header (composer, "Autocrypt", value->str); + else + e_alert_submit (E_ALERT_SINK (e_msg_composer_get_editor (composer)), + "mail-composer:info-autocrypt-header-too-large", from_email, NULL); g_string_free (value, TRUE); } diff --git a/src/composer/mail-composer.error.xml b/src/composer/mail-composer.error.xml index 712beffe00..40896d98ac 100644 --- a/src/composer/mail-composer.error.xml +++ b/src/composer/mail-composer.error.xml @@ -158,4 +158,9 @@ Detailed error: {0} <_primary>Message Redirection <_secondary>This message is a redirection, which allows you to change the recipients, subject and other message attributes, but not the contents of the message. + + + <_primary>Not adding OpenPGP public key into the mail. + <_secondary>The OpenPGP public key for “{0}” is too large for the transfer. + diff --git a/src/e-util/e-alert-bar.c b/src/e-util/e-alert-bar.c index c5088fdfeb..05692dec35 100644 --- a/src/e-util/e-alert-bar.c +++ b/src/e-util/e-alert-bar.c @@ -542,6 +542,27 @@ e_alert_bar_clear (EAlertBar *alert_bar) alert_bar_response_close (alert); } +gboolean +e_alert_bar_remove_alert_by_tag (EAlertBar *alert_bar, + const gchar *tag) +{ + GList *link; + + g_return_val_if_fail (E_IS_ALERT_BAR (alert_bar), FALSE); + g_return_val_if_fail (tag != NULL, FALSE); + + for (link = g_queue_peek_head_link (&alert_bar->priv->alerts); link; link = g_list_next (link)) { + EAlert *alert = link->data; + + if (g_strcmp0 (tag, e_alert_get_tag (alert)) == 0) { + alert_bar_response_close (alert); + return TRUE; + } + } + + return FALSE; +} + typedef struct { gboolean found; EAlert *looking_for; diff --git a/src/e-util/e-alert-bar.h b/src/e-util/e-alert-bar.h index b510bec2ea..90e7291f91 100644 --- a/src/e-util/e-alert-bar.h +++ b/src/e-util/e-alert-bar.h @@ -65,6 +65,8 @@ GtkWidget * e_alert_bar_new (void); void e_alert_bar_clear (EAlertBar *alert_bar); void e_alert_bar_add_alert (EAlertBar *alert_bar, EAlert *alert); +gboolean e_alert_bar_remove_alert_by_tag (EAlertBar *alert_bar, + const gchar *tag); gboolean e_alert_bar_close_alert (EAlertBar *alert_bar); void e_alert_bar_submit_alert (EAlertBar *alert_bar, EAlert *alert); diff --git a/src/e-util/e-alert.c b/src/e-util/e-alert.c index f925e3ec4d..83fa421ed9 100644 --- a/src/e-util/e-alert.c +++ b/src/e-util/e-alert.c @@ -790,6 +790,14 @@ e_alert_new_array (const gchar *tag, return g_object_new (E_TYPE_ALERT, "tag", tag, "args", args, NULL); } +const gchar * +e_alert_get_tag (EAlert *alert) +{ + g_return_val_if_fail (E_IS_ALERT (alert), NULL); + + return alert->priv->tag; +} + gint e_alert_get_default_response (EAlert *alert) { diff --git a/src/e-util/e-alert.h b/src/e-util/e-alert.h index c4201861e8..6463f03cb9 100644 --- a/src/e-util/e-alert.h +++ b/src/e-util/e-alert.h @@ -86,6 +86,7 @@ EAlert * e_alert_new_valist (const gchar *tag, va_list va); EAlert * e_alert_new_array (const gchar *tag, GPtrArray *args); +const gchar * e_alert_get_tag (EAlert *alert); gint e_alert_get_default_response (EAlert *alert); void e_alert_set_default_response (EAlert *alert, gint response_id); diff --git a/src/e-util/e-html-editor.c b/src/e-util/e-html-editor.c index 4ba9615d41..a92d6946aa 100644 --- a/src/e-util/e-html-editor.c +++ b/src/e-util/e-html-editor.c @@ -2476,3 +2476,21 @@ e_html_editor_clear_alerts (EHTMLEditor *editor) if (editor->priv->alert_bar) e_alert_bar_clear (E_ALERT_BAR (editor->priv->alert_bar)); } + +/** + * e_html_editor_get_alert_bar: + * @editor: an #EHTMLEditor + * + * Returns an #EAlertBar used by the @editor. + * + * Returns: (transfer none) (nullable): an #EAlertBar used by the @editor + * + * Since: 3.50 + **/ +EAlertBar * +e_html_editor_get_alert_bar (EHTMLEditor *editor) +{ + g_return_val_if_fail (E_IS_HTML_EDITOR (editor), NULL); + + return editor->priv->alert_bar ? E_ALERT_BAR (editor->priv->alert_bar) : NULL; +} diff --git a/src/e-util/e-html-editor.h b/src/e-util/e-html-editor.h index e1670c6471..997f3e113f 100644 --- a/src/e-util/e-html-editor.h +++ b/src/e-util/e-html-editor.h @@ -29,6 +29,7 @@ #include #include #include +#include #include #include @@ -142,6 +143,7 @@ void e_html_editor_remove_all_cid_parts CamelMimePart * e_html_editor_ref_cid_part (EHTMLEditor *editor, const gchar *cid_uri); void e_html_editor_clear_alerts (EHTMLEditor *editor); +EAlertBar * e_html_editor_get_alert_bar (EHTMLEditor *editor); EActionComboBox * e_html_editor_util_new_mode_combobox (void);