1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
|
From b110a5990eb9f02b0118401d8960dc1e00a49253 Mon Sep 17 00:00:00 2001
From: Yuri D'Elia <wavexx@thregr.org>
Date: Sun, 30 Jul 2017 16:47:38 +0200
Subject: [PATCH] Support gmime 3.0
---
configure.ac | 6 +-
contrib/gmime-test.c | 63 +++++++++--------
lib/mu-msg-crypto.c | 163 +++++++------------------------------------
lib/mu-msg-file.c | 46 ++++++------
lib/mu-msg-part.c | 26 ++++---
lib/mu-msg.c | 61 +++++++---------
6 files changed, 126 insertions(+), 239 deletions(-)
diff --git a/configure.ac b/configure.ac
index 55c0718b..58531ae4 100644
--- a/configure.ac
+++ b/configure.ac
@@ -139,11 +139,11 @@ AC_SUBST(GLIB_CFLAGS)
AC_SUBST(GLIB_LIBS)
glib_version="`$PKG_CONFIG --modversion glib-2.0`"
-# gmime, some late-2012 version
-PKG_CHECK_MODULES(GMIME,gmime-2.6 >= 2.6.7)
+# gmime, version 3.0 or higher
+PKG_CHECK_MODULES(GMIME,gmime-3.0)
AC_SUBST(GMIME_CFLAGS)
AC_SUBST(GMIME_LIBS)
-gmime_version="`$PKG_CONFIG --modversion gmime-2.6`"
+gmime_version="`$PKG_CONFIG --modversion gmime-3.0`"
# xapian checking - we need 1.2.x at least
diff --git a/contrib/gmime-test.c b/contrib/gmime-test.c
index ce8c6d06..5c59ed2b 100644
--- a/contrib/gmime-test.c
+++ b/contrib/gmime-test.c
@@ -31,13 +31,13 @@
#include <locale.h>
static gchar*
-get_recip (GMimeMessage *msg, GMimeRecipientType rtype)
+get_recip (GMimeMessage *msg, GMimeAddressType atype)
{
char *recep;
InternetAddressList *receps;
- receps = g_mime_message_get_recipients (msg, rtype);
- recep = (char*)internet_address_list_to_string (receps, FALSE);
+ receps = g_mime_message_get_addresses (msg, atype);
+ recep = (char*)internet_address_list_to_string (receps, NULL, FALSE);
if (!recep || !*recep) {
g_free (recep);
@@ -51,20 +51,19 @@ static gchar*
get_refs_str (GMimeMessage *msg)
{
const gchar *str;
- const GMimeReferences *cur;
GMimeReferences *mime_refs;
+ int i, refs_len;
gchar *rv;
str = g_mime_object_get_header (GMIME_OBJECT(msg), "References");
if (!str)
return NULL;
- mime_refs = g_mime_references_decode (str);
- for (rv = NULL, cur = mime_refs; cur;
- cur = g_mime_references_get_next(cur)) {
-
+ mime_refs = g_mime_references_parse (NULL, str);
+ refs_len = g_mime_references_length (mime_refs);
+ for (rv = NULL, i = 0; i < refs_len; ++i) {
const char* msgid;
- msgid = g_mime_references_get_message_id (cur);
+ msgid = g_mime_references_get_message_id (mime_refs, i);
rv = g_strdup_printf ("%s%s%s",
rv ? rv : "",
rv ? "," : "",
@@ -78,21 +77,21 @@ get_refs_str (GMimeMessage *msg)
static void
print_date (GMimeMessage *msg)
{
- time_t t;
- int tz;
- char buf[64];
- size_t len;
- struct tm *t_m;
-
+ GDateTime *dt;
+ gchar *buf;
- g_mime_message_get_date (msg, &t, &tz);
- t_m = localtime (&t);
+ dt = g_mime_message_get_date (msg);
+ if (!dt)
+ return;
- len = strftime (buf, sizeof(buf) - 1, "%c", t_m);
+ dt = g_date_time_to_local (dt);
+ buf = g_date_time_format (dt, "%c");
+ g_date_time_unref (dt);
- if (len > 0)
- g_print ("Date : %s (%s%04d)\n",
- buf,tz < 0 ? "-" : "+", tz);
+ if (buf) {
+ g_print ("Date : %s\n", buf);
+ g_free (buf);
+ }
}
@@ -111,7 +110,7 @@ print_body (GMimeMessage *msg)
if (!GMIME_IS_PART(body))
return;
- wrapper = g_mime_part_get_content_object (GMIME_PART(body));
+ wrapper = g_mime_part_get_content (GMIME_PART(body));
if (!GMIME_IS_DATA_WRAPPER(wrapper))
return;
@@ -142,17 +141,19 @@ test_message (GMimeMessage *msg)
gchar *val;
const gchar *str;
- g_print ("From : %s\n", g_mime_message_get_sender (msg));
+ val = get_recip (msg, GMIME_ADDRESS_TYPE_FROM);
+ g_print ("From : %s\n", val ? val : "<none>" );
+ g_free (val);
- val = get_recip (msg, GMIME_RECIPIENT_TYPE_TO);
+ val = get_recip (msg, GMIME_ADDRESS_TYPE_TO);
g_print ("To : %s\n", val ? val : "<none>" );
g_free (val);
- val = get_recip (msg, GMIME_RECIPIENT_TYPE_CC);
+ val = get_recip (msg, GMIME_ADDRESS_TYPE_CC);
g_print ("Cc : %s\n", val ? val : "<none>" );
g_free (val);
- val = get_recip (msg, GMIME_RECIPIENT_TYPE_BCC);
+ val = get_recip (msg, GMIME_ADDRESS_TYPE_BCC);
g_print ("Bcc : %s\n", val ? val : "<none>" );
g_free (val);
@@ -195,7 +196,7 @@ test_stream (GMimeStream *stream)
goto leave;
}
- msg = g_mime_parser_construct_message (parser);
+ msg = g_mime_parser_construct_message (parser, NULL);
if (!msg) {
g_warning ("failed to construct message");
rv = FALSE;
@@ -207,8 +208,6 @@ test_stream (GMimeStream *stream)
leave:
if (parser)
g_object_unref (parser);
- else
- g_object_unref (stream);
if (msg)
g_object_unref (msg);
@@ -242,7 +241,9 @@ test_file (const char *path)
goto leave;
}
- rv = test_stream (stream); /* test-stream will unref it */
+ rv = test_stream (stream);
+ g_object_unref (stream);
+ return rv;
leave:
if (file)
@@ -264,7 +265,7 @@ main (int argc, char *argv[])
setlocale (LC_ALL, "");
- g_mime_init(GMIME_ENABLE_RFC2047_WORKAROUNDS);
+ g_mime_init();
rv = test_file (argv[1]);
diff --git a/lib/mu-msg-crypto.c b/lib/mu-msg-crypto.c
index 4c9b132c..ba0d5e7c 100644
--- a/lib/mu-msg-crypto.c
+++ b/lib/mu-msg-crypto.c
@@ -99,83 +99,6 @@ dummy_password_func (const char *user_id, const char *prompt_ctx,
}
-static char*
-get_gpg (GError **err)
-{
- char *path;
- const char *envpath;
-
- if ((envpath = g_getenv ("MU_GPG_PATH"))) {
- if (access (envpath, X_OK) != 0) {
- mu_util_g_set_error (
- err, MU_ERROR,
- "'%s': not a valid gpg path: %s",
- envpath, strerror (errno));
- return NULL;
- }
- return g_strdup (envpath);
- }
-
- if (!(path = g_find_program_in_path ("gpg2")) &&
- !(path = g_find_program_in_path ("gpg"))) {
- mu_util_g_set_error (err, MU_ERROR, "gpg/gpg2 not found");
- return NULL;
- } else
- return path;
-}
-
-
-static GMimeCryptoContext*
-get_gpg_crypto_context (MuMsgOptions opts, GError **err)
-{
- GMimeCryptoContext *cctx;
- char *gpg;
-
- cctx = NULL;
- if (!(gpg = get_gpg (err)))
- return NULL;
-
- cctx = g_mime_gpg_context_new (
- (GMimePasswordRequestFunc)password_requester, gpg);
- g_free (gpg);
-
- if (!cctx) {
- mu_util_g_set_error (err, MU_ERROR,
- "failed to get GPG crypto context");
- return NULL;
- }
-
- /* always try to use the agent */
- g_mime_gpg_context_set_use_agent (GMIME_GPG_CONTEXT(cctx), TRUE);
- g_mime_gpg_context_set_auto_key_retrieve
- (GMIME_GPG_CONTEXT(cctx),
- opts & MU_MSG_OPTION_AUTO_RETRIEVE ? TRUE:FALSE);
-
- return cctx;
-}
-
-
-static GMimeCryptoContext*
-get_crypto_context (MuMsgOptions opts, MuMsgPartPasswordFunc password_func,
- gpointer user_data, GError **err)
-{
- CallbackData *cbdata;
- GMimeCryptoContext *cctx;
-
- cctx = get_gpg_crypto_context (opts, err);
- if (!cctx)
- return NULL;
-
- /* use gobject to pass data to the callback func */
- cbdata = g_new0 (CallbackData, 1);
- cbdata->pw_func = password_func ? password_func : dummy_password_func;
- cbdata->user_data = user_data;
-
- g_object_set_data_full (G_OBJECT(cctx), CALLBACK_DATA,
- cbdata, (GDestroyNotify)g_free);
- return cctx;
-}
-
static const char*
get_pubkey_algo_name (GMimePubKeyAlgo algo)
{
@@ -250,12 +173,12 @@ get_cert_details (GMimeCertificate *cert)
(g_mime_certificate_get_pubkey_algo (cert));
switch (g_mime_certificate_get_trust (cert)) {
- case GMIME_CERTIFICATE_TRUST_NONE: trust = "none"; break;
- case GMIME_CERTIFICATE_TRUST_NEVER: trust = "never"; break;
- case GMIME_CERTIFICATE_TRUST_UNDEFINED: trust = "undefined"; break;
- case GMIME_CERTIFICATE_TRUST_MARGINAL: trust = "marginal"; break;
- case GMIME_CERTIFICATE_TRUST_FULLY: trust = "full"; break;
- case GMIME_CERTIFICATE_TRUST_ULTIMATE: trust = "ultimate"; break;
+ case GMIME_TRUST_UNKNOWN: trust = "unknown"; break;
+ case GMIME_TRUST_UNDEFINED: trust = "undefined"; break;
+ case GMIME_TRUST_NEVER: trust = "never"; break;
+ case GMIME_TRUST_MARGINAL: trust = "marginal"; break;
+ case GMIME_TRUST_FULL: trust = "full"; break;
+ case GMIME_TRUST_ULTIMATE: trust = "ultimate"; break;
default:
g_return_val_if_reached (NULL);
}
@@ -277,21 +200,17 @@ get_verdict_report (GMimeSignature *msig)
time_t t;
const char *created, *expires, *verdict;
char *certdata, *report;
-
- switch (g_mime_signature_get_status (msig)) {
- case GMIME_SIGNATURE_STATUS_GOOD:
- verdict = "good";
- break;
- case GMIME_SIGNATURE_STATUS_ERROR:
- verdict = "error";
- break;
- case GMIME_SIGNATURE_STATUS_BAD:
- verdict = "bad";
- break;
- default:
- g_return_val_if_reached (NULL);
- return NULL;
- }
+ GMimeSignatureStatus sigstat;
+
+ sigstat = g_mime_signature_get_status (msig);
+ if (sigstat & GMIME_SIGNATURE_STATUS_ERROR_MASK)
+ verdict = "error";
+ else if (sigstat & GMIME_SIGNATURE_STATUS_RED)
+ verdict = "bad";
+ else if (sigstat & GMIME_SIGNATURE_STATUS_GREEN)
+ verdict = "good";
+ else
+ g_return_val_if_reached (NULL);
t = g_mime_signature_get_created (msig);
created = (t == 0 || t == (time_t)-1) ? "?" : mu_date_str_s ("%x", t);
@@ -353,17 +272,13 @@ get_status_report (GMimeSignatureList *sigs)
msig = g_mime_signature_list_get_signature (sigs, i);
sigstat = g_mime_signature_get_status (msig);
- switch (sigstat) {
- case GMIME_SIGNATURE_STATUS_GOOD:
- break;
- case GMIME_SIGNATURE_STATUS_ERROR:
- status = MU_MSG_PART_SIG_STATUS_ERROR;
- break;
- case GMIME_SIGNATURE_STATUS_BAD:
- status = MU_MSG_PART_SIG_STATUS_BAD;
- break;
- default: g_return_val_if_reached (NULL);
- }
+ /* downgrade our expectations */
+ if ((sigstat & GMIME_SIGNATURE_STATUS_ERROR_MASK) &&
+ status != MU_MSG_PART_SIG_STATUS_ERROR)
+ status = MU_MSG_PART_SIG_STATUS_ERROR;
+ else if ((sigstat & GMIME_SIGNATURE_STATUS_RED) &&
+ status == MU_MSG_PART_SIG_STATUS_GOOD)
+ status = MU_MSG_PART_SIG_STATUS_BAD;
rep = get_verdict_report (msig);
report = g_strdup_printf ("%s%s%d: %s",
@@ -419,20 +334,11 @@ mu_msg_crypto_verify_part (GMimeMultipartSigned *sig, MuMsgOptions opts,
{
/* the signature status */
MuMsgPartSigStatusReport *report;
- GMimeCryptoContext *ctx;
GMimeSignatureList *sigs;
g_return_if_fail (GMIME_IS_MULTIPART_SIGNED(sig));
- ctx = get_crypto_context (opts, NULL, NULL, err);
- if (!ctx) {
- mu_util_g_set_error (err, MU_ERROR_CRYPTO,
- "failed to get crypto context");
- return;
- }
-
- sigs = g_mime_multipart_signed_verify (sig, ctx, err);
- g_object_unref (ctx);
+ sigs = g_mime_multipart_signed_verify (sig, GMIME_VERIFY_NONE, err);
if (!sigs) {
if (err && !*err)
mu_util_g_set_error (err, MU_ERROR_CRYPTO,
@@ -482,29 +388,12 @@ mu_msg_crypto_decrypt_part (GMimeMultipartEncrypted *enc, MuMsgOptions opts,
GError **err)
{
GMimeObject *dec;
- GMimeCryptoContext *ctx;
GMimeDecryptResult *res;
g_return_val_if_fail (GMIME_IS_MULTIPART_ENCRYPTED(enc), NULL);
- ctx = get_crypto_context (opts, func, user_data, err);
- if (!ctx) {
- mu_util_g_set_error (err, MU_ERROR_CRYPTO,
- "failed to get crypto context");
- return NULL;
- }
-
- /* at the time of writing, there is a small leak in
- * g_mime_multipart_encrypted_decrypt; I've notified its
- * author and it has been fixed 2012-09-12:
- * http://git.gnome.org/browse/gmime/commit/
- * ?id=1bacd43b50d91bd03a4ae1dc9f46f5783dee61b1
- * (or GMime > 2.6.10)
- * */
res = NULL;
- dec = g_mime_multipart_encrypted_decrypt (enc, ctx, &res, err);
- g_object_unref (ctx);
-
+ dec = g_mime_multipart_encrypted_decrypt (enc, GMIME_DECRYPT_NONE, NULL, &res, err);
check_decrypt_result(enc, res, err);
if (!dec) {
diff --git a/lib/mu-msg-file.c b/lib/mu-msg-file.c
index e727ab12..b143b8e7 100644
--- a/lib/mu-msg-file.c
+++ b/lib/mu-msg-file.c
@@ -159,7 +159,7 @@ init_mime_msg (MuMsgFile *self, const char* path, GError **err)
return FALSE;
}
- self->_mime_msg = g_mime_parser_construct_message (parser);
+ self->_mime_msg = g_mime_parser_construct_message (parser, NULL);
g_object_unref (parser);
if (!self->_mime_msg) {
g_set_error (err, MU_ERROR_DOMAIN, MU_ERROR_GMIME,
@@ -171,15 +171,15 @@ init_mime_msg (MuMsgFile *self, const char* path, GError **err)
}
static char*
-get_recipient (MuMsgFile *self, GMimeRecipientType rtype)
+get_recipient (MuMsgFile *self, GMimeAddressType atype)
{
char *recip;
InternetAddressList *recips;
- recips = g_mime_message_get_recipients (self->_mime_msg, rtype);
+ recips = g_mime_message_get_addresses (self->_mime_msg, atype);
/* FALSE --> don't encode */
- recip = (char*)internet_address_list_to_string (recips, FALSE);
+ recip = (char*)internet_address_list_to_string (recips, NULL, FALSE);
if (recip && !g_utf8_validate (recip, -1, NULL)) {
g_debug ("invalid recipient in %s\n", self->_path);
@@ -488,7 +488,7 @@ mu_msg_mime_part_to_string (GMimePart *part, gboolean *err)
*err = TRUE; /* guilty until proven innocent */
g_return_val_if_fail (GMIME_IS_PART(part), NULL);
- wrapper = g_mime_part_get_content_object (part);
+ wrapper = g_mime_part_get_content (part);
if (!wrapper) {
/* this happens with invalid mails */
g_debug ("failed to create data wrapper");
@@ -545,20 +545,21 @@ get_references (MuMsgFile *self)
for (msgids = NULL, u = 0; headers[u]; ++u) {
char *str;
- const GMimeReferences *cur;
GMimeReferences *mime_refs;
+ int i, refs_len;
str = mu_msg_file_get_header (self, headers[u]);
if (!str)
continue;
- mime_refs = g_mime_references_decode (str);
+ mime_refs = g_mime_references_parse (NULL, str);
g_free (str);
- for (cur = mime_refs; cur;
- cur = g_mime_references_get_next(cur)) {
+ refs_len = g_mime_references_length (mime_refs);
+ for (i = 0; i < refs_len; ++i) {
const char* msgid;
- msgid = g_mime_references_get_message_id (cur);
+ msgid = g_mime_references_get_message_id (mime_refs, i);
+
/* don't include duplicates */
if (msgid && !contains (msgids, msgid))
/* explicitly ensure it's utf8-safe,
@@ -638,13 +639,14 @@ cleanup_maybe (const char *str, gboolean *do_free)
-G_GNUC_CONST static GMimeRecipientType
-recipient_type (MuMsgFieldId mfid)
+G_GNUC_CONST static GMimeAddressType
+address_type (MuMsgFieldId mfid)
{
switch (mfid) {
- case MU_MSG_FIELD_ID_BCC: return GMIME_RECIPIENT_TYPE_BCC;
- case MU_MSG_FIELD_ID_CC : return GMIME_RECIPIENT_TYPE_CC;
- case MU_MSG_FIELD_ID_TO : return GMIME_RECIPIENT_TYPE_TO;
+ case MU_MSG_FIELD_ID_BCC : return GMIME_ADDRESS_TYPE_BCC;
+ case MU_MSG_FIELD_ID_CC : return GMIME_ADDRESS_TYPE_CC;
+ case MU_MSG_FIELD_ID_TO : return GMIME_ADDRESS_TYPE_TO;
+ case MU_MSG_FIELD_ID_FROM: return GMIME_ADDRESS_TYPE_FROM;
default: g_return_val_if_reached (-1);
}
}
@@ -679,12 +681,10 @@ mu_msg_file_get_str_field (MuMsgFile *self, MuMsgFieldId mfid,
case MU_MSG_FIELD_ID_BCC:
case MU_MSG_FIELD_ID_CC:
- case MU_MSG_FIELD_ID_TO: *do_free = TRUE;
- return get_recipient (self, recipient_type(mfid));
-
case MU_MSG_FIELD_ID_FROM:
- return (char*)cleanup_maybe
- (g_mime_message_get_sender (self->_mime_msg), do_free);
+ case MU_MSG_FIELD_ID_TO:
+ *do_free = TRUE;
+ return get_recipient (self, address_type(mfid));
case MU_MSG_FIELD_ID_PATH: return self->_path;
@@ -736,9 +736,9 @@ mu_msg_file_get_num_field (MuMsgFile *self, const MuMsgFieldId mfid)
switch (mfid) {
case MU_MSG_FIELD_ID_DATE: {
- time_t t;
- g_mime_message_get_date (self->_mime_msg, &t, NULL);
- return (time_t)t;
+ GDateTime *dt;
+ dt = g_mime_message_get_date (self->_mime_msg);
+ return dt ? g_date_time_to_unix (dt) : 0;
}
case MU_MSG_FIELD_ID_FLAGS:
diff --git a/lib/mu-msg-part.c b/lib/mu-msg-part.c
index a1037fe7..67045016 100644
--- a/lib/mu-msg-part.c
+++ b/lib/mu-msg-part.c
@@ -113,18 +113,22 @@ accumulate_text_message (MuMsg *msg, MuMsgPart *part, GString **gstrp)
/* put sender, recipients and subject in the string, so they
* can be indexed as well */
mimemsg = GMIME_MESSAGE (part->data);
- str = g_mime_message_get_sender (mimemsg);
+ addresses = g_mime_message_get_addresses (mimemsg, GMIME_ADDRESS_TYPE_FROM);
+ adrs = internet_address_list_to_string (addresses, NULL, FALSE);
g_string_append_printf
- (*gstrp, "%s%s", str ? str : "", str ? "\n" : "");
+ (*gstrp, "%s%s", adrs ? adrs : "", adrs ? "\n" : "");
+ g_free (adrs);
+
str = g_mime_message_get_subject (mimemsg);
g_string_append_printf
(*gstrp, "%s%s", str ? str : "", str ? "\n" : "");
- addresses = g_mime_message_get_all_recipients (mimemsg);
- adrs = internet_address_list_to_string (addresses, FALSE);
- g_object_unref (addresses);
- g_string_append_printf
- (*gstrp, "%s%s", adrs ? adrs : "", adrs ? "\n" : "");
- g_free (adrs);
+
+ addresses = g_mime_message_get_all_recipients (mimemsg);
+ adrs = internet_address_list_to_string (addresses, NULL, FALSE);
+ g_object_unref (addresses);
+ g_string_append_printf
+ (*gstrp, "%s%s", adrs ? adrs : "", adrs ? "\n" : "");
+ g_free (adrs);
}
static void
@@ -225,7 +229,7 @@ get_part_size (GMimePart *part)
GMimeDataWrapper *wrapper;
GMimeStream *stream;
- wrapper = g_mime_part_get_content_object (part);
+ wrapper = g_mime_part_get_content (part);
if (!GMIME_IS_DATA_WRAPPER(wrapper))
return -1;
@@ -665,7 +669,7 @@ write_part_to_fd (GMimePart *part, int fd, GError **err)
}
g_mime_stream_fs_set_owner (GMIME_STREAM_FS(stream), FALSE);
- wrapper = g_mime_part_get_content_object (part);
+ wrapper = g_mime_part_get_content (part);
if (!GMIME_IS_DATA_WRAPPER(wrapper)) {
g_set_error (err, MU_ERROR_DOMAIN, MU_ERROR_GMIME,
"failed to create wrapper");
@@ -694,7 +698,7 @@ static gboolean
write_object_to_fd (GMimeObject *obj, int fd, GError **err)
{
gchar *str;
- str = g_mime_object_to_string (obj);
+ str = g_mime_object_to_string (obj, NULL);
if (!str) {
g_set_error (err, MU_ERROR_DOMAIN, MU_ERROR_GMIME,
diff --git a/lib/mu-msg.c b/lib/mu-msg.c
index 8a9d03f3..93d4d241 100644
--- a/lib/mu-msg.c
+++ b/lib/mu-msg.c
@@ -48,12 +48,7 @@ gmime_init (void)
{
g_return_if_fail (!_gmime_initialized);
-#ifdef GMIME_ENABLE_RFC2047_WORKAROUNDS
- g_mime_init(GMIME_ENABLE_RFC2047_WORKAROUNDS);
-#else
- g_mime_init(0);
-#endif /* GMIME_ENABLE_RFC2047_WORKAROUNDS */
-
+ g_mime_init();
_gmime_initialized = TRUE;
}
@@ -385,7 +380,7 @@ mu_msg_get_mailing_list (MuMsg *self)
if (!ml)
return NULL;
- decml = g_mime_utils_header_decode_text (ml);
+ decml = g_mime_utils_header_decode_text (NULL, ml);
if (!decml)
return NULL;
@@ -566,21 +561,22 @@ get_content_type_parameters (MuMsg *self, MuMsgOptions opts, gboolean want_html)
if (cdata.ctype) {
- GSList *paramlist;
+ GSList *gslist;
+ GMimeParamList *paramlist;
const GMimeParam *param;
+ int i, len;
- paramlist = NULL;
- param = g_mime_content_type_get_params (cdata.ctype);
-
- for (; param; param = param->next) {
- paramlist = g_slist_prepend (paramlist,
- g_strdup (param->name));
+ gslist = NULL;
+ paramlist = g_mime_content_type_get_parameters (cdata.ctype);
+ len = g_mime_param_list_length (paramlist);
- paramlist = g_slist_prepend (paramlist,
- g_strdup (param->value));
+ for (i = 0; i < len; ++i) {
+ param = g_mime_param_list_get_parameter_at (paramlist, i);
+ gslist = g_slist_prepend (gslist, g_strdup (param->name));
+ gslist = g_slist_prepend (gslist, g_strdup (param->value));
}
- return free_later_lst(self, g_slist_reverse (paramlist));
+ return free_later_lst (self, g_slist_reverse (gslist));
}
return NULL;
}
@@ -660,6 +656,10 @@ fill_contact (MuMsgContact *self, InternetAddress *addr,
return FALSE;
self->name = internet_address_get_name (addr);
+ if (mu_str_is_empty (self->name)) {
+ self->name = NULL;
+ }
+
self->type = ctype;
/* we only support internet mailbox addresses; if we don't
@@ -716,7 +716,7 @@ addresses_foreach (const char* addrs, MuMsgContactType ctype,
if (!addrs)
return;
- addrlist = internet_address_list_parse_string (addrs);
+ addrlist = internet_address_list_parse (NULL, addrs);
if (addrlist) {
address_list_foreach (addrlist, ctype, func, user_data);
g_object_unref (addrlist);
@@ -730,27 +730,20 @@ msg_contact_foreach_file (MuMsg *msg, MuMsgContactForeachFunc func,
{
int i;
struct {
- GMimeRecipientType _gmime_type;
- MuMsgContactType _type;
+ GMimeAddressType _gmime_type;
+ MuMsgContactType _type;
} ctypes[] = {
- {GMIME_RECIPIENT_TYPE_TO, MU_MSG_CONTACT_TYPE_TO},
- {GMIME_RECIPIENT_TYPE_CC, MU_MSG_CONTACT_TYPE_CC},
- {GMIME_RECIPIENT_TYPE_BCC, MU_MSG_CONTACT_TYPE_BCC},
+ {GMIME_ADDRESS_TYPE_FROM, MU_MSG_CONTACT_TYPE_FROM},
+ {GMIME_ADDRESS_TYPE_REPLY_TO, MU_MSG_CONTACT_TYPE_REPLY_TO},
+ {GMIME_ADDRESS_TYPE_TO, MU_MSG_CONTACT_TYPE_TO},
+ {GMIME_ADDRESS_TYPE_CC, MU_MSG_CONTACT_TYPE_CC},
+ {GMIME_ADDRESS_TYPE_BCC, MU_MSG_CONTACT_TYPE_BCC},
};
- /* sender */
- addresses_foreach (g_mime_message_get_sender (msg->_file->_mime_msg),
- MU_MSG_CONTACT_TYPE_FROM, func, user_data);
-
- /* reply_to */
- addresses_foreach (g_mime_message_get_reply_to (msg->_file->_mime_msg),
- MU_MSG_CONTACT_TYPE_REPLY_TO, func, user_data);
-
- /* get to, cc, bcc */
for (i = 0; i != G_N_ELEMENTS(ctypes); ++i) {
InternetAddressList *addrlist;
- addrlist = g_mime_message_get_recipients (msg->_file->_mime_msg,
- ctypes[i]._gmime_type);
+ addrlist = g_mime_message_get_addresses (msg->_file->_mime_msg,
+ ctypes[i]._gmime_type);
address_list_foreach (addrlist, ctypes[i]._type, func, user_data);
}
}
--
2.17.0
|