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
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
2544
2545
2546
2547
2548
2549
2550
2551
2552
2553
2554
2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
2581
2582
2583
2584
2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
2616
2617
2618
2619
2620
2621
2622
2623
2624
2625
2626
2627
2628
2629
2630
2631
2632
2633
2634
2635
2636
2637
2638
2639
2640
2641
2642
2643
2644
2645
2646
2647
2648
2649
2650
2651
2652
2653
2654
2655
2656
2657
2658
2659
2660
2661
2662
2663
2664
2665
2666
2667
2668
2669
2670
2671
2672
2673
2674
2675
2676
2677
2678
2679
2680
2681
2682
2683
2684
2685
2686
2687
2688
2689
2690
2691
2692
2693
2694
2695
2696
2697
2698
2699
2700
2701
2702
2703
2704
2705
2706
2707
2708
2709
2710
2711
2712
2713
2714
2715
2716
2717
2718
2719
2720
2721
2722
2723
2724
2725
2726
2727
2728
2729
2730
2731
2732
2733
2734
2735
2736
2737
2738
2739
2740
2741
2742
2743
2744
2745
2746
2747
2748
2749
2750
2751
2752
2753
2754
2755
2756
2757
2758
2759
2760
2761
2762
2763
2764
2765
2766
2767
2768
2769
2770
2771
2772
2773
2774
2775
2776
2777
2778
2779
2780
2781
2782
2783
2784
2785
2786
2787
2788
2789
2790
2791
2792
2793
2794
2795
2796
2797
2798
2799
2800
2801
2802
2803
2804
2805
2806
2807
2808
2809
2810
2811
2812
2813
2814
2815
2816
2817
2818
2819
2820
2821
2822
2823
2824
2825
2826
2827
2828
2829
2830
2831
2832
2833
2834
2835
2836
2837
2838
2839
2840
2841
2842
2843
2844
2845
2846
2847
2848
2849
2850
2851
2852
2853
2854
2855
2856
2857
2858
2859
2860
2861
2862
2863
2864
2865
2866
2867
2868
2869
2870
2871
2872
2873
2874
2875
2876
2877
2878
2879
2880
2881
2882
2883
2884
2885
2886
2887
2888
2889
2890
2891
2892
2893
2894
2895
2896
2897
2898
2899
2900
2901
2902
2903
2904
2905
2906
2907
2908
2909
2910
2911
2912
2913
2914
2915
2916
2917
2918
2919
2920
2921
2922
2923
2924
2925
2926
2927
2928
2929
2930
2931
2932
2933
2934
2935
2936
2937
2938
2939
2940
2941
2942
2943
2944
2945
2946
2947
2948
2949
2950
2951
2952
2953
2954
2955
2956
2957
2958
2959
2960
2961
2962
2963
2964
2965
2966
2967
2968
2969
2970
2971
2972
2973
2974
2975
2976
2977
2978
2979
2980
2981
2982
2983
2984
2985
2986
2987
2988
2989
2990
2991
2992
2993
2994
2995
2996
2997
2998
2999
3000
3001
3002
3003
3004
3005
3006
3007
3008
3009
3010
3011
3012
3013
3014
3015
3016
3017
3018
3019
3020
3021
3022
3023
3024
3025
3026
3027
3028
3029
3030
3031
3032
3033
3034
3035
3036
3037
3038
3039
3040
3041
3042
3043
3044
3045
3046
3047
3048
3049
3050
3051
3052
3053
3054
3055
3056
3057
3058
3059
3060
3061
3062
3063
3064
3065
3066
3067
3068
3069
3070
3071
3072
3073
3074
3075
3076
3077
3078
3079
3080
3081
3082
3083
3084
3085
3086
3087
3088
3089
3090
3091
3092
3093
3094
3095
3096
3097
3098
3099
3100
3101
3102
3103
3104
3105
3106
3107
3108
3109
3110
3111
3112
3113
3114
3115
3116
3117
3118
3119
3120
3121
3122
3123
3124
3125
3126
3127
3128
3129
3130
3131
3132
3133
3134
3135
3136
3137
3138
3139
3140
3141
3142
3143
3144
3145
3146
3147
3148
3149
3150
3151
3152
3153
3154
3155
3156
3157
3158
3159
3160
3161
3162
3163
3164
3165
3166
3167
3168
3169
3170
3171
3172
3173
3174
3175
3176
3177
3178
3179
3180
3181
3182
3183
3184
3185
3186
3187
3188
3189
3190
3191
3192
3193
3194
3195
3196
3197
3198
3199
3200
3201
3202
3203
3204
3205
3206
3207
3208
3209
3210
3211
3212
3213
3214
3215
3216
3217
3218
3219
3220
3221
3222
3223
3224
3225
3226
3227
3228
3229
3230
3231
3232
3233
3234
3235
3236
3237
3238
3239
3240
3241
3242
3243
3244
3245
3246
3247
3248
3249
3250
3251
3252
3253
3254
3255
3256
3257
3258
3259
3260
3261
3262
3263
3264
3265
3266
3267
3268
3269
3270
3271
3272
3273
3274
3275
3276
3277
3278
3279
3280
3281
3282
3283
3284
3285
3286
3287
3288
3289
3290
3291
3292
3293
3294
3295
3296
3297
3298
3299
3300
3301
3302
3303
3304
3305
3306
3307
3308
3309
3310
3311
3312
3313
3314
3315
3316
3317
3318
3319
3320
3321
3322
3323
3324
3325
3326
3327
3328
3329
3330
3331
3332
3333
3334
3335
3336
3337
3338
3339
3340
3341
3342
3343
3344
3345
3346
3347
3348
3349
3350
3351
3352
3353
3354
3355
3356
3357
3358
3359
3360
3361
3362
3363
3364
3365
3366
3367
3368
3369
3370
3371
3372
3373
3374
3375
3376
3377
3378
3379
3380
3381
3382
3383
3384
3385
3386
3387
3388
3389
3390
3391
3392
3393
3394
3395
3396
3397
3398
3399
3400
3401
3402
3403
3404
3405
3406
3407
3408
3409
3410
3411
3412
3413
3414
3415
3416
3417
3418
3419
3420
3421
3422
3423
3424
3425
3426
3427
3428
3429
3430
3431
3432
3433
3434
3435
3436
3437
3438
3439
3440
3441
3442
3443
3444
3445
3446
3447
3448
3449
3450
3451
3452
3453
3454
3455
3456
3457
3458
3459
3460
3461
3462
3463
3464
3465
3466
3467
3468
3469
3470
3471
3472
3473
3474
3475
3476
3477
3478
3479
3480
3481
3482
3483
3484
3485
3486
3487
3488
3489
3490
3491
3492
3493
3494
3495
3496
3497
3498
3499
3500
3501
3502
3503
3504
3505
3506
3507
3508
3509
3510
3511
3512
3513
3514
3515
3516
3517
3518
3519
3520
3521
3522
3523
3524
3525
3526
3527
3528
3529
3530
3531
3532
3533
3534
3535
3536
3537
3538
3539
3540
3541
3542
3543
3544
3545
3546
3547
3548
3549
3550
3551
3552
3553
3554
3555
3556
3557
3558
3559
3560
3561
3562
3563
3564
3565
3566
3567
3568
3569
3570
3571
3572
3573
3574
3575
3576
3577
3578
3579
3580
3581
3582
3583
3584
3585
3586
3587
3588
3589
3590
3591
3592
3593
3594
3595
3596
3597
3598
3599
3600
3601
3602
3603
3604
3605
3606
3607
3608
3609
3610
3611
3612
3613
3614
3615
3616
3617
3618
3619
3620
3621
3622
3623
3624
3625
3626
3627
3628
3629
3630
3631
3632
3633
3634
3635
3636
3637
3638
3639
3640
3641
3642
3643
3644
3645
3646
3647
3648
3649
3650
3651
3652
3653
3654
3655
3656
3657
3658
3659
3660
3661
3662
3663
3664
3665
3666
3667
3668
3669
3670
3671
3672
3673
3674
3675
3676
3677
3678
3679
3680
3681
3682
3683
3684
3685
3686
3687
3688
3689
3690
3691
3692
3693
3694
3695
3696
3697
3698
3699
3700
3701
3702
3703
3704
3705
3706
3707
3708
3709
3710
3711
3712
3713
3714
3715
3716
3717
3718
3719
3720
3721
3722
3723
3724
3725
3726
3727
3728
3729
3730
3731
3732
3733
3734
3735
3736
3737
3738
3739
3740
3741
3742
3743
3744
3745
3746
3747
3748
3749
3750
3751
3752
3753
3754
3755
3756
3757
3758
3759
3760
3761
3762
3763
3764
3765
3766
3767
3768
3769
3770
3771
3772
3773
3774
3775
3776
3777
3778
3779
3780
3781
3782
3783
3784
3785
3786
3787
3788
3789
3790
3791
3792
3793
3794
3795
3796
3797
3798
3799
3800
3801
3802
3803
3804
3805
3806
3807
3808
3809
3810
3811
3812
3813
3814
3815
3816
3817
3818
3819
3820
3821
3822
3823
3824
3825
3826
3827
3828
3829
3830
3831
3832
3833
3834
3835
3836
3837
3838
3839
3840
3841
3842
3843
3844
3845
3846
3847
3848
3849
3850
3851
3852
3853
3854
3855
3856
3857
3858
3859
3860
3861
3862
3863
3864
3865
3866
3867
3868
3869
3870
3871
3872
3873
3874
3875
3876
3877
3878
3879
3880
3881
3882
3883
3884
3885
3886
3887
3888
3889
3890
3891
3892
3893
3894
3895
3896
3897
3898
3899
3900
3901
3902
3903
3904
3905
3906
3907
3908
3909
3910
3911
3912
3913
3914
3915
3916
3917
3918
3919
3920
3921
3922
3923
3924
3925
3926
3927
3928
3929
3930
3931
3932
3933
3934
3935
3936
3937
3938
3939
3940
3941
3942
3943
3944
3945
3946
3947
3948
3949
3950
3951
3952
3953
3954
3955
3956
3957
3958
3959
3960
3961
3962
3963
3964
3965
3966
3967
3968
3969
3970
3971
3972
3973
3974
3975
3976
3977
3978
3979
3980
3981
3982
3983
3984
3985
3986
3987
3988
3989
3990
3991
3992
3993
3994
3995
3996
3997
3998
3999
4000
4001
4002
4003
4004
4005
4006
4007
4008
4009
4010
4011
4012
4013
4014
4015
4016
4017
4018
4019
4020
4021
4022
4023
4024
4025
4026
4027
4028
4029
4030
4031
4032
4033
4034
4035
4036
4037
4038
4039
4040
4041
4042
4043
4044
4045
4046
4047
4048
4049
4050
4051
4052
4053
4054
4055
4056
4057
4058
4059
4060
4061
4062
4063
4064
4065
4066
4067
4068
4069
4070
4071
4072
4073
4074
4075
4076
4077
4078
4079
4080
4081
4082
4083
4084
4085
4086
4087
4088
4089
4090
4091
4092
4093
4094
4095
4096
4097
4098
4099
4100
4101
4102
4103
4104
4105
4106
4107
4108
4109
4110
4111
4112
4113
4114
4115
4116
4117
4118
4119
4120
4121
4122
4123
4124
4125
4126
4127
4128
4129
4130
4131
4132
4133
4134
4135
4136
4137
4138
4139
4140
4141
4142
4143
4144
4145
4146
4147
4148
4149
4150
4151
4152
4153
4154
4155
4156
4157
4158
4159
4160
4161
4162
4163
4164
4165
4166
4167
4168
4169
4170
4171
4172
4173
4174
4175
4176
4177
4178
4179
4180
4181
4182
4183
4184
4185
4186
4187
4188
4189
4190
4191
4192
4193
4194
4195
4196
4197
4198
4199
4200
4201
4202
4203
4204
4205
4206
4207
4208
4209
4210
4211
4212
4213
4214
4215
4216
4217
4218
4219
4220
4221
4222
4223
4224
4225
4226
4227
4228
4229
4230
4231
4232
4233
4234
4235
4236
4237
4238
4239
4240
4241
4242
4243
4244
4245
4246
4247
4248
4249
4250
4251
4252
4253
4254
4255
4256
4257
4258
4259
4260
4261
4262
4263
4264
4265
4266
4267
4268
4269
4270
4271
4272
4273
4274
4275
4276
4277
4278
4279
4280
4281
4282
4283
4284
4285
4286
4287
4288
4289
4290
4291
4292
4293
4294
4295
4296
4297
4298
4299
4300
4301
4302
4303
4304
4305
4306
4307
4308
4309
4310
4311
4312
4313
|
/*
* e-mail-reader.c
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) version 3.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with the program; if not, see <http://www.gnu.org/licenses/>
*
*
* Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
*
*/
#include "e-mail-reader.h"
#include <glib/gi18n.h>
#include <gdk/gdkkeysyms.h>
#ifdef HAVE_XFREE
#include <X11/XF86keysym.h>
#endif
#include "e-util/e-account-utils.h"
#include "e-util/e-charset.h"
#include "e-util/e-util.h"
#include "e-util/e-alert-dialog.h"
#include "e-util/gconf-bridge.h"
#include "shell/e-shell-utils.h"
#include "widgets/misc/e-popup-action.h"
#include "widgets/misc/e-menu-tool-action.h"
#include "mail/e-mail-backend.h"
#include "mail/e-mail-browser.h"
#include "mail/e-mail-display.h"
#include "mail/e-mail-enumtypes.h"
#include "mail/e-mail-reader-utils.h"
#include "mail/em-composer-utils.h"
#include "mail/em-event.h"
#include "mail/em-folder-selector.h"
#include "mail/em-folder-tree.h"
#include "mail/em-utils.h"
#include "mail/mail-autofilter.h"
#include "mail/mail-ops.h"
#include "mail/mail-mt.h"
#include "mail/mail-vfolder.h"
#include "mail/message-list.h"
#if HAVE_CLUTTER
#include <clutter/clutter.h>
#include <mx/mx.h>
#include <clutter-gtk/clutter-gtk.h>
#endif
#define E_MAIL_READER_GET_PRIVATE(obj) \
((EMailReaderPrivate *) g_object_get_qdata \
(G_OBJECT (obj), quark_private))
typedef struct _EMailReaderClosure EMailReaderClosure;
typedef struct _EMailReaderPrivate EMailReaderPrivate;
struct _EMailReaderClosure {
EMailReader *reader;
EActivity *activity;
gchar *message_uid;
};
struct _EMailReaderPrivate {
/* This timer runs when the user selects a single message. */
guint message_selected_timeout_id;
/* This allows message retrieval to be cancelled if another
* message is selected before the retrieval has completed. */
GCancellable *retrieving_message;
/* These flags work together to prevent message selection
* restoration after a folder switch from automatically
* marking the message as read. We only want that to
* happen when the -user- selects a message. */
guint folder_was_just_selected : 1;
guint restoring_message_selection : 1;
guint group_by_threads : 1;
};
enum {
CHANGED,
FOLDER_LOADED,
SHOW_SEARCH_BAR,
UPDATE_ACTIONS,
SHOW_FOLDER,
SHOW_PREVTAB,
SHOW_NEXTTAB,
CLOSE_TAB,
LAST_SIGNAL
};
/* Remembers the previously selected folder when transferring messages. */
static gchar *default_xfer_messages_uri;
static GQuark quark_private;
static GQuark quark_forward_style;
static GQuark quark_reply_style;
static guint signals[LAST_SIGNAL];
G_DEFINE_INTERFACE (EMailReader, e_mail_reader, G_TYPE_INITIALLY_UNOWNED)
static void
mail_reader_closure_free (EMailReaderClosure *closure)
{
if (closure->reader != NULL)
g_object_unref (closure->reader);
if (closure->activity != NULL)
g_object_unref (closure->activity);
g_free (closure->message_uid);
g_slice_free (EMailReaderClosure, closure);
}
static void
mail_reader_private_free (EMailReaderPrivate *priv)
{
if (priv->message_selected_timeout_id > 0)
g_source_remove (priv->message_selected_timeout_id);
if (priv->retrieving_message != NULL) {
g_cancellable_cancel (priv->retrieving_message);
g_object_unref (priv->retrieving_message);
priv->retrieving_message = 0;
}
g_slice_free (EMailReaderPrivate, priv);
}
static void
action_mail_add_sender_cb (GtkAction *action,
EMailReader *reader)
{
EShell *shell;
EMailBackend *backend;
EShellBackend *shell_backend;
CamelMessageInfo *info = NULL;
CamelFolder *folder;
GPtrArray *uids;
const gchar *address;
folder = e_mail_reader_get_folder (reader);
backend = e_mail_reader_get_backend (reader);
uids = e_mail_reader_get_selected_uids (reader);
if (uids->len != 1)
goto exit;
info = camel_folder_get_message_info (folder, uids->pdata[0]);
if (info == NULL)
goto exit;
address = camel_message_info_from (info);
if (address == NULL || *address == '\0')
goto exit;
/* XXX EBookShellBackend should be listening for this
* event. Kind of kludgey, but works for now. */
shell_backend = E_SHELL_BACKEND (backend);
shell = e_shell_backend_get_shell (shell_backend);
e_shell_event (shell, "contact-quick-add-email", (gpointer) address);
emu_remove_from_mail_cache_1 (address);
exit:
if (info)
camel_folder_free_message_info (folder, info);
em_utils_uids_free (uids);
}
static void
action_add_to_address_book_cb (GtkAction *action,
EMailReader *reader)
{
EShell *shell;
EMailBackend *backend;
EShellBackend *shell_backend;
EMFormatHTML *formatter;
CamelInternetAddress *cia;
EWebView *web_view;
CamelURL *curl;
const gchar *uri;
gchar *email;
/* This action is defined in EMailDisplay. */
backend = e_mail_reader_get_backend (reader);
formatter = e_mail_reader_get_formatter (reader);
web_view = em_format_html_get_web_view (formatter);
uri = e_web_view_get_selected_uri (web_view);
g_return_if_fail (uri != NULL);
curl = camel_url_new (uri, NULL);
g_return_if_fail (curl != NULL);
if (curl->path == NULL || *curl->path == '\0')
goto exit;
cia = camel_internet_address_new ();
if (camel_address_decode (CAMEL_ADDRESS (cia), curl->path) < 0) {
g_object_unref (cia);
goto exit;
}
email = camel_address_format (CAMEL_ADDRESS (cia));
/* XXX EBookShellBackend should be listening for this
* event. Kind of kludgey, but works for now. */
shell_backend = E_SHELL_BACKEND (backend);
shell = e_shell_backend_get_shell (shell_backend);
e_shell_event (shell, "contact-quick-add-email", email);
emu_remove_from_mail_cache_1 (curl->path);
g_object_unref (cia);
g_free (email);
exit:
camel_url_free (curl);
}
static void
action_mail_charset_cb (GtkRadioAction *action,
GtkRadioAction *current,
EMailReader *reader)
{
EMFormatHTML *formatter;
const gchar *charset;
if (action != current)
return;
formatter = e_mail_reader_get_formatter (reader);
charset = g_object_get_data (G_OBJECT (action), "charset");
/* Charset for "Default" action will be NULL. */
em_format_set_charset (EM_FORMAT (formatter), charset);
}
static void
action_mail_check_for_junk_cb (GtkAction *action,
EMailReader *reader)
{
EMailBackend *backend;
EMailSession *session;
CamelFolder *folder;
GPtrArray *uids;
folder = e_mail_reader_get_folder (reader);
backend = e_mail_reader_get_backend (reader);
uids = e_mail_reader_get_selected_uids (reader);
session = e_mail_backend_get_session (backend);
mail_filter_folder (
session, folder, uids,
E_FILTER_SOURCE_JUNKTEST, FALSE);
}
static void
action_mail_copy_cb (GtkAction *action,
EMailReader *reader)
{
CamelFolder *folder;
EMailBackend *backend;
EMailSession *session;
GtkWidget *folder_tree;
GtkWidget *dialog;
GtkWindow *window;
GPtrArray *uids;
const gchar *uri;
backend = e_mail_reader_get_backend (reader);
session = e_mail_backend_get_session (backend);
folder = e_mail_reader_get_folder (reader);
window = e_mail_reader_get_window (reader);
uids = e_mail_reader_get_selected_uids (reader);
folder_tree = em_folder_tree_new (session);
emu_restore_folder_tree_state (EM_FOLDER_TREE (folder_tree));
em_folder_tree_set_excluded (
EM_FOLDER_TREE (folder_tree),
EMFT_EXCLUDE_NOSELECT | EMFT_EXCLUDE_VIRTUAL |
EMFT_EXCLUDE_VTRASH);
dialog = em_folder_selector_new (
window, EM_FOLDER_TREE (folder_tree),
EM_FOLDER_SELECTOR_CAN_CREATE,
_("Copy to Folder"), NULL, _("C_opy"));
if (default_xfer_messages_uri != NULL)
em_folder_selector_set_selected (
EM_FOLDER_SELECTOR (dialog),
default_xfer_messages_uri);
if (gtk_dialog_run (GTK_DIALOG (dialog)) != GTK_RESPONSE_OK)
goto exit;
uri = em_folder_selector_get_selected_uri (
EM_FOLDER_SELECTOR (dialog));
g_free (default_xfer_messages_uri);
default_xfer_messages_uri = g_strdup (uri);
if (uri != NULL) {
mail_transfer_messages (
session, folder, uids,
FALSE, uri, 0, NULL, NULL);
uids = NULL;
}
exit:
if (uids != NULL)
em_utils_uids_free (uids);
gtk_widget_destroy (dialog);
}
static void
action_mail_delete_cb (GtkAction *action,
EMailReader *reader)
{
guint32 mask = CAMEL_MESSAGE_SEEN | CAMEL_MESSAGE_DELETED;
guint32 set = CAMEL_MESSAGE_SEEN | CAMEL_MESSAGE_DELETED;
if (!e_mail_reader_confirm_delete (reader))
return;
/* FIXME Verify all selected messages are deletable.
* But handle it by disabling this action. */
if (e_mail_reader_mark_selected (reader, mask, set) == 1)
e_mail_reader_select_next_message (reader, FALSE);
}
static void
action_mail_filter_on_mailing_list_cb (GtkAction *action,
EMailReader *reader)
{
e_mail_reader_create_filter_from_selected (reader, AUTO_MLIST);
}
static void
action_mail_filter_on_recipients_cb (GtkAction *action,
EMailReader *reader)
{
e_mail_reader_create_filter_from_selected (reader, AUTO_TO);
}
static void
action_mail_filter_on_sender_cb (GtkAction *action,
EMailReader *reader)
{
e_mail_reader_create_filter_from_selected (reader, AUTO_FROM);
}
static void
action_mail_filter_on_subject_cb (GtkAction *action,
EMailReader *reader)
{
e_mail_reader_create_filter_from_selected (reader, AUTO_SUBJECT);
}
static void
action_mail_filters_apply_cb (GtkAction *action,
EMailReader *reader)
{
EMailBackend *backend;
EMailSession *session;
CamelFolder *folder;
GPtrArray *uids;
folder = e_mail_reader_get_folder (reader);
backend = e_mail_reader_get_backend (reader);
uids = e_mail_reader_get_selected_uids (reader);
session = e_mail_backend_get_session (backend);
mail_filter_folder (
session, folder, uids,
E_FILTER_SOURCE_DEMAND, FALSE);
}
static void
action_mail_remove_attachments_cb (GtkAction *action, EMailReader *reader)
{
CamelFolder *folder;
GPtrArray *uids;
folder = e_mail_reader_get_folder (reader);
uids = e_mail_reader_get_selected_uids (reader);
mail_remove_attachments (folder, uids);
}
static gchar *
get_message_checksum (CamelFolder *folder, CamelMimeMessage *msg)
{
static const GChecksumType duplicate_csum = G_CHECKSUM_SHA256;
CamelDataWrapper *content;
CamelStream *mem;
GByteArray *buffer;
gchar *digest = NULL;
if (!msg)
return NULL;
/* get message contents */
content = camel_medium_get_content ((CamelMedium *) msg);
if (!content)
return NULL;
/* calculate checksum */
mem = camel_stream_mem_new ();
camel_data_wrapper_decode_to_stream_sync (content, mem, NULL, NULL);
buffer = camel_stream_mem_get_byte_array (CAMEL_STREAM_MEM (mem));
if (buffer)
digest = g_compute_checksum_for_data (
duplicate_csum, buffer->data, buffer->len);
g_object_unref (mem);
return digest;
}
static gboolean
message_is_duplicated (GHashTable *messages, guint64 id, gchar *digest)
{
gchar *hash_digest = g_hash_table_lookup (messages, &id);
if (!hash_digest)
return FALSE;
return g_str_equal (digest, hash_digest);
}
static void
remove_duplicates_got_messages_cb (CamelFolder *folder,
GPtrArray *uids,
GPtrArray *msgs,
gpointer data)
{
EMailReader *reader = data;
GtkWindow *parent;
GHashTable *messages;
GPtrArray *dups;
gint ii;
g_return_if_fail (CAMEL_IS_FOLDER (folder));
g_return_if_fail (uids != NULL);
g_return_if_fail (msgs != NULL);
g_return_if_fail (msgs->len <= uids->len);
g_return_if_fail (E_IS_MAIL_READER (reader));
parent = e_mail_reader_get_window (reader);
messages = g_hash_table_new_full (
g_int_hash, g_int_equal, g_free, g_free);
dups = g_ptr_array_new ();
for (ii = 0; ii < msgs->len; ii++) {
CamelMessageInfo *msg_info;
const CamelSummaryMessageID *mid;
guint32 flags;
msg_info = camel_folder_get_message_info (
folder, uids->pdata[ii]);
mid = camel_message_info_message_id (msg_info);
flags = camel_message_info_flags (msg_info);
if (!(flags & CAMEL_MESSAGE_DELETED)) {
gchar *digest;
digest = get_message_checksum (folder, msgs->pdata[ii]);
if (digest != NULL) {
if (message_is_duplicated (
messages, mid->id.id, digest)) {
g_ptr_array_add (dups, uids->pdata[ii]);
g_free (digest);
} else {
guint64 *id;
id = g_new0 (guint64, 1);
*id = mid->id.id;
g_hash_table_insert (
messages, id, digest);
}
}
}
camel_message_info_free (msg_info);
}
if (dups->len == 0) {
em_utils_prompt_user (
parent, NULL, "mail:info-no-remove-duplicates",
camel_folder_get_name (folder), NULL);
} else {
gchar *msg = g_strdup_printf (ngettext (
/* Translators: %s is replaced with a folder name
%d with count of duplicate messages. */
"Folder '%s' contains %d duplicate message. "
"Are you sure you want to delete it?",
"Folder '%s' contains %d duplicate messages. "
"Are you sure you want to delete them?",
dups->len),
camel_folder_get_name (folder), dups->len);
if (em_utils_prompt_user (
parent, NULL, "mail:ask-remove-duplicates", msg, NULL)) {
camel_folder_freeze (folder);
for (ii = 0; ii < dups->len; ii++)
camel_folder_delete_message (
folder, g_ptr_array_index (dups, ii));
camel_folder_thaw (folder);
}
g_free (msg);
}
g_hash_table_destroy (messages);
g_ptr_array_free (dups, TRUE);
}
static void
action_mail_remove_duplicates (GtkAction *action, EMailReader *reader)
{
MessageList *message_list;
CamelFolder *folder;
GPtrArray *uids;
message_list = MESSAGE_LIST (e_mail_reader_get_message_list (reader));
uids = message_list_get_selected (message_list);
folder = message_list->folder;
if (!uids || uids->len <= 1) {
if (uids)
em_utils_uids_free (uids);
} else {
/* the function itself is freeing uids */
mail_get_messages (
folder, uids,
remove_duplicates_got_messages_cb, reader);
}
}
static void
action_mail_find_cb (GtkAction *action,
EMailReader *reader)
{
e_mail_reader_show_search_bar (reader);
}
static void
action_mail_flag_clear_cb (GtkAction *action,
EMailReader *reader)
{
EMFormatHTML *formatter;
CamelFolder *folder;
GtkWindow *window;
GPtrArray *uids;
folder = e_mail_reader_get_folder (reader);
formatter = e_mail_reader_get_formatter (reader);
uids = e_mail_reader_get_selected_uids (reader);
window = e_mail_reader_get_window (reader);
em_utils_flag_for_followup_clear (window, folder, uids);
em_format_queue_redraw (EM_FORMAT (formatter));
}
static void
action_mail_flag_completed_cb (GtkAction *action,
EMailReader *reader)
{
EMFormatHTML *formatter;
CamelFolder *folder;
GtkWindow *window;
GPtrArray *uids;
folder = e_mail_reader_get_folder (reader);
formatter = e_mail_reader_get_formatter (reader);
uids = e_mail_reader_get_selected_uids (reader);
window = e_mail_reader_get_window (reader);
em_utils_flag_for_followup_completed (window, folder, uids);
em_format_queue_redraw (EM_FORMAT (formatter));
}
static void
action_mail_flag_for_followup_cb (GtkAction *action,
EMailReader *reader)
{
CamelFolder *folder;
GPtrArray *uids;
folder = e_mail_reader_get_folder (reader);
uids = e_mail_reader_get_selected_uids (reader);
em_utils_flag_for_followup (reader, folder, uids);
}
static void
check_close_browser_reader (EMailReader *reader)
{
GConfClient *client;
gchar *value;
gboolean close_it = FALSE;
/* only allow closing of a mail browser and nothing else */
if (!E_IS_MAIL_BROWSER (reader))
return;
client = gconf_client_get_default ();
value = gconf_client_get_string (
client, "/apps/evolution/mail/prompts/reply_close_browser", NULL);
if (value && g_str_equal (value, "always")) {
close_it = TRUE;
} else if (!value || !g_str_equal (value, "never")) {
GtkWidget *dialog;
GtkWindow *parent;
gint response;
EShell *shell;
EMailBackend *backend;
EShellBackend *shell_backend;
backend = e_mail_reader_get_backend (reader);
shell_backend = E_SHELL_BACKEND (backend);
shell = e_shell_backend_get_shell (shell_backend);
parent = e_shell_get_active_window (shell);
if (!parent)
parent = e_mail_reader_get_window (reader);
dialog = e_alert_dialog_new_for_args (
parent, "mail:ask-reply-close-browser", NULL);
response = gtk_dialog_run (GTK_DIALOG (dialog));
gtk_widget_destroy (dialog);
close_it = response == GTK_RESPONSE_YES || response == GTK_RESPONSE_OK;
if (response == GTK_RESPONSE_OK || response == GTK_RESPONSE_CANCEL)
gconf_client_set_string (
client, "/apps/evolution/mail/prompts/reply_close_browser",
response == GTK_RESPONSE_OK ? "always" : "never", NULL);
}
g_free (value);
if (close_it)
gtk_widget_destroy (GTK_WIDGET (reader));
g_object_unref (client);
}
static void
action_mail_forward_cb (GtkAction *action,
EMailReader *reader)
{
EShell *shell;
EMailBackend *backend;
EShellBackend *shell_backend;
CamelFolder *folder;
GtkWindow *window;
GPtrArray *uids;
const gchar *folder_uri;
backend = e_mail_reader_get_backend (reader);
folder = e_mail_reader_get_folder (reader);
folder_uri = e_mail_reader_get_folder_uri (reader);
uids = e_mail_reader_get_selected_uids (reader);
window = e_mail_reader_get_window (reader);
g_return_if_fail (uids != NULL);
shell_backend = E_SHELL_BACKEND (backend);
shell = e_shell_backend_get_shell (shell_backend);
if (em_utils_ask_open_many (window, uids->len))
em_utils_forward_messages (
shell, folder, uids, folder_uri,
e_mail_reader_get_forward_style (reader));
else
em_utils_uids_free (uids);
check_close_browser_reader (reader);
}
static void
action_mail_forward_attached_cb (GtkAction *action,
EMailReader *reader)
{
EShell *shell;
EMailBackend *backend;
EShellBackend *shell_backend;
CamelFolder *folder;
GtkWindow *window;
GPtrArray *uids;
const gchar *folder_uri;
backend = e_mail_reader_get_backend (reader);
folder = e_mail_reader_get_folder (reader);
folder_uri = e_mail_reader_get_folder_uri (reader);
uids = e_mail_reader_get_selected_uids (reader);
window = e_mail_reader_get_window (reader);
g_return_if_fail (uids != NULL);
shell_backend = E_SHELL_BACKEND (backend);
shell = e_shell_backend_get_shell (shell_backend);
if (em_utils_ask_open_many (window, uids->len))
em_utils_forward_messages (
shell, folder, uids, folder_uri,
E_MAIL_FORWARD_STYLE_ATTACHED);
else
em_utils_uids_free (uids);
check_close_browser_reader (reader);
}
static void
action_mail_forward_inline_cb (GtkAction *action,
EMailReader *reader)
{
EShell *shell;
EMailBackend *backend;
EShellBackend *shell_backend;
CamelFolder *folder;
GtkWindow *window;
GPtrArray *uids;
const gchar *folder_uri;
backend = e_mail_reader_get_backend (reader);
folder = e_mail_reader_get_folder (reader);
folder_uri = e_mail_reader_get_folder_uri (reader);
uids = e_mail_reader_get_selected_uids (reader);
window = e_mail_reader_get_window (reader);
g_return_if_fail (uids != NULL);
shell_backend = E_SHELL_BACKEND (backend);
shell = e_shell_backend_get_shell (shell_backend);
if (em_utils_ask_open_many (window, uids->len))
em_utils_forward_messages (
shell, folder, uids, folder_uri,
E_MAIL_FORWARD_STYLE_INLINE);
else
em_utils_uids_free (uids);
check_close_browser_reader (reader);
}
static void
action_mail_forward_quoted_cb (GtkAction *action,
EMailReader *reader)
{
EShell *shell;
EMailBackend *backend;
EShellBackend *shell_backend;
CamelFolder *folder;
GtkWindow *window;
GPtrArray *uids;
const gchar *folder_uri;
backend = e_mail_reader_get_backend (reader);
folder = e_mail_reader_get_folder (reader);
folder_uri = e_mail_reader_get_folder_uri (reader);
uids = e_mail_reader_get_selected_uids (reader);
window = e_mail_reader_get_window (reader);
g_return_if_fail (uids != NULL);
shell_backend = E_SHELL_BACKEND (backend);
shell = e_shell_backend_get_shell (shell_backend);
if (em_utils_ask_open_many (window, uids->len))
em_utils_forward_messages (
shell, folder, uids, folder_uri,
E_MAIL_FORWARD_STYLE_QUOTED);
else
em_utils_uids_free (uids);
check_close_browser_reader (reader);
}
static void
action_mail_load_images_cb (GtkAction *action,
EMailReader *reader)
{
EMFormatHTML *formatter;
formatter = e_mail_reader_get_formatter (reader);
em_format_html_load_images (formatter);
}
static void
action_mail_mark_important_cb (GtkAction *action,
EMailReader *reader)
{
guint32 mask = CAMEL_MESSAGE_FLAGGED | CAMEL_MESSAGE_DELETED;
guint32 set = CAMEL_MESSAGE_FLAGGED;
e_mail_reader_mark_selected (reader, mask, set);
}
static void
action_mail_mark_junk_cb (GtkAction *action,
EMailReader *reader)
{
guint32 mask = CAMEL_MESSAGE_SEEN | CAMEL_MESSAGE_JUNK |
CAMEL_MESSAGE_NOTJUNK | CAMEL_MESSAGE_JUNK_LEARN;
guint32 set = CAMEL_MESSAGE_SEEN | CAMEL_MESSAGE_JUNK |
CAMEL_MESSAGE_JUNK_LEARN;
if (e_mail_reader_mark_selected (reader, mask, set) == 1)
e_mail_reader_select_next_message (reader, TRUE);
}
static void
action_mail_mark_notjunk_cb (GtkAction *action,
EMailReader *reader)
{
guint32 mask = CAMEL_MESSAGE_JUNK | CAMEL_MESSAGE_NOTJUNK |
CAMEL_MESSAGE_JUNK_LEARN;
guint32 set = CAMEL_MESSAGE_NOTJUNK | CAMEL_MESSAGE_JUNK_LEARN;
if (e_mail_reader_mark_selected (reader, mask, set) == 1)
e_mail_reader_select_next_message (reader, TRUE);
}
static void
action_mail_mark_read_cb (GtkAction *action,
EMailReader *reader)
{
guint32 mask = CAMEL_MESSAGE_SEEN;
guint32 set = CAMEL_MESSAGE_SEEN;
e_mail_reader_mark_selected (reader, mask, set);
}
static void
action_mail_mark_unimportant_cb (GtkAction *action,
EMailReader *reader)
{
guint32 mask = CAMEL_MESSAGE_FLAGGED;
guint32 set = 0;
e_mail_reader_mark_selected (reader, mask, set);
}
static void
action_mail_mark_unread_cb (GtkAction *action,
EMailReader *reader)
{
GtkWidget *message_list;
EMFolderTreeModel *model;
const gchar *folder_uri;
guint32 mask = CAMEL_MESSAGE_SEEN | CAMEL_MESSAGE_DELETED;
guint32 set = 0;
guint n_marked;
message_list = e_mail_reader_get_message_list (reader);
n_marked = e_mail_reader_mark_selected (reader, mask, set);
if (MESSAGE_LIST (message_list)->seen_id != 0) {
g_source_remove (MESSAGE_LIST (message_list)->seen_id);
MESSAGE_LIST (message_list)->seen_id = 0;
}
/* Notify the tree model that the user has marked messages as
* unread so it doesn't mistake the event as new mail arriving. */
model = em_folder_tree_model_get_default ();
folder_uri = e_mail_reader_get_folder_uri (reader);
em_folder_tree_model_user_marked_unread (model, folder_uri, n_marked);
}
static void
action_mail_message_edit_cb (GtkAction *action,
EMailReader *reader)
{
EShell *shell;
EMailBackend *backend;
EShellBackend *shell_backend;
CamelFolder *folder;
GPtrArray *uids;
gboolean replace;
backend = e_mail_reader_get_backend (reader);
folder = e_mail_reader_get_folder (reader);
uids = e_mail_reader_get_selected_uids (reader);
shell_backend = E_SHELL_BACKEND (backend);
shell = e_shell_backend_get_shell (shell_backend);
replace = em_utils_folder_is_drafts (folder);
em_utils_edit_messages (shell, folder, uids, replace);
}
static void
action_mail_message_new_cb (GtkAction *action,
EMailReader *reader)
{
EShell *shell;
EMailBackend *backend;
EShellBackend *shell_backend;
const gchar *folder_uri;
backend = e_mail_reader_get_backend (reader);
folder_uri = e_mail_reader_get_folder_uri (reader);
shell_backend = E_SHELL_BACKEND (backend);
shell = e_shell_backend_get_shell (shell_backend);
em_utils_compose_new_message (shell, folder_uri);
}
static void
action_mail_message_open_cb (GtkAction *action,
EMailReader *reader)
{
e_mail_reader_open_selected_mail (reader);
}
static void
action_mail_move_cb (GtkAction *action,
EMailReader *reader)
{
CamelFolder *folder;
EMailBackend *backend;
EMailSession *session;
GtkWidget *folder_tree;
GtkWidget *dialog;
GtkWindow *window;
GPtrArray *uids;
const gchar *uri;
backend = e_mail_reader_get_backend (reader);
folder = e_mail_reader_get_folder (reader);
uids = e_mail_reader_get_selected_uids (reader);
window = e_mail_reader_get_window (reader);
session = e_mail_backend_get_session (backend);
folder_tree = em_folder_tree_new (session);
emu_restore_folder_tree_state (EM_FOLDER_TREE (folder_tree));
em_folder_tree_set_excluded (
EM_FOLDER_TREE (folder_tree),
EMFT_EXCLUDE_NOSELECT | EMFT_EXCLUDE_VIRTUAL |
EMFT_EXCLUDE_VTRASH);
dialog = em_folder_selector_new (
window, EM_FOLDER_TREE (folder_tree),
EM_FOLDER_SELECTOR_CAN_CREATE,
_("Move to Folder"), NULL, _("_Move"));
if (default_xfer_messages_uri != NULL)
em_folder_selector_set_selected (
EM_FOLDER_SELECTOR (dialog),
default_xfer_messages_uri);
if (gtk_dialog_run (GTK_DIALOG (dialog)) != GTK_RESPONSE_OK)
goto exit;
uri = em_folder_selector_get_selected_uri (
EM_FOLDER_SELECTOR (dialog));
g_free (default_xfer_messages_uri);
default_xfer_messages_uri = g_strdup (uri);
if (uri != NULL) {
mail_transfer_messages (
session, folder, uids,
TRUE, uri, 0, NULL, NULL);
uids = NULL;
}
exit:
if (uids != NULL)
em_utils_uids_free (uids);
gtk_widget_destroy (dialog);
}
static void
action_mail_folder_cb (GtkAction *action,
EMailReader *reader)
{
g_signal_emit (reader, signals[SHOW_FOLDER], 0);
}
static void
action_mail_nexttab_cb (GtkAction *action,
EMailReader *reader)
{
g_signal_emit (reader, signals[SHOW_NEXTTAB], 0);
}
static void
action_mail_prevtab_cb (GtkAction *action,
EMailReader *reader)
{
g_signal_emit (reader, signals[SHOW_PREVTAB], 0);
}
static void
action_mail_closetab_cb (GtkAction *action,
EMailReader *reader)
{
g_signal_emit (reader, signals[CLOSE_TAB], 0);
}
static void
action_mail_next_cb (GtkAction *action,
EMailReader *reader)
{
GtkWidget *message_list;
MessageListSelectDirection direction;
guint32 flags, mask;
#if HAVE_CLUTTER
ClutterActor *actor;
#endif
direction = MESSAGE_LIST_SELECT_NEXT;
flags = 0;
mask = 0;
message_list = e_mail_reader_get_message_list (reader);
#if HAVE_CLUTTER
actor = g_object_get_data (G_OBJECT (message_list), "preview-actor");
if (actor != NULL) {
clutter_actor_set_opacity (actor, 0);
clutter_actor_animate (
actor, CLUTTER_EASE_OUT_SINE,
500, "opacity", 255, NULL);
}
#endif
message_list_select (
MESSAGE_LIST (message_list), direction, flags, mask);
}
static void
action_mail_next_important_cb (GtkAction *action,
EMailReader *reader)
{
GtkWidget *message_list;
MessageListSelectDirection direction;
guint32 flags, mask;
direction = MESSAGE_LIST_SELECT_NEXT | MESSAGE_LIST_SELECT_WRAP;
flags = CAMEL_MESSAGE_FLAGGED;
mask = CAMEL_MESSAGE_FLAGGED;
message_list = e_mail_reader_get_message_list (reader);
message_list_select (
MESSAGE_LIST (message_list), direction, flags, mask);
}
static void
action_mail_next_thread_cb (GtkAction *action,
EMailReader *reader)
{
GtkWidget *message_list;
message_list = e_mail_reader_get_message_list (reader);
message_list_select_next_thread (MESSAGE_LIST (message_list));
}
static void
action_mail_next_unread_cb (GtkAction *action,
EMailReader *reader)
{
GtkWidget *message_list;
MessageListSelectDirection direction;
guint32 flags, mask;
direction = MESSAGE_LIST_SELECT_NEXT | MESSAGE_LIST_SELECT_WRAP;
flags = 0;
mask = CAMEL_MESSAGE_SEEN;
message_list = e_mail_reader_get_message_list (reader);
message_list_select (
MESSAGE_LIST (message_list), direction, flags, mask);
}
static void
action_mail_previous_cb (GtkAction *action,
EMailReader *reader)
{
GtkWidget *message_list;
MessageListSelectDirection direction;
guint32 flags, mask;
direction = MESSAGE_LIST_SELECT_PREVIOUS;
flags = 0;
mask = 0;
message_list = e_mail_reader_get_message_list (reader);
message_list_select (
MESSAGE_LIST (message_list), direction, flags, mask);
}
static void
action_mail_previous_important_cb (GtkAction *action,
EMailReader *reader)
{
GtkWidget *message_list;
MessageListSelectDirection direction;
guint32 flags, mask;
direction = MESSAGE_LIST_SELECT_PREVIOUS | MESSAGE_LIST_SELECT_WRAP;
flags = CAMEL_MESSAGE_FLAGGED;
mask = CAMEL_MESSAGE_FLAGGED;
message_list = e_mail_reader_get_message_list (reader);
message_list_select (
MESSAGE_LIST (message_list), direction, flags, mask);
}
static void
action_mail_previous_thread_cb (GtkAction *action,
EMailReader *reader)
{
GtkWidget *message_list;
message_list = e_mail_reader_get_message_list (reader);
message_list_select_prev_thread (MESSAGE_LIST (message_list));
}
static void
action_mail_previous_unread_cb (GtkAction *action,
EMailReader *reader)
{
GtkWidget *message_list;
MessageListSelectDirection direction;
guint32 flags, mask;
direction = MESSAGE_LIST_SELECT_PREVIOUS | MESSAGE_LIST_SELECT_WRAP;
flags = 0;
mask = CAMEL_MESSAGE_SEEN;
message_list = e_mail_reader_get_message_list (reader);
message_list_select (
MESSAGE_LIST (message_list), direction, flags, mask);
}
static void
action_mail_print_cb (GtkAction *action,
EMailReader *reader)
{
GtkPrintOperationAction print_action;
print_action = GTK_PRINT_OPERATION_ACTION_PRINT_DIALOG;
e_mail_reader_print (reader, print_action);
}
static void
action_mail_print_preview_cb (GtkAction *action,
EMailReader *reader)
{
GtkPrintOperationAction print_action;
print_action = GTK_PRINT_OPERATION_ACTION_PREVIEW;
e_mail_reader_print (reader, print_action);
}
static void
action_mail_redirect_cb (GtkAction *action,
EMailReader *reader)
{
EShell *shell;
EMailBackend *backend;
EShellBackend *shell_backend;
GtkWidget *message_list;
CamelFolder *folder;
const gchar *uid;
backend = e_mail_reader_get_backend (reader);
folder = e_mail_reader_get_folder (reader);
message_list = e_mail_reader_get_message_list (reader);
uid = MESSAGE_LIST (message_list)->cursor_uid;
g_return_if_fail (uid != NULL);
shell_backend = E_SHELL_BACKEND (backend);
shell = e_shell_backend_get_shell (shell_backend);
em_utils_redirect_message_by_uid (shell, folder, uid);
check_close_browser_reader (reader);
}
static void
action_mail_reply_all_check (CamelFolder *folder,
const gchar *uid,
CamelMimeMessage *message,
gpointer user_data)
{
EMailReader *reader = user_data;
CamelInternetAddress *to, *cc;
gint recip_count = 0;
EMailReplyType type = E_MAIL_REPLY_TO_ALL;
if (!message)
return;
/* get_message_free () will unref the message, so we need to take an
extra ref for e_mail_reader_reply_to_message () to own. */
g_object_ref (message);
to = camel_mime_message_get_recipients (message, CAMEL_RECIPIENT_TYPE_TO);
cc = camel_mime_message_get_recipients (message, CAMEL_RECIPIENT_TYPE_CC);
recip_count = camel_address_length (CAMEL_ADDRESS (to));
recip_count += camel_address_length (CAMEL_ADDRESS (cc));
if (recip_count >= 15) {
GtkWidget *dialog;
GtkWidget *check;
GtkWidget *container;
gint response;
dialog = e_alert_dialog_new_for_args (
e_mail_reader_get_window (reader),
"mail:ask-reply-many-recips", NULL);
container = e_alert_dialog_get_content_area (
E_ALERT_DIALOG (dialog));
/* Check buttons */
check = gtk_check_button_new_with_mnemonic (
_("_Do not ask me again."));
gtk_box_pack_start (
GTK_BOX (container), check, FALSE, FALSE, 0);
gtk_widget_show (check);
response = gtk_dialog_run (GTK_DIALOG (dialog));
if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (check))) {
GConfClient *client;
const gchar *key;
client = gconf_client_get_default ();
key = "/apps/evolution/mail/prompts/reply_many_recips";
gconf_client_set_bool (client, key, FALSE, NULL);
g_object_unref (client);
}
gtk_widget_destroy (dialog);
switch (response) {
case GTK_RESPONSE_NO:
type = E_MAIL_REPLY_TO_SENDER;
break;
case GTK_RESPONSE_CANCEL:
case GTK_RESPONSE_DELETE_EVENT:
g_object_unref (message);
return;
default:
break;
}
}
e_mail_reader_reply_to_message (reader, message, type);
check_close_browser_reader (reader);
}
static void
action_mail_reply_all_cb (GtkAction *action,
EMailReader *reader)
{
GConfClient *client;
const gchar *key;
guint32 state;
gboolean ask;
state = e_mail_reader_check_state (reader);
client = gconf_client_get_default ();
key = "/apps/evolution/mail/prompts/reply_many_recips";
ask = gconf_client_get_bool (client, key, NULL);
g_object_unref (client);
if (ask && !(state & E_MAIL_READER_SELECTION_IS_MAILING_LIST)) {
CamelMimeMessage *message = NULL;
EWebView *web_view;
EMFormatHTML *formatter;
formatter = e_mail_reader_get_formatter (reader);
web_view = em_format_html_get_web_view (formatter);
if (gtk_widget_get_mapped (GTK_WIDGET (web_view)))
message = CAMEL_MIME_MESSAGE (EM_FORMAT (formatter)->message);
if (!message) {
CamelFolder *folder;
GtkWidget *message_list;
gchar *uid;
folder = e_mail_reader_get_folder (reader);
message_list = e_mail_reader_get_message_list (reader);
uid = MESSAGE_LIST (message_list)->cursor_uid;
g_return_if_fail (uid != NULL);
mail_get_message (
folder, uid, action_mail_reply_all_check,
reader, mail_msg_unordered_push);
return;
}
action_mail_reply_all_check (NULL, NULL, message, reader);
return;
}
e_mail_reader_reply_to_message (reader, NULL, E_MAIL_REPLY_TO_ALL);
check_close_browser_reader (reader);
}
static void
action_mail_reply_group_cb (GtkAction *action,
EMailReader *reader)
{
GConfClient *client;
gboolean reply_list;
const gchar *key;
guint32 state;
state = e_mail_reader_check_state (reader);
client = gconf_client_get_default ();
key = "/apps/evolution/mail/composer/group_reply_to_list";
reply_list = gconf_client_get_bool (client, key, NULL);
g_object_unref (client);
if (reply_list && (state & E_MAIL_READER_SELECTION_IS_MAILING_LIST)) {
e_mail_reader_reply_to_message (
reader, NULL, E_MAIL_REPLY_TO_LIST);
check_close_browser_reader (reader);
} else
action_mail_reply_all_cb (action, reader);
}
static void
action_mail_reply_list_cb (GtkAction *action,
EMailReader *reader)
{
e_mail_reader_reply_to_message (reader, NULL, E_MAIL_REPLY_TO_LIST);
check_close_browser_reader (reader);
}
static void
action_mail_reply_sender_check (CamelFolder *folder,
const gchar *uid,
CamelMimeMessage *message,
gpointer user_data)
{
EMailReader *reader = user_data;
GConfClient *client;
EMailReplyType type = E_MAIL_REPLY_TO_SENDER;
const gchar *key;
gboolean ask_ignore_list_reply_to;
gboolean ask_list_reply_to;
gboolean munged_list_message;
if (!message)
return;
client = gconf_client_get_default ();
key = "/apps/evolution/mail/composer/ignore_list_reply_to";
ask_ignore_list_reply_to = gconf_client_get_bool (client, key, NULL);
key = "/apps/evolution/mail/prompts/list_reply_to";
ask_list_reply_to = gconf_client_get_bool (client, key, NULL);
munged_list_message = em_utils_is_munged_list_message (message);
/* get_message_free () will unref the message, so we need to take an
extra ref for e_mail_reader_reply_to_message () to own. */
g_object_ref (message);
/* Don't do the "Are you sure you want to reply in private?" pop-up if
it's a Reply-To: munged list message... unless we're ignoring munging */
if (ask_ignore_list_reply_to || !munged_list_message) {
GtkWidget *dialog;
GtkWidget *check;
GtkWidget *container;
gint response;
dialog = e_alert_dialog_new_for_args (
e_mail_reader_get_window (reader),
"mail:ask-list-private-reply", NULL);
container = e_alert_dialog_get_content_area (
E_ALERT_DIALOG (dialog));
/* Check buttons */
check = gtk_check_button_new_with_mnemonic (
_("_Do not ask me again."));
gtk_box_pack_start (
GTK_BOX (container), check, FALSE, FALSE, 0);
gtk_widget_show (check);
response = gtk_dialog_run (GTK_DIALOG (dialog));
if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (check)))
gconf_client_set_bool (
client, "/apps/evolution/mail/prompts/private_list_reply", FALSE, NULL);
gtk_widget_destroy (dialog);
if (response == GTK_RESPONSE_YES)
type = E_MAIL_REPLY_TO_ALL;
else if (response == GTK_RESPONSE_OK)
type = E_MAIL_REPLY_TO_LIST;
else if (response == GTK_RESPONSE_CANCEL || response == GTK_RESPONSE_DELETE_EVENT) {
g_object_unref (message);
goto exit;
}
} else if (ask_list_reply_to) {
GtkWidget *dialog;
GtkWidget *container;
GtkWidget *check_again;
GtkWidget *check_always_ignore;
gint response;
dialog = e_alert_dialog_new_for_args (
e_mail_reader_get_window (reader),
"mail:ask-list-honour-reply-to", NULL);
container = e_alert_dialog_get_content_area (
E_ALERT_DIALOG (dialog));
check_again = gtk_check_button_new_with_mnemonic (
_("_Do not ask me again."));
gtk_box_pack_start (
GTK_BOX (container), check_again, FALSE, FALSE, 0);
gtk_widget_show (check_again);
check_always_ignore = gtk_check_button_new_with_mnemonic (
_("_Always ignore Reply-To: for mailing lists."));
gtk_box_pack_start (
GTK_BOX (container), check_always_ignore,
FALSE, FALSE, 0);
gtk_widget_show (check_always_ignore);
response = gtk_dialog_run (GTK_DIALOG (dialog));
if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (check_again)))
gconf_client_set_bool (
client, "/apps/evolution/mail/prompts/list_reply_to", FALSE, NULL);
gconf_client_set_bool (
client, "/apps/evolution/mail/composer/ignore_list_reply_to",
gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (check_always_ignore)),
NULL);
gtk_widget_destroy (dialog);
switch (response) {
case GTK_RESPONSE_NO:
type = E_MAIL_REPLY_TO_FROM;
break;
case GTK_RESPONSE_OK:
type = E_MAIL_REPLY_TO_LIST;
break;
case GTK_RESPONSE_CANCEL:
case GTK_RESPONSE_DELETE_EVENT:
g_object_unref (message);
goto exit;
default:
break;
}
}
e_mail_reader_reply_to_message (reader, message, type);
check_close_browser_reader (reader);
exit:
g_object_unref (client);
}
static void
action_mail_reply_sender_cb (GtkAction *action,
EMailReader *reader)
{
GConfClient *client;
gboolean ask_list_reply_to;
gboolean ask_private_list_reply;
const gchar *key;
guint32 state;
state = e_mail_reader_check_state (reader);
client = gconf_client_get_default ();
key = "/apps/evolution/mail/prompts/list_reply_to";
ask_list_reply_to = gconf_client_get_bool (client, key, NULL);
key = "/apps/evolution/mail/prompts/private_list_reply";
ask_private_list_reply = gconf_client_get_bool (client, key, NULL);
g_object_unref (client);
if ((ask_private_list_reply || ask_list_reply_to) &&
state & E_MAIL_READER_SELECTION_IS_MAILING_LIST) {
CamelMimeMessage *message = NULL;
EWebView *web_view;
EMFormatHTML *formatter;
formatter = e_mail_reader_get_formatter (reader);
web_view = em_format_html_get_web_view (formatter);
if (gtk_widget_get_mapped (GTK_WIDGET (web_view)))
message = CAMEL_MIME_MESSAGE (EM_FORMAT (formatter)->message);
if (!message) {
CamelFolder *folder;
GtkWidget *message_list;
gchar *uid;
folder = e_mail_reader_get_folder (reader);
message_list = e_mail_reader_get_message_list (reader);
uid = MESSAGE_LIST (message_list)->cursor_uid;
g_return_if_fail (uid != NULL);
mail_get_message (
folder, uid, action_mail_reply_sender_check,
reader, mail_msg_unordered_push);
return;
}
action_mail_reply_sender_check (NULL, NULL, message, reader);
return;
}
e_mail_reader_reply_to_message (reader, NULL, E_MAIL_REPLY_TO_SENDER);
check_close_browser_reader (reader);
}
static void
action_mail_save_as_cb (GtkAction *action,
EMailReader *reader)
{
EShell *shell;
EMailBackend *backend;
EShellBackend *shell_backend;
CamelMessageInfo *info;
CamelFolder *folder;
GPtrArray *uids;
GFile *file;
const gchar *title;
gchar *suggestion = NULL;
gchar *uri;
folder = e_mail_reader_get_folder (reader);
backend = e_mail_reader_get_backend (reader);
uids = e_mail_reader_get_selected_uids (reader);
g_return_if_fail (uids->len > 0);
title = ngettext ("Save Message", "Save Messages", uids->len);
/* Suggest as a filename the subject of the first message. */
info = camel_folder_get_message_info (folder, uids->pdata[0]);
if (info != NULL) {
const gchar *subject = camel_message_info_subject (info);
if (subject)
suggestion = g_strconcat (subject, ".mbox", NULL);
camel_folder_free_message_info (folder, info);
}
if (!suggestion) {
const gchar *basename;
/* Translators: This is a part of a suggested file name
* used when saving a message or multiple messages to an
* mbox format, when the first message doesn't have a
* Subject. The extension ".mbox" is appended to this
* string, thus it will be something like "Message.mbox"
* at the end. */
basename = ngettext ("Message", "Messages", uids->len);
suggestion = g_strconcat (basename, ".mbox", NULL);
}
shell_backend = E_SHELL_BACKEND (backend);
shell = e_shell_backend_get_shell (shell_backend);
file = e_shell_run_save_dialog (
shell, title, suggestion,
"*.mbox:application/mbox,message/rfc822", NULL, NULL);
if (file == NULL) {
em_utils_uids_free (uids);
return;
}
uri = g_file_get_uri (file);
/* This eats the UID array, so do not free it. */
mail_save_messages (folder, uids, uri, NULL, NULL);
g_free (uri);
g_object_unref (file);
}
static void
action_mail_search_folder_from_mailing_list_cb (GtkAction *action,
EMailReader *reader)
{
e_mail_reader_create_vfolder_from_selected (reader, AUTO_MLIST);
}
static void
action_mail_search_folder_from_recipients_cb (GtkAction *action,
EMailReader *reader)
{
e_mail_reader_create_vfolder_from_selected (reader, AUTO_TO);
}
static void
action_mail_search_folder_from_sender_cb (GtkAction *action,
EMailReader *reader)
{
e_mail_reader_create_vfolder_from_selected (reader, AUTO_FROM);
}
static void
action_mail_search_folder_from_subject_cb (GtkAction *action,
EMailReader *reader)
{
e_mail_reader_create_vfolder_from_selected (reader, AUTO_SUBJECT);
}
static void
action_mail_show_all_headers_cb (GtkToggleAction *action,
EMailReader *reader)
{
EMFormatHTML *formatter;
EMFormatMode mode;
formatter = e_mail_reader_get_formatter (reader);
if (!formatter)
return;
if (gtk_toggle_action_get_active (action))
mode = EM_FORMAT_MODE_ALLHEADERS;
else
mode = EM_FORMAT_MODE_NORMAL;
em_format_set_mode (EM_FORMAT (formatter), mode);
}
static void
action_mail_show_source_cb (GtkAction *action,
EMailReader *reader)
{
EMailBackend *backend;
EMFormatHTML *formatter;
CamelFolder *folder;
GtkWidget *browser;
GPtrArray *uids;
backend = e_mail_reader_get_backend (reader);
folder = e_mail_reader_get_folder (reader);
uids = e_mail_reader_get_selected_uids (reader);
g_return_if_fail (uids->len > 0);
browser = e_mail_browser_new (backend);
reader = E_MAIL_READER (browser);
formatter = e_mail_reader_get_formatter (reader);
if (formatter != NULL)
em_format_set_mode (
EM_FORMAT (formatter), EM_FORMAT_MODE_SOURCE);
e_mail_reader_set_folder (reader, folder);
e_mail_reader_set_message (reader, uids->pdata[0]);
gtk_widget_show (browser);
em_utils_uids_free (uids);
}
static void
action_mail_toggle_important_cb (GtkAction *action,
EMailReader *reader)
{
CamelFolder *folder;
GPtrArray *uids;
guint ii;
folder = e_mail_reader_get_folder (reader);
uids = e_mail_reader_get_selected_uids (reader);
camel_folder_freeze (folder);
for (ii = 0; ii < uids->len; ii++) {
guint32 flags;
flags = camel_folder_get_message_flags (
folder, uids->pdata[ii]);
flags ^= CAMEL_MESSAGE_FLAGGED;
if (flags & CAMEL_MESSAGE_FLAGGED)
flags &= ~CAMEL_MESSAGE_DELETED;
camel_folder_set_message_flags (
folder, uids->pdata[ii], CAMEL_MESSAGE_FLAGGED |
CAMEL_MESSAGE_DELETED, flags);
}
camel_folder_thaw (folder);
em_utils_uids_free (uids);
}
static void
action_mail_undelete_cb (GtkAction *action,
EMailReader *reader)
{
guint32 mask = CAMEL_MESSAGE_DELETED;
guint32 set = 0;
e_mail_reader_mark_selected (reader, mask, set);
}
static void
action_mail_zoom_100_cb (GtkAction *action,
EMailReader *reader)
{
EMFormatHTML *formatter;
EWebView *web_view;
formatter = e_mail_reader_get_formatter (reader);
web_view = em_format_html_get_web_view (formatter);
e_web_view_zoom_100 (web_view);
}
static void
action_mail_zoom_in_cb (GtkAction *action,
EMailReader *reader)
{
EMFormatHTML *formatter;
EWebView *web_view;
formatter = e_mail_reader_get_formatter (reader);
web_view = em_format_html_get_web_view (formatter);
e_web_view_zoom_in (web_view);
}
static void
action_mail_zoom_out_cb (GtkAction *action,
EMailReader *reader)
{
EMFormatHTML *formatter;
EWebView *web_view;
formatter = e_mail_reader_get_formatter (reader);
web_view = em_format_html_get_web_view (formatter);
e_web_view_zoom_out (web_view);
}
static void
action_search_folder_recipient_cb (GtkAction *action,
EMailReader *reader)
{
EMailBackend *backend;
EMailSession *session;
EMFormatHTML *formatter;
EWebView *web_view;
CamelURL *curl;
const gchar *folder_uri;
const gchar *uri;
/* This action is defined in EMailDisplay. */
folder_uri = e_mail_reader_get_folder_uri (reader);
formatter = e_mail_reader_get_formatter (reader);
web_view = em_format_html_get_web_view (formatter);
uri = e_web_view_get_selected_uri (web_view);
g_return_if_fail (uri != NULL);
curl = camel_url_new (uri, NULL);
g_return_if_fail (curl != NULL);
backend = e_mail_reader_get_backend (reader);
session = e_mail_backend_get_session (backend);
if (curl->path != NULL && *curl->path != '\0') {
CamelInternetAddress *inet_addr;
inet_addr = camel_internet_address_new ();
camel_address_decode (CAMEL_ADDRESS (inet_addr), curl->path);
vfolder_gui_add_from_address (
session, inet_addr, AUTO_TO, folder_uri);
g_object_unref (inet_addr);
}
camel_url_free (curl);
}
static void
action_search_folder_sender_cb (GtkAction *action,
EMailReader *reader)
{
EMailBackend *backend;
EMailSession *session;
EMFormatHTML *formatter;
EWebView *web_view;
CamelURL *curl;
const gchar *folder_uri;
const gchar *uri;
/* This action is defined in EMailDisplay. */
folder_uri = e_mail_reader_get_folder_uri (reader);
formatter = e_mail_reader_get_formatter (reader);
web_view = em_format_html_get_web_view (formatter);
uri = e_web_view_get_selected_uri (web_view);
g_return_if_fail (uri != NULL);
curl = camel_url_new (uri, NULL);
g_return_if_fail (curl != NULL);
backend = e_mail_reader_get_backend (reader);
session = e_mail_backend_get_session (backend);
if (curl->path != NULL && *curl->path != '\0') {
CamelInternetAddress *inet_addr;
inet_addr = camel_internet_address_new ();
camel_address_decode (CAMEL_ADDRESS (inet_addr), curl->path);
vfolder_gui_add_from_address (
session, inet_addr, AUTO_FROM, folder_uri);
g_object_unref (inet_addr);
}
camel_url_free (curl);
}
static GtkActionEntry mail_reader_entries[] = {
{ "mail-add-sender",
NULL,
N_("A_dd Sender to Address Book"),
NULL,
N_("Add sender to address book"),
G_CALLBACK (action_mail_add_sender_cb) },
{ "mail-check-for-junk",
"mail-mark-junk",
N_("Check for _Junk"),
NULL,
N_("Filter the selected messages for junk status"),
G_CALLBACK (action_mail_check_for_junk_cb) },
{ "mail-copy",
"mail-copy",
N_("_Copy to Folder..."),
"<Shift><Control>y",
N_("Copy selected messages to another folder"),
G_CALLBACK (action_mail_copy_cb) },
{ "mail-delete",
"user-trash",
N_("_Delete Message"),
"<Control>d",
N_("Mark the selected messages for deletion"),
G_CALLBACK (action_mail_delete_cb) },
{ "mail-filter-on-mailing-list",
NULL,
N_("Filter on Mailing _List..."),
NULL,
N_("Create a rule to filter messages to this mailing list"),
G_CALLBACK (action_mail_filter_on_mailing_list_cb) },
{ "mail-filter-on-recipients",
NULL,
N_("Filter on _Recipients..."),
NULL,
N_("Create a rule to filter messages to these recipients"),
G_CALLBACK (action_mail_filter_on_recipients_cb) },
{ "mail-filter-on-sender",
NULL,
N_("Filter on Se_nder..."),
NULL,
N_("Create a rule to filter messages from this sender"),
G_CALLBACK (action_mail_filter_on_sender_cb) },
{ "mail-filter-on-subject",
NULL,
N_("Filter on _Subject..."),
NULL,
N_("Create a rule to filter messages with this subject"),
G_CALLBACK (action_mail_filter_on_subject_cb) },
{ "mail-filters-apply",
"stock_mail-filters-apply",
N_("A_pply Filters"),
"<Control>y",
N_("Apply filter rules to the selected messages"),
G_CALLBACK (action_mail_filters_apply_cb) },
{ "mail-find",
GTK_STOCK_FIND,
N_("_Find in Message..."),
"<Shift><Control>f",
N_("Search for text in the body of the displayed message"),
G_CALLBACK (action_mail_find_cb) },
{ "mail-flag-clear",
NULL,
N_("_Clear Flag"),
NULL,
N_("Remove the follow-up flag from the selected messages"),
G_CALLBACK (action_mail_flag_clear_cb) },
{ "mail-flag-completed",
NULL,
N_("_Flag Completed"),
NULL,
N_("Set the follow-up flag to completed on the selected messages"),
G_CALLBACK (action_mail_flag_completed_cb) },
{ "mail-flag-for-followup",
"stock_mail-flag-for-followup",
N_("Follow _Up..."),
"<Shift><Control>g",
N_("Flag the selected messages for follow-up"),
G_CALLBACK (action_mail_flag_for_followup_cb) },
{ "mail-forward-attached",
NULL,
N_("_Attached"),
NULL,
N_("Forward the selected message to someone as an attachment"),
G_CALLBACK (action_mail_forward_attached_cb) },
{ "mail-forward-attached-full",
NULL,
N_("Forward As _Attached"),
NULL,
N_("Forward the selected message to someone as an attachment"),
G_CALLBACK (action_mail_forward_attached_cb) },
{ "mail-forward-inline",
NULL,
N_("_Inline"),
NULL,
N_("Forward the selected message in the body of a new message"),
G_CALLBACK (action_mail_forward_inline_cb) },
{ "mail-forward-inline-full",
NULL,
N_("Forward As _Inline"),
NULL,
N_("Forward the selected message in the body of a new message"),
G_CALLBACK (action_mail_forward_inline_cb) },
{ "mail-forward-quoted",
NULL,
N_("_Quoted"),
NULL,
N_("Forward the selected message quoted like a reply"),
G_CALLBACK (action_mail_forward_quoted_cb) },
{ "mail-forward-quoted-full",
NULL,
N_("Forward As _Quoted"),
NULL,
N_("Forward the selected message quoted like a reply"),
G_CALLBACK (action_mail_forward_quoted_cb) },
{ "mail-load-images",
"image-x-generic",
N_("_Load Images"),
"<Control>i",
N_("Force images in HTML mail to be loaded"),
G_CALLBACK (action_mail_load_images_cb) },
{ "mail-mark-important",
"mail-mark-important",
N_("_Important"),
NULL,
N_("Mark the selected messages as important"),
G_CALLBACK (action_mail_mark_important_cb) },
{ "mail-mark-junk",
"mail-mark-junk",
N_("_Junk"),
"<Control>j",
N_("Mark the selected messages as junk"),
G_CALLBACK (action_mail_mark_junk_cb) },
{ "mail-mark-notjunk",
"mail-mark-notjunk",
N_("_Not Junk"),
"<Shift><Control>j",
N_("Mark the selected messages as not being junk"),
G_CALLBACK (action_mail_mark_notjunk_cb) },
{ "mail-mark-read",
"mail-mark-read",
N_("_Read"),
"<Control>k",
N_("Mark the selected messages as having been read"),
G_CALLBACK (action_mail_mark_read_cb) },
{ "mail-mark-unimportant",
NULL,
N_("Uni_mportant"),
NULL,
N_("Mark the selected messages as unimportant"),
G_CALLBACK (action_mail_mark_unimportant_cb) },
{ "mail-mark-unread",
"mail-mark-unread",
N_("_Unread"),
"<Shift><Control>k",
N_("Mark the selected messages as not having been read"),
G_CALLBACK (action_mail_mark_unread_cb) },
{ "mail-message-edit",
NULL,
N_("_Edit as New Message..."),
NULL,
N_("Open the selected messages in the composer for editing"),
G_CALLBACK (action_mail_message_edit_cb) },
{ "mail-message-new",
"mail-message-new",
N_("Compose _New Message"),
"<Shift><Control>m",
N_("Open a window for composing a mail message"),
G_CALLBACK (action_mail_message_new_cb) },
{ "mail-message-open",
NULL,
N_("_Open in New Window"),
"<Control>o",
N_("Open the selected messages in a new window"),
G_CALLBACK (action_mail_message_open_cb) },
{ "mail-move",
"mail-move",
N_("_Move to Folder..."),
"<Shift><Control>v",
N_("Move selected messages to another folder"),
G_CALLBACK (action_mail_move_cb) },
{ "mail-goto-folder",
NULL,
N_("_Switch to Folder"),
"<Control>Up",
N_("Display the parent folder"),
G_CALLBACK (action_mail_folder_cb) },
{ "mail-goto-nexttab",
NULL,
N_("Switch to _next tab"),
"<Shift><Control>Down",
N_("Switch to the next tab"),
G_CALLBACK (action_mail_nexttab_cb) },
{ "mail-goto-prevtab",
NULL,
N_("Switch to _previous tab"),
"<Shift><Control>Up",
N_("Switch to the previous tab"),
G_CALLBACK (action_mail_prevtab_cb) },
{ "mail-close-tab",
NULL,
N_("Cl_ose current tab"),
"<Shift><Control>w",
N_("Close current tab"),
G_CALLBACK (action_mail_closetab_cb) },
{ "mail-next",
GTK_STOCK_GO_FORWARD,
N_("_Next Message"),
"<Control>Page_Down",
N_("Display the next message"),
G_CALLBACK (action_mail_next_cb) },
{ "mail-next-important",
NULL,
N_("Next _Important Message"),
NULL,
N_("Display the next important message"),
G_CALLBACK (action_mail_next_important_cb) },
{ "mail-next-thread",
NULL,
N_("Next _Thread"),
NULL,
N_("Display the next thread"),
G_CALLBACK (action_mail_next_thread_cb) },
{ "mail-next-unread",
NULL,
N_("Next _Unread Message"),
"<Control>bracketright",
N_("Display the next unread message"),
G_CALLBACK (action_mail_next_unread_cb) },
{ "mail-previous",
GTK_STOCK_GO_BACK,
N_("_Previous Message"),
"<Control>Page_Up",
N_("Display the previous message"),
G_CALLBACK (action_mail_previous_cb) },
{ "mail-previous-important",
NULL,
N_("Pr_evious Important Message"),
NULL,
N_("Display the previous important message"),
G_CALLBACK (action_mail_previous_important_cb) },
{ "mail-previous-thread",
NULL,
N_("Previous T_hread"),
NULL,
N_("Display the previous thread"),
G_CALLBACK (action_mail_previous_thread_cb) },
{ "mail-previous-unread",
NULL,
N_("P_revious Unread Message"),
"<Control>bracketleft",
N_("Display the previous unread message"),
G_CALLBACK (action_mail_previous_unread_cb) },
{ "mail-print",
GTK_STOCK_PRINT,
NULL,
"<Control>p",
N_("Print this message"),
G_CALLBACK (action_mail_print_cb) },
{ "mail-print-preview",
GTK_STOCK_PRINT_PREVIEW,
NULL,
NULL,
N_("Preview the message to be printed"),
G_CALLBACK (action_mail_print_preview_cb) },
{ "mail-redirect",
NULL,
N_("Re_direct"),
NULL,
N_("Redirect (bounce) the selected message to someone"),
G_CALLBACK (action_mail_redirect_cb) },
{ "mail-remove-attachments",
GTK_STOCK_DELETE,
N_("Remo_ve Attachments"),
NULL,
N_("Remove attachments"),
G_CALLBACK (action_mail_remove_attachments_cb) },
{ "mail-remove-duplicates",
NULL,
N_("Remove Du_plicate Messages"),
NULL,
N_("Checks selected messages for duplicates"),
G_CALLBACK (action_mail_remove_duplicates) },
{ "mail-reply-all",
NULL,
N_("Reply to _All"),
"<Shift><Control>r",
N_("Compose a reply to all the recipients of the selected message"),
G_CALLBACK (action_mail_reply_all_cb) },
{ "mail-reply-list",
NULL,
N_("Reply to _List"),
"<Control>l",
N_("Compose a reply to the mailing list of the selected message"),
G_CALLBACK (action_mail_reply_list_cb) },
{ "mail-reply-sender",
"mail-reply-sender",
N_("_Reply to Sender"),
"<Control>r",
N_("Compose a reply to the sender of the selected message"),
G_CALLBACK (action_mail_reply_sender_cb) },
{ "mail-save-as",
GTK_STOCK_SAVE_AS,
N_("_Save as mbox..."),
"<Control>s",
N_("Save selected messages as an mbox file"),
G_CALLBACK (action_mail_save_as_cb) },
{ "mail-search-folder-from-mailing-list",
NULL,
N_("Search Folder from Mailing _List..."),
NULL,
N_("Create a search folder for this mailing list"),
G_CALLBACK (action_mail_search_folder_from_mailing_list_cb) },
{ "mail-search-folder-from-recipients",
NULL,
N_("Search Folder from Recipien_ts..."),
NULL,
N_("Create a search folder for these recipients"),
G_CALLBACK (action_mail_search_folder_from_recipients_cb) },
{ "mail-search-folder-from-sender",
NULL,
N_("Search Folder from Sen_der..."),
NULL,
N_("Create a search folder for this sender"),
G_CALLBACK (action_mail_search_folder_from_sender_cb) },
{ "mail-search-folder-from-subject",
NULL,
N_("Search Folder from S_ubject..."),
NULL,
N_("Create a search folder for this subject"),
G_CALLBACK (action_mail_search_folder_from_subject_cb) },
{ "mail-show-source",
NULL,
N_("_Message Source"),
"<Control>u",
N_("Show the raw email source of the message"),
G_CALLBACK (action_mail_show_source_cb) },
{ "mail-toggle-important",
NULL,
NULL, /* No menu item; key press only */
NULL,
NULL,
G_CALLBACK (action_mail_toggle_important_cb) },
{ "mail-undelete",
NULL,
N_("_Undelete Message"),
"<Shift><Control>d",
N_("Undelete the selected messages"),
G_CALLBACK (action_mail_undelete_cb) },
{ "mail-zoom-100",
GTK_STOCK_ZOOM_100,
N_("_Normal Size"),
"<Control>0",
N_("Reset the text to its original size"),
G_CALLBACK (action_mail_zoom_100_cb) },
{ "mail-zoom-in",
GTK_STOCK_ZOOM_IN,
N_("_Zoom In"),
"<Control>plus",
N_("Increase the text size"),
G_CALLBACK (action_mail_zoom_in_cb) },
{ "mail-zoom-out",
GTK_STOCK_ZOOM_OUT,
N_("Zoom _Out"),
"<Control>minus",
N_("Decrease the text size"),
G_CALLBACK (action_mail_zoom_out_cb) },
/*** Menus ***/
{ "mail-create-rule-menu",
NULL,
N_("Create R_ule"),
NULL,
NULL,
NULL },
{ "mail-encoding-menu",
NULL,
N_("Ch_aracter Encoding"),
NULL,
NULL,
NULL },
{ "mail-forward-as-menu",
NULL,
N_("F_orward As"),
NULL,
NULL,
NULL },
{ "mail-reply-group-menu",
NULL,
N_("_Group Reply"),
NULL,
NULL,
NULL },
{ "mail-goto-menu",
GTK_STOCK_JUMP_TO,
N_("_Go To"),
NULL,
NULL,
NULL },
{ "mail-mark-as-menu",
NULL,
N_("Mar_k As"),
NULL,
NULL,
NULL },
{ "mail-message-menu",
NULL,
N_("_Message"),
NULL,
NULL,
NULL },
{ "mail-zoom-menu",
NULL,
N_("_Zoom"),
NULL,
NULL,
NULL }
};
static EPopupActionEntry mail_reader_popup_entries[] = {
{ "mail-popup-copy",
NULL,
"mail-copy" },
{ "mail-popup-delete",
NULL,
"mail-delete" },
{ "mail-popup-flag-clear",
NULL,
"mail-flag-clear" },
{ "mail-popup-flag-completed",
NULL,
"mail-flag-completed" },
{ "mail-popup-flag-for-followup",
N_("Mark for Follo_w Up..."),
"mail-flag-for-followup" },
{ "mail-popup-forward",
NULL,
"mail-forward" },
{ "mail-popup-mark-important",
N_("Mark as _Important"),
"mail-mark-important" },
{ "mail-popup-mark-junk",
N_("Mark as _Junk"),
"mail-mark-junk" },
{ "mail-popup-mark-notjunk",
N_("Mark as _Not Junk"),
"mail-mark-notjunk" },
{ "mail-popup-mark-read",
N_("Mar_k as Read"),
"mail-mark-read" },
{ "mail-popup-mark-unimportant",
N_("Mark as Uni_mportant"),
"mail-mark-unimportant" },
{ "mail-popup-mark-unread",
N_("Mark as _Unread"),
"mail-mark-unread" },
{ "mail-popup-message-edit",
NULL,
"mail-message-edit" },
{ "mail-popup-move",
NULL,
"mail-move" },
{ "mail-popup-print",
NULL,
"mail-print" },
{ "mail-popup-remove-attachments",
NULL,
"mail-remove-attachments" },
{ "mail-popup-remove-duplicates",
NULL,
"mail-remove-duplicates" },
{ "mail-popup-reply-all",
NULL,
"mail-reply-all" },
{ "mail-popup-reply-sender",
NULL,
"mail-reply-sender" },
{ "mail-popup-save-as",
NULL,
"mail-save-as" },
{ "mail-popup-undelete",
NULL,
"mail-undelete" }
};
static GtkToggleActionEntry mail_reader_toggle_entries[] = {
{ "mail-caret-mode",
NULL,
N_("_Caret Mode"),
"F7",
N_("Show a blinking cursor in the body of displayed messages"),
NULL, /* No callback required */
FALSE },
{ "mail-show-all-headers",
NULL,
N_("All Message _Headers"),
NULL,
N_("Show messages with all email headers"),
G_CALLBACK (action_mail_show_all_headers_cb),
FALSE }
};
static void
mail_reader_double_click_cb (EMailReader *reader,
gint row,
ETreePath path,
gint col,
GdkEvent *event)
{
/* Ignore double clicks on columns that handle their own state. */
if (MESSAGE_LIST_COLUMN_IS_ACTIVE (col))
return;
e_mail_reader_activate (reader, "mail-message-open");
}
static gboolean
mail_reader_key_press_event_cb (EMailReader *reader,
GdkEventKey *event)
{
const gchar *action_name;
if ((event->state & GDK_CONTROL_MASK) != 0)
goto ctrl;
/* <keyval> alone */
switch (event->keyval) {
case GDK_KEY_Delete:
case GDK_KEY_KP_Delete:
action_name = "mail-delete";
break;
case GDK_KEY_Return:
case GDK_KEY_KP_Enter:
case GDK_KEY_ISO_Enter:
action_name = "mail-message-open";
break;
case GDK_KEY_period:
case GDK_KEY_bracketright:
action_name = "mail-next-unread";
break;
case GDK_KEY_comma:
case GDK_KEY_bracketleft:
action_name = "mail-previous-unread";
break;
#ifdef HAVE_XFREE
case XF86XK_Reply:
action_name = "mail-reply-all";
break;
case XF86XK_MailForward:
action_name = "mail-forward";
break;
#endif
case GDK_KEY_exclam:
action_name = "mail-toggle-important";
break;
default:
return FALSE;
}
goto exit;
ctrl:
/* Ctrl + <keyval> */
switch (event->keyval) {
case GDK_KEY_period:
action_name = "mail-next-unread";
break;
case GDK_KEY_comma:
action_name = "mail-previous-unread";
break;
default:
return FALSE;
}
exit:
e_mail_reader_activate (reader, action_name);
return TRUE;
}
static gint
mail_reader_key_press_cb (EMailReader *reader,
gint row,
ETreePath path,
gint col,
GdkEvent *event)
{
return mail_reader_key_press_event_cb (reader, &event->key);
}
static gboolean
mail_reader_message_read_cb (EMailReaderClosure *closure)
{
EMailReader *reader;
GtkWidget *message_list;
const gchar *cursor_uid;
const gchar *message_uid;
reader = closure->reader;
message_uid = closure->message_uid;
message_list = e_mail_reader_get_message_list (reader);
cursor_uid = MESSAGE_LIST (message_list)->cursor_uid;
if (g_strcmp0 (cursor_uid, message_uid) == 0)
e_mail_reader_mark_as_read (reader, message_uid);
return FALSE;
}
static void
mail_reader_message_loaded_cb (CamelFolder *folder,
GAsyncResult *result,
EMailReaderClosure *closure)
{
EMailReader *reader;
EMailReaderPrivate *priv;
CamelMimeMessage *message = NULL;
EMFormatHTML *formatter;
GtkWidget *message_list;
EMailBackend *backend;
EShellBackend *shell_backend;
EShellSettings *shell_settings;
EShell *shell;
EWebView *web_view;
EMEvent *event;
EMEventTargetMessage *target;
const gchar *message_uid;
gboolean schedule_timeout;
gint timeout_interval;
GError *error = NULL;
reader = closure->reader;
message_uid = closure->message_uid;
priv = E_MAIL_READER_GET_PRIVATE (reader);
/* If the private struct is NULL, the EMailReader was destroyed
* while we were loading the message and we're likely holding the
* last reference. Nothing to do but drop the reference. */
if (priv == NULL) {
mail_reader_closure_free (closure);
return;
}
message = camel_folder_get_message_finish (folder, result, &error);
/* If the user picked a different message in the time it took
* to fetch this message, then don't bother rendering it. */
if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) {
g_error_free (error);
goto exit;
}
backend = e_mail_reader_get_backend (reader);
formatter = e_mail_reader_get_formatter (reader);
message_list = e_mail_reader_get_message_list (reader);
if (!message_list) {
/* for cases where message fetching took so long that
user closed the message window before this was called */
goto exit;
}
shell_backend = E_SHELL_BACKEND (backend);
shell = e_shell_backend_get_shell (shell_backend);
shell_settings = e_shell_get_shell_settings (shell);
web_view = em_format_html_get_web_view (formatter);
/** @Event: message.reading
* @Title: Viewing a message
* @Target: EMEventTargetMessage
*
* message.reading is emitted whenever a user views a message.
*/
event = em_event_peek ();
target = em_event_target_new_message (
event, folder, message, message_uid, 0, NULL);
e_event_emit (
(EEvent *) event, "message.reading",
(EEventTarget *) target);
/* FIXME Need to pass a GCancellable. */
em_format_format (
EM_FORMAT (formatter), folder,
message_uid, message, NULL);
/* Reset the shell view icon. */
e_shell_event (shell, "mail-icon", (gpointer) "evolution-mail");
/* Determine whether to mark the message as read. */
schedule_timeout =
(message != NULL) &&
e_shell_settings_get_boolean (
shell_settings, "mail-mark-seen") &&
!priv->restoring_message_selection;
timeout_interval =
e_shell_settings_get_int (
shell_settings, "mail-mark-seen-timeout");
if (MESSAGE_LIST (message_list)->seen_id > 0) {
g_source_remove (MESSAGE_LIST (message_list)->seen_id);
MESSAGE_LIST (message_list)->seen_id = 0;
}
if (schedule_timeout) {
EMailReaderClosure *timeout_closure;
timeout_closure = g_slice_new0 (EMailReaderClosure);
timeout_closure->reader = g_object_ref (reader);
timeout_closure->message_uid = g_strdup (message_uid);
MESSAGE_LIST (message_list)->seen_id = g_timeout_add_full (
G_PRIORITY_DEFAULT, timeout_interval,
(GSourceFunc) mail_reader_message_read_cb,
timeout_closure, (GDestroyNotify)
mail_reader_closure_free);
} else if (error != NULL) {
e_alert_submit (
E_ALERT_SINK (web_view),
"mail:no-retrieve-message",
error->message, NULL);
g_error_free (error);
}
exit:
priv->restoring_message_selection = FALSE;
mail_reader_closure_free (closure);
if (message)
g_object_unref (message);
}
static gboolean
mail_reader_message_selected_timeout_cb (EMailReader *reader)
{
EMailReaderPrivate *priv;
EMFormatHTML *formatter;
GtkWidget *message_list;
EWebView *web_view;
CamelFolder *folder;
EMailBackend *backend;
const gchar *cursor_uid;
const gchar *format_uid;
priv = E_MAIL_READER_GET_PRIVATE (reader);
folder = e_mail_reader_get_folder (reader);
backend = e_mail_reader_get_backend (reader);
formatter = e_mail_reader_get_formatter (reader);
message_list = e_mail_reader_get_message_list (reader);
cursor_uid = MESSAGE_LIST (message_list)->cursor_uid;
format_uid = EM_FORMAT (formatter)->uid;
web_view = em_format_html_get_web_view (formatter);
if (MESSAGE_LIST (message_list)->last_sel_single) {
GtkWidget *widget;
gboolean web_view_visible;
gboolean selected_uid_changed;
/* Decide whether to download the full message now. */
widget = GTK_WIDGET (web_view);
web_view_visible = gtk_widget_get_mapped (widget);
selected_uid_changed = g_strcmp0 (cursor_uid, format_uid);
if (web_view_visible && selected_uid_changed) {
EMailReaderClosure *closure;
GCancellable *cancellable;
EActivity *activity;
gchar *string;
string = g_strdup_printf (
_("Retrieving message '%s'"), cursor_uid);
#if HAVE_CLUTTER
if (!e_shell_get_express_mode (e_shell_get_default ()))
e_web_view_load_string (web_view, string);
#else
e_web_view_load_string (web_view, string);
#endif
g_free (string);
activity = e_activity_new ();
cancellable = camel_operation_new ();
e_activity_set_cancellable (activity, cancellable);
closure = g_slice_new0 (EMailReaderClosure);
closure->reader = g_object_ref (reader);
closure->activity = g_object_ref (activity);
closure->message_uid = g_strdup (cursor_uid);
camel_folder_get_message (
folder, cursor_uid, G_PRIORITY_DEFAULT,
cancellable, (GAsyncReadyCallback)
mail_reader_message_loaded_cb, closure);
e_shell_backend_add_activity (
E_SHELL_BACKEND (backend), activity);
if (priv->retrieving_message != NULL)
g_object_unref (priv->retrieving_message);
priv->retrieving_message = cancellable;
g_object_unref (activity);
}
} else {
/* FIXME Need to pass a GCancellable. */
em_format_format (
EM_FORMAT (formatter), NULL, NULL, NULL, NULL);
priv->restoring_message_selection = FALSE;
}
priv->message_selected_timeout_id = 0;
return FALSE;
}
static void
mail_reader_message_selected_cb (EMailReader *reader,
const gchar *uid)
{
EMailReaderPrivate *priv;
MessageList *message_list;
priv = E_MAIL_READER_GET_PRIVATE (reader);
/* Cancel the previous message retrieval activity. */
g_cancellable_cancel (priv->retrieving_message);
/* Cancel the seen timer. */
message_list = MESSAGE_LIST (e_mail_reader_get_message_list (reader));
if (message_list && message_list->seen_id) {
g_source_remove (message_list->seen_id);
message_list->seen_id = 0;
}
/* Cancel the message selected timer. */
if (priv->message_selected_timeout_id > 0) {
g_source_remove (priv->message_selected_timeout_id);
priv->message_selected_timeout_id = 0;
}
/* If a folder was just selected then we are now automatically
* restoring the previous message selection. We behave slightly
* differently than if the user had selected the message. */
priv->restoring_message_selection = priv->folder_was_just_selected;
priv->folder_was_just_selected = FALSE;
/* Skip the timeout if we're restoring the previous message
* selection. The timeout is there for when we're scrolling
* rapidly through the message list. */
if (priv->restoring_message_selection)
mail_reader_message_selected_timeout_cb (reader);
else
priv->message_selected_timeout_id = g_timeout_add (
100, (GSourceFunc)
mail_reader_message_selected_timeout_cb, reader);
e_mail_reader_changed (reader);
}
static void
mail_reader_emit_folder_loaded (EMailReader *reader)
{
g_signal_emit (reader, signals[FOLDER_LOADED], 0);
}
static GPtrArray *
mail_reader_get_selected_uids (EMailReader *reader)
{
GtkWidget *message_list;
message_list = e_mail_reader_get_message_list (reader);
return message_list_get_selected (MESSAGE_LIST (message_list));
}
static CamelFolder *
mail_reader_get_folder (EMailReader *reader)
{
GtkWidget *message_list;
message_list = e_mail_reader_get_message_list (reader);
return MESSAGE_LIST (message_list)->folder;
}
static const gchar *
mail_reader_get_folder_uri (EMailReader *reader)
{
GtkWidget *message_list;
message_list = e_mail_reader_get_message_list (reader);
return MESSAGE_LIST (message_list)->folder_uri;
}
static gboolean
mail_reader_get_enable_show_folder (EMailReader *reader)
{
return FALSE;
}
static void
mail_reader_set_folder (EMailReader *reader,
CamelFolder *folder)
{
EMailReaderPrivate *priv;
EMFormatHTML *formatter;
CamelFolder *previous_folder;
GtkWidget *message_list;
EMailBackend *backend;
EShell *shell;
const gchar *folder_uri = NULL;
gboolean outgoing;
priv = E_MAIL_READER_GET_PRIVATE (reader);
backend = e_mail_reader_get_backend (reader);
formatter = e_mail_reader_get_formatter (reader);
message_list = e_mail_reader_get_message_list (reader);
previous_folder = e_mail_reader_get_folder (reader);
shell = e_shell_backend_get_shell (E_SHELL_BACKEND (backend));
/* Only synchronize the folder if we're online. */
if (previous_folder != NULL && e_shell_get_online (shell))
mail_sync_folder (previous_folder, NULL, NULL);
/* Skip the rest if we're already viewing the folder. */
if (folder == previous_folder)
return;
if (folder != NULL)
folder_uri = camel_folder_get_uri (folder);
outgoing = folder != NULL && folder_uri != NULL && (
em_utils_folder_is_drafts (folder) ||
em_utils_folder_is_outbox (folder) ||
em_utils_folder_is_sent (folder));
/* FIXME Need to pass a GCancellable. */
em_format_format (EM_FORMAT (formatter), NULL, NULL, NULL, NULL);
priv->folder_was_just_selected = (folder != NULL);
message_list_set_folder (
MESSAGE_LIST (message_list), folder, outgoing);
mail_reader_emit_folder_loaded (reader);
}
static void
mail_reader_set_message (EMailReader *reader,
const gchar *uid)
{
GtkWidget *message_list;
message_list = e_mail_reader_get_message_list (reader);
message_list_select_uid (MESSAGE_LIST (message_list), uid, FALSE);
}
static void
mail_reader_update_actions (EMailReader *reader,
guint32 state)
{
GtkAction *action;
const gchar *action_name;
gboolean sensitive;
/* Be descriptive. */
gboolean any_messages_selected;
gboolean enable_flag_clear;
gboolean enable_flag_completed;
gboolean enable_flag_for_followup;
gboolean have_enabled_account;
gboolean multiple_messages_selected;
gboolean selection_has_attachment_messages;
gboolean selection_has_deleted_messages;
gboolean selection_has_important_messages;
gboolean selection_has_junk_messages;
gboolean selection_has_not_junk_messages;
gboolean selection_has_read_messages;
gboolean selection_has_undeleted_messages;
gboolean selection_has_unimportant_messages;
gboolean selection_has_unread_messages;
gboolean selection_is_mailing_list;
gboolean single_message_selected;
gboolean first_message_selected = FALSE;
gboolean last_message_selected = FALSE;
have_enabled_account =
(state & E_MAIL_READER_HAVE_ENABLED_ACCOUNT);
single_message_selected =
(state & E_MAIL_READER_SELECTION_SINGLE);
multiple_messages_selected =
(state & E_MAIL_READER_SELECTION_MULTIPLE);
/* FIXME Missing CAN_ADD_SENDER */
enable_flag_clear =
(state & E_MAIL_READER_SELECTION_FLAG_CLEAR);
enable_flag_completed =
(state & E_MAIL_READER_SELECTION_FLAG_COMPLETED);
enable_flag_for_followup =
(state & E_MAIL_READER_SELECTION_FLAG_FOLLOWUP);
selection_has_attachment_messages =
(state & E_MAIL_READER_SELECTION_HAS_ATTACHMENTS);
selection_has_deleted_messages =
(state & E_MAIL_READER_SELECTION_HAS_DELETED);
selection_has_important_messages =
(state & E_MAIL_READER_SELECTION_HAS_IMPORTANT);
selection_has_junk_messages =
(state & E_MAIL_READER_SELECTION_HAS_JUNK);
selection_has_not_junk_messages =
(state & E_MAIL_READER_SELECTION_HAS_NOT_JUNK);
selection_has_read_messages =
(state & E_MAIL_READER_SELECTION_HAS_READ);
selection_has_undeleted_messages =
(state & E_MAIL_READER_SELECTION_HAS_UNDELETED);
selection_has_unimportant_messages =
(state & E_MAIL_READER_SELECTION_HAS_UNIMPORTANT);
selection_has_unread_messages =
(state & E_MAIL_READER_SELECTION_HAS_UNREAD);
selection_is_mailing_list =
(state & E_MAIL_READER_SELECTION_IS_MAILING_LIST);
any_messages_selected =
(single_message_selected || multiple_messages_selected);
if (any_messages_selected) {
MessageList *message_list;
gint row = -1, count = -1;
ETreeTableAdapter *etta;
ETreePath node = NULL;
message_list = MESSAGE_LIST (
e_mail_reader_get_message_list (reader));
etta = e_tree_get_table_adapter (E_TREE (message_list));
if (message_list->cursor_uid != NULL)
node = g_hash_table_lookup (
message_list->uid_nodemap,
message_list->cursor_uid);
if (node != NULL) {
row = e_tree_table_adapter_row_of_node (etta, node);
count = e_table_model_row_count (E_TABLE_MODEL (etta));
}
first_message_selected = row <= 0;
last_message_selected = row < 0 || row + 1 >= count;
}
action_name = "mail-add-sender";
sensitive = single_message_selected;
action = e_mail_reader_get_action (reader, action_name);
gtk_action_set_sensitive (action, sensitive);
action_name = "mail-check-for-junk";
sensitive = any_messages_selected;
action = e_mail_reader_get_action (reader, action_name);
gtk_action_set_sensitive (action, sensitive);
action_name = "mail-copy";
sensitive = any_messages_selected;
action = e_mail_reader_get_action (reader, action_name);
gtk_action_set_sensitive (action, sensitive);
action_name = "mail-create-rule-menu";
sensitive = single_message_selected;
action = e_mail_reader_get_action (reader, action_name);
gtk_action_set_sensitive (action, sensitive);
/* If a single message is selected, let the user hit delete to
* advance the cursor even if the message is already deleted. */
action_name = "mail-delete";
sensitive =
single_message_selected ||
selection_has_undeleted_messages;
action = e_mail_reader_get_action (reader, action_name);
gtk_action_set_sensitive (action, sensitive);
action_name = "mail-filters-apply";
sensitive = any_messages_selected;
action = e_mail_reader_get_action (reader, action_name);
gtk_action_set_sensitive (action, sensitive);
action_name = "mail-find";
sensitive = single_message_selected;
action = e_mail_reader_get_action (reader, action_name);
gtk_action_set_sensitive (action, sensitive);
action_name = "mail-flag-clear";
sensitive = enable_flag_clear;
action = e_mail_reader_get_action (reader, action_name);
gtk_action_set_sensitive (action, sensitive);
action_name = "mail-flag-completed";
sensitive = enable_flag_completed;
action = e_mail_reader_get_action (reader, action_name);
gtk_action_set_sensitive (action, sensitive);
action_name = "mail-flag-for-followup";
sensitive = enable_flag_for_followup;
action = e_mail_reader_get_action (reader, action_name);
gtk_action_set_sensitive (action, sensitive);
action_name = "mail-forward";
sensitive = have_enabled_account && any_messages_selected;
action = e_mail_reader_get_action (reader, action_name);
gtk_action_set_sensitive (action, sensitive);
action_name = "mail-forward-attached";
sensitive = have_enabled_account && any_messages_selected;
action = e_mail_reader_get_action (reader, action_name);
gtk_action_set_sensitive (action, sensitive);
action_name = "mail-forward-attached-full";
sensitive = have_enabled_account && any_messages_selected;
action = e_mail_reader_get_action (reader, action_name);
gtk_action_set_sensitive (action, sensitive);
action_name = "mail-forward-as-menu";
sensitive = have_enabled_account && any_messages_selected;
action = e_mail_reader_get_action (reader, action_name);
gtk_action_set_sensitive (action, sensitive);
action_name = "mail-forward-inline";
sensitive = have_enabled_account && single_message_selected;
action = e_mail_reader_get_action (reader, action_name);
gtk_action_set_sensitive (action, sensitive);
action_name = "mail-forward-inline-full";
sensitive = have_enabled_account && single_message_selected;
action = e_mail_reader_get_action (reader, action_name);
gtk_action_set_sensitive (action, sensitive);
action_name = "mail-forward-quoted";
sensitive = have_enabled_account && single_message_selected;
action = e_mail_reader_get_action (reader, action_name);
gtk_action_set_sensitive (action, sensitive);
action_name = "mail-forward-quoted-full";
sensitive = have_enabled_account && single_message_selected;
action = e_mail_reader_get_action (reader, action_name);
gtk_action_set_sensitive (action, sensitive);
action_name = "mail-goto-menu";
sensitive = any_messages_selected;
action = e_mail_reader_get_action (reader, action_name);
gtk_action_set_sensitive (action, sensitive);
action_name = "mail-load-images";
sensitive = single_message_selected;
action = e_mail_reader_get_action (reader, action_name);
gtk_action_set_sensitive (action, sensitive);
action_name = "mail-mark-as-menu";
sensitive = any_messages_selected;
action = e_mail_reader_get_action (reader, action_name);
gtk_action_set_sensitive (action, sensitive);
action_name = "mail-mark-important";
sensitive = selection_has_unimportant_messages;
action = e_mail_reader_get_action (reader, action_name);
gtk_action_set_sensitive (action, sensitive);
action_name = "mail-mark-junk";
sensitive =
selection_has_not_junk_messages &&
!(state & E_MAIL_READER_FOLDER_IS_JUNK);
action = e_mail_reader_get_action (reader, action_name);
gtk_action_set_sensitive (action, sensitive);
action_name = "mail-mark-notjunk";
sensitive = selection_has_junk_messages;
action = e_mail_reader_get_action (reader, action_name);
gtk_action_set_sensitive (action, sensitive);
action_name = "mail-mark-read";
sensitive = selection_has_unread_messages;
action = e_mail_reader_get_action (reader, action_name);
gtk_action_set_sensitive (action, sensitive);
action_name = "mail-mark-unimportant";
sensitive = selection_has_important_messages;
action = e_mail_reader_get_action (reader, action_name);
gtk_action_set_sensitive (action, sensitive);
action_name = "mail-mark-unread";
sensitive = selection_has_read_messages;
action = e_mail_reader_get_action (reader, action_name);
gtk_action_set_sensitive (action, sensitive);
action_name = "mail-message-edit";
sensitive = have_enabled_account && single_message_selected;
action = e_mail_reader_get_action (reader, action_name);
gtk_action_set_sensitive (action, sensitive);
action_name = "mail-message-new";
sensitive = have_enabled_account;
action = e_mail_reader_get_action (reader, action_name);
gtk_action_set_sensitive (action, sensitive);
action_name = "mail-message-open";
sensitive = any_messages_selected;
action = e_mail_reader_get_action (reader, action_name);
gtk_action_set_sensitive (action, sensitive);
action_name = "mail-goto-folder";
sensitive = e_mail_reader_get_enable_show_folder (reader);
action = e_mail_reader_get_action (reader, action_name);
gtk_action_set_sensitive (action, sensitive);
gtk_action_set_visible (action, sensitive);
action_name = "mail-goto-nexttab";
action = e_mail_reader_get_action (reader, action_name);
gtk_action_set_sensitive (action, TRUE);
gtk_action_set_visible (action, FALSE);
action_name = "mail-goto-prevtab";
action = e_mail_reader_get_action (reader, action_name);
gtk_action_set_sensitive (action, TRUE);
gtk_action_set_visible (action, FALSE);
action_name = "mail-close-tab";
action = e_mail_reader_get_action (reader, action_name);
gtk_action_set_sensitive (action, TRUE);
gtk_action_set_visible (action, FALSE);
action_name = "mail-move";
sensitive = any_messages_selected;
action = e_mail_reader_get_action (reader, action_name);
gtk_action_set_sensitive (action, sensitive);
action_name = "mail-next";
sensitive = any_messages_selected && !last_message_selected;
action = e_mail_reader_get_action (reader, action_name);
gtk_action_set_sensitive (action, sensitive);
action_name = "mail-next-important";
sensitive = single_message_selected;
action = e_mail_reader_get_action (reader, action_name);
gtk_action_set_sensitive (action, sensitive);
action_name = "mail-next-thread";
sensitive = single_message_selected && !last_message_selected;
action = e_mail_reader_get_action (reader, action_name);
gtk_action_set_sensitive (action, sensitive);
action_name = "mail-next-unread";
sensitive = any_messages_selected;
action = e_mail_reader_get_action (reader, action_name);
gtk_action_set_sensitive (action, sensitive);
action_name = "mail-previous";
sensitive = any_messages_selected && !first_message_selected;
action = e_mail_reader_get_action (reader, action_name);
gtk_action_set_sensitive (action, sensitive);
action_name = "mail-previous-important";
sensitive = single_message_selected;
action = e_mail_reader_get_action (reader, action_name);
gtk_action_set_sensitive (action, sensitive);
action_name = "mail-previous-unread";
sensitive = any_messages_selected;
action = e_mail_reader_get_action (reader, action_name);
gtk_action_set_sensitive (action, sensitive);
action_name = "mail-previous-thread";
sensitive = any_messages_selected && !first_message_selected;
action = e_mail_reader_get_action (reader, action_name);
gtk_action_set_sensitive (action, sensitive);
action_name = "mail-print";
sensitive = single_message_selected;
action = e_mail_reader_get_action (reader, action_name);
gtk_action_set_sensitive (action, sensitive);
action_name = "mail-print-preview";
sensitive = single_message_selected;
action = e_mail_reader_get_action (reader, action_name);
gtk_action_set_sensitive (action, sensitive);
action_name = "mail-redirect";
sensitive = have_enabled_account && single_message_selected;
action = e_mail_reader_get_action (reader, action_name);
gtk_action_set_sensitive (action, sensitive);
action_name = "mail-remove-attachments";
sensitive = any_messages_selected && selection_has_attachment_messages;
action = e_mail_reader_get_action (reader, action_name);
gtk_action_set_sensitive (action, sensitive);
action_name = "mail-remove-duplicates";
sensitive = multiple_messages_selected;
action = e_mail_reader_get_action (reader, action_name);
gtk_action_set_sensitive (action, sensitive);
action_name = "mail-reply-all";
sensitive = have_enabled_account && single_message_selected;
action = e_mail_reader_get_action (reader, action_name);
gtk_action_set_sensitive (action, sensitive);
action_name = "mail-reply-group";
sensitive = have_enabled_account && single_message_selected;
action = e_mail_reader_get_action (reader, action_name);
gtk_action_set_sensitive (action, sensitive);
action_name = "mail-reply-group-menu";
sensitive = have_enabled_account && any_messages_selected;
action = e_mail_reader_get_action (reader, action_name);
gtk_action_set_sensitive (action, sensitive);
action_name = "mail-reply-list";
sensitive = have_enabled_account && single_message_selected &&
selection_is_mailing_list;
action = e_mail_reader_get_action (reader, action_name);
gtk_action_set_sensitive (action, sensitive);
action_name = "mail-reply-sender";
sensitive = have_enabled_account && single_message_selected;
action = e_mail_reader_get_action (reader, action_name);
gtk_action_set_sensitive (action, sensitive);
action_name = "mail-save-as";
sensitive = any_messages_selected;
action = e_mail_reader_get_action (reader, action_name);
gtk_action_set_sensitive (action, sensitive);
action_name = "mail-show-source";
sensitive = single_message_selected;
action = e_mail_reader_get_action (reader, action_name);
gtk_action_set_sensitive (action, sensitive);
action_name = "mail-undelete";
sensitive = selection_has_deleted_messages;
action = e_mail_reader_get_action (reader, action_name);
gtk_action_set_sensitive (action, sensitive);
action_name = "mail-zoom-100";
sensitive = single_message_selected;
action = e_mail_reader_get_action (reader, action_name);
gtk_action_set_sensitive (action, sensitive);
action_name = "mail-zoom-in";
sensitive = single_message_selected;
action = e_mail_reader_get_action (reader, action_name);
gtk_action_set_sensitive (action, sensitive);
action_name = "mail-zoom-out";
sensitive = single_message_selected;
action = e_mail_reader_get_action (reader, action_name);
gtk_action_set_sensitive (action, sensitive);
}
static void
mail_reader_init_charset_actions (EMailReader *reader)
{
GtkActionGroup *action_group;
GtkRadioAction *default_action;
GSList *radio_group;
action_group = e_mail_reader_get_action_group (reader);
radio_group = e_charset_add_radio_actions (
action_group, "mail-charset-", NULL,
G_CALLBACK (action_mail_charset_cb), reader);
/* XXX Add a tooltip! */
default_action = gtk_radio_action_new (
"mail-charset-default", _("Default"), NULL, NULL, -1);
gtk_radio_action_set_group (default_action, radio_group);
g_signal_connect (
default_action, "changed",
G_CALLBACK (action_mail_charset_cb), reader);
gtk_action_group_add_action (
action_group, GTK_ACTION (default_action));
gtk_radio_action_set_current_value (default_action, -1);
}
static void
e_mail_reader_default_init (EMailReaderInterface *interface)
{
quark_private = g_quark_from_static_string ("e-mail-reader-private");
/* Forward and reply styles are stored outside of the private
* structure as a workaround for EMailShellContent, which loads
* extensions long before the private structure is initialized,
* and one of those extensions binds our "forward-style" and
* "reply-style" properties to EShellSettings properties. */
quark_forward_style =
g_quark_from_static_string ("e-mail-reader-forward-style");
quark_reply_style =
g_quark_from_static_string ("e-mail-reader-reply-style");
interface->get_selected_uids = mail_reader_get_selected_uids;
interface->get_folder = mail_reader_get_folder;
interface->get_folder_uri = mail_reader_get_folder_uri;
interface->enable_show_folder = mail_reader_get_enable_show_folder;
interface->set_folder = mail_reader_set_folder;
interface->set_message = mail_reader_set_message;
interface->open_selected_mail = e_mail_reader_open_selected;
interface->update_actions = mail_reader_update_actions;
g_object_interface_install_property (
interface,
g_param_spec_enum (
"forward-style",
"Forward Style",
"How to forward messages",
E_TYPE_MAIL_FORWARD_STYLE,
E_MAIL_FORWARD_STYLE_ATTACHED,
G_PARAM_READWRITE));
g_object_interface_install_property (
interface,
g_param_spec_boolean (
"group-by-threads",
"Group by Threads",
"Whether to group messages by threads",
FALSE,
G_PARAM_READWRITE));
g_object_interface_install_property (
interface,
g_param_spec_enum (
"reply-style",
"Reply Style",
"How to reply to messages",
E_TYPE_MAIL_REPLY_STYLE,
E_MAIL_REPLY_STYLE_QUOTED,
G_PARAM_READWRITE));
signals[CHANGED] = g_signal_new (
"changed",
G_OBJECT_CLASS_TYPE (interface),
G_SIGNAL_RUN_FIRST,
0, NULL, NULL,
g_cclosure_marshal_VOID__VOID,
G_TYPE_NONE, 0);
signals[FOLDER_LOADED] = g_signal_new (
"folder-loaded",
G_OBJECT_CLASS_TYPE (interface),
G_SIGNAL_RUN_FIRST,
0, NULL, NULL,
g_cclosure_marshal_VOID__VOID,
G_TYPE_NONE, 0);
signals[SHOW_SEARCH_BAR] = g_signal_new (
"show-search-bar",
G_OBJECT_CLASS_TYPE (interface),
G_SIGNAL_RUN_FIRST | G_SIGNAL_ACTION,
G_STRUCT_OFFSET (EMailReaderInterface, show_search_bar),
NULL, NULL,
g_cclosure_marshal_VOID__VOID,
G_TYPE_NONE, 0);
signals[SHOW_FOLDER] = g_signal_new (
"show-folder",
G_OBJECT_CLASS_TYPE (interface),
G_SIGNAL_RUN_FIRST | G_SIGNAL_ACTION,
0,
NULL, NULL,
g_cclosure_marshal_VOID__VOID,
G_TYPE_NONE, 0);
signals[SHOW_NEXTTAB] = g_signal_new (
"show-next-tab",
G_OBJECT_CLASS_TYPE (interface),
G_SIGNAL_RUN_FIRST | G_SIGNAL_ACTION,
0,
NULL, NULL,
g_cclosure_marshal_VOID__VOID,
G_TYPE_NONE, 0);
signals[SHOW_PREVTAB] = g_signal_new (
"show-previous-tab",
G_OBJECT_CLASS_TYPE (interface),
G_SIGNAL_RUN_FIRST | G_SIGNAL_ACTION,
0,
NULL, NULL,
g_cclosure_marshal_VOID__VOID,
G_TYPE_NONE, 0);
signals[CLOSE_TAB] = g_signal_new (
"close-tab",
G_OBJECT_CLASS_TYPE (interface),
G_SIGNAL_RUN_FIRST | G_SIGNAL_ACTION,
0,
NULL, NULL,
g_cclosure_marshal_VOID__VOID,
G_TYPE_NONE, 0);
signals[UPDATE_ACTIONS] = g_signal_new (
"update-actions",
G_OBJECT_CLASS_TYPE (interface),
G_SIGNAL_RUN_FIRST | G_SIGNAL_ACTION,
G_STRUCT_OFFSET (EMailReaderInterface, update_actions),
NULL, NULL,
g_cclosure_marshal_VOID__UINT,
G_TYPE_NONE, 1,
G_TYPE_UINT);
}
void
e_mail_reader_init (EMailReader *reader,
gboolean init_actions,
gboolean connect_signals)
{
EMFormatHTML *formatter;
EMenuToolAction *menu_tool_action;
EWebView *web_view;
GtkActionGroup *action_group;
GtkWidget *message_list;
GConfBridge *bridge;
GtkAction *action;
gboolean sensitive;
const gchar *action_name;
const gchar *key;
#ifndef G_OS_WIN32
GSettings *settings;
#endif
g_return_if_fail (E_IS_MAIL_READER (reader));
formatter = e_mail_reader_get_formatter (reader);
message_list = e_mail_reader_get_message_list (reader);
web_view = em_format_html_get_web_view (formatter);
if (!init_actions)
goto connect_signals;
action_group = e_mail_reader_get_action_group (reader);
/* The "mail-forward" action is special: it uses a GtkMenuToolButton
* for its toolbar item type. So we have to create it separately. */
menu_tool_action = e_menu_tool_action_new (
"mail-forward", _("_Forward"),
_("Forward the selected message to someone"), NULL);
gtk_action_set_icon_name (
GTK_ACTION (menu_tool_action), "mail-forward");
g_signal_connect (
menu_tool_action, "activate",
G_CALLBACK (action_mail_forward_cb), reader);
gtk_action_group_add_action_with_accel (
action_group, GTK_ACTION (menu_tool_action), "<Control>f");
/* Likewise the "mail-reply-group" action */
/* For Translators: "Group Reply" will reply either to a mailing list
(if possible and if that configuration option is enabled), or else
it will reply to all. The word "Group" was chosen because it covers
either of those, without too strongly implying one or the other. */
menu_tool_action = e_menu_tool_action_new (
"mail-reply-group", _("Group Reply"),
_("Reply to the mailing list, or to all recipients"), NULL);
gtk_action_set_icon_name (
GTK_ACTION (menu_tool_action), "mail-reply-all");
g_signal_connect (
menu_tool_action, "activate",
G_CALLBACK (action_mail_reply_group_cb), reader);
gtk_action_group_add_action_with_accel (
action_group, GTK_ACTION (menu_tool_action), "<Control>g");
/* Add the other actions the normal way. */
gtk_action_group_set_translation_domain (action_group, GETTEXT_PACKAGE);
gtk_action_group_add_actions (
action_group, mail_reader_entries,
G_N_ELEMENTS (mail_reader_entries), reader);
e_action_group_add_popup_actions (
action_group, mail_reader_popup_entries,
G_N_ELEMENTS (mail_reader_popup_entries));
gtk_action_group_add_toggle_actions (
action_group, mail_reader_toggle_entries,
G_N_ELEMENTS (mail_reader_toggle_entries), reader);
mail_reader_init_charset_actions (reader);
/* Bind GObject properties to GConf keys. */
bridge = gconf_bridge_get ();
action_name = "mail-caret-mode";
key = "/apps/evolution/mail/display/caret_mode";
action = e_mail_reader_get_action (reader, action_name);
gconf_bridge_bind_property (bridge, key, G_OBJECT (action), "active");
action_name = "mail-show-all-headers";
key = "/apps/evolution/mail/display/show_all_headers";
action = e_mail_reader_get_action (reader, action_name);
gconf_bridge_bind_property (bridge, key, G_OBJECT (action), "active");
/* Fine tuning. */
action_name = "mail-delete";
action = e_mail_reader_get_action (reader, action_name);
gtk_action_set_short_label (action, _("Delete"));
action_name = "mail-forward";
action = e_mail_reader_get_action (reader, action_name);
gtk_action_set_is_important (action, TRUE);
action_name = "mail-reply-group";
action = e_mail_reader_get_action (reader, action_name);
gtk_action_set_is_important (action, TRUE);
action_name = "mail-goto-folder";
action = e_mail_reader_get_action (reader, action_name);
sensitive = e_mail_reader_get_enable_show_folder (reader);
gtk_action_set_sensitive (action, sensitive);
gtk_action_set_visible (action, FALSE);
action_name = "mail-goto-nexttab";
action = e_mail_reader_get_action (reader, action_name);
gtk_action_set_sensitive (action, TRUE);
gtk_action_set_visible (action, FALSE);
action_name = "mail-goto-prevtab";
action = e_mail_reader_get_action (reader, action_name);
gtk_action_set_sensitive (action, TRUE);
gtk_action_set_visible (action, FALSE);
action_name = "mail-close-tab";
action = e_mail_reader_get_action (reader, action_name);
gtk_action_set_sensitive (action, TRUE);
gtk_action_set_visible (action, FALSE);
action_name = "mail-next";
action = e_mail_reader_get_action (reader, action_name);
gtk_action_set_short_label (action, _("Next"));
action_name = "mail-previous";
action = e_mail_reader_get_action (reader, action_name);
gtk_action_set_short_label (action, _("Previous"));
action_name = "mail-reply-all";
action = e_mail_reader_get_action (reader, action_name);
gtk_action_set_is_important (action, TRUE);
action_name = "mail-reply-sender";
action = e_mail_reader_get_action (reader, action_name);
gtk_action_set_is_important (action, TRUE);
gtk_action_set_short_label (action, _("Reply"));
action_name = "add-to-address-book";
action = e_web_view_get_action (web_view, action_name);
g_signal_connect (
action, "activate",
G_CALLBACK (action_add_to_address_book_cb), reader);
action_name = "search-folder-recipient";
action = e_web_view_get_action (web_view, action_name);
g_signal_connect (
action, "activate",
G_CALLBACK (action_search_folder_recipient_cb), reader);
action_name = "search-folder-sender";
action = e_web_view_get_action (web_view, action_name);
g_signal_connect (
action, "activate",
G_CALLBACK (action_search_folder_sender_cb), reader);
#ifndef G_OS_WIN32
/* Lockdown integration. */
settings = g_settings_new ("org.gnome.desktop.lockdown");
action_name = "mail-print";
action = e_mail_reader_get_action (reader, action_name);
g_settings_bind (
settings, "disable-printing",
action, "visible",
G_SETTINGS_BIND_GET |
G_SETTINGS_BIND_NO_SENSITIVITY |
G_SETTINGS_BIND_INVERT_BOOLEAN);
action_name = "mail-print-preview";
action = e_mail_reader_get_action (reader, action_name);
g_settings_bind (
settings, "disable-printing",
action, "visible",
G_SETTINGS_BIND_GET |
G_SETTINGS_BIND_NO_SENSITIVITY |
G_SETTINGS_BIND_INVERT_BOOLEAN);
action_name = "mail-save-as";
action = e_mail_reader_get_action (reader, action_name);
g_settings_bind (
settings, "disable-save-to-disk",
action, "visible",
G_SETTINGS_BIND_GET |
G_SETTINGS_BIND_NO_SENSITIVITY |
G_SETTINGS_BIND_INVERT_BOOLEAN);
g_object_unref (settings);
#endif
/* Bind properties. */
action_name = "mail-caret-mode";
action = e_mail_reader_get_action (reader, action_name);
g_object_bind_property (
action, "active",
web_view, "caret-mode",
G_BINDING_BIDIRECTIONAL |
G_BINDING_SYNC_CREATE);
connect_signals:
if (!connect_signals)
goto init_private;
/* Connect signals. */
g_signal_connect_swapped (
web_view, "key-press-event",
G_CALLBACK (mail_reader_key_press_event_cb), reader);
g_signal_connect_swapped (
message_list, "message-selected",
G_CALLBACK (mail_reader_message_selected_cb), reader);
g_signal_connect_swapped (
message_list, "message-list-built",
G_CALLBACK (mail_reader_emit_folder_loaded), reader);
g_signal_connect_swapped (
message_list, "double-click",
G_CALLBACK (mail_reader_double_click_cb), reader);
g_signal_connect_swapped (
message_list, "key-press",
G_CALLBACK (mail_reader_key_press_cb), reader);
g_signal_connect_swapped (
message_list, "selection-change",
G_CALLBACK (e_mail_reader_changed), reader);
init_private:
/* Initialize a private struct. */
g_object_set_qdata_full (
G_OBJECT (reader), quark_private,
g_slice_new0 (EMailReaderPrivate),
(GDestroyNotify) mail_reader_private_free);
}
void
e_mail_reader_changed (EMailReader *reader)
{
g_return_if_fail (E_IS_MAIL_READER (reader));
g_signal_emit (reader, signals[CHANGED], 0);
}
guint32
e_mail_reader_check_state (EMailReader *reader)
{
GPtrArray *uids;
CamelFolder *folder;
CamelStore *store = NULL;
const gchar *tag;
gboolean can_clear_flags = FALSE;
gboolean can_flag_completed = FALSE;
gboolean can_flag_for_followup = FALSE;
gboolean has_attachments = FALSE;
gboolean has_deleted = FALSE;
gboolean has_important = FALSE;
gboolean has_junk = FALSE;
gboolean has_not_junk = FALSE;
gboolean has_read = FALSE;
gboolean has_undeleted = FALSE;
gboolean has_unimportant = FALSE;
gboolean has_unread = FALSE;
gboolean drafts_or_outbox = FALSE;
gboolean store_supports_vjunk = FALSE;
gboolean is_mailing_list;
gboolean is_junk_folder = FALSE;
guint32 state = 0;
guint ii;
g_return_val_if_fail (E_IS_MAIL_READER (reader), 0);
folder = e_mail_reader_get_folder (reader);
uids = e_mail_reader_get_selected_uids (reader);
if (folder != NULL) {
store = camel_folder_get_parent_store (folder);
store_supports_vjunk = (store->flags & CAMEL_STORE_VJUNK);
is_junk_folder =
(folder->folder_flags & CAMEL_FOLDER_IS_JUNK) != 0;
drafts_or_outbox =
em_utils_folder_is_drafts (folder) ||
em_utils_folder_is_outbox (folder);
}
/* Initialize this flag based on whether there are any
* messages selected. We will update it in the loop. */
is_mailing_list = (uids->len > 0);
for (ii = 0; ii < uids->len; ii++) {
CamelMessageInfo *info;
const gchar *string;
guint32 flags;
info = camel_folder_get_message_info (
folder, uids->pdata[ii]);
if (info == NULL)
continue;
flags = camel_message_info_flags (info);
if (flags & CAMEL_MESSAGE_SEEN)
has_read = TRUE;
else
has_unread = TRUE;
if (flags & CAMEL_MESSAGE_ATTACHMENTS)
has_attachments = TRUE;
if (drafts_or_outbox) {
has_junk = FALSE;
has_not_junk = FALSE;
} else if (store_supports_vjunk) {
guint32 bitmask;
/* XXX Strictly speaking, this logic is correct.
* Problem is there's nothing in the message
* list that indicates whether a message is
* already marked "Not Junk". So the user may
* think the "Not Junk" button is enabling and
* disabling itself randomly as he reads mail. */
if (flags & CAMEL_MESSAGE_JUNK)
has_junk = TRUE;
if (flags & CAMEL_MESSAGE_NOTJUNK)
has_not_junk = TRUE;
bitmask = CAMEL_MESSAGE_JUNK | CAMEL_MESSAGE_NOTJUNK;
/* If neither junk flag is set, the
* message can be marked either way. */
if ((flags & bitmask) == 0) {
has_junk = TRUE;
has_not_junk = TRUE;
}
} else {
has_junk = TRUE;
has_not_junk = TRUE;
}
if (flags & CAMEL_MESSAGE_DELETED)
has_deleted = TRUE;
else
has_undeleted = TRUE;
if (flags & CAMEL_MESSAGE_FLAGGED)
has_important = TRUE;
else
has_unimportant = TRUE;
tag = camel_message_info_user_tag (info, "follow-up");
if (tag != NULL && *tag != '\0') {
can_clear_flags = TRUE;
tag = camel_message_info_user_tag (
info, "completed-on");
if (tag == NULL || *tag == '\0')
can_flag_completed = TRUE;
} else
can_flag_for_followup = TRUE;
string = camel_message_info_mlist (info);
is_mailing_list &= (string != NULL && *string != '\0');
camel_folder_free_message_info (folder, info);
}
if (e_get_any_enabled_account () != NULL)
state |= E_MAIL_READER_HAVE_ENABLED_ACCOUNT;
if (uids->len == 1)
state |= E_MAIL_READER_SELECTION_SINGLE;
if (uids->len > 1)
state |= E_MAIL_READER_SELECTION_MULTIPLE;
if (!drafts_or_outbox && uids->len == 1)
state |= E_MAIL_READER_SELECTION_CAN_ADD_SENDER;
if (can_clear_flags)
state |= E_MAIL_READER_SELECTION_FLAG_CLEAR;
if (can_flag_completed)
state |= E_MAIL_READER_SELECTION_FLAG_COMPLETED;
if (can_flag_for_followup)
state |= E_MAIL_READER_SELECTION_FLAG_FOLLOWUP;
if (has_attachments)
state |= E_MAIL_READER_SELECTION_HAS_ATTACHMENTS;
if (has_deleted)
state |= E_MAIL_READER_SELECTION_HAS_DELETED;
if (has_important)
state |= E_MAIL_READER_SELECTION_HAS_IMPORTANT;
if (has_junk)
state |= E_MAIL_READER_SELECTION_HAS_JUNK;
if (has_not_junk)
state |= E_MAIL_READER_SELECTION_HAS_NOT_JUNK;
if (has_read)
state |= E_MAIL_READER_SELECTION_HAS_READ;
if (has_undeleted)
state |= E_MAIL_READER_SELECTION_HAS_UNDELETED;
if (has_unimportant)
state |= E_MAIL_READER_SELECTION_HAS_UNIMPORTANT;
if (has_unread)
state |= E_MAIL_READER_SELECTION_HAS_UNREAD;
if (is_mailing_list)
state |= E_MAIL_READER_SELECTION_IS_MAILING_LIST;
if (is_junk_folder)
state |= E_MAIL_READER_FOLDER_IS_JUNK;
em_utils_uids_free (uids);
return state;
}
void
e_mail_reader_update_actions (EMailReader *reader,
guint32 state)
{
g_return_if_fail (E_IS_MAIL_READER (reader));
g_signal_emit (reader, signals[UPDATE_ACTIONS], 0, state);
}
GtkAction *
e_mail_reader_get_action (EMailReader *reader,
const gchar *action_name)
{
GtkActionGroup *action_group;
GtkAction *action;
g_return_val_if_fail (E_IS_MAIL_READER (reader), NULL);
g_return_val_if_fail (action_name != NULL, NULL);
action_group = e_mail_reader_get_action_group (reader);
action = gtk_action_group_get_action (action_group, action_name);
if (action == NULL)
g_critical (
"%s: action '%s' not found", G_STRFUNC, action_name);
return action;
}
GtkActionGroup *
e_mail_reader_get_action_group (EMailReader *reader)
{
EMailReaderInterface *interface;
g_return_val_if_fail (E_IS_MAIL_READER (reader), NULL);
interface = E_MAIL_READER_GET_INTERFACE (reader);
g_return_val_if_fail (interface->get_action_group != NULL, NULL);
return interface->get_action_group (reader);
}
EAlertSink *
e_mail_reader_get_alert_sink (EMailReader *reader)
{
EMailReaderInterface *interface;
g_return_val_if_fail (E_IS_MAIL_READER (reader), NULL);
interface = E_MAIL_READER_GET_INTERFACE (reader);
g_return_val_if_fail (interface->get_alert_sink != NULL, NULL);
return interface->get_alert_sink (reader);
}
EMailBackend *
e_mail_reader_get_backend (EMailReader *reader)
{
EMailReaderInterface *interface;
g_return_val_if_fail (E_IS_MAIL_READER (reader), NULL);
interface = E_MAIL_READER_GET_INTERFACE (reader);
g_return_val_if_fail (interface->get_backend != NULL, NULL);
return interface->get_backend (reader);
}
EMFormatHTML *
e_mail_reader_get_formatter (EMailReader *reader)
{
EMailReaderInterface *interface;
g_return_val_if_fail (E_IS_MAIL_READER (reader), NULL);
interface = E_MAIL_READER_GET_INTERFACE (reader);
g_return_val_if_fail (interface->get_formatter != NULL, NULL);
return interface->get_formatter (reader);
}
gboolean
e_mail_reader_get_hide_deleted (EMailReader *reader)
{
EMailReaderInterface *interface;
g_return_val_if_fail (E_IS_MAIL_READER (reader), FALSE);
interface = E_MAIL_READER_GET_INTERFACE (reader);
g_return_val_if_fail (interface->get_hide_deleted != NULL, FALSE);
return interface->get_hide_deleted (reader);
}
GtkWidget *
e_mail_reader_get_message_list (EMailReader *reader)
{
EMailReaderInterface *interface;
g_return_val_if_fail (E_IS_MAIL_READER (reader), NULL);
interface = E_MAIL_READER_GET_INTERFACE (reader);
g_return_val_if_fail (interface->get_message_list != NULL, NULL);
return interface->get_message_list (reader);
}
GtkMenu *
e_mail_reader_get_popup_menu (EMailReader *reader)
{
EMailReaderInterface *interface;
g_return_val_if_fail (E_IS_MAIL_READER (reader), NULL);
interface = E_MAIL_READER_GET_INTERFACE (reader);
g_return_val_if_fail (interface->get_popup_menu != NULL, NULL);
return interface->get_popup_menu (reader);
}
GPtrArray *
e_mail_reader_get_selected_uids (EMailReader *reader)
{
EMailReaderInterface *interface;
g_return_val_if_fail (E_IS_MAIL_READER (reader), NULL);
interface = E_MAIL_READER_GET_INTERFACE (reader);
g_return_val_if_fail (interface->get_selected_uids != NULL, NULL);
return interface->get_selected_uids (reader);
}
GtkWindow *
e_mail_reader_get_window (EMailReader *reader)
{
EMailReaderInterface *interface;
g_return_val_if_fail (E_IS_MAIL_READER (reader), NULL);
interface = E_MAIL_READER_GET_INTERFACE (reader);
g_return_val_if_fail (interface->get_window != NULL, NULL);
return interface->get_window (reader);
}
CamelFolder *
e_mail_reader_get_folder (EMailReader *reader)
{
EMailReaderInterface *interface;
g_return_val_if_fail (E_IS_MAIL_READER (reader), NULL);
interface = E_MAIL_READER_GET_INTERFACE (reader);
g_return_val_if_fail (interface->get_folder != NULL, NULL);
return interface->get_folder (reader);
}
const gchar *
e_mail_reader_get_folder_uri (EMailReader *reader)
{
EMailReaderInterface *interface;
g_return_val_if_fail (E_IS_MAIL_READER (reader), NULL);
interface = E_MAIL_READER_GET_INTERFACE (reader);
g_return_val_if_fail (interface->get_folder_uri != NULL, NULL);
return interface->get_folder_uri (reader);
}
void
e_mail_reader_set_folder (EMailReader *reader,
CamelFolder *folder)
{
EMailReaderInterface *interface;
g_return_if_fail (E_IS_MAIL_READER (reader));
interface = E_MAIL_READER_GET_INTERFACE (reader);
g_return_if_fail (interface->set_folder != NULL);
interface->set_folder (reader, folder);
}
void
e_mail_reader_set_message (EMailReader *reader,
const gchar *uid)
{
EMailReaderInterface *interface;
g_return_if_fail (E_IS_MAIL_READER (reader));
interface = E_MAIL_READER_GET_INTERFACE (reader);
g_return_if_fail (interface->set_message != NULL);
interface->set_message (reader, uid);
}
guint
e_mail_reader_open_selected_mail (EMailReader *reader)
{
EMailReaderInterface *interface;
g_return_val_if_fail (E_IS_MAIL_READER (reader), 0);
interface = E_MAIL_READER_GET_INTERFACE (reader);
g_return_val_if_fail (interface->open_selected_mail != NULL, 0);
return interface->open_selected_mail (reader);
}
EMailForwardStyle
e_mail_reader_get_forward_style (EMailReader *reader)
{
g_return_val_if_fail (E_IS_MAIL_READER (reader), 0);
return (EMailForwardStyle)
GPOINTER_TO_INT (g_object_get_qdata (
G_OBJECT (reader), quark_forward_style));
}
void
e_mail_reader_set_forward_style (EMailReader *reader,
EMailForwardStyle style)
{
g_return_if_fail (E_IS_MAIL_READER (reader));
g_object_set_qdata (
G_OBJECT (reader), quark_forward_style,
GINT_TO_POINTER (style));
g_object_notify (G_OBJECT (reader), "forward-style");
}
gboolean
e_mail_reader_get_group_by_threads (EMailReader *reader)
{
EMailReaderPrivate *priv;
g_return_val_if_fail (E_IS_MAIL_READER (reader), FALSE);
priv = E_MAIL_READER_GET_PRIVATE (reader);
return priv->group_by_threads;
}
void
e_mail_reader_set_group_by_threads (EMailReader *reader,
gboolean group_by_threads)
{
EMailReaderPrivate *priv;
GtkWidget *message_list;
g_return_if_fail (E_IS_MAIL_READER (reader));
priv = E_MAIL_READER_GET_PRIVATE (reader);
if (group_by_threads == priv->group_by_threads)
return;
priv->group_by_threads = group_by_threads;
/* XXX MessageList should define a property for this. */
message_list = e_mail_reader_get_message_list (reader);
message_list_set_threaded (
MESSAGE_LIST (message_list), group_by_threads);
g_object_notify (G_OBJECT (reader), "group-by-threads");
}
EMailReplyStyle
e_mail_reader_get_reply_style (EMailReader *reader)
{
g_return_val_if_fail (E_IS_MAIL_READER (reader), 0);
return (EMailReplyStyle)
GPOINTER_TO_INT (g_object_get_qdata (
G_OBJECT (reader), quark_reply_style));
}
void
e_mail_reader_set_reply_style (EMailReader *reader,
EMailReplyStyle style)
{
g_return_if_fail (E_IS_MAIL_READER (reader));
g_object_set_qdata (
G_OBJECT (reader), quark_reply_style,
GINT_TO_POINTER (style));
g_object_notify (G_OBJECT (reader), "reply-style");
}
void
e_mail_reader_create_charset_menu (EMailReader *reader,
GtkUIManager *ui_manager,
guint merge_id)
{
GtkAction *action;
const gchar *action_name;
const gchar *path;
GSList *list;
g_return_if_fail (E_IS_MAIL_READER (reader));
g_return_if_fail (GTK_IS_UI_MANAGER (ui_manager));
action_name = "mail-charset-default";
action = e_mail_reader_get_action (reader, action_name);
g_return_if_fail (action != NULL);
list = gtk_radio_action_get_group (GTK_RADIO_ACTION (action));
list = g_slist_copy (list);
list = g_slist_remove (list, action);
list = g_slist_sort (list, (GCompareFunc) e_action_compare_by_label);
path = "/main-menu/view-menu/mail-message-view-actions/mail-encoding-menu";
while (list != NULL) {
action = list->data;
gtk_ui_manager_add_ui (
ui_manager, merge_id, path,
gtk_action_get_name (action),
gtk_action_get_name (action),
GTK_UI_MANAGER_AUTO, FALSE);
list = g_slist_delete_link (list, list);
}
gtk_ui_manager_ensure_update (ui_manager);
}
void
e_mail_reader_show_search_bar (EMailReader *reader)
{
g_return_if_fail (E_IS_MAIL_READER (reader));
g_signal_emit (reader, signals[SHOW_SEARCH_BAR], 0);
}
void
e_mail_reader_enable_show_folder (EMailReader *reader)
{
CamelFolder *folder;
GtkAction *action;
const gchar *action_name;
const gchar *full_name;
gboolean sensitive;
gchar *label;
g_return_if_fail (E_IS_MAIL_READER (reader));
folder = e_mail_reader_get_folder (reader);
full_name = camel_folder_get_full_name (folder);
label = g_strdup_printf (_("Folder '%s'"), full_name);
action_name = "mail-goto-folder";
action = e_mail_reader_get_action (reader, action_name);
sensitive = e_mail_reader_get_enable_show_folder (reader);
gtk_action_set_label (action, label);
gtk_action_set_visible (action, TRUE);
gtk_action_set_sensitive (action, sensitive);
g_free (label);
}
gboolean
e_mail_reader_get_enable_show_folder (EMailReader *reader)
{
EMailReaderInterface *interface;
g_return_val_if_fail (E_IS_MAIL_READER (reader), FALSE);
interface = E_MAIL_READER_GET_INTERFACE (reader);
g_return_val_if_fail (interface->enable_show_folder != NULL, FALSE);
return interface->enable_show_folder (reader);
}
|