[balsa] port to GMime-2.4
- From: Peter Bloomfield <PeterB src gnome org>
- To: svn-commits-list gnome org
- Subject: [balsa] port to GMime-2.4
- Date: Tue, 21 Apr 2009 22:15:02 -0400 (EDT)
commit 3bfbfb279bdbed31f6179d3fedd512ba29e1a488
Author: Peter Bloomfield <PeterBloomfield bellsouth net>
Date: Tue Apr 21 21:55:27 2009 -0400
port to GMime-2.4
---
ChangeLog | 6 +-
configure.in | 14 +--
libbalsa/abook-completion.c | 4 +-
libbalsa/address-book-extern.c | 2 +-
libbalsa/address-book-gpe.c | 2 +-
libbalsa/address-book-ldap.c | 2 +-
libbalsa/address-book-rubrica.c | 18 +-
libbalsa/address-book-text.c | 28 ++--
libbalsa/address-view.c | 98 +++++--------
libbalsa/address.c | 72 ++++++---
libbalsa/address.h | 7 +-
libbalsa/body.c | 59 ++++----
libbalsa/gmime-application-pkcs7.c | 52 +++----
libbalsa/gmime-gpgme-context.c | 39 ++++--
libbalsa/gmime-part-rfc2440.c | 61 +++-----
libbalsa/gmime-part-rfc2440.h | 5 +-
libbalsa/gmime-stream-gio.c | 24 ++--
libbalsa/gmime-stream-gio.h | 4 +-
libbalsa/gmime-stream-gnome-vfs.c | 32 ++--
libbalsa/gmime-stream-gnome-vfs.h | 4 +-
libbalsa/html.c | 2 +-
libbalsa/identity.c | 48 +++---
libbalsa/libbalsa.c | 11 +-
libbalsa/mailbox.c | 63 ++++++--
libbalsa/mailbox_imap.c | 77 ++++------
libbalsa/mailbox_local.c | 9 +-
libbalsa/mailbox_maildir.c | 6 +-
libbalsa/mailbox_mbox.c | 50 ++++---
libbalsa/mailbox_mh.c | 6 +-
libbalsa/message.c | 110 +++++++-------
libbalsa/mime-stream-shared.c | 12 +-
libbalsa/misc.c | 19 +--
libbalsa/rfc3156.c | 30 +++--
libbalsa/send.c | 202 ++++++++++++--------------
libinit_balsa/assistant_page_user.c | 7 +-
src/balsa-message.c | 72 +++++----
src/balsa-mime-widget-message.c | 10 +-
src/balsa-mime-widget-vcalendar.c | 30 ++--
src/save-restore.c | 2 +-
src/sendmsg-window.c | 275 +++++++++++++++++------------------
src/store-address.c | 34 +++--
41 files changed, 819 insertions(+), 789 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index b534c9b..a7f9e4c 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,6 +1,10 @@
2009-04-21 Peter Bloomfield
- create balsa-2-3 branch for updates to the pre-GMimje-2.4 tree.
+ port to GMime-2.4
+
+2009-04-21 Peter Bloomfield
+
+ create balsa-2-3 branch for updates to the pre-GMime-2.4 tree.
2009-04-21 Peter Bloomfield
diff --git a/configure.in b/configure.in
index b2e24fd..d6d5d60 100644
--- a/configure.in
+++ b/configure.in
@@ -384,7 +384,7 @@ dnl #####################################################################
PKG_CHECK_MODULES(BALSA, [
glib-2.0 >= 2.6.0
gtk+-2.0 >= 2.6.0
-gmime-2.0 >= 2.1.9
+gmime-2.4
$gio_extra
$gnome_extras
$gnome_print_extras
@@ -393,7 +393,7 @@ $gnome_print_extras
PKG_CHECK_MODULES(BALSA_AB, [
glib-2.0 >= 2.6.0
gtk+-2.0 >= 2.6.0
- gmime-2.0 >= 2.1.9
+ gmime-2.4
$gnome_extras
])
@@ -993,16 +993,6 @@ dnl however, we do not mess with the icon caches - it messes up more
dnl things that it fixes, for eg. user installs, package builds etc.
dnl AC_PATH_PROG(GTK_UPDATE_ICON_CACHE, gtk-update-icon-cache)
-dnl check GMime version
-if $PKG_CONFIG --atleast-version=2.2.5 gmime-2.0 ; then
- AC_DEFINE(HAVE_GMIME_2_2_5,1,[Defined when GMime is at least version
- 2.2.5.])
-fi
-if $PKG_CONFIG --atleast-version=2.2.7 gmime-2.0 ; then
- AC_DEFINE(HAVE_GMIME_2_2_7,1,[Defined when GMime is at least version
- 2.2.7.])
-fi
-
dnl #####################################################################
dnl 8. Output
dnl #####################################################################
diff --git a/libbalsa/abook-completion.c b/libbalsa/abook-completion.c
index 2d7fa61..22313c5 100644
--- a/libbalsa/abook-completion.c
+++ b/libbalsa/abook-completion.c
@@ -48,7 +48,7 @@ completion_data_new(InternetAddress * ia, const gchar * nick_name)
ret = g_new0(CompletionData, 1);
- internet_address_ref(ia);
+ g_object_ref(ia);
ret->ia = ia;
string = g_string_new(nick_name);
@@ -80,7 +80,7 @@ completion_data_new(InternetAddress * ia, const gchar * nick_name)
void
completion_data_free(CompletionData * data)
{
- internet_address_unref(data->ia);
+ g_object_unref(data->ia);
g_free(data->string);
g_free(data);
}
diff --git a/libbalsa/address-book-extern.c b/libbalsa/address-book-extern.c
index b147cb8..0f43d53 100644
--- a/libbalsa/address-book-extern.c
+++ b/libbalsa/address-book-extern.c
@@ -370,7 +370,7 @@ lbe_expand_cb(const gchar *email, const gchar *name, void *d)
if(!name || !*name)
name = _("No-Name");
*res = g_list_prepend(*res,
- internet_address_new_name(name, email));
+ internet_address_mailbox_new(name, email));
}
}
diff --git a/libbalsa/address-book-gpe.c b/libbalsa/address-book-gpe.c
index ff3a6f2..efbad1a 100644
--- a/libbalsa/address-book-gpe.c
+++ b/libbalsa/address-book-gpe.c
@@ -732,7 +732,7 @@ gpe_read_completion(void *arg, int argc, char **argv, char **names)
if(!a->full_name)
a->full_name = create_name(a->first_name, a->last_name);
for(l=a->address_list; l; l = l->next) {
- ia = internet_address_new_name(a->full_name, l->data);
+ ia = internet_address_mailbox_new(a->full_name, l->data);
gc->res = g_list_prepend(gc->res, ia);
}
if(gc->new_prefix && !*gc->new_prefix)
diff --git a/libbalsa/address-book-ldap.c b/libbalsa/address-book-ldap.c
index b989cf8..8d0add6 100644
--- a/libbalsa/address-book-ldap.c
+++ b/libbalsa/address-book-ldap.c
@@ -549,7 +549,7 @@ lbabl_get_internet_address(LDAP *dir, LDAPMessage * e)
if(!cn)
cn = create_name(first, sn);
- ia = internet_address_new_name(cn, email);
+ ia = internet_address_mailbox_new(cn, email);
g_free(email); g_free(sn); g_free(cn); g_free(first);
return ia;
diff --git a/libbalsa/address-book-rubrica.c b/libbalsa/address-book-rubrica.c
index cf52195..b1f7e7a 100644
--- a/libbalsa/address-book-rubrica.c
+++ b/libbalsa/address-book-rubrica.c
@@ -238,8 +238,7 @@ libbalsa_address_book_rubrica_alias_complete(LibBalsaAddressBook * ab,
g_completion_complete(ab_text->name_complete, (gchar *) prefix,
new_prefix); list; list = list->next) {
InternetAddress *ia = ((CompletionData *) list->data)->ia;
- internet_address_ref(ia);
- res = g_list_prepend(res, ia);
+ res = g_list_prepend(res, g_object_ref(ia));
}
return g_list_reverse(res);
@@ -471,28 +470,29 @@ lbab_rubrica_load_xml(LibBalsaAddressBookRubrica * ab_rubrica,
&& LIBBALSA_ADDRESS_BOOK(ab_rubrica)->dist_list_mode) {
/* Create a group address. */
InternetAddress *ia =
- internet_address_new_group(address->full_name);
+ internet_address_group_new(address->full_name);
+ InternetAddressGroup *group = (InternetAddressGroup *) ia;
for (l = address->address_list; l; l = l->next) {
InternetAddress *member =
- internet_address_new_name(NULL, l->data);
- internet_address_add_member(ia, member);
- internet_address_unref(member);
+ internet_address_mailbox_new(NULL, l->data);
+ internet_address_group_add_member(group, member);
+ g_object_unref(member);
}
cmp_data = completion_data_new(ia, address->nick_name);
completion_list = g_list_prepend(completion_list, cmp_data);
- internet_address_unref(ia);
+ g_object_unref(ia);
} else {
/* Create name addresses. */
GList *l;
for (l = address->address_list; l; l = l->next) {
InternetAddress *ia =
- internet_address_new_name(address->full_name, l->data);
+ internet_address_mailbox_new(address->full_name, l->data);
cmp_data = completion_data_new(ia, address->nick_name);
completion_list =
g_list_prepend(completion_list, cmp_data);
- internet_address_unref(ia);
+ g_object_unref(ia);
}
}
}
diff --git a/libbalsa/address-book-text.c b/libbalsa/address-book-text.c
index 19147cc..16a38f5 100644
--- a/libbalsa/address-book-text.c
+++ b/libbalsa/address-book-text.c
@@ -248,7 +248,7 @@ lbab_text_group_address(const gchar * group_name,
if (!lbab_text_group_addresses || !lbab_text_group_addresses->next)
return;
- ia = internet_address_new_group(group_name);
+ ia = internet_address_group_new(group_name);
for (l = lbab_text_group_addresses; l; l = l->next) {
GList *mailbox;
LibBalsaAddress *address = LIBBALSA_ADDRESS(l->data);
@@ -256,16 +256,16 @@ lbab_text_group_address(const gchar * group_name,
for (mailbox = address->address_list; mailbox;
mailbox = mailbox->next) {
InternetAddress *member =
- internet_address_new_name(address->full_name,
- mailbox->data);
- internet_address_add_member(ia, member);
- internet_address_unref(member);
+ internet_address_mailbox_new(address->full_name,
+ mailbox->data);
+ internet_address_group_add_member(ia, member);
+ g_object_unref(member);
}
}
g_slist_free(lbab_text_group_addresses);
cmp_data = completion_data_new(ia, NULL);
- internet_address_unref(ia);
+ g_object_unref(ia);
*completion_list = g_list_prepend(*completion_list, cmp_data);
}
#endif /* MAKE_GROUP_BY_ORGANIZATION */
@@ -354,28 +354,28 @@ lbab_text_load_file(LibBalsaAddressBookText * ab_text, FILE * stream)
&& LIBBALSA_ADDRESS_BOOK(ab_text)->dist_list_mode) {
/* Create a group address. */
InternetAddress *ia =
- internet_address_new_group(address->full_name);
+ internet_address_group_new(address->full_name);
for (l = address->address_list; l; l = l->next) {
InternetAddress *member =
- internet_address_new_name(NULL, l->data);
- internet_address_add_member(ia, member);
- internet_address_unref(member);
+ internet_address_mailbox_new(NULL, l->data);
+ internet_address_group_add_member((InternetAddressGroup *)ia, member);
+ g_object_unref(member);
}
cmp_data = completion_data_new(ia, address->nick_name);
completion_list = g_list_prepend(completion_list, cmp_data);
- internet_address_unref(ia);
+ g_object_unref(ia);
} else {
/* Create name addresses. */
GList *l;
for (l = address->address_list; l; l = l->next) {
InternetAddress *ia =
- internet_address_new_name(address->full_name, l->data);
+ internet_address_mailbox_new(address->full_name, l->data);
cmp_data = completion_data_new(ia, address->nick_name);
completion_list =
g_list_prepend(completion_list, cmp_data);
- internet_address_unref(ia);
+ g_object_unref(ia);
}
}
@@ -730,7 +730,7 @@ libbalsa_address_book_text_alias_complete(LibBalsaAddressBook * ab,
g_completion_complete(ab_text->name_complete, (gchar *) prefix,
new_prefix); list; list = list->next) {
InternetAddress *ia = ((CompletionData *) list->data)->ia;
- internet_address_ref(ia);
+ g_object_ref(ia);
res = g_list_prepend(res, ia);
}
diff --git a/libbalsa/address-view.c b/libbalsa/address-view.c
index e63aea1..1f0b95a 100644
--- a/libbalsa/address-view.c
+++ b/libbalsa/address-view.c
@@ -230,7 +230,7 @@ lbav_entry_setup_matches(LibBalsaAddressView * address_view,
if (*prefix)
match = lbav_get_matching_addresses(address_view, prefix, type);
lbav_append_addresses(address_view, completion, match, prefix);
- g_list_foreach(match, (GFunc) internet_address_unref, NULL);
+ g_list_foreach(match, (GFunc) g_object_unref, NULL);
g_list_free(match);
}
@@ -372,30 +372,30 @@ lbav_add_from_list(LibBalsaAddressView * address_view,
GtkTreeModel *model =
gtk_tree_view_get_model(GTK_TREE_VIEW(address_view));
GtkListStore *address_store = GTK_LIST_STORE(model);
+ InternetAddress *ia;
+ gchar *name;
guint type;
-
+ int i;
+
gtk_tree_model_get(model, iter, ADDRESS_TYPE_COL, &type, -1);
- while (list) {
- InternetAddress *ia = list->address;
-
- if (ia) {
- gchar *name = internet_address_to_string(ia, FALSE);
-
- libbalsa_utf8_sanitize(&name, address_view->fallback, NULL);
- lbav_clean_text(name);
-
- gtk_list_store_set(address_store, iter,
- ADDRESS_TYPE_COL, type,
- ADDRESS_TYPESTRING_COL,
- _(lbav_type_string(address_view, type)),
- ADDRESS_NAME_COL, name,
- ADDRESS_ICON_COL, lbav_close_icon,
- -1);
- g_free(name);
- }
-
- if ((list = list->next))
+ for (i = 0; i < internet_address_list_length (list); i++) {
+ ia = internet_address_list_get_address (list, i);;
+ name = internet_address_to_string (ia, FALSE);
+
+ libbalsa_utf8_sanitize(&name, address_view->fallback, NULL);
+ lbav_clean_text(name);
+
+ gtk_list_store_set(address_store, iter,
+ ADDRESS_TYPE_COL, type,
+ ADDRESS_TYPESTRING_COL,
+ _(lbav_type_string(address_view, type)),
+ ADDRESS_NAME_COL, name,
+ ADDRESS_ICON_COL, lbav_close_icon,
+ -1);
+ g_free(name);
+
+ if (i + 1 < internet_address_list_length (list))
gtk_list_store_insert_after(address_store, iter, iter);
}
}
@@ -410,12 +410,13 @@ static gboolean
lbav_add_from_string(LibBalsaAddressView * address_view,
GtkTreeIter * iter, const gchar * string)
{
- InternetAddressList *list = internet_address_parse_string(string);
+ InternetAddressList *list = internet_address_list_parse_string(string);
+ gboolean retval = internet_address_list_length(list) > 0;
lbav_add_from_list(address_view, iter, list);
- internet_address_list_destroy(list);
+ g_object_unref(list);
- return list != NULL;
+ return retval;
}
/*
@@ -537,24 +538,6 @@ lbav_set_text_at_path(LibBalsaAddressView * address_view,
}
/*
- * Count addresses in an InternetAddressList
- */
-static void
-lbav_count_addresses_in_list(InternetAddressList * list, gint * addresses)
-{
- for (; list && *addresses >= 0; list = list->next) {
- InternetAddress *ia = list->address;
- if (ia->type == INTERNET_ADDRESS_NAME) {
- if (strpbrk(ia->value.addr, "@%!"))
- ++(*addresses);
- else
- *addresses = -1;
- } else if (ia->type == INTERNET_ADDRESS_GROUP)
- lbav_count_addresses_in_list(ia->value.members, addresses);
- }
-}
-
-/*
* Find an address_type
*/
static guint
@@ -768,7 +751,7 @@ lbav_focus_out_cb(GtkEntry * entry, GdkEventFocus * event,
gtk_cell_editable_editing_done(GTK_CELL_EDITABLE(entry));
g_free(the_addr);
}
- g_list_foreach(match, (GFunc) internet_address_unref, NULL);
+ g_list_foreach(match, (GFunc) g_object_unref, NULL);
g_list_free(match);
}
}
@@ -1193,7 +1176,7 @@ libbalsa_address_view_set_from_list(LibBalsaAddressView * address_view,
lbav_remove(address_view, type);
- if (list) {
+ if (list && internet_address_list_length(list) > 0) {
GtkTreeModel *model =
gtk_tree_view_get_model(GTK_TREE_VIEW(address_view));
GtkListStore *address_store = GTK_LIST_STORE(model);
@@ -1216,19 +1199,18 @@ libbalsa_address_view_set_from_list(LibBalsaAddressView * address_view,
gint
libbalsa_address_view_n_addresses(LibBalsaAddressView * address_view)
{
- gint addresses;
+ gint addresses = 0;
guint type;
g_return_val_if_fail(LIBBALSA_IS_ADDRESS_VIEW(address_view), -1);
- addresses = 0;
for (type = 0; type < address_view->n_types; type++) {
InternetAddressList *list =
libbalsa_address_view_get_list(address_view,
lbav_type_string(address_view,
type));
- lbav_count_addresses_in_list(list, &addresses);
- internet_address_list_destroy(list);
+ addresses += libbalsa_address_n_mailboxes_in_list(list);
+ g_object_unref(list);
}
return addresses;
@@ -1236,7 +1218,8 @@ libbalsa_address_view_n_addresses(LibBalsaAddressView * address_view)
/*
* Create InternetAddressList corresponding to the view content.
- * The list must be destroyed using internet_address_list_destroy().
+ * The list, which is NULL only on error, must be destroyed using
+ * g_object_unref().
*/
InternetAddressList *
libbalsa_address_view_get_list(LibBalsaAddressView * address_view,
@@ -1255,7 +1238,7 @@ libbalsa_address_view_get_list(LibBalsaAddressView * address_view,
|| type < address_view->n_types, NULL);
model = gtk_tree_view_get_model(GTK_TREE_VIEW(address_view));
- address_list = NULL;
+ address_list = internet_address_list_new();
for (valid = gtk_tree_model_get_iter_first(model, &iter);
valid; valid = gtk_tree_model_iter_next(model, &iter)) {
guint this_type;
@@ -1266,15 +1249,10 @@ libbalsa_address_view_get_list(LibBalsaAddressView * address_view,
ADDRESS_NAME_COL, &name, -1);
if (this_type == type && name && *name) {
- InternetAddressList *l, *tmp_list =
- internet_address_parse_string(name);
- for (l = tmp_list; l; l = l->next) {
- InternetAddress *ia = l->address;
- if (ia)
- address_list =
- internet_address_list_append(address_list, ia);
- }
- internet_address_list_destroy(tmp_list);
+ InternetAddressList *tmp_list =
+ internet_address_list_parse_string(name);
+ internet_address_list_append(address_list, tmp_list);
+ g_object_unref(tmp_list);
}
g_free(name);
}
diff --git a/libbalsa/address.c b/libbalsa/address.c
index 97a5af2..6ab024e 100644
--- a/libbalsa/address.c
+++ b/libbalsa/address.c
@@ -209,14 +209,10 @@ vcard_qp_decode(gchar * str)
gint len = strlen(str);
gchar * newstr = g_malloc0(len + 1);
int state = 0;
-#if HAVE_GMIME_2_2_5
guint32 save;
-#else /* HAVE_GMIME_2_2_5 */
- int save;
-#endif /* HAVE_GMIME_2_2_5 */
/* qp decode the input string */
- g_mime_utils_quoted_decode_step((unsigned char *) str, len,
+ g_mime_encoding_quoted_decode_step((unsigned char *) str, len,
(unsigned char *) newstr, &state, &save);
/* free input and return new string */
@@ -234,7 +230,7 @@ vcard_b64_decode(gchar * str)
guint32 save;
/* base64 decode the input string */
- g_mime_utils_base64_decode_step((unsigned char *) str, len,
+ g_mime_encoding_base64_decode_step((unsigned char *) str, len,
(unsigned char *) newstr, &state, &save);
/* free input and return new string */
@@ -555,9 +551,9 @@ rfc2822_mailbox(const gchar * full_name, const gchar * address)
InternetAddress *ia;
gchar *new_str;
- ia = internet_address_new_name(full_name, address);
+ ia = internet_address_mailbox_new(full_name, address);
new_str = internet_address_to_string(ia, FALSE);
- internet_address_unref(ia);
+ g_object_unref(ia);
return new_str;
}
@@ -568,16 +564,16 @@ rfc2822_group(const gchar *full_name, GList *addr_list)
InternetAddress *ia;
gchar *res;
- ia = internet_address_new_group(full_name);
+ ia = internet_address_group_new(full_name);
for (; addr_list; addr_list = addr_list->next) {
InternetAddress *member;
- member = internet_address_new_name(NULL, addr_list->data);
- internet_address_add_member(ia, member);
- internet_address_unref(member);
+ member = internet_address_mailbox_new(NULL, addr_list->data);
+ internet_address_group_add_member(INTERNET_ADDRESS_GROUP(ia), member);
+ g_object_unref(member);
}
res = internet_address_to_string(ia, FALSE);
- internet_address_unref(ia);
+ g_object_unref(ia);
return res;
}
@@ -615,24 +611,30 @@ libbalsa_address_to_gchar(LibBalsaAddress * address, gint n)
/* Helper */
static const gchar *
-lba_get_name_or_mailbox(const InternetAddressList * address_list,
+lba_get_name_or_mailbox(InternetAddressList * address_list,
gboolean get_name, gboolean in_group)
{
const gchar *retval = NULL;
+ InternetAddress *ia;
+ gint i, len;
+
+ if (address_list == NULL)
+ return NULL;
- for (; address_list; address_list = address_list->next) {
- InternetAddress *ia = address_list->address;
+ len = internet_address_list_length(address_list);
+ for (i = 0; i < len; i++) {
+ ia = internet_address_list_get_address (address_list, i);
if (get_name && ia->name && *ia->name)
return ia->name;
- if (ia->type == INTERNET_ADDRESS_NAME)
- retval = ia->value.addr;
- else if (ia->type == INTERNET_ADDRESS_GROUP) {
+ if (INTERNET_ADDRESS_IS_MAILBOX (ia))
+ retval = INTERNET_ADDRESS_MAILBOX (ia)->addr;
+ else {
if (in_group)
g_message("Ignoring nested group address");
else
- retval = lba_get_name_or_mailbox(ia->value.members,
+ retval = lba_get_name_or_mailbox(INTERNET_ADDRESS_GROUP(ia)->members,
get_name, TRUE);
}
if (retval)
@@ -644,20 +646,42 @@ lba_get_name_or_mailbox(const InternetAddressList * address_list,
/* Get either a name or a mailbox from an InternetAddressList. */
const gchar *
-libbalsa_address_get_name_from_list(const InternetAddressList *
- address_list)
+libbalsa_address_get_name_from_list(InternetAddressList *address_list)
{
return lba_get_name_or_mailbox(address_list, TRUE, FALSE);
}
/* Get a mailbox from an InternetAddressList. */
const gchar *
-libbalsa_address_get_mailbox_from_list(const InternetAddressList *
- address_list)
+libbalsa_address_get_mailbox_from_list(InternetAddressList *address_list)
{
return lba_get_name_or_mailbox(address_list, FALSE, FALSE);
}
+/* Number of individual mailboxes in an InternetAddressList. */
+gint
+libbalsa_address_n_mailboxes_in_list(InternetAddressList * address_list)
+{
+ gint i, len, n_mailboxes = 0;
+
+ g_return_val_if_fail(IS_INTERNET_ADDRESS_LIST(address_list), -1);
+
+ len = internet_address_list_length(address_list);
+ for (i = 0; i < len; i++) {
+ const InternetAddress *ia =
+ internet_address_list_get_address(address_list, i);
+
+ if (INTERNET_ADDRESS_IS_MAILBOX(ia))
+ ++n_mailboxes;
+ else
+ n_mailboxes +=
+ libbalsa_address_n_mailboxes_in_list(INTERNET_ADDRESS_GROUP
+ (ia)->members);
+ }
+
+ return n_mailboxes;
+}
+
/* =================================================================== */
/* UI PART */
/* =================================================================== */
diff --git a/libbalsa/address.h b/libbalsa/address.h
index e51fbee..132e48e 100644
--- a/libbalsa/address.h
+++ b/libbalsa/address.h
@@ -95,11 +95,12 @@ gchar * libbalsa_address_extract_name(const gchar * string,
void libbalsa_address_set_copy(LibBalsaAddress *dest, LibBalsaAddress *src);
gchar *libbalsa_address_to_gchar(LibBalsaAddress * address, gint n);
-const gchar *libbalsa_address_get_name_from_list(const InternetAddressList
+const gchar *libbalsa_address_get_name_from_list(InternetAddressList
* address_list);
-const gchar *libbalsa_address_get_mailbox_from_list(const
- InternetAddressList *
+const gchar *libbalsa_address_get_mailbox_from_list(InternetAddressList *
address_list);
+gint libbalsa_address_n_mailboxes_in_list(InternetAddressList *
+ address_list);
/* =================================================================== */
/* UI PART */
diff --git a/libbalsa/body.c b/libbalsa/body.c
index cd6479a..3883377 100644
--- a/libbalsa/body.c
+++ b/libbalsa/body.c
@@ -116,11 +116,7 @@ libbalsa_message_body_extract_embedded_headers(GMimeMessage* msg)
subj = g_mime_message_get_subject(msg);
if (subj) {
ehdr->subject =
-#if HAVE_GMIME_2_2_5
g_mime_utils_header_decode_text(subj);
-#else
- g_mime_utils_header_decode_text((const unsigned char *) subj);
-#endif
libbalsa_utf8_sanitize(&ehdr->subject, TRUE, NULL);
} else
ehdr->subject = g_strdup(_("(No subject)"));
@@ -149,7 +145,7 @@ libbalsa_message_body_set_filename(LibBalsaMessageBody * body)
static void
libbalsa_message_body_set_types(LibBalsaMessageBody * body)
{
- const GMimeContentType *type;
+ GMimeContentType *type;
type = g_mime_object_get_content_type(body->mime_part);
if (g_mime_content_type_is_type(type, "audio", "*"))
@@ -193,7 +189,6 @@ libbalsa_message_body_set_message_part(LibBalsaMessageBody * body,
*next_part = libbalsa_message_body_new(body->message);
libbalsa_message_body_set_mime_body(*next_part,
embedded_message->mime_part);
- g_object_unref(embedded_message);
}
return *next_part ? &(*next_part)->next : next_part;
@@ -203,13 +198,16 @@ static LibBalsaMessageBody **
libbalsa_message_body_set_multipart(LibBalsaMessageBody * body,
LibBalsaMessageBody ** next_part)
{
- GList *child;
-
- for (child = GMIME_MULTIPART(body->mime_part)->subparts; child;
- child = child->next) {
+ GMimeMultipart *multipart = GMIME_MULTIPART(body->mime_part);
+ GMimeObject *part;
+ int count, i;
+
+ count = g_mime_multipart_get_count (multipart);
+ for (i = 0; i < count; i++) {
+ part = g_mime_multipart_get_part (multipart, i);
if (!*next_part)
*next_part = libbalsa_message_body_new(body->message);
- libbalsa_message_body_set_mime_body(*next_part, child->data);
+ libbalsa_message_body_set_mime_body(*next_part, part);
next_part = &(*next_part)->next;
}
@@ -263,19 +261,18 @@ gchar *
libbalsa_message_body_get_parameter(LibBalsaMessageBody * body,
const gchar * param)
{
+ GMimeContentType *type;
gchar *res = NULL;
g_return_val_if_fail(body != NULL, NULL);
if (body->mime_part) {
- const GMimeContentType *type =
- g_mime_object_get_content_type(body->mime_part);
+ type = g_mime_object_get_content_type(body->mime_part);
res = g_strdup(g_mime_content_type_get_parameter(type, param));
} else if (body->content_type) {
- GMimeContentType *type =
- g_mime_content_type_new_from_string(body->content_type);
+ type = g_mime_content_type_new_from_string(body->content_type);
res = g_strdup(g_mime_content_type_get_parameter(type, param));
- g_mime_content_type_destroy(type);
+ g_object_unref(type);
}
return res;
@@ -418,7 +415,7 @@ libbalsa_message_body_stream_add_filter(GMimeStream * stream,
{
if (!GMIME_IS_STREAM_FILTER(stream)) {
GMimeStream *filtered_stream =
- g_mime_stream_filter_new_with_stream(stream);
+ g_mime_stream_filter_new(stream);
g_object_unref(stream);
stream = filtered_stream;
}
@@ -435,7 +432,7 @@ libbalsa_message_body_get_part_stream(LibBalsaMessageBody * body,
{
GMimeStream *stream;
GMimeDataWrapper *wrapper;
- GMimePartEncodingType encoding;
+ GMimeContentEncoding encoding;
GMimeFilter *filter;
gchar *mime_type = NULL;
const gchar *charset;
@@ -449,22 +446,26 @@ libbalsa_message_body_get_part_stream(LibBalsaMessageBody * body,
return NULL;
}
- stream = g_mime_data_wrapper_get_stream(wrapper);
+ stream = g_object_ref(g_mime_data_wrapper_get_stream(wrapper));
encoding = g_mime_data_wrapper_get_encoding(wrapper);
- g_object_unref(wrapper);
switch (encoding) {
- case GMIME_PART_ENCODING_BASE64:
+ case GMIME_CONTENT_ENCODING_BASE64:
filter =
- g_mime_filter_basic_new_type(GMIME_FILTER_BASIC_BASE64_DEC);
+ g_mime_filter_basic_new(GMIME_CONTENT_ENCODING_BASE64,
+ FALSE);
stream = libbalsa_message_body_stream_add_filter(stream, filter);
break;
- case GMIME_PART_ENCODING_QUOTEDPRINTABLE:
- filter = g_mime_filter_basic_new_type(GMIME_FILTER_BASIC_QP_DEC);
+ case GMIME_CONTENT_ENCODING_QUOTEDPRINTABLE:
+ filter =
+ g_mime_filter_basic_new(GMIME_CONTENT_ENCODING_QUOTEDPRINTABLE,
+ FALSE);
stream = libbalsa_message_body_stream_add_filter(stream, filter);
break;
- case GMIME_PART_ENCODING_UUENCODE:
- filter = g_mime_filter_basic_new_type(GMIME_FILTER_BASIC_UU_DEC);
+ case GMIME_CONTENT_ENCODING_UUENCODE:
+ filter =
+ g_mime_filter_basic_new(GMIME_CONTENT_ENCODING_UUENCODE,
+ FALSE);
stream = libbalsa_message_body_stream_add_filter(stream, filter);
break;
default:
@@ -482,7 +483,7 @@ libbalsa_message_body_get_part_stream(LibBalsaMessageBody * body,
GMimeFilter *filter_windows;
stream_null = g_mime_stream_null_new();
- stream_filter = g_mime_stream_filter_new_with_stream(stream_null);
+ stream_filter = g_mime_stream_filter_new(stream_null);
g_object_unref(stream_null);
filter_windows = g_mime_filter_windows_new(charset);
@@ -676,9 +677,7 @@ libbalsa_message_body_save_stream(LibBalsaMessageBody * body,
g_mime_stream_reset(stream);
if (filter_crlf) {
- GMimeFilter *filter =
- g_mime_filter_crlf_new(GMIME_FILTER_CRLF_DECODE,
- GMIME_FILTER_CRLF_MODE_CRLF_ONLY);
+ GMimeFilter *filter = g_mime_filter_crlf_new(FALSE, FALSE);
stream =
libbalsa_message_body_stream_add_filter(stream, filter);
}
diff --git a/libbalsa/gmime-application-pkcs7.c b/libbalsa/gmime-application-pkcs7.c
index edc21e5..12f4f8f 100644
--- a/libbalsa/gmime-application-pkcs7.c
+++ b/libbalsa/gmime-application-pkcs7.c
@@ -50,7 +50,7 @@
static void
sign_prepare (GMimeObject *mime_part)
{
- GMimePartEncodingType encoding;
+ GMimeContentEncoding encoding;
GMimeObject *subpart;
if (GMIME_IS_MULTIPART (mime_part)) {
@@ -71,11 +71,11 @@ sign_prepare (GMimeObject *mime_part)
subpart = GMIME_MESSAGE_PART (mime_part)->message->mime_part;
sign_prepare (subpart);
} else {
- encoding = g_mime_part_get_encoding (GMIME_PART (mime_part));
+ encoding = g_mime_part_get_content_encoding (GMIME_PART (mime_part));
- if (encoding != GMIME_PART_ENCODING_BASE64)
- g_mime_part_set_encoding (GMIME_PART (mime_part),
- GMIME_PART_ENCODING_QUOTEDPRINTABLE);
+ if (encoding != GMIME_CONTENT_ENCODING_BASE64)
+ g_mime_part_set_content_encoding (GMIME_PART (mime_part),
+ GMIME_CONTENT_ENCODING_QUOTEDPRINTABLE);
}
}
@@ -105,7 +105,7 @@ g_mime_application_pkcs7_sign (GMimePart *pkcs7, GMimeObject *content,
/* get the cleartext */
stream = g_mime_stream_mem_new ();
- filtered_stream = g_mime_stream_filter_new_with_stream (stream);
+ filtered_stream = g_mime_stream_filter_new (stream);
/* See RFC 2633, Sect. 3.1- the following op's are "SHOULD", so we do it */
from_filter = g_mime_filter_from_new (GMIME_FILTER_FROM_MODE_ARMOR);
@@ -117,9 +117,9 @@ g_mime_application_pkcs7_sign (GMimePart *pkcs7, GMimeObject *content,
g_object_unref (filtered_stream);
g_mime_stream_reset (stream);
- filtered_stream = g_mime_stream_filter_new_with_stream (stream);
- crlf_filter = g_mime_filter_crlf_new (GMIME_FILTER_CRLF_ENCODE,
- GMIME_FILTER_CRLF_MODE_CRLF_ONLY);
+ filtered_stream = g_mime_stream_filter_new (stream);
+ crlf_filter = g_mime_filter_crlf_new (TRUE,
+ FALSE);
g_mime_stream_filter_add (GMIME_STREAM_FILTER (filtered_stream), crlf_filter);
g_object_unref (crlf_filter);
@@ -127,7 +127,7 @@ g_mime_application_pkcs7_sign (GMimePart *pkcs7, GMimeObject *content,
sig_data_stream = g_mime_stream_mem_new ();
/* get the signed content */
- if (g_mime_cipher_sign (ctx, userid, GMIME_CIPHER_HASH_DEFAULT, filtered_stream, sig_data_stream, err) == -1) {
+ if (g_mime_cipher_context_sign (ctx, userid, GMIME_CIPHER_HASH_DEFAULT, filtered_stream, sig_data_stream, err) == -1) {
g_object_unref (filtered_stream);
g_object_unref (sig_data_stream);
g_object_unref (stream);
@@ -144,8 +144,8 @@ g_mime_application_pkcs7_sign (GMimePart *pkcs7, GMimeObject *content,
g_object_unref(sig_data_stream);
g_mime_part_set_content_object(GMIME_PART(pkcs7), wrapper);
g_mime_part_set_filename(GMIME_PART(pkcs7), "smime.p7m");
- g_mime_part_set_encoding(GMIME_PART(pkcs7),
- GMIME_PART_ENCODING_BASE64);
+ g_mime_part_set_content_encoding(GMIME_PART(pkcs7),
+ GMIME_CONTENT_ENCODING_BASE64);
g_object_unref(wrapper);
/* set the content-type params for this part */
@@ -198,18 +198,17 @@ g_mime_application_pkcs7_verify(GMimePart * pkcs7,
ciphertext = g_mime_stream_mem_new ();
g_mime_data_wrapper_write_to_stream (wrapper, ciphertext);
g_mime_stream_reset(ciphertext);
- g_object_unref(wrapper);
stream = g_mime_stream_mem_new();
- filtered_stream = g_mime_stream_filter_new_with_stream(stream);
- crlf_filter = g_mime_filter_crlf_new(GMIME_FILTER_CRLF_DECODE,
- GMIME_FILTER_CRLF_MODE_CRLF_ONLY);
+ filtered_stream = g_mime_stream_filter_new(stream);
+ crlf_filter = g_mime_filter_crlf_new(FALSE,
+ FALSE);
g_mime_stream_filter_add(GMIME_STREAM_FILTER(filtered_stream),
crlf_filter);
g_object_unref(crlf_filter);
/* get the cleartext */
- *validity = g_mime_cipher_verify(ctx, GMIME_CIPHER_HASH_DEFAULT,
+ *validity = g_mime_cipher_context_verify(ctx, GMIME_CIPHER_HASH_DEFAULT,
ciphertext, filtered_stream, err);
if (!*validity) {
g_object_unref(filtered_stream);
@@ -264,10 +263,10 @@ g_mime_application_pkcs7_encrypt (GMimePart *pkcs7, GMimeObject *content,
/* get the cleartext */
stream = g_mime_stream_mem_new ();
- filtered_stream = g_mime_stream_filter_new_with_stream (stream);
+ filtered_stream = g_mime_stream_filter_new (stream);
- crlf_filter = g_mime_filter_crlf_new (GMIME_FILTER_CRLF_ENCODE,
- GMIME_FILTER_CRLF_MODE_CRLF_ONLY);
+ crlf_filter = g_mime_filter_crlf_new (TRUE,
+ FALSE);
g_mime_stream_filter_add (GMIME_STREAM_FILTER (filtered_stream), crlf_filter);
g_object_unref (crlf_filter);
@@ -280,7 +279,7 @@ g_mime_application_pkcs7_encrypt (GMimePart *pkcs7, GMimeObject *content,
/* encrypt the content stream */
ciphertext = g_mime_stream_mem_new ();
- if (g_mime_cipher_encrypt (ctx, FALSE, NULL, recipients, stream, ciphertext, err) == -1) {
+ if (g_mime_cipher_context_encrypt (ctx, FALSE, NULL, recipients, stream, ciphertext, err) == -1) {
g_object_unref (ciphertext);
g_object_unref (stream);
return -1;
@@ -295,7 +294,7 @@ g_mime_application_pkcs7_encrypt (GMimePart *pkcs7, GMimeObject *content,
g_object_unref(ciphertext);
g_mime_part_set_content_object(GMIME_PART(pkcs7), wrapper);
g_mime_part_set_filename(GMIME_PART(pkcs7), "smime.p7m");
- g_mime_part_set_encoding(GMIME_PART(pkcs7), GMIME_PART_ENCODING_BASE64);
+ g_mime_part_set_content_encoding(GMIME_PART(pkcs7), GMIME_CONTENT_ENCODING_BASE64);
g_object_unref(wrapper);
/* set the content-type params for this part */
@@ -344,18 +343,17 @@ g_mime_application_pkcs7_decrypt (GMimePart *pkcs7, GMimeCipherContext *ctx,
ciphertext = g_mime_stream_mem_new();
g_mime_data_wrapper_write_to_stream (wrapper, ciphertext);
g_mime_stream_reset(ciphertext);
- g_object_unref(wrapper);
stream = g_mime_stream_mem_new();
- filtered_stream = g_mime_stream_filter_new_with_stream(stream);
- crlf_filter = g_mime_filter_crlf_new(GMIME_FILTER_CRLF_DECODE,
- GMIME_FILTER_CRLF_MODE_CRLF_ONLY);
+ filtered_stream = g_mime_stream_filter_new(stream);
+ crlf_filter = g_mime_filter_crlf_new(FALSE,
+ FALSE);
g_mime_stream_filter_add(GMIME_STREAM_FILTER(filtered_stream),
crlf_filter);
g_object_unref(crlf_filter);
/* get the cleartext */
- if (g_mime_cipher_decrypt(ctx, ciphertext, filtered_stream, err) == -1) {
+ if (g_mime_cipher_context_decrypt(ctx, ciphertext, filtered_stream, err) == NULL) {
g_object_unref(filtered_stream);
g_object_unref(ciphertext);
g_object_unref(stream);
diff --git a/libbalsa/gmime-gpgme-context.c b/libbalsa/gmime-gpgme-context.c
index 3f28842..a13c260 100644
--- a/libbalsa/gmime-gpgme-context.c
+++ b/libbalsa/gmime-gpgme-context.c
@@ -64,9 +64,11 @@ static int g_mime_gpgme_encrypt(GMimeCipherContext * ctx, gboolean sign,
GMimeStream * istream,
GMimeStream * ostream, GError ** err);
-static int g_mime_gpgme_decrypt(GMimeCipherContext * ctx,
- GMimeStream * istream,
- GMimeStream * ostream, GError ** err);
+static GMimeSignatureValidity *g_mime_gpgme_decrypt(GMimeCipherContext *
+ ctx,
+ GMimeStream * istream,
+ GMimeStream * ostream,
+ GError ** err);
/* internal passphrase callback */
@@ -636,7 +638,7 @@ g_mime_gpgme_encrypt(GMimeCipherContext * context, gboolean sign,
* Decrypt istream to ostream. In RFC 2440 mode, also try to check an included
* signature (if any).
*/
-static int
+static GMimeSignatureValidity *
g_mime_gpgme_decrypt(GMimeCipherContext * context, GMimeStream * istream,
GMimeStream * ostream, GError ** error)
{
@@ -651,10 +653,11 @@ g_mime_gpgme_decrypt(GMimeCipherContext * context, GMimeStream * istream,
NULL, /* seek method */
cb_data_release /* release method */
};
+ GMimeSignatureValidity *validity;
/* some paranoia checks */
- g_return_val_if_fail(ctx, -1);
- g_return_val_if_fail(ctx->gpgme_ctx, -1);
+ g_return_val_if_fail(ctx, NULL);
+ g_return_val_if_fail(ctx->gpgme_ctx, NULL);
gpgme_ctx = ctx->gpgme_ctx;
protocol = gpgme_get_protocol(gpgme_ctx);
@@ -674,13 +677,13 @@ g_mime_gpgme_decrypt(GMimeCipherContext * context, GMimeStream * istream,
gpgme_data_new_from_cbs(&crypt, &cbs,
istream)) != GPG_ERR_NO_ERROR) {
g_set_error_from_gpgme(error, err, _("could not get data from stream"));
- return -1;
+ return NULL;
}
if ((err = gpgme_data_new_from_cbs(&plain, &cbs, ostream)) !=
GPG_ERR_NO_ERROR) {
g_set_error_from_gpgme(error, err, _("could not create new data object"));
gpgme_data_release(crypt);
- return -1;
+ return NULL;
}
/* try to decrypt */
@@ -690,7 +693,7 @@ g_mime_gpgme_decrypt(GMimeCipherContext * context, GMimeStream * istream,
g_set_error_from_gpgme(error, err, _("decryption failed"));
gpgme_data_release(plain);
gpgme_data_release(crypt);
- return -1;
+ return NULL;
}
gpgme_data_release(plain);
gpgme_data_release(crypt);
@@ -698,7 +701,23 @@ g_mime_gpgme_decrypt(GMimeCipherContext * context, GMimeStream * istream,
/* try to get information about the signature (if any) */
ctx->sig_state = g_mime_gpgme_sigstat_new_from_gpgme_ctx(gpgme_ctx);
- return 0;
+ validity = g_mime_signature_validity_new();
+ if (ctx->sig_state) {
+ switch (ctx->sig_state->status)
+ {
+ case GPG_ERR_NO_ERROR:
+ g_mime_signature_validity_set_status(validity, GMIME_SIGNATURE_STATUS_GOOD);
+ break;
+ case GPG_ERR_NOT_SIGNED:
+ g_mime_signature_validity_set_status(validity, GMIME_SIGNATURE_STATUS_UNKNOWN);
+ break;
+ default:
+ g_mime_signature_validity_set_status(validity, GMIME_SIGNATURE_STATUS_BAD);
+ }
+ } else
+ g_mime_signature_validity_set_status(validity, GMIME_SIGNATURE_STATUS_UNKNOWN);
+
+ return validity;
}
diff --git a/libbalsa/gmime-part-rfc2440.c b/libbalsa/gmime-part-rfc2440.c
index e4e9f01..795d2e1 100644
--- a/libbalsa/gmime-part-rfc2440.c
+++ b/libbalsa/gmime-part-rfc2440.c
@@ -42,14 +42,11 @@ g_mime_part_check_rfc2440(GMimePart * part)
/* try to get the content stream */
wrapper = g_mime_part_get_content_object(part);
g_return_val_if_fail(wrapper, GMIME_PART_RFC2440_NONE);
+
stream = g_mime_data_wrapper_get_stream(wrapper);
- g_object_unref(wrapper);
- if (!stream)
- return retval;
- if ((slen = g_mime_stream_length(stream)) == -1) {
- g_object_unref(stream);
+ if (!stream || (slen = g_mime_stream_length(stream)) < 0)
return retval;
- }
+
g_mime_stream_reset(stream);
/* check if the complete stream fits in the buffer */
@@ -89,7 +86,6 @@ g_mime_part_check_rfc2440(GMimePart * part)
}
}
- g_object_unref(stream);
return retval;
}
@@ -124,7 +120,6 @@ g_mime_part_rfc2440_sign_encrypt(GMimePart * part,
wrapper = g_mime_part_get_content_object(part);
g_return_val_if_fail(wrapper, -1); /* Incomplete part. */
stream = g_mime_data_wrapper_get_stream(wrapper);
- g_object_unref(wrapper);
g_mime_stream_reset(stream);
/* construct the stream for the crypto output */
@@ -136,15 +131,14 @@ g_mime_part_rfc2440_sign_encrypt(GMimePart * part,
ctx->singlepart_mode = TRUE;
if (recipients == NULL)
result =
- g_mime_cipher_sign(GMIME_CIPHER_CONTEXT(ctx), sign_userid,
+ g_mime_cipher_context_sign(GMIME_CIPHER_CONTEXT(ctx), sign_userid,
GMIME_CIPHER_HASH_DEFAULT, stream,
cipherstream, err);
else
result =
- g_mime_cipher_encrypt(GMIME_CIPHER_CONTEXT(ctx),
+ g_mime_cipher_context_encrypt(GMIME_CIPHER_CONTEXT(ctx),
sign_userid != NULL, sign_userid,
recipients, stream, cipherstream, err);
- g_object_unref(stream);
if (result == -1) {
g_object_unref(cipherstream);
return -1;
@@ -180,15 +174,15 @@ g_mime_part_rfc2440_sign_encrypt(GMimePart * part,
* and set the charset to us-ascii instead, as gpg added it's own armor.
*/
if (recipients == NULL) {
- if (g_mime_part_get_encoding(part) != GMIME_PART_ENCODING_BASE64)
- g_mime_part_set_encoding(part,
- GMIME_PART_ENCODING_QUOTEDPRINTABLE);
+ if (g_mime_part_get_content_encoding(part) != GMIME_CONTENT_ENCODING_BASE64)
+ g_mime_part_set_content_encoding(part,
+ GMIME_CONTENT_ENCODING_QUOTEDPRINTABLE);
g_mime_data_wrapper_set_encoding(wrapper,
- GMIME_PART_ENCODING_DEFAULT);
+ GMIME_CONTENT_ENCODING_DEFAULT);
} else {
- g_mime_part_set_encoding(part, GMIME_PART_ENCODING_7BIT);
+ g_mime_part_set_content_encoding(part, GMIME_CONTENT_ENCODING_7BIT);
g_mime_data_wrapper_set_encoding(wrapper,
- GMIME_PART_ENCODING_7BIT);
+ GMIME_CONTENT_ENCODING_7BIT);
g_mime_object_set_content_type_parameter(GMIME_OBJECT(part),
"charset", "US-ASCII");
}
@@ -212,7 +206,7 @@ GMimeSignatureValidity *
g_mime_part_rfc2440_verify(GMimePart * part,
GMimeGpgmeContext * ctx, GError ** err)
{
- GMimeStream *stream, *plainstream, *wrapper_stream;
+ GMimeStream *stream, *plainstream;
GMimeDataWrapper * wrapper;
GMimeSignatureValidity *valid;
@@ -224,12 +218,9 @@ g_mime_part_rfc2440_verify(GMimePart * part,
/* get the raw content */
wrapper = g_mime_part_get_content_object(GMIME_PART(part));
g_return_val_if_fail(wrapper, NULL); /* Incomplete part. */
- wrapper_stream = g_mime_data_wrapper_get_stream(wrapper);
stream = g_mime_stream_mem_new();
g_mime_data_wrapper_write_to_stream(wrapper, stream);
- g_object_unref(wrapper_stream);
g_mime_stream_reset(stream);
- g_object_unref(wrapper);
/* construct the stream for the checked output */
plainstream = g_mime_stream_mem_new();
@@ -237,10 +228,9 @@ g_mime_part_rfc2440_verify(GMimePart * part,
/* verify the signature */
ctx->singlepart_mode = TRUE;
valid =
- g_mime_cipher_verify(GMIME_CIPHER_CONTEXT(ctx),
+ g_mime_cipher_context_verify(GMIME_CIPHER_CONTEXT(ctx),
GMIME_CIPHER_HASH_DEFAULT, stream,
plainstream, err);
- g_object_unref(stream);
/* upon success, replace the signed content by the checked one */
if (valid) {
@@ -265,26 +255,25 @@ g_mime_part_rfc2440_verify(GMimePart * part,
* verified and the result is placed in ctx by the underlying gpgme
* context.
*/
-int
+GMimeSignatureValidity *
g_mime_part_rfc2440_decrypt(GMimePart * part,
GMimeGpgmeContext * ctx, GError ** err)
{
GMimeStream *stream, *plainstream;
GMimeDataWrapper * wrapper;
- gint result;
+ GMimeSignatureValidity *result;
gchar *headbuf = g_malloc0(1024);
- g_return_val_if_fail(GMIME_IS_PART(part), -1);
- g_return_val_if_fail(GMIME_IS_GPGME_CONTEXT(ctx), -1);
+ g_return_val_if_fail(GMIME_IS_PART(part), NULL);
+ g_return_val_if_fail(GMIME_IS_GPGME_CONTEXT(ctx), NULL);
g_return_val_if_fail(GMIME_CIPHER_CONTEXT(ctx)->encrypt_protocol !=
- NULL, -1);
+ NULL, NULL);
/* get the raw content */
wrapper = g_mime_part_get_content_object(part);
- g_return_val_if_fail(wrapper, -1); /* Incomplete part. */
+ g_return_val_if_fail(wrapper, NULL); /* Incomplete part. */
stream = g_mime_stream_mem_new();
g_mime_data_wrapper_write_to_stream(wrapper, stream);
- g_object_unref(wrapper);
g_mime_stream_reset(stream);
g_mime_stream_read(stream, headbuf, 1023);
@@ -295,19 +284,18 @@ g_mime_part_rfc2440_decrypt(GMimePart * part,
/* decrypt and (if possible) verify the input */
result =
- g_mime_cipher_decrypt(GMIME_CIPHER_CONTEXT(ctx), stream,
+ g_mime_cipher_context_decrypt(GMIME_CIPHER_CONTEXT(ctx), stream,
plainstream, err);
- if (result == 0) {
+ if (result != NULL) {
GMimeStream *filter_stream;
GMimeStream *out_stream;
GMimeFilter *filter;
GMimeDataWrapper *wrapper = g_mime_data_wrapper_new();
/* strip crlf off encrypted stuff coming from Winbloze crap */
- filter_stream = g_mime_stream_filter_new_with_stream(plainstream);
- filter = g_mime_filter_crlf_new(GMIME_FILTER_CRLF_DECODE,
- GMIME_FILTER_CRLF_MODE_CRLF_ONLY);
+ filter_stream = g_mime_stream_filter_new(plainstream);
+ filter = g_mime_filter_crlf_new(FALSE, FALSE);
g_mime_stream_filter_add(GMIME_STREAM_FILTER(filter_stream), filter);
g_object_unref(filter);
@@ -315,12 +303,11 @@ g_mime_part_rfc2440_decrypt(GMimePart * part,
out_stream = g_mime_stream_mem_new();
g_mime_data_wrapper_set_stream(wrapper, out_stream);
g_mime_part_set_content_object(part, wrapper);
- g_object_unref(wrapper);
g_mime_stream_reset(filter_stream);
g_mime_stream_write_to_stream(filter_stream, out_stream);
g_object_unref(filter_stream);
- g_mime_part_set_encoding(part, GMIME_PART_ENCODING_8BIT);
+ g_mime_part_set_content_encoding(part, GMIME_CONTENT_ENCODING_8BIT);
/*
* Set the charset of the decrypted content to the RFC 2440 "Charset:"
diff --git a/libbalsa/gmime-part-rfc2440.h b/libbalsa/gmime-part-rfc2440.h
index cb1392f..48be5a4 100644
--- a/libbalsa/gmime-part-rfc2440.h
+++ b/libbalsa/gmime-part-rfc2440.h
@@ -56,8 +56,9 @@ int g_mime_part_rfc2440_sign_encrypt(GMimePart * part,
GMimeSignatureValidity *g_mime_part_rfc2440_verify(GMimePart * part,
GMimeGpgmeContext * ctx,
GError ** err);
-gint g_mime_part_rfc2440_decrypt(GMimePart * part,
- GMimeGpgmeContext * ctx, GError ** err);
+GMimeSignatureValidity *g_mime_part_rfc2440_decrypt(GMimePart * part,
+ GMimeGpgmeContext *
+ ctx, GError ** err);
#ifdef __cplusplus
}
diff --git a/libbalsa/gmime-stream-gio.c b/libbalsa/gmime-stream-gio.c
index 6e925cc..ba5c292 100644
--- a/libbalsa/gmime-stream-gio.c
+++ b/libbalsa/gmime-stream-gio.c
@@ -48,14 +48,14 @@ static int stream_flush(GMimeStream *stream);
static int stream_close(GMimeStream *stream);
static gboolean stream_eos(GMimeStream *stream);
static int stream_reset(GMimeStream *stream);
-static off_t stream_seek(GMimeStream *stream,
- off_t offset,
+static gint64 stream_seek(GMimeStream *stream,
+ gint64 offset,
GMimeSeekWhence whence);
-static off_t stream_tell(GMimeStream *stream);
+static gint64 stream_tell(GMimeStream *stream);
static ssize_t stream_length(GMimeStream *stream);
static GMimeStream *stream_substream(GMimeStream *stream,
- off_t start,
- off_t end);
+ gint64 start,
+ gint64 end);
static GMimeStreamClass *parent_class = NULL;
@@ -167,7 +167,7 @@ stream_read(GMimeStream *stream, char *buf, size_t len)
return -1;
if (stream->bound_end != -1)
- len = MIN (stream->bound_end - stream->position, (off_t) len);
+ len = MIN (stream->bound_end - stream->position, (gint64) len);
/* try to create the stream if necessary */
if (!gios->stream) {
@@ -206,7 +206,7 @@ stream_write(GMimeStream *stream, const char *buf, size_t len)
return -1;
if (stream->bound_end != -1)
- len = MIN (stream->bound_end - stream->position, (off_t) len);
+ len = MIN (stream->bound_end - stream->position, (gint64) len);
/* try to create the stream if necessary */
if (!gios->stream) {
@@ -299,8 +299,8 @@ stream_reset(GMimeStream *stream)
return 0;
}
-static off_t
-stream_seek(GMimeStream *stream, off_t offset, GMimeSeekWhence whence)
+static gint64
+stream_seek(GMimeStream *stream, gint64 offset, GMimeSeekWhence whence)
{
GMimeStreamGio *gios = (GMimeStreamGio *) stream;
goffset real;
@@ -373,7 +373,7 @@ stream_seek(GMimeStream *stream, off_t offset, GMimeSeekWhence whence)
return real;
}
-static off_t
+static gint64
stream_tell (GMimeStream *stream)
{
g_return_val_if_fail(stream, -1);
@@ -413,7 +413,7 @@ stream_length(GMimeStream *stream)
}
static GMimeStream *
-stream_substream(GMimeStream *stream, off_t start, off_t end)
+stream_substream(GMimeStream *stream, gint64 start, gint64 end)
{
GMimeStreamGio *gios;
@@ -466,7 +466,7 @@ g_mime_stream_gio_new(GFile * gfile)
* Returns: a stream using @fd with bounds @start and @end.
**/
GMimeStream *
-g_mime_stream_gio_new_with_bounds(GFile * gfile, off_t start, off_t end)
+g_mime_stream_gio_new_with_bounds(GFile * gfile, gint64 start, gint64 end)
{
GMimeStreamGio *gios;
diff --git a/libbalsa/gmime-stream-gio.h b/libbalsa/gmime-stream-gio.h
index 649837c..251fcf6 100644
--- a/libbalsa/gmime-stream-gio.h
+++ b/libbalsa/gmime-stream-gio.h
@@ -63,8 +63,8 @@ GType g_mime_stream_gio_get_type(void);
GMimeStream *g_mime_stream_gio_new(GFile * gfile);
GMimeStream *g_mime_stream_gio_new_with_bounds(GFile * gfile,
- off_t start,
- off_t end);
+ gint64 start,
+ gint64 end);
G_END_DECLS
diff --git a/libbalsa/gmime-stream-gnome-vfs.c b/libbalsa/gmime-stream-gnome-vfs.c
index 6cc5bfb..d7bafa1 100644
--- a/libbalsa/gmime-stream-gnome-vfs.c
+++ b/libbalsa/gmime-stream-gnome-vfs.c
@@ -56,12 +56,12 @@ static int stream_flush(GMimeStream * stream);
static int stream_close(GMimeStream * stream);
static gboolean stream_eos(GMimeStream * stream);
static int stream_reset(GMimeStream * stream);
-static off_t stream_seek(GMimeStream * stream, off_t offset,
+static gint64 stream_seek(GMimeStream * stream, gint64 offset,
GMimeSeekWhence whence);
-static off_t stream_tell(GMimeStream * stream);
+static gint64 stream_tell(GMimeStream * stream);
static ssize_t stream_length(GMimeStream * stream);
-static GMimeStream *stream_substream(GMimeStream * stream, off_t start,
- off_t end);
+static GMimeStream *stream_substream(GMimeStream * stream, gint64 start,
+ gint64 end);
static GMimeStreamClass *parent_class = NULL;
@@ -147,7 +147,7 @@ stream_read(GMimeStream * stream, char *buf, size_t len)
return -1;
if (stream->bound_end != -1)
- len = MIN(stream->bound_end - stream->position, (off_t) len);
+ len = MIN(stream->bound_end - stream->position, (gint64) len);
/* make sure we are at the right position */
gnome_vfs_seek(gvfs->handle, GNOME_VFS_SEEK_START, stream->position);
@@ -178,7 +178,7 @@ stream_write(GMimeStream * stream, const char *buf, size_t len)
return -1;
if (stream->bound_end != -1)
- len = MIN(stream->bound_end - stream->position, (off_t) len);
+ len = MIN(stream->bound_end - stream->position, (gint64) len);
/* make sure we are at the right position */
gnome_vfs_seek(gvfs->handle, GNOME_VFS_SEEK_START, stream->position);
@@ -267,11 +267,11 @@ stream_reset(GMimeStream * stream)
return 0;
}
-static off_t
-stream_seek(GMimeStream * stream, off_t offset, GMimeSeekWhence whence)
+static gint64
+stream_seek(GMimeStream * stream, gint64 offset, GMimeSeekWhence whence)
{
GMimeStreamGvfs *gvfs = (GMimeStreamGvfs *) stream;
- off_t real;
+ gint64 real;
GnomeVFSFileSize gvfs_real;
g_return_val_if_fail(gvfs->handle != NULL, -1);
@@ -323,7 +323,7 @@ stream_seek(GMimeStream * stream, off_t offset, GMimeSeekWhence whence)
gnome_vfs_tell(gvfs->handle, &gvfs_real) != GNOME_VFS_OK)
return -1;
else
- real = (off_t) gvfs_real;
+ real = (gint64) gvfs_real;
/* reset eos if appropriate */
if ((stream->bound_end != -1 && real < stream->bound_end) ||
@@ -335,7 +335,7 @@ stream_seek(GMimeStream * stream, off_t offset, GMimeSeekWhence whence)
return real;
}
-static off_t
+static gint64
stream_tell(GMimeStream * stream)
{
return stream->position;
@@ -353,14 +353,14 @@ stream_length(GMimeStream * stream)
if (gnome_vfs_seek(gvfs->handle, GNOME_VFS_SEEK_END, 0) != GNOME_VFS_OK ||
gnome_vfs_tell(gvfs->handle, &bound_end) != GNOME_VFS_OK ||
gnome_vfs_seek(gvfs->handle, GNOME_VFS_SEEK_START, stream->position) != GNOME_VFS_OK ||
- (off_t) bound_end < stream->bound_start)
+ (gint64) bound_end < stream->bound_start)
return -1;
- return (off_t) bound_end - stream->bound_start;
+ return (ssize_t) bound_end - stream->bound_start;
}
static GMimeStream *
-stream_substream(GMimeStream * stream, off_t start, off_t end)
+stream_substream(GMimeStream * stream, gint64 start, gint64 end)
{
GMimeStreamGvfs *gvfs;
@@ -392,7 +392,7 @@ g_mime_stream_gvfs_new(GnomeVFSHandle * handle)
start = 0;
gvfs = g_object_new(GMIME_TYPE_STREAM_GVFS, NULL);
- g_mime_stream_construct(GMIME_STREAM(gvfs), (off_t) start, -1);
+ g_mime_stream_construct(GMIME_STREAM(gvfs), (gint64) start, -1);
gvfs->owner = TRUE;
gvfs->eos = FALSE;
gvfs->handle = handle;
@@ -413,7 +413,7 @@ g_mime_stream_gvfs_new(GnomeVFSHandle * handle)
* Returns a stream using @handle with bounds @start and @end.
**/
GMimeStream *
-g_mime_stream_gvfs_new_with_bounds(GnomeVFSHandle * handle, off_t start, off_t end)
+g_mime_stream_gvfs_new_with_bounds(GnomeVFSHandle * handle, gint64 start, gint64 end)
{
GMimeStreamGvfs *gvfs;
diff --git a/libbalsa/gmime-stream-gnome-vfs.h b/libbalsa/gmime-stream-gnome-vfs.h
index 6c8eff3..0916829 100644
--- a/libbalsa/gmime-stream-gnome-vfs.h
+++ b/libbalsa/gmime-stream-gnome-vfs.h
@@ -63,8 +63,8 @@ GType g_mime_stream_gvfs_get_type(void);
GMimeStream *g_mime_stream_gvfs_new(GnomeVFSHandle * handle);
GMimeStream *g_mime_stream_gvfs_new_with_bounds(GnomeVFSHandle * handle,
- off_t start,
- off_t end);
+ gint64 start,
+ gint64 end);
gboolean g_mime_stream_gvfs_get_owner(GMimeStreamGvfs * stream);
void g_mime_stream_gvfs_set_owner(GMimeStreamGvfs * stream,
diff --git a/libbalsa/html.c b/libbalsa/html.c
index 3c67b68..b16249f 100644
--- a/libbalsa/html.c
+++ b/libbalsa/html.c
@@ -791,7 +791,7 @@ libbalsa_html_filter(LibBalsaHTMLType html_type, gchar ** text, guint len)
array = g_byte_array_new();
g_mime_stream_mem_set_byte_array(GMIME_STREAM_MEM(stream), array);
- filter_stream = g_mime_stream_filter_new_with_stream(stream);
+ filter_stream = g_mime_stream_filter_new(stream);
g_object_unref(stream);
filter = g_mime_filter_enriched_new(flags);
diff --git a/libbalsa/identity.c b/libbalsa/identity.c
index 563fc2f..a480d5d 100644
--- a/libbalsa/identity.c
+++ b/libbalsa/identity.c
@@ -100,7 +100,7 @@ static void
libbalsa_identity_init(LibBalsaIdentity* ident)
{
ident->identity_name = NULL;
- ident->ia = internet_address_new();
+ ident->ia = NULL;
ident->replyto = NULL;
ident->domain = NULL;
ident->bcc = NULL;
@@ -137,7 +137,8 @@ libbalsa_identity_finalize(GObject * object)
{
LibBalsaIdentity *ident = LIBBALSA_IDENTITY(object);
- internet_address_unref(ident->ia);
+ if (ident->ia)
+ g_object_unref(ident->ia);
g_free(ident->identity_name);
g_free(ident->replyto);
g_free(ident->domain);
@@ -205,7 +206,8 @@ libbalsa_identity_set_address(LibBalsaIdentity * ident,
{
g_return_if_fail(ident != NULL);
- internet_address_unref(ident->ia);
+ if (ident->ia)
+ g_object_unref(ident->ia);
ident->ia = ia;
}
@@ -1449,16 +1451,15 @@ ident_dialog_update(GObject * dlg)
g_free(id->identity_name); id->identity_name = text;
set_identity_name_in_tree(GTK_TREE_VIEW(tree), id, text);
- text = ident_dialog_get_text(dlg, "identity-fullname");
- g_return_val_if_fail(text != NULL, FALSE);
- ia = internet_address_new();
- internet_address_set_name(ia, text);
- g_free(text);
-
text = ident_dialog_get_text(dlg, "identity-address");
- internet_address_set_addr(ia, text);
+ g_return_val_if_fail(text != NULL, FALSE);
+ ia = internet_address_mailbox_new(NULL, text);
g_free(text);
+
+ text = ident_dialog_get_text(dlg, "identity-fullname");
+ internet_address_set_name(ia, text);
libbalsa_identity_set_address(id, ia);
+ g_free(text);
g_free(id->replyto);
id->replyto = ident_dialog_get_text(dlg, "identity-replyto");
@@ -1827,10 +1828,10 @@ display_frame_update(GObject * dialog, LibBalsaIdentity* ident)
ident_dialog_update(dialog);
display_frame_set_field(dialog, "identity-name", ident->identity_name);
- display_frame_set_field(dialog, "identity-fullname", ident->ia->name);
- if (ident->ia->type == INTERNET_ADDRESS_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-address",
- ident->ia->value.addr);
+ INTERNET_ADDRESS_MAILBOX(ident->ia)->addr);
else
display_frame_set_field(dialog, "identity-address", NULL);
@@ -1941,17 +1942,16 @@ LibBalsaIdentity*
libbalsa_identity_new_config(const gchar* name)
{
LibBalsaIdentity* ident;
+ gchar *fname, *email;
gchar* tmpstr;
+ fname = libbalsa_conf_get_string("FullName");
+ email = libbalsa_conf_get_string("Address");
+
ident = LIBBALSA_IDENTITY(libbalsa_identity_new_with_name(name));
-
- tmpstr = libbalsa_conf_get_string("FullName");
- internet_address_set_name(ident->ia, tmpstr);
- g_free(tmpstr);
-
- tmpstr = libbalsa_conf_get_string("Address");
- internet_address_set_addr(ident->ia, tmpstr);
- g_free(tmpstr);
+ ident->ia = internet_address_mailbox_new (fname, email);
+ g_free(fname);
+ g_free(email);
ident->replyto = libbalsa_conf_get_string("ReplyTo");
ident->domain = libbalsa_conf_get_string("Domain");
@@ -2002,10 +2002,10 @@ libbalsa_identity_save(LibBalsaIdentity* ident, const gchar* group)
g_return_if_fail(ident);
libbalsa_conf_push_group(group);
- libbalsa_conf_set_string("FullName", ident->ia->name);
+ libbalsa_conf_set_string("FullName", ident->ia ? ident->ia->name : NULL);
- if (ident->ia->type == INTERNET_ADDRESS_NAME)
- libbalsa_conf_set_string("Address", ident->ia->value.addr);
+ if (ident->ia && INTERNET_ADDRESS_IS_MAILBOX (ident->ia))
+ libbalsa_conf_set_string("Address", INTERNET_ADDRESS_MAILBOX(ident->ia)->addr);
libbalsa_conf_set_string("ReplyTo", ident->replyto);
libbalsa_conf_set_string("Domain", ident->domain);
diff --git a/libbalsa/libbalsa.c b/libbalsa/libbalsa.c
index 176bd02..743bfc3 100644
--- a/libbalsa/libbalsa.c
+++ b/libbalsa/libbalsa.c
@@ -640,7 +640,12 @@ gboolean
libbalsa_abort_on_timeout(const char *host)
{ /* It appears not to be entirely thread safe... Some locks do not
get released as they should be. */
- return libbalsa_ask(ask_timeout_real, (void*)host) != 0;
+ char *hostname;
+
+ hostname = g_alloca (strlen (host) + 1);
+ strcpy (hostname, host);
+
+ return libbalsa_ask(ask_timeout_real, hostname) != 0;
}
@@ -847,9 +852,9 @@ libbalsa_get_image_from_face_header(const gchar * content, GError ** err)
GtkWidget *image = NULL;
stream = g_mime_stream_mem_new();
- stream_filter = g_mime_stream_filter_new_with_stream(stream);
+ stream_filter = g_mime_stream_filter_new(stream);
- filter = g_mime_filter_basic_new_type(GMIME_FILTER_BASIC_BASE64_DEC);
+ filter = g_mime_filter_basic_new(GMIME_CONTENT_ENCODING_BASE64, FALSE);
g_mime_stream_filter_add(GMIME_STREAM_FILTER(stream_filter), filter);
g_object_unref(filter);
diff --git a/libbalsa/mailbox.c b/libbalsa/mailbox.c
index 0c515b8..7ee9b6f 100644
--- a/libbalsa/mailbox.c
+++ b/libbalsa/mailbox.c
@@ -286,29 +286,62 @@ libbalsa_mailbox_dispose(GObject * object)
static gchar*
get_from_field(LibBalsaMessage *message)
{
- gboolean append_dots = FALSE;
+ InternetAddressList *address_list = NULL;
const gchar *name_str = NULL;
+ gboolean append_dots = FALSE;
gchar *from;
- const InternetAddressList *address_list = NULL;
g_return_val_if_fail(message->mailbox, NULL);
- if (message->mailbox->view &&
- message->mailbox->view->show == LB_MAILBOX_SHOW_TO) {
- if (message->headers && message->headers->to_list) {
+
+ if (message->headers) {
+ if (message->mailbox->view &&
+ message->mailbox->view->show == LB_MAILBOX_SHOW_TO)
address_list = message->headers->to_list;
- append_dots = internet_address_list_length(address_list) > 1;
- }
- } else {
- if (message->headers && message->headers->from)
+ else
address_list = message->headers->from;
}
- name_str = libbalsa_address_get_name_from_list(address_list);
- if(!name_str) /* !addy, or addy contained no name/address */
+
+ if (address_list) {
+ gint i, len = internet_address_list_length(address_list);
+
+ for (i = 0; i < len && name_str == NULL; i++) {
+ InternetAddress *ia =
+ internet_address_list_get_address(address_list, i);
+ if (ia->name && *ia->name) {
+ name_str = ia->name;
+ if (i < len - 1)
+ append_dots = TRUE;
+ } else if (INTERNET_ADDRESS_IS_MAILBOX(ia)) {
+ name_str = ((InternetAddressMailbox *) ia)->addr;
+ if (i < len - 1)
+ append_dots = TRUE;
+ } else {
+ InternetAddressGroup *g = (InternetAddressGroup *) ia;
+ gint gi, glen =
+ internet_address_list_length(g->members);
+ for (gi = 0; gi < glen && name_str == NULL; gi++) {
+ InternetAddress *ia2 =
+ internet_address_list_get_address(g->members, gi);
+ if (ia2->name && *ia2->name) {
+ name_str = ia2->name;
+ if (gi < glen - 1)
+ append_dots = TRUE;
+ } else if (INTERNET_ADDRESS_IS_MAILBOX(ia2)) {
+ name_str = ((InternetAddressMailbox *) ia2)->addr;
+ if (gi < glen - 1)
+ append_dots = TRUE;
+ }
+ }
+ }
+ }
+ }
+
+ if (name_str == NULL)
name_str = "";
-
from = append_dots ? g_strconcat(name_str, ",...", NULL)
: g_strdup(name_str);
libbalsa_utf8_sanitize(&from, TRUE, NULL);
+
return from;
}
@@ -2131,7 +2164,7 @@ void
libbalsa_mailbox_view_free(LibBalsaMailboxView * view)
{
if (view->mailing_list_address)
- internet_address_list_destroy(view->mailing_list_address);
+ g_object_unref(view->mailing_list_address);
g_free(view->identity_name);
g_free(view);
}
@@ -3792,7 +3825,8 @@ lbm_get_mime_msg(LibBalsaMailbox * mailbox, LibBalsaMessage * msg)
* message. */
static void
-lbm_try_reassemble_func(GMimeObject * mime_part, gpointer data)
+lbm_try_reassemble_func(GMimeObject * parent, GMimeObject * mime_part,
+ gpointer data)
{
if (GMIME_IS_MESSAGE_PART(mime_part))
mime_part = ((GMimeMessagePart *) mime_part)->message->mime_part;
@@ -3880,7 +3914,6 @@ lbm_try_reassemble(LibBalsaMailbox * mailbox, const gchar * id)
partial = NULL;
g_mime_multipart_foreach((GMimeMultipart *)
mime_message->mime_part,
- (GMimePartFunc)
lbm_try_reassemble_func, &partial);
if (partial
&& strcmp(g_mime_message_partial_get_id(partial), id) == 0) {
diff --git a/libbalsa/mailbox_imap.c b/libbalsa/mailbox_imap.c
index 032d744..972cae3 100644
--- a/libbalsa/mailbox_imap.c
+++ b/libbalsa/mailbox_imap.c
@@ -1821,39 +1821,32 @@ internet_address_new_from_imap_address(ImapAddress ** list)
if (!addr || (addr->name==NULL && addr->addr_spec==NULL))
return NULL;
- address = internet_address_new();
-
/* it will be owned by the caller */
- if (addr->name) {
- gchar *tmp =
-#if HAVE_GMIME_2_2_5
- g_mime_utils_header_decode_text(addr->name);
-#else /* HAVE_GMIME_2_2_5 */
- g_mime_utils_header_decode_text((unsigned char *) addr->name);
-#endif /* HAVE_GMIME_2_2_5 */
- internet_address_set_name(address, tmp);
- g_free(tmp);
- }
if (addr->addr_spec) {
- gchar *tmp =
-#if HAVE_GMIME_2_2_5
- g_mime_utils_header_decode_text(addr->addr_spec);
-#else /* HAVE_GMIME_2_2_5 */
- g_mime_utils_header_decode_text((unsigned char *) addr->addr_spec);
-#endif /* HAVE_GMIME_2_2_5 */
- internet_address_set_addr(address, tmp);
- g_free(tmp);
+ gchar *tmp = g_mime_utils_header_decode_text(addr->addr_spec);
+ address = internet_address_mailbox_new(NULL, tmp);
+ g_free(tmp);
+ if (addr->name) {
+ tmp = g_mime_utils_header_decode_text(addr->name);
+ internet_address_set_name(address, tmp);
+ g_free(tmp);
+ }
} else {
/* Begin group */
- internet_address_set_group
- (address,
+ gchar *tmp = g_mime_utils_header_decode_text(addr->name);
+ address = internet_address_group_new(tmp);
+ g_free(tmp);
+
+ internet_address_group_set_members
+ (INTERNET_ADDRESS_GROUP(address),
internet_address_new_list_from_imap_address_list(addr->next));
/* Skip to end of group */
- while (addr->next && (addr->name || addr->addr_spec))
+ while (addr && addr->addr_spec)
addr = addr->next;
*list = addr;
}
+
return address;
}
@@ -1861,13 +1854,13 @@ static InternetAddressList *
internet_address_new_list_from_imap_address_list(ImapAddress *list)
{
InternetAddress *addr;
- InternetAddressList *res = NULL;
+ InternetAddressList *res = internet_address_list_new();
for (; list; list = list->next) {
addr = internet_address_new_from_imap_address(&list);
if (addr) {
- res = internet_address_list_append(res, addr);
- internet_address_unref(addr);
+ internet_address_list_add(res, addr);
+ g_object_unref(addr);
}
}
return res;
@@ -1891,12 +1884,7 @@ lb_set_headers(LibBalsaMessageHeaders *headers, ImapEnvelope * envelope,
if(is_embedded) {
headers->subject =
-#if HAVE_GMIME_2_2_5
g_mime_utils_header_decode_text(envelope->subject);
-#else /* HAVE_GMIME_2_2_5 */
- g_mime_utils_header_decode_text((unsigned char *) envelope->
- subject);
-#endif /* HAVE_GMIME_2_2_5 */
libbalsa_utf8_sanitize(&headers->subject, TRUE, NULL);
}
}
@@ -2018,11 +2006,7 @@ lbm_imap_construct_body(LibBalsaMessageBody *lbbody, ImapBody *imap_body)
if(!str) str = imap_body_get_param(imap_body, "name");
if(str) {
lbbody->filename =
-#if HAVE_GMIME_2_2_5
g_mime_utils_header_decode_text(str);
-#else /* HAVE_GMIME_2_2_5 */
- g_mime_utils_header_decode_text((unsigned char *) str);
-#endif /* HAVE_GMIME_2_2_5 */
libbalsa_utf8_sanitize(&lbbody->filename, TRUE, NULL);
}
lbbody->charset = g_strdup(imap_body_get_param(imap_body, "charset"));
@@ -2064,11 +2048,10 @@ get_struct_from_cache(LibBalsaMailbox *mailbox, LibBalsaMessage *message,
return FALSE;
stream = g_mime_stream_fs_new(fd);
- fstream = g_mime_stream_filter_new_with_stream(stream);
+ fstream = g_mime_stream_filter_new(stream);
g_object_unref(stream);
- filter = g_mime_filter_crlf_new(GMIME_FILTER_CRLF_DECODE,
- GMIME_FILTER_CRLF_MODE_CRLF_ONLY);
+ filter = g_mime_filter_crlf_new(FALSE, FALSE);
g_mime_stream_filter_add(GMIME_STREAM_FILTER(fstream), filter);
g_object_unref(filter);
@@ -2468,7 +2451,7 @@ lbm_imap_get_msg_part(LibBalsaMessage * msg, LibBalsaMessageBody * part,
part->mime_part = GMIME_OBJECT(g_mime_multipart_new());
g_mime_object_set_content_type(part->mime_part, type);
} else {
- g_mime_content_type_destroy(type);
+ g_object_unref(type);
if (!lbm_imap_get_msg_part_from_cache(msg, part, err))
return FALSE;
}
@@ -2477,8 +2460,8 @@ lbm_imap_get_msg_part(LibBalsaMessage * msg, LibBalsaMessageBody * part,
if (parent_part) {
/* GMime will unref and so will we. */
g_object_ref(part->mime_part);
- g_mime_multipart_add_part(GMIME_MULTIPART(parent_part),
- part->mime_part);
+ g_mime_multipart_add(GMIME_MULTIPART(parent_part),
+ part->mime_part);
}
if (GMIME_IS_MULTIPART_SIGNED(part->mime_part)
@@ -2609,11 +2592,11 @@ libbalsa_mailbox_imap_add_messages(LibBalsaMailbox * mailbox,
if (flags & LIBBALSA_MESSAGE_FLAG_REPLIED)
IMSG_FLAG_SET(imap_flags, IMSGF_ANSWERED);
- tmpstream = g_mime_stream_filter_new_with_stream(stream);
+ tmpstream = g_mime_stream_filter_new(stream);
crlffilter =
- g_mime_filter_crlf_new(GMIME_FILTER_CRLF_ENCODE,
- GMIME_FILTER_CRLF_MODE_CRLF_ONLY);
+ g_mime_filter_crlf_new(TRUE,
+ FALSE);
g_mime_stream_filter_add(GMIME_STREAM_FILTER(tmpstream), crlffilter);
g_object_unref(crlffilter);
@@ -2734,11 +2717,11 @@ multi_append_cb(char * buf, size_t buflen,
if (flags & LIBBALSA_MESSAGE_FLAG_REPLIED)
IMSG_FLAG_SET(imap_flags, IMSGF_ANSWERED);
- tmpstream = g_mime_stream_filter_new_with_stream(stream);
+ tmpstream = g_mime_stream_filter_new(stream);
crlffilter =
- g_mime_filter_crlf_new(GMIME_FILTER_CRLF_ENCODE,
- GMIME_FILTER_CRLF_MODE_CRLF_ONLY);
+ g_mime_filter_crlf_new(TRUE,
+ FALSE);
g_mime_stream_filter_add(GMIME_STREAM_FILTER(tmpstream), crlffilter);
g_object_unref(crlffilter);
diff --git a/libbalsa/mailbox_local.c b/libbalsa/mailbox_local.c
index 7e1ca04..6b66437 100644
--- a/libbalsa/mailbox_local.c
+++ b/libbalsa/mailbox_local.c
@@ -1038,8 +1038,13 @@ libbalsa_mailbox_local_cache_message(LibBalsaMailboxLocal * local,
info->message_id = g_strdup(message->message_id);
info->refs_for_threading =
libbalsa_message_refs_for_threading(message);
- info->sender =
- internet_address_list_to_string(message->headers->from, FALSE);
+
+ info->sender = NULL;
+ if (message->headers->from)
+ info->sender =
+ internet_address_list_to_string(message->headers->from, FALSE);
+ if (!info->sender)
+ info->sender = g_strdup("");
}
void
diff --git a/libbalsa/mailbox_maildir.c b/libbalsa/mailbox_maildir.c
index e6ab256..6186eb1 100644
--- a/libbalsa/mailbox_maildir.c
+++ b/libbalsa/mailbox_maildir.c
@@ -911,10 +911,10 @@ libbalsa_mailbox_maildir_add_message(LibBalsaMailbox * mailbox,
return FALSE;
out_stream = g_mime_stream_fs_new(fd);
- in_stream = g_mime_stream_filter_new_with_stream(stream);
+ in_stream = g_mime_stream_filter_new(stream);
crlffilter =
- g_mime_filter_crlf_new(GMIME_FILTER_CRLF_DECODE,
- GMIME_FILTER_CRLF_MODE_CRLF_ONLY);
+ g_mime_filter_crlf_new(FALSE,
+ FALSE);
g_mime_stream_filter_add(GMIME_STREAM_FILTER(in_stream), crlffilter);
g_object_unref(crlffilter);
diff --git a/libbalsa/mailbox_mbox.c b/libbalsa/mailbox_mbox.c
index 2e39f89..7428fac 100644
--- a/libbalsa/mailbox_mbox.c
+++ b/libbalsa/mailbox_mbox.c
@@ -356,7 +356,7 @@ static void mbox_unlock(LibBalsaMailbox * mailbox, GMimeStream *stream)
*/
static void
lbm_mbox_header_cb(GMimeParser * parser, const char *header,
- const char *value, off_t offset,
+ const char *value, gint64 offset,
gpointer user_data)
{
struct message_info *msg_info = *(struct message_info **) user_data;
@@ -1793,7 +1793,7 @@ lbm_mbox_message_new(GMimeMessage * mime_message,
message = libbalsa_message_new();
- header = g_mime_message_get_header (mime_message, "Status");
+ header = g_mime_object_get_header (GMIME_OBJECT(mime_message), "Status");
if (header) {
if (strchr(header, 'R') == NULL) /* not found == not READ */
flags |= LIBBALSA_MESSAGE_FLAG_NEW;
@@ -1803,7 +1803,7 @@ lbm_mbox_message_new(GMimeMessage * mime_message,
flags |= LIBBALSA_MESSAGE_FLAG_RECENT;
} else
flags |= LIBBALSA_MESSAGE_FLAG_NEW | LIBBALSA_MESSAGE_FLAG_RECENT;
- header = g_mime_message_get_header (mime_message, "X-Status");
+ header = g_mime_object_get_header (GMIME_OBJECT(mime_message), "X-Status");
if (header) {
if (strchr(header, 'D') != NULL) /* found == DELETED */
flags |= LIBBALSA_MESSAGE_FLAG_DELETED;
@@ -1827,10 +1827,10 @@ static void update_message_status_headers(GMimeMessage *message,
/* Create headers with spaces in place of flags, if necessary, so we
* can later update them in place. */
lbm_mbox_status_hdr(flags, 2, new_header);
- g_mime_message_set_header(message, "Status", new_header->str);
+ g_mime_object_set_header(GMIME_OBJECT(message), "Status", new_header->str);
g_string_truncate(new_header, 0);
lbm_mbox_x_status_hdr(flags, 3, new_header);
- g_mime_message_set_header(message, "X-Status", new_header->str);
+ g_mime_object_set_header(GMIME_OBJECT(message), "X-Status", new_header->str);
g_string_free(new_header, TRUE);
}
@@ -1838,7 +1838,8 @@ static void update_message_status_headers(GMimeMessage *message,
* Encode text parts as quoted-printable.
*/
static void
-lbm_mbox_prepare_object(GMimeObject * mime_part)
+lbm_mbox_prepare_object(GMimeObject * parent, GMimeObject * mime_part,
+ gpointer data)
{
g_mime_object_remove_header(mime_part, "Content-Length");
@@ -1848,21 +1849,30 @@ lbm_mbox_prepare_object(GMimeObject * mime_part)
/* Do not break crypto. */
return;
+ if (parent)
+ /* We have been called by g_mime_multipart_foreach, which
+ * recursively descends the multipart tree, so we must not
+ * start another descent. */
+ return;
+
g_mime_multipart_foreach((GMimeMultipart *) mime_part,
- (GMimePartFunc) lbm_mbox_prepare_object,
+ lbm_mbox_prepare_object,
NULL);
} else if (GMIME_IS_MESSAGE_PART(mime_part))
- lbm_mbox_prepare_object(GMIME_OBJECT
+ lbm_mbox_prepare_object(NULL,
+ GMIME_OBJECT
(((GMimeMessagePart *) mime_part)->
- message));
+ message), NULL);
else if (GMIME_IS_MESSAGE(mime_part))
- lbm_mbox_prepare_object(((GMimeMessage *) mime_part)->mime_part);
+ lbm_mbox_prepare_object(NULL,
+ ((GMimeMessage *) mime_part)->mime_part,
+ NULL);
else if (!GMIME_IS_MESSAGE_PARTIAL(mime_part)) {
- GMimePartEncodingType encoding;
- const GMimeContentType *mime_type;
+ GMimeContentEncoding encoding;
+ GMimeContentType *mime_type;
- encoding = g_mime_part_get_encoding(GMIME_PART(mime_part));
- if (encoding == GMIME_PART_ENCODING_BASE64)
+ encoding = g_mime_part_get_content_encoding(GMIME_PART(mime_part));
+ if (encoding == GMIME_CONTENT_ENCODING_BASE64)
return;
mime_type = g_mime_object_get_content_type(mime_part);
@@ -1874,8 +1884,8 @@ lbm_mbox_prepare_object(GMimeObject * mime_part)
return;
}
- g_mime_part_set_encoding(GMIME_PART(mime_part),
- GMIME_PART_ENCODING_QUOTEDPRINTABLE);
+ g_mime_part_set_content_encoding(GMIME_PART(mime_part),
+ GMIME_CONTENT_ENCODING_QUOTEDPRINTABLE);
}
}
@@ -1888,7 +1898,7 @@ lbm_mbox_armored_object(GMimeStream * stream)
parser = g_mime_parser_new_with_stream(stream);
object = GMIME_OBJECT(g_mime_parser_construct_message(parser));
g_object_unref(parser);
- lbm_mbox_prepare_object(object);
+ lbm_mbox_prepare_object(NULL, object, NULL);
return object;
}
@@ -1899,10 +1909,10 @@ lbm_mbox_armored_stream(GMimeStream * stream)
GMimeStream *fstream;
GMimeFilter *filter;
- fstream = g_mime_stream_filter_new_with_stream(stream);
+ fstream = g_mime_stream_filter_new(stream);
- filter = g_mime_filter_crlf_new(GMIME_FILTER_CRLF_DECODE,
- GMIME_FILTER_CRLF_MODE_CRLF_ONLY);
+ filter = g_mime_filter_crlf_new(FALSE,
+ FALSE);
g_mime_stream_filter_add(GMIME_STREAM_FILTER(fstream), filter);
g_object_unref(filter);
diff --git a/libbalsa/mailbox_mh.c b/libbalsa/mailbox_mh.c
index 7a70dbd..1c79755 100644
--- a/libbalsa/mailbox_mh.c
+++ b/libbalsa/mailbox_mh.c
@@ -1094,9 +1094,9 @@ libbalsa_mailbox_mh_add_message(LibBalsaMailbox * mailbox,
}
out_stream = g_mime_stream_fs_new(fd);
- crlffilter = g_mime_filter_crlf_new(GMIME_FILTER_CRLF_DECODE,
- GMIME_FILTER_CRLF_MODE_CRLF_ONLY);
- in_stream = g_mime_stream_filter_new_with_stream(stream);
+ crlffilter = g_mime_filter_crlf_new(FALSE,
+ FALSE);
+ in_stream = g_mime_stream_filter_new(stream);
g_mime_stream_filter_add(GMIME_STREAM_FILTER(in_stream), crlffilter);
g_object_unref(crlffilter);
diff --git a/libbalsa/message.c b/libbalsa/message.c
index d5e367a..102b3f8 100644
--- a/libbalsa/message.c
+++ b/libbalsa/message.c
@@ -146,7 +146,7 @@ libbalsa_message_finalize(GObject * object)
message->headers = NULL;
if (message->sender) {
- internet_address_list_destroy(message->sender);
+ g_object_unref(message->sender);
message->sender = NULL;
}
@@ -211,37 +211,37 @@ libbalsa_message_headers_destroy(LibBalsaMessageHeaders * headers)
headers->subject = NULL;
if (headers->from) {
- internet_address_list_destroy(headers->from);
+ g_object_unref(headers->from);
headers->from = NULL;
}
if (headers->to_list) {
- internet_address_list_destroy(headers->to_list);
+ g_object_unref(headers->to_list);
headers->to_list = NULL;
}
if (headers->content_type) {
- g_mime_content_type_destroy(headers->content_type);
+ g_object_unref(headers->content_type);
headers->content_type = NULL;
}
if (headers->cc_list) {
- internet_address_list_destroy(headers->cc_list);
+ g_object_unref(headers->cc_list);
headers->cc_list = NULL;
}
if (headers->bcc_list) {
- internet_address_list_destroy(headers->bcc_list);
+ g_object_unref(headers->bcc_list);
headers->bcc_list = NULL;
}
if (headers->reply_to) {
- internet_address_list_destroy(headers->reply_to);
+ g_object_unref(headers->reply_to);
headers->reply_to = NULL;
}
if(headers->dispnotify_to) {
- internet_address_list_destroy(headers->dispnotify_to);
+ g_object_unref(headers->dispnotify_to);
headers->dispnotify_to = NULL;
}
@@ -263,7 +263,7 @@ libbalsa_message_body_charset(LibBalsaMessageBody * body)
return body->charset;
if (GMIME_IS_PART(body->mime_part)) {
- const GMimeContentType *type;
+ GMimeContentType *type;
type = g_mime_object_get_content_type(body->mime_part);
return g_mime_content_type_get_parameter(type, "charset");
@@ -467,6 +467,8 @@ prepend_header_misc(const char *name, const char *value,
GList *
libbalsa_message_user_hdrs_from_gmime(GMimeMessage * message)
{
+ GMimeHeaderList *hdrlist;
+ GMimeHeaderIter iter;
GList *res = NULL;
const char *value;
@@ -481,7 +483,7 @@ libbalsa_message_user_hdrs_from_gmime(GMimeMessage * message)
already present in LibBalsaMessage::references field. FWIW,
mailbox driver does not copy references to user_headers.
*/
- value = g_mime_message_get_header(message, "References");
+ value = g_mime_object_get_header(GMIME_OBJECT(message), "References");
if (value) {
#if BALSA_NEEDS_SEPARATE_USER_HEADERS
GMimeReferences *references, *reference;
@@ -504,26 +506,24 @@ libbalsa_message_user_hdrs_from_gmime(GMimeMessage * message)
#endif
}
- value = g_mime_message_get_header(message, "In-Reply-To");
+ value = g_mime_object_get_header(GMIME_OBJECT(message), "In-Reply-To");
if (value) {
res =
-#if HAVE_GMIME_2_2_5
g_list_prepend(res,
libbalsa_create_hdr_pair
("In-Reply-To",
g_mime_utils_header_decode_text(value)));
-#else /* HAVE_GMIME_2_2_5 */
- g_list_prepend(res,
- libbalsa_create_hdr_pair
- ("In-Reply-To",
- g_mime_utils_header_decode_text
- ((unsigned char *) value)));
-#endif /* HAVE_GMIME_2_2_5 */
}
- g_mime_header_foreach(GMIME_OBJECT(message)->headers,
- prepend_header_misc, &res);
-
+ hdrlist = g_mime_object_get_header_list (GMIME_OBJECT(message));
+ if (g_mime_header_list_get_iter (hdrlist, &iter)) {
+ do {
+ prepend_header_misc (g_mime_header_iter_get_name (&iter),
+ g_mime_header_iter_get_value (&iter),
+ &res);
+ } while (g_mime_header_iter_next (&iter));
+ }
+
return g_list_reverse(res);
}
@@ -698,7 +698,7 @@ libbalsa_message_is_multipart(LibBalsaMessage * message)
gboolean
libbalsa_message_is_partial(LibBalsaMessage * message, gchar ** id)
{
- const GMimeContentType *content_type;
+ GMimeContentType *content_type;
g_return_val_if_fail(LIBBALSA_IS_MESSAGE(message), FALSE);
@@ -809,9 +809,13 @@ libbalsa_message_set_dispnotify(LibBalsaMessage * message,
{
g_return_if_fail(message);
- internet_address_list_destroy(message->headers->dispnotify_to);
- message->headers->dispnotify_to =
- ia ? internet_address_list_prepend(NULL, ia) : NULL;
+ g_object_unref(message->headers->dispnotify_to);
+ if (ia) {
+ message->headers->dispnotify_to = internet_address_list_new ();
+ internet_address_list_add (message->headers->dispnotify_to, ia);
+ } else {
+ message->headers->dispnotify_to = NULL;
+ }
}
#ifndef MESSAGE_COPY_CONTENT
@@ -841,7 +845,7 @@ libbalsa_message_get_lines(LibBalsaMessage* msg)
const char *value;
if (!msg->mime_msg)
return 0;
- value = g_mime_message_get_header(msg->mime_msg, "Lines");
+ value = g_mime_object_get_header(msg->mime_msg, "Lines");
if (!value)
return 0;
return atoi(value);
@@ -853,7 +857,7 @@ libbalsa_message_get_length(LibBalsaMessage* msg)
const char *value;
if (!msg->mime_msg)
return 0;
- value = g_mime_message_get_header(msg->mime_msg, "Content-Length");
+ value = g_mime_object_get_header(msg->mime_msg, "Content-Length");
if (!value)
return 0;
return atoi(value);
@@ -871,15 +875,16 @@ libbalsa_message_get_no(LibBalsaMessage* msg)
/* Populate headers from mime_msg, but only the members that are needed
* all the time. */
static InternetAddressList *
-lb_message_recipients(GMimeMessage * message, const gchar * type)
+lb_message_recipients(GMimeMessage * message, GMimeRecipientType type)
{
const InternetAddressList *list;
InternetAddressList *copy = NULL;
- for (list = g_mime_message_get_recipients(message, type);
- list; list = list->next)
- copy = internet_address_list_append(copy, list->address);
-
+ if ((list = g_mime_message_get_recipients (message, type))) {
+ copy = internet_address_list_new ();
+ internet_address_list_append (copy, (InternetAddressList *) list);
+ }
+
return copy;
}
@@ -891,7 +896,7 @@ lb_message_headers_basic_from_gmime(LibBalsaMessageHeaders *headers,
g_return_if_fail(mime_msg != NULL);
if (!headers->from)
- headers->from = internet_address_parse_string(mime_msg->from);
+ headers->from = internet_address_list_parse_string(mime_msg->from);
if (!headers->date)
g_mime_message_get_date(mime_msg, &headers->date, NULL);
@@ -906,7 +911,7 @@ lb_message_headers_basic_from_gmime(LibBalsaMessageHeaders *headers,
* g_mime_content_type_copy
* (g_mime_object_get_content_type(mime_msg->mime_part));
*/
- const GMimeContentType *content_type;
+ GMimeContentType *content_type;
gchar *str;
g_return_if_fail(headers->content_type == NULL);
content_type = g_mime_object_get_content_type(mime_msg->mime_part);
@@ -927,12 +932,12 @@ lb_message_headers_extra_from_gmime(LibBalsaMessageHeaders *headers,
if (!headers->reply_to)
headers->reply_to =
- internet_address_parse_string(mime_msg->reply_to);
+ internet_address_list_parse_string(mime_msg->reply_to);
if (!headers->dispnotify_to)
headers->dispnotify_to =
- internet_address_parse_string(g_mime_message_get_header
- (mime_msg,
+ internet_address_list_parse_string(g_mime_object_get_header
+ (GMIME_OBJECT(mime_msg),
"Disposition-Notification-To"));
if (!headers->cc_list)
@@ -946,7 +951,7 @@ lb_message_headers_extra_from_gmime(LibBalsaMessageHeaders *headers,
/* Get fcc from message */
if (!headers->fcc_url)
headers->fcc_url =
- g_strdup(g_mime_message_get_header(mime_msg, "X-Balsa-Fcc"));
+ g_strdup(g_mime_object_get_header(GMIME_OBJECT(mime_msg), "X-Balsa-Fcc"));
}
/* Populate headers from the info in mime_msg. */
@@ -973,7 +978,7 @@ libbalsa_message_init_from_gmime(LibBalsaMessage * message,
header = g_mime_message_get_subject(mime_msg);
libbalsa_message_set_subject_from_header(message, header);
- header = g_mime_message_get_header(mime_msg, "Content-Length");
+ header = g_mime_object_get_header(GMIME_OBJECT(mime_msg), "Content-Length");
if (header)
message->length = atoi(header);
#endif
@@ -981,11 +986,11 @@ libbalsa_message_init_from_gmime(LibBalsaMessage * message,
if (header)
message->message_id = g_strdup(header);
- header = g_mime_message_get_header(mime_msg, "References");
+ header = g_mime_object_get_header(GMIME_OBJECT(mime_msg), "References");
if (header)
libbalsa_message_set_references_from_string(message, header);
- header = g_mime_message_get_header(mime_msg, "In-Reply-To");
+ header = g_mime_object_get_header(GMIME_OBJECT(mime_msg), "In-Reply-To");
if (header)
libbalsa_message_set_in_reply_to_from_string(message, header);
@@ -1094,11 +1099,7 @@ lbmsg_set_header(LibBalsaMessage *message, const gchar *name,
* appropriate GMime decoder. */
gchar *tmp = g_strdup(value);
libbalsa_utf8_sanitize(&tmp, TRUE, NULL);
-#if HAVE_GMIME_2_2_5
val = g_mime_utils_header_encode_text(tmp);
-#else /* HAVE_GMIME_2_2_5 */
- val = g_mime_utils_header_encode_text((unsigned char *) tmp);
-#endif /* HAVE_GMIME_2_2_5 */
g_free(tmp);
#ifdef DEBUG
g_print("%s: non-ascii \"%s\" header \"%s\" encoded as \"%s\"\n",
@@ -1122,11 +1123,11 @@ lbmsg_set_header(LibBalsaMessage *message, const gchar *name,
} else
if (message->headers->from == NULL &&
g_ascii_strcasecmp(name, "From") == 0) {
- message->headers->from = internet_address_parse_string(value);
+ message->headers->from = internet_address_list_parse_string(value);
} else
if (message->headers->to_list == NULL &&
g_ascii_strcasecmp(name, "To") == 0) {
- message->headers->to_list = internet_address_parse_string(value);
+ message->headers->to_list = internet_address_list_parse_string(value);
} else
if (g_ascii_strcasecmp(name, "In-Reply-To") == 0) {
libbalsa_message_set_in_reply_to_from_string(message, value);
@@ -1146,7 +1147,7 @@ lbmsg_set_header(LibBalsaMessage *message, const gchar *name,
if (message->headers->dispnotify_to == NULL &&
g_ascii_strcasecmp(name, "Disposition-Notification-To") == 0) {
message->headers->dispnotify_to =
- internet_address_parse_string(value);
+ internet_address_list_parse_string(value);
} else
#ifdef MESSAGE_COPY_CONTENT
if (g_ascii_strcasecmp(name, "Content-Length") == 0) {
@@ -1214,11 +1215,11 @@ libbalsa_message_load_envelope_from_stream(LibBalsaMessage * message,
* fields, and finding the empty line that separates the body from
* the header is simpler if it has no '\r' in it. */
gmime_stream_filter =
- g_mime_stream_filter_new_with_stream(gmime_stream);
+ g_mime_stream_filter_new(gmime_stream);
gmime_filter_crlf =
- g_mime_filter_crlf_new(GMIME_FILTER_CRLF_DECODE,
- GMIME_FILTER_CRLF_MODE_CRLF_ONLY);
+ g_mime_filter_crlf_new(FALSE,
+ FALSE);
g_mime_stream_filter_add(GMIME_STREAM_FILTER(gmime_stream_filter),
gmime_filter_crlf);
g_object_unref(gmime_filter_crlf);
@@ -1348,12 +1349,7 @@ libbalsa_message_set_subject_from_header(LibBalsaMessage * message,
{
if (header) {
gchar *subject =
-#if HAVE_GMIME_2_2_5
g_mime_utils_header_decode_text(header);
-#else /* HAVE_GMIME_2_2_5 */
- g_mime_utils_header_decode_text((const unsigned char *)
- header);
-#endif /* HAVE_GMIME_2_2_5 */
libbalsa_message_set_subject(message, subject);
g_free(subject);
}
diff --git a/libbalsa/mime-stream-shared.c b/libbalsa/mime-stream-shared.c
index 41c419b..1a5ae1d 100644
--- a/libbalsa/mime-stream-shared.c
+++ b/libbalsa/mime-stream-shared.c
@@ -63,10 +63,10 @@ static ssize_t lbmss_stream_read(GMimeStream * stream, char *buf,
static ssize_t lbmss_stream_write(GMimeStream * stream, const char *buf,
size_t len);
static int lbmss_stream_reset(GMimeStream * stream);
-static off_t lbmss_stream_seek(GMimeStream * stream, off_t offset,
+static gint64 lbmss_stream_seek(GMimeStream * stream, gint64 offset,
GMimeSeekWhence whence);
static GMimeStream *lbmss_stream_substream(GMimeStream * stream,
- off_t start, off_t end);
+ gint64 start, gint64 end);
static GMimeStreamFsClass *parent_class = NULL;
static GMutex *lbmss_mutex;
@@ -195,8 +195,8 @@ lbmss_stream_reset(GMimeStream * stream)
return GMIME_STREAM_CLASS(parent_class)->reset(stream);
}
-static off_t
-lbmss_stream_seek(GMimeStream * stream, off_t offset,
+static gint64
+lbmss_stream_seek(GMimeStream * stream, gint64 offset,
GMimeSeekWhence whence)
{
g_return_val_if_fail(lbmss_thread_has_lock(stream), -1);
@@ -204,7 +204,7 @@ lbmss_stream_seek(GMimeStream * stream, off_t offset,
}
static GMimeStream *
-lbmss_stream_substream(GMimeStream * stream, off_t start, off_t end)
+lbmss_stream_substream(GMimeStream * stream, gint64 start, gint64 end)
{
LibBalsaMimeStreamShared *stream_shared;
GMimeStreamFs *fstream;
@@ -238,7 +238,7 @@ libbalsa_mime_stream_shared_new(int fd)
{
LibBalsaMimeStreamShared *stream_shared;
GMimeStreamFs *fstream;
- off_t start;
+ gint64 start;
stream_shared =
g_object_new(LIBBALSA_TYPE_MIME_STREAM_SHARED, NULL, NULL);
diff --git a/libbalsa/misc.c b/libbalsa/misc.c
index 97370ae..ae7a76a 100644
--- a/libbalsa/misc.c
+++ b/libbalsa/misc.c
@@ -487,7 +487,6 @@ LibBalsaCodeset
libbalsa_set_fallback_codeset(LibBalsaCodeset codeset)
{
LibBalsaCodeset ret = sanitize_fallback_codeset;
-#if defined(HAVE_GMIME_2_2_7)
const gchar *charsets[] = {
"UTF-8",
libbalsa_get_codeset_name(NULL, codeset),
@@ -495,8 +494,6 @@ libbalsa_set_fallback_codeset(LibBalsaCodeset codeset)
};
g_mime_set_user_charsets(charsets);
- /* GMime will free the strings. */
-#endif /* HAVE_GMIME_2_2_7 */
sanitize_fallback_codeset = codeset;
return ret;
@@ -1047,23 +1044,25 @@ libbalsa_ia_rfc2821_equal(const InternetAddress * a,
const InternetAddress * b)
{
const gchar *a_atptr, *b_atptr;
+ const gchar *a_addr, *b_addr;
gint a_atpos, b_atpos;
- if (!a || !b || a->type != INTERNET_ADDRESS_NAME ||
- b->type != INTERNET_ADDRESS_NAME)
+ if (!INTERNET_ADDRESS_IS_MAILBOX(a) || !INTERNET_ADDRESS_IS_MAILBOX(b))
return FALSE;
/* first find the "@" in the two addresses */
- a_atptr = strchr(a->value.addr, '@');
- b_atptr = strchr(b->value.addr, '@');
+ a_addr = INTERNET_ADDRESS_MAILBOX(a)->addr;
+ b_addr = INTERNET_ADDRESS_MAILBOX(b)->addr;
+ a_atptr = strchr(a_addr, '@');
+ b_atptr = strchr(b_addr, '@');
if (!a_atptr || !b_atptr)
return FALSE;
- a_atpos = a_atptr - a->value.addr;
- b_atpos = b_atptr - b->value.addr;
+ a_atpos = a_atptr - a_addr;
+ b_atpos = b_atptr - b_addr;
/* now compare the strings */
if (!a_atpos || !b_atpos || a_atpos != b_atpos ||
- strncmp(a->value.addr, b->value.addr, a_atpos) ||
+ strncmp(a_addr, b_addr, a_atpos) ||
g_ascii_strcasecmp(a_atptr, b_atptr))
return FALSE;
else
diff --git a/libbalsa/rfc3156.c b/libbalsa/rfc3156.c
index 44fe850..2ead376 100644
--- a/libbalsa/rfc3156.c
+++ b/libbalsa/rfc3156.c
@@ -131,14 +131,14 @@ body_is_type(LibBalsaMessageBody * body, const gchar * type,
gboolean retval;
if (body->mime_part) {
- const GMimeContentType *content_type =
+ GMimeContentType *content_type =
g_mime_object_get_content_type(body->mime_part);
retval = g_mime_content_type_is_type(content_type, type, sub_type);
} else {
GMimeContentType *content_type =
g_mime_content_type_new_from_string(body->content_type);
retval = g_mime_content_type_is_type(content_type, type, sub_type);
- g_mime_content_type_destroy(content_type);
+ g_object_unref(content_type);
}
return retval;
@@ -392,6 +392,7 @@ libbalsa_encrypt_mime_object(GMimeObject ** content, GList * rfc822_for,
result =
g_mime_multipart_encrypted_encrypt(mpe, *content,
GMIME_CIPHER_CONTEXT(ctx),
+ FALSE, NULL,
recipients, error);
}
#ifdef HAVE_SMIME
@@ -508,7 +509,7 @@ libbalsa_body_check_signature(LibBalsaMessageBody * body,
/* check if the body is really a multipart/signed */
if (!GMIME_IS_MULTIPART_SIGNED(body->mime_part)
- || (g_mime_multipart_get_number
+ || (g_mime_multipart_get_count
(((GMimeMultipart *) body->mime_part))) < 2)
return FALSE;
if (body->parts->next->sig_info)
@@ -703,7 +704,6 @@ libbalsa_body_decrypt(LibBalsaMessageBody * body,
#endif
libbalsa_message_body_set_mime_body(body, mime_obj);
- g_object_unref(G_OBJECT(mime_obj));
if (ctx->sig_state && ctx->sig_state->status != GPG_ERR_NOT_SIGNED) {
g_object_ref(ctx->sig_state);
body->sig_info = ctx->sig_state;
@@ -920,7 +920,7 @@ libbalsa_rfc2440_decrypt(GMimePart * part, GMimeGpgmeSigstat ** sig_info,
}
/* decrypt */
- if (g_mime_part_rfc2440_decrypt(part, ctx, &error) == -1) {
+ if (g_mime_part_rfc2440_decrypt(part, ctx, &error) == NULL) {
if (error) {
if (error->code != GPG_ERR_CANCELED)
libbalsa_information(LIBBALSA_INFORMATION_ERROR, "%s: %s",
@@ -1749,16 +1749,22 @@ have_pub_key_for(gpgme_ctx_t gpgme_ctx, InternetAddressList * recipients)
gpgme_key_t key;
gboolean result = TRUE;
time_t now = time(NULL);
+ gint i;
- for (; result && recipients; recipients = recipients->next) {
- InternetAddress *ia = recipients->address;
+ for (i = 0; result && i < internet_address_list_length(recipients);
+ i++) {
+ InternetAddress *ia =
+ internet_address_list_get_address(recipients, i);
/* check all entries in the list, handle groups recursively */
- if (ia->type == INTERNET_ADDRESS_GROUP)
- result = have_pub_key_for(gpgme_ctx, ia->value.members);
- else if (recipients->address->type == INTERNET_ADDRESS_NAME) {
- if (gpgme_op_keylist_start(gpgme_ctx, ia->value.addr, FALSE) !=
- GPG_ERR_NO_ERROR)
+ if (INTERNET_ADDRESS_IS_GROUP(ia))
+ result =
+ have_pub_key_for(gpgme_ctx,
+ INTERNET_ADDRESS_GROUP(ia)->members);
+ else {
+ if (gpgme_op_keylist_start(gpgme_ctx,
+ INTERNET_ADDRESS_MAILBOX(ia)->addr,
+ FALSE) != GPG_ERR_NO_ERROR)
return FALSE;
result = FALSE;
diff --git a/libbalsa/send.c b/libbalsa/send.c
index e28af23..100f0e0 100644
--- a/libbalsa/send.c
+++ b/libbalsa/send.c
@@ -297,7 +297,7 @@ lbs_set_content(GMimePart * mime_part, gchar * content)
wrapper =
g_mime_data_wrapper_new_with_stream(stream,
- GMIME_PART_ENCODING_DEFAULT);
+ GMIME_CONTENT_ENCODING_DEFAULT);
g_object_unref(stream);
g_mime_part_set_content_object(mime_part, wrapper);
@@ -342,8 +342,8 @@ add_mime_body_plain(LibBalsaMessageBody *body, gboolean flow, gboolean postpone)
mime_part = g_mime_part_new_with_type("text", "plain");
}
- g_mime_part_set_content_disposition(mime_part, GMIME_DISPOSITION_INLINE);
- g_mime_part_set_encoding(mime_part, GMIME_PART_ENCODING_QUOTEDPRINTABLE);
+ g_mime_object_set_disposition(GMIME_OBJECT(mime_part), GMIME_DISPOSITION_INLINE);
+ g_mime_part_set_content_encoding(mime_part, GMIME_CONTENT_ENCODING_QUOTEDPRINTABLE);
g_mime_object_set_content_type_parameter(GMIME_OBJECT(mime_part),
"charset",
charset ? charset :
@@ -364,7 +364,7 @@ add_mime_body_plain(LibBalsaMessageBody *body, gboolean flow, gboolean postpone)
GMimeDataWrapper *wrapper;
stream = g_mime_stream_mem_new();
- filter_stream = g_mime_stream_filter_new_with_stream(stream);
+ filter_stream = g_mime_stream_filter_new(stream);
filter = g_mime_filter_charset_new("UTF-8", charset);
g_mime_stream_filter_add(GMIME_STREAM_FILTER(filter_stream), filter);
g_object_unref(G_OBJECT(filter));
@@ -374,7 +374,7 @@ add_mime_body_plain(LibBalsaMessageBody *body, gboolean flow, gboolean postpone)
wrapper =
g_mime_data_wrapper_new_with_stream(stream,
- GMIME_PART_ENCODING_DEFAULT);
+ GMIME_CONTENT_ENCODING_DEFAULT);
g_object_unref(stream);
g_mime_part_set_content_object(mime_part, wrapper);
@@ -401,14 +401,14 @@ add_mime_body_plain(LibBalsaMessageBody *body, gboolean flow, gboolean postpone)
if (body->html_buffer && !postpone) {
GMimeMultipart *mpa = g_mime_multipart_new_with_subtype("alternative");
- g_mime_multipart_add_part(mpa, GMIME_OBJECT(mime_part));
+ g_mime_multipart_add(mpa, GMIME_OBJECT(mime_part));
g_object_unref(G_OBJECT(mime_part));
mime_part = g_mime_part_new_with_type("text", "html");
- g_mime_multipart_add_part(mpa, GMIME_OBJECT(mime_part));
+ g_mime_multipart_add(mpa, GMIME_OBJECT(mime_part));
g_object_unref(G_OBJECT(mime_part));
- g_mime_part_set_content_disposition(mime_part, GMIME_DISPOSITION_INLINE);
- g_mime_part_set_encoding(mime_part, GMIME_PART_ENCODING_QUOTEDPRINTABLE);
+ g_mime_object_set_disposition(GMIME_OBJECT(mime_part), GMIME_DISPOSITION_INLINE);
+ g_mime_part_set_content_encoding(mime_part, GMIME_CONTENT_ENCODING_QUOTEDPRINTABLE);
g_mime_object_set_content_type_parameter(GMIME_OBJECT(mime_part),
"charset", "UTF-8");
lbs_set_content(mime_part, body->html_buffer);
@@ -472,10 +472,10 @@ libbalsa_message_queue(LibBalsaMessage * message, LibBalsaMailbox * outbox,
return result;
if (fccbox)
- g_mime_message_set_header(message->mime_msg, "X-Balsa-Fcc",
+ g_mime_object_set_header(GMIME_OBJECT(message->mime_msg), "X-Balsa-Fcc",
fccbox->url);
#if ENABLE_ESMTP
- g_mime_message_set_header(message->mime_msg, "X-Balsa-SmtpServer",
+ g_mime_object_set_header(GMIME_OBJECT(message->mime_msg), "X-Balsa-SmtpServer",
libbalsa_smtp_server_get_name(smtp_server));
big_message = libbalsa_smtp_server_get_big_message(smtp_server);
@@ -495,9 +495,9 @@ libbalsa_message_queue(LibBalsaMessage * message, LibBalsaMailbox * outbox,
/* RFC 2046, 5.2.2: "...it is specified that entities of
* type "message/partial" must always have a content-
* transfer-encoding of 7bit (the default)" */
- g_mime_part_set_encoding(GMIME_PART
+ g_mime_part_set_content_encoding(GMIME_PART
(mime_msgs[i]->mime_part),
- GMIME_PART_ENCODING_7BIT);
+ GMIME_CONTENT_ENCODING_7BIT);
libbalsa_set_message_id(mime_msgs[i]);
}
if (rc) {
@@ -600,13 +600,19 @@ static void
add_recipients(smtp_message_t message,
InternetAddressList * recipient_list)
{
- for (; recipient_list; recipient_list = recipient_list->next) {
- InternetAddress *ia = recipient_list->address;
+ const InternetAddress *ia;
+ int i;
+
+ if (recipient_list == NULL)
+ return;
+
+ for (i = 0; i < internet_address_list_length (recipient_list); i++) {
+ ia = internet_address_list_get_address (recipient_list, i);
- if (ia->type == INTERNET_ADDRESS_NAME)
- smtp_add_recipient (message, ia->value.addr);
- else if (ia->type == INTERNET_ADDRESS_GROUP)
- add_recipients(message, ia->value.members);
+ if (INTERNET_ADDRESS_IS_MAILBOX (ia))
+ smtp_add_recipient (message, INTERNET_ADDRESS_MAILBOX (ia)->addr);
+ else
+ add_recipients(message, INTERNET_ADDRESS_GROUP (ia)->members);
/* XXX - this is where to add DSN requests. It would be
cool if LibBalsaAddress could contain DSN options
@@ -614,26 +620,6 @@ add_recipients(smtp_message_t message,
}
}
-static guint
-lbs_list_n_addresses(InternetAddressList * recipient_list)
-{
- guint n_addresses = 0;
-
- for (; recipient_list; recipient_list = recipient_list->next) {
- InternetAddress *ia;
-
- if ((ia = recipient_list->address) == NULL)
- continue;
-
- if (ia->type == INTERNET_ADDRESS_NAME && ia->value.addr != NULL)
- ++n_addresses;
- else if (ia->type == INTERNET_ADDRESS_GROUP)
- n_addresses += lbs_list_n_addresses(ia->value.members);
- }
-
- return n_addresses;
-}
-
/* libbalsa_process_queue:
treats given mailbox as a set of messages to send. Loads them up and
launches sending thread/routine.
@@ -729,7 +715,7 @@ lbs_process_queue(LibBalsaMailbox * outbox, LibBalsaFccboxFinder finder,
} else {
gboolean has_open_recipients;
guint n_bcc_recipients;
- InternetAddress *ia;
+ const InternetAddress *ia;
libbalsa_message_change_flags(msg,
LIBBALSA_MESSAGE_FLAG_FLAGGED, 0);
@@ -754,10 +740,10 @@ lbs_process_queue(LibBalsaMailbox * outbox, LibBalsaFccboxFinder finder,
mem_stream = new_message->stream;
filter_stream =
- g_mime_stream_filter_new_with_stream(mem_stream);
+ g_mime_stream_filter_new(mem_stream);
filter =
- g_mime_filter_crlf_new( GMIME_FILTER_CRLF_ENCODE,
- GMIME_FILTER_CRLF_MODE_CRLF_ONLY);
+ g_mime_filter_crlf_new( TRUE,
+ FALSE);
g_mime_stream_filter_add(GMIME_STREAM_FILTER(filter_stream),
filter);
g_object_unref(G_OBJECT(filter));
@@ -775,10 +761,13 @@ lbs_process_queue(LibBalsaMailbox * outbox, LibBalsaFccboxFinder finder,
* session for that one recipient, in which the Bcc: header
* is preserved. */
has_open_recipients =
- lbs_list_n_addresses(msg->headers->to_list) > 0 ||
- lbs_list_n_addresses(msg->headers->cc_list) > 0;
+ libbalsa_address_n_mailboxes_in_list(msg->headers->
+ to_list) > 0
+ || libbalsa_address_n_mailboxes_in_list(msg->headers->
+ cc_list) > 0;
n_bcc_recipients =
- lbs_list_n_addresses(msg->headers->bcc_list);
+ libbalsa_address_n_mailboxes_in_list(msg->headers->
+ bcc_list);
if (has_open_recipients && n_bcc_recipients == 1)
bcc_message = smtp_add_message (session);
else
@@ -824,12 +813,11 @@ lbs_process_queue(LibBalsaMailbox * outbox, LibBalsaFccboxFinder finder,
/* Add the sender info */
if (msg->headers->from
- && (ia = msg->headers->from->address)
- && ia->type != INTERNET_ADDRESS_NONE) {
+ && (ia = internet_address_list_get_address (msg->headers->from, 0))) {
phrase = ia->name;
- while (ia->type == INTERNET_ADDRESS_GROUP)
- ia = ia->value.members->address;
- mailbox = ia->value.addr;
+ while (ia && INTERNET_ADDRESS_IS_GROUP (ia))
+ ia = internet_address_list_get_address (INTERNET_ADDRESS_GROUP (ia)->members, 0);
+ mailbox = ia ? INTERNET_ADDRESS_MAILBOX (ia)->addr : "";
} else
phrase = mailbox = "";
smtp_set_reverse_path (message, mailbox);
@@ -840,24 +828,22 @@ lbs_process_queue(LibBalsaMailbox * outbox, LibBalsaFccboxFinder finder,
}
if (msg->headers->reply_to
- && (ia = msg->headers->reply_to->address)
- && ia->type != INTERNET_ADDRESS_NONE) {
+ && (ia = internet_address_list_get_address (msg->headers->reply_to, 0))) {
phrase = ia->name;
- while (ia->type == INTERNET_ADDRESS_GROUP)
- ia = ia->value.members->address;
- mailbox = ia->value.addr;
+ while (ia && INTERNET_ADDRESS_IS_GROUP (ia))
+ ia = internet_address_list_get_address (INTERNET_ADDRESS_GROUP (ia)->members, 0);
+ mailbox = ia ? INTERNET_ADDRESS_MAILBOX (ia)->addr : "";
smtp_set_header (message, "Reply-To", phrase, mailbox);
if (bcc_message)
smtp_set_header (bcc_message, "Reply-To", phrase, mailbox);
}
if (msg->headers->dispnotify_to
- && (ia = msg->headers->dispnotify_to->address)
- && ia->type != INTERNET_ADDRESS_NONE) {
+ && (ia = internet_address_list_get_address (msg->headers->dispnotify_to, 0))) {
phrase = ia->name;
- while (ia->type == INTERNET_ADDRESS_GROUP)
- ia = ia->value.members->address;
- mailbox = ia->value.addr;
+ while (ia && INTERNET_ADDRESS_IS_GROUP (ia))
+ ia = internet_address_list_get_address (INTERNET_ADDRESS_GROUP (ia)->members, 0);
+ mailbox = ia ? INTERNET_ADDRESS_MAILBOX (ia)->addr : "";
smtp_set_header (message, "Disposition-Notification-To",
phrase, mailbox);
if (bcc_message)
@@ -1602,27 +1588,30 @@ message_add_references(LibBalsaMessage * message, GMimeMessage * msg)
g_string_append_c(str, ' ');
g_string_append_printf(str, "<%s>", (gchar *) list->data);
} while ((list = list->next) != NULL);
- g_mime_message_set_header(msg, "References", str->str);
+ g_mime_object_set_header(GMIME_OBJECT(msg), "References", str->str);
g_string_free(str, TRUE);
}
if (message->in_reply_to)
/* There's no specific header function for In-Reply-To */
- g_mime_message_set_header(msg, "In-Reply-To",
+ g_mime_object_set_header(GMIME_OBJECT(msg), "In-Reply-To",
message->in_reply_to->data);
}
#ifdef HAVE_GPGME
static GList *
-get_mailbox_names(GList *list, const InternetAddressList *address_list)
+get_mailbox_names(GList *list, InternetAddressList *address_list)
{
- for (; address_list; address_list = address_list->next) {
- InternetAddress *ia = address_list->address;
+ gint i;
+
+ for (i = 0; i < internet_address_list_length(address_list); i++) {
+ InternetAddress *ia =
+ internet_address_list_get_address(address_list, i);
- if (ia->type == INTERNET_ADDRESS_NAME)
- list = g_list_append(list, g_strdup(ia->value.addr));
- else if (ia->type == INTERNET_ADDRESS_GROUP)
- list = get_mailbox_names(list, ia->value.members);
+ if (INTERNET_ADDRESS_IS_MAILBOX(ia))
+ list = g_list_append(list, g_strdup(((InternetAddressMailbox *) ia)->addr));
+ else
+ list = get_mailbox_names(list, ((InternetAddressGroup *) ia)->members);
}
return list;
@@ -1683,6 +1672,7 @@ libbalsa_message_create_mime_message(LibBalsaMessage* message, gboolean flow,
GMimeObject *mime_root = NULL;
GMimeMessage *mime_message;
LibBalsaMessageBody *body;
+ InternetAddressList *recipients;
gchar *tmp;
GList *list;
GtkWindow * parent;
@@ -1710,8 +1700,8 @@ libbalsa_message_create_mime_message(LibBalsaMessage* message, gboolean flow,
g_mime_content_type_new("message", "external-body");
mime_part=g_mime_object_new_type("message", "external-body");
g_mime_object_set_content_type(mime_part, content_type);
- g_mime_part_set_encoding(GMIME_PART(mime_part),
- GMIME_PART_ENCODING_7BIT);
+ g_mime_part_set_content_encoding(GMIME_PART(mime_part),
+ GMIME_CONTENT_ENCODING_7BIT);
if (body->filename && !strncmp(body->filename, "URL", 3)) {
g_mime_object_set_content_type_parameter(mime_part,
"access-type", "URL");
@@ -1784,13 +1774,13 @@ libbalsa_message_create_mime_message(LibBalsaMessage* message, gboolean flow,
mime_part =
GMIME_OBJECT(g_mime_part_new_with_type(mime_type[0],
mime_type[1]));
- g_mime_part_set_content_disposition(GMIME_PART(mime_part),
+ g_mime_object_set_disposition(mime_part,
body->attach_mode == LIBBALSA_ATTACH_AS_INLINE ?
GMIME_DISPOSITION_INLINE : GMIME_DISPOSITION_ATTACHMENT);
if(g_ascii_strcasecmp(mime_type[0],"text") != 0)
{
- g_mime_part_set_encoding(GMIME_PART(mime_part),
- GMIME_PART_ENCODING_BASE64);
+ g_mime_part_set_content_encoding(GMIME_PART(mime_part),
+ GMIME_CONTENT_ENCODING_BASE64);
} else {
/* is text */
g_mime_object_set_content_type_parameter(mime_part,
@@ -1818,7 +1808,7 @@ libbalsa_message_create_mime_message(LibBalsaMessage* message, gboolean flow,
return LIBBALSA_MESSAGE_CREATE_ERROR;
}
content = g_mime_data_wrapper_new_with_stream(stream,
- GMIME_PART_ENCODING_DEFAULT);
+ GMIME_CONTENT_ENCODING_DEFAULT);
g_object_unref(stream);
g_mime_part_set_content_object(GMIME_PART(mime_part),
content);
@@ -1850,8 +1840,8 @@ libbalsa_message_create_mime_message(LibBalsaMessage* message, gboolean flow,
}
if (mime_root) {
- g_mime_multipart_add_part(GMIME_MULTIPART(mime_root),
- GMIME_OBJECT(mime_part));
+ g_mime_multipart_add(GMIME_MULTIPART(mime_root),
+ GMIME_OBJECT(mime_part));
g_object_unref(G_OBJECT(mime_part));
} else {
mime_root = mime_part;
@@ -1909,26 +1899,22 @@ libbalsa_message_create_mime_message(LibBalsaMessage* message, gboolean flow,
g_mime_message_set_date(mime_message, message->headers->date,
get_tz_offset(&message->headers->date));
- tmp = internet_address_list_to_string(message->headers->to_list, TRUE);
- g_mime_message_add_recipients_from_string(mime_message,
- GMIME_RECIPIENT_TYPE_TO, tmp);
- g_free(tmp);
-
- tmp = internet_address_list_to_string(message->headers->cc_list, TRUE);
- g_mime_message_add_recipients_from_string(mime_message,
- GMIME_RECIPIENT_TYPE_CC, tmp);
- g_free(tmp);
-
- tmp = internet_address_list_to_string(message->headers->bcc_list, TRUE);
- g_mime_message_add_recipients_from_string(mime_message,
- GMIME_RECIPIENT_TYPE_BCC, tmp);
- g_free(tmp);
-
+ recipients = g_mime_message_get_recipients(mime_message,
+ GMIME_RECIPIENT_TYPE_TO);
+ internet_address_list_append(recipients, message->headers->to_list);
+
+ recipients = g_mime_message_get_recipients(mime_message,
+ GMIME_RECIPIENT_TYPE_CC);
+ internet_address_list_append(recipients, message->headers->cc_list);
+
+ recipients = g_mime_message_get_recipients(mime_message,
+ GMIME_RECIPIENT_TYPE_BCC);
+ internet_address_list_append(recipients, message->headers->bcc_list);
+
if (message->headers->dispnotify_to) {
- tmp = internet_address_to_string(message->headers->dispnotify_to->
- address, TRUE);
+ tmp = internet_address_list_to_string(message->headers->dispnotify_to, TRUE);
if (tmp) {
- g_mime_message_add_header(mime_message,
+ g_mime_object_append_header(GMIME_OBJECT(mime_message),
"Disposition-Notification-To", tmp);
g_free(tmp);
}
@@ -1937,14 +1923,14 @@ libbalsa_message_create_mime_message(LibBalsaMessage* message, gboolean flow,
for (list = message->headers->user_hdrs; list; list = list->next) {
gchar **pair = list->data;
g_strchug(pair[1]);
- g_mime_message_add_header(mime_message, pair[0], pair[1]);
+ g_mime_object_append_header(GMIME_OBJECT(mime_message), pair[0], pair[1]);
#if DEBUG_USER_HEADERS
printf("adding header '%s:%s'\n", pair[0], pair[1]);
#endif
}
tmp = g_strdup_printf("Balsa %s", VERSION);
- g_mime_message_add_header(mime_message, "X-Mailer", tmp);
+ g_mime_object_append_header(GMIME_OBJECT(mime_message), "X-Mailer", tmp);
g_free(tmp);
message->mime_msg = mime_message;
@@ -1975,7 +1961,7 @@ libbalsa_message_postpone(LibBalsaMessage * message,
gint i;
for (i = 0; extra_headers[i] && extra_headers[i + 1]; i += 2)
- g_mime_message_set_header(message->mime_msg, extra_headers[i],
+ g_mime_object_set_header(GMIME_OBJECT(message->mime_msg), extra_headers[i],
extra_headers[i + 1]);
}
@@ -2069,21 +2055,17 @@ libbalsa_fill_msg_queue_item_from_queu(LibBalsaMessage * message,
static const gchar *
lb_send_from(LibBalsaMessage *message)
{
- InternetAddress *ia = message->headers->from->address;
+ InternetAddress *ia =
+ internet_address_list_get_address(message->headers->from, 0);
if (message->force_key_id)
return message->force_key_id;
- if (ia->type == INTERNET_ADDRESS_NONE)
- return NULL;
-
- while (ia->type == INTERNET_ADDRESS_GROUP)
- ia = ia->value.members->address;
-
- if (ia->type == INTERNET_ADDRESS_NONE)
- return NULL;
+ while (INTERNET_ADDRESS_IS_GROUP(ia))
+ ia = internet_address_list_get_address(((InternetAddressGroup *)
+ ia)->members, 0);
- return ia->value.addr;
+ return ((InternetAddressMailbox *) ia)->addr;
}
static LibBalsaMsgCreateResult
@@ -2204,7 +2186,7 @@ do_multipart_crypto(LibBalsaMessage * message, GMimeObject ** mime_root,
message->headers->cc_list);
encrypt_for = g_list_append(encrypt_for,
g_strdup(lb_send_from(message)));
- if (message->headers->bcc_list)
+ if (internet_address_list_length(message->headers->bcc_list) > 0)
libbalsa_information(LIBBALSA_INFORMATION_WARNING,
_("This message will not be encrypted for the BCC: recipient(s)."));
diff --git a/libinit_balsa/assistant_page_user.c b/libinit_balsa/assistant_page_user.c
index 923a4c4..2a26f2f 100644
--- a/libinit_balsa/assistant_page_user.c
+++ b/libinit_balsa/assistant_page_user.c
@@ -247,6 +247,7 @@ balsa_druid_page_user_next(GtkAssistant * druid, GtkWidget * page,
const gchar *host, *mailbox;
gchar *uhoh;
LibBalsaIdentity *ident;
+ InternetAddress *ia;
#if ENABLE_ESMTP
LibBalsaSmtpServer *smtp_server;
#endif /* ENABLE_ESMTP */
@@ -293,9 +294,9 @@ balsa_druid_page_user_next(GtkAssistant * druid, GtkWidget * page,
} else {
ident = balsa_app.current_ident;
}
- internet_address_set_name(ident->ia, mailbox);
- internet_address_set_addr(ident->ia,
- gtk_entry_get_text(GTK_ENTRY(user->email)));
+
+ ia = internet_address_mailbox_new (mailbox, gtk_entry_get_text(GTK_ENTRY(user->email)));
+ libbalsa_identity_set_address (ident, ia);
/* outgoing mail */
#if ENABLE_ESMTP
diff --git a/src/balsa-message.c b/src/balsa-message.c
index 1d7d332..3da2db5 100644
--- a/src/balsa-message.c
+++ b/src/balsa-message.c
@@ -1022,15 +1022,14 @@ tree_button_press_cb(GtkWidget * widget, GdkEventButton * event,
gchar *
balsa_message_sender_to_gchar(InternetAddressList * list, gint which)
{
+ InternetAddress *ia;
+
if (!list)
return g_strdup(_("(No sender)"));
if (which < 0)
return internet_address_list_to_string(list, FALSE);
- while (which > 0 && list->next) {
- list = list->next;
- --which;
- }
- return internet_address_to_string(list->address, FALSE);
+ ia = internet_address_list_get_address (list, which);
+ return internet_address_to_string(ia, FALSE);
}
static void
@@ -2082,7 +2081,7 @@ add_multipart_mixed(BalsaMessage * bm, LibBalsaMessageBody * body)
(g_mime_content_type_is_type(type, "application", "pkcs7-signature") ||
g_mime_content_type_is_type(type, "application", "x-pkcs7-signature"))))
add_body(bm, body);
- g_mime_content_type_destroy(type);
+ g_object_unref(type);
#else
if (libbalsa_message_body_is_inline(body) ||
bm->force_inline ||
@@ -2119,7 +2118,7 @@ add_multipart(BalsaMessage *bm, LibBalsaMessageBody *body)
} else { /* default to multipart/mixed */
body = add_multipart_mixed(bm, body->parts);
}
- g_mime_content_type_destroy(type);
+ g_object_unref(type);
return body;
}
@@ -2309,21 +2308,21 @@ balsa_message_grab_focus(BalsaMessage * bmessage)
return TRUE;
}
-static const InternetAddress *
-bm_get_mailbox(const InternetAddressList * list)
+static InternetAddress *
+bm_get_mailbox(InternetAddressList * list)
{
InternetAddress *ia;
if (!list)
return NULL;
- ia = list->address;
- if (!ia || ia->type == INTERNET_ADDRESS_NONE)
+ ia = internet_address_list_get_address (list, 0);
+ if (!ia)
return NULL;
- while (ia->type == INTERNET_ADDRESS_GROUP && ia->value.members)
- ia = ia->value.members->address;
- if (!ia || ia->type == INTERNET_ADDRESS_NONE)
+ while (ia && INTERNET_ADDRESS_IS_GROUP (ia))
+ ia = internet_address_list_get_address (INTERNET_ADDRESS_GROUP (ia)->members, 0);
+ if (!ia)
return NULL;
return ia;
@@ -2333,11 +2332,13 @@ static void
handle_mdn_request(GtkWindow *parent, LibBalsaMessage *message)
{
gboolean suspicious;
- const InternetAddressList *use_from;
- const InternetAddressList *list;
+ InternetAddressList *use_from;
+ InternetAddressList *list;
+ InternetAddress *from, *dn;
BalsaMDNReply action;
LibBalsaMessage *mdn;
LibBalsaIdentity *mdn_ident = NULL;
+ gint i, len;
/* Check if the dispnotify_to address is equal to the (in this order,
if present) reply_to, from or sender address. */
@@ -2351,25 +2352,27 @@ handle_mdn_request(GtkWindow *parent, LibBalsaMessage *message)
use_from = NULL;
/* note: neither Disposition-Notification-To: nor Reply-To:, From: or
Sender: may be address groups */
- suspicious =
- !libbalsa_ia_rfc2821_equal(message->headers->dispnotify_to->address,
- use_from->address);
+ from = use_from ? internet_address_list_get_address (use_from, 0) : NULL;
+ dn = internet_address_list_get_address (message->headers->dispnotify_to, 0);
+ suspicious = !libbalsa_ia_rfc2821_equal(dn, from);
/* Try to find "my" identity first in the to, then in the cc list */
- for (list = message->headers->to_list; list && !mdn_ident;
- list = list->next) {
+ list = message->headers->to_list;
+ len = list ? internet_address_list_length(list) : 0;
+ for (i = 0; i < len && !mdn_ident; i++) {
GList * id_list;
-
+
for (id_list = balsa_app.identities; !mdn_ident && id_list;
id_list = id_list->next) {
LibBalsaIdentity *ident = LIBBALSA_IDENTITY(id_list->data);
-
+
if (libbalsa_ia_rfc2821_equal(ident->ia, bm_get_mailbox(list)))
mdn_ident = ident;
}
}
- for (list = message->headers->cc_list; list && !mdn_ident;
- list = list->next) {
+
+ list = message->headers->cc_list;
+ for (i = 0; i < len && !mdn_ident; i++) {
GList * id_list;
for (id_list = balsa_app.identities; !mdn_ident && id_list;
@@ -2380,6 +2383,7 @@ handle_mdn_request(GtkWindow *parent, LibBalsaMessage *message)
mdn_ident = ident;
}
}
+
/* Now we decide from the settings of balsa_app.mdn_reply_[not]clean what
to do...
@@ -2402,7 +2406,7 @@ handle_mdn_request(GtkWindow *parent, LibBalsaMessage *message)
if (action == BALSA_MDN_REPLY_ASKME) {
gchar *sender;
gchar *reply_to;
- sender = internet_address_to_string (use_from->address, FALSE);
+ sender = from ? internet_address_to_string (from, FALSE) : NULL;
reply_to =
internet_address_list_to_string (message->headers->dispnotify_to,
FALSE);
@@ -2447,14 +2451,14 @@ static LibBalsaMessage *create_mdn_reply (const LibBalsaIdentity *mdn_ident,
/* create a message with the header set from the incoming message */
message = libbalsa_message_new();
- dummy = internet_address_to_string(mdn_ident->ia, FALSE);
- message->headers->from = internet_address_parse_string(dummy);
- g_free (dummy);
+ message->headers->from = internet_address_list_new();
+ internet_address_list_add(message->headers->from,
+ balsa_app.current_ident->ia);
message->headers->date = time(NULL);
libbalsa_message_set_subject(message, "Message Disposition Notification");
- message->headers->to_list =
- internet_address_list_prepend(NULL, for_msg->headers->
- dispnotify_to->address);
+ message->headers->to_list = internet_address_list_new ();
+ internet_address_list_append(message->headers->to_list,
+ for_msg->headers->dispnotify_to);
/* RFC 2298 requests this mime type... */
message->subtype = g_strdup("report");
@@ -2494,7 +2498,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",
- mdn_ident->ia->value.addr);
+ INTERNET_ADDRESS_MAILBOX(balsa_app.
+ current_ident->ia)->
+ addr);
if (for_msg->message_id)
g_string_append_printf(report, "Original-Message-ID: <%s>\n",
for_msg->message_id);
diff --git a/src/balsa-mime-widget-message.c b/src/balsa-mime-widget-message.c
index f947ba0..ad4a102 100644
--- a/src/balsa-mime-widget-message.c
+++ b/src/balsa-mime-widget-message.c
@@ -317,9 +317,9 @@ extbody_send_mail(GtkWidget * button, LibBalsaMessageBody * mime_body)
/* create a message */
message = libbalsa_message_new();
- data = internet_address_to_string(balsa_app.current_ident->ia, FALSE);
- message->headers->from = internet_address_parse_string(data);
- g_free(data);
+ message->headers->from = internet_address_list_new();
+ internet_address_list_add(message->headers->from,
+ balsa_app.current_ident->ia);
data = libbalsa_message_body_get_parameter(mime_body, "subject");
if (data) {
@@ -328,7 +328,7 @@ extbody_send_mail(GtkWidget * button, LibBalsaMessageBody * mime_body)
}
data = libbalsa_message_body_get_parameter(mime_body, "server");
- message->headers->to_list = internet_address_parse_string(data);
+ message->headers->to_list = internet_address_list_parse_string(data);
g_free(data);
/* the original body my have some data to be returned as commands... */
@@ -629,7 +629,7 @@ add_header_address_list(BalsaMessage * bm, GtkTextView * view,
{
gchar *value;
- if (list == NULL)
+ if (list == NULL || internet_address_list_length(list) == 0)
return;
if (!(bm->shown_headers == HEADERS_ALL ||
diff --git a/src/balsa-mime-widget-vcalendar.c b/src/balsa-mime-widget-vcalendar.c
index f7f4656..b2cb5b9 100644
--- a/src/balsa-mime-widget-vcalendar.c
+++ b/src/balsa-mime-widget-vcalendar.c
@@ -77,11 +77,15 @@ balsa_mime_widget_new_vcalendar(BalsaMessage * bm,
may_reply = TRUE;
if (lbm->headers) {
if (lbm->headers->reply_to)
- sender = lbm->headers->reply_to->address;
+ sender =
+ internet_address_list_get_address(lbm->headers->
+ reply_to, 0);
else if (lbm->headers && lbm->headers->from)
- sender = lbm->headers->from->address;
+ sender =
+ internet_address_list_get_address(lbm->headers->from,
+ 0);
} else if (lbm->sender)
- sender = lbm->sender->address;
+ sender = internet_address_list_get_address(lbm->sender, 0);
}
/* add events */
@@ -182,10 +186,11 @@ balsa_vevent_widget(LibBalsaVEvent * event, gboolean may_reply,
g_free(this_att);
if (may_reply && libbalsa_vcal_attendee_rsvp(lba)) {
- InternetAddress *ia = internet_address_new();
+ InternetAddress *ia =
+ internet_address_mailbox_new(NULL,
+ lba->address_list->data);
GList *list;
- internet_address_set_addr(ia, lba->address_list->data);
for (list = balsa_app.identities; list; list = list->next) {
LibBalsaIdentity *ident = list->data;
if (libbalsa_ia_rfc2821_equal(ident->ia, ia)) {
@@ -193,7 +198,7 @@ balsa_vevent_widget(LibBalsaVEvent * event, gboolean may_reply,
break;
}
}
- internet_address_unref(ia);
+ g_object_unref(ia);
}
}
TABLE_ATTACH(table, all_atts->str,
@@ -209,8 +214,8 @@ balsa_vevent_widget(LibBalsaVEvent * event, gboolean may_reply,
GtkWidget *button;
/* add the callback data to the event object */
- g_object_ref(G_OBJECT(event));
- internet_address_ref(sender);
+ g_object_ref(event);
+ g_object_ref(sender);
g_object_set_data_full(G_OBJECT(event), "ev:sender",
internet_address_to_string(sender, FALSE),
(GDestroyNotify) g_free);
@@ -285,10 +290,9 @@ vevent_reply(GObject * button, GtkWidget * box)
/* create a message with the header set from the incoming message */
message = libbalsa_message_new();
- dummy = internet_address_to_string(ident->ia, FALSE);
- message->headers->from = internet_address_parse_string(dummy);
- g_free(dummy);
- message->headers->to_list = internet_address_parse_string(rcpt);
+ message->headers->from = internet_address_list_new();
+ internet_address_list_add(message->headers->from, ident->ia);
+ message->headers->to_list = internet_address_list_parse_string(rcpt);
message->headers->date = time(NULL);
/* create the message subject */
@@ -302,7 +306,7 @@ vevent_reply(GObject * button, GtkWidget * box)
body = libbalsa_message_body_new(message);
body->buffer =
libbalsa_vevent_reply(event,
- internet_address_get_addr(ident->ia),
+ INTERNET_ADDRESS_MAILBOX(ident->ia)->addr,
pstat);
body->charset = g_strdup("utf-8");
body->content_type = g_strdup("text/calendar");
diff --git a/src/save-restore.c b/src/save-restore.c
index e819a6a..3a9de2a 100644
--- a/src/save-restore.c
+++ b/src/save-restore.c
@@ -1782,7 +1782,7 @@ config_view_load(const gchar * key, const gchar * value, gpointer data)
libbalsa_conf_get_string_with_default("MailingListAddress",
&def);
view->mailing_list_address =
- def ? NULL : internet_address_parse_string(address);
+ def ? NULL : internet_address_list_parse_string(address);
g_free(address);
view->identity_name = libbalsa_conf_get_string("Identity");
diff --git a/src/sendmsg-window.c b/src/sendmsg-window.c
index f2bcc45..bcdec4a 100644
--- a/src/sendmsg-window.c
+++ b/src/sendmsg-window.c
@@ -905,20 +905,21 @@ sw_delete_draft(BalsaSendmsg * bsmsg)
static gint
delete_handler(BalsaSendmsg * bsmsg)
{
- InternetAddressList *l;
+ InternetAddressList *list;
+ const InternetAddress *ia;
const gchar *tmp;
gint reply;
GtkWidget *d;
if (balsa_app.debug)
- printf("delete_event_cb\n");
+ printf("%s\n", __func__);
if (bsmsg->state == SENDMSG_STATE_CLEAN)
return FALSE;
- l = libbalsa_address_view_get_list(bsmsg->recipient_view, "To:");
- tmp = l && l->address && l->address->name ?
- l->address->name : _("(No name)");
+ list = libbalsa_address_view_get_list(bsmsg->recipient_view, "To:");
+ ia = internet_address_list_get_address(list, 0);
+ tmp = ia && ia->name ? ia->name : _("(No name)");
d = gtk_message_dialog_new(GTK_WINDOW(bsmsg->window),
GTK_DIALOG_DESTROY_WITH_PARENT,
@@ -926,7 +927,7 @@ delete_handler(BalsaSendmsg * bsmsg)
GTK_BUTTONS_YES_NO,
_("The message to '%s' is modified.\n"
"Save message to Draftbox?"), tmp);
- internet_address_list_destroy(l);
+ g_object_unref(list);
gtk_dialog_set_default_response(GTK_DIALOG(d), GTK_RESPONSE_YES);
gtk_dialog_add_button(GTK_DIALOG(d),
GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL);
@@ -1279,7 +1280,7 @@ edit_with_gnome(GtkAction * action, BalsaSendmsg* bsmsg)
libbalsa_address_view_get_list(bsmsg->recipient_view,
address_types[type]);
gchar *p = internet_address_list_to_string(list, FALSE);
- internet_address_list_destroy(list);
+ g_object_unref(list);
fprintf(tmp, "%s %s\n", _(address_types[type]), p);
g_free(p);
}
@@ -1491,39 +1492,49 @@ update_bsmsg_identity(BalsaSendmsg* bsmsg, LibBalsaIdentity* ident)
#endif
if (bsmsg->ident->bcc) {
- InternetAddressList *l,
- *old_ident_list, *new_ident_list,
- *old_list, *new_list = NULL;
-
- /* Copy the old list of Bcc addresses, omitting any that came
- * from the old identity: */
- old_ident_list = internet_address_parse_string(bsmsg->ident->bcc);
- old_list =
- libbalsa_address_view_get_list(bsmsg->recipient_view,
- "Bcc:");
- for (l = old_list; l; l = l->next) {
- InternetAddress *ia = l->address;
- InternetAddressList *m;
-
- for (m = old_ident_list; m; m = m->next)
- if (libbalsa_ia_rfc2821_equal(ia, m->address))
- break;
- if (!m) /* We didn't find this address. */
- new_list = internet_address_list_append(new_list, ia);
+ InternetAddressList *bcc_list, *ident_list;
+ int i, j;
+
+ bcc_list =
+ libbalsa_address_view_get_list(bsmsg->recipient_view, "Bcc:");
+
+ ident_list = internet_address_list_parse_string(bsmsg->ident->bcc);
+ if (ident_list) {
+ /* Remove any Bcc addresses that came from the old identity
+ * from the list. */
+ gint ident_list_len = internet_address_list_length(ident_list);
+
+ for (i = 0; i < internet_address_list_length(bcc_list); i++) {
+ InternetAddress *ia =
+ internet_address_list_get_address (bcc_list, i);
+
+ for (j = 0; j < ident_list_len; j++) {
+ InternetAddress *ia2 =
+ internet_address_list_get_address(ident_list, j);
+ if (libbalsa_ia_rfc2821_equal(ia, ia2))
+ break;
+ }
+
+ if (j < ident_list_len) {
+ /* This address was found in the identity. */
+ internet_address_list_remove_at(bcc_list, i);
+ --i;
+ }
+ }
+ g_object_unref(ident_list);
}
- internet_address_list_destroy(old_list);
- internet_address_list_destroy(old_ident_list);
/* Add the new Bcc addresses, if any: */
- new_ident_list = internet_address_parse_string(ident->bcc);
- new_list = internet_address_list_concat(new_list, new_ident_list);
- internet_address_list_destroy(new_ident_list);
+ ident_list = internet_address_list_parse_string(ident->bcc);
+ if (ident_list) {
+ internet_address_list_append(bcc_list, ident_list);
+ g_object_unref(ident_list);
+ }
/* Set the resulting list: */
- libbalsa_address_view_set_from_list(bsmsg->recipient_view,
- "Bcc:",
- new_list);
- internet_address_list_destroy(new_list);
+ libbalsa_address_view_set_from_list(bsmsg->recipient_view, "Bcc:",
+ bcc_list);
+ g_object_unref(bcc_list);
}
/* change the subject to use the reply/forward strings */
@@ -1993,12 +2004,7 @@ get_fwd_mail_headers(const gchar *mailfile)
if (!subject)
headers->subject = g_strdup(_("(no subject)"));
else
-#if HAVE_GMIME_2_2_5
headers->subject = g_mime_utils_header_decode_text(subject);
-#else /* HAVE_GMIME_2_2_5 */
- headers->subject =
- g_mime_utils_header_decode_text((guchar *) subject);
-#endif /* HAVE_GMIME_2_2_5 */
}
libbalsa_utf8_sanitize(&headers->subject,
balsa_app.convert_unknown_8bit,
@@ -3388,7 +3394,7 @@ tree_add_quote_body(LibBalsaMessageBody * body, GtkTreeStore * store, GtkTreeIte
gtk_tree_store_append(store, &iter, parent);
if (body->mime_part)
- disp_type = g_mime_part_get_content_disposition(GMIME_PART(body->mime_part));
+ disp_type = g_mime_object_get_disposition(body->mime_part);
else
disp_type = NULL;
preselect = !disp_type || *disp_type == '\0' ||
@@ -3810,7 +3816,7 @@ quote_body(BalsaSendmsg * bsmsg, LibBalsaMessageHeaders *headers,
g_free(from);
}
- if (headers->to_list) {
+ if (internet_address_list_length(headers->to_list) > 0) {
gchar *to_list =
internet_address_list_to_string(headers->to_list,
FALSE);
@@ -3818,7 +3824,7 @@ quote_body(BalsaSendmsg * bsmsg, LibBalsaMessageHeaders *headers,
g_free(to_list);
}
- if (headers->cc_list) {
+ if (internet_address_list_length(headers->cc_list) > 0) {
gchar *cc_list =
internet_address_list_to_string(headers->cc_list,
FALSE);
@@ -4237,77 +4243,58 @@ set_identity_from_mailbox(BalsaSendmsg* bsmsg, LibBalsaMessage * message)
* particular identity, other than the default. The to_list of the
* original message needs to be set in order for it to work.
**/
+/* First a helper; groups cannot be nested, and are not allowed in the
+ * From: list. */
static gboolean
-guess_identity(BalsaSendmsg* bsmsg, LibBalsaMessage * message)
+guess_identity_from_list(BalsaSendmsg * bsmsg, InternetAddressList * list,
+ gboolean allow_group)
{
- const gchar *address_string;
- GList *ilist;
- LibBalsaIdentity *ident;
- const gchar *tmp;
+ gint i;
+ for (i = 0; i < internet_address_list_length(list); i++) {
+ InternetAddress *ia = internet_address_list_get_address(list, i);
+ if (INTERNET_ADDRESS_IS_GROUP(ia)) {
+ InternetAddressList *members =
+ INTERNET_ADDRESS_GROUP(ia)->members;
+ if (allow_group
+ && guess_identity_from_list(bsmsg, members, FALSE))
+ return TRUE;
+ } else {
+ GList *l;
+
+ for (l = balsa_app.identities; l; l = l->next) {
+ LibBalsaIdentity *ident = LIBBALSA_IDENTITY(l->data);
+ if (libbalsa_ia_rfc2821_equal(ia, ident->ia)) {
+ bsmsg->ident = ident;
+ return TRUE;
+ }
+ }
+ }
+ }
+
+ return FALSE;
+}
+
+static gboolean
+guess_identity(BalsaSendmsg* bsmsg, LibBalsaMessage * message)
+{
if (!message || !message->headers || !balsa_app.identities)
return FALSE; /* use default */
- if (bsmsg->type == SEND_CONTINUE) {
- if (message->headers->from) {
- /*
- * Look for an identity that matches the From: address.
- */
- address_string =
- libbalsa_address_get_mailbox_from_list(message->headers->
- from);
- for (ilist = balsa_app.identities; ilist;
- ilist = g_list_next(ilist)) {
- ident = LIBBALSA_IDENTITY(ilist->data);
- if ((tmp = ident->ia->value.addr)
- && !g_ascii_strcasecmp(address_string, tmp)) {
- bsmsg->ident = ident;
- return( TRUE );
- }
- }
- }
- } else if (bsmsg->type != SEND_NORMAL) {
- /* bsmsg->type == SEND_REPLY || bsmsg->type == SEND_REPLY_ALL ||
- * bsmsg->type == SEND_REPLY_GROUP || bsmsg->type == SEND_FORWARD_ATTACH ||
- * bsmsg->type == SEND_FORWARD_INLINE */
- InternetAddressList *alist;
-
- /*
- * Loop through all the addresses in the message's To:
- * field, and look for an identity that matches one of them.
- */
- for (alist = message->headers->to_list; alist; alist = alist->next) {
- if (!(address_string =
- libbalsa_address_get_mailbox_from_list(alist)))
- continue;
- for (ilist = balsa_app.identities; ilist;
- ilist = g_list_next(ilist)) {
- ident = LIBBALSA_IDENTITY(ilist->data);
- if ((tmp = ident->ia->value.addr)
- && !g_ascii_strcasecmp(address_string, tmp)) {
- bsmsg->ident = ident;
- return TRUE;
- }
- }
- }
-
- /* No match in the to_list, try the cc_list */
- for (alist = message->headers->cc_list; alist; alist = alist->next) {
- if (!(address_string =
- libbalsa_address_get_mailbox_from_list(alist)))
- continue;
- for (ilist = balsa_app.identities; ilist;
- ilist = g_list_next(ilist)) {
- ident = LIBBALSA_IDENTITY(ilist->data);
- if ((tmp = ident->ia->value.addr)
- && !g_ascii_strcasecmp(address_string, tmp)) {
- bsmsg->ident = ident;
- return TRUE;
- }
- }
- }
- }
+ if (bsmsg->type == SEND_CONTINUE)
+ return guess_identity_from_list(bsmsg, message->headers->from,
+ FALSE);
+
+ if (bsmsg->type != SEND_NORMAL)
+ /* bsmsg->type == SEND_REPLY || bsmsg->type == SEND_REPLY_ALL ||
+ * bsmsg->type == SEND_REPLY_GROUP || bsmsg->type == SEND_FORWARD_ATTACH ||
+ * bsmsg->type == SEND_FORWARD_INLINE */
+ return guess_identity_from_list(bsmsg, message->headers->to_list,
+ TRUE)
+ || guess_identity_from_list(bsmsg, message->headers->cc_list,
+ TRUE);
+
return FALSE;
}
@@ -4499,19 +4486,21 @@ bsmsg_identities_changed_cb(BalsaSendmsg * bsmsg)
static void
sw_cc_add_list(InternetAddressList **new_cc, InternetAddressList * list)
{
- for (; list; list = list->next) {
- InternetAddress *ia;
-
- if ((ia = list->address)) {
- GList *ident;
-
- /* do not insert any of my identities into the cc: list */
- for (ident = balsa_app.identities; ident; ident = ident->next)
- if (libbalsa_ia_rfc2821_equal
- (ia, LIBBALSA_IDENTITY(ident->data)->ia))
- break;
- if (!ident)
- *new_cc = internet_address_list_append(*new_cc, ia);
+ int i;
+
+ for (i = 0; i < internet_address_list_length(list); i++) {
+ InternetAddress *ia = internet_address_list_get_address (list, i);
+ GList *ident;
+
+ /* do not insert any of my identities into the cc: list */
+ for (ident = balsa_app.identities; ident; ident = ident->next)
+ if (libbalsa_ia_rfc2821_equal
+ (ia, LIBBALSA_IDENTITY(ident->data)->ia))
+ break;
+ if (!ident) {
+ if (*new_cc == NULL)
+ *new_cc = internet_address_list_new();
+ internet_address_list_add(*new_cc, ia);
}
}
}
@@ -4775,7 +4764,8 @@ set_cc_from_all_recipients(BalsaSendmsg* bsmsg,
libbalsa_address_view_set_from_list(bsmsg->recipient_view,
"Cc:",
new_cc);
- internet_address_list_destroy(new_cc);
+ if (new_cc)
+ g_object_unref(new_cc);
}
static void
@@ -5513,7 +5503,8 @@ bsmsg2message(BalsaSendmsg * bsmsg)
message = libbalsa_message_new();
- message->headers->from = internet_address_list_prepend(NULL, ident->ia);
+ message->headers->from = internet_address_list_new ();
+ internet_address_list_add(message->headers->from, ident->ia);
tmp = gtk_editable_get_chars(GTK_EDITABLE(bsmsg->subject[1]), 0, -1);
strip_chars(tmp, "\r\n");
@@ -5733,9 +5724,8 @@ check_suggest_encryption(BalsaSendmsg * bsmsg)
{
InternetAddressList * ia_list;
gboolean can_encrypt;
- InternetAddressList * from_list;
- InternetAddressList * cc_list;
gpgme_protocol_t protocol;
+ gint len;
/* check if the user wants to see the message */
if (!bsmsg->ident->warn_send_plain)
@@ -5746,23 +5736,30 @@ check_suggest_encryption(BalsaSendmsg * bsmsg)
return TRUE;
/* we can not encrypt if we have bcc recipients */
- if ((ia_list = libbalsa_address_view_get_list(bsmsg->recipient_view, "Bcc:"))) {
- internet_address_list_destroy(ia_list);
- return TRUE;
- }
+ ia_list = libbalsa_address_view_get_list(bsmsg->recipient_view, "Bcc:");
+ len = internet_address_list_length(ia_list);
+ g_object_unref(ia_list);
+ if (len > 0)
+ return TRUE;
/* collect all to and cc recipients */
- ia_list = libbalsa_address_view_get_list(bsmsg->recipient_view, "To:");
- cc_list = libbalsa_address_view_get_list(bsmsg->recipient_view, "Cc:");
- from_list = internet_address_list_prepend(NULL, bsmsg->ident->ia);
protocol = bsmsg->gpg_mode & LIBBALSA_PROTECT_SMIMEV3 ?
GPGME_PROTOCOL_CMS : GPGME_PROTOCOL_OpenPGP;
- can_encrypt = libbalsa_can_encrypt_for_all(from_list, protocol) &
- libbalsa_can_encrypt_for_all(ia_list, protocol) &
- libbalsa_can_encrypt_for_all(cc_list, protocol);
- internet_address_list_destroy(from_list);
- internet_address_list_destroy(ia_list);
- internet_address_list_destroy(cc_list);
+
+ ia_list = libbalsa_address_view_get_list(bsmsg->recipient_view, "To:");
+ can_encrypt = libbalsa_can_encrypt_for_all(ia_list, protocol);
+ g_object_unref(ia_list);
+ if (can_encrypt) {
+ ia_list = libbalsa_address_view_get_list(bsmsg->recipient_view, "Cc:");
+ can_encrypt = libbalsa_can_encrypt_for_all(ia_list, protocol);
+ g_object_unref(ia_list);
+ }
+ if (can_encrypt) {
+ ia_list = internet_address_list_new();
+ internet_address_list_add(ia_list, bsmsg->ident->ia);
+ can_encrypt = libbalsa_can_encrypt_for_all(ia_list, protocol);
+ g_object_unref(ia_list);
+ }
/* ask the user if we could encrypt this message */
if (can_encrypt) {
@@ -6777,7 +6774,7 @@ set_list_post_address(BalsaSendmsg * bsmsg)
if (mailing_list_address) {
libbalsa_address_view_set_from_list(bsmsg->recipient_view, "To:",
mailing_list_address);
- internet_address_list_destroy(mailing_list_address);
+ g_object_unref(mailing_list_address);
return;
}
@@ -6911,7 +6908,7 @@ sendmsg_window_set_title(BalsaSendmsg * bsmsg)
list = libbalsa_address_view_get_list(bsmsg->recipient_view, "To:");
to_string = internet_address_list_to_string(list, FALSE);
- internet_address_list_destroy(list);
+ g_object_unref(list);
title = g_strdup_printf(title_format, to_string,
gtk_entry_get_text(GTK_ENTRY(bsmsg->subject[1])));
diff --git a/src/store-address.c b/src/store-address.c
index 0b8d962..3cb9c63 100644
--- a/src/store-address.c
+++ b/src/store-address.c
@@ -58,13 +58,13 @@ static void store_address_book_menu_cb(GtkWidget * widget,
StoreAddressInfo * info);
static void store_address_add_address(StoreAddressInfo * info,
const gchar * label,
- const InternetAddress * address,
- const InternetAddress * group);
+ InternetAddress * address,
+ InternetAddress * group);
static void store_address_add_lbaddress(StoreAddressInfo * info,
const LibBalsaAddress *address);
static void store_address_add_list(StoreAddressInfo * info,
const gchar * label,
- const InternetAddressList * list);
+ InternetAddressList * list);
/*
* public interface: balsa_store_address
@@ -347,8 +347,8 @@ store_address_book_menu_cb(GtkWidget * widget,
* make a new page in the notebook */
static void
store_address_add_address(StoreAddressInfo * info,
- const gchar * lab, const InternetAddress * ia,
- const InternetAddress * group)
+ const gchar * lab, InternetAddress * ia,
+ InternetAddress * group)
{
gchar *text;
LibBalsaAddress *address;
@@ -365,7 +365,7 @@ store_address_add_address(StoreAddressInfo * info,
address = libbalsa_address_new();
address->full_name =
g_strdup(ia->name ? ia->name : group ? group->name : NULL);
- address->address_list = g_list_prepend(NULL, g_strdup(ia->value.addr));
+ address->address_list = g_list_prepend(NULL, g_strdup(INTERNET_ADDRESS_MAILBOX (ia)->addr));
ew = libbalsa_address_get_edit_widget(address, entries, NULL, NULL);
g_object_unref(address);
@@ -408,20 +408,22 @@ store_address_add_lbaddress(StoreAddressInfo * info,
static void
store_address_add_list(StoreAddressInfo * info,
const gchar * label,
- const InternetAddressList * list)
+ InternetAddressList * list)
{
- for (; list; list = list->next) {
- InternetAddress *ia = list->address;
-
- if (ia->type == INTERNET_ADDRESS_NAME)
+ int i, j;
+
+ for (i = 0; i < internet_address_list_length (list); i++) {
+ InternetAddress *ia = internet_address_list_get_address (list, i);
+
+ if (INTERNET_ADDRESS_IS_MAILBOX (ia))
store_address_add_address(info, label, ia, NULL);
- else if (ia->type == INTERNET_ADDRESS_GROUP) {
- InternetAddressList *member;
+ else {
+ InternetAddressList *members = INTERNET_ADDRESS_GROUP (ia)->members;
- for (member = ia->value.members; member; member = member->next) {
- InternetAddress *member_address = member->address;
+ for (j = 0; j < internet_address_list_length (members); j++) {
+ InternetAddress *member_address = internet_address_list_get_address (members, j);
- if (member_address->type == INTERNET_ADDRESS_NAME)
+ if (INTERNET_ADDRESS_IS_MAILBOX (member_address))
store_address_add_address(info, label, member_address,
ia);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]