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
|
/*
* Copyright (c) 2015, Ford Motor Company
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
*
* Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following
* disclaimer in the documentation and/or other materials provided with the
* distribution.
*
* Neither the name of the Ford Motor Company nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
#include "config_profile/profile.h"
#include <errno.h>
#include <string.h>
#include <stdlib.h>
#include <sstream>
#include <algorithm>
#include "config_profile/ini_file.h"
#include "utils/logger.h"
#include "utils/threads/thread.h"
#include "utils/file_system.h"
namespace {
#define LOG_UPDATED_VALUE(value, key, section) {\
LOG4CXX_INFO(logger_, "Setting value '" << value\
<< "' for key '" << key\
<< "' in section '" << section << "'.");\
}
#define LOG_UPDATED_BOOL_VALUE(value, key, section) {\
LOG4CXX_INFO(logger_, "Setting value '" << std::boolalpha << value\
<< "' for key '" << key\
<< "' in section '" << section << "'.");\
}
const char* kDefaultConfigFileName = "smartDeviceLink.ini";
const char* kMainSection = "MAIN";
const char* kPolicySection = "Policy";
const char* kHmiSection = "HMI";
const char* kAppInfoSection = "AppInfo";
const char* kMediaManagerSection = "MEDIA MANAGER";
const char* kGlobalPropertiesSection = "GLOBAL PROPERTIES";
const char* kVrCommandsSection = "VR COMMANDS";
const char* kTransportManagerSection = "TransportManager";
const char* kApplicationManagerSection = "ApplicationManager";
const char* kFilesystemRestrictionsSection = "FILESYSTEM RESTRICTIONS";
const char* kIAPSection = "IAP";
const char* kProtocolHandlerSection = "ProtocolHandler";
const char* kSDL4Section = "SDL4";
const char* kResumptionSection = "Resumption";
const char* kHmiCapabilitiesKey = "HMICapabilities";
const char* kPathToSnapshotKey = "PathToSnapshot";
const char* kPreloadedPTKey = "PreloadedPT";
const char* kAttemptsToOpenPolicyDBKey = "AttemptsToOpenPolicyDB";
const char* kOpenAttemptTimeoutMsKey = "OpenAttemptTimeoutMs";
const char* kServerAddressKey = "ServerAddress";
const char* kAppInfoStorageKey = "AppInfoStorage";
const char* kAppStorageFolderKey = "AppStorageFolder";
const char* kAppResourseFolderKey = "AppResourceFolder";
const char* kAppConfigFolderKey = "AppConfigFolder";
const char* kEnableProtocol4Key = "EnableProtocol4";
const char* kAppIconsFolderKey = "AppIconsFolder";
const char* kAppIconsFolderMaxSizeKey = "AppIconsFolderMaxSize";
const char* kAppIconsAmountToRemoveKey = "AppIconsAmountToRemove";
const char* kLaunchHMIKey = "LaunchHMI";
#ifdef WEB_HMI
const char* kLinkToWebHMI = "LinkToWebHMI";
#endif // WEB_HMI
const char* kStartStreamRetry = "StartStreamRetry";
const char* kEnableRedecodingKey = "EnableRedecoding";
const char* kVideoStreamConsumerKey = "VideoStreamConsumer";
const char* kAudioStreamConsumerKey = "AudioStreamConsumer";
const char* kNamedVideoPipePathKey = "NamedVideoPipePath";
const char* kNamedAudioPipePathKey = "NamedAudioPipePath";
const char* kVideoStreamFileKey = "VideoStreamFile";
const char* kAudioStreamFileKey = "AudioStreamFile";
const char* kAudioDataStoppedTimeoutKey = "AudioDataStoppedTimeout";
const char* kVideoDataStoppedTimeoutKey = "VideoDataStoppedTimeout";
const char* kMixingAudioSupportedKey = "MixingAudioSupported";
const char* kHelpPromptKey = "HelpPromt";
const char* kTimeoutPromptKey = "TimeOutPromt";
const char* kHelpTitleKey = "HelpTitle";
const char* kHelpCommandKey = "HelpCommand";
const char* kSystemFilesPathKey = "SystemFilesPath";
const char* kHeartBeatTimeoutKey = "HeartBeatTimeout";
const char* kUseLastStateKey = "UseLastState";
const char* kTCPAdapterPortKey = "TCPAdapterPort";
const char* kServerPortKey = "ServerPort";
const char* kVideoStreamingPortKey = "VideoStreamingPort";
const char* kAudioStreamingPortKey = "AudioStreamingPort";
const char* kStopStreamingTimeout = "StopStreamingTimeout";
const char* kTimeTestingPortKey = "TimeTestingPort";
const char* kThreadStackSizeKey = "ThreadStackSize";
const char* kMaxCmdIdKey = "MaxCmdID";
const char* kPutFileRequestKey = "PutFileRequest";
const char* kDeleteFileRequestKey = "DeleteFileRequest";
const char* kListFilesRequestKey = "ListFilesRequest";
const char* kDefaultTimeoutKey = "DefaultTimeout";
const char* kAppResumingTimeoutKey = "ApplicationResumingTimeout";
const char* kAppSavePersistentDataTimeoutKey = "AppSavePersistentDataTimeout";
const char* kResumptionDelayBeforeIgnKey = "ResumptionDelayBeforeIgn";
const char* kResumptionDelayAfterIgnKey = "ResumptionDelayAfterIgn";
const char* kAppDirectoryQuotaKey = "AppDirectoryQuota";
const char* kAppTimeScaleMaxRequestsKey = "AppTimeScaleMaxRequests";
const char* kAppRequestsTimeScaleKey = "AppRequestsTimeScale";
const char* kAppHmiLevelNoneTimeScaleMaxRequestsKey =
"AppHMILevelNoneTimeScaleMaxRequests";
const char* kAppHmiLevelNoneRequestsTimeScaleKey =
"AppHMILevelNoneRequestsTimeScale";
const char* kPendingRequestsAmoundKey = "PendingRequestsAmount";
const char* kSupportedDiagModesKey = "SupportedDiagModes";
const char* kTransportManagerDisconnectTimeoutKey = "DisconnectTimeout";
const char* kTTSDelimiterKey = "TTSDelimiter";
const char* kRecordingFileNameKey = "RecordingFileName";
const char* kRecordingFileSourceKey = "RecordingFileSource";
const char* kEnablePolicy = "EnablePolicy";
const char* kMmeDatabaseNameKey = "MMEDatabase";
const char* kEventMQKey = "EventMQ";
const char* kAckMQKey = "AckMQ";
const char* kApplicationListUpdateTimeoutKey = "ApplicationListUpdateTimeout";
const char* kReadDIDFrequencykey = "ReadDIDRequest";
const char* kGetVehicleDataFrequencyKey = "GetVehicleDataRequest";
const char* kLegacyProtocolMaskKey = "LegacyProtocol";
const char* kHubProtocolMaskKey = "HubProtocol";
const char* kPoolProtocolMaskKey = "PoolProtocol";
const char* kIAPSystemConfigKey = "IAPSystemConfig";
const char* kIAP2SystemConfigKey = "IAP2SystemConfig";
const char* kIAP2HubConnectAttemptskey = "IAP2HubConnectAttempts";
const char* kIAPHubConnectionWaitTimeoutKey = "ConnectionWaitTimeout";
const char* kDefaultHubProtocolIndexKey = "DefaultHubProtocolIndex";
const char* kTTSGlobalPropertiesTimeoutKey = "TTSGlobalPropertiesTimeout";
const char* kMaximumPayloadSizeKey = "MaximumPayloadSize";
const char* kFrequencyCount = "FrequencyCount";
const char* kFrequencyTime = "FrequencyTime";
const char* kMalformedMessageFiltering = "MalformedMessageFiltering";
const char* kMalformedFrequencyCount = "MalformedFrequencyCount";
const char* kMalformedFrequencyTime = "MalformedFrequencyTime";
const char* kHashStringSizeKey = "HashStringSize";
#ifdef WEB_HMI
const char* kDefaultLinkToWebHMI = "HMI/index.html";
#endif // WEB_HMI
const char* kDefaultPoliciesSnapshotFileName = "sdl_snapshot.json";
const char* kDefaultHmiCapabilitiesFileName = "hmi_capabilities.json";
const char* kDefaultPreloadedPTFileName = "sdl_preloaded_pt.json";
const char* kDefaultServerAddress = "127.0.0.1";
const char* kDefaultAppInfoFileName = "app_info.dat";
const char* kDefaultSystemFilesPath = "/tmp/fs/mp/images/ivsu_cache";
const char* kDefaultTtsDelimiter = ",";
const uint32_t kDefaultAudioDataStoppedTimeout = 1000;
const uint32_t kDefaultVideoDataStoppedTimeout = 1000;
const char* kDefaultMmeDatabaseName = "/dev/qdb/mediaservice_db";
const char* kDefaultEventMQ = "/dev/mqueue/ToSDLCoreUSBAdapter";
const char* kDefaultAckMQ = "/dev/mqueue/FromSDLCoreUSBAdapter";
const char* kDefaultRecordingFileSourceName = "audio.8bit.wav";
const char* kDefaultRecordingFileName = "record.wav";
const char* kDefaultThreadPoolSize = "ThreadPoolSize";
const char* kDefaultLegacyProtocolMask = "com.ford.sync.prot";
const char* kDefaultHubProtocolMask = "com.smartdevicelink.prot";
const char* kDefaultPoolProtocolMask = "com.smartdevicelink.prot";
const char* kDefaultIAPSystemConfig = "/fs/mp/etc/mm/ipod.cfg";
const char* kDefaultIAP2SystemConfig = "/fs/mp/etc/mm/iap2.cfg";
const uint32_t kDefaultHubProtocolIndex = 0;
const uint32_t kDefaultHeartBeatTimeout = 0;
const uint16_t kDefautTransportManagerTCPPort = 12345;
const uint16_t kDefaultServerPort = 8087;
const uint16_t kDefaultVideoStreamingPort = 5050;
const uint16_t kDefaultAudioStreamingPort = 5080;
const uint32_t kDefaultStopStreamingTimeout = 1;
const uint16_t kDefaultTimeTestingPort = 5090;
const uint32_t kDefaultMaxCmdId = 2000000000;
const uint32_t kDefaultPutFileRequestInNone = 5;
const uint32_t kDefaultDeleteFileRequestInNone = 5;
const uint32_t kDefaultListFilesRequestInNone = 5;
const uint32_t kDefaultTimeout = 10000;
const uint32_t kDefaultAppResumingTimeout = 3;
const uint32_t kDefaultAppSavePersistentDataTimeout = 10;
const uint32_t kDefaultResumptionDelayBeforeIgn = 30;
const uint32_t kDefaultResumptionDelayAfterIgn = 30;
const uint32_t kDefaultHashStringSize = 32;
const uint32_t kDefaultDirQuota = 104857600;
const uint32_t kDefaultAppTimeScaleMaxRequests = 0;
const uint32_t kDefaultAppRequestsTimeScale = 0;
const uint32_t kDefaultAppHmiLevelNoneTimeScaleMaxRequests = 100;
const uint32_t kDefaultAppHmiLevelNoneRequestsTimeScale = 10;
const uint32_t kDefaultPendingRequestsAmount = 0;
const uint32_t kDefaultTransportManagerDisconnectTimeout = 0;
const uint32_t kDefaultApplicationListUpdateTimeout = 1;
const std::pair<uint32_t, uint32_t> kReadDIDFrequency = { 5, 1 };
const std::pair<uint32_t, uint32_t> kGetVehicleDataFrequency = { 5, 1 };
const std::pair<uint32_t, uint32_t> kStartStreamRetryAmount = { 3, 1 };
const uint32_t kDefaultMaxThreadPoolSize = 2;
const int kDefaultIAP2HubConnectAttempts = 0;
const int kDefaultIAPHubConnectionWaitTimeout = 10;
const uint16_t kDefaultTTSGlobalPropertiesTimeout = 20;
// TCP MTU - header size = 1500 - 12
const size_t kDefaultMaximumPayloadSize = 1500 - 12;
const size_t kDefaultFrequencyCount = 1000;
const size_t kDefaultFrequencyTime = 1000;
const bool kDefaulMalformedMessageFiltering = true;
const size_t kDefaultMalformedFrequencyCount = 10;
const size_t kDefaultMalformedFrequencyTime = 1000;
const uint16_t kDefaultAttemptsToOpenPolicyDB = 5;
const uint16_t kDefaultOpenAttemptTimeoutMsKey = 500;
const uint32_t kDefaultAppIconsFolderMaxSize = 1048576;
const uint32_t kDefaultAppIconsAmountToRemove = 1;
} // namespace
namespace profile {
CREATE_LOGGERPTR_GLOBAL(logger_, "Profile")
Profile::Profile()
: launch_hmi_(true),
#ifdef WEB_HMI
link_to_web_hmi_(kDefaultLinkToWebHMI),
#endif // WEB_HMI
app_config_folder_(),
app_storage_folder_(),
app_resourse_folder_(),
enable_protocol_4_(false),
app_icons_folder_(),
app_icons_folder_max_size_(kDefaultAppIconsFolderMaxSize),
app_icons_amount_to_remove_(kDefaultAppIconsAmountToRemove),
config_file_name_(kDefaultConfigFileName),
server_address_(kDefaultServerAddress),
server_port_(kDefaultServerPort),
video_streaming_port_(kDefaultVideoStreamingPort),
audio_streaming_port_(kDefaultAudioStreamingPort),
time_testing_port_(kDefaultTimeTestingPort),
hmi_capabilities_file_name_(kDefaultHmiCapabilitiesFileName),
help_prompt_(),
time_out_promt_(),
min_tread_stack_size_(threads::Thread::kMinStackSize),
is_mixing_audio_supported_(false),
is_redecoding_enabled_(false),
max_cmd_id_(kDefaultMaxCmdId),
default_timeout_(kDefaultTimeout),
app_resuming_timeout_(kDefaultAppResumingTimeout),
app_dir_quota_(kDefaultDirQuota),
app_hmi_level_none_time_scale_max_requests_(
kDefaultAppHmiLevelNoneTimeScaleMaxRequests),
app_hmi_level_none_requests_time_scale_(
kDefaultAppHmiLevelNoneRequestsTimeScale),
app_time_scale_max_requests_(kDefaultAppTimeScaleMaxRequests),
app_requests_time_scale_(kDefaultAppRequestsTimeScale),
pending_requests_amount_(kDefaultPendingRequestsAmount),
put_file_in_none_(kDefaultPutFileRequestInNone),
delete_file_in_none_(kDefaultDeleteFileRequestInNone),
list_files_in_none_(kDefaultListFilesRequestInNone),
app_info_storage_(kDefaultAppInfoFileName),
heart_beat_timeout_(kDefaultHeartBeatTimeout),
policy_snapshot_file_name_(kDefaultPoliciesSnapshotFileName),
enable_policy_(false),
transport_manager_disconnect_timeout_(
kDefaultTransportManagerDisconnectTimeout),
use_last_state_(false),
supported_diag_modes_(),
system_files_path_(kDefaultSystemFilesPath),
transport_manager_tcp_adapter_port_(kDefautTransportManagerTCPPort),
tts_delimiter_(kDefaultTtsDelimiter),
audio_data_stopped_timeout_(kDefaultAudioDataStoppedTimeout),
video_data_stopped_timeout_(kDefaultVideoDataStoppedTimeout),
mme_db_name_(kDefaultMmeDatabaseName),
event_mq_name_(kDefaultEventMQ),
ack_mq_name_(kDefaultAckMQ),
recording_file_source_(kDefaultRecordingFileSourceName),
recording_file_name_(kDefaultRecordingFileName),
application_list_update_timeout_(kDefaultApplicationListUpdateTimeout),
iap_legacy_protocol_mask_(kDefaultLegacyProtocolMask),
iap_hub_protocol_mask_(kDefaultHubProtocolMask),
iap_pool_protocol_mask_(kDefaultPoolProtocolMask),
iap_system_config_(kDefaultIAPSystemConfig),
iap2_system_config_(kDefaultIAP2SystemConfig),
iap2_hub_connect_attempts_(kDefaultIAP2HubConnectAttempts),
iap_hub_connection_wait_timeout_(kDefaultIAPHubConnectionWaitTimeout),
tts_global_properties_timeout_(kDefaultTTSGlobalPropertiesTimeout),
attempts_to_open_policy_db_(kDefaultAttemptsToOpenPolicyDB),
open_attempt_timeout_ms_(kDefaultAttemptsToOpenPolicyDB),
hash_string_size_(kDefaultHashStringSize) {
}
Profile::~Profile() {
}
void Profile::config_file_name(const std::string& fileName) {
if (false == fileName.empty()) {
config_file_name_ = fileName;
UpdateValues();
}
}
const std::string& Profile::config_file_name() const {
return config_file_name_;
}
bool Profile::launch_hmi() const {
return launch_hmi_;
}
#ifdef WEB_HMI
std::string Profile::link_to_web_hmi() const {
return link_to_web_hmi_;
}
#endif // WEB_HMI
const std::string& Profile::app_config_folder() const {
return app_config_folder_;
}
const std::string& Profile::app_storage_folder() const {
return app_storage_folder_;
}
const std::string& Profile::app_resourse_folder() const {
return app_resourse_folder_;
}
bool Profile::enable_protocol_4() const {
return enable_protocol_4_;
}
const std::string&Profile::app_icons_folder() const {
return app_icons_folder_;
}
const uint32_t&Profile::app_icons_folder_max_size() const {
return app_icons_folder_max_size_;
}
const uint32_t&Profile::app_icons_amount_to_remove() const {
return app_icons_amount_to_remove_;
}
const std::string& Profile::hmi_capabilities_file_name() const {
return hmi_capabilities_file_name_;
}
const std::string& Profile::server_address() const {
return server_address_;
}
const std::vector<std::string>& Profile::help_prompt() const {
return help_prompt_;
}
const std::vector<std::string>& Profile::time_out_promt() const {
return time_out_promt_;
}
const std::vector<std::string>& Profile::vr_commands() const {
return vr_commands_;
}
const uint32_t& Profile::max_cmd_id() const {
return max_cmd_id_;
}
const uint32_t& Profile::default_timeout() const {
return default_timeout_;
}
const uint32_t& Profile::app_resuming_timeout() const {
return app_resuming_timeout_;
}
const uint32_t& Profile::app_resumption_save_persistent_data_timeout() const {
return app_resumption_save_persistent_data_timeout_;
}
const std::string& Profile::vr_help_title() const {
return vr_help_title_;
}
const uint16_t& Profile::server_port() const {
return server_port_;
}
const uint16_t& Profile::video_streaming_port() const {
return video_streaming_port_;
}
const uint16_t& Profile::audio_streaming_port() const {
return audio_streaming_port_;
}
uint32_t Profile::stop_streaming_timeout() const {
return stop_streaming_timeout_;
}
const uint16_t& Profile::time_testing_port() const {
return time_testing_port_;
}
const uint64_t& Profile::thread_min_stack_size() const {
return min_tread_stack_size_;
}
bool Profile::is_mixing_audio_supported() const {
return is_mixing_audio_supported_;
}
const uint32_t& Profile::app_dir_quota() const {
return app_dir_quota_;
}
bool Profile::is_redecoding_enabled() const {
return is_redecoding_enabled_;
}
const std::string& Profile::video_server_type() const {
return video_consumer_type_;
}
const std::string& Profile::audio_server_type() const {
return audio_consumer_type_;
}
const std::string& Profile::named_video_pipe_path() const {
return named_video_pipe_path_;
}
const std::string& Profile::named_audio_pipe_path() const {
return named_audio_pipe_path_;
}
const uint32_t& Profile::app_hmi_level_none_time_scale() const {
return app_hmi_level_none_requests_time_scale_;
}
const uint32_t& Profile::app_hmi_level_none_time_scale_max_requests() const {
return app_hmi_level_none_time_scale_max_requests_;
}
const std::string& Profile::video_stream_file() const {
return video_stream_file_;
}
const std::string& Profile::audio_stream_file() const {
return audio_stream_file_;
}
const std::uint32_t Profile::audio_data_stopped_timeout() const {
return audio_data_stopped_timeout_;
}
const std::uint32_t Profile::video_data_stopped_timeout() const {
return video_data_stopped_timeout_;
}
const uint32_t& Profile::app_time_scale() const {
return app_requests_time_scale_;
}
const uint32_t& Profile::app_time_scale_max_requests() const {
return app_time_scale_max_requests_;
}
const uint32_t& Profile::pending_requests_amount() const {
return pending_requests_amount_;
}
const uint32_t& Profile::put_file_in_none() const {
return put_file_in_none_;
}
const uint32_t& Profile::delete_file_in_none() const {
return delete_file_in_none_;
}
const uint32_t& Profile::list_files_in_none() const {
return list_files_in_none_;
}
const std::string& Profile::app_info_storage() const {
return app_info_storage_;
}
int32_t Profile::heart_beat_timeout() const {
return heart_beat_timeout_;
}
const std::string& Profile::preloaded_pt_file() const {
return preloaded_pt_file_;
}
const std::string& Profile::policies_snapshot_file_name() const {
return policy_snapshot_file_name_;
}
bool Profile::enable_policy() const {
return enable_policy_;
}
uint32_t Profile::transport_manager_disconnect_timeout() const {
return transport_manager_disconnect_timeout_;
}
bool Profile::use_last_state() const {
return use_last_state_;
}
const std::string& Profile::system_files_path() const {
return system_files_path_;
}
const std::vector<uint32_t>& Profile::supported_diag_modes() const {
return supported_diag_modes_;
}
uint16_t Profile::transport_manager_tcp_adapter_port() const {
return transport_manager_tcp_adapter_port_;
}
const std::string& Profile::tts_delimiter() const {
return tts_delimiter_;
}
const std::string& Profile::recording_file_source() const {
return recording_file_source_;
}
const std::string&Profile::recording_file_name() const {
return recording_file_name_;
}
const std::string& Profile::mme_db_name() const {
return mme_db_name_;
}
const std::string& Profile::event_mq_name() const {
return event_mq_name_;
}
const std::string& Profile::ack_mq_name() const {
return ack_mq_name_;
}
uint32_t Profile::application_list_update_timeout() const {
return application_list_update_timeout_;
}
const std::pair<uint32_t, int32_t>& Profile::read_did_frequency() const {
return read_did_frequency_;
}
const std::pair<uint32_t, int32_t>& Profile::get_vehicle_data_frequency() const {
return get_vehicle_data_frequency_;
}
const std::pair<uint32_t, int32_t>& Profile::start_stream_retry_amount() const {
return start_stream_retry_amount_;
}
uint32_t Profile::thread_pool_size() const {
return max_thread_pool_size_;
}
uint32_t Profile::default_hub_protocol_index() const {
return default_hub_protocol_index_;
}
const std::string& Profile::iap_legacy_protocol_mask() const {
return iap_legacy_protocol_mask_;
}
const std::string& Profile::iap_hub_protocol_mask() const {
return iap_hub_protocol_mask_;
}
const std::string& Profile::iap_pool_protocol_mask() const {
return iap_pool_protocol_mask_;
}
const std::string& Profile::iap_system_config() const {
return iap_system_config_;
}
const std::string& Profile::iap2_system_config() const {
return iap2_system_config_;
}
int Profile::iap2_hub_connect_attempts() const {
return iap2_hub_connect_attempts_;
}
int Profile::iap_hub_connection_wait_timeout() const {
return iap_hub_connection_wait_timeout_;
}
size_t Profile::maximum_payload_size() const {
size_t maximum_payload_size = 0;
ReadUIntValue(&maximum_payload_size, kDefaultMaximumPayloadSize,
kProtocolHandlerSection, kMaximumPayloadSizeKey);
return maximum_payload_size;
}
size_t Profile::message_frequency_count() const {
size_t message_frequency_count = 0;
ReadUIntValue(&message_frequency_count, kDefaultFrequencyCount,
kProtocolHandlerSection, kFrequencyCount);
return message_frequency_count;
}
size_t Profile::message_frequency_time() const {
size_t message_frequency_time = 0;
ReadUIntValue(&message_frequency_time, kDefaultFrequencyTime,
kProtocolHandlerSection, kFrequencyTime);
return message_frequency_time;
}
bool Profile::malformed_message_filtering() const {
bool malformed_message_filtering = 0;
ReadBoolValue(&malformed_message_filtering, kDefaulMalformedMessageFiltering,
kProtocolHandlerSection, kMalformedMessageFiltering);
return malformed_message_filtering;
}
size_t Profile::malformed_frequency_count() const {
size_t malformed_frequency_count = 0;
ReadUIntValue(&malformed_frequency_count, kDefaultMalformedFrequencyCount,
kProtocolHandlerSection, kMalformedFrequencyCount);
return malformed_frequency_count;
}
size_t Profile::malformed_frequency_time() const {
size_t malformed_frequency_time = 0;
ReadUIntValue(&malformed_frequency_time, kDefaultMalformedFrequencyTime,
kProtocolHandlerSection, kMalformedFrequencyTime);
return malformed_frequency_time;
}
uint16_t Profile::attempts_to_open_policy_db() const {
return attempts_to_open_policy_db_;
}
uint16_t Profile::open_attempt_timeout_ms() const {
return open_attempt_timeout_ms_;
}
uint32_t Profile::resumption_delay_before_ign() const {
return resumption_delay_before_ign_;
}
uint32_t Profile::resumption_delay_after_ign() const {
return resumption_delay_after_ign_;
}
uint32_t Profile::hash_string_size() const {
return hash_string_size_;
}
uint16_t Profile::tts_global_properties_timeout() const {
return tts_global_properties_timeout_;
}
void Profile::UpdateValues() {
LOG4CXX_AUTO_TRACE(logger_);
// Launch HMI parameter
std::string launch_value;
if (ReadValue(&launch_value, kHmiSection, kLaunchHMIKey) &&
0 == strcmp("true", launch_value.c_str())) {
launch_hmi_ = true;
} else {
launch_hmi_ = false;
}
LOG_UPDATED_BOOL_VALUE(launch_hmi_, kLaunchHMIKey, kHmiSection);
#ifdef WEB_HMI
// Link to web HMI parameter
ReadStringValue(&link_to_web_hmi_, kDefaultLinkToWebHMI,
kHmiSection, kLinkToWebHMI);
LOG_UPDATED_BOOL_VALUE(link_to_web_hmi_, kLinkToWebHMI, kHmiSection);
#endif // WEB_HMI
// Application config folder
ReadStringValue(&app_config_folder_,
file_system::CurrentWorkingDirectory().c_str(),
kMainSection, kAppConfigFolderKey);
if (IsRelativePath(app_config_folder_)) {
MakeAbsolutePath(app_config_folder_);
}
LOG_UPDATED_VALUE(app_config_folder_, kAppConfigFolderKey, kMainSection);
// Application storage folder
ReadStringValue(&app_storage_folder_,
file_system::CurrentWorkingDirectory().c_str(),
kMainSection, kAppStorageFolderKey);
if (IsRelativePath(app_storage_folder_)) {
MakeAbsolutePath(app_storage_folder_);
}
LOG_UPDATED_VALUE(app_storage_folder_, kAppStorageFolderKey, kMainSection);
// Application resourse folder
ReadStringValue(&app_resourse_folder_,
file_system::CurrentWorkingDirectory().c_str(),
kMainSection, kAppResourseFolderKey);
if (IsRelativePath(app_resourse_folder_)) {
MakeAbsolutePath(app_resourse_folder_);
}
LOG_UPDATED_VALUE(app_resourse_folder_, kAppResourseFolderKey,
kMainSection);
// Enable protocol ver.4 parameter
std::string enable_protocol_4_value;
if (ReadValue(&enable_protocol_4_value, kSDL4Section, kEnableProtocol4Key) &&
0 == strcmp("true", enable_protocol_4_value.c_str())) {
enable_protocol_4_ = true;
} else {
enable_protocol_4_ = false;
}
LOG_UPDATED_BOOL_VALUE(enable_protocol_4_, kEnableProtocol4Key, kSDL4Section);
// Application icon folder
ReadStringValue(&app_icons_folder_,
file_system::CurrentWorkingDirectory().c_str(),
kSDL4Section, kAppIconsFolderKey);
if (IsRelativePath(app_icons_folder_)) {
MakeAbsolutePath(app_icons_folder_);
}
LOG_UPDATED_VALUE(app_icons_folder_, kAppIconsFolderKey,
kSDL4Section);
// Application icon folder maximum size
ReadUIntValue(&app_icons_folder_max_size_, kDefaultAppIconsFolderMaxSize,
kSDL4Section, kAppIconsFolderMaxSizeKey);
if (app_icons_folder_max_size_ < kDefaultAppIconsFolderMaxSize) {
app_icons_folder_max_size_ = kDefaultAppIconsFolderMaxSize;
}
LOG_UPDATED_VALUE(app_icons_folder_max_size_, kAppIconsFolderMaxSizeKey,
kSDL4Section);
// Application icon folder maximum size
ReadUIntValue(&app_icons_amount_to_remove_, kDefaultAppIconsAmountToRemove,
kSDL4Section, kAppIconsAmountToRemoveKey);
LOG_UPDATED_VALUE(app_icons_amount_to_remove_, kAppIconsAmountToRemoveKey,
kSDL4Section);
// Application info file name
ReadStringValue(&app_info_storage_, kDefaultAppInfoFileName,
kAppInfoSection,
kAppInfoStorageKey);
LOG_UPDATED_VALUE(app_info_storage_, kAppInfoStorageKey,
kAppInfoSection);
// Server address
ReadStringValue(&server_address_, kDefaultServerAddress, kHmiSection,
kServerAddressKey);
LOG_UPDATED_VALUE(server_address_, kServerAddressKey, kHmiSection);
// HMI capabilities
ReadStringValue(&hmi_capabilities_file_name_ ,
kDefaultHmiCapabilitiesFileName,
kMainSection, kHmiCapabilitiesKey);
hmi_capabilities_file_name_ = app_config_folder_ + "/" +
hmi_capabilities_file_name_;
LOG_UPDATED_VALUE(hmi_capabilities_file_name_, kHmiCapabilitiesKey,
kMainSection);
// Server port
ReadUIntValue(&server_port_, kDefaultServerPort, kHmiSection,
kServerPortKey);
LOG_UPDATED_VALUE(server_port_, kServerPortKey, kHmiSection);
// Video streaming port
ReadUIntValue(&video_streaming_port_, kDefaultVideoStreamingPort,
kHmiSection, kVideoStreamingPortKey);
LOG_UPDATED_VALUE(video_streaming_port_, kVideoStreamingPortKey,
kHmiSection);
// Audio streaming port
ReadUIntValue(&audio_streaming_port_, kDefaultAudioStreamingPort,
kHmiSection, kAudioStreamingPortKey);
LOG_UPDATED_VALUE(audio_streaming_port_, kAudioStreamingPortKey,
kHmiSection);
// Streaming timeout
ReadUIntValue(&stop_streaming_timeout_, kDefaultStopStreamingTimeout,
kMediaManagerSection, kStopStreamingTimeout);
stop_streaming_timeout_ = std::max(kDefaultStopStreamingTimeout, stop_streaming_timeout_);
LOG_UPDATED_VALUE(stop_streaming_timeout_, kStopStreamingTimeout,
kHmiSection);
// Time testing port
ReadUIntValue(&time_testing_port_, kDefaultTimeTestingPort, kMainSection,
kTimeTestingPortKey);
LOG_UPDATED_VALUE(time_testing_port_, kTimeTestingPortKey, kMainSection);
// Minimum thread stack size
ReadUIntValue(&min_tread_stack_size_, threads::Thread::kMinStackSize,
kMainSection, kThreadStackSizeKey);
if (min_tread_stack_size_ < threads::Thread::kMinStackSize) {
min_tread_stack_size_ = threads::Thread::kMinStackSize;
}
LOG_UPDATED_VALUE(min_tread_stack_size_, kThreadStackSizeKey, kMainSection);
// Start stream retry frequency
ReadUintIntPairValue(&start_stream_retry_amount_, kStartStreamRetryAmount,
kMediaManagerSection, kStartStreamRetry);
// Redecoding parameter
std::string redecoding_value;
if (ReadValue(&redecoding_value, kMediaManagerSection, kEnableRedecodingKey)
&& 0 == strcmp("true", redecoding_value.c_str())) {
is_redecoding_enabled_ = true;
} else {
is_redecoding_enabled_ = false;
}
LOG_UPDATED_BOOL_VALUE(is_redecoding_enabled_, kEnableRedecodingKey,
kMediaManagerSection);
// Video consumer type
ReadStringValue(&video_consumer_type_, "", kMediaManagerSection,
kVideoStreamConsumerKey);
LOG_UPDATED_VALUE(video_consumer_type_, kVideoStreamConsumerKey,
kMediaManagerSection);
// Audio stream consumer
ReadStringValue(&audio_consumer_type_, "", kMediaManagerSection,
kAudioStreamConsumerKey);
LOG_UPDATED_VALUE(audio_consumer_type_, kAudioStreamConsumerKey,
kMediaManagerSection);
// Named video pipe path
ReadStringValue(&named_video_pipe_path_, "", kMediaManagerSection,
kNamedVideoPipePathKey);
named_video_pipe_path_ = app_storage_folder_ + "/" + named_video_pipe_path_;
LOG_UPDATED_VALUE(named_video_pipe_path_, kNamedVideoPipePathKey,
kMediaManagerSection);
// Named audio pipe path
ReadStringValue(&named_audio_pipe_path_, "", kMediaManagerSection,
kNamedAudioPipePathKey);
named_audio_pipe_path_ = app_storage_folder_ + "/" + named_audio_pipe_path_;
LOG_UPDATED_VALUE(named_audio_pipe_path_, kNamedAudioPipePathKey,
kMediaManagerSection);
// Video stream file
ReadStringValue(&video_stream_file_, "", kMediaManagerSection,
kVideoStreamFileKey);
video_stream_file_ = app_storage_folder_ + "/" + video_stream_file_;
LOG_UPDATED_VALUE(video_stream_file_, kVideoStreamFileKey,
kMediaManagerSection);
// Audio stream file
ReadStringValue(&audio_stream_file_, "", kMediaManagerSection,
kAudioStreamFileKey);
audio_stream_file_ = app_storage_folder_ + "/" + audio_stream_file_;
LOG_UPDATED_VALUE(audio_stream_file_, kAudioStreamFileKey,
kMediaManagerSection);
ReadUIntValue(&audio_data_stopped_timeout_, kDefaultAudioDataStoppedTimeout,
kMediaManagerSection, kAudioDataStoppedTimeoutKey);
LOG_UPDATED_VALUE(audio_data_stopped_timeout_, kAudioDataStoppedTimeoutKey,
kMediaManagerSection);
ReadUIntValue(&video_data_stopped_timeout_, kDefaultVideoDataStoppedTimeout,
kMediaManagerSection, kVideoDataStoppedTimeoutKey);
LOG_UPDATED_VALUE(video_data_stopped_timeout_, kVideoDataStoppedTimeoutKey,
kMediaManagerSection);
// Mixing audio parameter
std::string mixing_audio_value;
if (ReadValue(&mixing_audio_value, kMainSection, kMixingAudioSupportedKey)
&& 0 == strcmp("true", mixing_audio_value.c_str())) {
is_mixing_audio_supported_ = true;
} else {
is_mixing_audio_supported_ = false;
}
LOG_UPDATED_BOOL_VALUE(is_mixing_audio_supported_, kMixingAudioSupportedKey,
kMainSection);
// Maximum command id value
ReadUIntValue(&max_cmd_id_, kDefaultMaxCmdId, kMainSection, kMaxCmdIdKey);
LOG_UPDATED_VALUE(max_cmd_id_, kMaxCmdIdKey, kMainSection);
// PutFile restrictions
ReadUIntValue(&put_file_in_none_, kDefaultPutFileRequestInNone,
kFilesystemRestrictionsSection, kPutFileRequestKey);
LOG_UPDATED_VALUE(put_file_in_none_, kPutFileRequestKey,
kFilesystemRestrictionsSection);
// DeleteFileRestrictions
ReadUIntValue(&delete_file_in_none_, kDefaultDeleteFileRequestInNone,
kFilesystemRestrictionsSection, kDeleteFileRequestKey);
LOG_UPDATED_VALUE(delete_file_in_none_, kDeleteFileRequestKey,
kFilesystemRestrictionsSection);
// ListFiles restrictions
ReadUIntValue(&list_files_in_none_, kDefaultListFilesRequestInNone,
kFilesystemRestrictionsSection, kListFilesRequestKey);
LOG_UPDATED_VALUE(list_files_in_none_, kListFilesRequestKey,
kFilesystemRestrictionsSection);
// Default timeout
ReadUIntValue(&default_timeout_, kDefaultTimeout, kMainSection,
kDefaultTimeoutKey);
if (default_timeout_ == 0) {
default_timeout_ = kDefaultTimeout;
}
LOG_UPDATED_VALUE(default_timeout_, kDefaultTimeoutKey, kMainSection);
// Application resuming timeout
ReadUIntValue(&app_resuming_timeout_, kDefaultAppResumingTimeout,
kResumptionSection, kAppResumingTimeoutKey);
if (app_resuming_timeout_ == 0) {
app_resuming_timeout_ = kDefaultAppResumingTimeout;
}
// Save resumption info to File System
LOG_UPDATED_VALUE(app_resuming_timeout_, kAppSavePersistentDataTimeoutKey,
kResumptionSection);
ReadUIntValue(&app_resumption_save_persistent_data_timeout_,
kDefaultAppSavePersistentDataTimeout,
kResumptionSection, kAppSavePersistentDataTimeoutKey);
if (app_resuming_timeout_ == 0) {
app_resuming_timeout_ = kDefaultAppSavePersistentDataTimeout;
}
LOG_UPDATED_VALUE(app_resuming_timeout_, kAppResumingTimeoutKey,
kResumptionSection);
// Open attempt timeout in ms
ReadUIntValue(&resumption_delay_before_ign_,
kDefaultResumptionDelayBeforeIgn,
kResumptionSection,
kResumptionDelayBeforeIgnKey);
LOG_UPDATED_VALUE(resumption_delay_before_ign_,
kResumptionDelayBeforeIgnKey, kResumptionSection);
// Open attempt timeout in ms
ReadUIntValue(&resumption_delay_after_ign_,
kDefaultResumptionDelayAfterIgn,
kResumptionSection,
kResumptionDelayAfterIgnKey);
LOG_UPDATED_VALUE(resumption_delay_after_ign_,
kResumptionDelayAfterIgnKey, kResumptionSection);
// Application directory quota
ReadUIntValue(&app_dir_quota_, kDefaultDirQuota, kMainSection,
kAppDirectoryQuotaKey);
if (app_dir_quota_ == 0) {
app_dir_quota_ = kDefaultDirQuota;
}
LOG_UPDATED_VALUE(app_dir_quota_, kAppDirectoryQuotaKey, kMainSection);
// TTS delimiter
// Should be gotten before any TTS prompts, since it should be appended back
ReadStringValue(&tts_delimiter_, kDefaultTtsDelimiter,
kGlobalPropertiesSection, kTTSDelimiterKey);
LOG_UPDATED_VALUE(tts_delimiter_, kTTSDelimiterKey,
kGlobalPropertiesSection);
// Help prompt
help_prompt_.clear();
std::string help_prompt_value;
if (ReadValue(&help_prompt_value, kGlobalPropertiesSection,
kHelpPromptKey)) {
char* str = NULL;
str = strtok(const_cast<char*>(help_prompt_value.c_str()), ",");
while (str != NULL) {
// Default prompt should have delimiter included for each item
const std::string prompt_item = std::string(str) + tts_delimiter_;
help_prompt_.push_back(prompt_item);
LOG_UPDATED_VALUE(prompt_item, kHelpPromptKey,
kGlobalPropertiesSection);
str = strtok(NULL, ",");
}
} else {
help_prompt_value.clear();
LOG_UPDATED_VALUE(help_prompt_value, kHelpPromptKey,
kGlobalPropertiesSection);
}
// Timeout prompt
time_out_promt_.clear();
std::string timeout_prompt_value;
if (ReadValue(&timeout_prompt_value, kGlobalPropertiesSection,
kTimeoutPromptKey)) {
char* str = NULL;
str = strtok(const_cast<char*>(timeout_prompt_value.c_str()), ",");
while (str != NULL) {
// Default prompt should have delimiter included for each item
const std::string prompt_item = std::string(str) + tts_delimiter_;
time_out_promt_.push_back(prompt_item);
LOG_UPDATED_VALUE(prompt_item, kTimeoutPromptKey,
kGlobalPropertiesSection);
str = strtok(NULL, ",");
}
} else {
timeout_prompt_value.clear();
LOG_UPDATED_VALUE(timeout_prompt_value, kTimeoutPromptKey,
kGlobalPropertiesSection);
}
// Voice recognition help title
ReadStringValue(&vr_help_title_, "", kGlobalPropertiesSection,
kHelpTitleKey);
LOG_UPDATED_VALUE(vr_help_title_, kHelpTitleKey,
kGlobalPropertiesSection);
// Voice recognition help command
vr_commands_.clear();
std::string vr_help_command_value;
if (ReadValue(&vr_help_command_value, kVrCommandsSection,
kHelpCommandKey)) {
char* str = NULL;
str = strtok(const_cast<char*>(vr_help_command_value.c_str()), ",");
while (str != NULL) {
const std::string vr_item = str;
vr_commands_.push_back(vr_item);
LOG_UPDATED_VALUE(vr_item, kHelpCommandKey, kVrCommandsSection);
str = strtok(NULL, ",");
}
} else {
vr_help_command_value.clear();
LOG_UPDATED_VALUE(vr_help_command_value, kHelpCommandKey,
kVrCommandsSection);
}
//TTS GlobalProperties timeout
ReadUIntValue(&tts_global_properties_timeout_,
kDefaultTTSGlobalPropertiesTimeout,
kGlobalPropertiesSection,
kTTSGlobalPropertiesTimeoutKey);
LOG_UPDATED_VALUE(tts_global_properties_timeout_, kTTSGlobalPropertiesTimeoutKey,
kGlobalPropertiesSection);
// Application time scale maximum requests
ReadUIntValue(&app_time_scale_max_requests_,
kDefaultAppTimeScaleMaxRequests,
kMainSection,
kAppTimeScaleMaxRequestsKey);
LOG_UPDATED_VALUE(app_time_scale_max_requests_, kAppTimeScaleMaxRequestsKey,
kMainSection);
// Application time scale
ReadUIntValue(&app_requests_time_scale_, kDefaultAppRequestsTimeScale,
kMainSection, kAppRequestsTimeScaleKey);
LOG_UPDATED_VALUE(app_requests_time_scale_, kAppRequestsTimeScaleKey,
kMainSection);
// Application HMI level NONE time scale maximum requests
ReadUIntValue(&app_hmi_level_none_time_scale_max_requests_,
kDefaultAppHmiLevelNoneTimeScaleMaxRequests,
kMainSection,
kAppHmiLevelNoneTimeScaleMaxRequestsKey);
LOG_UPDATED_VALUE(app_hmi_level_none_time_scale_max_requests_,
kAppHmiLevelNoneTimeScaleMaxRequestsKey,
kMainSection);
// Application HMI level NONE requests time scale
ReadUIntValue(&app_hmi_level_none_requests_time_scale_,
kDefaultAppHmiLevelNoneRequestsTimeScale,
kMainSection,
kAppHmiLevelNoneRequestsTimeScaleKey);
LOG_UPDATED_VALUE(app_hmi_level_none_requests_time_scale_,
kAppHmiLevelNoneRequestsTimeScaleKey,
kMainSection);
// Amount of pending requests
ReadUIntValue(&pending_requests_amount_, kDefaultPendingRequestsAmount,
kMainSection, kPendingRequestsAmoundKey);
if (pending_requests_amount_ == 0) {
pending_requests_amount_ = kDefaultPendingRequestsAmount;
}
LOG_UPDATED_VALUE(pending_requests_amount_, kPendingRequestsAmoundKey,
kMainSection);
// Supported diagnostic modes
supported_diag_modes_.clear();
std::string supported_diag_modes_value;
std::string correct_diag_modes;
if (ReadStringValue(&supported_diag_modes_value, "", kMainSection,
kSupportedDiagModesKey)) {
char* str = NULL;
str = strtok(const_cast<char*>(supported_diag_modes_value.c_str()), ",");
while (str != NULL) {
errno = 0;
uint32_t user_value = strtol(str, NULL, 16);
if (user_value && errno != ERANGE) {
correct_diag_modes += str;
correct_diag_modes += ",";
supported_diag_modes_.push_back(user_value);
}
str = strtok(NULL, ",");
}
}
LOG_UPDATED_VALUE(correct_diag_modes, kSupportedDiagModesKey, kMainSection);
// System files path
ReadStringValue(&system_files_path_, kDefaultSystemFilesPath, kMainSection,
kSystemFilesPathKey);
LOG_UPDATED_VALUE(system_files_path_, kSystemFilesPathKey, kMainSection);
// Heartbeat timeout
ReadUIntValue(&heart_beat_timeout_, kDefaultHeartBeatTimeout, kMainSection,
kHeartBeatTimeoutKey);
LOG_UPDATED_VALUE(heart_beat_timeout_, kHeartBeatTimeoutKey, kMainSection);
// Use last state value
std::string last_state_value;
if (ReadValue(&last_state_value, kMainSection, kUseLastStateKey) &&
0 == strcmp("true", last_state_value.c_str())) {
use_last_state_ = true;
} else {
use_last_state_ = false;
}
LOG_UPDATED_BOOL_VALUE(use_last_state_, kUseLastStateKey, kMainSection);
// Transport manager TCP port
ReadUIntValue(&transport_manager_tcp_adapter_port_,
kDefautTransportManagerTCPPort,
kTransportManagerSection,
kTCPAdapterPortKey);
LOG_UPDATED_VALUE(transport_manager_tcp_adapter_port_, kTCPAdapterPortKey,
kTransportManagerSection);
// MME database name
ReadStringValue(&mme_db_name_,
kDefaultMmeDatabaseName,
kTransportManagerSection,
kMmeDatabaseNameKey);
LOG_UPDATED_VALUE(mme_db_name_, kMmeDatabaseNameKey, kTransportManagerSection);
// Event MQ
ReadStringValue(&event_mq_name_,
kDefaultEventMQ,
kTransportManagerSection,
kEventMQKey);
LOG_UPDATED_VALUE(event_mq_name_, kEventMQKey, kTransportManagerSection);
// Ack MQ
ReadStringValue(&ack_mq_name_,
kDefaultAckMQ,
kTransportManagerSection,
kAckMQKey);
LOG_UPDATED_VALUE(ack_mq_name_, kAckMQKey, kTransportManagerSection);
// Transport manager disconnect timeout
ReadUIntValue(&transport_manager_disconnect_timeout_,
kDefaultTransportManagerDisconnectTimeout,
kTransportManagerSection,
kTransportManagerDisconnectTimeoutKey);
LOG_UPDATED_VALUE(transport_manager_disconnect_timeout_,
kTransportManagerDisconnectTimeoutKey,
kTransportManagerSection);
// Recording file
ReadStringValue(&recording_file_name_, kDefaultRecordingFileName,
kMediaManagerSection, kRecordingFileNameKey);
LOG_UPDATED_VALUE(recording_file_name_, kRecordingFileNameKey, kMediaManagerSection);
// Recording file source
ReadStringValue(&recording_file_source_, kDefaultRecordingFileSourceName,
kMediaManagerSection, kRecordingFileSourceKey);
LOG_UPDATED_VALUE(recording_file_source_, kRecordingFileSourceKey,
kMediaManagerSection);
// Policy preloaded file
ReadStringValue(&preloaded_pt_file_,
kDefaultPreloadedPTFileName,
kPolicySection, kPreloadedPTKey);
preloaded_pt_file_ = app_config_folder_ + '/' + preloaded_pt_file_;
LOG_UPDATED_VALUE(preloaded_pt_file_, kPreloadedPTKey, kPolicySection);
// Policy snapshot file
ReadStringValue(&policy_snapshot_file_name_,
kDefaultPoliciesSnapshotFileName,
kPolicySection, kPathToSnapshotKey);
LOG_UPDATED_VALUE(policy_snapshot_file_name_, kPathToSnapshotKey,
kPolicySection);
// Attempts number for opening policy DB
ReadUIntValue(&attempts_to_open_policy_db_,
kDefaultAttemptsToOpenPolicyDB,
kPolicySection,
kAttemptsToOpenPolicyDBKey);
LOG_UPDATED_VALUE(attempts_to_open_policy_db_,
kAttemptsToOpenPolicyDBKey, kPolicySection);
// Open attempt timeout in ms
ReadUIntValue(&open_attempt_timeout_ms_,
kDefaultOpenAttemptTimeoutMsKey,
kPolicySection,
kOpenAttemptTimeoutMsKey);
LOG_UPDATED_VALUE(open_attempt_timeout_ms_,
kOpenAttemptTimeoutMsKey, kPolicySection);
// Turn Policy Off?
std::string enable_policy_string;
if (ReadValue(&enable_policy_string, kPolicySection, kEnablePolicy) &&
0 == strcmp("true", enable_policy_string.c_str())) {
enable_policy_ = true;
} else {
enable_policy_ = false;
}
LOG_UPDATED_BOOL_VALUE(enable_policy_, kEnablePolicy, kPolicySection);
ReadUIntValue(&application_list_update_timeout_,
kDefaultApplicationListUpdateTimeout,
kApplicationManagerSection,
kApplicationListUpdateTimeoutKey);
LOG_UPDATED_VALUE(application_list_update_timeout_,
kApplicationListUpdateTimeoutKey, kMainSection);
ReadUintIntPairValue(&read_did_frequency_, kReadDIDFrequency,
kMainSection, kReadDIDFrequencykey);
ReadUintIntPairValue(&get_vehicle_data_frequency_, kGetVehicleDataFrequency,
kMainSection, kGetVehicleDataFrequencyKey);
ReadUIntValue(&max_thread_pool_size_,
kDefaultMaxThreadPoolSize,
kApplicationManagerSection,
kDefaultThreadPoolSize);
if (max_thread_pool_size_ > kDefaultMaxThreadPoolSize) {
max_thread_pool_size_ = kDefaultMaxThreadPoolSize;
}
LOG_UPDATED_VALUE(max_thread_pool_size_,
kDefaultMaxThreadPoolSize, kApplicationManagerSection);
ReadStringValue(&iap_legacy_protocol_mask_,
kDefaultLegacyProtocolMask,
kIAPSection,
kLegacyProtocolMaskKey);
LOG_UPDATED_VALUE(iap_legacy_protocol_mask_, kLegacyProtocolMaskKey, kIAPSection);
ReadStringValue(&iap_hub_protocol_mask_,
kDefaultHubProtocolMask,
kIAPSection,
kHubProtocolMaskKey);
LOG_UPDATED_VALUE(iap_hub_protocol_mask_, kHubProtocolMaskKey, kIAPSection);
ReadStringValue(&iap_pool_protocol_mask_,
kDefaultPoolProtocolMask,
kIAPSection,
kPoolProtocolMaskKey);
LOG_UPDATED_VALUE(iap_pool_protocol_mask_, kPoolProtocolMaskKey, kIAPSection);
ReadStringValue(&iap_system_config_,
kDefaultIAPSystemConfig,
kIAPSection,
kIAPSystemConfigKey);
LOG_UPDATED_VALUE(iap_system_config_, kIAPSystemConfigKey, kIAPSection);
ReadStringValue(&iap2_system_config_,
kDefaultIAP2SystemConfig,
kIAPSection,
kIAP2SystemConfigKey);
LOG_UPDATED_VALUE(iap2_system_config_, kIAP2SystemConfigKey, kIAPSection);
ReadIntValue(&iap2_hub_connect_attempts_,
kDefaultIAP2HubConnectAttempts,
kIAPSection,
kIAP2HubConnectAttemptskey);
LOG_UPDATED_VALUE(iap2_hub_connect_attempts_, kIAP2HubConnectAttemptskey, kIAPSection);
ReadIntValue(&iap_hub_connection_wait_timeout_,
kDefaultIAPHubConnectionWaitTimeout,
kIAPSection,
kIAPHubConnectionWaitTimeoutKey);
LOG_UPDATED_VALUE(iap_hub_connection_wait_timeout_,
kIAPHubConnectionWaitTimeoutKey, kIAPSection);
ReadUIntValue(&default_hub_protocol_index_, kDefaultHubProtocolIndex, kIAPSection, kDefaultHubProtocolIndexKey);
LOG_UPDATED_VALUE(default_hub_protocol_index_, kDefaultHubProtocolIndexKey, kIAPSection);
ReadUIntValue(&hash_string_size_,
kDefaultHashStringSize,
kApplicationManagerSection,
kHashStringSizeKey);
LOG_UPDATED_VALUE(hash_string_size_,
kHashStringSizeKey,
kApplicationManagerSection);
}
bool Profile::ReadValue(bool* value, const char* const pSection,
const char* const pKey) const {
DCHECK(value);
bool ret = false;
char buf[INI_LINE_LEN + 1];
*buf = '\0';
if ((0 != ini_read_value(config_file_name_.c_str(), pSection, pKey, buf))
&& ('\0' != *buf)) {
const int32_t tmpVal = atoi(buf);
if (0 == tmpVal) {
*value = false;
} else {
*value = true;
}
ret = true;
}
return ret;
}
bool Profile::ReadValue(std::string* value, const char* const pSection,
const char* const pKey) const {
DCHECK(value);
bool ret = false;
char buf[INI_LINE_LEN + 1];
*buf = '\0';
if ((0 != ini_read_value(config_file_name_.c_str(), pSection, pKey, buf))
&& ('\0' != *buf)) {
*value = buf;
ret = true;
}
return ret;
}
bool Profile::ReadStringValue(std::string* value, const char* default_value,
const char* const pSection,
const char* const pKey) const {
DCHECK(value);
if (!ReadValue(value, pSection, pKey)) {
*value = default_value;
return false;
}
return true;
}
bool Profile::ReadIntValue(int32_t* value, const int32_t default_value,
const char* const pSection,
const char* const pKey) const {
DCHECK(value);
std::string string_value;
if (!ReadValue(&string_value, pSection, pKey)) {
*value = default_value;
return false;
}
*value = atoi(string_value.c_str());
return true;
}
bool Profile::ReadUintIntPairValue(std::pair<uint32_t, int32_t>* value,
const std::pair<uint32_t, uint32_t>& default_value,
const char *const pSection,
const char *const pKey) const {
std::string string_value;
if (!ReadValue(&string_value, pSection, pKey)) {
*value = default_value;
return false;
}
std::string first_str = string_value.substr(0, string_value.find(","));
std::string second_str = string_value.substr(string_value.find(",") + 1,
string_value.size() - first_str.size());
(*value).first = strtoul(first_str.c_str(), NULL, 10);
(*value).second = strtoul(second_str.c_str(), NULL, 10);
return true;
}
bool Profile::ReadBoolValue(bool* value, const bool default_value,
const char* const pSection,
const char* const pKey) const {
DCHECK(value);
bool read_value;
const bool result = ReadValue(&read_value, pSection, pKey);
*value = result ? read_value : default_value;
return result;
}
namespace {
int32_t hex_to_int(const std::string& value) {
return static_cast<int32_t>(strtol(value.c_str(), NULL, 16));
}
}
std::list<int> Profile::ReadIntContainer(
const char * const pSection, const char * const pKey,
bool *out_result) const {
const std::list<std::string> string_list =
ReadStringContainer(pSection, pKey, out_result);
std::list<int> value_list;
value_list.resize(string_list.size());
std::transform(string_list.begin(), string_list.end(),
value_list.begin(), hex_to_int);
return value_list;
}
std::list<std::string> Profile::ReadStringContainer(
const char * const pSection, const char * const pKey,
bool *out_result) const {
std::string string;
const bool result = ReadValue(&string, pSection, pKey);
if (out_result)
*out_result = result;
std::list < std::string > value_container;
if (result) {
std::istringstream iss(string);
std::string temp_str;
while (iss) {
if (!getline( iss, temp_str, ',' )) break;
value_container.push_back(temp_str);
}
}
return value_container;
}
bool Profile::ReadUIntValue(uint16_t* value, uint16_t default_value,
const char* const pSection,
const char* const pKey) const {
std::string string_value;
if (!ReadValue(&string_value, pSection, pKey)) {
*value = default_value;
return false;
} else {
uint64_t user_value;
if (!StringToNumber(string_value, user_value)) {
*value = default_value;
return false;
}
*value = static_cast<uint16_t>(user_value);
return true;
}
}
bool Profile::ReadUIntValue(uint32_t* value, uint32_t default_value,
const char* const pSection,
const char* const pKey) const {
std::string string_value;
if (!ReadValue(&string_value, pSection, pKey)) {
*value = default_value;
return false;
} else {
uint64_t user_value;
if (!StringToNumber(string_value, user_value)) {
*value = default_value;
return false;
}
*value = static_cast<uint32_t>(user_value);
return true;
}
}
bool Profile::ReadUIntValue(uint64_t* value, uint64_t default_value,
const char* const pSection,
const char* const pKey) const {
std::string string_value;
if (!ReadValue(&string_value, pSection, pKey)) {
*value = default_value;
return false;
} else {
uint64_t user_value;
if (!StringToNumber(string_value, user_value)) {
*value = default_value;
return false;
}
*value = user_value;
return true;
}
}
bool Profile::StringToNumber(const std::string& input, uint64_t& output) const {
const char* input_value = input.c_str();
char* endptr;
const int8_t base = 10;
errno = 0;
uint64_t user_value = strtoull(input_value, &endptr, base);
bool is_real_zero_value =
(!user_value && endptr != input_value && *endptr == '\0');
if (!is_real_zero_value && (!user_value || errno == ERANGE)) {
return false;
}
output = user_value;
return true;
}
bool Profile::IsRelativePath(const std::string& path) {
if (path.empty()) {
LOG4CXX_ERROR(logger_, "Empty path passed.");
return false;
}
return '/' != path[0];
}
void Profile::MakeAbsolutePath(std::string& path) {
path = file_system::CurrentWorkingDirectory() + "/" + path;
}
}// namespace profile
|