Index: src/balsa-mime-widget-message.c
===================================================================
--- src/balsa-mime-widget-message.c	(revision 8057)
+++ src/balsa-mime-widget-message.c	(working copy)
@@ -315,9 +315,9 @@
 
     /* 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) {
@@ -326,7 +326,7 @@
     }
 
     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... */
@@ -625,7 +625,7 @@
 {
     gchar *value;
 
-    if (list == NULL)
+    if (list == NULL || internet_address_list_length(list) == 0)
 	return;
 
     if (!(bm->shown_headers == HEADERS_ALL ||
Index: src/store-address.c
===================================================================
--- src/store-address.c	(revision 8057)
+++ src/store-address.c	(working copy)
@@ -58,13 +58,13 @@
                                        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 @@
  * 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 @@
     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 @@
 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);
             }
Index: src/sendmsg-window.c
===================================================================
--- src/sendmsg-window.c	(revision 8057)
+++ src/sendmsg-window.c	(working copy)
@@ -900,20 +900,21 @@
 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,
@@ -921,7 +922,7 @@
                                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);
@@ -1274,7 +1275,7 @@
                 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);
         }
@@ -1486,39 +1487,49 @@
 #endif
 
     if (bsmsg->ident->bcc) {
-        InternetAddressList *l,
-                            *old_ident_list, *new_ident_list,
-                            *old_list, *new_list = NULL;
+        InternetAddressList *bcc_list, *ident_list;
+	int i, j;
 
-        /* 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;
+        bcc_list =
+            libbalsa_address_view_get_list(bsmsg->recipient_view, "Bcc:");
 
-            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);
+        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 */
@@ -1988,12 +1999,7 @@
 	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,
@@ -3383,7 +3389,7 @@
 
     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' ||
@@ -3805,7 +3811,7 @@
 	    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);
@@ -3813,7 +3819,7 @@
 	    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);
@@ -4232,77 +4238,58 @@
  * 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;
 }
 
@@ -4494,19 +4481,21 @@
 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);
         }
     }
 }
@@ -4766,7 +4755,8 @@
     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
@@ -5504,7 +5494,8 @@
 
     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");
@@ -5724,9 +5715,8 @@
 {
     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)
@@ -5737,24 +5727,31 @@
 	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) {
 	GtkWidget *dialog;
@@ -6768,7 +6765,7 @@
     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;
     }
 
@@ -6902,7 +6899,7 @@
 
     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])));
Index: src/save-restore.c
===================================================================
--- src/save-restore.c	(revision 8057)
+++ src/save-restore.c	(working copy)
@@ -1779,7 +1779,7 @@
             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");
Index: src/balsa-message.c
===================================================================
--- src/balsa-message.c	(revision 8057)
+++ src/balsa-message.c	(working copy)
@@ -1018,15 +1018,14 @@
 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
@@ -2075,7 +2074,7 @@
 		 (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 ||
@@ -2112,7 +2111,7 @@
     } else { /* default to multipart/mixed */
 	body = add_multipart_mixed(bm, body->parts);
     }
-    g_mime_content_type_destroy(type);
+    g_object_unref(type);
 
     return body;
 }
@@ -2302,21 +2301,21 @@
     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;
@@ -2326,10 +2325,12 @@
 handle_mdn_request(GtkWindow *parent, LibBalsaMessage *message)
 {
     gboolean suspicious, found;
-    const InternetAddressList *use_from;
-    const InternetAddressList *list;
+    InternetAddressList *use_from;
+    InternetAddressList *list;
+    InternetAddress *from, *dn;
     BalsaMDNReply action;
     LibBalsaMessage *mdn;
+    gint i, len;
 
     /* Check if the dispnotify_to address is equal to the (in this order,
        if present) reply_to, from or sender address. */
@@ -2341,28 +2342,29 @@
         use_from = message->sender;
     else
         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);
     
     if (!suspicious) {
         /* Try to find "my" address first in the to, then in the cc list */
+        found = FALSE;
+
         list = message->headers->to_list;
-        found = FALSE;
-        while (list && !found) {
-            found = libbalsa_ia_rfc2821_equal(balsa_app.current_ident->ia,
+        len = list ? internet_address_list_length(list) : 0;
+	for (i = 0; i < len && !found; i++)
+	    found = libbalsa_ia_rfc2821_equal(balsa_app.current_ident->ia,
 					      bm_get_mailbox(list));
-            list = list->next;
-        }
+	
         if (!found) {
             list = message->headers->cc_list;
-            while (list && !found) {
-                found = libbalsa_ia_rfc2821_equal(balsa_app.current_ident->ia,
+            len = list ? internet_address_list_length(list) : 0;
+            for (i = 0; i < len && !found; i++)
+		found = libbalsa_ia_rfc2821_equal(balsa_app.current_ident->ia,
 						  bm_get_mailbox(list));
-                list = list->next;
-            }
         }
         suspicious = !found;
     }
@@ -2384,7 +2386,7 @@
     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);
@@ -2427,14 +2429,14 @@
 
     /* create a message with the header set from the incoming message */
     message = libbalsa_message_new();
-    dummy = internet_address_to_string(balsa_app.current_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");
@@ -2474,7 +2476,7 @@
 	g_string_append_printf(report, "Original-Recipient: %s\n",
 			       original_rcpt);	
     g_string_append_printf(report, "Final-Recipient: rfc822; %s\n",
-			   balsa_app.current_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);
Index: libinit_balsa/assistant_page_user.c
===================================================================
--- libinit_balsa/assistant_page_user.c	(revision 8057)
+++ libinit_balsa/assistant_page_user.c	(working copy)
@@ -246,6 +246,7 @@
     const gchar *host, *mailbox;
     gchar *uhoh;
     LibBalsaIdentity *ident;
+    InternetAddress *ia;
 #if ENABLE_ESMTP
     LibBalsaSmtpServer *smtp_server;
 #endif /* ENABLE_ESMTP */
@@ -292,9 +293,9 @@
     } 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
Index: configure.in
===================================================================
--- configure.in	(revision 8057)
+++ configure.in	(working copy)
@@ -371,7 +371,7 @@
 PKG_CHECK_MODULES(BALSA, [
 glib-2.0
 gtk+-2.0 >= 2.4
-gmime-2.0 >= 2.1.9
+gmime-2.4 >= 2.3.8
 gconf-2.0
 $gio_extra
 $gnome_extras
@@ -382,7 +382,7 @@
    libgnome-2.0 libgnomeui-2.0 
    glib-2.0
    gtk+-2.0 >= 2.4
-   gmime-2.0 >= 2.1.9
+   gmime-2.4 >= 2.3.8
 ])
 
 dnl ##########################################################################
@@ -951,16 +951,6 @@
 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 #####################################################################
Index: libbalsa/address-book-rubrica.c
===================================================================
--- libbalsa/address-book-rubrica.c	(revision 8057)
+++ libbalsa/address-book-rubrica.c	(working copy)
@@ -236,8 +236,7 @@
 	 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);
@@ -469,28 +468,29 @@
 	    && 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);
 	    }
 	}
     }
Index: libbalsa/abook-completion.c
===================================================================
--- libbalsa/abook-completion.c	(revision 8057)
+++ libbalsa/abook-completion.c	(working copy)
@@ -46,7 +46,7 @@
 
     ret = g_new0(CompletionData, 1);
 
-    internet_address_ref(ia);
+    g_object_ref(ia);
     ret->ia = ia;
 
     string = g_string_new(nick_name);
@@ -78,7 +78,7 @@
 void
 completion_data_free(CompletionData * data)
 {
-    internet_address_unref(data->ia);
+    g_object_unref(data->ia);
     g_free(data->string);
     g_free(data);
 }
Index: libbalsa/gmime-gpgme-context.c
===================================================================
--- libbalsa/gmime-gpgme-context.c	(revision 8057)
+++ libbalsa/gmime-gpgme-context.c	(working copy)
@@ -62,9 +62,11 @@
 				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 */
@@ -634,7 +636,7 @@
  * 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)
 {
@@ -649,10 +651,11 @@
 	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);
 
@@ -672,13 +675,13 @@
 	 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 */
@@ -688,7 +691,7 @@
 	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);
@@ -696,7 +699,23 @@
     /* 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;
 }
 
 
Index: libbalsa/mailbox_mh.c
===================================================================
--- libbalsa/mailbox_mh.c	(revision 8057)
+++ libbalsa/mailbox_mh.c	(working copy)
@@ -1094,9 +1094,9 @@
     }
     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);
 
Index: libbalsa/mailbox_mbox.c
===================================================================
--- libbalsa/mailbox_mbox.c	(revision 8057)
+++ libbalsa/mailbox_mbox.c	(working copy)
@@ -353,7 +353,7 @@
  */
 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;
@@ -1787,7 +1787,7 @@
 
     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;
@@ -1797,7 +1797,7 @@
 	    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;
@@ -1821,10 +1821,10 @@
     /* 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);
 }
 
@@ -1832,7 +1832,8 @@
  * 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");
 
@@ -1842,21 +1843,30 @@
             /* 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);
@@ -1868,8 +1878,8 @@
                 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);
     }
 }
 
@@ -1882,7 +1892,7 @@
     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;
 }
@@ -1893,10 +1903,10 @@
     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);
 
Index: libbalsa/message.c
===================================================================
--- libbalsa/message.c	(revision 8057)
+++ libbalsa/message.c	(working copy)
@@ -144,7 +144,7 @@
     message->headers = NULL;
 
     if (message->sender) {
-	internet_address_list_destroy(message->sender);
+	g_object_unref(message->sender);
 	message->sender = NULL;
     }
 
@@ -209,37 +209,37 @@
     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;
     }
 
@@ -261,7 +261,7 @@
         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");
@@ -465,6 +465,8 @@
 GList *
 libbalsa_message_user_hdrs_from_gmime(GMimeMessage * message)
 {
+    GMimeHeaderList *hdrlist;
+    GMimeHeaderIter iter;
     GList *res = NULL;
     const char *value;
 
@@ -479,7 +481,7 @@
        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;
@@ -502,26 +504,24 @@
 #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);
 }
 
@@ -696,7 +696,7 @@
 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);
 
@@ -807,9 +807,13 @@
 {
     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
@@ -839,7 +843,7 @@
     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);
@@ -851,7 +855,7 @@
     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);
@@ -869,15 +873,16 @@
 /* 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;
 }
 
@@ -889,7 +894,7 @@
     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);
@@ -904,7 +909,7 @@
 	 *     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);
@@ -925,12 +930,12 @@
 
     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)
@@ -944,7 +949,7 @@
     /* 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. */
@@ -971,7 +976,7 @@
     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
@@ -979,11 +984,11 @@
     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);
 
@@ -1092,11 +1097,7 @@
          * 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",
@@ -1120,11 +1121,11 @@
     } 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);
@@ -1144,7 +1145,7 @@
     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) {
@@ -1212,11 +1213,11 @@
      * 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);
@@ -1346,12 +1347,7 @@
 {
     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);
     }
Index: libbalsa/mime-stream-shared.c
===================================================================
--- libbalsa/mime-stream-shared.c	(revision 8057)
+++ libbalsa/mime-stream-shared.c	(working copy)
@@ -60,10 +60,10 @@
 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;
@@ -192,8 +192,8 @@
     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);
@@ -201,7 +201,7 @@
 }
 
 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;
@@ -235,7 +235,7 @@
 {
     LibBalsaMimeStreamShared *stream_shared;
     GMimeStreamFs *fstream;
-    off_t start;
+    gint64 start;
 
     stream_shared =
         g_object_new(LIBBALSA_TYPE_MIME_STREAM_SHARED, NULL, NULL);
Index: libbalsa/address-book-gpe.c
===================================================================
--- libbalsa/address-book-gpe.c	(revision 8057)
+++ libbalsa/address-book-gpe.c	(working copy)
@@ -729,7 +729,7 @@
     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)
Index: libbalsa/gmime-stream-gnome-vfs.c
===================================================================
--- libbalsa/gmime-stream-gnome-vfs.c	(revision 8057)
+++ libbalsa/gmime-stream-gnome-vfs.c	(working copy)
@@ -56,12 +56,12 @@
 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 @@
 	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 @@
 	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 @@
     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 @@
         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 @@
     return real;
 }
 
-static off_t
+static gint64
 stream_tell(GMimeStream * stream)
 {
     return stream->position;
@@ -353,14 +353,14 @@
     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 @@
         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 @@
  * 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;
 
Index: libbalsa/send.c
===================================================================
--- libbalsa/send.c	(revision 8057)
+++ libbalsa/send.c	(working copy)
@@ -294,7 +294,7 @@
 
     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);
@@ -339,8 +339,8 @@
         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 :
@@ -361,7 +361,7 @@
 	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));
@@ -371,7 +371,7 @@
 
         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);
@@ -398,14 +398,14 @@
     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);
@@ -469,10 +469,10 @@
         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);
@@ -492,9 +492,9 @@
                 /* 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) {
@@ -597,13 +597,19 @@
 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
@@ -611,26 +617,6 @@
     }
 }
 
-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.
@@ -726,7 +712,7 @@
 	} else {
             gboolean has_open_recipients;
             guint n_bcc_recipients;
-	    InternetAddress *ia;
+	    const InternetAddress *ia;
 
 	    libbalsa_message_change_flags(msg,
                                           LIBBALSA_MESSAGE_FLAG_FLAGGED, 0);
@@ -751,10 +737,10 @@
 
 		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));
@@ -772,10 +758,13 @@
              * 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
@@ -821,12 +810,11 @@
 
 	    /* 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);
@@ -837,24 +825,22 @@
 	    }
 
 	    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)
@@ -1599,27 +1585,30 @@
 		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;
 
-	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);
+    for (i = 0; i < internet_address_list_length(address_list); i++) {
+	InternetAddress *ia =
+            internet_address_list_get_address(address_list, i);
+
+	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;
@@ -1680,6 +1669,7 @@
     GMimeObject *mime_root = NULL;
     GMimeMessage *mime_message;
     LibBalsaMessageBody *body;
+    InternetAddressList *recipients;
     gchar *tmp;
     GList *list;
     GtkWindow * parent;
@@ -1707,8 +1697,8 @@
 		    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");
@@ -1781,13 +1771,13 @@
 		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(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,
@@ -1815,7 +1805,7 @@
 		    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);
@@ -1847,8 +1837,8 @@
 	}
 
 	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;
@@ -1906,26 +1896,22 @@
     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);
 	}
@@ -1934,14 +1920,14 @@
     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;
@@ -1972,7 +1958,7 @@
 	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]);
     }
 
@@ -2066,21 +2052,17 @@
 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;
+    while (INTERNET_ADDRESS_IS_GROUP(ia))
+        ia = internet_address_list_get_address(((InternetAddressGroup *)
+                                                ia)->members, 0);
 
-    if (ia->type == INTERNET_ADDRESS_NONE)
-	return NULL;
-
-    return ia->value.addr;
+    return ((InternetAddressMailbox *) ia)->addr;
 }
 
 static LibBalsaMsgCreateResult
@@ -2201,7 +2183,7 @@
 						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)."));
 
Index: libbalsa/rfc3156.c
===================================================================
--- libbalsa/rfc3156.c	(revision 8057)
+++ libbalsa/rfc3156.c	(working copy)
@@ -129,14 +129,14 @@
     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;
@@ -390,6 +390,7 @@
 	result = 
 	    g_mime_multipart_encrypted_encrypt(mpe, *content,
 					       GMIME_CIPHER_CONTEXT(ctx),
+                                               FALSE, NULL,
 					       recipients, error);
     }
 #ifdef HAVE_SMIME
@@ -506,7 +507,7 @@
 
     /* 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)
@@ -701,7 +702,6 @@
 #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;
@@ -918,7 +918,7 @@
     }
 
     /* 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",
@@ -1751,16 +1751,22 @@
     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;
Index: libbalsa/gmime-stream-gnome-vfs.h
===================================================================
--- libbalsa/gmime-stream-gnome-vfs.h	(revision 8057)
+++ libbalsa/gmime-stream-gnome-vfs.h	(working copy)
@@ -61,8 +61,8 @@
 
 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,
Index: libbalsa/mailbox_maildir.c
===================================================================
--- libbalsa/mailbox_maildir.c	(revision 8057)
+++ libbalsa/mailbox_maildir.c	(working copy)
@@ -911,10 +911,10 @@
 	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);
  
Index: libbalsa/address-view.c
===================================================================
--- libbalsa/address-view.c	(revision 8057)
+++ libbalsa/address-view.c	(working copy)
@@ -227,7 +227,7 @@
     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);
 }
 
@@ -369,30 +369,30 @@
     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);
     }
 }
@@ -407,12 +407,13 @@
 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;
 }
 
 /*
@@ -534,24 +535,6 @@
 }
 
 /*
- *     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
@@ -765,7 +748,7 @@
                 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);
         }
     }
@@ -1190,7 +1173,7 @@
 
     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);
@@ -1213,19 +1196,18 @@
 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;
@@ -1233,7 +1215,8 @@
 
 /*
  *     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,
@@ -1252,7 +1235,7 @@
                          || 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;
@@ -1263,15 +1246,10 @@
                            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);
     }
Index: libbalsa/gmime-part-rfc2440.c
===================================================================
--- libbalsa/gmime-part-rfc2440.c	(revision 8057)
+++ libbalsa/gmime-part-rfc2440.c	(working copy)
@@ -40,14 +40,11 @@
     /* 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 */
@@ -87,7 +84,6 @@
 	}
     }
 
-    g_object_unref(stream);
     return retval;
 }
 
@@ -122,7 +118,6 @@
     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 */
@@ -134,15 +129,14 @@
     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;
@@ -178,15 +172,15 @@
      * 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");
     }
@@ -210,7 +204,7 @@
 g_mime_part_rfc2440_verify(GMimePart * part,
 			   GMimeGpgmeContext * ctx, GError ** err)
 {
-    GMimeStream *stream, *plainstream, *wrapper_stream;
+    GMimeStream *stream, *plainstream;
     GMimeDataWrapper * wrapper;
     GMimeSignatureValidity *valid;
 
@@ -222,12 +216,9 @@
     /* 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();
@@ -235,10 +226,9 @@
     /* 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) {
@@ -263,26 +253,25 @@
  * 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);
@@ -293,19 +282,18 @@
 
     /* 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);
 
@@ -313,12 +301,11 @@
 	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:"
Index: libbalsa/gmime-part-rfc2440.h
===================================================================
--- libbalsa/gmime-part-rfc2440.h	(revision 8057)
+++ libbalsa/gmime-part-rfc2440.h	(working copy)
@@ -56,8 +56,9 @@
 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
 }
Index: libbalsa/address-book-text.c
===================================================================
--- libbalsa/address-book-text.c	(revision 8057)
+++ libbalsa/address-book-text.c	(working copy)
@@ -246,7 +246,7 @@
     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);
@@ -254,16 +254,16 @@
         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 */
@@ -352,28 +352,28 @@
             && 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);
             }
         }
 
@@ -728,7 +728,7 @@
          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);
     }
 
Index: libbalsa/mailbox_imap.c
===================================================================
--- libbalsa/mailbox_imap.c	(revision 8057)
+++ libbalsa/mailbox_imap.c	(working copy)
@@ -1808,39 +1808,32 @@
     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;
 }
 
@@ -1848,13 +1841,13 @@
 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;
@@ -1878,12 +1871,7 @@
 
     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);
     }
 }
@@ -2005,11 +1993,7 @@
     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"));
@@ -2051,11 +2035,10 @@
             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);
 
@@ -2455,7 +2438,7 @@
                 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;
         }
@@ -2464,8 +2447,8 @@
     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)
@@ -2596,11 +2579,11 @@
 	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);
 
@@ -2721,11 +2704,11 @@
 	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);
 
Index: libbalsa/mailbox_local.c
===================================================================
--- libbalsa/mailbox_local.c	(revision 8057)
+++ libbalsa/mailbox_local.c	(working copy)
@@ -1035,8 +1035,13 @@
     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
Index: libbalsa/libbalsa.c
===================================================================
--- libbalsa/libbalsa.c	(revision 8057)
+++ libbalsa/libbalsa.c	(working copy)
@@ -639,7 +639,12 @@
 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; 
 }
 
 
@@ -846,9 +851,9 @@
     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);
 
Index: libbalsa/address.c
===================================================================
--- libbalsa/address.c	(revision 8057)
+++ libbalsa/address.c	(working copy)
@@ -207,14 +207,10 @@
     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 */
@@ -232,7 +228,7 @@
     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 */
@@ -553,9 +549,9 @@
     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;
 }
@@ -566,16 +562,16 @@
     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;
 }
@@ -613,24 +609,30 @@
 
 /* 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)
@@ -642,20 +644,42 @@
 
 /* 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                              */
 /* =================================================================== */
Index: libbalsa/address.h
===================================================================
--- libbalsa/address.h	(revision 8057)
+++ libbalsa/address.h	(working copy)
@@ -95,11 +95,12 @@
 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                              */
Index: libbalsa/gmime-stream-gio.c
===================================================================
--- libbalsa/gmime-stream-gio.c	(revision 8057)
+++ libbalsa/gmime-stream-gio.c	(working copy)
@@ -48,14 +48,14 @@
 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;
@@ -168,7 +168,7 @@
 	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) {
@@ -207,7 +207,7 @@
 	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) {
@@ -300,8 +300,8 @@
     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;
@@ -374,7 +374,7 @@
     return real;
 }
 
-static off_t
+static gint64
 stream_tell (GMimeStream *stream)
 {
     g_return_val_if_fail(stream, -1);
@@ -414,7 +414,7 @@
 }
 
 static GMimeStream *
-stream_substream(GMimeStream *stream, off_t start, off_t end)
+stream_substream(GMimeStream *stream, gint64 start, gint64 end)
 {
     GMimeStreamGio *gios;
 	
@@ -467,7 +467,7 @@
  * 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;
 	
Index: libbalsa/html.c
===================================================================
--- libbalsa/html.c	(revision 8057)
+++ libbalsa/html.c	(working copy)
@@ -790,7 +790,7 @@
     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);
Index: libbalsa/gmime-stream-gio.h
===================================================================
--- libbalsa/gmime-stream-gio.h	(revision 8057)
+++ libbalsa/gmime-stream-gio.h	(working copy)
@@ -61,8 +61,8 @@
 
 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
 
Index: libbalsa/address-book-extern.c
===================================================================
--- libbalsa/address-book-extern.c	(revision 8057)
+++ libbalsa/address-book-extern.c	(working copy)
@@ -369,7 +369,7 @@
         if(!name || !*name)
             name = _("No-Name");
         *res = g_list_prepend(*res,
-                              internet_address_new_name(name, email));
+                              internet_address_mailbox_new(name, email));
     }
 }
 
Index: libbalsa/gmime-application-pkcs7.c
===================================================================
--- libbalsa/gmime-application-pkcs7.c	(revision 8057)
+++ libbalsa/gmime-application-pkcs7.c	(working copy)
@@ -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 @@
 	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 @@
 	
     /* 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_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 @@
     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_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 @@
     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 @@
 	
     /* 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 @@
 	
     /* 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_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 @@
     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);
Index: libbalsa/identity.c
===================================================================
--- libbalsa/identity.c	(revision 8057)
+++ libbalsa/identity.c	(working copy)
@@ -98,7 +98,7 @@
 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;
@@ -135,7 +135,8 @@
 {
     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);
@@ -203,7 +204,8 @@
 {
     g_return_if_fail(ident != NULL);
 
-    internet_address_unref(ident->ia);
+    if (ident->ia)
+	g_object_unref(ident->ia);
     ident->ia = ia;
 }
 
@@ -1469,16 +1471,15 @@
     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-address");
+    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");
-    g_return_val_if_fail(text != NULL, FALSE);
-    ia = internet_address_new();
     internet_address_set_name(ia, text);
+    libbalsa_identity_set_address(id, ia);
     g_free(text);
-    
-    text = ident_dialog_get_text(dlg, "identity-address");
-    internet_address_set_addr(ia, text);
-    g_free(text);
-    libbalsa_identity_set_address(id, ia);
 
     g_free(id->replyto);
     id->replyto         = ident_dialog_get_text(dlg, "identity-replyto");
@@ -1850,10 +1851,10 @@
 
     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);
     
@@ -1964,18 +1965,17 @@
 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));
+    ident->ia = internet_address_mailbox_new (fname, email);
+    g_free(fname);
+    g_free(email);
 
-    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->replyto = libbalsa_conf_get_string("ReplyTo");
     ident->domain = libbalsa_conf_get_string("Domain");
     ident->bcc = libbalsa_conf_get_string("Bcc");
@@ -2025,10 +2025,10 @@
     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);
Index: libbalsa/mailbox.c
===================================================================
--- libbalsa/mailbox.c	(revision 8057)
+++ libbalsa/mailbox.c	(working copy)
@@ -285,29 +285,62 @@
 static gchar*
 get_from_field(LibBalsaMessage *message)
 {
+    InternetAddressList *address_list = NULL;
+    const gchar *name_str = NULL;
     gboolean append_dots = FALSE;
-    const gchar *name_str = NULL;
     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;
 }
 
@@ -2130,7 +2163,7 @@
 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);
 }
@@ -3791,7 +3824,8 @@
  * 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;
@@ -3879,7 +3913,6 @@
             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) {
Index: libbalsa/misc.c
===================================================================
--- libbalsa/misc.c	(revision 8057)
+++ libbalsa/misc.c	(working copy)
@@ -486,7 +486,6 @@
 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),
@@ -494,8 +493,6 @@
     };
 
     g_mime_set_user_charsets(charsets);
-    /* GMime will free the strings. */
-#endif                          /* HAVE_GMIME_2_2_7 */
 
     sanitize_fallback_codeset = codeset;
     return ret;
@@ -1062,23 +1059,25 @@
 			  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
Index: libbalsa/body.c
===================================================================
--- libbalsa/body.c	(revision 8057)
+++ libbalsa/body.c	(working copy)
@@ -114,11 +114,7 @@
     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)"));
@@ -147,7 +143,7 @@
 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", "*"))
@@ -191,7 +187,6 @@
             *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;
@@ -201,13 +196,16 @@
 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;
     }
 
@@ -261,19 +259,18 @@
 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;
@@ -416,7 +413,7 @@
 {
     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;
     }
@@ -432,7 +429,7 @@
 {
     GMimeStream *stream;
     GMimeDataWrapper *wrapper;
-    GMimePartEncodingType encoding;
+    GMimeContentEncoding encoding;
     GMimeFilter *filter;
     gchar *mime_type = NULL;
     const gchar *charset;
@@ -488,22 +485,26 @@
     wrapper = g_mime_part_get_content_object(GMIME_PART(body->mime_part));
     if (!wrapper)               /* part is incomplete. */
         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:
@@ -521,7 +522,7 @@
         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);
@@ -646,9 +647,7 @@
         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);
         }
