[balsa/gmime3: 24/49] GMimeRecipientType has been replaced
- From: Peter Bloomfield <peterb src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [balsa/gmime3: 24/49] GMimeRecipientType has been replaced
- Date: Wed, 26 Feb 2020 16:00:07 +0000 (UTC)
commit 5dfcc30cddb3035f158cc9285107d0f0fdcc85a6
Author: Peter Bloomfield <PeterBloomfield bellsouth net>
Date: Fri Nov 22 13:09:32 2019 -0800
GMimeRecipientType has been replaced
by GMimeAddressType.
libbalsa/message.c | 97 ++++++++++++++++++++++++++----------------------------
1 file changed, 47 insertions(+), 50 deletions(-)
---
diff --git a/libbalsa/message.c b/libbalsa/message.c
index 9f9835d15..c040503b4 100644
--- a/libbalsa/message.c
+++ b/libbalsa/message.c
@@ -965,120 +965,117 @@ libbalsa_message_get_no(LibBalsaMessage* msg)
}
-#endif /* MESSAGE_COPY_CONTENT */
+#endif
/* Populate headers from mime_msg, but only the members that are needed
* all the time. */
+
static InternetAddressList *
-lb_message_recipients(GMimeMessage *message,
- GMimeRecipientType type)
+lb_message_address_list_ref(InternetAddressList * list)
{
- const InternetAddressList *list;
- InternetAddressList *copy = NULL;
-
- if ((list = g_mime_message_get_recipients (message, type))) {
- copy = internet_address_list_new ();
- internet_address_list_append (copy, (InternetAddressList *) list);
+ if (list != NULL && internet_address_list_length(list) > 0) {
+ return g_object_ref(list);
}
- return copy;
+ return NULL;
}
+static InternetAddressList *
+lb_message_recipients(GMimeMessage * message,
+ GMimeAddressType type)
+{
+ return lb_message_address_list_ref(g_mime_message_get_addresses(message, type));
+}
static void
lb_message_headers_basic_from_gmime(LibBalsaMessageHeaders *headers,
- GMimeMessage *mime_msg)
+ GMimeMessage *mime_msg)
{
- g_return_if_fail(headers);
- g_return_if_fail(mime_msg != NULL);
-
- if (headers->from == NULL)
- headers->from = internet_address_list_parse(libbalsa_parser_options(), mime_msg->from);
+ if (headers->from == NULL) {
+ headers->from =
+ lb_message_address_list_ref(g_mime_message_get_from(mime_msg));
+ }
if (headers->date == 0) {
GDateTime *datetime;
datetime = g_mime_message_get_date(mime_msg);
headers->date = g_date_time_to_unix(datetime);
- g_date_time_unref(datetime);
}
- if (headers->to_list == NULL) {
+ if (headers->to_list == NULL)
headers->to_list =
- lb_message_recipients(mime_msg, GMIME_RECIPIENT_TYPE_TO);
- }
+ lb_message_recipients(mime_msg, GMIME_ADDRESS_TYPE_TO);
if (headers->content_type == NULL) {
- /* If we could:
- * headers->content_type =
- * g_mime_content_type_copy
- * (g_mime_object_get_content_type(mime_msg->mime_part));
- */
- 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);
- str = g_mime_content_type_get_mime_type(content_type);
- headers->content_type = g_mime_content_type_parse(libbalsa_parser_options(), str);
- g_free(str);
+ /* If we could:
+ * headers->content_type =
+ * g_mime_content_type_copy
+ * (g_mime_object_get_content_type(mime_msg->mime_part));
+ */
+ GMimeContentType *content_type;
+ gchar *str;
+
+ content_type = g_mime_object_get_content_type(mime_msg->mime_part);
+ str = g_mime_content_type_get_mime_type(content_type);
+ headers->content_type = g_mime_content_type_parse(libbalsa_parser_options(), str);
+ g_free(str);
}
}
-
/* Populate headers from mime_msg, but only the members not handled in
* lb_message_headers_basic_from_gmime. */
static void
lb_message_headers_extra_from_gmime(LibBalsaMessageHeaders *headers,
- GMimeMessage *mime_msg)
+ GMimeMessage *mime_msg)
{
g_return_if_fail(headers);
g_return_if_fail(mime_msg != NULL);
if (headers->reply_to == NULL) {
headers->reply_to =
- internet_address_list_parse(libbalsa_parser_options(), mime_msg->reply_to);
+ lb_message_address_list_ref(g_mime_message_get_reply_to(mime_msg));
}
if (headers->dispnotify_to == NULL) {
- headers->dispnotify_to =
- internet_address_list_parse(libbalsa_parser_options(), g_mime_object_get_header
- (GMIME_OBJECT(mime_msg),
- "Disposition-Notification-To"));
+ const gchar *value =
+ g_mime_object_get_header(GMIME_OBJECT(mime_msg), "Disposition-Notification-To");
+
+ if (value != NULL)
+ headers->dispnotify_to =
+ internet_address_list_parse(libbalsa_parser_options(), value);
}
if (headers->cc_list == NULL) {
headers->cc_list =
- lb_message_recipients(mime_msg, GMIME_RECIPIENT_TYPE_CC);
+ lb_message_recipients(mime_msg, GMIME_ADDRESS_TYPE_CC);
}
if (headers->bcc_list == NULL) {
headers->bcc_list =
- lb_message_recipients(mime_msg, GMIME_RECIPIENT_TYPE_BCC);
+ lb_message_recipients(mime_msg, GMIME_ADDRESS_TYPE_BCC);
}
/* Get fcc from message */
- if (headers->fcc_url == NULL) {
- headers->fcc_url =
- g_strdup(g_mime_object_get_header(GMIME_OBJECT(mime_msg), "X-Balsa-Fcc"));
- }
+ if (!headers->fcc_url)
+ headers->fcc_url =
+ g_strdup(g_mime_object_get_header(GMIME_OBJECT(mime_msg), "X-Balsa-Fcc"));
}
-
/* Populate headers from the info in mime_msg. */
void
libbalsa_message_headers_from_gmime(LibBalsaMessageHeaders *headers,
- GMimeMessage *mime_msg)
+ GMimeMessage *mime_msg)
{
lb_message_headers_basic_from_gmime(headers, mime_msg);
lb_message_headers_extra_from_gmime(headers, mime_msg);
}
-
/* Populate message and message->headers from the info in mime_msg,
* but only the members that are needed all the time. */
void
-libbalsa_message_init_from_gmime(LibBalsaMessage *message,
- GMimeMessage *mime_msg)
+libbalsa_message_init_from_gmime(LibBalsaMessage * message,
+ GMimeMessage *mime_msg)
{
const gchar *header;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]