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
|
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
/*
* This library 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) any later version.
*
* This library 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 this library; if not, write to the
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301 USA.
*
* Copyright 2007 - 2008 Novell, Inc.
* Copyright 2007 - 2014 Red Hat, Inc.
*/
#include "nm-default.h"
#include <string.h>
#include <libudev.h>
#include "nm-utils.h"
#include "nm-client.h"
#include "nm-manager.h"
#include "nm-dns-manager.h"
#include "nm-remote-settings.h"
#include "nm-device-ethernet.h"
#include "nm-device-wifi.h"
#include "nm-core-internal.h"
#include "nm-active-connection.h"
#include "nm-vpn-connection.h"
#include "nm-remote-connection.h"
#include "nm-dbus-helpers.h"
#include "nm-wimax-nsp.h"
#include "nm-object-private.h"
#include "introspection/org.freedesktop.NetworkManager.h"
#include "introspection/org.freedesktop.NetworkManager.Device.Wireless.h"
#include "introspection/org.freedesktop.NetworkManager.Device.h"
#include "introspection/org.freedesktop.NetworkManager.DnsManager.h"
#include "introspection/org.freedesktop.NetworkManager.Settings.h"
#include "introspection/org.freedesktop.NetworkManager.Settings.Connection.h"
#include "introspection/org.freedesktop.NetworkManager.VPN.Connection.h"
#include "introspection/org.freedesktop.NetworkManager.Connection.Active.h"
#include "nm-access-point.h"
#include "nm-active-connection.h"
#include "nm-checkpoint.h"
#include "nm-device-adsl.h"
#include "nm-device-bond.h"
#include "nm-device-bridge.h"
#include "nm-device-bt.h"
#include "nm-device-dummy.h"
#include "nm-device-ethernet.h"
#include "nm-device-generic.h"
#include "nm-device-infiniband.h"
#include "nm-device-ip-tunnel.h"
#include "nm-device-macsec.h"
#include "nm-device-macvlan.h"
#include "nm-device-modem.h"
#include "nm-device-olpc-mesh.h"
#include "nm-device-ovs-interface.h"
#include "nm-device-ovs-port.h"
#include "nm-device-ovs-bridge.h"
#include "nm-device-ppp.h"
#include "nm-device-team.h"
#include "nm-device-tun.h"
#include "nm-device-vlan.h"
#include "nm-device-vxlan.h"
#include "nm-device-wifi.h"
#include "nm-device-wimax.h"
#include "nm-dhcp4-config.h"
#include "nm-dhcp6-config.h"
#include "nm-dhcp-config.h"
#include "nm-ip4-config.h"
#include "nm-ip6-config.h"
#include "nm-manager.h"
#include "nm-remote-connection.h"
#include "nm-remote-settings.h"
#include "nm-vpn-connection.h"
void _nm_device_wifi_set_wireless_enabled (NMDeviceWifi *device, gboolean enabled);
static void nm_client_initable_iface_init (GInitableIface *iface);
static void nm_client_async_initable_iface_init (GAsyncInitableIface *iface);
G_DEFINE_TYPE_WITH_CODE (NMClient, nm_client, G_TYPE_OBJECT,
G_IMPLEMENT_INTERFACE (G_TYPE_INITABLE, nm_client_initable_iface_init);
G_IMPLEMENT_INTERFACE (G_TYPE_ASYNC_INITABLE, nm_client_async_initable_iface_init);
)
#define NM_CLIENT_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_CLIENT, NMClientPrivate))
typedef struct {
NMClient *client;
GCancellable *cancellable;
GSimpleAsyncResult *result;
int pending_init;
} NMClientInitData;
typedef struct {
NMManager *manager;
NMRemoteSettings *settings;
NMDnsManager *dns_manager;
GDBusObjectManager *object_manager;
GCancellable *new_object_manager_cancellable;
struct udev *udev;
} NMClientPrivate;
enum {
PROP_0,
PROP_VERSION,
PROP_STATE,
PROP_STARTUP,
PROP_NM_RUNNING,
PROP_NETWORKING_ENABLED,
PROP_WIRELESS_ENABLED,
PROP_WIRELESS_HARDWARE_ENABLED,
PROP_WWAN_ENABLED,
PROP_WWAN_HARDWARE_ENABLED,
PROP_WIMAX_ENABLED,
PROP_WIMAX_HARDWARE_ENABLED,
PROP_ACTIVE_CONNECTIONS,
PROP_CONNECTIVITY,
PROP_CONNECTIVITY_CHECK_AVAILABLE,
PROP_CONNECTIVITY_CHECK_ENABLED,
PROP_PRIMARY_CONNECTION,
PROP_ACTIVATING_CONNECTION,
PROP_DEVICES,
PROP_ALL_DEVICES,
PROP_CONNECTIONS,
PROP_HOSTNAME,
PROP_CAN_MODIFY,
PROP_METERED,
PROP_DNS_MODE,
PROP_DNS_RC_MANAGER,
PROP_DNS_CONFIGURATION,
PROP_CHECKPOINTS,
LAST_PROP
};
enum {
DEVICE_ADDED,
DEVICE_REMOVED,
ANY_DEVICE_ADDED,
ANY_DEVICE_REMOVED,
PERMISSION_CHANGED,
CONNECTION_ADDED,
CONNECTION_REMOVED,
ACTIVE_CONNECTION_ADDED,
ACTIVE_CONNECTION_REMOVED,
LAST_SIGNAL
};
static guint signals[LAST_SIGNAL] = { 0 };
static const GPtrArray empty = { 0, };
/*****************************************************************************/
/**
* nm_client_error_quark:
*
* Registers an error quark for #NMClient if necessary.
*
* Returns: the error quark used for #NMClient errors.
**/
NM_CACHED_QUARK_FCN ("nm-client-error-quark", nm_client_error_quark)
/*****************************************************************************/
static void
nm_client_init (NMClient *client)
{
}
static gboolean
_nm_client_check_nm_running (NMClient *client, GError **error)
{
if (nm_client_get_nm_running (client))
return TRUE;
else {
g_set_error_literal (error,
NM_CLIENT_ERROR,
NM_CLIENT_ERROR_MANAGER_NOT_RUNNING,
"NetworkManager is not running");
return FALSE;
}
}
/**
* nm_client_get_version:
* @client: a #NMClient
*
* Gets NetworkManager version.
*
* Returns: string with the version (or %NULL if NetworkManager is not running)
**/
const char *
nm_client_get_version (NMClient *client)
{
g_return_val_if_fail (NM_IS_CLIENT (client), NULL);
if (!nm_client_get_nm_running (client))
return NULL;
return nm_manager_get_version (NM_CLIENT_GET_PRIVATE (client)->manager);
}
/**
* nm_client_get_state:
* @client: a #NMClient
*
* Gets the current daemon state.
*
* Returns: the current %NMState
**/
NMState
nm_client_get_state (NMClient *client)
{
g_return_val_if_fail (NM_IS_CLIENT (client), NM_STATE_UNKNOWN);
if (!nm_client_get_nm_running (client))
return NM_STATE_UNKNOWN;
return nm_manager_get_state (NM_CLIENT_GET_PRIVATE (client)->manager);
}
/**
* nm_client_get_startup:
* @client: a #NMClient
*
* Tests whether the daemon is still in the process of activating
* connections at startup.
*
* Returns: whether the daemon is still starting up
**/
gboolean
nm_client_get_startup (NMClient *client)
{
g_return_val_if_fail (NM_IS_CLIENT (client), FALSE);
if (!nm_client_get_nm_running (client))
return FALSE;
return nm_manager_get_startup (NM_CLIENT_GET_PRIVATE (client)->manager);
}
/**
* nm_client_get_nm_running:
* @client: a #NMClient
*
* Determines whether the daemon is running.
*
* Returns: %TRUE if the daemon is running
**/
gboolean
nm_client_get_nm_running (NMClient *client)
{
g_return_val_if_fail (NM_IS_CLIENT (client), FALSE);
return NM_CLIENT_GET_PRIVATE (client)->manager != NULL;
}
/**
* nm_client_networking_get_enabled:
* @client: a #NMClient
*
* Whether networking is enabled or disabled.
*
* Returns: %TRUE if networking is enabled, %FALSE if networking is disabled
**/
gboolean
nm_client_networking_get_enabled (NMClient *client)
{
g_return_val_if_fail (NM_IS_CLIENT (client), FALSE);
if (!nm_client_get_nm_running (client))
return FALSE;
return nm_manager_networking_get_enabled (NM_CLIENT_GET_PRIVATE (client)->manager);
}
/**
* nm_client_networking_set_enabled:
* @client: a #NMClient
* @enabled: %TRUE to set networking enabled, %FALSE to set networking disabled
* @error: (allow-none): return location for a #GError, or %NULL
*
* Enables or disables networking. When networking is disabled, all controlled
* interfaces are disconnected and deactivated. When networking is enabled,
* all controlled interfaces are available for activation.
*
* Returns: %TRUE on success, %FALSE otherwise
**/
gboolean
nm_client_networking_set_enabled (NMClient *client, gboolean enable, GError **error)
{
g_return_val_if_fail (NM_IS_CLIENT (client), FALSE);
if (!_nm_client_check_nm_running (client, error))
return FALSE;
return nm_manager_networking_set_enabled (NM_CLIENT_GET_PRIVATE (client)->manager,
enable, error);
}
/**
* nm_client_wireless_get_enabled:
* @client: a #NMClient
*
* Determines whether the wireless is enabled.
*
* Returns: %TRUE if wireless is enabled
**/
gboolean
nm_client_wireless_get_enabled (NMClient *client)
{
g_return_val_if_fail (NM_IS_CLIENT (client), FALSE);
if (!nm_client_get_nm_running (client))
return FALSE;
return nm_manager_wireless_get_enabled (NM_CLIENT_GET_PRIVATE (client)->manager);
}
/**
* nm_client_wireless_set_enabled:
* @client: a #NMClient
* @enabled: %TRUE to enable wireless
*
* Enables or disables wireless devices.
**/
void
nm_client_wireless_set_enabled (NMClient *client, gboolean enabled)
{
g_return_if_fail (NM_IS_CLIENT (client));
if (!nm_client_get_nm_running (client))
return;
nm_manager_wireless_set_enabled (NM_CLIENT_GET_PRIVATE (client)->manager, enabled);
}
/**
* nm_client_wireless_hardware_get_enabled:
* @client: a #NMClient
*
* Determines whether the wireless hardware is enabled.
*
* Returns: %TRUE if the wireless hardware is enabled
**/
gboolean
nm_client_wireless_hardware_get_enabled (NMClient *client)
{
g_return_val_if_fail (NM_IS_CLIENT (client), FALSE);
if (!nm_client_get_nm_running (client))
return FALSE;
return nm_manager_wireless_hardware_get_enabled (NM_CLIENT_GET_PRIVATE (client)->manager);
}
/**
* nm_client_wwan_get_enabled:
* @client: a #NMClient
*
* Determines whether WWAN is enabled.
*
* Returns: %TRUE if WWAN is enabled
**/
gboolean
nm_client_wwan_get_enabled (NMClient *client)
{
g_return_val_if_fail (NM_IS_CLIENT (client), FALSE);
if (!nm_client_get_nm_running (client))
return FALSE;
return nm_manager_wwan_get_enabled (NM_CLIENT_GET_PRIVATE (client)->manager);
}
/**
* nm_client_wwan_set_enabled:
* @client: a #NMClient
* @enabled: %TRUE to enable WWAN
*
* Enables or disables WWAN devices.
**/
void
nm_client_wwan_set_enabled (NMClient *client, gboolean enabled)
{
g_return_if_fail (NM_IS_CLIENT (client));
if (!_nm_client_check_nm_running (client, NULL))
return;
nm_manager_wwan_set_enabled (NM_CLIENT_GET_PRIVATE (client)->manager, enabled);
}
/**
* nm_client_wwan_hardware_get_enabled:
* @client: a #NMClient
*
* Determines whether the WWAN hardware is enabled.
*
* Returns: %TRUE if the WWAN hardware is enabled
**/
gboolean
nm_client_wwan_hardware_get_enabled (NMClient *client)
{
g_return_val_if_fail (NM_IS_CLIENT (client), FALSE);
if (!nm_client_get_nm_running (client))
return FALSE;
return nm_manager_wwan_hardware_get_enabled (NM_CLIENT_GET_PRIVATE (client)->manager);
}
/**
* nm_client_wimax_get_enabled:
* @client: a #NMClient
*
* Determines whether WiMAX is enabled.
*
* Returns: %TRUE if WiMAX is enabled
**/
gboolean
nm_client_wimax_get_enabled (NMClient *client)
{
g_return_val_if_fail (NM_IS_CLIENT (client), FALSE);
if (!nm_client_get_nm_running (client))
return FALSE;
return nm_manager_wimax_get_enabled (NM_CLIENT_GET_PRIVATE (client)->manager);
}
/**
* nm_client_wimax_set_enabled:
* @client: a #NMClient
* @enabled: %TRUE to enable WiMAX
*
* Enables or disables WiMAX devices.
**/
void
nm_client_wimax_set_enabled (NMClient *client, gboolean enabled)
{
g_return_if_fail (NM_IS_CLIENT (client));
if (!nm_client_get_nm_running (client))
return;
nm_manager_wimax_set_enabled (NM_CLIENT_GET_PRIVATE (client)->manager, enabled);
}
/**
* nm_client_wimax_hardware_get_enabled:
* @client: a #NMClient
*
* Determines whether the WiMAX hardware is enabled.
*
* Returns: %TRUE if the WiMAX hardware is enabled
**/
gboolean
nm_client_wimax_hardware_get_enabled (NMClient *client)
{
g_return_val_if_fail (NM_IS_CLIENT (client), FALSE);
if (!nm_client_get_nm_running (client))
return FALSE;
return nm_manager_wimax_hardware_get_enabled (NM_CLIENT_GET_PRIVATE (client)->manager);
}
/**
* nm_client_connectivity_check_get_available:
* @client: a #NMClient
*
* Determine whether connectivity checking is available. This
* requires that the URI of a connectivity service has been set in the
* configuration file.
*
* Returns: %TRUE if connectivity checking is available.
*
* Since: 1.10
*/
gboolean
nm_client_connectivity_check_get_available (NMClient *client)
{
g_return_val_if_fail (NM_IS_CLIENT (client), FALSE);
if (!nm_client_get_nm_running (client))
return FALSE;
return nm_manager_connectivity_check_get_available (NM_CLIENT_GET_PRIVATE (client)->manager);
}
/**
* nm_client_connectivity_check_get_enabled:
* @client: a #NMClient
*
* Determine whether connectivity checking is enabled.
*
* Returns: %TRUE if connectivity checking is enabled.
*
* Since: 1.10
*/
gboolean
nm_client_connectivity_check_get_enabled (NMClient *client)
{
g_return_val_if_fail (NM_IS_CLIENT (client), FALSE);
if (!nm_client_get_nm_running (client))
return FALSE;
return nm_manager_connectivity_check_get_enabled (NM_CLIENT_GET_PRIVATE (client)->manager);
}
/**
* nm_client_connectivity_check_set_enabled:
* @client: a #NMClient
* @enabled: %TRUE to enable connectivity checking
*
* Enable or disable connectivity checking. Note that if a
* connectivity checking URI has not been configured, this will not
* have any effect.
*
* Since: 1.10
*/
void
nm_client_connectivity_check_set_enabled (NMClient *client, gboolean enabled)
{
g_return_if_fail (NM_IS_CLIENT (client));
if (!nm_client_get_nm_running (client))
return;
nm_manager_connectivity_check_set_enabled (NM_CLIENT_GET_PRIVATE (client)->manager, enabled);
}
/**
* nm_client_get_logging:
* @client: a #NMClient
* @level: (allow-none): return location for logging level string
* @domains: (allow-none): return location for log domains string. The string is
* a list of domains separated by ","
* @error: (allow-none): return location for a #GError, or %NULL
*
* Gets NetworkManager current logging level and domains.
*
* Returns: %TRUE on success, %FALSE otherwise
**/
gboolean
nm_client_get_logging (NMClient *client, char **level, char **domains, GError **error)
{
g_return_val_if_fail (NM_IS_CLIENT (client), FALSE);
g_return_val_if_fail (level == NULL || *level == NULL, FALSE);
g_return_val_if_fail (domains == NULL || *domains == NULL, FALSE);
g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
if (!_nm_client_check_nm_running (client, error))
return FALSE;
return nm_manager_get_logging (NM_CLIENT_GET_PRIVATE (client)->manager,
level, domains, error);
}
/**
* nm_client_set_logging:
* @client: a #NMClient
* @level: (allow-none): logging level to set (%NULL or an empty string for no change)
* @domains: (allow-none): logging domains to set. The string should be a list of log
* domains separated by ",". (%NULL or an empty string for no change)
* @error: (allow-none): return location for a #GError, or %NULL
*
* Sets NetworkManager logging level and/or domains.
*
* Returns: %TRUE on success, %FALSE otherwise
**/
gboolean
nm_client_set_logging (NMClient *client, const char *level, const char *domains, GError **error)
{
g_return_val_if_fail (NM_IS_CLIENT (client), FALSE);
g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
if (!_nm_client_check_nm_running (client, error))
return FALSE;
return nm_manager_set_logging (NM_CLIENT_GET_PRIVATE (client)->manager,
level, domains, error);
}
/**
* nm_client_get_permission_result:
* @client: a #NMClient
* @permission: the permission for which to return the result, one of #NMClientPermission
*
* Requests the result of a specific permission, which indicates whether the
* client can or cannot perform the action the permission represents
*
* Returns: the permission's result, one of #NMClientPermissionResult
**/
NMClientPermissionResult
nm_client_get_permission_result (NMClient *client, NMClientPermission permission)
{
g_return_val_if_fail (NM_IS_CLIENT (client), NM_CLIENT_PERMISSION_RESULT_UNKNOWN);
if (!nm_client_get_nm_running (client))
return NM_CLIENT_PERMISSION_RESULT_UNKNOWN;
return nm_manager_get_permission_result (NM_CLIENT_GET_PRIVATE (client)->manager, permission);
}
/**
* nm_client_get_connectivity:
* @client: an #NMClient
*
* Gets the current network connectivity state. Contrast
* nm_client_check_connectivity() and
* nm_client_check_connectivity_async(), which re-check the
* connectivity state first before returning any information.
*
* Returns: the current connectivity state
*/
NMConnectivityState
nm_client_get_connectivity (NMClient *client)
{
g_return_val_if_fail (NM_IS_CLIENT (client), NM_CONNECTIVITY_UNKNOWN);
if (!nm_client_get_nm_running (client))
return NM_CONNECTIVITY_UNKNOWN;
return nm_manager_get_connectivity (NM_CLIENT_GET_PRIVATE (client)->manager);
}
/**
* nm_client_check_connectivity:
* @client: an #NMClient
* @cancellable: a #GCancellable
* @error: return location for a #GError
*
* Updates the network connectivity state and returns the (new)
* current state. Contrast nm_client_get_connectivity(), which returns
* the most recent known state without re-checking.
*
* This is a blocking call; use nm_client_check_connectivity_async()
* if you do not want to block.
*
* Returns: the (new) current connectivity state
*/
NMConnectivityState
nm_client_check_connectivity (NMClient *client,
GCancellable *cancellable,
GError **error)
{
g_return_val_if_fail (NM_IS_CLIENT (client), NM_CONNECTIVITY_UNKNOWN);
if (!_nm_client_check_nm_running (client, error))
return NM_CONNECTIVITY_UNKNOWN;
return nm_manager_check_connectivity (NM_CLIENT_GET_PRIVATE (client)->manager,
cancellable, error);
}
static void
check_connectivity_cb (GObject *object,
GAsyncResult *result,
gpointer user_data)
{
GSimpleAsyncResult *simple = user_data;
NMConnectivityState connectivity;
GError *error = NULL;
connectivity = nm_manager_check_connectivity_finish (NM_MANAGER (object),
result, &error);
if (!error)
g_simple_async_result_set_op_res_gssize (simple, connectivity);
else
g_simple_async_result_take_error (simple, error);
g_simple_async_result_complete (simple);
g_object_unref (simple);
}
/**
* nm_client_check_connectivity_async:
* @client: an #NMClient
* @cancellable: a #GCancellable
* @callback: callback to call with the result
* @user_data: data for @callback.
*
* Asynchronously updates the network connectivity state and invokes
* @callback when complete. Contrast nm_client_get_connectivity(),
* which (immediately) returns the most recent known state without
* re-checking, and nm_client_check_connectivity(), which blocks.
*/
void
nm_client_check_connectivity_async (NMClient *client,
GCancellable *cancellable,
GAsyncReadyCallback callback,
gpointer user_data)
{
GSimpleAsyncResult *simple;
GError *error = NULL;
g_return_if_fail (NM_IS_CLIENT (client));
if (!_nm_client_check_nm_running (client, &error)) {
g_simple_async_report_take_gerror_in_idle (G_OBJECT (client), callback, user_data, error);
return;
}
simple = g_simple_async_result_new (G_OBJECT (client), callback, user_data,
nm_client_check_connectivity_async);
if (cancellable)
g_simple_async_result_set_check_cancellable (simple, cancellable);
nm_manager_check_connectivity_async (NM_CLIENT_GET_PRIVATE (client)->manager,
cancellable, check_connectivity_cb, simple);
}
/**
* nm_client_check_connectivity_finish:
* @client: an #NMClient
* @result: the #GAsyncResult
* @error: return location for a #GError
*
* Retrieves the result of an nm_client_check_connectivity_async()
* call.
*
* Returns: the (new) current connectivity state
*/
NMConnectivityState
nm_client_check_connectivity_finish (NMClient *client,
GAsyncResult *result,
GError **error)
{
GSimpleAsyncResult *simple;
g_return_val_if_fail (NM_IS_CLIENT (client), NM_CONNECTIVITY_UNKNOWN);
g_return_val_if_fail (G_IS_SIMPLE_ASYNC_RESULT (result), NM_CONNECTIVITY_UNKNOWN);
simple = G_SIMPLE_ASYNC_RESULT (result);
if (g_simple_async_result_propagate_error (simple, error))
return NM_CONNECTIVITY_UNKNOWN;
return (NMConnectivityState) g_simple_async_result_get_op_res_gssize (simple);
}
/**
* nm_client_save_hostname:
* @client: the %NMClient
* @hostname: (allow-none): the new persistent hostname to set, or %NULL to
* clear any existing persistent hostname
* @cancellable: a #GCancellable, or %NULL
* @error: return location for #GError
*
* Requests that the machine's persistent hostname be set to the specified value
* or cleared.
*
* Returns: %TRUE if the request was successful, %FALSE if it failed
**/
gboolean
nm_client_save_hostname (NMClient *client,
const char *hostname,
GCancellable *cancellable,
GError **error)
{
g_return_val_if_fail (NM_IS_CLIENT (client), FALSE);
if (!_nm_client_check_nm_running (client, error))
return FALSE;
return nm_remote_settings_save_hostname (NM_CLIENT_GET_PRIVATE (client)->settings,
hostname, cancellable, error);
}
static void
save_hostname_cb (GObject *object,
GAsyncResult *result,
gpointer user_data)
{
GSimpleAsyncResult *simple = user_data;
GError *error = NULL;
if (nm_remote_settings_save_hostname_finish (NM_REMOTE_SETTINGS (object), result, &error))
g_simple_async_result_set_op_res_gboolean (simple, TRUE);
else
g_simple_async_result_take_error (simple, error);
g_simple_async_result_complete (simple);
g_object_unref (simple);
}
/**
* nm_client_save_hostname_async:
* @client: the %NMClient
* @hostname: (allow-none): the new persistent hostname to set, or %NULL to
* clear any existing persistent hostname
* @cancellable: a #GCancellable, or %NULL
* @callback: (scope async): callback to be called when the operation completes
* @user_data: (closure): caller-specific data passed to @callback
*
* Requests that the machine's persistent hostname be set to the specified value
* or cleared.
**/
void
nm_client_save_hostname_async (NMClient *client,
const char *hostname,
GCancellable *cancellable,
GAsyncReadyCallback callback,
gpointer user_data)
{
GSimpleAsyncResult *simple;
GError *error = NULL;
g_return_if_fail (NM_IS_CLIENT (client));
if (!_nm_client_check_nm_running (client, &error)) {
g_simple_async_report_take_gerror_in_idle (G_OBJECT (client), callback, user_data, error);
return;
}
simple = g_simple_async_result_new (G_OBJECT (client), callback, user_data,
nm_client_save_hostname_async);
if (cancellable)
g_simple_async_result_set_check_cancellable (simple, cancellable);
nm_remote_settings_save_hostname_async (NM_CLIENT_GET_PRIVATE (client)->settings,
hostname,
cancellable, save_hostname_cb, simple);
}
/**
* nm_client_save_hostname_finish:
* @client: the %NMClient
* @result: the result passed to the #GAsyncReadyCallback
* @error: return location for #GError
*
* Gets the result of an nm_client_save_hostname_async() call.
*
* Returns: %TRUE if the request was successful, %FALSE if it failed
**/
gboolean
nm_client_save_hostname_finish (NMClient *client,
GAsyncResult *result,
GError **error)
{
GSimpleAsyncResult *simple;
g_return_val_if_fail (NM_IS_CLIENT (client), FALSE);
g_return_val_if_fail (G_IS_SIMPLE_ASYNC_RESULT (result), FALSE);
simple = G_SIMPLE_ASYNC_RESULT (result);
if (g_simple_async_result_propagate_error (simple, error))
return FALSE;
else
return g_simple_async_result_get_op_res_gboolean (simple);
}
/*****************************************************************************/
/* Devices */
/*****************************************************************************/
/**
* nm_client_get_devices:
* @client: a #NMClient
*
* Gets all the known network devices. Use nm_device_get_type() or the
* <literal>NM_IS_DEVICE_XXXX</literal> functions to determine what kind of
* device member of the returned array is, and then you may use device-specific
* methods such as nm_device_ethernet_get_hw_address().
*
* Returns: (transfer none) (element-type NMDevice): a #GPtrArray
* containing all the #NMDevices. The returned array is owned by the
* #NMClient object and should not be modified.
**/
const GPtrArray *
nm_client_get_devices (NMClient *client)
{
g_return_val_if_fail (NM_IS_CLIENT (client), NULL);
if (!nm_client_get_nm_running (client))
return ∅
return nm_manager_get_devices (NM_CLIENT_GET_PRIVATE (client)->manager);
}
/**
* nm_client_get_all_devices:
* @client: a #NMClient
*
* Gets both real devices and device placeholders (eg, software devices which
* do not currently exist, but could be created automatically by NetworkManager
* if one of their NMDevice::ActivatableConnections was activated). Use
* nm_device_is_real() to determine whether each device is a real device or
* a placeholder.
*
* Use nm_device_get_type() or the NM_IS_DEVICE_XXXX() functions to determine
* what kind of device each member of the returned array is, and then you may
* use device-specific methods such as nm_device_ethernet_get_hw_address().
*
* Returns: (transfer none) (element-type NMDevice): a #GPtrArray
* containing all the #NMDevices. The returned array is owned by the
* #NMClient object and should not be modified.
*
* Since: 1.2
**/
const GPtrArray *
nm_client_get_all_devices (NMClient *client)
{
g_return_val_if_fail (NM_IS_CLIENT (client), NULL);
if (!nm_client_get_nm_running (client))
return ∅
return nm_manager_get_all_devices (NM_CLIENT_GET_PRIVATE (client)->manager);
}
/**
* nm_client_get_device_by_path:
* @client: a #NMClient
* @object_path: the object path to search for
*
* Gets a #NMDevice from a #NMClient.
*
* Returns: (transfer none): the #NMDevice for the given @object_path or %NULL if none is found.
**/
NMDevice *
nm_client_get_device_by_path (NMClient *client, const char *object_path)
{
g_return_val_if_fail (NM_IS_CLIENT (client), NULL);
g_return_val_if_fail (object_path, NULL);
if (!nm_client_get_nm_running (client))
return NULL;
return nm_manager_get_device_by_path (NM_CLIENT_GET_PRIVATE (client)->manager, object_path);
}
/**
* nm_client_get_device_by_iface:
* @client: a #NMClient
* @iface: the interface name to search for
*
* Gets a #NMDevice from a #NMClient.
*
* Returns: (transfer none): the #NMDevice for the given @iface or %NULL if none is found.
**/
NMDevice *
nm_client_get_device_by_iface (NMClient *client, const char *iface)
{
g_return_val_if_fail (NM_IS_CLIENT (client), NULL);
g_return_val_if_fail (iface, NULL);
if (!nm_client_get_nm_running (client))
return NULL;
return nm_manager_get_device_by_iface (NM_CLIENT_GET_PRIVATE (client)->manager, iface);
}
/*****************************************************************************/
/* Active Connections */
/*****************************************************************************/
/**
* nm_client_get_active_connections:
* @client: a #NMClient
*
* Gets the active connections.
*
* Returns: (transfer none) (element-type NMActiveConnection): a #GPtrArray
* containing all the active #NMActiveConnections.
* The returned array is owned by the client and should not be modified.
**/
const GPtrArray *
nm_client_get_active_connections (NMClient *client)
{
g_return_val_if_fail (NM_IS_CLIENT (client), NULL);
if (!nm_client_get_nm_running (client))
return ∅
return nm_manager_get_active_connections (NM_CLIENT_GET_PRIVATE (client)->manager);
}
/**
* nm_client_get_primary_connection:
* @client: an #NMClient
*
* Gets the #NMActiveConnection corresponding to the primary active
* network device.
*
* In particular, when there is no VPN active, or the VPN does not
* have the default route, this returns the active connection that has
* the default route. If there is a VPN active with the default route,
* then this function returns the active connection that contains the
* route to the VPN endpoint.
*
* If there is no default route, or the default route is over a
* non-NetworkManager-recognized device, this will return %NULL.
*
* Returns: (transfer none): the appropriate #NMActiveConnection, if
* any
*/
NMActiveConnection *
nm_client_get_primary_connection (NMClient *client)
{
g_return_val_if_fail (NM_IS_CLIENT (client), NULL);
if (!nm_client_get_nm_running (client))
return NULL;
return nm_manager_get_primary_connection (NM_CLIENT_GET_PRIVATE (client)->manager);
}
/**
* nm_client_get_activating_connection:
* @client: an #NMClient
*
* Gets the #NMActiveConnection corresponding to a
* currently-activating connection that is expected to become the new
* #NMClient:primary-connection upon successful activation.
*
* Returns: (transfer none): the appropriate #NMActiveConnection, if
* any.
*/
NMActiveConnection *
nm_client_get_activating_connection (NMClient *client)
{
g_return_val_if_fail (NM_IS_CLIENT (client), NULL);
if (!nm_client_get_nm_running (client))
return NULL;
return nm_manager_get_activating_connection (NM_CLIENT_GET_PRIVATE (client)->manager);
}
static void
activate_cb (GObject *object,
GAsyncResult *result,
gpointer user_data)
{
GSimpleAsyncResult *simple = user_data;
NMActiveConnection *ac;
GError *error = NULL;
ac = nm_manager_activate_connection_finish (NM_MANAGER (object), result, &error);
if (ac)
g_simple_async_result_set_op_res_gpointer (simple, ac, g_object_unref);
else
g_simple_async_result_take_error (simple, error);
g_simple_async_result_complete (simple);
g_object_unref (simple);
}
/**
* nm_client_activate_connection_async:
* @client: a #NMClient
* @connection: (allow-none): an #NMConnection
* @device: (allow-none): the #NMDevice
* @specific_object: (allow-none): the object path of a connection-type-specific
* object this activation should use. This parameter is currently ignored for
* wired and mobile broadband connections, and the value of %NULL should be used
* (ie, no specific object). For Wi-Fi or WiMAX connections, pass the object
* path of a #NMAccessPoint or #NMWimaxNsp owned by @device, which you can
* get using nm_object_get_path(), and which will be used to complete the
* details of the newly added connection.
* @cancellable: a #GCancellable, or %NULL
* @callback: callback to be called when the activation has started
* @user_data: caller-specific data passed to @callback
*
* Asynchronously starts a connection to a particular network using the
* configuration settings from @connection and the network device @device.
* Certain connection types also take a "specific object" which is the object
* path of a connection- specific object, like an #NMAccessPoint for Wi-Fi
* connections, or an #NMWimaxNsp for WiMAX connections, to which you wish to
* connect. If the specific object is not given, NetworkManager can, in some
* cases, automatically determine which network to connect to given the settings
* in @connection.
*
* If @connection is not given for a device-based activation, NetworkManager
* picks the best available connection for the device and activates it.
*
* Note that the callback is invoked when NetworkManager has started activating
* the new connection, not when it finishes. You can use the returned
* #NMActiveConnection object (in particular, #NMActiveConnection:state) to
* track the activation to its completion.
**/
void
nm_client_activate_connection_async (NMClient *client,
NMConnection *connection,
NMDevice *device,
const char *specific_object,
GCancellable *cancellable,
GAsyncReadyCallback callback,
gpointer user_data)
{
GSimpleAsyncResult *simple;
GError *error = NULL;
g_return_if_fail (NM_IS_CLIENT (client));
if (device)
g_return_if_fail (NM_IS_DEVICE (device));
if (connection)
g_return_if_fail (NM_IS_CONNECTION (connection));
if (!_nm_client_check_nm_running (client, &error)) {
g_simple_async_report_take_gerror_in_idle (G_OBJECT (client), callback, user_data, error);
return;
}
simple = g_simple_async_result_new (G_OBJECT (client), callback, user_data,
nm_client_activate_connection_async);
if (cancellable)
g_simple_async_result_set_check_cancellable (simple, cancellable);
nm_manager_activate_connection_async (NM_CLIENT_GET_PRIVATE (client)->manager,
connection, device, specific_object,
cancellable, activate_cb, simple);
}
/**
* nm_client_activate_connection_finish:
* @client: an #NMClient
* @result: the result passed to the #GAsyncReadyCallback
* @error: location for a #GError, or %NULL
*
* Gets the result of a call to nm_client_activate_connection_async().
*
* Returns: (transfer full): the new #NMActiveConnection on success, %NULL on
* failure, in which case @error will be set.
**/
NMActiveConnection *
nm_client_activate_connection_finish (NMClient *client,
GAsyncResult *result,
GError **error)
{
GSimpleAsyncResult *simple;
g_return_val_if_fail (NM_IS_CLIENT (client), NULL);
g_return_val_if_fail (G_IS_SIMPLE_ASYNC_RESULT (result), NULL);
simple = G_SIMPLE_ASYNC_RESULT (result);
if (g_simple_async_result_propagate_error (simple, error))
return NULL;
else
return g_object_ref (g_simple_async_result_get_op_res_gpointer (simple));
}
static void
add_activate_cb (GObject *object,
GAsyncResult *result,
gpointer user_data)
{
GSimpleAsyncResult *simple = user_data;
NMActiveConnection *ac;
GError *error = NULL;
ac = nm_manager_add_and_activate_connection_finish (NM_MANAGER (object), result, &error);
if (ac)
g_simple_async_result_set_op_res_gpointer (simple, ac, g_object_unref);
else
g_simple_async_result_take_error (simple, error);
g_simple_async_result_complete (simple);
g_object_unref (simple);
}
/**
* nm_client_add_and_activate_connection_async:
* @client: a #NMClient
* @partial: (allow-none): an #NMConnection to add; the connection may be
* partially filled (or even %NULL) and will be completed by NetworkManager
* using the given @device and @specific_object before being added
* @device: the #NMDevice
* @specific_object: (allow-none): the object path of a connection-type-specific
* object this activation should use. This parameter is currently ignored for
* wired and mobile broadband connections, and the value of %NULL should be used
* (ie, no specific object). For Wi-Fi or WiMAX connections, pass the object
* path of a #NMAccessPoint or #NMWimaxNsp owned by @device, which you can
* get using nm_object_get_path(), and which will be used to complete the
* details of the newly added connection.
* @cancellable: a #GCancellable, or %NULL
* @callback: callback to be called when the activation has started
* @user_data: caller-specific data passed to @callback
*
* Adds a new connection using the given details (if any) as a template,
* automatically filling in missing settings with the capabilities of the given
* device and specific object. The new connection is then asynchronously
* activated as with nm_client_activate_connection_async(). Cannot be used for
* VPN connections at this time.
*
* Note that the callback is invoked when NetworkManager has started activating
* the new connection, not when it finishes. You can used the returned
* #NMActiveConnection object (in particular, #NMActiveConnection:state) to
* track the activation to its completion.
**/
void
nm_client_add_and_activate_connection_async (NMClient *client,
NMConnection *partial,
NMDevice *device,
const char *specific_object,
GCancellable *cancellable,
GAsyncReadyCallback callback,
gpointer user_data)
{
GSimpleAsyncResult *simple;
GError *error = NULL;
g_return_if_fail (NM_IS_CLIENT (client));
g_return_if_fail (NM_IS_DEVICE (device));
if (partial)
g_return_if_fail (NM_IS_CONNECTION (partial));
if (!_nm_client_check_nm_running (client, &error)) {
g_simple_async_report_take_gerror_in_idle (G_OBJECT (client), callback, user_data, error);
return;
}
simple = g_simple_async_result_new (G_OBJECT (client), callback, user_data,
nm_client_add_and_activate_connection_async);
if (cancellable)
g_simple_async_result_set_check_cancellable (simple, cancellable);
nm_manager_add_and_activate_connection_async (NM_CLIENT_GET_PRIVATE (client)->manager,
partial, device, specific_object,
cancellable, add_activate_cb, simple);
}
/**
* nm_client_add_and_activate_connection_finish:
* @client: an #NMClient
* @result: the result passed to the #GAsyncReadyCallback
* @error: location for a #GError, or %NULL
*
* Gets the result of a call to nm_client_add_and_activate_connection_async().
*
* You can call nm_active_connection_get_connection() on the returned
* #NMActiveConnection to find the path of the created #NMConnection.
*
* Returns: (transfer full): the new #NMActiveConnection on success, %NULL on
* failure, in which case @error will be set.
**/
NMActiveConnection *
nm_client_add_and_activate_connection_finish (NMClient *client,
GAsyncResult *result,
GError **error)
{
GSimpleAsyncResult *simple;
g_return_val_if_fail (NM_IS_CLIENT (client), NULL);
g_return_val_if_fail (G_IS_SIMPLE_ASYNC_RESULT (result), NULL);
simple = G_SIMPLE_ASYNC_RESULT (result);
if (g_simple_async_result_propagate_error (simple, error))
return NULL;
else
return g_object_ref (g_simple_async_result_get_op_res_gpointer (simple));
}
/**
* nm_client_deactivate_connection:
* @client: a #NMClient
* @active: the #NMActiveConnection to deactivate
* @cancellable: a #GCancellable, or %NULL
* @error: location for a #GError, or %NULL
*
* Deactivates an active #NMActiveConnection.
*
* Returns: success or failure
**/
gboolean
nm_client_deactivate_connection (NMClient *client,
NMActiveConnection *active,
GCancellable *cancellable,
GError **error)
{
g_return_val_if_fail (NM_IS_CLIENT (client), FALSE);
g_return_val_if_fail (NM_IS_ACTIVE_CONNECTION (active), FALSE);
if (!nm_client_get_nm_running (client))
return TRUE;
return nm_manager_deactivate_connection (NM_CLIENT_GET_PRIVATE (client)->manager,
active, cancellable, error);
}
static void
deactivated_cb (GObject *object,
GAsyncResult *result,
gpointer user_data)
{
GSimpleAsyncResult *simple = user_data;
GError *error = NULL;
if (nm_manager_deactivate_connection_finish (NM_MANAGER (object), result, &error))
g_simple_async_result_set_op_res_gboolean (simple, TRUE);
else
g_simple_async_result_take_error (simple, error);
g_simple_async_result_complete (simple);
g_object_unref (simple);
}
/**
* nm_client_deactivate_connection_async:
* @client: a #NMClient
* @active: the #NMActiveConnection to deactivate
* @cancellable: a #GCancellable, or %NULL
* @callback: callback to be called when the deactivation has completed
* @user_data: caller-specific data passed to @callback
*
* Asynchronously deactivates an active #NMActiveConnection.
**/
void
nm_client_deactivate_connection_async (NMClient *client,
NMActiveConnection *active,
GCancellable *cancellable,
GAsyncReadyCallback callback,
gpointer user_data)
{
GSimpleAsyncResult *simple;
g_return_if_fail (NM_IS_CLIENT (client));
g_return_if_fail (NM_IS_ACTIVE_CONNECTION (active));
simple = g_simple_async_result_new (G_OBJECT (client), callback, user_data,
nm_client_deactivate_connection_async);
if (cancellable)
g_simple_async_result_set_check_cancellable (simple, cancellable);
if (!_nm_client_check_nm_running (client, NULL)) {
g_simple_async_result_set_op_res_gboolean (simple, TRUE);
g_simple_async_result_complete_in_idle (simple);
g_object_unref (simple);
return;
}
nm_manager_deactivate_connection_async (NM_CLIENT_GET_PRIVATE (client)->manager,
active,
cancellable, deactivated_cb, simple);
}
/**
* nm_client_deactivate_connection_finish:
* @client: a #NMClient
* @result: the result passed to the #GAsyncReadyCallback
* @error: location for a #GError, or %NULL
*
* Gets the result of a call to nm_client_deactivate_connection_async().
*
* Returns: success or failure
**/
gboolean
nm_client_deactivate_connection_finish (NMClient *client,
GAsyncResult *result,
GError **error)
{
GSimpleAsyncResult *simple;
g_return_val_if_fail (NM_IS_CLIENT (client), FALSE);
g_return_val_if_fail (G_IS_SIMPLE_ASYNC_RESULT (result), FALSE);
simple = G_SIMPLE_ASYNC_RESULT (result);
if (g_simple_async_result_propagate_error (simple, error))
return FALSE;
else
return g_simple_async_result_get_op_res_gboolean (simple);
}
/*****************************************************************************/
/* Connections */
/*****************************************************************************/
/**
* nm_client_get_connections:
* @client: the %NMClient
*
* Returns: (transfer none) (element-type NMRemoteConnection): an array
* containing all connections provided by the remote settings service. The
* returned array is owned by the #NMClient object and should not be modified.
*
* The connections are as received from D-Bus and might not validate according
* to nm_connection_verify().
**/
const GPtrArray *
nm_client_get_connections (NMClient *client)
{
g_return_val_if_fail (NM_IS_CLIENT (client), NULL);
if (!nm_client_get_nm_running (client))
return ∅
return nm_remote_settings_get_connections (NM_CLIENT_GET_PRIVATE (client)->settings);
}
/**
* nm_client_get_connection_by_id:
* @client: the %NMClient
* @id: the id of the remote connection
*
* Returns the first matching %NMRemoteConnection matching a given @id.
*
* Returns: (transfer none): the remote connection object on success, or %NULL if no
* matching object was found.
*
* The connection is as received from D-Bus and might not validate according
* to nm_connection_verify().
**/
NMRemoteConnection *
nm_client_get_connection_by_id (NMClient *client, const char *id)
{
g_return_val_if_fail (NM_IS_CLIENT (client), NULL);
g_return_val_if_fail (id != NULL, NULL);
if (!nm_client_get_nm_running (client))
return NULL;
return nm_remote_settings_get_connection_by_id (NM_CLIENT_GET_PRIVATE (client)->settings, id);
}
/**
* nm_client_get_connection_by_path:
* @client: the %NMClient
* @path: the D-Bus object path of the remote connection
*
* Returns the %NMRemoteConnection representing the connection at @path.
*
* Returns: (transfer none): the remote connection object on success, or %NULL if the object was
* not known
*
* The connection is as received from D-Bus and might not validate according
* to nm_connection_verify().
**/
NMRemoteConnection *
nm_client_get_connection_by_path (NMClient *client, const char *path)
{
g_return_val_if_fail (NM_IS_CLIENT (client), NULL);
g_return_val_if_fail (path != NULL, NULL);
if (!nm_client_get_nm_running (client))
return NULL;
return nm_remote_settings_get_connection_by_path (NM_CLIENT_GET_PRIVATE (client)->settings, path);
}
/**
* nm_client_get_connection_by_uuid:
* @client: the %NMClient
* @uuid: the UUID of the remote connection
*
* Returns the %NMRemoteConnection identified by @uuid.
*
* Returns: (transfer none): the remote connection object on success, or %NULL if the object was
* not known
*
* The connection is as received from D-Bus and might not validate according
* to nm_connection_verify().
**/
NMRemoteConnection *
nm_client_get_connection_by_uuid (NMClient *client, const char *uuid)
{
g_return_val_if_fail (NM_IS_CLIENT (client), NULL);
g_return_val_if_fail (uuid != NULL, NULL);
if (!nm_client_get_nm_running (client))
return NULL;
return nm_remote_settings_get_connection_by_uuid (NM_CLIENT_GET_PRIVATE (client)->settings, uuid);
}
static void
add_connection_cb (GObject *object,
GAsyncResult *result,
gpointer user_data)
{
GSimpleAsyncResult *simple = user_data;
NMRemoteConnection *conn;
GError *error = NULL;
conn = nm_remote_settings_add_connection_finish (NM_REMOTE_SETTINGS (object), result, &error);
if (conn)
g_simple_async_result_set_op_res_gpointer (simple, conn, g_object_unref);
else
g_simple_async_result_take_error (simple, error);
g_simple_async_result_complete (simple);
g_object_unref (simple);
}
/**
* nm_client_add_connection_async:
* @client: the %NMClient
* @connection: the connection to add. Note that this object's settings will be
* added, not the object itself
* @save_to_disk: whether to immediately save the connection to disk
* @cancellable: a #GCancellable, or %NULL
* @callback: (scope async): callback to be called when the add operation completes
* @user_data: (closure): caller-specific data passed to @callback
*
* Requests that the remote settings service add the given settings to a new
* connection. If @save_to_disk is %TRUE, the connection is immediately written
* to disk; otherwise it is initially only stored in memory, but may be saved
* later by calling the connection's nm_remote_connection_commit_changes()
* method.
*
* @connection is untouched by this function and only serves as a template of
* the settings to add. The #NMRemoteConnection object that represents what
* NetworkManager actually added is returned to @callback when the addition
* operation is complete.
*
* Note that the #NMRemoteConnection returned in @callback may not contain
* identical settings to @connection as NetworkManager may perform automatic
* completion and/or normalization of connection properties.
**/
void
nm_client_add_connection_async (NMClient *client,
NMConnection *connection,
gboolean save_to_disk,
GCancellable *cancellable,
GAsyncReadyCallback callback,
gpointer user_data)
{
GSimpleAsyncResult *simple;
GError *error = NULL;
g_return_if_fail (NM_IS_CLIENT (client));
g_return_if_fail (NM_IS_CONNECTION (connection));
if (!_nm_client_check_nm_running (client, &error)) {
g_simple_async_report_take_gerror_in_idle (G_OBJECT (client), callback, user_data, error);
return;
}
simple = g_simple_async_result_new (G_OBJECT (client), callback, user_data,
nm_client_add_connection_async);
if (cancellable)
g_simple_async_result_set_check_cancellable (simple, cancellable);
nm_remote_settings_add_connection_async (NM_CLIENT_GET_PRIVATE (client)->settings,
connection, save_to_disk,
cancellable, add_connection_cb, simple);
}
/**
* nm_client_add_connection_finish:
* @client: an #NMClient
* @result: the result passed to the #GAsyncReadyCallback
* @error: location for a #GError, or %NULL
*
* Gets the result of a call to nm_client_add_connection_async().
*
* Returns: (transfer full): the new #NMRemoteConnection on success, %NULL on
* failure, in which case @error will be set.
**/
NMRemoteConnection *
nm_client_add_connection_finish (NMClient *client,
GAsyncResult *result,
GError **error)
{
GSimpleAsyncResult *simple;
g_return_val_if_fail (NM_IS_CLIENT (client), NULL);
g_return_val_if_fail (G_IS_SIMPLE_ASYNC_RESULT (result), NULL);
simple = G_SIMPLE_ASYNC_RESULT (result);
if (g_simple_async_result_propagate_error (simple, error))
return NULL;
else
return g_object_ref (g_simple_async_result_get_op_res_gpointer (simple));
}
/**
* nm_client_load_connections:
* @client: the %NMClient
* @filenames: (array zero-terminated=1): %NULL-terminated array of filenames to load
* @failures: (out) (transfer full): on return, a %NULL-terminated array of
* filenames that failed to load
* @cancellable: a #GCancellable, or %NULL
* @error: return location for #GError
*
* Requests that the remote settings service load or reload the given files,
* adding or updating the connections described within.
*
* The changes to the indicated files will not yet be reflected in
* @client's connections array when the function returns.
*
* If all of the indicated files were successfully loaded, the
* function will return %TRUE, and @failures will be set to %NULL. If
* NetworkManager tried to load the files, but some (or all) failed,
* then @failures will be set to a %NULL-terminated array of the
* filenames that failed to load.
*
* Returns: %TRUE if NetworkManager at least tried to load @filenames,
* %FALSE if an error occurred (eg, permission denied).
**/
gboolean
nm_client_load_connections (NMClient *client,
char **filenames,
char ***failures,
GCancellable *cancellable,
GError **error)
{
g_return_val_if_fail (NM_IS_CLIENT (client), FALSE);
g_return_val_if_fail (filenames != NULL, FALSE);
if (!_nm_client_check_nm_running (client, error))
return FALSE;
return nm_remote_settings_load_connections (NM_CLIENT_GET_PRIVATE (client)->settings,
filenames, failures,
cancellable, error);
}
static void
load_connections_cb (GObject *object, GAsyncResult *result, gpointer user_data)
{
GSimpleAsyncResult *simple = user_data;
GError *error = NULL;
char **failures = NULL;
if (nm_remote_settings_load_connections_finish (NM_REMOTE_SETTINGS (object),
&failures, result, &error))
g_simple_async_result_set_op_res_gpointer (simple, failures, (GDestroyNotify) g_strfreev);
else
g_simple_async_result_take_error (simple, error);
g_simple_async_result_complete (simple);
g_object_unref (simple);
}
/**
* nm_client_load_connections_async:
* @client: the %NMClient
* @filenames: (array zero-terminated=1): %NULL-terminated array of filenames to load
* @cancellable: a #GCancellable, or %NULL
* @callback: (scope async): callback to be called when the operation completes
* @user_data: (closure): caller-specific data passed to @callback
*
* Requests that the remote settings service asynchronously load or reload the
* given files, adding or updating the connections described within.
*
* See nm_client_load_connections() for more details.
**/
void
nm_client_load_connections_async (NMClient *client,
char **filenames,
GCancellable *cancellable,
GAsyncReadyCallback callback,
gpointer user_data)
{
GSimpleAsyncResult *simple;
GError *error = NULL;
g_return_if_fail (NM_IS_CLIENT (client));
g_return_if_fail (filenames != NULL);
if (!_nm_client_check_nm_running (client, &error)) {
g_simple_async_report_take_gerror_in_idle (G_OBJECT (client), callback, user_data, error);
return;
}
simple = g_simple_async_result_new (G_OBJECT (client), callback, user_data,
nm_client_load_connections_async);
if (cancellable)
g_simple_async_result_set_check_cancellable (simple, cancellable);
nm_remote_settings_load_connections_async (NM_CLIENT_GET_PRIVATE (client)->settings,
filenames,
cancellable, load_connections_cb, simple);
}
/**
* nm_client_load_connections_finish:
* @client: the %NMClient
* @failures: (out) (transfer full) (array zero-terminated=1): on return, a
* %NULL-terminated array of filenames that failed to load
* @result: the result passed to the #GAsyncReadyCallback
* @error: location for a #GError, or %NULL
*
* Gets the result of an nm_client_load_connections_async() call.
* See nm_client_load_connections() for more details.
*
* Returns: %TRUE if NetworkManager at least tried to load @filenames,
* %FALSE if an error occurred (eg, permission denied).
**/
gboolean
nm_client_load_connections_finish (NMClient *client,
char ***failures,
GAsyncResult *result,
GError **error)
{
GSimpleAsyncResult *simple;
g_return_val_if_fail (NM_IS_CLIENT (client), FALSE);
g_return_val_if_fail (G_IS_SIMPLE_ASYNC_RESULT (result), FALSE);
simple = G_SIMPLE_ASYNC_RESULT (result);
if (g_simple_async_result_propagate_error (simple, error))
return FALSE;
else {
if (failures)
*failures = g_strdupv (g_simple_async_result_get_op_res_gpointer (simple));
return TRUE;
}
}
/**
* nm_client_reload_connections:
* @client: the #NMClient
* @cancellable: a #GCancellable, or %NULL
* @error: return location for #GError
*
* Requests that the remote settings service reload all connection
* files from disk, adding, updating, and removing connections until
* the in-memory state matches the on-disk state.
*
* Return value: %TRUE on success, %FALSE on failure
**/
gboolean
nm_client_reload_connections (NMClient *client,
GCancellable *cancellable,
GError **error)
{
g_return_val_if_fail (NM_IS_CLIENT (client), FALSE);
if (!_nm_client_check_nm_running (client, error))
return FALSE;
return nm_remote_settings_reload_connections (NM_CLIENT_GET_PRIVATE (client)->settings,
cancellable, error);
}
static void
reload_connections_cb (GObject *object, GAsyncResult *result, gpointer user_data)
{
GSimpleAsyncResult *simple = user_data;
GError *error = NULL;
if (nm_remote_settings_reload_connections_finish (NM_REMOTE_SETTINGS (object),
result, &error))
g_simple_async_result_set_op_res_gboolean (simple, TRUE);
else
g_simple_async_result_take_error (simple, error);
g_simple_async_result_complete (simple);
g_object_unref (simple);
}
/**
* nm_client_reload_connections_async:
* @client: the #NMClient
* @cancellable: a #GCancellable, or %NULL
* @callback: (scope async): callback to be called when the reload operation completes
* @user_data: (closure): caller-specific data passed to @callback
*
* Requests that the remote settings service begin reloading all connection
* files from disk, adding, updating, and removing connections until the
* in-memory state matches the on-disk state.
**/
void
nm_client_reload_connections_async (NMClient *client,
GCancellable *cancellable,
GAsyncReadyCallback callback,
gpointer user_data)
{
GSimpleAsyncResult *simple;
GError *error = NULL;
g_return_if_fail (NM_IS_CLIENT (client));
if (!_nm_client_check_nm_running (client, &error)) {
g_simple_async_report_take_gerror_in_idle (G_OBJECT (client), callback, user_data, error);
return;
}
simple = g_simple_async_result_new (G_OBJECT (client), callback, user_data,
nm_client_reload_connections_async);
if (cancellable)
g_simple_async_result_set_check_cancellable (simple, cancellable);
nm_remote_settings_reload_connections_async (NM_CLIENT_GET_PRIVATE (client)->settings,
cancellable, reload_connections_cb, simple);
}
/**
* nm_client_reload_connections_finish:
* @client: the #NMClient
* @result: the result passed to the #GAsyncReadyCallback
* @error: return location for #GError
*
* Gets the result of an nm_client_reload_connections_async() call.
*
* Return value: %TRUE on success, %FALSE on failure
**/
gboolean
nm_client_reload_connections_finish (NMClient *client,
GAsyncResult *result,
GError **error)
{
GSimpleAsyncResult *simple;
g_return_val_if_fail (NM_IS_CLIENT (client), FALSE);
g_return_val_if_fail (G_IS_SIMPLE_ASYNC_RESULT (result), FALSE);
simple = G_SIMPLE_ASYNC_RESULT (result);
if (g_simple_async_result_propagate_error (simple, error))
return FALSE;
else
return g_simple_async_result_get_op_res_gboolean (simple);
}
/*****************************************************************************/
/**
* nm_client_get_dns_mode:
* @client: the #NMClient
*
* Gets the current DNS processing mode.
*
* Return value: the DNS processing mode, or %NULL in case the
* value is not available.
*
* Since: 1.6
**/
const char *
nm_client_get_dns_mode (NMClient *client)
{
NMClientPrivate *priv;
g_return_val_if_fail (NM_IS_CLIENT (client), NULL);
priv = NM_CLIENT_GET_PRIVATE (client);
if (priv->dns_manager)
return nm_dns_manager_get_mode (priv->dns_manager);
else
return NULL;
}
/**
* nm_client_get_dns_rc_manager:
* @client: the #NMClient
*
* Gets the current DNS resolv.conf manager.
*
* Return value: the resolv.conf manager or %NULL in case the
* value is not available.
*
* Since: 1.6
**/
const char *
nm_client_get_dns_rc_manager (NMClient *client)
{
NMClientPrivate *priv;
g_return_val_if_fail (NM_IS_CLIENT (client), NULL);
priv = NM_CLIENT_GET_PRIVATE (client);
if (priv->dns_manager)
return nm_dns_manager_get_rc_manager (priv->dns_manager);
else
return NULL;
}
/**
* nm_client_get_dns_configuration:
* @client: a #NMClient
*
* Gets the current DNS configuration
*
* Returns: (transfer none) (element-type NMDnsEntry): a #GPtrArray
* containing #NMDnsEntry elements or %NULL in case the value is not
* available. The returned array is owned by the #NMClient object
* and should not be modified.
*
* Since: 1.6
**/
const GPtrArray *
nm_client_get_dns_configuration (NMClient *client)
{
NMClientPrivate *priv;
g_return_val_if_fail (NM_IS_CLIENT (client), NULL);
priv = NM_CLIENT_GET_PRIVATE (client);
if (priv->dns_manager)
return nm_dns_manager_get_configuration (priv->dns_manager);
else
return NULL;
}
/*****************************************************************************/
/**
* nm_client_new:
* @cancellable: a #GCancellable, or %NULL
* @error: location for a #GError, or %NULL
*
* Creates a new #NMClient.
*
* Note that this will do blocking D-Bus calls to initialize the
* client. You can use nm_client_new_async() if you want to avoid
* that.
*
* Returns: a new #NMClient or NULL on an error
**/
NMClient *
nm_client_new (GCancellable *cancellable,
GError **error)
{
return g_initable_new (NM_TYPE_CLIENT, cancellable, error,
NULL);
}
static void
client_inited (GObject *source, GAsyncResult *result, gpointer user_data)
{
GSimpleAsyncResult *simple = user_data;
GError *error = NULL;
if (!g_async_initable_new_finish (G_ASYNC_INITABLE (source), result, &error))
g_simple_async_result_take_error (simple, error);
else
g_simple_async_result_set_op_res_gpointer (simple, source, g_object_unref);
g_simple_async_result_complete (simple);
g_object_unref (simple);
}
/**
* nm_client_new_async:
* @cancellable: a #GCancellable, or %NULL
* @callback: callback to call when the client is created
* @user_data: data for @callback
*
* Creates a new #NMClient and begins asynchronously initializing it.
* @callback will be called when it is done; use
* nm_client_new_finish() to get the result. Note that on an error,
* the callback can be invoked with two first parameters as NULL.
**/
void
nm_client_new_async (GCancellable *cancellable,
GAsyncReadyCallback callback,
gpointer user_data)
{
GSimpleAsyncResult *simple;
simple = g_simple_async_result_new (NULL, callback, user_data, nm_client_new_async);
if (cancellable)
g_simple_async_result_set_check_cancellable (simple, cancellable);
g_async_initable_new_async (NM_TYPE_CLIENT, G_PRIORITY_DEFAULT,
cancellable, client_inited, simple,
NULL);
}
/**
* nm_client_new_finish:
* @result: a #GAsyncResult
* @error: location for a #GError, or %NULL
*
* Gets the result of an nm_client_new_async() call.
*
* Returns: a new #NMClient, or %NULL on error
**/
NMClient *
nm_client_new_finish (GAsyncResult *result, GError **error)
{
GSimpleAsyncResult *simple;
g_return_val_if_fail (g_simple_async_result_is_valid (result, NULL, nm_client_new_async), NULL);
g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
simple = G_SIMPLE_ASYNC_RESULT (result);
if (g_simple_async_result_propagate_error (simple, error))
return NULL;
else
return g_object_ref (g_simple_async_result_get_op_res_gpointer (simple));
}
static void
subobject_notify (GObject *object,
GParamSpec *pspec,
gpointer client)
{
if (!g_str_has_suffix (pspec->name, "-internal"))
g_object_notify (client, pspec->name);
}
static void
manager_device_added (NMManager *manager,
NMDevice *device,
gpointer client)
{
g_signal_emit (client, signals[DEVICE_ADDED], 0, device);
}
static void
manager_device_removed (NMManager *manager,
NMDevice *device,
gpointer client)
{
g_signal_emit (client, signals[DEVICE_REMOVED], 0, device);
}
static void
manager_any_device_added (NMManager *manager,
NMDevice *device,
gpointer client)
{
g_signal_emit (client, signals[ANY_DEVICE_ADDED], 0, device);
}
static void
manager_any_device_removed (NMManager *manager,
NMDevice *device,
gpointer client)
{
g_signal_emit (client, signals[ANY_DEVICE_REMOVED], 0, device);
}
static void
manager_permission_changed (NMManager *manager,
NMClientPermission permission,
NMClientPermissionResult result,
gpointer client)
{
g_signal_emit (client, signals[PERMISSION_CHANGED], 0, permission, result);
}
static void
settings_connection_added (NMRemoteSettings *manager,
NMRemoteConnection *connection,
gpointer client)
{
g_signal_emit (client, signals[CONNECTION_ADDED], 0, connection);
}
static void
settings_connection_removed (NMRemoteSettings *manager,
NMRemoteConnection *connection,
gpointer client)
{
g_signal_emit (client, signals[CONNECTION_REMOVED], 0, connection);
}
static void
manager_active_connection_added (NMManager *manager,
NMActiveConnection *active_connection,
gpointer client)
{
g_signal_emit (client, signals[ACTIVE_CONNECTION_ADDED], 0, active_connection);
}
static void
manager_active_connection_removed (NMManager *manager,
NMActiveConnection *active_connection,
gpointer client)
{
g_signal_emit (client, signals[ACTIVE_CONNECTION_REMOVED], 0, active_connection);
}
static void
dns_notify (GObject *object,
GParamSpec *pspec,
gpointer client)
{
char pname[128];
if (NM_IN_STRSET (pspec->name,
NM_DNS_MANAGER_MODE,
NM_DNS_MANAGER_RC_MANAGER,
NM_DNS_MANAGER_CONFIGURATION)) {
nm_sprintf_buf (pname, "dns-%s", pspec->name);
g_object_notify (client, pname);
}
}
static void
checkpoint_create_cb (GObject *object,
GAsyncResult *result,
gpointer user_data)
{
GSimpleAsyncResult *simple = user_data;
NMCheckpoint *checkpoint;
GError *error = NULL;
checkpoint = nm_manager_checkpoint_create_finish (NM_MANAGER (object), result, &error);
if (checkpoint)
g_simple_async_result_set_op_res_gpointer (simple, checkpoint, g_object_unref);
else
g_simple_async_result_take_error (simple, error);
g_simple_async_result_complete (simple);
g_object_unref (simple);
}
/**
* nm_client_get_checkpoints:
* @client: a #NMClient
*
* Gets all the active checkpoints.
*
* Returns: (transfer none) (element-type NMCheckpoint): a #GPtrArray
* containing all the #NMCheckpoint. The returned array is owned by the
* #NMClient object and should not be modified.
*
* Since: 1.12
**/
const GPtrArray *
nm_client_get_checkpoints (NMClient *client)
{
g_return_val_if_fail (NM_IS_CLIENT (client), NULL);
if (!nm_client_get_nm_running (client))
return ∅
return nm_manager_get_checkpoints (NM_CLIENT_GET_PRIVATE (client)->manager);
}
/**
* nm_client_checkpoint_create:
* @client: the %NMClient
* @devices: (element-type NMDevice): a list of devices for which a
* checkpoint should be created.
* @rollback_timeout: the rollback timeout in seconds
* @flags: creation flags
* @cancellable: a #GCancellable, or %NULL
* @callback: (scope async): callback to be called when the add operation completes
* @user_data: (closure): caller-specific data passed to @callback
*
* Creates a checkpoint of the current networking configuration
* for given interfaces. An empty @devices argument means all
* devices. If @rollback_timeout is not zero, a rollback is
* automatically performed after the given timeout.
*
* Since: 1.12
**/
void
nm_client_checkpoint_create (NMClient *client,
const GPtrArray *devices,
guint32 rollback_timeout,
NMCheckpointCreateFlags flags,
GCancellable *cancellable,
GAsyncReadyCallback callback,
gpointer user_data)
{
GSimpleAsyncResult *simple;
GError *error = NULL;
g_return_if_fail (NM_IS_CLIENT (client));
if (!_nm_client_check_nm_running (client, &error)) {
g_simple_async_report_take_gerror_in_idle (G_OBJECT (client), callback, user_data, error);
return;
}
simple = g_simple_async_result_new (G_OBJECT (client), callback, user_data,
nm_client_checkpoint_create);
if (cancellable)
g_simple_async_result_set_check_cancellable (simple, cancellable);
nm_manager_checkpoint_create (NM_CLIENT_GET_PRIVATE (client)->manager,
devices, rollback_timeout, flags,
cancellable, checkpoint_create_cb, simple);
}
/**
* nm_client_checkpoint_create_finish:
* @client: the #NMClient
* @result: the result passed to the #GAsyncReadyCallback
* @error: location for a #GError, or %NULL
*
* Gets the result of a call to nm_client_checkpoint_create().
*
* Returns: (transfer full): the new #NMCheckpoint on success, %NULL on
* failure, in which case @error will be set.
*
* Since: 1.12
**/
NMCheckpoint *
nm_client_checkpoint_create_finish (NMClient *client,
GAsyncResult *result,
GError **error)
{
GSimpleAsyncResult *simple;
g_return_val_if_fail (NM_IS_CLIENT (client), NULL);
g_return_val_if_fail (G_IS_SIMPLE_ASYNC_RESULT (result), NULL);
simple = G_SIMPLE_ASYNC_RESULT (result);
if (g_simple_async_result_propagate_error (simple, error))
return NULL;
else
return g_object_ref (g_simple_async_result_get_op_res_gpointer (simple));
}
static void
checkpoint_destroy_cb (GObject *object,
GAsyncResult *result,
gpointer user_data)
{
GSimpleAsyncResult *simple = user_data;
GError *error = NULL;
if (nm_manager_checkpoint_destroy_finish (NM_MANAGER (object), result, &error))
g_simple_async_result_set_op_res_gboolean (simple, TRUE);
else
g_simple_async_result_take_error (simple, error);
g_simple_async_result_complete (simple);
g_object_unref (simple);
}
/**
* nm_client_checkpoint_destroy:
* @client: the %NMClient
* @checkpoint_path: the D-Bus path for the checkpoint
* @cancellable: a #GCancellable, or %NULL
* @callback: (scope async): callback to be called when the add operation completes
* @user_data: (closure): caller-specific data passed to @callback
*
* Destroys an existing checkpoint without performing a rollback.
*
* Since: 1.12
**/
void
nm_client_checkpoint_destroy (NMClient *client,
const char *checkpoint_path,
GCancellable *cancellable,
GAsyncReadyCallback callback,
gpointer user_data)
{
GSimpleAsyncResult *simple;
GError *error = NULL;
g_return_if_fail (NM_IS_CLIENT (client));
g_return_if_fail (checkpoint_path && checkpoint_path[0] == '/');
if (!_nm_client_check_nm_running (client, &error)) {
g_simple_async_report_take_gerror_in_idle (G_OBJECT (client), callback, user_data, error);
return;
}
simple = g_simple_async_result_new (G_OBJECT (client), callback, user_data,
nm_client_checkpoint_destroy);
if (cancellable)
g_simple_async_result_set_check_cancellable (simple, cancellable);
nm_manager_checkpoint_destroy (NM_CLIENT_GET_PRIVATE (client)->manager,
checkpoint_path,
cancellable, checkpoint_destroy_cb, simple);
}
/**
* nm_client_checkpoint_destroy_finish:
* @client: an #NMClient
* @result: the result passed to the #GAsyncReadyCallback
* @error: location for a #GError, or %NULL
*
* Gets the result of a call to nm_client_checkpoint_destroy().
*
* Returns: %TRUE on success or %FALSE on failure, in which case
* @error will be set.
*
* Since: 1.12
**/
gboolean
nm_client_checkpoint_destroy_finish (NMClient *client,
GAsyncResult *result,
GError **error)
{
GSimpleAsyncResult *simple;
g_return_val_if_fail (NM_IS_CLIENT (client), FALSE);
g_return_val_if_fail (G_IS_SIMPLE_ASYNC_RESULT (result), FALSE);
simple = G_SIMPLE_ASYNC_RESULT (result);
if (g_simple_async_result_propagate_error (simple, error))
return FALSE;
else
return g_simple_async_result_get_op_res_gboolean (simple);
}
static void
checkpoint_rollback_cb (GObject *object,
GAsyncResult *result,
gpointer user_data)
{
GSimpleAsyncResult *simple = user_data;
GHashTable *hash;
GError *error = NULL;
hash = nm_manager_checkpoint_rollback_finish (NM_MANAGER (object), result, &error);
if (hash)
g_simple_async_result_set_op_res_gpointer (simple, hash, (GDestroyNotify) g_hash_table_unref);
else
g_simple_async_result_take_error (simple, error);
g_simple_async_result_complete (simple);
g_object_unref (simple);
}
/**
* nm_client_checkpoint_rollback:
* @client: the %NMClient
* @checkpoint_path: the D-Bus path to the checkpoint
* @cancellable: a #GCancellable, or %NULL
* @callback: (scope async): callback to be called when the add operation completes
* @user_data: (closure): caller-specific data passed to @callback
*
* Performs the rollback of a checkpoint before the timeout is reached.
*
* Since: 1.12
**/
void
nm_client_checkpoint_rollback (NMClient *client,
const char *checkpoint_path,
GCancellable *cancellable,
GAsyncReadyCallback callback,
gpointer user_data)
{
GSimpleAsyncResult *simple;
GError *error = NULL;
g_return_if_fail (NM_IS_CLIENT (client));
g_return_if_fail (checkpoint_path && checkpoint_path[0] == '/');
if (!_nm_client_check_nm_running (client, &error)) {
g_simple_async_report_take_gerror_in_idle (G_OBJECT (client), callback, user_data, error);
return;
}
simple = g_simple_async_result_new (G_OBJECT (client), callback, user_data,
nm_client_checkpoint_rollback);
if (cancellable)
g_simple_async_result_set_check_cancellable (simple, cancellable);
nm_manager_checkpoint_rollback (NM_CLIENT_GET_PRIVATE (client)->manager,
checkpoint_path,
cancellable, checkpoint_rollback_cb, simple);
}
/**
* nm_client_checkpoint_rollback_finish:
* @client: an #NMClient
* @result: the result passed to the #GAsyncReadyCallback
* @error: location for a #GError, or %NULL
*
* Gets the result of a call to nm_client_checkpoint_rollback().
*
* Returns: (transfer full) (element-type utf8 guint32): an hash table of
* devices and results. Devices are represented by their original
* D-Bus path; each result is a #NMRollbackResult.
*
* Since: 1.12
**/
GHashTable *
nm_client_checkpoint_rollback_finish (NMClient *client,
GAsyncResult *result,
GError **error)
{
GSimpleAsyncResult *simple;
GHashTable *hash;
g_return_val_if_fail (NM_IS_CLIENT (client), NULL);
g_return_val_if_fail (G_IS_SIMPLE_ASYNC_RESULT (result), NULL);
simple = G_SIMPLE_ASYNC_RESULT (result);
if (g_simple_async_result_propagate_error (simple, error))
return NULL;
else {
hash = g_simple_async_result_get_op_res_gpointer (simple);
return g_hash_table_ref (hash);
}
}
static void
checkpoint_adjust_rollback_timeout_cb (GObject *object,
GAsyncResult *result,
gpointer user_data)
{
gs_unref_object GSimpleAsyncResult *simple = user_data;
GError *error = NULL;
if (nm_manager_checkpoint_adjust_rollback_timeout_finish (NM_MANAGER (object), result, &error))
g_simple_async_result_set_op_res_gboolean (simple, TRUE);
else
g_simple_async_result_take_error (simple, error);
g_simple_async_result_complete (simple);
}
/**
* nm_client_checkpoint_adjust_rollback_timeout:
* @client: the %NMClient
* @checkpoint_path: a D-Bus path to a checkpoint
* @add_timeout: the timeout in seconds counting from now.
* Set to zero, to disable the timeout.
* @cancellable: a #GCancellable, or %NULL
* @callback: (scope async): callback to be called when the add operation completes
* @user_data: (closure): caller-specific data passed to @callback
*
* Resets the timeout for the checkpoint with path @checkpoint_path
* to @timeout_add.
*
* Since: 1.12
**/
void
nm_client_checkpoint_adjust_rollback_timeout (NMClient *client,
const char *checkpoint_path,
guint32 add_timeout,
GCancellable *cancellable,
GAsyncReadyCallback callback,
gpointer user_data)
{
GSimpleAsyncResult *simple;
GError *error = NULL;
g_return_if_fail (NM_IS_CLIENT (client));
g_return_if_fail (checkpoint_path && checkpoint_path[0] == '/');
if (!_nm_client_check_nm_running (client, &error)) {
g_simple_async_report_take_gerror_in_idle (G_OBJECT (client), callback, user_data, error);
return;
}
simple = g_simple_async_result_new (G_OBJECT (client), callback, user_data,
nm_client_checkpoint_rollback);
if (cancellable)
g_simple_async_result_set_check_cancellable (simple, cancellable);
nm_manager_checkpoint_adjust_rollback_timeout (NM_CLIENT_GET_PRIVATE (client)->manager,
checkpoint_path, add_timeout,
cancellable, checkpoint_adjust_rollback_timeout_cb, simple);
}
/**
* nm_client_checkpoint_adjust_rollback_timeout_finish:
* @client: an #NMClient
* @result: the result passed to the #GAsyncReadyCallback
* @error: location for a #GError, or %NULL
*
* Gets the result of a call to nm_client_checkpoint_adjust_rollback_timeout().
*
* Returns: %TRUE on success or %FALSE on failure.
*
* Since: 1.12
**/
gboolean
nm_client_checkpoint_adjust_rollback_timeout_finish (NMClient *client,
GAsyncResult *result,
GError **error)
{
g_return_val_if_fail (NM_IS_CLIENT (client), FALSE);
g_return_val_if_fail (G_IS_SIMPLE_ASYNC_RESULT (result), FALSE);
return !g_simple_async_result_propagate_error (G_SIMPLE_ASYNC_RESULT (result),
error);
}
/****************************************************************/
/* Object Initialization */
/****************************************************************/
static GType
proxy_type (GDBusObjectManagerClient *manager,
const gchar *object_path,
const gchar *interface_name,
gpointer user_data)
{
/* ObjectManager asks us for an object proxy. Unfortunatelly, we can't
* decide that by interface name and GDBusObjectManager doesn't allow
* us to look at the known interface list. Thus we need to create a
* generic GDBusObject and only couple a NMObject subclass later. */
if (!interface_name)
return G_TYPE_DBUS_OBJECT_PROXY;
/* An interface proxy */
if (strcmp (interface_name, NM_DBUS_INTERFACE) == 0)
return NMDBUS_TYPE_MANAGER_PROXY;
else if (strcmp (interface_name, NM_DBUS_INTERFACE_DEVICE_WIRELESS) == 0)
return NMDBUS_TYPE_DEVICE_WIFI_PROXY;
else if (strcmp (interface_name, NM_DBUS_INTERFACE_DEVICE) == 0)
return NMDBUS_TYPE_DEVICE_PROXY;
else if (strcmp (interface_name, NM_DBUS_INTERFACE_SETTINGS_CONNECTION) == 0)
return NMDBUS_TYPE_SETTINGS_CONNECTION_PROXY;
else if (strcmp (interface_name, NM_DBUS_INTERFACE_SETTINGS) == 0)
return NMDBUS_TYPE_SETTINGS_PROXY;
else if (strcmp (interface_name, NM_DBUS_INTERFACE_DNS_MANAGER) == 0)
return NMDBUS_TYPE_DNS_MANAGER_PROXY;
else if (strcmp (interface_name, NM_DBUS_INTERFACE_VPN_CONNECTION) == 0)
return NMDBUS_TYPE_VPN_CONNECTION_PROXY;
else if (strcmp (interface_name, NM_DBUS_INTERFACE_ACTIVE_CONNECTION) == 0)
return NMDBUS_TYPE_ACTIVE_CONNECTION_PROXY;
/* Use a generic D-Bus Proxy whenever we can. The typed GDBusProxy
* subclasses actually use quite some memory, so they're better avoided. */
return G_TYPE_DBUS_PROXY;
}
static NMObject *
obj_nm_for_gdbus_object (NMClient *self, GDBusObject *object, GDBusObjectManager *object_manager)
{
NMClientPrivate *priv;
GList *interfaces;
GList *l;
GType type = G_TYPE_INVALID;
NMObject *obj_nm;
g_return_val_if_fail (G_IS_DBUS_OBJECT_PROXY (object), NULL);
interfaces = g_dbus_object_get_interfaces (object);
for (l = interfaces; l; l = l->next) {
GDBusProxy *proxy = G_DBUS_PROXY (l->data);
const char *ifname = g_dbus_proxy_get_interface_name (proxy);
/* This is a performance/scalability hack. It makes sense to call it
* from here, since this is in the common object creation path. */
_nm_dbus_proxy_replace_match (proxy);
if (strcmp (ifname, NM_DBUS_INTERFACE) == 0)
type = NM_TYPE_MANAGER;
else if (strcmp (ifname, NM_DBUS_INTERFACE_ACCESS_POINT) == 0)
type = NM_TYPE_ACCESS_POINT;
else if (strcmp (ifname, NM_DBUS_INTERFACE_ACTIVE_CONNECTION) == 0 && type != NM_TYPE_VPN_CONNECTION)
type = NM_TYPE_ACTIVE_CONNECTION;
else if (strcmp (ifname, NM_DBUS_INTERFACE_DEVICE_ADSL) == 0)
type = NM_TYPE_DEVICE_ADSL;
else if (strcmp (ifname, NM_DBUS_INTERFACE_DEVICE_BOND) == 0)
type = NM_TYPE_DEVICE_BOND;
else if (strcmp (ifname, NM_DBUS_INTERFACE_DEVICE_BRIDGE) == 0)
type = NM_TYPE_DEVICE_BRIDGE;
else if (strcmp (ifname, NM_DBUS_INTERFACE_DEVICE_BLUETOOTH) == 0)
type = NM_TYPE_DEVICE_BT;
else if (strcmp (ifname, NM_DBUS_INTERFACE_DEVICE_DUMMY) == 0)
type = NM_TYPE_DEVICE_DUMMY;
else if (strcmp (ifname, NM_DBUS_INTERFACE_DEVICE_WIRED) == 0)
type = NM_TYPE_DEVICE_ETHERNET;
else if (strcmp (ifname, NM_DBUS_INTERFACE_DEVICE_GENERIC) == 0)
type = NM_TYPE_DEVICE_GENERIC;
else if (strcmp (ifname, NM_DBUS_INTERFACE_DEVICE_INFINIBAND) == 0)
type = NM_TYPE_DEVICE_INFINIBAND;
else if (strcmp (ifname, NM_DBUS_INTERFACE_DEVICE_IP_TUNNEL) == 0)
type = NM_TYPE_DEVICE_IP_TUNNEL;
else if (strcmp (ifname, NM_DBUS_INTERFACE_DEVICE_MACSEC) == 0)
type = NM_TYPE_DEVICE_MACSEC;
else if (strcmp (ifname, NM_DBUS_INTERFACE_DEVICE_MACVLAN) == 0)
type = NM_TYPE_DEVICE_MACVLAN;
else if (strcmp (ifname, NM_DBUS_INTERFACE_DEVICE_MODEM) == 0)
type = NM_TYPE_DEVICE_MODEM;
else if (strcmp (ifname, NM_DBUS_INTERFACE_DEVICE_OLPC_MESH) == 0)
type = NM_TYPE_DEVICE_OLPC_MESH;
else if (strcmp (ifname, NM_DBUS_INTERFACE_DEVICE_OVS_INTERFACE) == 0)
type = NM_TYPE_DEVICE_OVS_INTERFACE;
else if (strcmp (ifname, NM_DBUS_INTERFACE_DEVICE_OVS_PORT) == 0)
type = NM_TYPE_DEVICE_OVS_PORT;
else if (strcmp (ifname, NM_DBUS_INTERFACE_DEVICE_OVS_BRIDGE) == 0)
type = NM_TYPE_DEVICE_OVS_BRIDGE;
else if (strcmp (ifname, NM_DBUS_INTERFACE_DEVICE_PPP) == 0)
type = NM_TYPE_DEVICE_PPP;
else if (strcmp (ifname, NM_DBUS_INTERFACE_DEVICE_TEAM) == 0)
type = NM_TYPE_DEVICE_TEAM;
else if (strcmp (ifname, NM_DBUS_INTERFACE_DEVICE_TUN) == 0)
type = NM_TYPE_DEVICE_TUN;
else if (strcmp (ifname, NM_DBUS_INTERFACE_DEVICE_VLAN) == 0)
type = NM_TYPE_DEVICE_VLAN;
else if (strcmp (ifname, NM_DBUS_INTERFACE_DEVICE_VXLAN) == 0)
type = NM_TYPE_DEVICE_VXLAN;
else if (strcmp (ifname, NM_DBUS_INTERFACE_DEVICE_WIRELESS) == 0)
type = NM_TYPE_DEVICE_WIFI;
else if (strcmp (ifname, NM_DBUS_INTERFACE_DEVICE_WIMAX) == 0)
type = NM_TYPE_DEVICE_WIMAX;
else if (strcmp (ifname, NM_DBUS_INTERFACE_DHCP4_CONFIG) == 0)
type = NM_TYPE_DHCP4_CONFIG;
else if (strcmp (ifname, NM_DBUS_INTERFACE_DHCP6_CONFIG) == 0)
type = NM_TYPE_DHCP6_CONFIG;
else if (strcmp (ifname, NM_DBUS_INTERFACE_IP4_CONFIG) == 0)
type = NM_TYPE_IP4_CONFIG;
else if (strcmp (ifname, NM_DBUS_INTERFACE_IP6_CONFIG) == 0)
type = NM_TYPE_IP6_CONFIG;
else if (strcmp (ifname, NM_DBUS_INTERFACE_SETTINGS_CONNECTION) == 0)
type = NM_TYPE_REMOTE_CONNECTION;
else if (strcmp (ifname, NM_DBUS_INTERFACE_SETTINGS) == 0)
type = NM_TYPE_REMOTE_SETTINGS;
else if (strcmp (ifname, NM_DBUS_INTERFACE_DNS_MANAGER) == 0)
type = NM_TYPE_DNS_MANAGER;
else if (strcmp (ifname, NM_DBUS_INTERFACE_VPN_CONNECTION) == 0)
type = NM_TYPE_VPN_CONNECTION;
else if (strcmp (ifname, NM_DBUS_INTERFACE_WIMAX_NSP) == 0)
type = NM_TYPE_WIMAX_NSP;
else if (strcmp (ifname, NM_DBUS_INTERFACE_CHECKPOINT) == 0)
type = NM_TYPE_CHECKPOINT;
if (type != G_TYPE_INVALID)
break;
}
g_list_free_full (interfaces, g_object_unref);
if (type == G_TYPE_INVALID)
return NULL;
obj_nm = g_object_new (type,
NM_OBJECT_DBUS_OBJECT, object,
NM_OBJECT_DBUS_OBJECT_MANAGER, object_manager,
NULL);
if (NM_IS_DEVICE (obj_nm)) {
priv = NM_CLIENT_GET_PRIVATE (self);
if (!priv->udev)
priv->udev = udev_new ();
_nm_device_set_udev (NM_DEVICE (obj_nm), priv->udev);
}
g_object_set_qdata_full (G_OBJECT (object), _nm_object_obj_nm_quark (),
obj_nm, g_object_unref);
return obj_nm;
}
static void
obj_nm_inited (GObject *object, GAsyncResult *result, gpointer user_data)
{
if (!g_async_initable_init_finish (G_ASYNC_INITABLE (object), result, NULL)) {
/* This is a can-not-happen situation, the NMObject subclasses are not
* supposed to fail initialization. */
g_warn_if_reached ();
}
}
static void
object_added (GDBusObjectManager *object_manager, GDBusObject *object, gpointer user_data)
{
NMClient *client = user_data;
NMObject *obj_nm;
obj_nm = obj_nm_for_gdbus_object (client, object, object_manager);
if (obj_nm) {
g_async_initable_init_async (G_ASYNC_INITABLE (obj_nm),
G_PRIORITY_DEFAULT, NULL,
obj_nm_inited, NULL);
}
}
static void
object_removed (GDBusObjectManager *object_manager, GDBusObject *object, gpointer user_data)
{
g_object_set_qdata (G_OBJECT (object), _nm_object_obj_nm_quark (), NULL);
}
static gboolean
objects_created (NMClient *client, GDBusObjectManager *object_manager, GError **error)
{
NMClientPrivate *priv = NM_CLIENT_GET_PRIVATE (client);
gs_unref_object GDBusObject *manager = NULL;
gs_unref_object GDBusObject *settings = NULL;
gs_unref_object GDBusObject *dns_manager = NULL;
NMObject *obj_nm;
GList *objects, *iter;
/* First just ensure all the NMObjects for known GDBusObjects exist. */
objects = g_dbus_object_manager_get_objects (object_manager);
for (iter = objects; iter; iter = iter->next)
obj_nm_for_gdbus_object (client, iter->data, object_manager);
g_list_free_full (objects, g_object_unref);
manager = g_dbus_object_manager_get_object (object_manager, NM_DBUS_PATH);
if (!manager) {
g_set_error_literal (error,
NM_CLIENT_ERROR,
NM_CLIENT_ERROR_MANAGER_NOT_RUNNING,
"Manager object not found");
return FALSE;
}
obj_nm = g_object_get_qdata (G_OBJECT (manager), _nm_object_obj_nm_quark ());
if (!obj_nm) {
g_set_error_literal (error,
NM_CLIENT_ERROR,
NM_CLIENT_ERROR_MANAGER_NOT_RUNNING,
"Manager object lacks the proper interface");
return FALSE;
}
priv->manager = NM_MANAGER (g_object_ref (obj_nm));
g_signal_connect (priv->manager, "notify",
G_CALLBACK (subobject_notify), client);
g_signal_connect (priv->manager, "device-added",
G_CALLBACK (manager_device_added), client);
g_signal_connect (priv->manager, "device-removed",
G_CALLBACK (manager_device_removed), client);
g_signal_connect (priv->manager, "any-device-added",
G_CALLBACK (manager_any_device_added), client);
g_signal_connect (priv->manager, "any-device-removed",
G_CALLBACK (manager_any_device_removed), client);
g_signal_connect (priv->manager, "permission-changed",
G_CALLBACK (manager_permission_changed), client);
g_signal_connect (priv->manager, "active-connection-added",
G_CALLBACK (manager_active_connection_added), client);
g_signal_connect (priv->manager, "active-connection-removed",
G_CALLBACK (manager_active_connection_removed), client);
settings = g_dbus_object_manager_get_object (object_manager, NM_DBUS_PATH_SETTINGS);
if (!settings) {
g_set_error_literal (error,
NM_CLIENT_ERROR,
NM_CLIENT_ERROR_MANAGER_NOT_RUNNING,
"Settings object not found");
return FALSE;
}
obj_nm = g_object_get_qdata (G_OBJECT (settings), _nm_object_obj_nm_quark ());
if (!obj_nm) {
g_set_error_literal (error,
NM_CLIENT_ERROR,
NM_CLIENT_ERROR_MANAGER_NOT_RUNNING,
"Settings object lacks the proper interface");
return FALSE;
}
priv->settings = NM_REMOTE_SETTINGS (g_object_ref (obj_nm));
g_signal_connect (priv->settings, "notify",
G_CALLBACK (subobject_notify), client);
g_signal_connect (priv->settings, "connection-added",
G_CALLBACK (settings_connection_added), client);
g_signal_connect (priv->settings, "connection-removed",
G_CALLBACK (settings_connection_removed), client);
dns_manager = g_dbus_object_manager_get_object (object_manager, NM_DBUS_PATH_DNS_MANAGER);
if (dns_manager) {
obj_nm = g_object_get_qdata (G_OBJECT (dns_manager), _nm_object_obj_nm_quark ());
if (!obj_nm) {
g_set_error_literal (error,
NM_CLIENT_ERROR,
NM_CLIENT_ERROR_MANAGER_NOT_RUNNING,
"DNS manager object lacks the proper interface");
return FALSE;
}
priv->dns_manager = NM_DNS_MANAGER (g_object_ref (obj_nm));
g_signal_connect (priv->dns_manager, "notify",
G_CALLBACK (dns_notify), client);
}
/* The handlers don't really use the client instance. However
* it makes it convenient to unhook them by data. */
g_signal_connect (object_manager, "object-added",
G_CALLBACK (object_added), client);
g_signal_connect (object_manager, "object-removed",
G_CALLBACK (object_removed), client);
return TRUE;
}
/* Synchronous initialization. */
static void name_owner_changed (GObject *object, GParamSpec *pspec, gpointer user_data);
static gboolean
_om_has_name_owner (GDBusObjectManager *object_manager)
{
gs_free char *name_owner = NULL;
nm_assert (G_IS_DBUS_OBJECT_MANAGER_CLIENT (object_manager));
name_owner = g_dbus_object_manager_client_get_name_owner (G_DBUS_OBJECT_MANAGER_CLIENT (object_manager));
return !!name_owner;
}
static gboolean
init_sync (GInitable *initable, GCancellable *cancellable, GError **error)
{
NMClient *client = NM_CLIENT (initable);
NMClientPrivate *priv = NM_CLIENT_GET_PRIVATE (client);
GList *objects, *iter;
priv->object_manager = g_dbus_object_manager_client_new_for_bus_sync (_nm_dbus_bus_type (),
G_DBUS_OBJECT_MANAGER_CLIENT_FLAGS_DO_NOT_AUTO_START,
"org.freedesktop.NetworkManager",
"/org/freedesktop",
proxy_type, NULL, NULL,
cancellable, error);
if (!priv->object_manager)
return FALSE;
if (_om_has_name_owner (priv->object_manager)) {
if (!objects_created (client, priv->object_manager, error))
return FALSE;
objects = g_dbus_object_manager_get_objects (priv->object_manager);
for (iter = objects; iter; iter = iter->next) {
NMObject *obj_nm;
obj_nm = g_object_get_qdata (iter->data, _nm_object_obj_nm_quark ());
if (!obj_nm)
continue;
if (!g_initable_init (G_INITABLE (obj_nm), cancellable, NULL)) {
/* This is a can-not-happen situation, the NMObject subclasses are not
* supposed to fail initialization. */
g_warn_if_reached ();
}
}
g_list_free_full (objects, g_object_unref);
}
g_signal_connect (priv->object_manager, "notify::name-owner",
G_CALLBACK (name_owner_changed), client);
return TRUE;
}
/* Asynchronous initialization. */
static void
init_async_complete (NMClientInitData *init_data)
{
if (init_data->pending_init > 0)
return;
g_simple_async_result_complete (init_data->result);
g_object_unref (init_data->result);
g_clear_object (&init_data->cancellable);
g_slice_free (NMClientInitData, init_data);
}
static void
async_inited_obj_nm (GObject *object, GAsyncResult *result, gpointer user_data)
{
NMClientInitData *init_data = user_data;
GError *error = NULL;
nm_assert (init_data && init_data->pending_init > 0);
if (!g_async_initable_init_finish (G_ASYNC_INITABLE (object), result, &error))
g_simple_async_result_take_error (init_data->result, error);
init_data->pending_init--;
init_async_complete (init_data);
}
static void
init_async (GAsyncInitable *initable, int io_priority,
GCancellable *cancellable, GAsyncReadyCallback callback,
gpointer user_data);
static void
unhook_om (NMClient *self)
{
NMClientPrivate *priv = NM_CLIENT_GET_PRIVATE (self);
GList *objects, *iter;
if (priv->manager) {
const GPtrArray *active_connections;
const GPtrArray *devices;
int i;
active_connections = nm_manager_get_active_connections (priv->manager);
for (i = 0; i < active_connections->len; i++)
g_signal_emit (self, signals[ACTIVE_CONNECTION_REMOVED], 0, active_connections->pdata[i]);
devices = nm_manager_get_all_devices (priv->manager);
for (i = 0; i < devices->len; i++)
g_signal_emit (self, signals[DEVICE_REMOVED], 0, devices->pdata[i]);
g_signal_handlers_disconnect_by_data (priv->manager, self);
g_clear_object (&priv->manager);
g_object_notify (G_OBJECT (self), NM_CLIENT_ACTIVE_CONNECTIONS);
g_object_notify (G_OBJECT (self), NM_CLIENT_NM_RUNNING);
}
if (priv->settings) {
const GPtrArray *connections;
guint i;
connections = nm_remote_settings_get_connections (priv->settings);
for (i = 0; i < connections->len; i++)
g_signal_emit (self, signals[CONNECTION_REMOVED], 0, connections->pdata[i]);
g_signal_handlers_disconnect_by_data (priv->settings, self);
g_clear_object (&priv->settings);
g_object_notify (G_OBJECT (self), NM_CLIENT_CONNECTIONS);
g_object_notify (G_OBJECT (self), NM_CLIENT_HOSTNAME);
g_object_notify (G_OBJECT (self), NM_CLIENT_CAN_MODIFY);
}
if (priv->dns_manager) {
g_signal_handlers_disconnect_by_data (priv->dns_manager, self);
g_clear_object (&priv->dns_manager);
}
objects = g_dbus_object_manager_get_objects (priv->object_manager);
for (iter = objects; iter; iter = iter->next)
g_object_set_qdata (iter->data, _nm_object_obj_nm_quark (), NULL);
g_list_free_full (objects, g_object_unref);
}
static void
new_object_manager (GObject *source_object, GAsyncResult *res, gpointer user_data)
{
NMClient *self = NM_CLIENT (user_data);
NMClientPrivate *priv = NM_CLIENT_GET_PRIVATE (self);
g_clear_object (&priv->new_object_manager_cancellable);
g_object_notify (G_OBJECT (user_data), NM_CLIENT_NM_RUNNING);
}
static void
got_object_manager (GObject *object, GAsyncResult *result, gpointer user_data)
{
NMClientInitData *init_data = user_data;
NMClient *client;
NMClientPrivate *priv;
GList *objects, *iter;
GError *error = NULL;
GDBusObjectManager *object_manager;
object_manager = g_dbus_object_manager_client_new_for_bus_finish (result, &error);
if (object_manager == NULL) {
g_simple_async_result_take_error (init_data->result, error);
init_async_complete (init_data);
return;
}
client = init_data->client;
priv = NM_CLIENT_GET_PRIVATE (client);
priv->object_manager = object_manager;
if (_om_has_name_owner (priv->object_manager)) {
if (!objects_created (client, priv->object_manager, &error)) {
g_simple_async_result_take_error (init_data->result, error);
init_async_complete (init_data);
return;
}
objects = g_dbus_object_manager_get_objects (priv->object_manager);
for (iter = objects; iter; iter = iter->next) {
NMObject *obj_nm;
obj_nm = g_object_get_qdata (iter->data, _nm_object_obj_nm_quark ());
if (!obj_nm)
continue;
init_data->pending_init++;
g_async_initable_init_async (G_ASYNC_INITABLE (obj_nm),
G_PRIORITY_DEFAULT, init_data->cancellable,
async_inited_obj_nm, init_data);
}
g_list_free_full (objects, g_object_unref);
}
init_async_complete (init_data);
g_signal_connect (priv->object_manager, "notify::name-owner",
G_CALLBACK (name_owner_changed), client);
}
static void
prepare_object_manager (NMClient *client,
GCancellable *cancellable,
GAsyncReadyCallback callback,
gpointer user_data)
{
NMClientInitData *init_data;
init_data = g_slice_new0 (NMClientInitData);
init_data->client = client;
init_data->cancellable = cancellable ? g_object_ref (cancellable) : NULL;
init_data->result = g_simple_async_result_new (G_OBJECT (client), callback,
user_data, init_async);
if (cancellable)
g_simple_async_result_set_check_cancellable (init_data->result, cancellable);
g_simple_async_result_set_op_res_gboolean (init_data->result, TRUE);
g_dbus_object_manager_client_new_for_bus (_nm_dbus_bus_type (),
G_DBUS_OBJECT_MANAGER_CLIENT_FLAGS_DO_NOT_AUTO_START,
"org.freedesktop.NetworkManager",
"/org/freedesktop",
proxy_type, NULL, NULL,
init_data->cancellable,
got_object_manager,
init_data);
}
static void
name_owner_changed (GObject *object, GParamSpec *pspec, gpointer user_data)
{
NMClient *self = user_data;
NMClientPrivate *priv = NM_CLIENT_GET_PRIVATE (self);
GDBusObjectManager *object_manager = G_DBUS_OBJECT_MANAGER (object);
nm_assert (object_manager == priv->object_manager);
if (_om_has_name_owner (object_manager)) {
g_signal_handlers_disconnect_by_data (priv->object_manager, self);
g_clear_object (&priv->object_manager);
nm_clear_g_cancellable (&priv->new_object_manager_cancellable);
priv->new_object_manager_cancellable = g_cancellable_new ();
prepare_object_manager (self, priv->new_object_manager_cancellable,
new_object_manager, self);
} else {
g_signal_handlers_disconnect_by_func (object_manager, object_added, self);
unhook_om (self);
}
}
static void
init_async (GAsyncInitable *initable, int io_priority,
GCancellable *cancellable, GAsyncReadyCallback callback,
gpointer user_data)
{
prepare_object_manager (NM_CLIENT (initable), cancellable, callback, user_data);
}
static gboolean
init_finish (GAsyncInitable *initable, GAsyncResult *result, GError **error)
{
GSimpleAsyncResult *simple = G_SIMPLE_ASYNC_RESULT (result);
if (g_simple_async_result_propagate_error (simple, error))
return FALSE;
else
return TRUE;
}
static void
dispose (GObject *object)
{
NMClientPrivate *priv = NM_CLIENT_GET_PRIVATE (object);
nm_clear_g_cancellable (&priv->new_object_manager_cancellable);
if (priv->manager) {
g_signal_handlers_disconnect_by_data (priv->manager, object);
g_clear_object (&priv->manager);
}
if (priv->settings) {
g_signal_handlers_disconnect_by_data (priv->settings, object);
g_clear_object (&priv->settings);
}
if (priv->dns_manager) {
g_signal_handlers_disconnect_by_data (priv->dns_manager, object);
g_clear_object (&priv->dns_manager);
}
if (priv->object_manager) {
GList *objects, *iter;
/* Unhook the NM objects. */
objects = g_dbus_object_manager_get_objects (priv->object_manager);
for (iter = objects; iter; iter = iter->next)
g_object_set_qdata (G_OBJECT (iter->data), _nm_object_obj_nm_quark (), NULL);
g_list_free_full (objects, g_object_unref);
g_signal_handlers_disconnect_by_data (priv->object_manager, object);
g_clear_object (&priv->object_manager);
}
G_OBJECT_CLASS (nm_client_parent_class)->dispose (object);
if (priv->udev) {
udev_unref (priv->udev);
priv->udev = NULL;
}
}
static void
set_property (GObject *object, guint prop_id,
const GValue *value, GParamSpec *pspec)
{
NMClientPrivate *priv = NM_CLIENT_GET_PRIVATE (object);
switch (prop_id) {
case PROP_NETWORKING_ENABLED:
case PROP_WIRELESS_ENABLED:
case PROP_WWAN_ENABLED:
case PROP_WIMAX_ENABLED:
case PROP_CONNECTIVITY_CHECK_ENABLED:
if (priv->manager)
g_object_set_property (G_OBJECT (priv->manager), pspec->name, value);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}
}
static void
get_property (GObject *object, guint prop_id,
GValue *value, GParamSpec *pspec)
{
NMClient *self = NM_CLIENT (object);
NMClientPrivate *priv = NM_CLIENT_GET_PRIVATE (object);
switch (prop_id) {
case PROP_NM_RUNNING:
g_value_set_boolean (value, nm_client_get_nm_running (self));
break;
/* Manager properties. */
case PROP_VERSION:
g_value_set_string (value, nm_client_get_version (self));
break;
case PROP_STATE:
g_value_set_enum (value, nm_client_get_state (self));
break;
case PROP_STARTUP:
g_value_set_boolean (value, nm_client_get_startup (self));
break;
case PROP_NETWORKING_ENABLED:
g_value_set_boolean (value, nm_client_networking_get_enabled (self));
break;
case PROP_WIRELESS_ENABLED:
g_value_set_boolean (value, nm_client_wireless_get_enabled (self));
break;
case PROP_WIRELESS_HARDWARE_ENABLED:
if (priv->manager)
g_object_get_property (G_OBJECT (priv->manager), pspec->name, value);
else
g_value_set_boolean (value, FALSE);
break;
case PROP_WWAN_ENABLED:
g_value_set_boolean (value, nm_client_wwan_get_enabled (self));
break;
case PROP_WWAN_HARDWARE_ENABLED:
if (priv->manager)
g_object_get_property (G_OBJECT (priv->manager), pspec->name, value);
else
g_value_set_boolean (value, FALSE);
break;
case PROP_WIMAX_ENABLED:
g_value_set_boolean (value, nm_client_wimax_get_enabled (self));
break;
case PROP_WIMAX_HARDWARE_ENABLED:
if (priv->manager)
g_object_get_property (G_OBJECT (priv->manager), pspec->name, value);
else
g_value_set_boolean (value, FALSE);
break;
case PROP_ACTIVE_CONNECTIONS:
g_value_take_boxed (value, _nm_utils_copy_object_array (nm_client_get_active_connections (self)));
break;
case PROP_CONNECTIVITY:
g_value_set_enum (value, nm_client_get_connectivity (self));
break;
case PROP_CONNECTIVITY_CHECK_AVAILABLE:
g_value_set_boolean (value, nm_client_connectivity_check_get_available (self));
break;
case PROP_CONNECTIVITY_CHECK_ENABLED:
g_value_set_boolean (value, nm_client_connectivity_check_get_enabled (self));
break;
case PROP_PRIMARY_CONNECTION:
g_value_set_object (value, nm_client_get_primary_connection (self));
break;
case PROP_ACTIVATING_CONNECTION:
g_value_set_object (value, nm_client_get_activating_connection (self));
break;
case PROP_DEVICES:
g_value_take_boxed (value, _nm_utils_copy_object_array (nm_client_get_devices (self)));
break;
case PROP_METERED:
if (priv->manager)
g_object_get_property (G_OBJECT (priv->manager), pspec->name, value);
else
g_value_set_uint (value, NM_METERED_UNKNOWN);
break;
case PROP_ALL_DEVICES:
g_value_take_boxed (value, _nm_utils_copy_object_array (nm_client_get_all_devices (self)));
break;
case PROP_CHECKPOINTS:
if (priv->manager)
g_object_get_property (G_OBJECT (priv->manager), pspec->name, value);
else
g_value_take_boxed (value, g_ptr_array_new ());
break;
/* Settings properties. */
case PROP_CONNECTIONS:
if (priv->settings)
g_object_get_property (G_OBJECT (priv->settings), pspec->name, value);
else
g_value_take_boxed (value, _nm_utils_copy_object_array (&empty));
break;
case PROP_HOSTNAME:
if (priv->settings)
g_object_get_property (G_OBJECT (priv->settings), pspec->name, value);
else
g_value_set_string (value, NULL);
break;
case PROP_CAN_MODIFY:
if (priv->settings)
g_object_get_property (G_OBJECT (priv->settings), pspec->name, value);
else
g_value_set_boolean (value, FALSE);
break;
/* DNS properties */
case PROP_DNS_MODE:
case PROP_DNS_RC_MANAGER:
g_return_if_fail (pspec->name && strlen (pspec->name) > NM_STRLEN ("dns-"));
if (priv->dns_manager)
g_object_get_property (G_OBJECT (priv->dns_manager),
&pspec->name[NM_STRLEN ("dns-")], value);
else
g_value_set_string (value, NULL);
break;
case PROP_DNS_CONFIGURATION:
if (priv->dns_manager) {
g_object_get_property (G_OBJECT (priv->dns_manager),
NM_DNS_MANAGER_CONFIGURATION,
value);
} else
g_value_take_boxed (value, NULL);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}
}
static void
nm_client_class_init (NMClientClass *client_class)
{
GObjectClass *object_class = G_OBJECT_CLASS (client_class);
g_type_class_add_private (client_class, sizeof (NMClientPrivate));
/* virtual methods */
object_class->set_property = set_property;
object_class->get_property = get_property;
object_class->dispose = dispose;
/* properties */
/**
* NMClient:version:
*
* The NetworkManager version.
**/
g_object_class_install_property
(object_class, PROP_VERSION,
g_param_spec_string (NM_CLIENT_VERSION, "", "",
NULL,
G_PARAM_READABLE |
G_PARAM_STATIC_STRINGS));
/**
* NMClient:state:
*
* The current daemon state.
**/
g_object_class_install_property
(object_class, PROP_STATE,
g_param_spec_enum (NM_CLIENT_STATE, "", "",
NM_TYPE_STATE,
NM_STATE_UNKNOWN,
G_PARAM_READABLE |
G_PARAM_STATIC_STRINGS));
/**
* NMClient:startup:
*
* Whether the daemon is still starting up.
**/
g_object_class_install_property
(object_class, PROP_STARTUP,
g_param_spec_boolean (NM_CLIENT_STARTUP, "", "",
FALSE,
G_PARAM_READABLE |
G_PARAM_STATIC_STRINGS));
/**
* NMClient:nm-running:
*
* Whether the daemon is running.
**/
g_object_class_install_property
(object_class, PROP_NM_RUNNING,
g_param_spec_boolean (NM_CLIENT_NM_RUNNING, "", "",
FALSE,
G_PARAM_READABLE |
G_PARAM_STATIC_STRINGS));
/**
* NMClient:networking-enabled:
*
* Whether networking is enabled.
**/
g_object_class_install_property
(object_class, PROP_NETWORKING_ENABLED,
g_param_spec_boolean (NM_CLIENT_NETWORKING_ENABLED, "", "",
TRUE,
G_PARAM_READWRITE |
G_PARAM_STATIC_STRINGS));
/**
* NMClient:wireless-enabled:
*
* Whether wireless is enabled.
**/
g_object_class_install_property
(object_class, PROP_WIRELESS_ENABLED,
g_param_spec_boolean (NM_CLIENT_WIRELESS_ENABLED, "", "",
FALSE,
G_PARAM_READWRITE |
G_PARAM_STATIC_STRINGS));
/**
* NMClient:wireless-hardware-enabled:
*
* Whether the wireless hardware is enabled.
**/
g_object_class_install_property
(object_class, PROP_WIRELESS_HARDWARE_ENABLED,
g_param_spec_boolean (NM_CLIENT_WIRELESS_HARDWARE_ENABLED, "", "",
TRUE,
G_PARAM_READABLE |
G_PARAM_STATIC_STRINGS));
/**
* NMClient:wwan-enabled:
*
* Whether WWAN functionality is enabled.
**/
g_object_class_install_property
(object_class, PROP_WWAN_ENABLED,
g_param_spec_boolean (NM_CLIENT_WWAN_ENABLED, "", "",
FALSE,
G_PARAM_READWRITE |
G_PARAM_STATIC_STRINGS));
/**
* NMClient:wwan-hardware-enabled:
*
* Whether the WWAN hardware is enabled.
**/
g_object_class_install_property
(object_class, PROP_WWAN_HARDWARE_ENABLED,
g_param_spec_boolean (NM_CLIENT_WWAN_HARDWARE_ENABLED, "", "",
FALSE,
G_PARAM_READABLE |
G_PARAM_STATIC_STRINGS));
/**
* NMClient:wimax-enabled:
*
* Whether WiMAX functionality is enabled.
**/
g_object_class_install_property
(object_class, PROP_WIMAX_ENABLED,
g_param_spec_boolean (NM_CLIENT_WIMAX_ENABLED, "", "",
FALSE,
G_PARAM_READWRITE |
G_PARAM_STATIC_STRINGS));
/**
* NMClient:wimax-hardware-enabled:
*
* Whether the WiMAX hardware is enabled.
**/
g_object_class_install_property
(object_class, PROP_WIMAX_HARDWARE_ENABLED,
g_param_spec_boolean (NM_CLIENT_WIMAX_HARDWARE_ENABLED, "", "",
FALSE,
G_PARAM_READABLE |
G_PARAM_STATIC_STRINGS));
/**
* NMClient:active-connections: (type GPtrArray(NMActiveConnection))
*
* The active connections.
**/
g_object_class_install_property
(object_class, PROP_ACTIVE_CONNECTIONS,
g_param_spec_boxed (NM_CLIENT_ACTIVE_CONNECTIONS, "", "",
G_TYPE_PTR_ARRAY,
G_PARAM_READABLE |
G_PARAM_STATIC_STRINGS));
/**
* NMClient:connectivity:
*
* The network connectivity state.
*/
g_object_class_install_property
(object_class, PROP_CONNECTIVITY,
g_param_spec_enum (NM_CLIENT_CONNECTIVITY, "", "",
NM_TYPE_CONNECTIVITY_STATE,
NM_CONNECTIVITY_UNKNOWN,
G_PARAM_READABLE |
G_PARAM_STATIC_STRINGS));
/**
* NMClient::connectivity-check-available
*
* Whether a connectivity checking service has been configured.
*
* Since: 1.10
*/
g_object_class_install_property
(object_class, PROP_CONNECTIVITY_CHECK_AVAILABLE,
g_param_spec_boolean (NM_CLIENT_CONNECTIVITY_CHECK_AVAILABLE, "", "",
FALSE,
G_PARAM_READABLE |
G_PARAM_STATIC_STRINGS));
/**
* NMClient::connectivity-check-enabled
*
* Whether a connectivity checking service has been enabled.
*
* Since: 1.10
*/
g_object_class_install_property
(object_class, PROP_CONNECTIVITY_CHECK_ENABLED,
g_param_spec_boolean (NM_CLIENT_CONNECTIVITY_CHECK_ENABLED, "", "",
FALSE,
G_PARAM_READWRITE |
G_PARAM_STATIC_STRINGS));
/**
* NMClient:primary-connection:
*
* The #NMActiveConnection of the device with the default route;
* see nm_client_get_primary_connection() for more details.
**/
g_object_class_install_property
(object_class, PROP_PRIMARY_CONNECTION,
g_param_spec_object (NM_CLIENT_PRIMARY_CONNECTION, "", "",
NM_TYPE_ACTIVE_CONNECTION,
G_PARAM_READABLE |
G_PARAM_STATIC_STRINGS));
/**
* NMClient:activating-connection:
*
* The #NMActiveConnection of the activating connection that is
* likely to become the new #NMClient:primary-connection.
**/
g_object_class_install_property
(object_class, PROP_ACTIVATING_CONNECTION,
g_param_spec_object (NM_CLIENT_ACTIVATING_CONNECTION, "", "",
NM_TYPE_ACTIVE_CONNECTION,
G_PARAM_READABLE |
G_PARAM_STATIC_STRINGS));
/**
* NMClient:devices: (type GPtrArray(NMDevice))
*
* List of real network devices. Does not include placeholder devices.
**/
g_object_class_install_property
(object_class, PROP_DEVICES,
g_param_spec_boxed (NM_CLIENT_DEVICES, "", "",
G_TYPE_PTR_ARRAY,
G_PARAM_READABLE |
G_PARAM_STATIC_STRINGS));
/**
* NMClient:all-devices: (type GPtrArray(NMDevice))
*
* List of both real devices and device placeholders.
* Since: 1.2
**/
g_object_class_install_property
(object_class, PROP_ALL_DEVICES,
g_param_spec_boxed (NM_CLIENT_ALL_DEVICES, "", "",
G_TYPE_PTR_ARRAY,
G_PARAM_READABLE |
G_PARAM_STATIC_STRINGS));
/**
* NMClient:connections: (type GPtrArray(NMRemoteConnection))
*
* The list of configured connections that are available to the user. (Note
* that this differs from the underlying D-Bus property, which may also
* contain the object paths of connections that the user does not have
* permission to read the details of.)
*/
g_object_class_install_property
(object_class, PROP_CONNECTIONS,
g_param_spec_boxed (NM_CLIENT_CONNECTIONS, "", "",
G_TYPE_PTR_ARRAY,
G_PARAM_READABLE |
G_PARAM_STATIC_STRINGS));
/**
* NMClient:hostname:
*
* The machine hostname stored in persistent configuration. This can be
* modified by calling nm_client_save_hostname().
*/
g_object_class_install_property
(object_class, PROP_HOSTNAME,
g_param_spec_string (NM_CLIENT_HOSTNAME, "", "",
NULL,
G_PARAM_READABLE |
G_PARAM_STATIC_STRINGS));
/**
* NMClient:can-modify:
*
* If %TRUE, adding and modifying connections is supported.
*/
g_object_class_install_property
(object_class, PROP_CAN_MODIFY,
g_param_spec_boolean (NM_CLIENT_CAN_MODIFY, "", "",
FALSE,
G_PARAM_READABLE |
G_PARAM_STATIC_STRINGS));
/**
* NMClient:metered:
*
* Whether the connectivity is metered.
*
* Since: 1.2
**/
g_object_class_install_property
(object_class, PROP_METERED,
g_param_spec_uint (NM_CLIENT_METERED, "", "",
0, G_MAXUINT32, NM_METERED_UNKNOWN,
G_PARAM_READABLE |
G_PARAM_STATIC_STRINGS));
/**
* NMClient:dns-mode:
*
* The current DNS processing mode.
*
* Since: 1.6
**/
g_object_class_install_property
(object_class, PROP_DNS_MODE,
g_param_spec_string (NM_CLIENT_DNS_MODE, "", "",
"",
G_PARAM_READABLE |
G_PARAM_STATIC_STRINGS));
/**
* NMClient:dns-rc-manager:
*
* The current resolv.conf management mode.
*
* Since: 1.6
**/
g_object_class_install_property
(object_class, PROP_DNS_RC_MANAGER,
g_param_spec_string (NM_CLIENT_DNS_RC_MANAGER, "", "",
"",
G_PARAM_READABLE |
G_PARAM_STATIC_STRINGS));
/**
* NMClient:dns-configuration: (type GPtrArray(GVariant))
*
* The current DNS configuration represented as an array of
* dictionaries. Each dictionary has the "nameservers",
* "priority" keys and, optionally, "interface" and "vpn".
* "nameservers" is the list of DNS servers, "priority" their
* relative priority, "interface" the interface on which these
* servers are contacted, "vpn" a boolean telling whether the
* configuration was obtained from a VPN connection.
*
* Since: 1.6
**/
g_object_class_install_property
(object_class, PROP_DNS_CONFIGURATION,
g_param_spec_boxed (NM_CLIENT_DNS_CONFIGURATION, "", "",
G_TYPE_PTR_ARRAY,
G_PARAM_READABLE |
G_PARAM_STATIC_STRINGS));
/**
* NMClient:checkpoints: (type GPtrArray(NMCheckpoint))
*
* The list of active checkpoints.
*
* Since: 1.12
*/
g_object_class_install_property
(object_class, PROP_CHECKPOINTS,
g_param_spec_boxed (NM_MANAGER_CHECKPOINTS, "", "",
G_TYPE_PTR_ARRAY,
G_PARAM_READABLE |
G_PARAM_STATIC_STRINGS));
/* signals */
/**
* NMClient::device-added:
* @client: the client that received the signal
* @device: (type NMDevice): the new device
*
* Notifies that a #NMDevice is added. This signal is not emitted for
* placeholder devices.
**/
signals[DEVICE_ADDED] =
g_signal_new (NM_CLIENT_DEVICE_ADDED,
G_OBJECT_CLASS_TYPE (object_class),
G_SIGNAL_RUN_FIRST,
G_STRUCT_OFFSET (NMClientClass, device_added),
NULL, NULL, NULL,
G_TYPE_NONE, 1,
G_TYPE_OBJECT);
/**
* NMClient::device-removed:
* @client: the client that received the signal
* @device: (type NMDevice): the removed device
*
* Notifies that a #NMDevice is removed. This signal is not emitted for
* placeholder devices.
**/
signals[DEVICE_REMOVED] =
g_signal_new (NM_CLIENT_DEVICE_REMOVED,
G_OBJECT_CLASS_TYPE (object_class),
G_SIGNAL_RUN_FIRST,
G_STRUCT_OFFSET (NMClientClass, device_removed),
NULL, NULL, NULL,
G_TYPE_NONE, 1,
G_TYPE_OBJECT);
/**
* NMClient::any-device-added:
* @client: the client that received the signal
* @device: (type NMDevice): the new device
*
* Notifies that a #NMDevice is added. This signal is emitted for both
* regular devices and placeholder devices.
**/
signals[ANY_DEVICE_ADDED] =
g_signal_new (NM_CLIENT_ANY_DEVICE_ADDED,
G_OBJECT_CLASS_TYPE (object_class),
G_SIGNAL_RUN_FIRST,
G_STRUCT_OFFSET (NMClientClass, any_device_added),
NULL, NULL, NULL,
G_TYPE_NONE, 1,
G_TYPE_OBJECT);
/**
* NMClient::any-device-removed:
* @client: the client that received the signal
* @device: (type NMDevice): the removed device
*
* Notifies that a #NMDevice is removed. This signal is emitted for both
* regular devices and placeholder devices.
**/
signals[ANY_DEVICE_REMOVED] =
g_signal_new (NM_CLIENT_ANY_DEVICE_REMOVED,
G_OBJECT_CLASS_TYPE (object_class),
G_SIGNAL_RUN_FIRST,
G_STRUCT_OFFSET (NMClientClass, any_device_removed),
NULL, NULL, NULL,
G_TYPE_NONE, 1,
G_TYPE_OBJECT);
/**
* NMClient::permission-changed:
* @client: the client that received the signal
* @permission: a permission from #NMClientPermission
* @result: the permission's result, one of #NMClientPermissionResult
*
* Notifies that a permission has changed
**/
signals[PERMISSION_CHANGED] =
g_signal_new (NM_CLIENT_PERMISSION_CHANGED,
G_OBJECT_CLASS_TYPE (object_class),
G_SIGNAL_RUN_FIRST,
0, NULL, NULL, NULL,
G_TYPE_NONE, 2, G_TYPE_UINT, G_TYPE_UINT);
/**
* NMClient::connection-added:
* @client: the settings object that received the signal
* @connection: the new connection
*
* Notifies that a #NMConnection has been added.
**/
signals[CONNECTION_ADDED] =
g_signal_new (NM_CLIENT_CONNECTION_ADDED,
G_OBJECT_CLASS_TYPE (object_class),
G_SIGNAL_RUN_FIRST,
G_STRUCT_OFFSET (NMClientClass, connection_added),
NULL, NULL, NULL,
G_TYPE_NONE, 1,
NM_TYPE_REMOTE_CONNECTION);
/**
* NMClient::connection-removed:
* @client: the settings object that received the signal
* @connection: the removed connection
*
* Notifies that a #NMConnection has been removed.
**/
signals[CONNECTION_REMOVED] =
g_signal_new (NM_CLIENT_CONNECTION_REMOVED,
G_OBJECT_CLASS_TYPE (object_class),
G_SIGNAL_RUN_FIRST,
G_STRUCT_OFFSET (NMClientClass, connection_removed),
NULL, NULL, NULL,
G_TYPE_NONE, 1,
NM_TYPE_REMOTE_CONNECTION);
/**
* NMClient::active-connection-added:
* @client: the settings object that received the signal
* @active_connection: the new active connection
*
* Notifies that a #NMActiveConnection has been added.
**/
signals[ACTIVE_CONNECTION_ADDED] =
g_signal_new (NM_CLIENT_ACTIVE_CONNECTION_ADDED,
G_OBJECT_CLASS_TYPE (object_class),
G_SIGNAL_RUN_FIRST,
0, NULL, NULL, NULL,
G_TYPE_NONE, 1,
NM_TYPE_ACTIVE_CONNECTION);
/**
* NMClient::active-connection-removed:
* @client: the settings object that received the signal
* @active_connection: the removed active connection
*
* Notifies that a #NMActiveConnection has been removed.
**/
signals[ACTIVE_CONNECTION_REMOVED] =
g_signal_new (NM_CLIENT_ACTIVE_CONNECTION_REMOVED,
G_OBJECT_CLASS_TYPE (object_class),
G_SIGNAL_RUN_FIRST,
0, NULL, NULL, NULL,
G_TYPE_NONE, 1,
NM_TYPE_ACTIVE_CONNECTION);
}
static void
nm_client_initable_iface_init (GInitableIface *iface)
{
iface->init = init_sync;
}
static void
nm_client_async_initable_iface_init (GAsyncInitableIface *iface)
{
iface->init_async = init_async;
iface->init_finish = init_finish;
}
/*****************************************************************************
* Backported symbols. Usually, new API is only added in new major versions
* of NetworkManager (that is, on "master" branch). Sometimes however, we might
* have to backport some API to an older stable branch. In that case, we backport
* the symbols with a different version corresponding to the minor API.
*
* To allow upgrading from such a extended minor-release, "master" contains these
* backported symbols too.
*
* For example, 1.2.0 added nm_setting_connection_autoconnect_slaves_get_type.
* This was backported for 1.0.4 as nm_setting_connection_autoconnect_slaves_get_type@libnm_1_0_4
* To allow an application that was linked against 1.0.4 to seamlessly upgrade to
* a newer major version, the same symbols is also exposed on "master". Note, that
* a user can only seamlessly upgrade to a newer major version, that is released
* *after* 1.0.4 is out. In this example, 1.2.0 was released after 1.4.0, and thus
* a 1.0.4 user can upgrade to 1.2.0 ABI.
*****************************************************************************/
NM_BACKPORT_SYMBOL (libnm_1_0_4, NMSettingConnectionAutoconnectSlaves, nm_setting_connection_get_autoconnect_slaves, (NMSettingConnection *setting), (setting));
NM_BACKPORT_SYMBOL (libnm_1_0_4, GType, nm_setting_connection_autoconnect_slaves_get_type, (void), ());
NM_BACKPORT_SYMBOL (libnm_1_0_6, NMMetered, nm_setting_connection_get_metered, (NMSettingConnection *setting), (setting));
NM_BACKPORT_SYMBOL (libnm_1_0_6, GType, nm_metered_get_type, (void), ());
NM_BACKPORT_SYMBOL (libnm_1_0_6, NMSettingWiredWakeOnLan, nm_setting_wired_get_wake_on_lan,
(NMSettingWired *setting), (setting));
NM_BACKPORT_SYMBOL (libnm_1_0_6, const char *, nm_setting_wired_get_wake_on_lan_password,
(NMSettingWired *setting), (setting));
NM_BACKPORT_SYMBOL (libnm_1_0_6, GType, nm_setting_wired_wake_on_lan_get_type, (void), ());
NM_BACKPORT_SYMBOL (libnm_1_0_6, const guint *, nm_utils_wifi_2ghz_freqs, (void), ());
NM_BACKPORT_SYMBOL (libnm_1_0_6, const guint *, nm_utils_wifi_5ghz_freqs, (void), ());
NM_BACKPORT_SYMBOL (libnm_1_0_6, char *, nm_utils_enum_to_str,
(GType type, int value), (type, value));
NM_BACKPORT_SYMBOL (libnm_1_0_6, gboolean, nm_utils_enum_from_str,
(GType type, const char *str, int *out_value, char **err_token),
(type, str, out_value, err_token));
NM_BACKPORT_SYMBOL (libnm_1_2_4, gint, nm_setting_ip_config_get_dns_priority, (NMSettingIPConfig *setting), (setting));
|