summaryrefslogtreecommitdiff
path: root/community/balsa/gmime26.patch
blob: fe4e6a9fa5bc16dd501e509dd1f2ea47db3351e9 (plain)
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
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
From 393d0077495cb750ee47bab6ec44a60906a95179 Mon Sep 17 00:00:00 2001
From: Peter Bloomfield <PeterBloomfield@bellsouth.net>
Date: Mon, 28 Nov 2011 03:00:55 +0000
Subject: Build with GMime 2.6.0

	* configure.in: check for GMime >= 2.5.7
	* libbalsa/gmime-application-pkcs7.c
	(g_mime_application_pkcs7_sign), (g_mime_application_pkcs7_verify),
	(g_mime_application_pkcs7_encrypt),
	(g_mime_application_pkcs7_decrypt): build with GMime >= 2.5.7.
	* libbalsa/gmime-application-pkcs7.h: ditto.
	* libbalsa/gmime-gpgme-context.c (g_mime_gpgme_context_get_type),
	(g_mime_gpgme_context_class_init), (g_mime_gpgme_context_finalize),
	(g_mime_gpgme_digest_id): ditto.
	* libbalsa/gmime-gpgme-context.h: ditto.
	* libbalsa/gmime-part-rfc2440.c (g_mime_part_rfc2440_sign_encrypt),
	(g_mime_part_rfc2440_verify), (g_mime_part_rfc2440_decrypt):
	ditto.
	* libbalsa/gmime-part-rfc2440.h: ditto.
	* libbalsa/rfc3156.c (password_request_func),
	(libbalsa_sign_mime_object), (libbalsa_encrypt_mime_object),
	(libbalsa_body_check_signature), (libbalsa_body_decrypt): ditto.
---
diff --git a/ChangeLog b/ChangeLog
index bd95e68..d5c62f5 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,25 @@
+2011-11-27  Peter Bloomfield
+
+	Build with GMime 2.6.0
+
+	* configure.in: check for GMime >= 2.5.7
+	* libbalsa/gmime-application-pkcs7.c
+	(g_mime_application_pkcs7_sign), (g_mime_application_pkcs7_verify),
+	(g_mime_application_pkcs7_encrypt),
+	(g_mime_application_pkcs7_decrypt): build with GMime >= 2.5.7.
+	* libbalsa/gmime-application-pkcs7.h: ditto.
+	* libbalsa/gmime-gpgme-context.c (g_mime_gpgme_context_get_type),
+	(g_mime_gpgme_context_class_init), (g_mime_gpgme_context_finalize),
+	(g_mime_gpgme_digest_id): ditto.
+	* libbalsa/gmime-gpgme-context.h: ditto.
+	* libbalsa/gmime-part-rfc2440.c (g_mime_part_rfc2440_sign_encrypt),
+	(g_mime_part_rfc2440_verify), (g_mime_part_rfc2440_decrypt):
+	ditto.
+	* libbalsa/gmime-part-rfc2440.h: ditto.
+	* libbalsa/rfc3156.c (password_request_func),
+	(libbalsa_sign_mime_object), (libbalsa_encrypt_mime_object),
+	(libbalsa_body_check_signature), (libbalsa_body_decrypt): ditto.
+
 2011-11-22  Pawel Salek
 
 	* NEWS, configure.in: release balsa-2.4.11
diff --git a/configure.in b/configure.in
index 4a8320e..64d99f3 100644
--- a/configure.in
+++ b/configure.in
@@ -307,7 +307,12 @@ fi
 case "$with_gmime" in
     2.4) ;;
     2.6) AC_DEFINE([HAVE_GMIME_2_6], [1],
-                   [Defined to build with GMime version 2.5 or 2.6]) ;;
+                   [Defined to build with GMime version 2.5 or 2.6])
+         if $PKG_CONFIG --atleast-version=2.5.7 gmime-2.6; then
+             AC_DEFINE([HAVE_GMIME_2_5_7], [1],
+                       [Defined when GMime version is at least 2.5.7])
+         fi
+         ;;
     *) AC_MSG_ERROR([unknown GMime version $with_gmime]) ;;
 esac
 
diff --git a/libbalsa/gmime-application-pkcs7.c b/libbalsa/gmime-application-pkcs7.c
index 12f4f8f..63b8087 100644
--- a/libbalsa/gmime-application-pkcs7.c
+++ b/libbalsa/gmime-application-pkcs7.c
@@ -96,8 +96,14 @@ g_mime_application_pkcs7_sign (GMimePart *pkcs7, GMimeObject *content,
     GMimeFilter *crlf_filter, *from_filter;
 	
     g_return_val_if_fail (GMIME_IS_PART (pkcs7), -1);
+#ifndef HAVE_GMIME_2_5_7
     g_return_val_if_fail (GMIME_IS_CIPHER_CONTEXT (ctx), -1);
     g_return_val_if_fail (ctx->sign_protocol != NULL, -1);
+#else /* HAVE_GMIME_2_5_7 */
+    g_return_val_if_fail (GMIME_IS_CRYPTO_CONTEXT (ctx), -1);
+    g_return_val_if_fail(g_mime_crypto_context_get_signature_protocol(ctx)
+                         != NULL, -1);
+#endif /* HAVE_GMIME_2_5_7 */
     g_return_val_if_fail (GMIME_IS_OBJECT (content), -1);
 	
     /* Prepare all the parts for signing... */
@@ -127,7 +133,14 @@ g_mime_application_pkcs7_sign (GMimePart *pkcs7, GMimeObject *content,
     sig_data_stream = g_mime_stream_mem_new ();
 	
     /* get the signed content */
-    if (g_mime_cipher_context_sign (ctx, userid, GMIME_CIPHER_HASH_DEFAULT, filtered_stream, sig_data_stream, err) == -1) {
+#ifndef HAVE_GMIME_2_5_7
+    if (g_mime_cipher_context_sign (ctx, userid, GMIME_CIPHER_HASH_DEFAULT, filtered_stream, sig_data_stream, err) == -1)
+#else /* HAVE_GMIME_2_5_7 */
+    if (g_mime_crypto_context_sign
+        (ctx, userid, GMIME_CIPHER_HASH_DEFAULT, filtered_stream,
+         sig_data_stream, err) == -1)
+#endif /* HAVE_GMIME_2_5_7 */
+    {
 	g_object_unref (filtered_stream);
 	g_object_unref (sig_data_stream);
 	g_object_unref (stream);
@@ -168,9 +181,15 @@ g_mime_application_pkcs7_sign (GMimePart *pkcs7, GMimeObject *content,
  * decrypting it again. In this case, validity is undefined.
  */
 GMimeObject *
+#ifndef HAVE_GMIME_2_5_7
 g_mime_application_pkcs7_verify(GMimePart * pkcs7,
 				GMimeSignatureValidity ** validity,
 				GMimeCipherContext * ctx, GError ** err)
+#else /* HAVE_GMIME_2_5_7 */
+g_mime_application_pkcs7_verify(GMimePart * pkcs7,
+                                GMimeSignatureList ** list,
+                                GMimeCryptoContext * ctx, GError ** err)
+#endif /* HAVE_GMIME_2_5_7 */
 {
     GMimeObject *decrypted;
     GMimeDataWrapper *wrapper;
@@ -181,8 +200,14 @@ g_mime_application_pkcs7_verify(GMimePart * pkcs7,
     const char *smime_type;
 
     g_return_val_if_fail(GMIME_IS_PART(pkcs7), NULL);
+#ifndef HAVE_GMIME_2_5_7
     g_return_val_if_fail(GMIME_IS_CIPHER_CONTEXT(ctx), NULL);
     g_return_val_if_fail(ctx->encrypt_protocol != NULL, NULL);
+#else /* HAVE_GMIME_2_5_7 */
+    g_return_val_if_fail(GMIME_IS_CRYPTO_CONTEXT(ctx), NULL);
+    g_return_val_if_fail(g_mime_crypto_context_get_encryption_protocol(ctx)
+                         != NULL, NULL);
+#endif /* HAVE_GMIME_2_5_7 */
 
     /* some sanity checks */
     smime_type =
@@ -208,9 +233,16 @@ g_mime_application_pkcs7_verify(GMimePart * pkcs7,
     g_object_unref(crlf_filter);
 
     /* get the cleartext */
+#ifndef HAVE_GMIME_2_5_7
     *validity = g_mime_cipher_context_verify(ctx, GMIME_CIPHER_HASH_DEFAULT,
 				     ciphertext, filtered_stream, err);
-    if (!*validity) {
+    if (!*validity)
+#else /* HAVE_GMIME_2_5_7 */
+    *list = g_mime_crypto_context_verify(ctx, GMIME_CIPHER_ALGO_DEFAULT,
+                                         ciphertext, filtered_stream, err);
+    if (!*list)
+#endif /* HAVE_GMIME_2_5_7 */
+    {
 	g_object_unref(filtered_stream);
 	g_object_unref(ciphertext);
 	g_object_unref(stream);
@@ -248,7 +280,12 @@ g_mime_application_pkcs7_verify(GMimePart * pkcs7,
  */
 int
 g_mime_application_pkcs7_encrypt (GMimePart *pkcs7, GMimeObject *content,
+#ifndef HAVE_GMIME_2_5_7
 				  GMimeCipherContext *ctx, GPtrArray *recipients,
+#else /* HAVE_GMIME_2_5_7 */
+				  GMimeCryptoContext *ctx,
+                                  GPtrArray *recipients,
+#endif /* HAVE_GMIME_2_5_7 */
 				  GError **err)
 {
     GMimeDataWrapper *wrapper;
@@ -257,8 +294,14 @@ g_mime_application_pkcs7_encrypt (GMimePart *pkcs7, GMimeObject *content,
     GMimeFilter *crlf_filter;
 	
     g_return_val_if_fail (GMIME_IS_PART (pkcs7), -1);
+#ifndef HAVE_GMIME_2_5_7
     g_return_val_if_fail (GMIME_IS_CIPHER_CONTEXT (ctx), -1);
     g_return_val_if_fail (ctx->encrypt_protocol != NULL, -1);
+#else /* HAVE_GMIME_2_5_7 */
+    g_return_val_if_fail (GMIME_IS_CRYPTO_CONTEXT (ctx), -1);
+    g_return_val_if_fail(g_mime_crypto_context_get_encryption_protocol(ctx)
+                         != NULL, -1);
+#endif /* HAVE_GMIME_2_5_7 */
     g_return_val_if_fail (GMIME_IS_OBJECT (content), -1);
 	
     /* get the cleartext */
@@ -279,7 +322,15 @@ g_mime_application_pkcs7_encrypt (GMimePart *pkcs7, GMimeObject *content,
 	
     /* encrypt the content stream */
     ciphertext = g_mime_stream_mem_new ();
-    if (g_mime_cipher_context_encrypt (ctx, FALSE, NULL, recipients, stream, ciphertext, err) == -1) {
+#ifndef HAVE_GMIME_2_5_7
+    if (g_mime_cipher_context_encrypt (ctx, FALSE, NULL, recipients, stream, ciphertext, err) == -1)
+#else /* HAVE_GMIME_2_5_7 */
+    if (g_mime_crypto_context_encrypt
+        (ctx, FALSE, NULL,
+         GMIME_CIPHER_ALGO_DEFAULT,
+         recipients, stream, ciphertext, err) == -1)
+#endif /* HAVE_GMIME_2_5_7 */
+    {
 	g_object_unref (ciphertext);
 	g_object_unref (stream);
 	return -1;
@@ -313,8 +364,14 @@ g_mime_application_pkcs7_encrypt (GMimePart *pkcs7, GMimeObject *content,
  * err with more information about the reason.
  */
 GMimeObject *
+#ifndef HAVE_GMIME_2_5_7
 g_mime_application_pkcs7_decrypt (GMimePart *pkcs7, GMimeCipherContext *ctx,
 				  GError **err)
+#else /* HAVE_GMIME_2_5_7 */
+g_mime_application_pkcs7_decrypt (GMimePart *pkcs7,
+                                  GMimeCryptoContext *ctx,
+				  GError **err)
+#endif /* HAVE_GMIME_2_5_7 */
 {
     GMimeObject *decrypted;
     GMimeDataWrapper *wrapper;
@@ -325,8 +382,14 @@ g_mime_application_pkcs7_decrypt (GMimePart *pkcs7, GMimeCipherContext *ctx,
     const char *smime_type;
 
     g_return_val_if_fail(GMIME_IS_PART(pkcs7), NULL);
+#ifndef HAVE_GMIME_2_5_7
     g_return_val_if_fail(GMIME_IS_CIPHER_CONTEXT(ctx), NULL);
     g_return_val_if_fail(ctx->encrypt_protocol != NULL, NULL);
+#else /* HAVE_GMIME_2_5_7 */
+    g_return_val_if_fail(GMIME_IS_CRYPTO_CONTEXT(ctx), NULL);
+    g_return_val_if_fail(g_mime_crypto_context_get_encryption_protocol(ctx)
+                         != NULL, NULL);
+#endif /* HAVE_GMIME_2_5_7 */
 
     /* some sanity checks */
     smime_type =
@@ -353,7 +416,13 @@ g_mime_application_pkcs7_decrypt (GMimePart *pkcs7, GMimeCipherContext *ctx,
     g_object_unref(crlf_filter);
 
     /* get the cleartext */
-    if (g_mime_cipher_context_decrypt(ctx, ciphertext, filtered_stream, err) == NULL) {
+#ifndef HAVE_GMIME_2_5_7
+    if (g_mime_cipher_context_decrypt(ctx, ciphertext, filtered_stream, err) == NULL)
+#else /* HAVE_GMIME_2_5_7 */
+    if (g_mime_crypto_context_decrypt
+        (ctx, ciphertext, filtered_stream, err) == NULL)
+#endif /* HAVE_GMIME_2_5_7 */
+    {
 	g_object_unref(filtered_stream);
 	g_object_unref(ciphertext);
 	g_object_unref(stream);
diff --git a/libbalsa/gmime-application-pkcs7.h b/libbalsa/gmime-application-pkcs7.h
index 03fa401..6678ff5 100644
--- a/libbalsa/gmime-application-pkcs7.h
+++ b/libbalsa/gmime-application-pkcs7.h
@@ -28,7 +28,11 @@ extern "C" {
 #endif				/* __cplusplus */
 
 #include <gmime/gmime-part.h>
+#ifndef HAVE_GMIME_2_5_7
 #include <gmime/gmime-cipher-context.h>
+#else /* HAVE_GMIME_2_5_7 */
+#include <gmime/gmime-crypto-context.h>
+#endif /* HAVE_GMIME_2_5_7 */
 
 #undef HAS_APPLICATION_PKCS7_MIME_SIGNED_SUPPORT
 
@@ -39,21 +43,40 @@ extern "C" {
  * Balsa always encodes S/MIME signed stuff as multipart/signed. */
 int g_mime_application_pkcs7_sign(GMimePart * pkcs7,
 				  GMimeObject * content,
+#ifndef HAVE_GMIME_2_5_7
 				  GMimeCipherContext * ctx,
+#else /* HAVE_GMIME_2_5_7 */
+				  GMimeCryptoContext * ctx,
+#endif /* HAVE_GMIME_2_5_7 */
 				  const char *userid, GError ** err);
 #endif
 
+#ifndef HAVE_GMIME_2_5_7
 GMimeObject *g_mime_application_pkcs7_verify(GMimePart * pkcs7,
 					     GMimeSignatureValidity ** validity,
 					     GMimeCipherContext * ctx, GError ** err);
+#else /* HAVE_GMIME_2_5_7 */
+GMimeObject *g_mime_application_pkcs7_verify(GMimePart * pkcs7,
+					     GMimeSignatureList ** validity,
+					     GMimeCryptoContext * ctx, GError ** err);
+#endif /* HAVE_GMIME_2_5_7 */
 
 int g_mime_application_pkcs7_encrypt(GMimePart * pkcs7,
 				     GMimeObject * content,
+#ifndef HAVE_GMIME_2_5_7
 				     GMimeCipherContext * ctx,
+#else /* HAVE_GMIME_2_5_7 */
+				     GMimeCryptoContext * ctx,
+#endif /* HAVE_GMIME_2_5_7 */
 				     GPtrArray * recipients, GError ** err);
 
+#ifndef HAVE_GMIME_2_5_7
 GMimeObject *g_mime_application_pkcs7_decrypt(GMimePart * pkcs7,
 					      GMimeCipherContext * ctx, GError ** err);
+#else /* HAVE_GMIME_2_5_7 */
+GMimeObject *g_mime_application_pkcs7_decrypt(GMimePart * pkcs7,
+					      GMimeCryptoContext * ctx, GError ** err);
+#endif /* HAVE_GMIME_2_5_7 */
 
 #ifdef __cplusplus
 }
diff --git a/libbalsa/gmime-gpgme-context.c b/libbalsa/gmime-gpgme-context.c
index 24b140b..0c56f94 100644
--- a/libbalsa/gmime-gpgme-context.c
+++ b/libbalsa/gmime-gpgme-context.c
@@ -27,6 +27,9 @@
 #include <unistd.h>
 #include <glib.h>
 #include <gmime/gmime.h>
+#ifdef HAVE_GMIME_2_5_7
+#include <gmime/gmime-certificate.h>
+#endif /* HAVE_GMIME_2_5_7 */
 #include <gpgme.h>
 #include <time.h>
 #include <glib/gi18n.h>
@@ -44,6 +47,7 @@ static gboolean g_mime_gpgme_context_check_protocol(GMimeGpgmeContextClass
 						    protocol,
 						    GError ** error);
 
+#ifndef HAVE_GMIME_2_5_7
 static GMimeCipherHash g_mime_gpgme_hash_id(GMimeCipherContext * ctx,
 					    const char *hash);
 
@@ -70,6 +74,46 @@ static GMimeSignatureValidity *g_mime_gpgme_decrypt(GMimeCipherContext *
                                                     GMimeStream * istream,
                                                     GMimeStream * ostream,
                                                     GError ** err);
+#else /* HAVE_GMIME_2_5_7 */
+static GMimeDigestAlgo g_mime_gpgme_digest_id(GMimeCryptoContext * ctx,
+                                              const char *hash);
+
+static const char *g_mime_gpgme_digest_name(GMimeCryptoContext * ctx,
+                                            GMimeDigestAlgo hash);
+
+static const char
+    *g_mime_gpgme_get_signature_protocol(GMimeCryptoContext * context);
+static const char
+    *g_mime_gpgme_get_encryption_protocol(GMimeCryptoContext * context);
+static const char
+    *g_mime_gpgme_get_key_exchange_protocol(GMimeCryptoContext * context);
+
+static int g_mime_gpgme_sign(GMimeCryptoContext * ctx,
+                             const char * userid,
+			     GMimeDigestAlgo hash,
+                             GMimeStream * istream,
+			     GMimeStream * ostream,
+                             GError ** err);
+
+static GMimeSignatureList *g_mime_gpgme_verify(GMimeCryptoContext * ctx,
+                                               GMimeDigestAlgo hash,
+                                               GMimeStream * istream,
+                                               GMimeStream * sigstream,
+                                               GError ** err);
+
+static int g_mime_gpgme_encrypt(GMimeCryptoContext * ctx,
+                                gboolean sign,
+				const char *userid,
+                                GMimeDigestAlgo digest,
+                                GPtrArray * recipients,
+				GMimeStream * istream,
+				GMimeStream * ostream, GError ** err);
+
+static GMimeDecryptResult *g_mime_gpgme_decrypt(GMimeCryptoContext * ctx,
+                                                GMimeStream * istream,
+                                                GMimeStream * ostream,
+                                                GError ** err);
+#endif /* HAVE_GMIME_2_5_7 */
 
 
 /* internal passphrase callback */
@@ -102,7 +146,11 @@ static void g_set_error_from_gpgme(GError ** error, gpgme_error_t gpgme_err,
 				   const gchar * message);
 
 
+#ifndef HAVE_GMIME_2_5_7
 static GMimeCipherContextClass *parent_class = NULL;
+#else /* HAVE_GMIME_2_5_7 */
+static GMimeCryptoContextClass *parent_class = NULL;
+#endif /* HAVE_GMIME_2_5_7 */
 
 
 GType
@@ -124,8 +172,13 @@ g_mime_gpgme_context_get_type(void)
 	};
 
 	type =
+#ifndef HAVE_GMIME_2_5_7
 	    g_type_register_static(GMIME_TYPE_CIPHER_CONTEXT,
 				   "GMimeGpgmeContext", &info, 0);
+#else /* HAVE_GMIME_2_5_7 */
+	    g_type_register_static(GMIME_TYPE_CRYPTO_CONTEXT,
+				   "GMimeGpgmeContext", &info, 0);
+#endif /* HAVE_GMIME_2_5_7 */
     }
 
     return type;
@@ -136,19 +189,39 @@ static void
 g_mime_gpgme_context_class_init(GMimeGpgmeContextClass * klass)
 {
     GObjectClass *object_class = G_OBJECT_CLASS(klass);
+#ifndef HAVE_GMIME_2_5_7
     GMimeCipherContextClass *cipher_class =
 	GMIME_CIPHER_CONTEXT_CLASS(klass);
+#else /* HAVE_GMIME_2_5_7 */
+    GMimeCryptoContextClass *crypto_class =
+	GMIME_CRYPTO_CONTEXT_CLASS(klass);
+#endif /* HAVE_GMIME_2_5_7 */
 
     parent_class = g_type_class_ref(G_TYPE_OBJECT);
 
     object_class->finalize = g_mime_gpgme_context_finalize;
 
+#ifndef HAVE_GMIME_2_5_7
     cipher_class->hash_id = g_mime_gpgme_hash_id;
     cipher_class->hash_name = g_mime_gpgme_hash_name;
     cipher_class->sign = g_mime_gpgme_sign;
     cipher_class->verify = g_mime_gpgme_verify;
     cipher_class->encrypt = g_mime_gpgme_encrypt;
     cipher_class->decrypt = g_mime_gpgme_decrypt;
+#else /* HAVE_GMIME_2_5_7 */
+    crypto_class->digest_id = g_mime_gpgme_digest_id;
+    crypto_class->digest_name = g_mime_gpgme_digest_name;
+    crypto_class->get_signature_protocol =
+        g_mime_gpgme_get_signature_protocol;
+    crypto_class->get_encryption_protocol =
+        g_mime_gpgme_get_encryption_protocol;
+    crypto_class->get_key_exchange_protocol =
+        g_mime_gpgme_get_key_exchange_protocol;
+    crypto_class->sign = g_mime_gpgme_sign;
+    crypto_class->verify = g_mime_gpgme_verify;
+    crypto_class->encrypt = g_mime_gpgme_encrypt;
+    crypto_class->decrypt = g_mime_gpgme_decrypt;
+#endif /* HAVE_GMIME_2_5_7 */
 
     if (gpgme_engine_check_version(GPGME_PROTOCOL_OpenPGP) ==
 	GPG_ERR_NO_ERROR)
@@ -190,7 +263,11 @@ g_mime_gpgme_context_finalize(GObject * object)
     }
 
 #if !defined(HAVE_GMIME_2_6)
+#ifndef HAVE_GMIME_2_5_7
     g_object_unref(GMIME_CIPHER_CONTEXT(ctx)->session);
+#else /* HAVE_GMIME_2_5_7 */
+    g_object_unref(GMIME_CRYPTO_CONTEXT(ctx)->session);
+#endif /* HAVE_GMIME_2_5_7 */
 #endif                          /* HAVE_GMIME_2_6 */
 
     G_OBJECT_CLASS(parent_class)->finalize(object);
@@ -200,15 +277,26 @@ g_mime_gpgme_context_finalize(GObject * object)
 /*
  * Convert a hash algorithm name to a number
  */
+#ifndef HAVE_GMIME_2_5_7
 static GMimeCipherHash
 g_mime_gpgme_hash_id(GMimeCipherContext * ctx, const char *hash)
+#else /* HAVE_GMIME_2_5_7 */
+static GMimeDigestAlgo
+g_mime_gpgme_digest_id(GMimeCryptoContext * ctx, const char *hash)
+#endif /* HAVE_GMIME_2_5_7 */
 {
+#ifndef HAVE_GMIME_2_5_7
     if (hash == NULL)
 	return GMIME_CIPHER_HASH_DEFAULT;
+#else /* HAVE_GMIME_2_5_7 */
+    if (hash == NULL)
+	return GMIME_DIGEST_ALGO_DEFAULT;
+#endif /* HAVE_GMIME_2_5_7 */
 
     if (!g_ascii_strcasecmp(hash, "pgp-"))
 	hash += 4;
 
+#ifndef HAVE_GMIME_2_5_7
     if (!g_ascii_strcasecmp(hash, "md2"))
 	return GMIME_CIPHER_HASH_MD2;
     else if (!g_ascii_strcasecmp(hash, "md5"))
@@ -223,6 +311,22 @@ g_mime_gpgme_hash_id(GMimeCipherContext * ctx, const char *hash)
 	return GMIME_CIPHER_HASH_HAVAL5160;
 
     return GMIME_CIPHER_HASH_DEFAULT;
+#else /* HAVE_GMIME_2_5_7 */
+    if (!g_ascii_strcasecmp(hash, "md2"))
+	return GMIME_DIGEST_ALGO_MD2;
+    else if (!g_ascii_strcasecmp(hash, "md5"))
+	return GMIME_DIGEST_ALGO_MD5;
+    else if (!g_ascii_strcasecmp(hash, "sha1"))
+	return GMIME_DIGEST_ALGO_SHA1;
+    else if (!g_ascii_strcasecmp(hash, "ripemd160"))
+	return GMIME_DIGEST_ALGO_RIPEMD160;
+    else if (!g_ascii_strcasecmp(hash, "tiger192"))
+	return GMIME_DIGEST_ALGO_TIGER192;
+    else if (!g_ascii_strcasecmp(hash, "haval-5-160"))
+	return GMIME_DIGEST_ALGO_HAVAL5160;
+
+    return GMIME_DIGEST_ALGO_DEFAULT;
+#endif /* HAVE_GMIME_2_5_7 */
 }
 
 
@@ -230,7 +334,11 @@ g_mime_gpgme_hash_id(GMimeCipherContext * ctx, const char *hash)
  * Convert a hash algorithm number to a string
  */
 static const char *
+#ifndef HAVE_GMIME_2_5_7
 g_mime_gpgme_hash_name(GMimeCipherContext * context, GMimeCipherHash hash)
+#else /* HAVE_GMIME_2_5_7 */
+g_mime_gpgme_digest_name(GMimeCryptoContext * context, GMimeDigestAlgo hash)
+#endif /* HAVE_GMIME_2_5_7 */
 {
     GMimeGpgmeContext *ctx = GMIME_GPGME_CONTEXT(context);
     char *p;
@@ -239,6 +347,7 @@ g_mime_gpgme_hash_name(GMimeCipherContext * context, GMimeCipherHash hash)
     g_return_val_if_fail(ctx->gpgme_ctx, NULL);
 
     /* note: this is only a subset of the hash algorithms gpg(me) supports */
+#ifndef HAVE_GMIME_2_5_7
     switch (hash) {
     case GMIME_CIPHER_HASH_MD2:
 	p = "pgp-md2";
@@ -258,6 +367,27 @@ g_mime_gpgme_hash_name(GMimeCipherContext * context, GMimeCipherHash hash)
     case GMIME_CIPHER_HASH_HAVAL5160:
 	p = "pgp-haval-5-160";
 	break;
+#else /* HAVE_GMIME_2_5_7 */
+    switch (hash) {
+    case GMIME_DIGEST_ALGO_MD2:
+	p = "pgp-md2";
+	break;
+    case GMIME_DIGEST_ALGO_MD5:
+	p = "pgp-md5";
+	break;
+    case GMIME_DIGEST_ALGO_SHA1:
+	p = "pgp-sha1";
+	break;
+    case GMIME_DIGEST_ALGO_RIPEMD160:
+	p = "pgp-ripemd160";
+	break;
+    case GMIME_DIGEST_ALGO_TIGER192:
+	p = "pgp-tiger192";
+	break;
+    case GMIME_DIGEST_ALGO_HAVAL5160:
+	p = "pgp-haval-5-160";
+	break;
+#endif /* HAVE_GMIME_2_5_7 */
     default:
 	if (!(p = ctx->micalg))
 	    return p;
@@ -270,6 +400,29 @@ g_mime_gpgme_hash_name(GMimeCipherContext * context, GMimeCipherHash hash)
     return p;
 }
 
+#ifdef HAVE_GMIME_2_5_7
+static const char *
+g_mime_gpgme_get_signature_protocol(GMimeCryptoContext * context)
+{
+    GMimeGpgmeContext *ctx = GMIME_GPGME_CONTEXT(context);
+    return ctx->sign_protocol;
+}
+
+static const char *
+g_mime_gpgme_get_encryption_protocol(GMimeCryptoContext * context)
+{
+    GMimeGpgmeContext *ctx = GMIME_GPGME_CONTEXT(context);
+    return ctx->encrypt_protocol;
+}
+
+static const char *
+g_mime_gpgme_get_key_exchange_protocol(GMimeCryptoContext * context)
+{
+    GMimeGpgmeContext *ctx = GMIME_GPGME_CONTEXT(context);
+    return ctx->key_protocol;
+}
+
+#endif /* HAVE_GMIME_2_5_7 */
 
 /*
  * Wrapper to convert the passphrase returned from the gmime session to gpgme.
@@ -279,7 +432,11 @@ g_mime_session_passphrase(void *HOOK, const char *UID_HINT,
 			  const char *PASSPHRASE_INFO, int PREV_WAS_BAD,
 			  int FD)
 {
+#ifndef HAVE_GMIME_2_5_7
     GMimeCipherContext *ctx = GMIME_CIPHER_CONTEXT(HOOK);
+#else /* HAVE_GMIME_2_5_7 */
+    GMimeCryptoContext *ctx = GMIME_CRYPTO_CONTEXT(HOOK);
+#endif /* HAVE_GMIME_2_5_7 */
 #if defined(HAVE_GMIME_2_6)
     GMimeStream *stream;
     gboolean rc;
@@ -366,9 +523,15 @@ cb_data_release(void *handle)
  * arg, but set the value in the context.
  */
 static int
+#ifndef HAVE_GMIME_2_5_7
 g_mime_gpgme_sign(GMimeCipherContext * context, const char *userid,
 		  GMimeCipherHash hash, GMimeStream * istream,
 		  GMimeStream * ostream, GError ** error)
+#else /* HAVE_GMIME_2_5_7 */
+g_mime_gpgme_sign(GMimeCryptoContext * context, const char *userid,
+		  GMimeDigestAlgo hash, GMimeStream * istream,
+		  GMimeStream * ostream, GError ** error)
+#endif /* HAVE_GMIME_2_5_7 */
 {
     GMimeGpgmeContext *ctx = (GMimeGpgmeContext *) context;
     gpgme_sig_mode_t sig_mode;
@@ -460,6 +623,7 @@ g_mime_gpgme_sign(GMimeCipherContext * context, const char *userid,
 }
 
 
+#ifndef HAVE_GMIME_2_5_7
 /*
  * In standard mode, verify that sigstream contains a detached signature for
  * istream. In single-part mode (RFC 2440, RFC 2633 application/pkcs7-mime),
@@ -471,13 +635,33 @@ static GMimeSignatureValidity *
 g_mime_gpgme_verify(GMimeCipherContext * context, GMimeCipherHash hash,
 		    GMimeStream * istream, GMimeStream * sigstream,
 		    GError ** error)
+#else /* HAVE_GMIME_2_5_7 */
+/*
+ * In standard mode, verify that sigstream contains a detached signature for
+ * istream. In single-part mode (RFC 2440, RFC 2633 application/pkcs7-mime),
+ * istream contains clearsigned data, and sigstream will be filled with the
+ * verified plaintext. The routine returns a GMimeSignatureList object.
+ * More information is saved in the context's signature object.
+ * On error error is set accordingly.
+ */
+static GMimeSignatureList *
+g_mime_gpgme_verify(GMimeCryptoContext * context, GMimeDigestAlgo hash,
+		    GMimeStream * istream, GMimeStream * sigstream,
+		    GError ** error)
+#endif /* HAVE_GMIME_2_5_7 */
 {
     GMimeGpgmeContext *ctx = (GMimeGpgmeContext *) context;
     gpgme_ctx_t gpgme_ctx;
     gpgme_protocol_t protocol;
     gpgme_error_t err;
     gpgme_data_t msg, sig;
+#ifndef HAVE_GMIME_2_5_7
     GMimeSignatureValidity *validity;
+#else /* HAVE_GMIME_2_5_7 */
+    GMimeSignatureList *list;
+    GMimeSignature *signature;
+
+#endif /* HAVE_GMIME_2_5_7 */
     struct gpgme_data_cbs cbs = {
 	(gpgme_data_read_cb_t) g_mime_gpgme_stream_rd,	/* read method */
 	(gpgme_data_write_cb_t) g_mime_gpgme_stream_wr,	/* write method */
@@ -521,6 +705,7 @@ g_mime_gpgme_verify(GMimeCipherContext * context, GMimeCipherHash hash,
 	ctx->sig_state =
 	    g_mime_gpgme_sigstat_new_from_gpgme_ctx(gpgme_ctx);
 
+#ifndef HAVE_GMIME_2_5_7
     validity = g_mime_signature_validity_new();
     if (ctx->sig_state) {
 	switch (ctx->sig_state->status)
@@ -536,12 +721,44 @@ g_mime_gpgme_verify(GMimeCipherContext * context, GMimeCipherHash hash,
 	    }
     } else
 	g_mime_signature_validity_set_status(validity, GMIME_SIGNATURE_STATUS_UNKNOWN);
+#else /* HAVE_GMIME_2_5_7 */
+    list = g_mime_signature_list_new();
+    signature = g_mime_signature_new();
+    g_mime_signature_list_add(list, signature);
+
+    if (ctx->sig_state) {
+	switch (ctx->sig_state->status)
+	    {
+	    case GPG_ERR_NO_ERROR:
+		g_mime_signature_set_status(signature,
+                                            GMIME_SIGNATURE_STATUS_GOOD);
+		break;
+	    case GPG_ERR_NOT_SIGNED:
+		g_mime_signature_set_status(signature,
+                                            GMIME_SIGNATURE_STATUS_ERROR);
+		g_mime_signature_set_errors(signature,
+                                            GMIME_SIGNATURE_ERROR_NONE);
+		break;
+	    default:
+		g_mime_signature_set_status(signature,
+                                            GMIME_SIGNATURE_STATUS_BAD);
+	    }
+    } else {
+	g_mime_signature_set_status(signature,
+                                    GMIME_SIGNATURE_STATUS_ERROR);
+        g_mime_signature_set_errors(signature, GMIME_SIGNATURE_ERROR_NONE);
+    }
+#endif /* HAVE_GMIME_2_5_7 */
 
     /* release gmgme data buffers */
     gpgme_data_release(msg);
     gpgme_data_release(sig);
 
+#ifndef HAVE_GMIME_2_5_7
     return validity;
+#else /* HAVE_GMIME_2_5_7 */
+    return list;
+#endif /* HAVE_GMIME_2_5_7 */
 }
 
 
@@ -549,10 +766,19 @@ g_mime_gpgme_verify(GMimeCipherContext * context, GMimeCipherHash hash,
  * Encrypt istream to ostream for recipients. If sign is set, sign by userid.
  */
 static int
+#ifndef HAVE_GMIME_2_5_7
 g_mime_gpgme_encrypt(GMimeCipherContext * context, gboolean sign,
 		     const char *userid, GPtrArray * recipients,
 		     GMimeStream * istream, GMimeStream * ostream,
 		     GError ** error)
+#else /* HAVE_GMIME_2_5_7 */
+g_mime_gpgme_encrypt(GMimeCryptoContext * context, gboolean sign,
+		     const char *userid,
+                     GMimeDigestAlgo digest,
+                     GPtrArray * recipients,
+		     GMimeStream * istream, GMimeStream * ostream,
+		     GError ** error)
+#endif /* HAVE_GMIME_2_5_7 */
 {
     GMimeGpgmeContext *ctx = (GMimeGpgmeContext *) context;
     gpgme_ctx_t gpgme_ctx;
@@ -653,9 +879,15 @@ g_mime_gpgme_encrypt(GMimeCipherContext * context, gboolean sign,
  * Decrypt istream to ostream. In RFC 2440 mode, also try to check an included
  * signature (if any).
  */
+#ifndef HAVE_GMIME_2_5_7
 static GMimeSignatureValidity *
 g_mime_gpgme_decrypt(GMimeCipherContext * context, GMimeStream * istream,
 		     GMimeStream * ostream, GError ** error)
+#else /* HAVE_GMIME_2_5_7 */
+static GMimeDecryptResult *
+g_mime_gpgme_decrypt(GMimeCryptoContext * context, GMimeStream * istream,
+		     GMimeStream * ostream, GError ** error)
+#endif /* HAVE_GMIME_2_5_7 */
 {
     GMimeGpgmeContext *ctx = (GMimeGpgmeContext *) context;
     gpgme_ctx_t gpgme_ctx;
@@ -668,7 +900,13 @@ g_mime_gpgme_decrypt(GMimeCipherContext * context, GMimeStream * istream,
 	NULL,			/* seek method */
 	cb_data_release		/* release method */
     };
+#ifndef HAVE_GMIME_2_5_7
     GMimeSignatureValidity *validity;
+#else /* HAVE_GMIME_2_5_7 */
+    GMimeDecryptResult *result;
+    GMimeSignatureList *list;
+    GMimeSignature *signature;
+#endif /* HAVE_GMIME_2_5_7 */
 
     /* some paranoia checks */
     g_return_val_if_fail(ctx, NULL);
@@ -716,6 +954,7 @@ g_mime_gpgme_decrypt(GMimeCipherContext * context, GMimeStream * istream,
     /* try to get information about the signature (if any) */
     ctx->sig_state = g_mime_gpgme_sigstat_new_from_gpgme_ctx(gpgme_ctx);
 
+#ifndef HAVE_GMIME_2_5_7
     validity = g_mime_signature_validity_new();
     if (ctx->sig_state) {
 	switch (ctx->sig_state->status)
@@ -733,14 +972,57 @@ g_mime_gpgme_decrypt(GMimeCipherContext * context, GMimeStream * istream,
 	g_mime_signature_validity_set_status(validity, GMIME_SIGNATURE_STATUS_UNKNOWN);
 
     return validity;
+#else /* HAVE_GMIME_2_5_7 */
+    list = g_mime_signature_list_new();
+    signature = g_mime_signature_new();
+    g_mime_signature_list_add(list, signature);
+    result = g_mime_decrypt_result_new();
+    g_mime_decrypt_result_set_signatures(result, list);
+
+    if (ctx->sig_state) {
+	switch (ctx->sig_state->status)
+	    {
+	    case GPG_ERR_NO_ERROR:
+		g_mime_signature_set_status(signature,
+                                            GMIME_SIGNATURE_STATUS_GOOD);
+		break;
+	    case GPG_ERR_NOT_SIGNED:
+		g_mime_signature_set_status(signature,
+                                            GMIME_SIGNATURE_STATUS_ERROR);
+		g_mime_signature_set_errors(signature,
+                                            GMIME_SIGNATURE_ERROR_NONE);
+		break;
+	    default:
+		g_mime_signature_set_status(signature,
+                                            GMIME_SIGNATURE_STATUS_BAD);
+	    }
+    } else {
+	g_mime_signature_set_status(signature,
+                                    GMIME_SIGNATURE_STATUS_ERROR);
+        g_mime_signature_set_errors(signature, GMIME_SIGNATURE_ERROR_NONE);
+    }
+
+    return result;
+#endif /* HAVE_GMIME_2_5_7 */
 }
 
 
+#ifndef HAVE_GMIME_2_5_7
 /*
  * Create a new gpgme cipher context with protocol. If anything fails, return
  * NULL and set error.
  */
+#else /* HAVE_GMIME_2_5_7 */
+/*
+ * Create a new gpgme crypto context with protocol. If anything fails, return
+ * NULL and set error.
+ */
+#endif /* HAVE_GMIME_2_5_7 */
+#ifndef HAVE_GMIME_2_5_7
 GMimeCipherContext *
+#else /* HAVE_GMIME_2_5_7 */
+GMimeCryptoContext *
+#endif /* HAVE_GMIME_2_5_7 */
 #if defined(HAVE_GMIME_2_6)
 g_mime_gpgme_context_new(GMimePasswordRequestFunc request_passwd,
                          gpgme_protocol_t protocol, GError ** error)
@@ -749,7 +1031,11 @@ g_mime_gpgme_context_new(GMimeSession * session,
 			 gpgme_protocol_t protocol, GError ** error)
 #endif                          /* HAVE_GMIME_2_6 */
 {
+#ifndef HAVE_GMIME_2_5_7
     GMimeCipherContext *cipher;
+#else /* HAVE_GMIME_2_5_7 */
+    GMimeCryptoContext *crypto;
+#endif /* HAVE_GMIME_2_5_7 */
     GMimeGpgmeContext *ctx;
     gpgme_error_t err;
     gpgme_ctx_t gpgme_ctx;
@@ -766,14 +1052,22 @@ g_mime_gpgme_context_new(GMimeSession * session,
 	return NULL;
     }
 
+#ifndef HAVE_GMIME_2_5_7
     /* create the cipher context */
+#else /* HAVE_GMIME_2_5_7 */
+    /* create the crypto context */
+#endif /* HAVE_GMIME_2_5_7 */
     ctx = g_object_new(GMIME_TYPE_GPGME_CONTEXT, NULL, NULL);
     if (!ctx) {
 	gpgme_release(gpgme_ctx);
 	return NULL;
     } else
 	ctx->gpgme_ctx = gpgme_ctx;
+#ifndef HAVE_GMIME_2_5_7
     cipher = (GMimeCipherContext *) ctx;
+#else /* HAVE_GMIME_2_5_7 */
+    crypto = (GMimeCryptoContext *) ctx;
+#endif /* HAVE_GMIME_2_5_7 */
 
     /* check if the requested protocol is available */
     if (!g_mime_gpgme_context_check_protocol
@@ -785,23 +1079,47 @@ g_mime_gpgme_context_new(GMimeSession * session,
 
     /* setup according to requested protocol */
 #if defined(HAVE_GMIME_2_6)
+#ifndef HAVE_GMIME_2_5_7
     cipher->request_passwd = request_passwd;
+#else /* HAVE_GMIME_2_5_7 */
+    crypto->request_passwd = request_passwd;
+#endif /* HAVE_GMIME_2_5_7 */
 #else                           /* HAVE_GMIME_2_6 */
+#ifndef HAVE_GMIME_2_5_7
     cipher->session = session;
+#else /* HAVE_GMIME_2_5_7 */
+    crypto->session = session;
+#endif /* HAVE_GMIME_2_5_7 */
     g_object_ref(session);
 #endif                          /* HAVE_GMIME_2_6 */
     gpgme_set_protocol(gpgme_ctx, protocol);
     if (protocol == GPGME_PROTOCOL_OpenPGP) {
+#ifndef HAVE_GMIME_2_5_7
 	cipher->sign_protocol = "application/pgp-signature";
 	cipher->encrypt_protocol = "application/pgp-encrypted";
 	cipher->key_protocol = NULL;	/* FIXME */
+#else /* HAVE_GMIME_2_5_7 */
+	ctx->sign_protocol = "application/pgp-signature";
+	ctx->encrypt_protocol = "application/pgp-encrypted";
+	ctx->key_protocol = NULL;	/* FIXME */
+#endif /* HAVE_GMIME_2_5_7 */
     } else {
+#ifndef HAVE_GMIME_2_5_7
 	cipher->sign_protocol = "application/pkcs7-signature";
 	cipher->encrypt_protocol = "application/pkcs7-mime";
 	cipher->key_protocol = NULL;	/* FIXME */
+#else /* HAVE_GMIME_2_5_7 */
+	ctx->sign_protocol = "application/pkcs7-signature";
+	ctx->encrypt_protocol = "application/pkcs7-mime";
+	ctx->key_protocol = NULL;	/* FIXME */
+#endif /* HAVE_GMIME_2_5_7 */
     }
 
+#ifndef HAVE_GMIME_2_5_7
     return cipher;
+#else /* HAVE_GMIME_2_5_7 */
+    return crypto;
+#endif /* HAVE_GMIME_2_5_7 */
 }
 
 
diff --git a/libbalsa/gmime-gpgme-context.h b/libbalsa/gmime-gpgme-context.h
index 585d927..19c5fae 100644
--- a/libbalsa/gmime-gpgme-context.h
+++ b/libbalsa/gmime-gpgme-context.h
@@ -63,7 +63,11 @@ typedef gboolean(*GMimeGpgmeKeyTrustCB) (const gchar * name,
 					 GMimeGpgmeContext * ctx);
 
 struct _GMimeGpgmeContext {
+#ifndef HAVE_GMIME_2_5_7
     GMimeCipherContext parent_object;
+#else /* HAVE_GMIME_2_5_7 */
+    GMimeCryptoContext parent_object;
+#endif /* HAVE_GMIME_2_5_7 */
 
     gpgme_ctx_t gpgme_ctx;	/* gpgme context */
     gboolean singlepart_mode;	/* set context to single-part mode (RFC 2440, 2633) */
@@ -73,11 +77,21 @@ struct _GMimeGpgmeContext {
     GMimeGpgmeKeySelectCB key_select_cb;	/* key selection callback */
     GMimeGpgmeKeyTrustCB key_trust_cb;          /* low trust key cb */
     gpgme_passphrase_cb_t passphrase_cb;	/* passphrase callback */
+#ifdef HAVE_GMIME_2_5_7
+
+    const gchar *sign_protocol;
+    const gchar *encrypt_protocol;
+    const gchar *key_protocol;
+#endif /* HAVE_GMIME_2_5_7 */
 };
 
 
 struct _GMimeGpgmeContextClass {
+#ifndef HAVE_GMIME_2_5_7
     GMimeCipherContextClass parent_class;
+#else /* HAVE_GMIME_2_5_7 */
+    GMimeCryptoContextClass parent_class;
+#endif /* HAVE_GMIME_2_5_7 */
 
     gboolean has_proto_openpgp;
     gboolean has_proto_cms;
@@ -86,10 +100,17 @@ struct _GMimeGpgmeContextClass {
 
 GType g_mime_gpgme_context_get_type(void);
 #if defined(HAVE_GMIME_2_6)
+#ifndef HAVE_GMIME_2_5_7
 GMimeCipherContext *g_mime_gpgme_context_new(GMimePasswordRequestFunc
                                              request_passwd,
 					     gpgme_protocol_t protocol,
 					     GError ** error);
+#else /* HAVE_GMIME_2_5_7 */
+GMimeCryptoContext *g_mime_gpgme_context_new(GMimePasswordRequestFunc
+                                             request_passwd,
+					     gpgme_protocol_t protocol,
+					     GError ** error);
+#endif /* HAVE_GMIME_2_5_7 */
 #else                           /* HAVE_GMIME_2_6 */
 GMimeCipherContext *g_mime_gpgme_context_new(GMimeSession * session,
 					     gpgme_protocol_t protocol,
diff --git a/libbalsa/gmime-part-rfc2440.c b/libbalsa/gmime-part-rfc2440.c
index 795d2e1..e79c4cb 100644
--- a/libbalsa/gmime-part-rfc2440.c
+++ b/libbalsa/gmime-part-rfc2440.c
@@ -112,8 +112,13 @@ g_mime_part_rfc2440_sign_encrypt(GMimePart * part,
 
     g_return_val_if_fail(GMIME_IS_PART(part), -1);
     g_return_val_if_fail(GMIME_IS_GPGME_CONTEXT(ctx), -1);
+#ifndef HAVE_GMIME_2_5_7
     g_return_val_if_fail(GMIME_CIPHER_CONTEXT(ctx)->sign_protocol != NULL,
 			 -1);
+#else /* HAVE_GMIME_2_5_7 */
+    g_return_val_if_fail(g_mime_crypto_context_get_signature_protocol
+                         (GMIME_CRYPTO_CONTEXT(ctx)) != NULL, -1);
+#endif /* HAVE_GMIME_2_5_7 */
     g_return_val_if_fail(recipients != NULL || sign_userid != NULL, -1);
 
     /* get the raw content */
@@ -131,14 +136,27 @@ g_mime_part_rfc2440_sign_encrypt(GMimePart * part,
     ctx->singlepart_mode = TRUE;
     if (recipients == NULL)
 	result =
+#ifndef HAVE_GMIME_2_5_7
 	    g_mime_cipher_context_sign(GMIME_CIPHER_CONTEXT(ctx), sign_userid,
 			       GMIME_CIPHER_HASH_DEFAULT, stream,
 			       cipherstream, err);
+#else /* HAVE_GMIME_2_5_7 */
+	    g_mime_crypto_context_sign(GMIME_CRYPTO_CONTEXT(ctx), sign_userid,
+			       GMIME_CIPHER_ALGO_DEFAULT, stream,
+			       cipherstream, err);
+#endif /* HAVE_GMIME_2_5_7 */
     else
 	result =
+#ifndef HAVE_GMIME_2_5_7
 	    g_mime_cipher_context_encrypt(GMIME_CIPHER_CONTEXT(ctx),
 				  sign_userid != NULL, sign_userid,
 				  recipients, stream, cipherstream, err);
+#else /* HAVE_GMIME_2_5_7 */
+	    g_mime_crypto_context_encrypt(GMIME_CRYPTO_CONTEXT(ctx),
+				  sign_userid != NULL, sign_userid,
+                                  GMIME_CIPHER_ALGO_DEFAULT,
+				  recipients, stream, cipherstream, err);
+#endif /* HAVE_GMIME_2_5_7 */
     if (result == -1) {
 	g_object_unref(cipherstream);
 	return -1;
@@ -202,18 +220,31 @@ g_mime_part_rfc2440_sign_encrypt(GMimePart * part,
  * set on err to provide more information. Upon success, the content
  * of part is replaced by the verified output of the crypto engine.
  */
+#ifndef HAVE_GMIME_2_5_7
 GMimeSignatureValidity *
+#else /* HAVE_GMIME_2_5_7 */
+GMimeSignatureList *
+#endif /* HAVE_GMIME_2_5_7 */
 g_mime_part_rfc2440_verify(GMimePart * part,
 			   GMimeGpgmeContext * ctx, GError ** err)
 {
     GMimeStream *stream, *plainstream;
     GMimeDataWrapper * wrapper;
+#ifndef HAVE_GMIME_2_5_7
     GMimeSignatureValidity *valid;
+#else /* HAVE_GMIME_2_5_7 */
+    GMimeSignatureList *list;
+#endif /* HAVE_GMIME_2_5_7 */
 
     g_return_val_if_fail(GMIME_IS_PART(part), NULL);
     g_return_val_if_fail(GMIME_IS_GPGME_CONTEXT(ctx), NULL);
+#ifndef HAVE_GMIME_2_5_7
     g_return_val_if_fail(GMIME_CIPHER_CONTEXT(ctx)->sign_protocol != NULL,
 			 NULL);
+#else /* HAVE_GMIME_2_5_7 */
+    g_return_val_if_fail(g_mime_crypto_context_get_signature_protocol
+                         (GMIME_CRYPTO_CONTEXT(ctx)) != NULL, NULL);
+#endif /* HAVE_GMIME_2_5_7 */
 
     /* get the raw content */
     wrapper = g_mime_part_get_content_object(GMIME_PART(part));
@@ -227,13 +258,25 @@ g_mime_part_rfc2440_verify(GMimePart * part,
 
     /* verify the signature */
     ctx->singlepart_mode = TRUE;
+#ifndef HAVE_GMIME_2_5_7
     valid =
 	g_mime_cipher_context_verify(GMIME_CIPHER_CONTEXT(ctx),
 			     GMIME_CIPHER_HASH_DEFAULT, stream,
 			     plainstream, err);
+#else /* HAVE_GMIME_2_5_7 */
+    list =
+	g_mime_crypto_context_verify(GMIME_CRYPTO_CONTEXT(ctx),
+			     GMIME_CIPHER_ALGO_DEFAULT, stream,
+			     plainstream, err);
+#endif /* HAVE_GMIME_2_5_7 */
 
     /* upon success, replace the signed content by the checked one */
-    if (valid) {
+#ifndef HAVE_GMIME_2_5_7
+    if (valid)
+#else /* HAVE_GMIME_2_5_7 */
+    if (list)
+#endif /* HAVE_GMIME_2_5_7 */
+    {
 	GMimeDataWrapper *wrapper = g_mime_data_wrapper_new();
 
 	g_mime_data_wrapper_set_stream(wrapper, plainstream);
@@ -242,7 +285,11 @@ g_mime_part_rfc2440_verify(GMimePart * part,
     }
     g_object_unref(plainstream);
 
+#ifndef HAVE_GMIME_2_5_7
     return valid;
+#else /* HAVE_GMIME_2_5_7 */
+    return list;
+#endif /* HAVE_GMIME_2_5_7 */
 }
 
 
@@ -255,19 +302,32 @@ g_mime_part_rfc2440_verify(GMimePart * part,
  * verified and the result is placed in ctx by the underlying gpgme
  * context.
  */
+#ifndef HAVE_GMIME_2_5_7
 GMimeSignatureValidity *
+#else /* HAVE_GMIME_2_5_7 */
+GMimeDecryptResult *
+#endif /* HAVE_GMIME_2_5_7 */
 g_mime_part_rfc2440_decrypt(GMimePart * part,
 			    GMimeGpgmeContext * ctx, GError ** err)
 {
     GMimeStream *stream, *plainstream;
     GMimeDataWrapper * wrapper;
+#ifndef HAVE_GMIME_2_5_7
     GMimeSignatureValidity *result;
+#else /* HAVE_GMIME_2_5_7 */
+    GMimeDecryptResult *result;
+#endif /* HAVE_GMIME_2_5_7 */
     gchar *headbuf = g_malloc0(1024);
 
     g_return_val_if_fail(GMIME_IS_PART(part), NULL);
     g_return_val_if_fail(GMIME_IS_GPGME_CONTEXT(ctx), NULL);
+#ifndef HAVE_GMIME_2_5_7
     g_return_val_if_fail(GMIME_CIPHER_CONTEXT(ctx)->encrypt_protocol !=
 			 NULL, NULL);
+#else /* HAVE_GMIME_2_5_7 */
+    g_return_val_if_fail(g_mime_crypto_context_get_encryption_protocol
+                         (GMIME_CRYPTO_CONTEXT(ctx)) != NULL, NULL);
+#endif /* HAVE_GMIME_2_5_7 */
 
     /* get the raw content */
     wrapper = g_mime_part_get_content_object(part);
@@ -284,8 +344,13 @@ g_mime_part_rfc2440_decrypt(GMimePart * part,
 
     /* decrypt and (if possible) verify the input */
     result =
+#ifndef HAVE_GMIME_2_5_7
 	g_mime_cipher_context_decrypt(GMIME_CIPHER_CONTEXT(ctx), stream,
 			      plainstream, err);
+#else /* HAVE_GMIME_2_5_7 */
+	g_mime_crypto_context_decrypt(GMIME_CRYPTO_CONTEXT(ctx), stream,
+                                      plainstream, err);
+#endif /* HAVE_GMIME_2_5_7 */
 
     if (result != NULL) {
 	GMimeStream *filter_stream;
diff --git a/libbalsa/gmime-part-rfc2440.h b/libbalsa/gmime-part-rfc2440.h
index 48be5a4..cc1901a 100644
--- a/libbalsa/gmime-part-rfc2440.h
+++ b/libbalsa/gmime-part-rfc2440.h
@@ -53,12 +53,21 @@ int g_mime_part_rfc2440_sign_encrypt(GMimePart * part,
 				     GPtrArray * recipients,
 				     const char *sign_userid,
 				     GError ** err);
+#ifndef HAVE_GMIME_2_5_7
 GMimeSignatureValidity *g_mime_part_rfc2440_verify(GMimePart * part,
 						   GMimeGpgmeContext * ctx,
 						   GError ** err);
 GMimeSignatureValidity *g_mime_part_rfc2440_decrypt(GMimePart * part,
                                                     GMimeGpgmeContext *
                                                     ctx, GError ** err);
+#else /* HAVE_GMIME_2_5_7 */
+GMimeSignatureList *g_mime_part_rfc2440_verify(GMimePart * part,
+                                               GMimeGpgmeContext * ctx,
+                                               GError ** err);
+GMimeDecryptResult *g_mime_part_rfc2440_decrypt(GMimePart * part,
+                                                GMimeGpgmeContext * ctx,
+                                                GError ** err);
+#endif /* HAVE_GMIME_2_5_7 */
 
 #ifdef __cplusplus
 }
diff --git a/libbalsa/rfc3156.c b/libbalsa/rfc3156.c
index a56e12c..df4a2e1 100644
--- a/libbalsa/rfc3156.c
+++ b/libbalsa/rfc3156.c
@@ -268,9 +268,15 @@ libbalsa_message_body_protection(LibBalsaMessageBody * body)
 
 #if defined(HAVE_GMIME_2_6)
 static gboolean
+#ifndef HAVE_GMIME_2_5_7
 password_request_func(GMimeCipherContext * ctx, const char *user_id,
                       const char *prompt_ctx, gboolean reprompt,
                       GMimeStream * response, GError ** err)
+#else /* HAVE_GMIME_2_5_7 */
+password_request_func(GMimeCryptoContext * ctx, const char *user_id,
+                      const char *prompt_ctx, gboolean reprompt,
+                      GMimeStream * response, GError ** err)
+#endif /* HAVE_GMIME_2_5_7 */
 {
     gint fd;
     gchar *name_used;
@@ -366,9 +372,16 @@ libbalsa_sign_mime_object(GMimeObject ** content, const gchar * rfc822_for,
 	return FALSE;
     }
 
+#ifndef HAVE_GMIME_2_5_7
     if (g_mime_multipart_signed_sign
 	(mps, *content, GMIME_CIPHER_CONTEXT(ctx), rfc822_for,
-	 GMIME_CIPHER_HASH_DEFAULT, error) != 0) {
+	 GMIME_CIPHER_HASH_DEFAULT, error) != 0)
+#else /* HAVE_GMIME_2_5_7 */
+    if (g_mime_multipart_signed_sign
+	(mps, *content, GMIME_CRYPTO_CONTEXT(ctx), rfc822_for,
+	 GMIME_DIGEST_ALGO_DEFAULT, error) != 0)
+#endif /* HAVE_GMIME_2_5_7 */
+    {
 	g_object_unref(mps);
 	g_object_unref(ctx);
 #if !defined(HAVE_GMIME_2_6)
@@ -458,10 +471,18 @@ libbalsa_encrypt_mime_object(GMimeObject ** content, GList * rfc822_for,
 
 	encrypted_obj = GMIME_OBJECT(mpe);
 	result = 
+#ifndef HAVE_GMIME_2_5_7
 	    g_mime_multipart_encrypted_encrypt(mpe, *content,
 					       GMIME_CIPHER_CONTEXT(ctx),
                                                FALSE, NULL,
 					       recipients, error);
+#else /* HAVE_GMIME_2_5_7 */
+	    g_mime_multipart_encrypted_encrypt(mpe, *content,
+					       GMIME_CRYPTO_CONTEXT(ctx),
+                                               FALSE, NULL,
+                                               GMIME_DIGEST_ALGO_DEFAULT,
+					       recipients, error);
+#endif /* HAVE_GMIME_2_5_7 */
     }
 #ifdef HAVE_SMIME
     else {
@@ -471,9 +492,15 @@ libbalsa_encrypt_mime_object(GMimeObject ** content, GList * rfc822_for,
 	encrypted_obj = GMIME_OBJECT(pkcs7);
 	ctx->singlepart_mode = TRUE;
 	result = 
+#ifndef HAVE_GMIME_2_5_7
 	    g_mime_application_pkcs7_encrypt(pkcs7, *content,
 					     GMIME_CIPHER_CONTEXT(ctx),
 					     recipients, error);
+#else /* HAVE_GMIME_2_5_7 */
+	    g_mime_application_pkcs7_encrypt(pkcs7, *content,
+					     GMIME_CRYPTO_CONTEXT(ctx),
+					     recipients, error);
+#endif /* HAVE_GMIME_2_5_7 */
     }
 #endif
 
@@ -565,8 +592,14 @@ libbalsa_body_check_signature(LibBalsaMessageBody * body,
 #if !defined(HAVE_GMIME_2_6)
     GMimeSession *session;
 #endif                          /* HAVE_GMIME_2_6 */
-    GMimeCipherContext *ctx;
+#ifndef HAVE_GMIME_2_5_7
+    GMimeCipherContext *g_mime_ctx;
     GMimeSignatureValidity *valid;
+#else /* HAVE_GMIME_2_5_7 */
+    GMimeCryptoContext *g_mime_ctx;
+    GMimeSignatureList *valid;
+#endif /* HAVE_GMIME_2_5_7 */
+    GMimeGpgmeContext *ctx;
     GError *error = NULL;
 
     /* paranoia checks */
@@ -592,12 +625,12 @@ libbalsa_body_check_signature(LibBalsaMessageBody * body,
     /* try to create GMimeGpgMEContext */
 #if !defined(HAVE_GMIME_2_6)
     session = g_object_new(g_mime_session_get_type(), NULL, NULL);
-    ctx = g_mime_gpgme_context_new(session, protocol, &error);
+    g_mime_ctx = g_mime_gpgme_context_new(session, protocol, &error);
 #else                           /* HAVE_GMIME_2_6 */
-    ctx =
+    g_mime_ctx =
         g_mime_gpgme_context_new(password_request_func, protocol, &error);
 #endif                          /* HAVE_GMIME_2_6 */
-    if (ctx == NULL) {
+    if (g_mime_ctx == NULL) {
 	if (error) {
 	    libbalsa_information(LIBBALSA_INFORMATION_ERROR, "%s: %s",
 				 _("creating a gpgme context failed"),
@@ -613,6 +646,7 @@ libbalsa_body_check_signature(LibBalsaMessageBody * body,
 	body->parts->next->sig_info->status = GPGME_SIG_STAT_ERROR;
 	return FALSE;
     }
+    ctx = GMIME_GPGME_CONTEXT(g_mime_ctx);
 
     /* S/MIME uses the protocol application/pkcs7-signature, but some ancient
        mailers, not yet knowing RFC 2633, use application/x-pkcs7-signature,
@@ -622,14 +656,19 @@ libbalsa_body_check_signature(LibBalsaMessageBody * body,
 	    g_mime_object_get_content_type_parameter(GMIME_OBJECT (body->mime_part),
 						     "protocol");
 	if (!g_ascii_strcasecmp(cms_protocol, "application/x-pkcs7-signature"))
+#ifndef HAVE_GMIME_2_5_7
+	    g_mime_ctx->sign_protocol = cms_protocol;
+#else /* HAVE_GMIME_2_5_7 */
 	    ctx->sign_protocol = cms_protocol;
+#endif /* HAVE_GMIME_2_5_7 */
     }
 
     /* verify the signature */
 
     libbalsa_mailbox_lock_store(body->message->mailbox);
     valid = g_mime_multipart_signed_verify(GMIME_MULTIPART_SIGNED
-					   (body->mime_part), ctx, &error);
+					   (body->mime_part), g_mime_ctx,
+                                           &error);
     libbalsa_mailbox_unlock_store(body->message->mailbox);
 
     if (valid == NULL) {
@@ -642,12 +681,16 @@ libbalsa_body_check_signature(LibBalsaMessageBody * body,
 	    libbalsa_information(LIBBALSA_INFORMATION_ERROR,
 				 _("signature verification failed"));
     }
-    if (GMIME_GPGME_CONTEXT(ctx)->sig_state) {
-	body->parts->next->sig_info = GMIME_GPGME_CONTEXT(ctx)->sig_state;
+    if (ctx->sig_state) {
+	body->parts->next->sig_info = ctx->sig_state;
 	g_object_ref(G_OBJECT(body->parts->next->sig_info));
     }
+#ifndef HAVE_GMIME_2_5_7
     g_mime_signature_validity_free(valid);
-    g_object_unref(ctx);
+#else /* HAVE_GMIME_2_5_7 */
+    g_object_unref(valid);
+#endif /* HAVE_GMIME_2_5_7 */
+    g_object_unref(g_mime_ctx);
 #if !defined(HAVE_GMIME_2_6)
     g_object_unref(session);
 #endif                          /* HAVE_GMIME_2_6 */
@@ -747,14 +790,26 @@ libbalsa_body_decrypt(LibBalsaMessageBody * body,
     libbalsa_mailbox_lock_store(body->message->mailbox);
     if (protocol == GPGME_PROTOCOL_OpenPGP)
 	mime_obj =
+#ifndef HAVE_GMIME_2_5_7
 	    g_mime_multipart_encrypted_decrypt(GMIME_MULTIPART_ENCRYPTED(body->mime_part),
 					       GMIME_CIPHER_CONTEXT(ctx),
 					       &error);
+#else /* HAVE_GMIME_2_5_7 */
+	    g_mime_multipart_encrypted_decrypt(GMIME_MULTIPART_ENCRYPTED(body->mime_part),
+					       GMIME_CRYPTO_CONTEXT(ctx),
+                                               NULL,
+					       &error);
+#endif /* HAVE_GMIME_2_5_7 */
 #ifdef HAVE_SMIME
     else if (smime_signed) {
+#ifndef HAVE_GMIME_2_5_7
 	GMimeSignatureValidity *valid;
+#else /* HAVE_GMIME_2_5_7 */
+	GMimeSignatureList *valid;
+#endif /* HAVE_GMIME_2_5_7 */
 
 	ctx->singlepart_mode = TRUE;
+#ifndef HAVE_GMIME_2_5_7
 	mime_obj =
 	    g_mime_application_pkcs7_verify(GMIME_PART(body->mime_part),
 					    &valid,
@@ -766,6 +821,19 @@ libbalsa_body_decrypt(LibBalsaMessageBody * body,
 	    g_mime_application_pkcs7_decrypt(GMIME_PART(body->mime_part),
 					       GMIME_CIPHER_CONTEXT(ctx),
 					       &error);
+#else /* HAVE_GMIME_2_5_7 */
+	mime_obj =
+	    g_mime_application_pkcs7_verify(GMIME_PART(body->mime_part),
+					    &valid,
+					    GMIME_CRYPTO_CONTEXT(ctx),
+					    &error);
+	g_object_unref(valid);
+    } else
+	mime_obj =
+	    g_mime_application_pkcs7_decrypt(GMIME_PART(body->mime_part),
+					       GMIME_CRYPTO_CONTEXT(ctx),
+					       &error);
+#endif /* HAVE_GMIME_2_5_7 */
 #endif
     libbalsa_mailbox_unlock_store(body->message->mailbox);
 
@@ -906,7 +974,11 @@ libbalsa_rfc2440_verify(GMimePart * part, GMimeGpgmeSigstat ** sig_info)
     GMimeSession *session;
 #endif                          /* HAVE_GMIME_2_6 */
     GMimeGpgmeContext *ctx;
+#ifndef HAVE_GMIME_2_5_7
     GMimeSignatureValidity *valid;
+#else /* HAVE_GMIME_2_5_7 */
+    GMimeSignatureList *valid;
+#endif /* HAVE_GMIME_2_5_7 */
     GError *error = NULL;
     gpgme_error_t retval;
 
@@ -978,7 +1050,11 @@ libbalsa_rfc2440_verify(GMimePart * part, GMimeGpgmeSigstat ** sig_info)
     }
 
     /* clean up */
+#ifndef HAVE_GMIME_2_5_7
     g_mime_signature_validity_free(valid);
+#else /* HAVE_GMIME_2_5_7 */
+    g_object_unref(valid);
+#endif /* HAVE_GMIME_2_5_7 */
     retval = ctx->sig_state->status;
     g_object_unref(ctx);
 #if !defined(HAVE_GMIME_2_6)
--
cgit v0.9.0.2