[balsa/wip/gtk4: 215/351] identity: Add and use the getters
- From: Peter Bloomfield <peterb src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [balsa/wip/gtk4: 215/351] identity: Add and use the getters
- Date: Wed, 23 May 2018 21:35:02 +0000 (UTC)
commit 4d0f4c0a8eb70339fead6ddb6a39105185760760
Author: Peter Bloomfield <PeterBloomfield bellsouth net>
Date: Mon Mar 12 11:04:07 2018 -0400
identity: Add and use the getters
and make members private.
Also remove identity-private.h, which was never committed, as we no
longer need to share the struct with identity-widgets.c
libbalsa/identity-widgets.c | 89 +++++++------
libbalsa/identity.c | 270 ++++++++++++++++++++++++++++++++++++-
libbalsa/identity.h | 84 +++++-------
libbalsa/send.c | 44 ++++---
src/balsa-message.c | 22 ++--
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 | 175 ++++++++++++++----------
10 files changed, 511 insertions(+), 202 deletions(-)
---
diff --git a/libbalsa/identity-widgets.c b/libbalsa/identity-widgets.c
index b1f2224..230bed2 100644
--- a/libbalsa/identity-widgets.c
+++ b/libbalsa/identity-widgets.c
@@ -60,7 +60,10 @@ get_selected_identity(GtkTreeView * tree)
static gint
compare_identities(LibBalsaIdentity *id1, LibBalsaIdentity *id2)
{
- return g_ascii_strcasecmp(id1->identity_name, id2->identity_name);
+ const gchar *name1 = libbalsa_identity_get_identity_name(id1);
+ const gchar *name2 = libbalsa_identity_get_identity_name(id2);
+
+ return g_ascii_strcasecmp(name1, name2);
}
static gboolean
@@ -109,7 +112,7 @@ identity_list_update_real(GtkTreeView * tree,
gtk_list_store_append(store, &iter);
gtk_list_store_set(store, &iter,
DEFAULT_COLUMN, ident == default_id,
- NAME_COLUMN, ident->identity_name,
+ NAME_COLUMN, libbalsa_identity_get_identity_name(ident),
IDENT_COLUMN, ident,
-1);
}
@@ -392,7 +395,8 @@ static void add_show_menu(const char *label, gpointer data,
static void ident_dialog_free_values(GPtrArray * values);
static void display_frame_set_gpg_mode(GObject * dialog,
- const gchar * key, gint * value);
+ const gchar * key,
+ LibBalsaIdentity * ident);
static void ident_dialog_add_smtp_menu(GtkWidget * grid, gint row,
GtkDialog * dialog,
@@ -1115,7 +1119,8 @@ ident_dialog_update(GObject * dlg)
for (list = *identities; list != NULL; list = list->next) {
exist_ident = list->data;
- if (g_ascii_strcasecmp(exist_ident->identity_name, text) == 0
+ if (g_ascii_strcasecmp(libbalsa_identity_get_identity_name(exist_ident),
+ text) == 0
&& id != exist_ident) {
libbalsa_information(LIBBALSA_INFORMATION_ERROR,
_("Error: An identity with that"
@@ -1504,68 +1509,67 @@ display_frame_update(GObject * dialog, LibBalsaIdentity* ident)
return;
ident_dialog_update(dialog);
- display_frame_set_field(dialog, "identity-name", ident->identity_name);
- display_frame_set_field(dialog, "identity-fullname", ident->ia ? ident->ia->name : NULL);
- if (ident->ia && INTERNET_ADDRESS_IS_MAILBOX (ident->ia))
+ display_frame_set_field(dialog, "identity-name", libbalsa_identity_get_identity_name(ident));
+ display_frame_set_field(dialog, "identity-fullname", libbalsa_identity_get_address(ident) ?
libbalsa_identity_get_address(ident)->name : NULL);
+ if (libbalsa_identity_get_address(ident) && INTERNET_ADDRESS_IS_MAILBOX
(libbalsa_identity_get_address(ident)))
display_frame_set_field(dialog, "identity-address",
- INTERNET_ADDRESS_MAILBOX(ident->ia)->addr);
+ INTERNET_ADDRESS_MAILBOX(libbalsa_identity_get_address(ident))->addr);
else
display_frame_set_field(dialog, "identity-address", NULL);
- display_frame_set_field(dialog, "identity-replyto", ident->replyto);
- display_frame_set_field(dialog, "identity-domain", ident->domain);
- display_frame_set_field(dialog, "identity-bcc", ident->bcc);
+ display_frame_set_field(dialog, "identity-replyto", libbalsa_identity_get_replyto(ident));
+ display_frame_set_field(dialog, "identity-domain", libbalsa_identity_get_domain(ident));
+ display_frame_set_field(dialog, "identity-bcc", libbalsa_identity_get_bcc(ident));
display_frame_set_field(dialog, "identity-replystring",
- ident->reply_string);
+ libbalsa_identity_get_reply_string(ident));
display_frame_set_field(dialog, "identity-forwardstring",
- ident->forward_string);
+ libbalsa_identity_get_forward_string(ident));
display_frame_set_boolean(dialog, "identity-sendmpalternative",
- ident->send_mp_alternative);
+ libbalsa_identity_get_send_mp_alternative(ident));
display_frame_set_server(dialog, "identity-smtp-server",
- ident->smtp_server);
+ libbalsa_identity_get_smtp_server(ident));
display_frame_set_path(dialog, "identity-sigpath",
- ident->signature_path, FALSE);
- display_frame_set_boolean(dialog, "identity-sigexecutable", ident->sig_executable);
+ libbalsa_identity_get_signature_path(ident), FALSE);
+ display_frame_set_boolean(dialog, "identity-sigexecutable", libbalsa_identity_get_sig_executable(ident));
- display_frame_set_boolean(dialog, "identity-sigappend", ident->sig_sending);
+ display_frame_set_boolean(dialog, "identity-sigappend", libbalsa_identity_get_sig_sending(ident));
display_frame_set_boolean(dialog, "identity-whenforward",
- ident->sig_whenforward);
+ libbalsa_identity_get_sig_whenforward(ident));
display_frame_set_boolean(dialog, "identity-whenreply",
- ident->sig_whenreply);
+ libbalsa_identity_get_sig_whenreply(ident));
display_frame_set_boolean(dialog, "identity-sigseparator",
- ident->sig_separator);
+ libbalsa_identity_get_sig_separator(ident));
display_frame_set_boolean(dialog, "identity-sigprepend",
- ident->sig_prepend);
+ libbalsa_identity_get_sig_prepend(ident));
face_box = g_object_get_data(G_OBJECT(dialog),
path_info[LBI_PATH_TYPE_FACE].box_key);
gtk_widget_hide(face_box);
display_frame_set_path(dialog, path_info[LBI_PATH_TYPE_FACE].path_key,
- ident->face, TRUE);
+ libbalsa_identity_get_face_path(ident), TRUE);
face_box = g_object_get_data(G_OBJECT(dialog),
path_info[LBI_PATH_TYPE_XFACE].box_key);
gtk_widget_hide(face_box);
display_frame_set_path(dialog, path_info[LBI_PATH_TYPE_XFACE].path_key,
- ident->x_face, TRUE);
+ libbalsa_identity_get_x_face_path(ident), TRUE);
display_frame_set_boolean(dialog, "identity-requestmdn",
- ident->request_mdn);
+ libbalsa_identity_get_request_mdn(ident));
display_frame_set_boolean(dialog, "identity-requestdsn",
- ident->request_dsn);
+ libbalsa_identity_get_request_dsn(ident));
display_frame_set_boolean(dialog, "identity-gpgsign",
- ident->gpg_sign);
+ libbalsa_identity_get_gpg_sign(ident));
display_frame_set_boolean(dialog, "identity-gpgencrypt",
- ident->gpg_encrypt);
+ libbalsa_identity_get_gpg_encrypt(ident));
display_frame_set_boolean(dialog, "identity-trust-always",
- ident->always_trust);
+ libbalsa_identity_get_always_trust(ident));
display_frame_set_boolean(dialog, "identity-warn-send-plain",
- ident->warn_send_plain);
- display_frame_set_gpg_mode(dialog, "identity-crypt-protocol",
- &ident->crypt_protocol);
- display_frame_set_field(dialog, "identity-keyid", ident->force_gpg_key_id);
- display_frame_set_field(dialog, "identity-keyid-sm", ident->force_smime_key_id);
+ libbalsa_identity_get_warn_send_plain(ident));
+ display_frame_set_gpg_mode(dialog, "identity-crypt-protocol", ident);
+ display_frame_set_field(dialog, "identity-keyid", libbalsa_identity_get_force_gpg_key_id(ident));
+ display_frame_set_field(dialog, "identity-keyid-sm", libbalsa_identity_get_force_smime_key_id(ident));
}
@@ -1611,22 +1615,25 @@ display_frame_set_path(GObject * dialog,
static void
-display_frame_set_gpg_mode(GObject * dialog, const gchar* key, gint * value)
+display_frame_set_gpg_mode(GObject * dialog, const gchar* key, LibBalsaIdentity * ident)
{
GtkComboBox *opt_menu = g_object_get_data(G_OBJECT(dialog), key);
+ gint value = libbalsa_identity_get_crypt_protocol(ident);
- switch (*value)
+ switch (value)
{
+ case LIBBALSA_PROTECT_RFC3156:
+ gtk_combo_box_set_active(opt_menu, 0);
+ break;
case LIBBALSA_PROTECT_OPENPGP:
gtk_combo_box_set_active(opt_menu, 1);
break;
case LIBBALSA_PROTECT_SMIMEV3:
gtk_combo_box_set_active(opt_menu, 2);
break;
- case LIBBALSA_PROTECT_RFC3156:
default:
gtk_combo_box_set_active(opt_menu, 0);
- *value = LIBBALSA_PROTECT_RFC3156;
+ libbalsa_identity_set_crypt_protocol(ident, LIBBALSA_PROTECT_RFC3156);
}
}
@@ -1781,8 +1788,8 @@ libbalsa_identity_combo_box(GList * identities,
GtkTreeIter iter;
ident = list->data;
- from = internet_address_to_string(ident->ia, FALSE);
- name = g_strconcat("(", ident->identity_name, ")", NULL);
+ from = internet_address_to_string(libbalsa_identity_get_address(ident), FALSE);
+ name = g_strconcat("(", libbalsa_identity_get_identity_name(ident), ")", NULL);
gtk_list_store_append(store, &iter);
gtk_list_store_set(store, &iter,
@@ -1794,7 +1801,7 @@ libbalsa_identity_combo_box(GList * identities,
g_free(from);
g_free(name);
- if (g_strcmp0(active_name, ident->identity_name) == 0)
+ if (g_strcmp0(active_name, libbalsa_identity_get_identity_name(ident)) == 0)
gtk_combo_box_set_active_iter(GTK_COMBO_BOX(combo_box), &iter);
}
g_object_unref(store);
diff --git a/libbalsa/identity.c b/libbalsa/identity.c
index 7ef1b7a..7279465 100644
--- a/libbalsa/identity.c
+++ b/libbalsa/identity.c
@@ -44,6 +44,45 @@
* The 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;
+ LibBalsaSmtpServer *smtp_server;
+};
+
/* Forward references. */
static void libbalsa_identity_dispose(GObject* object);
static void libbalsa_identity_finalize(GObject* object);
@@ -138,7 +177,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"));
@@ -149,15 +188,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);
- return G_OBJECT(ident);
+ return (LibBalsaIdentity *) ident;
}
@@ -232,7 +271,8 @@ libbalsa_identity_set_forward_string(LibBalsaIdentity* ident, const gchar* forwa
void
-libbalsa_identity_set_send_mp_alternative(LibBalsaIdentity* ident, gboolean send_mp_alternative)
+libbalsa_identity_set_send_mp_alternative(LibBalsaIdentity *ident,
+ gboolean send_mp_alternative)
{
g_return_if_fail(LIBBALSA_IS_IDENTITY(ident));
ident->send_mp_alternative = send_mp_alternative;
@@ -568,3 +608,223 @@ libbalsa_identity_set_crypt_protocol(LibBalsaIdentity* ident, gint protocol)
g_return_if_fail(LIBBALSA_IS_IDENTITY(ident));
ident->crypt_protocol = protocol;
}
+
+/*
+ * 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;
+}
diff --git a/libbalsa/identity.h b/libbalsa/identity.h
index 62004cd..da7a643 100644
--- a/libbalsa/identity.h
+++ b/libbalsa/identity.h
@@ -39,55 +39,19 @@ G_DECLARE_FINAL_TYPE(LibBalsaIdentity,
IDENTITY,
GObject)
-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;
- LibBalsaSmtpServer *smtp_server;
-};
-
-struct _LibBalsaIdentityClass {
- GObjectClass parent_class;
-};
-
-
/* Function prototypes */
-GObject *libbalsa_identity_new(void);
-GObject *libbalsa_identity_new_with_name(const gchar *ident_name);
+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_identity_name(LibBalsaIdentity *ident,
const gchar *name);
void libbalsa_identity_set_address(LibBalsaIdentity *ident,
InternetAddress *ia);
-void libbalsa_identity_set_replyto(LibBalsaIdentity *id,
+void libbalsa_identity_set_replyto(LibBalsaIdentity *ident,
const gchar *reply_to);
void libbalsa_identity_set_domain(LibBalsaIdentity *ident,
const gchar *text);
@@ -142,10 +106,38 @@ void libbalsa_identity_set_gpg_encrypt(LibBalsaIdentity *ident,
void libbalsa_identity_set_crypt_protocol(LibBalsaIdentity *ident,
gint proto);
-LibBalsaIdentity *libbalsa_identity_new_from_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);
+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);
G_END_DECLS
diff --git a/libbalsa/send.c b/libbalsa/send.c
index eb48202..97a1952 100644
--- a/libbalsa/send.c
+++ b/libbalsa/send.c
@@ -1695,27 +1695,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 4da666d..7c1fdae 100644
--- a/src/balsa-message.c
+++ b/src/balsa-message.c
@@ -2364,8 +2364,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;
}
}
@@ -2377,8 +2379,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;
}
}
@@ -2419,7 +2423,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);
@@ -2448,7 +2452,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 ();
@@ -2493,9 +2497,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);
@@ -2560,8 +2564,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);
diff --git a/src/balsa-mime-widget-message.c b/src/balsa-mime-widget-message.c
index a8d36f8..010a1ee 100644
--- a/src/balsa-mime-widget-message.c
+++ b/src/balsa-mime-widget-message.c
@@ -343,7 +343,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) {
@@ -382,7 +382,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 80cc2b2..b293abd 100644
--- a/src/balsa-mime-widget-vcalendar.c
+++ b/src/balsa-mime-widget-vcalendar.c
@@ -196,7 +196,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;
}
@@ -282,12 +283,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);
@@ -295,7 +298,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);
@@ -310,7 +313,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");
@@ -325,7 +328,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 a517706..aca5cfd 100644
--- a/src/mailbox-conf.c
+++ b/src/mailbox-conf.c
@@ -1649,7 +1649,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 6d8d5bf..98fe1b8 100644
--- a/src/save-restore.c
+++ b/src/save-restore.c
@@ -1607,7 +1607,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;
@@ -1658,8 +1659,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);
@@ -1668,7 +1670,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 8853722..cbd29a3 100644
--- a/src/sendmsg-window.c
+++ b/src/sendmsg-window.c
@@ -918,20 +918,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);
@@ -1072,6 +1074,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 ||
@@ -1087,10 +1094,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")) {
@@ -1098,13 +1106,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. */
@@ -1133,7 +1142,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);
@@ -1161,15 +1171,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 {
@@ -1191,9 +1207,9 @@ update_bsmsg_identity(BalsaSendmsg* bsmsg, LibBalsaIdentity* ident)
/* 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))
+ 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;
@@ -1202,7 +1218,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);
@@ -1273,7 +1289,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));
#ifdef HAVE_GPGME
bsmsg_update_gpg_ui_on_ident_change(bsmsg, ident);
@@ -1283,10 +1300,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));
}
@@ -2387,7 +2404,7 @@ create_email_entry(BalsaSendmsg * bsmsg,
GDK_ACTION_COPY | GDK_ACTION_MOVE);
gdk_content_formats_unref(formats);
- 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(*view, "view-changed",
G_CALLBACK(check_readiness), bsmsg);
}
@@ -3670,15 +3687,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) {
@@ -3687,8 +3705,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;
}
}
@@ -3696,14 +3714,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);
}
@@ -3719,6 +3737,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)
@@ -3735,7 +3754,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;
}
@@ -3747,13 +3766,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;
@@ -3867,19 +3886,21 @@ setup_headers_from_message(BalsaSendmsg* bsmsg, LibBalsaMessage *message)
static gboolean
set_identity_from_mailbox(BalsaSendmsg* bsmsg, LibBalsaMessage * message)
{
- const gchar *identity;
-
- LibBalsaIdentity* ident;
- GList *ilist;
-
if( message && message->mailbox && balsa_app.identities) {
+ const gchar *identity;
+ GList *ilist;
+
identity = libbalsa_mailbox_get_identity_name(message->mailbox);
- if(!identity) return FALSE;
+ if (identity == NULL)
+ return FALSE;
+
for (ilist = balsa_app.identities;
ilist != NULL;
ilist = ilist->next) {
- ident = LIBBALSA_IDENTITY(ilist->data);
- if (!g_ascii_strcasecmp(identity, ident->identity_name)) {
+ LibBalsaIdentity *ident = LIBBALSA_IDENTITY(ilist->data);
+
+ if (g_ascii_strcasecmp(libbalsa_identity_get_identity_name(ident),
+ identity) == 0) {
bsmsg->ident = ident;
return TRUE;
}
@@ -3898,6 +3919,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)
@@ -3907,6 +3929,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);
@@ -3921,7 +3944,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;
}
@@ -3957,16 +3981,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,
@@ -4191,14 +4221,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);
@@ -4213,7 +4244,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);
@@ -4800,13 +4831,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");
@@ -4831,13 +4863,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"));
@@ -5023,7 +5055,7 @@ check_suggest_encryption(BalsaSendmsg * bsmsg)
gint len;
/* check if the user wants to see the message */
- if (!bsmsg->ident->warn_send_plain)
+ if (!libbalsa_identity_get_warn_send_plain(bsmsg->ident))
return TRUE;
/* nothing to do if encryption is already enabled */
@@ -5051,7 +5083,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);
}
@@ -5207,12 +5239,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);
@@ -6392,18 +6424,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"));
@@ -6656,7 +6688,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);
#ifdef HAVE_GPGME
@@ -6721,7 +6754,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;
@@ -6769,7 +6802,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,
@@ -6819,7 +6852,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));
@@ -6849,7 +6882,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]