[balsa] Declare LibBalsaIdentity final



commit f62d88c4343a10b24ba9ae37937781086e0f25f7
Author: Peter Bloomfield <PeterBloomfield bellsouth net>
Date:   Tue Jun 4 18:00:18 2019 -0400

    Declare LibBalsaIdentity final
    
    Use G_DECLARE_FINAL_TYPE to declare LibBalsaIdentity
    
    Make the structure private, and provide and use the necessary
    getters and setters.

 ChangeLog                         |  61 +++++
 libbalsa/autocrypt.c              |  20 +-
 libbalsa/autocrypt.h              |   2 +-
 libbalsa/identity.c               | 504 +++++++++++++++++++++++---------------
 libbalsa/identity.h               | 190 ++++++--------
 libbalsa/send.c                   |  47 ++--
 src/balsa-message.c               |  26 +-
 src/balsa-mime-widget-message.c   |   5 +-
 src/balsa-mime-widget-vcalendar.c |  11 +-
 src/mailbox-conf.c                |   3 +-
 src/save-restore.c                |  10 +-
 src/sendmsg-window.c              | 223 ++++++++++-------
 12 files changed, 647 insertions(+), 455 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index f862eb62e..d8e52c8da 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,64 @@
+2019-06-04  Peter Bloomfield  <pbloomfield bellsouth net>
+
+       Use G_DECLARE_FINAL_TYPE to declare LibBalsaIdentity
+
+       Make the structure private, and provide and use the necessary
+       getters and setters.
+
+       * libbalsa/autocrypt.c (autocrypt_header):
+       * libbalsa/autocrypt.h:
+       * libbalsa/identity.c (libbalsa_identity_finalize),
+       (libbalsa_identity_new_with_name), (libbalsa_identity_set_address),
+       (libbalsa_identity_set_domain), (libbalsa_identity_get_signature),
+       (libbalsa_identity_get_sig_prepend),
+       (libbalsa_identity_get_sig_whenreply),
+       (libbalsa_identity_get_sig_whenforward),
+       (libbalsa_identity_get_sig_sending),
+       (libbalsa_identity_get_send_mp_alternative),
+       (libbalsa_identity_get_request_mdn),
+       (libbalsa_identity_get_request_dsn),
+       (libbalsa_identity_get_warn_send_plain),
+       (libbalsa_identity_get_always_trust),
+       (libbalsa_identity_get_gpg_sign),
+       (libbalsa_identity_get_gpg_encrypt),
+       (libbalsa_identity_get_sig_executable),
+       (libbalsa_identity_get_sig_separator),
+       (libbalsa_identity_get_crypt_protocol),
+       (libbalsa_identity_get_identity_name),
+       (libbalsa_identity_get_force_gpg_key_id),
+       (libbalsa_identity_get_force_smime_key_id),
+       (libbalsa_identity_get_replyto), (libbalsa_identity_get_bcc),
+       (libbalsa_identity_get_reply_string),
+       (libbalsa_identity_get_forward_string),
+       (libbalsa_identity_get_domain), (libbalsa_identity_get_face_path),
+       (libbalsa_identity_get_x_face_path),
+       (libbalsa_identity_get_signature_path),
+       (libbalsa_identity_get_address),
+       (libbalsa_identity_get_smtp_server),
+       (libbalsa_identity_get_autocrypt_mode):
+       * libbalsa/identity.h:
+       * libbalsa/send.c (libbalsa_message_create_mime_message),
+       (lb_send_from):
+       * src/balsa-message.c (handle_mdn_request), (create_mdn_reply),
+       (mdn_dialog_response), (autocrypt_in_use):
+       * src/balsa-mime-widget-message.c (extbody_send_mail):
+       * src/balsa-mime-widget-vcalendar.c (balsa_vevent_widget),
+       (vevent_reply):
+       * src/mailbox-conf.c (mailbox_conf_view_check):
+       * src/save-restore.c (config_identity_load),
+       (config_identities_save):
+       * src/sendmsg-window.c (replace_identity_signature),
+       (update_bsmsg_identity), (create_email_entry),
+       (sw_insert_sig_activated), (generate_forwarded_subject),
+       (bsmsg_set_subject_from_body), (set_identity_from_mailbox),
+       (guess_identity_from_list), (setup_headers_from_identity),
+       (sw_cc_add_list), (insert_initial_sig), (bsmsg2message),
+       (check_suggest_encryption), (check_autocrypt_recommendation),
+       (send_message_handler), (bsmsg_update_gpg_ui_on_ident_change),
+       (sendmsg_window_new), (sendmsg_window_compose),
+       (sendmsg_window_reply), (sendmsg_window_reply_embedded),
+       (sendmsg_window_forward):
+
 2019-06-04  Peter Bloomfield  <pbloomfield bellsouth net>
 
        Use G_DECLARE_FINAL_TYPE to declare LibBalsaCellRendererButton
diff --git a/libbalsa/autocrypt.c b/libbalsa/autocrypt.c
index 3cc95bbcf..739cd62aa 100644
--- a/libbalsa/autocrypt.c
+++ b/libbalsa/autocrypt.c
@@ -264,17 +264,25 @@ autocrypt_from_message(LibBalsaMessage  *message,
 
 /* documentation: see header file */
 gchar *
-autocrypt_header(const LibBalsaIdentity *identity, GError **error)
+autocrypt_header(LibBalsaIdentity *identity, GError **error)
 {
        const gchar *mailbox;
        gchar *use_fpr = NULL;
        gchar *result = NULL;
+        InternetAddress *ia;
+        const gchar *force_gpg_key_id;
+        AutocryptMode autocrypt_mode;
 
-       g_return_val_if_fail((identity != NULL) && (identity->autocrypt_mode != AUTOCRYPT_DISABLE), NULL);
-       mailbox = internet_address_mailbox_get_addr(INTERNET_ADDRESS_MAILBOX(identity->ia));
+       g_return_val_if_fail(identity != NULL, NULL);
+       autocrypt_mode = libbalsa_identity_get_autocrypt_mode(identity);
+       g_return_val_if_fail(autocrypt_mode != AUTOCRYPT_DISABLE, NULL);
+
+       ia = libbalsa_identity_get_address(identity);
+       mailbox = internet_address_mailbox_get_addr(INTERNET_ADDRESS_MAILBOX(ia));
 
        /* no key fingerprint has been passed - try to find the fingerprint of a secret key matching the 
passed mailbox */
-       if ((identity->force_gpg_key_id == NULL) || (identity->force_gpg_key_id[0] == '\0')) {
+        force_gpg_key_id = libbalsa_identity_get_force_gpg_key_id(identity);
+       if ((force_gpg_key_id == NULL) || (force_gpg_key_id[0] == '\0')) {
                gpgme_ctx_t ctx;
 
                ctx = libbalsa_gpgme_new_with_proto(GPGME_PROTOCOL_OpenPGP, NULL, NULL, error);
@@ -300,7 +308,7 @@ autocrypt_header(const LibBalsaIdentity *identity, GError **error)
                        g_debug("found fingerprint %s for '%s'", use_fpr, mailbox);
                }
        } else {
-               use_fpr = g_strdup(identity->force_gpg_key_id);
+               use_fpr = g_strdup(force_gpg_key_id);
        }
 
        if (use_fpr != NULL) {
@@ -314,7 +322,7 @@ autocrypt_header(const LibBalsaIdentity *identity, GError **error)
 
                        buffer = g_string_new(NULL);
                        g_string_append_printf(buffer, "addr=%s;", mailbox);
-                       if (identity->autocrypt_mode == AUTOCRYPT_PREFER_ENCRYPT) {
+                       if (autocrypt_mode == AUTOCRYPT_PREFER_ENCRYPT) {
                                g_string_append(buffer, "prefer-encrypt=mutual;");
                        }
                        g_string_append_printf(buffer, "keydata=%s", keydata);
diff --git a/libbalsa/autocrypt.h b/libbalsa/autocrypt.h
index 11f9dd21f..821df9c53 100644
--- a/libbalsa/autocrypt.h
+++ b/libbalsa/autocrypt.h
@@ -88,7 +88,7 @@ void autocrypt_from_message(LibBalsaMessage  *message,
  * minimalistic, depending upon the export capabilities of the gpg backend being used.  It is an error to 
call this function if the
  * Autocrypt mode of the passed identity is AUTOCRYPT_DISABLE.
  */
-gchar *autocrypt_header(const LibBalsaIdentity  *identity,
+gchar *autocrypt_header(LibBalsaIdentity  *identity,
                                                GError                     **error)
        G_GNUC_WARN_UNUSED_RESULT;
 
diff --git a/libbalsa/identity.c b/libbalsa/identity.c
index b0ff23a87..e811a4d39 100644
--- a/libbalsa/identity.c
+++ b/libbalsa/identity.c
@@ -1,6 +1,6 @@
 /* -*-mode:c; c-style:k&r; c-basic-offset:4; -*- */
 /* Balsa E-Mail Client
- * Copyright (C) 1997-2016 Stuart Parmenter and others,
+ * Copyright (C) 1997-2019 Stuart Parmenter and others,
  *                         See the file AUTHORS for a list.
  *
  * This program is free software; you can redistribute it and/or modify
@@ -44,37 +44,55 @@
 
 static GObjectClass* parent_class;
 
+struct _LibBalsaIdentityClass {
+    GObjectClass parent_class;
+};
+
+struct _LibBalsaIdentity {
+    GObject object;
+
+    gchar *identity_name;
+
+    InternetAddress *ia;
+    gchar *replyto;
+    gchar *domain;
+    gchar *bcc;
+    gchar *reply_string;
+    gchar *forward_string;
+    gboolean send_mp_alternative;
+
+    gchar *signature_path;
+    gboolean sig_executable;
+    gboolean sig_sending;
+    gboolean sig_whenforward;
+    gboolean sig_whenreply;
+    gboolean sig_separator;
+    gboolean sig_prepend;
+    gchar *face;
+    gchar *x_face;
+    gboolean request_mdn;
+    gboolean request_dsn;
+
+    gboolean gpg_sign;
+    gboolean gpg_encrypt;
+    gboolean always_trust;
+    gboolean warn_send_plain;
+    gint crypt_protocol;
+    gchar *force_gpg_key_id;
+    gchar *force_smime_key_id;
+#ifdef ENABLE_AUTOCRYPT
+    AutocryptMode autocrypt_mode;
+#endif
+
+    LibBalsaSmtpServer *smtp_server;
+};
+
 /* Forward references. */
 static void libbalsa_identity_class_init(LibBalsaIdentityClass* klass);
 static void libbalsa_identity_init(LibBalsaIdentity* ident);
 static void libbalsa_identity_finalize(GObject* object);
 
-GType
-libbalsa_identity_get_type()
-{
-    static GType libbalsa_identity_type = 0;
-
-    if (!libbalsa_identity_type) {
-        static const GTypeInfo libbalsa_identity_info = {
-            sizeof(LibBalsaIdentityClass),
-            NULL,               /* base_init */
-            NULL,               /* base_finalize */
-            (GClassInitFunc) libbalsa_identity_class_init,
-            NULL,               /* class_finalize */
-            NULL,               /* class_data */
-            sizeof(LibBalsaIdentity),
-            0,                  /* n_preallocs */
-            (GInstanceInitFunc) libbalsa_identity_init,
-        };
-
-        libbalsa_identity_type =
-            g_type_register_static(G_TYPE_OBJECT,
-                                   "LibBalsaIdentity",
-                                   &libbalsa_identity_info, 0);
-    }
-
-    return libbalsa_identity_type;
-}
+G_DEFINE_TYPE(LibBalsaIdentity, libbalsa_identity, G_TYPE_OBJECT)
 
 static void
 libbalsa_identity_class_init(LibBalsaIdentityClass* klass)
@@ -150,7 +168,7 @@ libbalsa_identity_finalize(GObject * object)
     g_free(ident->force_gpg_key_id);
     g_free(ident->force_smime_key_id);
 
-    G_OBJECT_CLASS(parent_class)->finalize(object);
+    G_OBJECT_CLASS(libbalsa_identity_parent_class)->finalize(object);
 }
 
 /*
@@ -161,7 +179,7 @@ libbalsa_identity_finalize(GObject * object)
  * Create a new object with the default identity name.  Does not add
  * it to the list of identities for the application.
  */
-GObject*
+LibBalsaIdentity *
 libbalsa_identity_new(void)
 {
     return libbalsa_identity_new_with_name(_("New Identity"));
@@ -172,25 +190,15 @@ libbalsa_identity_new(void)
  * Create a new object with the specified identity name.  Does not add
  * it to the list of identities for the application.
  */
-GObject*
+LibBalsaIdentity *
 libbalsa_identity_new_with_name(const gchar* ident_name)
 {
-    LibBalsaIdentity* ident;
+    LibBalsaIdentity *ident;
 
     ident = g_object_new(LIBBALSA_TYPE_IDENTITY, NULL);
-    libbalsa_identity_set_identity_name(ident, ident_name);
+    ident->identity_name = g_strdup(ident_name);
 
-    return G_OBJECT(ident);
-}
-
-
-void
-libbalsa_identity_set_identity_name(LibBalsaIdentity* ident, const gchar* name)
-{
-    g_return_if_fail(ident != NULL);
-
-    g_free(ident->identity_name);
-    ident->identity_name = g_strdup(name);
+    return ident;
 }
 
 
@@ -198,7 +206,7 @@ void
 libbalsa_identity_set_address(LibBalsaIdentity * ident,
                               InternetAddress * ia)
 {
-    g_return_if_fail(ident != NULL);
+    g_return_if_fail(LIBBALSA_IS_IDENTITY(ident));
 
     if (ident->ia)
        g_object_unref(ident->ia);
@@ -206,168 +214,62 @@ libbalsa_identity_set_address(LibBalsaIdentity * ident,
 }
 
 
-void
-libbalsa_identity_set_replyto(LibBalsaIdentity* ident, const gchar* address)
-{
-    g_return_if_fail(ident != NULL);
-
-    g_free(ident->replyto);
-    ident->replyto = g_strdup(address);
-}
-
-
 void
 libbalsa_identity_set_domain(LibBalsaIdentity* ident, const gchar* dom)
 {
-    g_return_if_fail(ident != NULL);
+    g_return_if_fail(LIBBALSA_IS_IDENTITY(ident));
 
     g_free(ident->domain);
     ident->domain = g_strdup(dom);
 }
 
 
-void
-libbalsa_identity_set_bcc(LibBalsaIdentity* ident, const gchar* bcc)
-{
-    g_return_if_fail(ident != NULL);
-
-    g_free(ident->bcc);
-    ident->bcc = g_strdup(bcc);
-}
-
-
-void
-libbalsa_identity_set_reply_string(LibBalsaIdentity* ident, const gchar* reply)
-{
-    g_return_if_fail(ident != NULL);
-
-    g_free(ident->reply_string);
-    ident->reply_string = g_strdup(reply);
-}
-
-
-void
-libbalsa_identity_set_forward_string(LibBalsaIdentity* ident, const gchar* forward)
-{
-    g_return_if_fail(ident != NULL);
-
-    g_free(ident->forward_string);
-    ident->forward_string = g_strdup(forward);
-}
-
-
-void
-libbalsa_identity_set_send_mp_alternative(LibBalsaIdentity* ident, gboolean send_mp_alternative)
-{
-    g_return_if_fail(ident != NULL);
-    ident->send_mp_alternative = send_mp_alternative;
-}
-
-
-void
-libbalsa_identity_set_signature_path(LibBalsaIdentity* ident, const gchar* path)
-{
-    g_return_if_fail(ident != NULL);
-
-    g_free(ident->signature_path);
-    ident->signature_path = g_strdup(path);
-}
-
-
-void
-libbalsa_identity_set_sig_executable(LibBalsaIdentity* ident, gboolean sig_executable)
-{
-    g_return_if_fail(ident != NULL);
-    ident->sig_executable = sig_executable;
-}
-
-
-void
-libbalsa_identity_set_sig_sending(LibBalsaIdentity* ident, gboolean sig_sending)
-{
-    g_return_if_fail(ident != NULL);
-    ident->sig_sending = sig_sending;
-}
-
-
-void
-libbalsa_identity_set_sig_whenforward(LibBalsaIdentity* ident, gboolean forward)
-{
-    g_return_if_fail(ident != NULL);
-    ident->sig_whenforward = forward;
-}
-
-
-void
-libbalsa_identity_set_sig_whenreply(LibBalsaIdentity* ident, gboolean reply)
-{
-    g_return_if_fail(ident != NULL);
-    ident->sig_whenreply = reply;
-}
-
-
-void
-libbalsa_identity_set_sig_separator(LibBalsaIdentity* ident, gboolean separator)
-{
-    g_return_if_fail(ident != NULL);
-    ident->sig_separator = separator;
-}
-
-
-void
-libbalsa_identity_set_sig_prepend(LibBalsaIdentity* ident, gboolean prepend)
-{
-    g_return_if_fail(ident != NULL);
-    ident->sig_prepend = prepend;
-}
-
 /** Returns a signature for given identity, adding a signature prefix
-    if needed. parent can be NULL. */
+    if needed. */
 gchar*
-libbalsa_identity_get_signature(LibBalsaIdentity* identity, GtkWindow *parent)
+libbalsa_identity_get_signature(LibBalsaIdentity * ident, GError ** error)
 {
     gchar *ret = NULL, *path;
     gchar *retval;
 
-    if (identity->signature_path == NULL ||
-        *identity->signature_path == '\0')
+    if (ident->signature_path == NULL || *ident->signature_path == '\0')
        return NULL;
 
-    path = libbalsa_expand_path(identity->signature_path);
-    if(identity->sig_executable){
-        GError *error = NULL;
+    path = libbalsa_expand_path(ident->signature_path);
+    if (ident->sig_executable) {
         gchar *argv[] = {"/bin/sh", "-c", path, NULL};
+        gchar *standard_error = NULL;
 
         if (!g_spawn_sync(NULL, argv, NULL, G_SPAWN_DEFAULT, NULL, NULL,
-                          &ret, NULL, NULL, &error)) {
-            libbalsa_information_parented(parent, LIBBALSA_INFORMATION_ERROR,
-                                          _("Error executing signature generator “%s”: %s"),
-                                          identity->signature_path, error->message);
-            g_error_free(error);
+                          &ret, &standard_error, NULL, error)) {
+            g_prefix_error(error, _("Error executing signature generator “%s”: "),
+                           ident->signature_path);
+        } else if (standard_error != NULL) {
+            g_set_error(error, LIBBALSA_ERROR_QUARK, -1,
+                        _("Error executing signature generator “%s”: %s"),
+                        ident->signature_path, standard_error);
         }
+        g_free(standard_error);
     } else {
-       GError *error = NULL;
-
-       if (!g_file_get_contents(path, &ret, NULL, &error)) {
-            libbalsa_information_parented(parent, LIBBALSA_INFORMATION_ERROR,
-                                          _("Cannot read signature file “%s”: %s"),
-                                          identity->signature_path, error->message);
-               g_error_free(error);
+       if (!g_file_get_contents(path, &ret, NULL, error)) {
+            g_prefix_error(error, _("Cannot read signature file “%s”: "),
+                           ident->signature_path);
        }
     }
     g_free(path);
 
-    if(ret == NULL) return NULL;
+    if ((error != NULL && *error != NULL) || ret == NULL)
+        return NULL;
 
     if (!libbalsa_utf8_sanitize(&ret, FALSE, NULL)) {
-        libbalsa_information_parented(parent, LIBBALSA_INFORMATION_ERROR,
-                                      _("Signature in %s is not a UTF-8 text."),
-                                      identity->signature_path);
+        g_set_error(error, LIBBALSA_ERROR_QUARK, -1,
+                    _("Signature in “%s” is not a UTF-8 text."),
+                    ident->signature_path);
     }
 
     /* Prepend the separator if needed... */
 
-    if (identity->sig_separator
+    if (ident->sig_separator
         && !(g_str_has_prefix(ret, "--\n") || g_str_has_prefix(ret, "-- \n"))) {
         retval = g_strconcat("\n-- \n", ret, NULL);
     } else {
@@ -2094,30 +1996,6 @@ libbalsa_identity_save(LibBalsaIdentity* ident, const gchar* group)
 
 /* collected helper stuff for GPGME support */
 
-void
-libbalsa_identity_set_gpg_sign(LibBalsaIdentity* ident, gboolean sign)
-{
-    g_return_if_fail(ident != NULL);
-    ident->gpg_sign = sign;
-}
-
-
-void
-libbalsa_identity_set_gpg_encrypt(LibBalsaIdentity* ident, gboolean encrypt)
-{
-    g_return_if_fail(ident != NULL);
-    ident->gpg_encrypt = encrypt;
-}
-
-
-void
-libbalsa_identity_set_crypt_protocol(LibBalsaIdentity* ident, gint protocol)
-{
-    g_return_if_fail(ident != NULL);
-    ident->crypt_protocol = protocol;
-}
-
-
 
 static void
 display_frame_set_gpg_mode(GObject * dialog, const gchar* key, gint * value)
@@ -2360,3 +2238,233 @@ libbalsa_identity_combo_box(GList       * identities,
 
     return combo_box;
 }
+
+/*
+ * Getters
+ */
+
+gboolean
+libbalsa_identity_get_sig_prepend(LibBalsaIdentity *ident)
+{
+    g_return_val_if_fail(LIBBALSA_IS_IDENTITY(ident), FALSE);
+
+    return ident->sig_prepend;
+}
+
+gboolean
+libbalsa_identity_get_sig_whenreply(LibBalsaIdentity *ident)
+{
+    g_return_val_if_fail(LIBBALSA_IS_IDENTITY(ident), FALSE);
+
+    return ident->sig_whenreply;
+}
+
+gboolean
+libbalsa_identity_get_sig_whenforward(LibBalsaIdentity *ident)
+{
+    g_return_val_if_fail(LIBBALSA_IS_IDENTITY(ident), FALSE);
+
+    return ident->sig_whenforward;
+}
+
+gboolean
+libbalsa_identity_get_sig_sending(LibBalsaIdentity *ident)
+{
+    g_return_val_if_fail(LIBBALSA_IS_IDENTITY(ident), FALSE);
+
+    return ident->sig_sending;
+}
+
+gboolean
+libbalsa_identity_get_send_mp_alternative(LibBalsaIdentity *ident)
+{
+    g_return_val_if_fail(LIBBALSA_IS_IDENTITY(ident), FALSE);
+
+    return ident->send_mp_alternative;
+}
+
+gboolean
+libbalsa_identity_get_request_mdn(LibBalsaIdentity *ident)
+{
+    g_return_val_if_fail(LIBBALSA_IS_IDENTITY(ident), FALSE);
+
+    return ident->request_mdn;
+}
+
+gboolean
+libbalsa_identity_get_request_dsn(LibBalsaIdentity *ident)
+{
+    g_return_val_if_fail(LIBBALSA_IS_IDENTITY(ident), FALSE);
+
+    return ident->request_dsn;
+}
+
+gboolean
+libbalsa_identity_get_warn_send_plain(LibBalsaIdentity *ident)
+{
+    g_return_val_if_fail(LIBBALSA_IS_IDENTITY(ident), FALSE);
+
+    return ident->warn_send_plain;
+}
+
+gboolean
+libbalsa_identity_get_always_trust(LibBalsaIdentity *ident)
+{
+    g_return_val_if_fail(LIBBALSA_IS_IDENTITY(ident), FALSE);
+
+    return ident->always_trust;
+}
+
+gboolean
+libbalsa_identity_get_gpg_sign(LibBalsaIdentity *ident)
+{
+    g_return_val_if_fail(LIBBALSA_IS_IDENTITY(ident), FALSE);
+
+    return ident->gpg_sign;
+}
+
+gboolean
+libbalsa_identity_get_gpg_encrypt(LibBalsaIdentity *ident)
+{
+    g_return_val_if_fail(LIBBALSA_IS_IDENTITY(ident), FALSE);
+
+    return ident->gpg_encrypt;
+}
+
+gboolean
+libbalsa_identity_get_sig_executable(LibBalsaIdentity *ident)
+{
+    g_return_val_if_fail(LIBBALSA_IS_IDENTITY(ident), 0);
+
+    return ident->sig_executable;
+}
+
+gboolean
+libbalsa_identity_get_sig_separator(LibBalsaIdentity *ident)
+{
+    g_return_val_if_fail(LIBBALSA_IS_IDENTITY(ident), 0);
+
+    return ident->sig_separator;
+}
+
+gint
+libbalsa_identity_get_crypt_protocol(LibBalsaIdentity *ident)
+{
+    g_return_val_if_fail(LIBBALSA_IS_IDENTITY(ident), 0);
+
+    return ident->crypt_protocol;
+}
+
+const gchar *
+libbalsa_identity_get_identity_name(LibBalsaIdentity *ident)
+{
+    g_return_val_if_fail(LIBBALSA_IS_IDENTITY(ident), NULL);
+
+    return ident->identity_name;
+}
+
+const gchar *
+libbalsa_identity_get_force_gpg_key_id(LibBalsaIdentity *ident)
+{
+    g_return_val_if_fail(LIBBALSA_IS_IDENTITY(ident), NULL);
+
+    return ident->force_gpg_key_id;
+}
+
+const gchar *
+libbalsa_identity_get_force_smime_key_id(LibBalsaIdentity *ident)
+{
+    g_return_val_if_fail(LIBBALSA_IS_IDENTITY(ident), NULL);
+
+    return ident->force_smime_key_id;
+}
+
+const gchar *
+libbalsa_identity_get_replyto(LibBalsaIdentity *ident)
+{
+    g_return_val_if_fail(LIBBALSA_IS_IDENTITY(ident), NULL);
+
+    return ident->replyto;
+}
+
+const gchar *
+libbalsa_identity_get_bcc(LibBalsaIdentity *ident)
+{
+    g_return_val_if_fail(LIBBALSA_IS_IDENTITY(ident), NULL);
+
+    return ident->bcc;
+}
+
+const gchar *
+libbalsa_identity_get_reply_string(LibBalsaIdentity *ident)
+{
+    g_return_val_if_fail(LIBBALSA_IS_IDENTITY(ident), NULL);
+
+    return ident->reply_string;
+}
+
+const gchar *
+libbalsa_identity_get_forward_string(LibBalsaIdentity *ident)
+{
+    g_return_val_if_fail(LIBBALSA_IS_IDENTITY(ident), NULL);
+
+    return ident->forward_string;
+}
+
+const gchar *
+libbalsa_identity_get_domain(LibBalsaIdentity *ident)
+{
+    g_return_val_if_fail(LIBBALSA_IS_IDENTITY(ident), NULL);
+
+    return ident->domain;
+}
+
+const gchar *
+libbalsa_identity_get_face_path(LibBalsaIdentity *ident)
+{
+    g_return_val_if_fail(LIBBALSA_IS_IDENTITY(ident), NULL);
+
+    return ident->face;
+}
+
+const gchar *
+libbalsa_identity_get_x_face_path(LibBalsaIdentity *ident)
+{
+    g_return_val_if_fail(LIBBALSA_IS_IDENTITY(ident), NULL);
+
+    return ident->x_face;
+}
+
+const gchar *
+libbalsa_identity_get_signature_path(LibBalsaIdentity *ident)
+{
+    g_return_val_if_fail(LIBBALSA_IS_IDENTITY(ident), NULL);
+
+    return ident->signature_path;
+}
+
+InternetAddress *
+libbalsa_identity_get_address(LibBalsaIdentity *ident)
+{
+    g_return_val_if_fail(LIBBALSA_IS_IDENTITY(ident), NULL);
+
+    return ident->ia;
+}
+
+LibBalsaSmtpServer *
+libbalsa_identity_get_smtp_server(LibBalsaIdentity * ident)
+{
+    g_return_val_if_fail(LIBBALSA_IS_IDENTITY(ident), NULL);
+
+    return ident->smtp_server;
+}
+
+#ifdef ENABLE_AUTOCRYPT
+AutocryptMode
+libbalsa_identity_get_autocrypt_mode(LibBalsaIdentity * ident)
+{
+    g_return_val_if_fail(LIBBALSA_IS_IDENTITY(ident), AUTOCRYPT_DISABLE);
+
+    return ident->autocrypt_mode;
+}
+#endif
diff --git a/libbalsa/identity.h b/libbalsa/identity.h
index d3f3d93e9..9535a29ad 100644
--- a/libbalsa/identity.h
+++ b/libbalsa/identity.h
@@ -5,14 +5,14 @@
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2, or (at your option) 
+ * the Free Software Foundation; either version 2, or (at your option)
  * any later version.
- *  
+ *
  * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of 
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the  
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  * GNU General Public License for more details.
- *  
+ *
  * You should have received a copy of the GNU General Public License
  * along with this program; if not, see <http://www.gnu.org/licenses/>.
  */
@@ -34,121 +34,81 @@
 
 G_BEGIN_DECLS
 
-
-    GType libbalsa_identity_get_type(void);
-
-#define LIBBALSA_TYPE_IDENTITY \
-    (libbalsa_identity_get_type ())
-#define LIBBALSA_IDENTITY(obj) \
-    (G_TYPE_CHECK_INSTANCE_CAST (obj, LIBBALSA_TYPE_IDENTITY, \
-                                 LibBalsaIdentity))
-#define LIBBALSA_IDENTITY_CLASS(klass) \
-    (G_TYPE_CHECK_CLASS_CAST (klass, LIBBALSA_TYPE_IDENTITY, \
-                              LibBalsaIdentityClass))
-#define LIBBALSA_IS_IDENTITY(obj) \
-    (G_TYPE_CHECK_INSTANCE_TYPE (obj, LIBBALSA_TYPE_IDENTITY))
-#define LIBBALSA_IS_IDENTITY_CLASS(klass) \
-    (G_TYPE_CHECK_CLASS_TYPE (klass, LIBBALSA_TYPE_IDENTITY))
-
-    typedef struct _LibBalsaIdentityClass LibBalsaIdentityClass;
-    
-    
-    struct _LibBalsaIdentity 
-    {
-        GObject object;
-        
-        gchar* identity_name;
-        
-        InternetAddress *ia;
-        gchar* replyto;
-        gchar* domain;
-        gchar* bcc;
-        gchar* reply_string;
-        gchar* forward_string;
-        gboolean send_mp_alternative;
-
-        gchar* signature_path;
-        gboolean sig_executable;
-       gboolean sig_sending;
-        gboolean sig_whenforward;
-        gboolean sig_whenreply;
-        gboolean sig_separator;
-        gboolean sig_prepend;
-        gchar *face;
-        gchar *x_face;
-       gboolean request_mdn;
-       gboolean request_dsn;
-
-       gboolean gpg_sign;
-       gboolean gpg_encrypt;
-       gboolean always_trust;
-       gboolean warn_send_plain;
-       gint crypt_protocol;
-        gchar *force_gpg_key_id;
-        gchar *force_smime_key_id;
-#ifdef ENABLE_AUTOCRYPT
-        AutocryptMode autocrypt_mode;
-#endif
-       LibBalsaSmtpServer *smtp_server;
-    };
-
-    struct _LibBalsaIdentityClass 
-    {
-        GObjectClass parent_class;
-    };
+#define LIBBALSA_TYPE_IDENTITY (libbalsa_identity_get_type ())
+G_DECLARE_FINAL_TYPE(LibBalsaIdentity, libbalsa_identity, LIBBALSA, IDENTITY, GObject)
 
 
 /* Function prototypes */
-    GObject* libbalsa_identity_new(void);
-    GObject* libbalsa_identity_new_with_name(const gchar* ident_name);
-    
-    void libbalsa_identity_set_identity_name(LibBalsaIdentity*, const gchar*);
-    void libbalsa_identity_set_address(LibBalsaIdentity*, InternetAddress*);
-    void libbalsa_identity_set_replyto(LibBalsaIdentity*, const gchar*);
-    void libbalsa_identity_set_domain(LibBalsaIdentity*, const gchar*);
-    void libbalsa_identity_set_bcc(LibBalsaIdentity*, const gchar*);
-    void libbalsa_identity_set_reply_string(LibBalsaIdentity* , const gchar*);
-    void libbalsa_identity_set_forward_string(LibBalsaIdentity*, const gchar*);
-    void libbalsa_identity_set_send_mp_alternative(LibBalsaIdentity*, gboolean);
-    void libbalsa_identity_set_signature_path(LibBalsaIdentity*, const gchar*);
-    void libbalsa_identity_set_sig_executable(LibBalsaIdentity*, gboolean);
-    void libbalsa_identity_set_sig_sending(LibBalsaIdentity*, gboolean);
-    void libbalsa_identity_set_sig_whenforward(LibBalsaIdentity*, gboolean);
-    void libbalsa_identity_set_sig_whenreply(LibBalsaIdentity*, gboolean);
-    void libbalsa_identity_set_sig_separator(LibBalsaIdentity*, gboolean);
-    void libbalsa_identity_set_sig_prepend(LibBalsaIdentity*, gboolean);
-    gchar* libbalsa_identity_get_signature(LibBalsaIdentity*, 
-                                           GtkWindow *parent);
-    void libbalsa_identity_set_smtp_server(LibBalsaIdentity * ident,
-                                           LibBalsaSmtpServer *
-                                           smtp_server);
-
-    void libbalsa_identity_set_gpg_sign(LibBalsaIdentity*, gboolean);
-    void libbalsa_identity_set_gpg_encrypt(LibBalsaIdentity*, gboolean);
-    void libbalsa_identity_set_crypt_protocol(LibBalsaIdentity* ident, gint);
-
-    void libbalsa_identity_config_dialog(GtkWindow * parent,
-                                         GList ** identities,
-                                         LibBalsaIdentity ** current,
+LibBalsaIdentity *libbalsa_identity_new(void);
+LibBalsaIdentity *libbalsa_identity_new_with_name(const gchar *ident_name);
+LibBalsaIdentity *libbalsa_identity_new_from_config(const gchar *name);
+void              libbalsa_identity_save(LibBalsaIdentity *ident,
+                                         const gchar      *prefix);
+
+/* Setters */
+void libbalsa_identity_set_address(LibBalsaIdentity *ident, InternetAddress *ia);
+void libbalsa_identity_set_domain(LibBalsaIdentity *ident, const gchar *domain);
+void libbalsa_identity_set_smtp_server(LibBalsaIdentity * ident,
+                                       LibBalsaSmtpServer *smtp_server);
+
+/* Widgets */
+void libbalsa_identity_config_dialog(GtkWindow * parent,
+                                     GList ** identities,
+                                     LibBalsaIdentity ** current,
                                                                                 GSList * smtp_servers,
-                                         void (*changed_cb)(gpointer));
-
-    typedef void (*LibBalsaIdentityCallback) (gpointer data,
-                                              LibBalsaIdentity * identity);
-    void libbalsa_identity_select_dialog(GtkWindow * parent,
-                                         const gchar * prompt,
-                                         GList * identities,
-                                         LibBalsaIdentity * initial_id,
-                                         LibBalsaIdentityCallback update,
-                                         gpointer data);
-    GtkWidget * libbalsa_identity_combo_box(GList       * identities,
-                                            const gchar * active_name,
-                                            GCallback     changed_cb,
-                                            gpointer      changed_data);
-
-    LibBalsaIdentity* libbalsa_identity_new_config(const gchar* name);
-    void libbalsa_identity_save(LibBalsaIdentity* id, const gchar* prefix);
+                                     void (*changed_cb)(gpointer));
+
+typedef void (*LibBalsaIdentityCallback) (gpointer data,
+                                          LibBalsaIdentity * identity);
+void libbalsa_identity_select_dialog(GtkWindow * parent,
+                                     const gchar * prompt,
+                                     GList * identities,
+                                     LibBalsaIdentity * initial_id,
+                                     LibBalsaIdentityCallback update,
+                                     gpointer data);
+GtkWidget * libbalsa_identity_combo_box(GList       * identities,
+                                        const gchar * active_name,
+                                        GCallback     changed_cb,
+                                        gpointer      changed_data);
+
+LibBalsaIdentity* libbalsa_identity_new_config(const gchar* name);
+void libbalsa_identity_save(LibBalsaIdentity* id, const gchar* prefix);
+
+/*
+ * Getters
+ */
 
+gboolean     libbalsa_identity_get_sig_prepend(LibBalsaIdentity *ident);
+gboolean     libbalsa_identity_get_sig_whenreply(LibBalsaIdentity *ident);
+gboolean     libbalsa_identity_get_sig_whenforward(LibBalsaIdentity *ident);
+gboolean     libbalsa_identity_get_sig_sending(LibBalsaIdentity *ident);
+gboolean     libbalsa_identity_get_send_mp_alternative(LibBalsaIdentity *ident);
+gboolean     libbalsa_identity_get_request_mdn(LibBalsaIdentity *ident);
+gboolean     libbalsa_identity_get_request_dsn(LibBalsaIdentity *ident);
+gboolean     libbalsa_identity_get_warn_send_plain(LibBalsaIdentity *ident);
+gboolean     libbalsa_identity_get_always_trust(LibBalsaIdentity *ident);
+gboolean     libbalsa_identity_get_gpg_sign(LibBalsaIdentity *ident);
+gboolean     libbalsa_identity_get_gpg_encrypt(LibBalsaIdentity *ident);
+gboolean     libbalsa_identity_get_sig_executable(LibBalsaIdentity *ident);
+gboolean     libbalsa_identity_get_sig_separator(LibBalsaIdentity *ident);
+gint         libbalsa_identity_get_crypt_protocol(LibBalsaIdentity *ident);
+gchar* libbalsa_identity_get_signature(LibBalsaIdentity *ident, GError **error);
+const gchar *libbalsa_identity_get_identity_name(LibBalsaIdentity *ident);
+const gchar *libbalsa_identity_get_force_gpg_key_id(LibBalsaIdentity *ident);
+const gchar *libbalsa_identity_get_force_smime_key_id(LibBalsaIdentity *ident);
+const gchar *libbalsa_identity_get_replyto(LibBalsaIdentity *ident);
+const gchar *libbalsa_identity_get_bcc(LibBalsaIdentity *ident);
+const gchar *libbalsa_identity_get_reply_string(LibBalsaIdentity *ident);
+const gchar *libbalsa_identity_get_forward_string(LibBalsaIdentity *ident);
+const gchar *libbalsa_identity_get_domain(LibBalsaIdentity *ident);
+const gchar *libbalsa_identity_get_face_path(LibBalsaIdentity *ident);
+const gchar *libbalsa_identity_get_x_face_path(LibBalsaIdentity *ident);
+const gchar *libbalsa_identity_get_signature_path(LibBalsaIdentity *ident);
+InternetAddress *libbalsa_identity_get_address(LibBalsaIdentity *ident);
+LibBalsaSmtpServer *libbalsa_identity_get_smtp_server(LibBalsaIdentity *ident);
+#ifdef ENABLE_AUTOCRYPT
+AutocryptMode libbalsa_identity_get_autocrypt_mode(LibBalsaIdentity *ident);
+#endif
 
 G_END_DECLS
 
diff --git a/libbalsa/send.c b/libbalsa/send.c
index 8ba6178b4..ba2854e84 100644
--- a/libbalsa/send.c
+++ b/libbalsa/send.c
@@ -1482,7 +1482,8 @@ libbalsa_message_create_mime_message(LibBalsaMessage *message,
 
 #ifdef ENABLE_AUTOCRYPT
     /* add Autocrypt header if requested */
-    if (!postponing && (message->ident != NULL) && (message->ident->autocrypt_mode != AUTOCRYPT_DISABLE) &&
+    if (!postponing && (message->ident != NULL) &&
+        (libbalsa_identity_get_autocrypt_mode(message->ident) != AUTOCRYPT_DISABLE) &&
        !autocrypt_ignore(g_mime_object_get_content_type(mime_root))) {
        tmp = autocrypt_header(message->ident, error);
        if (tmp == NULL) {
@@ -1695,27 +1696,33 @@ libbalsa_fill_msg_queue_item_from_queu(LibBalsaMessage  *message,
  * "From:" address list to let GpeME automagically select the proper key.
  */
 static const gchar *
-lb_send_from(LibBalsaMessage  *message,
-                        gpgme_protocol_t  protocol)
+lb_send_from(LibBalsaMessage * message, gpgme_protocol_t protocol)
 {
-       const gchar *from_id;
-
-       if ((protocol == GPGME_PROTOCOL_OpenPGP) &&
-               (message->ident->force_gpg_key_id != NULL) &&
-               (message->ident->force_gpg_key_id[0] != '\0')) {
-               from_id = message->ident->force_gpg_key_id;
-       } else if ((protocol == GPGME_PROTOCOL_CMS) &&
-               (message->ident->force_smime_key_id != NULL) &&
-               (message->ident->force_smime_key_id[0] != '\0')) {
-               from_id = message->ident->force_smime_key_id;
-       } else {
-               InternetAddress *ia = internet_address_list_get_address(message->headers->from, 0);
+    const gchar *from_id;
+    const gchar *key_id;
+
+    if ((protocol == GPGME_PROTOCOL_OpenPGP) &&
+        ((key_id =
+          libbalsa_identity_get_force_gpg_key_id(message->ident)) != NULL)
+        && (key_id[0] != '\0')) {
+        from_id = key_id;
+    } else if ((protocol == GPGME_PROTOCOL_CMS) &&
+               ((key_id =
+                 libbalsa_identity_get_force_smime_key_id(message->
+                                                          ident)) != NULL)
+               && (key_id[0] != '\0')) {
+        from_id = key_id;
+    } else {
+        InternetAddress *ia =
+            internet_address_list_get_address(message->headers->from, 0);
 
-               while (INTERNET_ADDRESS_IS_GROUP(ia)) {
-                       ia = internet_address_list_get_address(((InternetAddressGroup *) ia)->members, 0);
-               }
-               from_id = ((InternetAddressMailbox *) ia)->addr;
-       }
+        while (INTERNET_ADDRESS_IS_GROUP(ia)) {
+            ia = internet_address_list_get_address(((InternetAddressGroup
+                                                     *) ia)->members, 0);
+        }
+
+        from_id = ((InternetAddressMailbox *) ia)->addr;
+    }
 
     return from_id;
 }
diff --git a/src/balsa-message.c b/src/balsa-message.c
index 614f7f2c4..23b33335e 100644
--- a/src/balsa-message.c
+++ b/src/balsa-message.c
@@ -2440,8 +2440,10 @@ handle_mdn_request(GtkWindow *parent, LibBalsaMessage *message)
         for (id_list = balsa_app.identities; !mdn_ident && id_list;
              id_list = id_list->next) {
             LibBalsaIdentity *ident = LIBBALSA_IDENTITY(id_list->data);
+            InternetAddress *ia;
 
-            if (libbalsa_ia_rfc2821_equal(ident->ia, bm_get_mailbox(list)))
+            ia = libbalsa_identity_get_address(ident);
+            if (libbalsa_ia_rfc2821_equal(ia, bm_get_mailbox(list)))
                 mdn_ident = ident;
         }
     }
@@ -2453,8 +2455,10 @@ handle_mdn_request(GtkWindow *parent, LibBalsaMessage *message)
         for (id_list = balsa_app.identities; !mdn_ident && id_list;
              id_list = id_list->next) {
             LibBalsaIdentity *ident = LIBBALSA_IDENTITY(id_list->data);
+            InternetAddress *ia;
 
-            if (libbalsa_ia_rfc2821_equal(ident->ia, bm_get_mailbox(list)))
+            ia = libbalsa_identity_get_address(ident);
+            if (libbalsa_ia_rfc2821_equal(ia, bm_get_mailbox(list)))
                 mdn_ident = ident;
         }
     }
@@ -2495,7 +2499,7 @@ handle_mdn_request(GtkWindow *parent, LibBalsaMessage *message)
 
         result = libbalsa_message_send(mdn, balsa_app.outbox, NULL,
                                       balsa_find_sentbox_by_url,
-                                      mdn_ident->smtp_server,
+                                      libbalsa_identity_get_smtp_server(mdn_ident),
                                           balsa_app.send_progress_dialog,
                                        parent,
                                       TRUE, &error);
@@ -2524,7 +2528,7 @@ static LibBalsaMessage *create_mdn_reply (const LibBalsaIdentity *mdn_ident,
     message = libbalsa_message_new();
     message->headers->from = internet_address_list_new();
     internet_address_list_add(message->headers->from,
-                              balsa_app.current_ident->ia);
+                              libbalsa_identity_get_address(balsa_app.current_ident));
     message->headers->date = time(NULL);
     libbalsa_message_set_subject(message, "Message Disposition Notification");
     message->headers->to_list = internet_address_list_new ();
@@ -2569,9 +2573,9 @@ static LibBalsaMessage *create_mdn_reply (const LibBalsaIdentity *mdn_ident,
        g_string_append_printf(report, "Original-Recipient: %s\n",
                               original_rcpt);
     g_string_append_printf(report, "Final-Recipient: rfc822; %s\n",
-                           INTERNET_ADDRESS_MAILBOX(balsa_app.
-                                                    current_ident->ia)->
-                           addr);
+                           INTERNET_ADDRESS_MAILBOX
+                           (libbalsa_identity_get_address
+                            (balsa_app.current_ident))->addr);
     if (for_msg->message_id)
         g_string_append_printf(report, "Original-Message-ID: <%s>\n",
                                for_msg->message_id);
@@ -2636,8 +2640,8 @@ mdn_dialog_response(GtkWidget * dialog, gint response, gpointer user_data)
         result =
             libbalsa_message_send(send_msg, balsa_app.outbox, NULL,
                                   balsa_find_sentbox_by_url,
-                                  mdn_ident->smtp_server,
-                                                                 balsa_app.send_progress_dialog,
+                                 libbalsa_identity_get_smtp_server(mdn_ident),
+                                  balsa_app.send_progress_dialog,
                                   gtk_window_get_transient_for
                                   ((GtkWindow *) dialog),
                                   TRUE, &error);
@@ -3342,7 +3346,9 @@ autocrypt_in_use(void)
        GList *ident;
 
        for (ident = balsa_app.identities; !result && (ident != NULL); ident = ident->next) {
-               result = LIBBALSA_IDENTITY(ident->data)->autocrypt_mode != AUTOCRYPT_DISABLE;
+                LibBalsaIdentity *identity = LIBBALSA_IDENTITY(ident->data);
+                AutocryptMode autocrypt_mode = libbalsa_identity_get_autocrypt_mode(identity);
+               result = autocrypt_mode != AUTOCRYPT_DISABLE;
        }
        return result;
 }
diff --git a/src/balsa-mime-widget-message.c b/src/balsa-mime-widget-message.c
index 01cf8a6c1..2fb251c10 100644
--- a/src/balsa-mime-widget-message.c
+++ b/src/balsa-mime-widget-message.c
@@ -336,7 +336,7 @@ extbody_send_mail(GtkWidget * button, LibBalsaMessageBody * mime_body)
     message = libbalsa_message_new();
     message->headers->from = internet_address_list_new();
     internet_address_list_add(message->headers->from,
-                              balsa_app.current_ident->ia);
+                              libbalsa_identity_get_address(balsa_app.current_ident));
 
     data = libbalsa_message_body_get_parameter(mime_body, "subject");
     if (data) {
@@ -375,7 +375,8 @@ extbody_send_mail(GtkWidget * button, LibBalsaMessageBody * mime_body)
     libbalsa_message_append_part(message, body);
     result = libbalsa_message_send(message, balsa_app.outbox, NULL,
                                   balsa_find_sentbox_by_url,
-                                  balsa_app.current_ident->smtp_server,
+                                  libbalsa_identity_get_smtp_server
+                                   (balsa_app.current_ident),
                                   balsa_app.send_progress_dialog,
                                    GTK_WINDOW(gtk_widget_get_toplevel
                                               (button)),
diff --git a/src/balsa-mime-widget-vcalendar.c b/src/balsa-mime-widget-vcalendar.c
index aee834a5d..c50912b97 100644
--- a/src/balsa-mime-widget-vcalendar.c
+++ b/src/balsa-mime-widget-vcalendar.c
@@ -195,7 +195,8 @@ balsa_vevent_widget(LibBalsaVEvent * event, gboolean may_reply,
 
                 for (list = balsa_app.identities; list; list = list->next) {
                     LibBalsaIdentity *ident = list->data;
-                    if (libbalsa_ia_rfc2821_equal(ident->ia, ia)) {
+                    if (libbalsa_ia_rfc2821_equal(libbalsa_identity_get_address(ident),
+                                                  ia)) {
                         vevent_ident = ident;
                         break;
                     }
@@ -281,12 +282,14 @@ vevent_reply(GObject * button, GtkWidget * box)
     GError *error = NULL;
     LibBalsaMsgCreateResult result;
     LibBalsaIdentity *ident;
+    InternetAddress *ia;
 
     g_return_if_fail(event != NULL);
     rcpt = (gchar *) g_object_get_data(G_OBJECT(event), "ev:sender");
     g_return_if_fail(rcpt != NULL);
     ident = g_object_get_data(G_OBJECT(event), "ev:ident");
     g_return_if_fail(ident != NULL);
+    ia = libbalsa_identity_get_address(ident);
 
     /* make the button box insensitive... */
     gtk_widget_set_sensitive(box, FALSE);
@@ -294,7 +297,7 @@ vevent_reply(GObject * button, GtkWidget * box)
     /* create a message with the header set from the incoming message */
     message = libbalsa_message_new();
     message->headers->from = internet_address_list_new();
-    internet_address_list_add(message->headers->from, ident->ia);
+    internet_address_list_add(message->headers->from, ia);
     message->headers->to_list = internet_address_list_parse_string(rcpt);
     message->headers->date = time(NULL);
 
@@ -309,7 +312,7 @@ vevent_reply(GObject * button, GtkWidget * box)
     body = libbalsa_message_body_new(message);
     body->buffer =
        libbalsa_vevent_reply(event,
-                             INTERNET_ADDRESS_MAILBOX(ident->ia)->addr,
+                             INTERNET_ADDRESS_MAILBOX(ia)->addr,
                              pstat);
     body->charset = g_strdup("utf-8");
     body->content_type = g_strdup("text/calendar");
@@ -324,7 +327,7 @@ vevent_reply(GObject * button, GtkWidget * box)
 
     result = libbalsa_message_send(message, balsa_app.outbox, NULL,
                                   balsa_find_sentbox_by_url,
-                                  ident->smtp_server,
+                                  libbalsa_identity_get_smtp_server(ident),
                                   balsa_app.send_progress_dialog,
                                    GTK_WINDOW(gtk_widget_get_toplevel
                                               ((GtkWidget *) button)),
diff --git a/src/mailbox-conf.c b/src/mailbox-conf.c
index 6826d473a..8af6bff42 100644
--- a/src/mailbox-conf.c
+++ b/src/mailbox-conf.c
@@ -1015,7 +1015,8 @@ mailbox_conf_view_check(BalsaMailboxConfView * view_info,
 
         model = gtk_combo_box_get_model(combo_box);
         gtk_tree_model_get(model, &iter, 2, &ident, -1);
-        libbalsa_mailbox_set_identity_name(mailbox, ident->identity_name);
+        libbalsa_mailbox_set_identity_name(mailbox,
+                                           libbalsa_identity_get_identity_name(ident));
         g_object_unref(ident);
         changed = TRUE;
     }
diff --git a/src/save-restore.c b/src/save-restore.c
index ec607da31..3ecc19dac 100644
--- a/src/save-restore.c
+++ b/src/save-restore.c
@@ -1665,7 +1665,8 @@ config_identity_load(const gchar * key, const gchar * value, gpointer data)
     g_free(smtp_server_name);
     libbalsa_conf_pop_group();
     balsa_app.identities = g_list_prepend(balsa_app.identities, ident);
-    if (g_ascii_strcasecmp(default_ident, ident->identity_name) == 0)
+    if (g_ascii_strcasecmp(libbalsa_identity_get_identity_name(ident),
+                           default_ident) == 0)
         balsa_app.current_ident = ident;
 
     return FALSE;
@@ -1717,8 +1718,9 @@ config_identities_save(void)
     gchar *prefix;
 
     libbalsa_conf_push_group("identity");
-    libbalsa_conf_set_string("CurrentIdentity", 
-                            balsa_app.current_ident->identity_name);
+    libbalsa_conf_set_string("CurrentIdentity",
+                             libbalsa_identity_get_identity_name
+                             (balsa_app.current_ident));
     libbalsa_conf_pop_group();
 
     config_remove_groups(IDENTITY_SECTION_PREFIX);
@@ -1727,7 +1729,7 @@ config_identities_save(void)
     for (list = balsa_app.identities; list; list = list->next) {
        ident = LIBBALSA_IDENTITY(list->data);
        prefix = g_strconcat(IDENTITY_SECTION_PREFIX, 
-                            ident->identity_name, NULL);
+                            libbalsa_identity_get_identity_name(ident), NULL);
         libbalsa_identity_save(ident, prefix);
        g_free(prefix);
     }
diff --git a/src/sendmsg-window.c b/src/sendmsg-window.c
index cfd791a15..f392deedd 100644
--- a/src/sendmsg-window.c
+++ b/src/sendmsg-window.c
@@ -931,20 +931,22 @@ replace_identity_signature(BalsaSendmsg* bsmsg, LibBalsaIdentity* new_ident,
     case SEND_REPLY:
     case SEND_REPLY_ALL:
     case SEND_REPLY_GROUP:
-        insert_signature = new_ident->sig_whenreply;
+        insert_signature = libbalsa_identity_get_sig_whenreply(new_ident);
         break;
     case SEND_FORWARD_ATTACH:
     case SEND_FORWARD_INLINE:
-        insert_signature = new_ident->sig_whenforward;
+        insert_signature = libbalsa_identity_get_sig_whenforward(new_ident);
         break;
     }
     if (insert_signature) {
+        gboolean new_sig_prepend = libbalsa_identity_get_sig_prepend(new_ident);
+        gboolean old_sig_prepend = libbalsa_identity_get_sig_prepend(old_ident);
 
         /* see if sig location is probably going to be the same */
-        if (new_ident->sig_prepend == old_ident->sig_prepend) {
+        if (new_sig_prepend == old_sig_prepend) {
             /* account for sig length difference in replacement offset */
             *replace_offset += newsiglen - siglen;
-        } else if (new_ident->sig_prepend) {
+        } else if (new_sig_prepend) {
             /* sig location not the same between idents, take a WAG and
              * put it at the start of the message */
             gtk_text_buffer_get_start_iter(buffer, &ins);
@@ -1085,6 +1087,11 @@ update_bsmsg_identity(BalsaSendmsg* bsmsg, LibBalsaIdentity* ident)
     gchar* tmpstr;
     const gchar* subject;
     gint replen, fwdlen;
+    const gchar *addr;
+    const gchar *reply_string;
+    const gchar *old_reply_string;
+    const gchar *forward_string;
+    const gchar *old_forward_string;
 
     LibBalsaIdentity* old_ident;
     gboolean reply_type = (bsmsg->type == SEND_REPLY ||
@@ -1100,10 +1107,11 @@ update_bsmsg_identity(BalsaSendmsg* bsmsg, LibBalsaIdentity* ident)
     gtk_combo_box_set_active(GTK_COMBO_BOX(bsmsg->from[1]),
                              g_list_index(balsa_app.identities, ident));
 
-    if (ident->replyto && *ident->replyto) {
+    addr = libbalsa_identity_get_replyto(ident);
+    if (addr != NULL && addr[0] != '\0') {
         libbalsa_address_view_set_from_string(bsmsg->replyto_view,
                                               "Reply To:",
-                                              ident->replyto);
+                                              addr);
         gtk_widget_show(bsmsg->replyto[0]);
         gtk_widget_show(bsmsg->replyto[1]);
     } else if (!sw_action_get_active(bsmsg, "reply-to")) {
@@ -1111,13 +1119,14 @@ update_bsmsg_identity(BalsaSendmsg* bsmsg, LibBalsaIdentity* ident)
         gtk_widget_hide(bsmsg->replyto[1]);
     }
 
-    if (bsmsg->ident->bcc) {
+    addr = libbalsa_identity_get_bcc(bsmsg->ident);
+    if (addr != NULL) {
         InternetAddressList *bcc_list, *ident_list;
 
         bcc_list =
             libbalsa_address_view_get_list(bsmsg->recipient_view, "BCC:");
 
-        ident_list = internet_address_list_parse_string(bsmsg->ident->bcc);
+        ident_list = internet_address_list_parse_string(addr);
         if (ident_list) {
             /* Remove any Bcc addresses that came from the old identity
              * from the list. */
@@ -1146,7 +1155,8 @@ update_bsmsg_identity(BalsaSendmsg* bsmsg, LibBalsaIdentity* ident)
         }
 
         /* Add the new Bcc addresses, if any: */
-        ident_list = internet_address_list_parse_string(ident->bcc);
+        addr = libbalsa_identity_get_bcc(ident);
+        ident_list = internet_address_list_parse_string(addr);
         if (ident_list) {
             internet_address_list_append(bcc_list, ident_list);
             g_object_unref(ident_list);
@@ -1174,15 +1184,21 @@ update_bsmsg_identity(BalsaSendmsg* bsmsg, LibBalsaIdentity* ident)
      *    not want it altered
      */
 
+    reply_string = libbalsa_identity_get_reply_string(ident);
+    forward_string = libbalsa_identity_get_forward_string(ident);
+
     old_ident = bsmsg->ident;
-    if (((replen = strlen(old_ident->reply_string)) > 0) &&
-       (strncmp(subject, old_ident->reply_string, replen) == 0)) {
-       tmpstr = g_strconcat(ident->reply_string, &(subject[replen]), NULL);
+    old_reply_string = libbalsa_identity_get_reply_string(old_ident);
+    old_forward_string = libbalsa_identity_get_forward_string(old_ident);
+
+    if (((replen = strlen(old_forward_string)) > 0) &&
+       (strncmp(subject, old_reply_string, replen) == 0)) {
+       tmpstr = g_strconcat(reply_string, &(subject[replen]), NULL);
        gtk_entry_set_text(GTK_ENTRY(bsmsg->subject[1]), tmpstr);
        g_free(tmpstr);
-    } else if (((fwdlen = strlen(old_ident->forward_string)) > 0) &&
-              (strncmp(subject, old_ident->forward_string, fwdlen) == 0)) {
-       tmpstr = g_strconcat(ident->forward_string, &(subject[fwdlen]), NULL);
+    } else if (((fwdlen = strlen(old_forward_string)) > 0) &&
+              (strncmp(subject, old_forward_string, fwdlen) == 0)) {
+       tmpstr = g_strconcat(forward_string, &(subject[fwdlen]), NULL);
        gtk_entry_set_text(GTK_ENTRY(bsmsg->subject[1]), tmpstr);
        g_free(tmpstr);
     } else {
@@ -1199,17 +1215,15 @@ update_bsmsg_identity(BalsaSendmsg* bsmsg, LibBalsaIdentity* ident)
      * the signature if path changed */
 
     /* reconstruct the old signature to search with */
-    old_sig = libbalsa_identity_get_signature(old_ident,
-                                              GTK_WINDOW(bsmsg->window));
+    old_sig = libbalsa_identity_get_signature(old_ident, NULL);
 
     /* switch identities in bsmsg here so we can use read_signature
      * again */
     bsmsg->ident = ident;
-    if ( (reply_type && ident->sig_whenreply)
-         || (forward_type && ident->sig_whenforward)
-         || (bsmsg->type == SEND_NORMAL && ident->sig_sending))
-        new_sig = libbalsa_identity_get_signature(ident,
-                                                  GTK_WINDOW(bsmsg->window));
+    if ( (reply_type && libbalsa_identity_get_sig_whenreply(ident))
+         || (forward_type && libbalsa_identity_get_sig_whenforward(ident))
+         || (bsmsg->type == SEND_NORMAL && libbalsa_identity_get_sig_sending(ident)))
+        new_sig = libbalsa_identity_get_signature(ident, NULL);
     else
         new_sig = NULL;
     if(!new_sig) new_sig = g_strdup("");
@@ -1217,7 +1231,7 @@ update_bsmsg_identity(BalsaSendmsg* bsmsg, LibBalsaIdentity* ident)
     gtk_text_buffer_get_bounds(buffer, &start, &end);
     message_text = gtk_text_iter_get_text(&start, &end);
     if (!old_sig) {
-        replace_offset = bsmsg->ident->sig_prepend
+        replace_offset = libbalsa_identity_get_sig_prepend(bsmsg->ident)
             ? 0 : g_utf8_strlen(message_text, -1);
         replace_identity_signature(bsmsg, ident, old_ident, &replace_offset,
                                    0, new_sig);
@@ -1288,7 +1302,8 @@ update_bsmsg_identity(BalsaSendmsg* bsmsg, LibBalsaIdentity* ident)
         }
         g_strfreev(message_split);
     }
-    sw_action_set_active(bsmsg, "send-html", bsmsg->ident->send_mp_alternative);
+    sw_action_set_active(bsmsg, "send-html",
+                         libbalsa_identity_get_send_mp_alternative(bsmsg->ident));
 
     bsmsg_update_gpg_ui_on_ident_change(bsmsg, ident);
 
@@ -1296,10 +1311,10 @@ update_bsmsg_identity(BalsaSendmsg* bsmsg, LibBalsaIdentity* ident)
     g_free(new_sig);
     g_free(message_text);
 
-    libbalsa_address_view_set_domain(bsmsg->recipient_view, ident->domain);
+    libbalsa_address_view_set_domain(bsmsg->recipient_view, libbalsa_identity_get_domain(ident));
 
-    sw_action_set_active(bsmsg, "request-mdn", ident->request_mdn);
-    sw_action_set_active(bsmsg, "request-dsn", ident->request_dsn);
+    sw_action_set_active(bsmsg, "request-mdn", libbalsa_identity_get_request_mdn(ident));
+    sw_action_set_active(bsmsg, "request-dsn", libbalsa_identity_get_request_dsn(ident));
 }
 
 
@@ -2386,7 +2401,7 @@ create_email_entry(BalsaSendmsg         * bsmsg,
                          G_N_ELEMENTS(email_field_drop_types),
                      GDK_ACTION_COPY | GDK_ACTION_MOVE);
 
-    libbalsa_address_view_set_domain(*view, bsmsg->ident->domain);
+    libbalsa_address_view_set_domain(*view, libbalsa_identity_get_domain(bsmsg->ident));
     g_signal_connect_swapped(gtk_tree_view_get_model(GTK_TREE_VIEW(*view)),
                              "row-changed", G_CALLBACK(check_readiness),
                              bsmsg);
@@ -3744,11 +3759,10 @@ sw_insert_sig_activated(GSimpleAction * action,
 {
     BalsaSendmsg *bsmsg = data;
     gchar *signature;
+    GError *error = NULL;
+
+    signature = libbalsa_identity_get_signature(bsmsg->ident, &error);
 
-    if(!bsmsg->ident->signature_path || !bsmsg->ident->signature_path[0])
-        return;
-    signature = libbalsa_identity_get_signature(bsmsg->ident,
-                                                GTK_WINDOW(bsmsg->window));
     if (signature != NULL) {
         GtkTextBuffer *buffer =
             gtk_text_view_get_buffer(GTK_TEXT_VIEW(bsmsg->text));
@@ -3760,10 +3774,12 @@ sw_insert_sig_activated(GSimpleAction * action,
         sw_buffer_signals_unblock(bsmsg, buffer);
 
        g_free(signature);
-    } else
+    } else if (error != NULL) {
         balsa_information_parented(GTK_WINDOW(bsmsg->window),
                                    LIBBALSA_INFORMATION_ERROR,
-                                   _("No signature found!"));
+                                   error->message);
+        g_error_free(error);
+    }
 }
 
 
@@ -3787,15 +3803,16 @@ generate_forwarded_subject(const char *orig_subject,
                            LibBalsaIdentity       *ident)
 {
     char *newsubject;
+    const gchar *forward_string = libbalsa_identity_get_forward_string(ident);
 
     if (!orig_subject) {
         if (headers && headers->from)
             newsubject = g_strdup_printf("%s from %s",
-                                         ident->forward_string,
+                                         forward_string,
                                          libbalsa_address_get_mailbox_from_list
                                          (headers->from));
         else
-            newsubject = g_strdup(ident->forward_string);
+            newsubject = g_strdup(forward_string);
     } else {
         const char *tmp = orig_subject;
         if (g_ascii_strncasecmp(tmp, "fwd:", 4) == 0) {
@@ -3804,8 +3821,8 @@ generate_forwarded_subject(const char *orig_subject,
                                        strlen(_("Fwd:"))) == 0) {
             tmp += strlen(_("Fwd:"));
         } else {
-            size_t i = strlen(ident->forward_string);
-            if (g_ascii_strncasecmp(tmp, ident->forward_string, i) == 0) {
+            size_t i = strlen(forward_string);
+            if (g_ascii_strncasecmp(tmp, forward_string, i) == 0) {
                 tmp += i;
             }
         }
@@ -3813,14 +3830,14 @@ generate_forwarded_subject(const char *orig_subject,
         if (headers && headers->from)
             newsubject =
                 g_strdup_printf("%s %s [%s]",
-                                ident->forward_string,
+                                forward_string,
                                 tmp,
                                 libbalsa_address_get_mailbox_from_list
                                 (headers->from));
         else {
             newsubject =
                 g_strdup_printf("%s %s",
-                                ident->forward_string,
+                                forward_string,
                                 tmp);
             g_strchomp(newsubject);
         }
@@ -3836,6 +3853,7 @@ bsmsg_set_subject_from_body(BalsaSendmsg * bsmsg,
                             LibBalsaMessageBody * part,
                             LibBalsaIdentity * ident)
 {
+    const gchar *reply_string = libbalsa_identity_get_reply_string(ident);
     gchar *subject;
 
     if (!part)
@@ -3852,7 +3870,7 @@ bsmsg_set_subject_from_body(BalsaSendmsg * bsmsg,
         case SEND_REPLY_ALL:
         case SEND_REPLY_GROUP:
             if (!subject) {
-                subject = g_strdup(ident->reply_string);
+                subject = g_strdup(reply_string);
                 break;
             }
 
@@ -3864,13 +3882,13 @@ bsmsg_set_subject_from_body(BalsaSendmsg * bsmsg,
                        == 0)
                 tmp += strlen(_("Re:"));
             else {
-                gint len = strlen(ident->reply_string);
-                if (g_ascii_strncasecmp(tmp, ident->reply_string, len) == 0)
+                gint len = strlen(reply_string);
+                if (g_ascii_strncasecmp(tmp, reply_string, len) == 0)
                     tmp += len;
             }
             while (*tmp && isspace((int) *tmp))
                 tmp++;
-            newsubject = g_strdup_printf("%s %s", ident->reply_string, tmp);
+            newsubject = g_strdup_printf("%s %s", reply_string, tmp);
             g_strchomp(newsubject);
             g_strdelimit(newsubject, "\r\n", ' ');
             break;
@@ -3982,28 +4000,29 @@ setup_headers_from_message(BalsaSendmsg* bsmsg, LibBalsaMessage *message)
  * the message.
  **/
 static gboolean
-set_identity_from_mailbox(BalsaSendmsg* bsmsg, LibBalsaMessage * message)
+set_identity_from_mailbox(BalsaSendmsg *bsmsg, LibBalsaMessage *message)
 {
     const gchar *identity;
-
-    LibBalsaIdentity* ident;
     GList *ilist;
 
-    if( message && message->mailbox && balsa_app.identities) {
-        identity = libbalsa_mailbox_get_identity_name(message->mailbox);
-        if(!identity) return FALSE;
-        for (ilist = balsa_app.identities;
-             ilist != NULL;
-             ilist = g_list_next(ilist)) {
-            ident = LIBBALSA_IDENTITY(ilist->data);
-            if (!g_ascii_strcasecmp(identity, ident->identity_name)) {
-                bsmsg->ident = ident;
-                return TRUE;
-            }
+    if (message == NULL || message->mailbox == NULL)
+        return FALSE;
+
+    identity = libbalsa_mailbox_get_identity_name(message->mailbox);
+    if (identity == NULL)
+        return FALSE;
+
+    for (ilist = balsa_app.identities; ilist != NULL; ilist = ilist->next) {
+        LibBalsaIdentity *ident = LIBBALSA_IDENTITY(ilist->data);
+        const gchar *name = libbalsa_identity_get_identity_name(ident);
+
+        if (g_ascii_strcasecmp(name, identity) == 0) {
+            bsmsg->ident = ident;
+            return TRUE;
         }
     }
 
-    return FALSE; /* use default */
+    return FALSE;               /* use default */
 }
 
 /*
@@ -4015,6 +4034,7 @@ set_identity_from_mailbox(BalsaSendmsg* bsmsg, LibBalsaMessage * message)
  **/
 /* First a helper; groups cannot be nested, and are not allowed in the
  * From: list. */
+/* Update: RFC 6854 allows groups in "From:" and "Sender:" */
 static gboolean
 guess_identity_from_list(BalsaSendmsg * bsmsg, InternetAddressList * list,
                          gboolean allow_group)
@@ -4024,6 +4044,7 @@ guess_identity_from_list(BalsaSendmsg * bsmsg, InternetAddressList * list,
     if (!list)
         return FALSE;
 
+    allow_group = TRUE;
     for (i = 0; i < internet_address_list_length(list); i++) {
         InternetAddress *ia = internet_address_list_get_address(list, i);
 
@@ -4038,7 +4059,8 @@ guess_identity_from_list(BalsaSendmsg * bsmsg, InternetAddressList * list,
 
             for (l = balsa_app.identities; l; l = l->next) {
                 LibBalsaIdentity *ident = LIBBALSA_IDENTITY(l->data);
-                if (libbalsa_ia_rfc2821_equal(ia, ident->ia)) {
+                if (libbalsa_ia_rfc2821_equal(libbalsa_identity_get_address(ident),
+                                              ia)) {
                     bsmsg->ident = ident;
                     return TRUE;
                 }
@@ -4074,16 +4096,22 @@ guess_identity(BalsaSendmsg* bsmsg, LibBalsaMessage * message)
 static void
 setup_headers_from_identity(BalsaSendmsg* bsmsg, LibBalsaIdentity *ident)
 {
+    const gchar *addr;
+
     gtk_combo_box_set_active(GTK_COMBO_BOX(bsmsg->from[1]),
                              g_list_index(balsa_app.identities, ident));
-    if(ident->replyto)
+
+    addr = libbalsa_identity_get_replyto(ident);
+    if (addr != NULL)
         libbalsa_address_view_set_from_string(bsmsg->replyto_view,
                                               "Reply To:",
-                                              ident->replyto);
-    if(ident->bcc)
+                                              addr);
+
+    addr = libbalsa_identity_get_bcc(ident);
+    if (addr != NULL)
         libbalsa_address_view_set_from_string(bsmsg->recipient_view,
                                               "BCC:",
-                                              ident->bcc);
+                                              addr);
 
     /* Make sure the blank line is "To:" */
     libbalsa_address_view_add_from_string(bsmsg->recipient_view,
@@ -4309,14 +4337,15 @@ sw_cc_add_list(InternetAddressList **new_cc, InternetAddressList * list)
 
     for (i = 0; i < internet_address_list_length(list); i++) {
         InternetAddress *ia = internet_address_list_get_address (list, i);
-       GList *ident;
+       GList *ilist;
 
        /* do not insert any of my identities into the cc: list */
-       for (ident = balsa_app.identities; ident; ident = ident->next)
+       for (ilist = balsa_app.identities; ilist != NULL; ilist = ilist->next) {
            if (libbalsa_ia_rfc2821_equal
-               (ia, LIBBALSA_IDENTITY(ident->data)->ia))
+               (ia, libbalsa_identity_get_address(ilist->data)))
                break;
-       if (!ident) {
+        }
+       if (ilist == NULL) {
             if (*new_cc == NULL)
                 *new_cc = internet_address_list_new();
            internet_address_list_add(*new_cc, ia);
@@ -4331,7 +4360,7 @@ insert_initial_sig(BalsaSendmsg *bsmsg)
     GtkTextBuffer *buffer =
         gtk_text_view_get_buffer(GTK_TEXT_VIEW(bsmsg->text));
 
-    if(bsmsg->ident->sig_prepend)
+    if(libbalsa_identity_get_sig_prepend(bsmsg->ident))
         gtk_text_buffer_get_start_iter(buffer, &sig_pos);
     else
         gtk_text_buffer_get_end_iter(buffer, &sig_pos);
@@ -4919,13 +4948,14 @@ bsmsg2message(BalsaSendmsg * bsmsg)
     gchar *tmp;
     GtkTextIter start, end;
     LibBalsaIdentity *ident = bsmsg->ident;
+    InternetAddress *ia = libbalsa_identity_get_address(ident);
     GtkTextBuffer *buffer;
     GtkTextBuffer *new_buffer = NULL;
 
     message = libbalsa_message_new();
 
     message->headers->from = internet_address_list_new ();
-    internet_address_list_add(message->headers->from, ident->ia);
+    internet_address_list_add(message->headers->from, ia);
 
     tmp = gtk_editable_get_chars(GTK_EDITABLE(bsmsg->subject[1]), 0, -1);
     strip_chars(tmp, "\r\n");
@@ -4950,13 +4980,13 @@ bsmsg2message(BalsaSendmsg * bsmsg)
         libbalsa_address_view_get_list(bsmsg->replyto_view, "Reply To:");
 
     if (bsmsg->req_mdn)
-       libbalsa_message_set_dispnotify(message, ident->ia);
+       libbalsa_message_set_dispnotify(message, ia);
     message->request_dsn = bsmsg->req_dsn;
 
-    sw_set_header_from_path(message, "Face", ident->face,
+    sw_set_header_from_path(message, "Face", libbalsa_identity_get_face_path(ident),
             /* Translators: please do not translate Face. */
                             _("Could not load Face header file %s: %s"));
-    sw_set_header_from_path(message, "X-Face", ident->x_face,
+    sw_set_header_from_path(message, "X-Face", libbalsa_identity_get_x_face_path(ident),
             /* Translators: please do not translate Face. */
                             _("Could not load X-Face header file %s: %s"));
 
@@ -5190,7 +5220,8 @@ check_suggest_encryption(BalsaSendmsg * bsmsg)
     gboolean result = TRUE;
 
     /* check if the user wants to see the message */
-    if ((bsmsg->ident == NULL) || !bsmsg->ident->warn_send_plain)
+    if (bsmsg->ident == NULL ||
+        !libbalsa_identity_get_warn_send_plain(bsmsg->ident))
        return TRUE;
 
     /* nothing to do if encryption is already enabled */
@@ -5218,7 +5249,7 @@ check_suggest_encryption(BalsaSendmsg * bsmsg)
     }
     if (can_encrypt) {
         ia_list = internet_address_list_new();
-        internet_address_list_add(ia_list, bsmsg->ident->ia);
+        internet_address_list_add(ia_list, libbalsa_identity_get_address(bsmsg->ident));
         can_encrypt = libbalsa_can_encrypt_for_all(ia_list, protocol);
         g_object_unref(ia_list);
     }
@@ -5272,9 +5303,10 @@ check_autocrypt_recommendation(BalsaSendmsg *bsmsg)
     gboolean result;
 
     /* check if autocrypt is enabled, use the non-Autocrypt approach if not */
-       if ((bsmsg->ident == NULL) || (bsmsg->ident->autocrypt_mode == AUTOCRYPT_DISABLE)) {
-               return check_suggest_encryption(bsmsg);
-       }
+    if ((bsmsg->ident == NULL) ||
+        (libbalsa_identity_get_autocrypt_mode(bsmsg->ident) == AUTOCRYPT_DISABLE)) {
+        return check_suggest_encryption(bsmsg);
+    }
 
     /* nothing to do if encryption is already enabled or if S/MIME mode is selected */
     if ((bsmsg->gpg_mode & (LIBBALSA_PROTECT_ENCRYPT | LIBBALSA_PROTECT_SMIMEV3)) != 0) {
@@ -5294,7 +5326,7 @@ check_autocrypt_recommendation(BalsaSendmsg *bsmsg)
     tmp_list = libbalsa_address_view_get_list(bsmsg->recipient_view, "CC:");
     internet_address_list_append(check_list, tmp_list);
     g_object_unref(tmp_list);
-    internet_address_list_add(check_list, bsmsg->ident->ia);           /* validates that we have a key for 
the current identity */
+    internet_address_list_add(check_list, libbalsa_identity_get_address(bsmsg->ident));                /* 
validates that we have a key for the current identity */
     autocrypt_mode = autocrypt_recommendation(check_list, &missing_keys, &error);
     g_object_unref(check_list);
 
@@ -5320,8 +5352,10 @@ check_autocrypt_recommendation(BalsaSendmsg *bsmsg)
                        protoname, protoname);
 
        /* default to encryption if all participants have prefer-encrypt=mutual, or if we reply to an 
encrypted message */
-       if (((autocrypt_mode == AUTOCRYPT_ENCR_AVAIL_MUTUAL) && (bsmsg->ident->autocrypt_mode == 
AUTOCRYPT_PREFER_ENCRYPT)) ||
-               ((bsmsg->parent_message != NULL) && (bsmsg->parent_message->prot_state == 
LIBBALSA_MSG_PROTECT_CRYPT))) {
+       if (((autocrypt_mode == AUTOCRYPT_ENCR_AVAIL_MUTUAL) &&
+             (libbalsa_identity_get_autocrypt_mode(bsmsg->ident) == AUTOCRYPT_PREFER_ENCRYPT)) ||
+            ((bsmsg->parent_message != NULL) &&
+             (bsmsg->parent_message->prot_state == LIBBALSA_MSG_PROTECT_CRYPT))) {
                default_choice = GTK_RESPONSE_YES;
        } else if (autocrypt_mode == AUTOCRYPT_ENCR_AVAIL) {
                default_choice = GTK_RESPONSE_NO;
@@ -5470,12 +5504,12 @@ send_message_handler(BalsaSendmsg * bsmsg, gboolean queue_only)
 
     if(queue_only)
        result = libbalsa_message_queue(message, balsa_app.outbox, fcc,
-                                       bsmsg->ident->smtp_server,
+                                       libbalsa_identity_get_smtp_server(bsmsg->ident),
                                        bsmsg->flow, &error);
     else
         result = libbalsa_message_send(message, balsa_app.outbox, fcc,
                                        balsa_find_sentbox_by_url,
-                                      bsmsg->ident->smtp_server,
+                                      libbalsa_identity_get_smtp_server(bsmsg->ident),
                                                                           balsa_app.send_progress_dialog,
                                        GTK_WINDOW(balsa_app.main_window),
                                        bsmsg->flow, &error);
@@ -6651,18 +6685,18 @@ bsmsg_update_gpg_ui_on_ident_change(BalsaSendmsg * bsmsg,
 
     /* preset according to identity */
     bsmsg->gpg_mode = 0;
-    if (ident->always_trust)
+    if (libbalsa_identity_get_always_trust(ident))
         bsmsg->gpg_mode |= LIBBALSA_PROTECT_ALWAYS_TRUST;
 
-    sw_action_set_active(bsmsg, "sign", ident->gpg_sign);
-    if (ident->gpg_sign)
+    sw_action_set_active(bsmsg, "sign", libbalsa_identity_get_gpg_sign(ident));
+    if (libbalsa_identity_get_gpg_sign(ident))
         bsmsg->gpg_mode |= LIBBALSA_PROTECT_SIGN;
 
-    sw_action_set_active(bsmsg, "encrypt", ident->gpg_encrypt);
-    if (ident->gpg_encrypt)
+    sw_action_set_active(bsmsg, "encrypt", libbalsa_identity_get_gpg_encrypt(ident));
+    if (libbalsa_identity_get_gpg_encrypt(ident))
         bsmsg->gpg_mode |= LIBBALSA_PROTECT_ENCRYPT;
 
-    switch (ident->crypt_protocol) {
+    switch (libbalsa_identity_get_crypt_protocol(ident)) {
     case LIBBALSA_PROTECT_OPENPGP:
         bsmsg->gpg_mode |= LIBBALSA_PROTECT_OPENPGP;
         g_action_change_state(action, g_variant_new_string("open-pgp"));
@@ -6899,7 +6933,8 @@ sendmsg_window_new()
     bsmsg->req_dsn = FALSE;
 
     sw_action_set_active(bsmsg, "flowed", bsmsg->flow);
-    sw_action_set_active(bsmsg, "send-html", bsmsg->ident->send_mp_alternative);
+    sw_action_set_active(bsmsg, "send-html",
+                         libbalsa_identity_get_send_mp_alternative(bsmsg->ident));
     sw_action_set_active(bsmsg, "show-toolbar", balsa_app.show_compose_toolbar);
 
     bsmsg_setup_gpg_ui(bsmsg);
@@ -6962,7 +6997,7 @@ sendmsg_window_compose(void)
     /* set the initial window title */
     bsmsg->type = SEND_NORMAL;
     sendmsg_window_set_title(bsmsg);
-    if(bsmsg->ident->sig_sending)
+    if (libbalsa_identity_get_sig_sending(bsmsg->ident))
         insert_initial_sig(bsmsg);
     bsmsg->state = SENDMSG_STATE_CLEAN;
     return bsmsg;
@@ -7015,7 +7050,7 @@ sendmsg_window_reply(LibBalsaMailbox * mailbox, guint msgno,
                          message->message_id);
     if(balsa_app.autoquote)
         fill_body_from_message(bsmsg, message, QUOTE_ALL);
-    if(bsmsg->ident->sig_whenreply)
+    if (libbalsa_identity_get_sig_whenreply(bsmsg->ident))
         insert_initial_sig(bsmsg);
     bsm_finish_setup(bsmsg, message->body_list);
     g_idle_add((GSourceFunc) sw_grab_focus_to_text,
@@ -7066,7 +7101,7 @@ sendmsg_window_reply_embedded(LibBalsaMessageBody *part,
         set_cc_from_all_recipients(bsmsg, part->embhdrs);
 
     bsm_finish_setup(bsmsg, part);
-    if(bsmsg->ident->sig_whenreply)
+    if (libbalsa_identity_get_sig_whenreply(bsmsg->ident))
         insert_initial_sig(bsmsg);
     g_idle_add((GSourceFunc) sw_grab_focus_to_text,
                g_object_ref(bsmsg->text));
@@ -7096,7 +7131,7 @@ sendmsg_window_forward(LibBalsaMailbox *mailbox, guint msgno,
         fill_body_from_message(bsmsg, message, QUOTE_NOPREFIX);
         bsm_finish_setup(bsmsg, message->body_list);
     }
-    if(bsmsg->ident->sig_whenforward)
+    if (libbalsa_identity_get_sig_whenforward(bsmsg->ident))
         insert_initial_sig(bsmsg);
     if(!attach) {
         GtkTextBuffer *buffer =


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]